net: reserve ports for applications using fixed port numbers
(Dropped the infiniband part, because Tetsuo modified the related code, I will send a separate patch for it once this is accepted.) This patch introduces /proc/sys/net/ipv4/ip_local_reserved_ports which allows users to reserve ports for third-party applications. The reserved ports will not be used by automatic port assignments (e.g. when calling connect() or bind() with port number 0). Explicit port allocation behavior is unchanged. Signed-off-by: Octavian Purdila <opurdila@ixiacom.com> Signed-off-by: WANG Cong <amwang@redhat.com> Cc: Neil Horman <nhorman@tuxdriver.com> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
9f977fb7ae
commit
e3826f1e94
@@ -299,6 +299,13 @@ static struct ctl_table ipv4_table[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = ipv4_local_port_range,
|
||||
},
|
||||
{
|
||||
.procname = "ip_local_reserved_ports",
|
||||
.data = NULL, /* initialized in sysctl_ipv4_init */
|
||||
.maxlen = 65536,
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_do_large_bitmap,
|
||||
},
|
||||
#ifdef CONFIG_IP_MULTICAST
|
||||
{
|
||||
.procname = "igmp_max_memberships",
|
||||
@@ -736,6 +743,16 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
|
||||
static __init int sysctl_ipv4_init(void)
|
||||
{
|
||||
struct ctl_table_header *hdr;
|
||||
struct ctl_table *i;
|
||||
|
||||
for (i = ipv4_table; i->procname; i++) {
|
||||
if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
|
||||
i->data = sysctl_local_reserved_ports;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!i->procname)
|
||||
return -EINVAL;
|
||||
|
||||
hdr = register_sysctl_paths(net_ipv4_ctl_path, ipv4_table);
|
||||
if (hdr == NULL)
|
||||
|
Reference in New Issue
Block a user