net/tls: add skeleton of MIB statistics
Add a skeleton structure for adding TLS statistics. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
9ec1c6ac27
commit
d26b698dd3
@@ -7,7 +7,7 @@ CFLAGS_trace.o := -I$(src)
|
||||
|
||||
obj-$(CONFIG_TLS) += tls.o
|
||||
|
||||
tls-y := tls_main.o tls_sw.o trace.o
|
||||
tls-y := tls_main.o tls_sw.o tls_proc.o trace.o
|
||||
|
||||
tls-$(CONFIG_TLS_TOE) += tls_toe.o
|
||||
tls-$(CONFIG_TLS_DEVICE) += tls_device.o tls_device_fallback.o
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <linux/inetdevice.h>
|
||||
#include <linux/inet_diag.h>
|
||||
|
||||
#include <net/snmp.h>
|
||||
#include <net/tls.h>
|
||||
#include <net/tls_toe.h>
|
||||
|
||||
@@ -795,6 +796,35 @@ static size_t tls_get_info_size(const struct sock *sk)
|
||||
return size;
|
||||
}
|
||||
|
||||
static int __net_init tls_init_net(struct net *net)
|
||||
{
|
||||
int err;
|
||||
|
||||
net->mib.tls_statistics = alloc_percpu(struct linux_tls_mib);
|
||||
if (!net->mib.tls_statistics)
|
||||
return -ENOMEM;
|
||||
|
||||
err = tls_proc_init(net);
|
||||
if (err)
|
||||
goto err_free_stats;
|
||||
|
||||
return 0;
|
||||
err_free_stats:
|
||||
free_percpu(net->mib.tls_statistics);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __net_exit tls_exit_net(struct net *net)
|
||||
{
|
||||
tls_proc_fini(net);
|
||||
free_percpu(net->mib.tls_statistics);
|
||||
}
|
||||
|
||||
static struct pernet_operations tls_proc_ops = {
|
||||
.init = tls_init_net,
|
||||
.exit = tls_exit_net,
|
||||
};
|
||||
|
||||
static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = {
|
||||
.name = "tls",
|
||||
.owner = THIS_MODULE,
|
||||
@@ -806,6 +836,12 @@ static struct tcp_ulp_ops tcp_tls_ulp_ops __read_mostly = {
|
||||
|
||||
static int __init tls_register(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = register_pernet_subsys(&tls_proc_ops);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
tls_sw_proto_ops = inet_stream_ops;
|
||||
tls_sw_proto_ops.splice_read = tls_sw_splice_read;
|
||||
|
||||
@@ -819,6 +855,7 @@ static void __exit tls_unregister(void)
|
||||
{
|
||||
tcp_unregister_ulp(&tcp_tls_ulp_ops);
|
||||
tls_device_cleanup();
|
||||
unregister_pernet_subsys(&tls_proc_ops);
|
||||
}
|
||||
|
||||
module_init(tls_register);
|
||||
|
37
net/tls/tls_proc.c
Normal file
37
net/tls/tls_proc.c
Normal file
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
/* Copyright (C) 2019 Netronome Systems, Inc. */
|
||||
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <net/snmp.h>
|
||||
#include <net/tls.h>
|
||||
|
||||
static const struct snmp_mib tls_mib_list[] = {
|
||||
SNMP_MIB_SENTINEL
|
||||
};
|
||||
|
||||
static int tls_statistics_seq_show(struct seq_file *seq, void *v)
|
||||
{
|
||||
unsigned long buf[LINUX_MIB_TLSMAX] = {};
|
||||
struct net *net = seq->private;
|
||||
int i;
|
||||
|
||||
snmp_get_cpu_field_batch(buf, tls_mib_list, net->mib.tls_statistics);
|
||||
for (i = 0; tls_mib_list[i].name; i++)
|
||||
seq_printf(seq, "%-32s\t%lu\n", tls_mib_list[i].name, buf[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __net_init tls_proc_init(struct net *net)
|
||||
{
|
||||
if (!proc_create_net_single("tls_stat", 0444, net->proc_net,
|
||||
tls_statistics_seq_show, NULL))
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __net_exit tls_proc_fini(struct net *net)
|
||||
{
|
||||
remove_proc_entry("tls_stat", net->proc_net);
|
||||
}
|
Reference in New Issue
Block a user