ipv4: make ip_local_reserved_ports per netns

ip_local_port_range is already per netns, so should ip_local_reserved_ports
be. And since it is none by default we don't actually need it when we don't
enable CONFIG_SYSCTL.

By the way, rename inet_is_reserved_local_port() to inet_is_local_reserved_port()

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
WANG Cong
2014-05-14 15:31:45 -04:00
committed by David S. Miller
parent 9cc5e36d1c
commit 122ff243f5
9 changed files with 38 additions and 37 deletions
+11 -3
View File
@@ -208,11 +208,19 @@ static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_o
void inet_get_local_port_range(struct net *net, int *low, int *high);
extern unsigned long *sysctl_local_reserved_ports;
static inline int inet_is_reserved_local_port(int port)
#if CONFIG_SYSCTL
static inline int inet_is_local_reserved_port(struct net *net, int port)
{
return test_bit(port, sysctl_local_reserved_ports);
if (!net->ipv4.sysctl_local_reserved_ports)
return 0;
return test_bit(port, net->ipv4.sysctl_local_reserved_ports);
}
#else
static inline int inet_is_local_reserved_port(struct net *net, int port)
{
return 0;
}
#endif
extern int sysctl_ip_nonlocal_bind;
+4
View File
@@ -84,6 +84,10 @@ struct netns_ipv4 {
atomic_t dev_addr_genid;
#ifdef CONFIG_SYSCTL
unsigned long *sysctl_local_reserved_ports;
#endif
#ifdef CONFIG_IP_MROUTE
#ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
struct mr_table *mrt;