diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2012-04-18 23:39:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-21 15:52:25 -0400 |
commit | 4a17fd5229c1b6066aa478f6b690f8293ce811a1 (patch) | |
tree | f6acd00935d2d7a990befb4c77f57fdf39f46689 /net | |
parent | 59c55bdde856c4000bbeb33ba212c3df6f1997a4 (diff) |
sock: Introduce named constants for sk_reuse
Name them in a "backward compatible" manner, i.e. reuse or not
are still 1 and 0 respectively. The reuse value of 2 means that
the socket with it will forcibly reuse everyone else's port.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 2 | ||||
-rw-r--r-- | net/econet/af_econet.c | 4 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 2 | ||||
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 3 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 2 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_sync.c | 2 | ||||
-rw-r--r-- | net/rds/tcp_listen.c | 2 | ||||
-rw-r--r-- | net/sunrpc/svcsock.c | 2 |
8 files changed, 11 insertions, 8 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index c7e60eac639b..679c5bbe2bed 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -561,7 +561,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
561 | sock_valbool_flag(sk, SOCK_DBG, valbool); | 561 | sock_valbool_flag(sk, SOCK_DBG, valbool); |
562 | break; | 562 | break; |
563 | case SO_REUSEADDR: | 563 | case SO_REUSEADDR: |
564 | sk->sk_reuse = valbool; | 564 | sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE); |
565 | break; | 565 | break; |
566 | case SO_TYPE: | 566 | case SO_TYPE: |
567 | case SO_PROTOCOL: | 567 | case SO_PROTOCOL: |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 71b5edcee401..fa14ca76b77b 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -617,7 +617,7 @@ static int econet_create(struct net *net, struct socket *sock, int protocol, | |||
617 | if (sk == NULL) | 617 | if (sk == NULL) |
618 | goto out; | 618 | goto out; |
619 | 619 | ||
620 | sk->sk_reuse = 1; | 620 | sk->sk_reuse = SK_CAN_REUSE; |
621 | sock->ops = &econet_ops; | 621 | sock->ops = &econet_ops; |
622 | sock_init_data(sock, sk); | 622 | sock_init_data(sock, sk); |
623 | 623 | ||
@@ -1012,7 +1012,7 @@ static int __init aun_udp_initialise(void) | |||
1012 | return error; | 1012 | return error; |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | udpsock->sk->sk_reuse = 1; | 1015 | udpsock->sk->sk_reuse = SK_CAN_REUSE; |
1016 | udpsock->sk->sk_allocation = GFP_ATOMIC; /* we're going to call it | 1016 | udpsock->sk->sk_allocation = GFP_ATOMIC; /* we're going to call it |
1017 | from interrupts */ | 1017 | from interrupts */ |
1018 | 1018 | ||
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 3744c1c0af5a..c8f7aee587d1 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -350,7 +350,7 @@ lookup_protocol: | |||
350 | err = 0; | 350 | err = 0; |
351 | sk->sk_no_check = answer_no_check; | 351 | sk->sk_no_check = answer_no_check; |
352 | if (INET_PROTOSW_REUSE & answer_flags) | 352 | if (INET_PROTOSW_REUSE & answer_flags) |
353 | sk->sk_reuse = 1; | 353 | sk->sk_reuse = SK_CAN_REUSE; |
354 | 354 | ||
355 | inet = inet_sk(sk); | 355 | inet = inet_sk(sk); |
356 | inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; | 356 | inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; |
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 7d972f650a61..95e61596e605 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -182,6 +182,9 @@ have_snum: | |||
182 | goto tb_not_found; | 182 | goto tb_not_found; |
183 | tb_found: | 183 | tb_found: |
184 | if (!hlist_empty(&tb->owners)) { | 184 | if (!hlist_empty(&tb->owners)) { |
185 | if (sk->sk_reuse == SK_FORCE_REUSE) | ||
186 | goto success; | ||
187 | |||
185 | if (tb->fastreuse > 0 && | 188 | if (tb->fastreuse > 0 && |
186 | sk->sk_reuse && sk->sk_state != TCP_LISTEN && | 189 | sk->sk_reuse && sk->sk_state != TCP_LISTEN && |
187 | smallest_size == -1) { | 190 | smallest_size == -1) { |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 461e7896e5d8..0ad046c7ae95 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -180,7 +180,7 @@ lookup_protocol: | |||
180 | err = 0; | 180 | err = 0; |
181 | sk->sk_no_check = answer_no_check; | 181 | sk->sk_no_check = answer_no_check; |
182 | if (INET_PROTOSW_REUSE & answer_flags) | 182 | if (INET_PROTOSW_REUSE & answer_flags) |
183 | sk->sk_reuse = 1; | 183 | sk->sk_reuse = SK_CAN_REUSE; |
184 | 184 | ||
185 | inet = inet_sk(sk); | 185 | inet = inet_sk(sk); |
186 | inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; | 186 | inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0; |
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index f4e0b6cf8246..bf5e538af67b 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c | |||
@@ -1368,7 +1368,7 @@ static struct socket *make_receive_sock(struct net *net) | |||
1368 | */ | 1368 | */ |
1369 | sk_change_net(sock->sk, net); | 1369 | sk_change_net(sock->sk, net); |
1370 | /* it is equivalent to the REUSEADDR option in user-space */ | 1370 | /* it is equivalent to the REUSEADDR option in user-space */ |
1371 | sock->sk->sk_reuse = 1; | 1371 | sock->sk->sk_reuse = SK_CAN_REUSE; |
1372 | 1372 | ||
1373 | result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr, | 1373 | result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr, |
1374 | sizeof(struct sockaddr)); | 1374 | sizeof(struct sockaddr)); |
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c index 8b5cc4aa8868..72981375f47c 100644 --- a/net/rds/tcp_listen.c +++ b/net/rds/tcp_listen.c | |||
@@ -145,7 +145,7 @@ int rds_tcp_listen_init(void) | |||
145 | if (ret < 0) | 145 | if (ret < 0) |
146 | goto out; | 146 | goto out; |
147 | 147 | ||
148 | sock->sk->sk_reuse = 1; | 148 | sock->sk->sk_reuse = SK_CAN_REUSE; |
149 | rds_tcp_nonagle(sock); | 149 | rds_tcp_nonagle(sock); |
150 | 150 | ||
151 | write_lock_bh(&sock->sk->sk_callback_lock); | 151 | write_lock_bh(&sock->sk->sk_callback_lock); |
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 824d32fb3121..f0132b2e875e 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -1556,7 +1556,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv, | |||
1556 | (char *)&val, sizeof(val)); | 1556 | (char *)&val, sizeof(val)); |
1557 | 1557 | ||
1558 | if (type == SOCK_STREAM) | 1558 | if (type == SOCK_STREAM) |
1559 | sock->sk->sk_reuse = 1; /* allow address reuse */ | 1559 | sock->sk->sk_reuse = SK_CAN_REUSE; /* allow address reuse */ |
1560 | error = kernel_bind(sock, sin, len); | 1560 | error = kernel_bind(sock, sin, len); |
1561 | if (error < 0) | 1561 | if (error < 0) |
1562 | goto bummer; | 1562 | goto bummer; |