[RFC PATCH 1/7] net: Add a /sys/net directory to sysfs

schumaker.anna
2021-01-11T21:42:42Z

Sunrpc will want to place its files under this directory

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
include/net/sock.h | 4 ++++
net/socket.c | 8 ++++++++
2 files changed, 12 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index bdc4323ce53c..cd986c6fbc6f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1765,6 +1765,10 @@ void sk_common_release(struct sock *sk);
/* Initialise core socket variables */
void sock_init_data(struct socket *sock, struct sock *sk);

+
+/* /sys/net */
+extern struct kobject *net_kobj;
+
/*
* Socket reference counting postulates.
*
diff --git a/net/socket.c b/net/socket.c
index 33e8b6c4e1d3..43986419d673 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -141,6 +141,10 @@ static void sock_show_fdinfo(struct seq_file *m, struct file *f)
#define sock_show_fdinfo NULL
#endif

+/* /sys/net */
+struct kobject *net_kobj;
+EXPORT_SYMBOL_GPL(net_kobj);
+
/*
* Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
* in the operation structures but are done directly via the socketcall() multiplexor.
@@ -3060,6 +3064,10 @@ static int __init sock_init(void)
goto out_mount;
}

+ net_kobj = kobject_create_and_add("net", NULL);
+ if (!net_kobj)
+ printk(KERN_WARNING "%s: kobj create error\n", __func__);
+
/* The real protocol initialization is performed in later initcalls.
*/

--
2.29.2