diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-09-28 17:10:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-01 00:59:38 -0400 |
commit | 0bbf87d852d243680ed7074110ccc1dea003b61a (patch) | |
tree | 016273c3e3e097096a94b10f590437acbb61ece7 /net/ipv4/inet_connection_sock.c | |
parent | 56d7b53f47e7c9a0ab1c6289f2669a8d3a65cf17 (diff) |
net ipv4: Convert ipv4.ip_local_port_range to be per netns v3
- Move sysctl_local_ports from a global variable into struct netns_ipv4.
- Modify inet_get_local_port_range to take a struct net, and update all
of the callers.
- Move the initialization of sysctl_local_ports into
sysctl_net_ipv4.c:ipv4_sysctl_init_net from inet_connection_sock.c
v2:
- Ensure indentation used tabs
- Fixed ip.h so it applies cleanly to todays net-next
v3:
- Compile fixes of strange callers of inet_get_local_port_range.
This patch now successfully passes an allmodconfig build.
Removed manual inlining of inet_get_local_port_range in ipv4_local_port_range
Originally-by: Samya <samya@twitter.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_connection_sock.c')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 6acb541c9091..7ac7aa11130e 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -29,27 +29,19 @@ const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n"; | |||
29 | EXPORT_SYMBOL(inet_csk_timer_bug_msg); | 29 | EXPORT_SYMBOL(inet_csk_timer_bug_msg); |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | /* | ||
33 | * This struct holds the first and last local port number. | ||
34 | */ | ||
35 | struct local_ports sysctl_local_ports __read_mostly = { | ||
36 | .lock = __SEQLOCK_UNLOCKED(sysctl_local_ports.lock), | ||
37 | .range = { 32768, 61000 }, | ||
38 | }; | ||
39 | |||
40 | unsigned long *sysctl_local_reserved_ports; | 32 | unsigned long *sysctl_local_reserved_ports; |
41 | EXPORT_SYMBOL(sysctl_local_reserved_ports); | 33 | EXPORT_SYMBOL(sysctl_local_reserved_ports); |
42 | 34 | ||
43 | void inet_get_local_port_range(int *low, int *high) | 35 | void inet_get_local_port_range(struct net *net, int *low, int *high) |
44 | { | 36 | { |
45 | unsigned int seq; | 37 | unsigned int seq; |
46 | 38 | ||
47 | do { | 39 | do { |
48 | seq = read_seqbegin(&sysctl_local_ports.lock); | 40 | seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); |
49 | 41 | ||
50 | *low = sysctl_local_ports.range[0]; | 42 | *low = net->ipv4.sysctl_local_ports.range[0]; |
51 | *high = sysctl_local_ports.range[1]; | 43 | *high = net->ipv4.sysctl_local_ports.range[1]; |
52 | } while (read_seqretry(&sysctl_local_ports.lock, seq)); | 44 | } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); |
53 | } | 45 | } |
54 | EXPORT_SYMBOL(inet_get_local_port_range); | 46 | EXPORT_SYMBOL(inet_get_local_port_range); |
55 | 47 | ||
@@ -116,7 +108,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum) | |||
116 | int remaining, rover, low, high; | 108 | int remaining, rover, low, high; |
117 | 109 | ||
118 | again: | 110 | again: |
119 | inet_get_local_port_range(&low, &high); | 111 | inet_get_local_port_range(net, &low, &high); |
120 | remaining = (high - low) + 1; | 112 | remaining = (high - low) + 1; |
121 | smallest_rover = rover = net_random() % remaining + low; | 113 | smallest_rover = rover = net_random() % remaining + low; |
122 | 114 | ||