Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NETNS]: struct net content re-work (v3)

Recently David Miller and Herbert Xu pointed out that struct net becomes
overbloated and un-maintainable. There are two solutions:
- provide a pointer to a network subsystem definition from struct net.
This costs an additional dereferrence
- place sub-system definition into the structure itself. This will speedup
run-time access at the cost of recompilation time

The second approach looks better for us. Other sub-systems will follow.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Denis V. Lunev and committed by
David S. Miller
a0a53c8b 27147c9e

+24 -11
+3 -3
include/net/net_namespace.h
··· 8 8 #include <linux/workqueue.h> 9 9 #include <linux/list.h> 10 10 11 + #include <net/netns/unix.h> 12 + 11 13 struct proc_dir_entry; 12 14 struct net_device; 13 15 struct sock; ··· 47 45 rwlock_t packet_sklist_lock; 48 46 struct hlist_head packet_sklist; 49 47 50 - /* unix sockets */ 51 - int sysctl_unix_max_dgram_qlen; 52 - struct ctl_table_header *unix_ctl; 48 + struct netns_unix unx; 53 49 }; 54 50 55 51 #ifdef CONFIG_NET
+13
include/net/netns/unix.h
··· 1 + /* 2 + * Unix network namespace 3 + */ 4 + #ifndef __NETNS_UNIX_H__ 5 + #define __NETNS_UNIX_H__ 6 + 7 + struct ctl_table_header; 8 + struct netns_unix { 9 + int sysctl_max_dgram_qlen; 10 + struct ctl_table_header *ctl; 11 + }; 12 + 13 + #endif /* __NETNS_UNIX_H__ */
+2 -2
net/unix/af_unix.c
··· 592 592 &af_unix_sk_receive_queue_lock_key); 593 593 594 594 sk->sk_write_space = unix_write_space; 595 - sk->sk_max_ack_backlog = net->sysctl_unix_max_dgram_qlen; 595 + sk->sk_max_ack_backlog = net->unx.sysctl_max_dgram_qlen; 596 596 sk->sk_destruct = unix_sock_destructor; 597 597 u = unix_sk(sk); 598 598 u->dentry = NULL; ··· 2138 2138 { 2139 2139 int error = -ENOMEM; 2140 2140 2141 - net->sysctl_unix_max_dgram_qlen = 10; 2141 + net->unx.sysctl_max_dgram_qlen = 10; 2142 2142 if (unix_sysctl_register(net)) 2143 2143 goto out; 2144 2144
+6 -6
net/unix/sysctl_net_unix.c
··· 18 18 { 19 19 .ctl_name = NET_UNIX_MAX_DGRAM_QLEN, 20 20 .procname = "max_dgram_qlen", 21 - .data = &init_net.sysctl_unix_max_dgram_qlen, 21 + .data = &init_net.unx.sysctl_max_dgram_qlen, 22 22 .maxlen = sizeof(int), 23 23 .mode = 0644, 24 24 .proc_handler = &proc_dointvec ··· 40 40 if (table == NULL) 41 41 goto err_alloc; 42 42 43 - table[0].data = &net->sysctl_unix_max_dgram_qlen; 44 - net->unix_ctl = register_net_sysctl_table(net, unix_path, table); 45 - if (net->unix_ctl == NULL) 43 + table[0].data = &net->unx.sysctl_max_dgram_qlen; 44 + net->unx.ctl = register_net_sysctl_table(net, unix_path, table); 45 + if (net->unx.ctl == NULL) 46 46 goto err_reg; 47 47 48 48 return 0; ··· 57 57 { 58 58 struct ctl_table *table; 59 59 60 - table = net->unix_ctl->ctl_table_arg; 61 - unregister_sysctl_table(net->unix_ctl); 60 + table = net->unx.ctl->ctl_table_arg; 61 + unregister_sysctl_table(net->unx.ctl); 62 62 kfree(table); 63 63 } 64 64