diff options
author | Amerigo Wang <amwang@redhat.com> | 2010-05-04 20:27:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-16 02:28:40 -0400 |
commit | e3826f1e946e7d2354943232f1457be1455a29e2 (patch) | |
tree | a34055c7de762410b6a10c21ab5e1999fb38803b /net/ipv4/af_inet.c | |
parent | 9f977fb7ae9ddf565b4800854212fb9a1ed6c2ea (diff) |
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>
Diffstat (limited to 'net/ipv4/af_inet.c')
-rw-r--r-- | net/ipv4/af_inet.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index c6c43bcd1c6f..551ce564b035 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -1573,9 +1573,13 @@ static int __init inet_init(void) | |||
1573 | 1573 | ||
1574 | BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb)); | 1574 | BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb)); |
1575 | 1575 | ||
1576 | sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL); | ||
1577 | if (!sysctl_local_reserved_ports) | ||
1578 | goto out; | ||
1579 | |||
1576 | rc = proto_register(&tcp_prot, 1); | 1580 | rc = proto_register(&tcp_prot, 1); |
1577 | if (rc) | 1581 | if (rc) |
1578 | goto out; | 1582 | goto out_free_reserved_ports; |
1579 | 1583 | ||
1580 | rc = proto_register(&udp_prot, 1); | 1584 | rc = proto_register(&udp_prot, 1); |
1581 | if (rc) | 1585 | if (rc) |
@@ -1674,6 +1678,8 @@ out_unregister_udp_proto: | |||
1674 | proto_unregister(&udp_prot); | 1678 | proto_unregister(&udp_prot); |
1675 | out_unregister_tcp_proto: | 1679 | out_unregister_tcp_proto: |
1676 | proto_unregister(&tcp_prot); | 1680 | proto_unregister(&tcp_prot); |
1681 | out_free_reserved_ports: | ||
1682 | kfree(sysctl_local_reserved_ports); | ||
1677 | goto out; | 1683 | goto out; |
1678 | } | 1684 | } |
1679 | 1685 | ||