Commit a0a53c8ba95451feef6c1975016f0a1eb3044ad4

Authored by Denis V. Lunev
Committed by David S. Miller
1 parent 27147c9e6e

[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>

Showing 4 changed files with 24 additions and 11 deletions Side-by-side Diff

include/net/net_namespace.h
... ... @@ -8,6 +8,8 @@
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;
... ... @@ -45,9 +47,7 @@
45 47 rwlock_t packet_sklist_lock;
46 48 struct hlist_head packet_sklist;
47 49  
48   - /* unix sockets */
49   - int sysctl_unix_max_dgram_qlen;
50   - struct ctl_table_header *unix_ctl;
  50 + struct netns_unix unx;
51 51 };
52 52  
53 53 #ifdef CONFIG_NET
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__ */
... ... @@ -592,7 +592,7 @@
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,7 +2138,7 @@
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  
net/unix/sysctl_net_unix.c
... ... @@ -18,7 +18,7 @@
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,9 +40,9 @@
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,8 +57,8 @@
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 }