@@ -721,7 +721,7 @@ static int prepare_listen_socket(struct drbd_connection *connection, struct acce
goto out;
}
- s_listen->sk->sk_reuse = SK_CAN_REUSE; /* SO_REUSEADDR */
+ s_listen->sk->sk_reuse = SOCK_CAN_REUSE; /* SO_REUSEADDR */
drbd_setbufsize(s_listen, sndbuf_size, rcvbuf_size);
what = "bind before listen";
@@ -1023,8 +1023,8 @@ static int conn_connect(struct drbd_connection *connection)
if (ad.s_listen)
sock_release(ad.s_listen);
- sock.socket->sk->sk_reuse = SK_CAN_REUSE; /* SO_REUSEADDR */
- msock.socket->sk->sk_reuse = SK_CAN_REUSE; /* SO_REUSEADDR */
+ sock.socket->sk->sk_reuse = SOCK_CAN_REUSE; /* SO_REUSEADDR */
+ msock.socket->sk->sk_reuse = SOCK_CAN_REUSE; /* SO_REUSEADDR */
sock.socket->sk->sk_allocation = GFP_NOIO;
msock.socket->sk->sk_allocation = GFP_NOIO;
@@ -735,7 +735,7 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
/* setup Socket parameters */
sk = sock->sk;
- sk->sk_reuse = SK_CAN_REUSE;
+ sk->sk_reuse = SOCK_CAN_REUSE;
sk->sk_sndtimeo = 15 * HZ; /* FIXME: make it configurable */
sk->sk_allocation = GFP_ATOMIC;
sk->sk_use_task_frag = false;
@@ -1997,7 +1997,7 @@ static int o2net_open_listening_sock(__be32 addr, __be16 port)
o2net_listen_sock = sock;
INIT_WORK(&o2net_listen_work, o2net_accept_many);
- sock->sk->sk_reuse = SK_CAN_REUSE;
+ sock->sk->sk_reuse = SOCK_CAN_REUSE;
ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
if (ret < 0) {
printk(KERN_ERR "o2net: Error %d while binding socket at "
@@ -657,17 +657,6 @@ void sock_net_set(struct sock *sk, struct net *net)
write_pnet(&sk->sk_net, net);
}
-/*
- * SK_CAN_REUSE and SK_NO_REUSE on a socket mean that the socket is OK
- * or not whether his port will be reused by someone else. SK_FORCE_REUSE
- * on a socket means that the socket will reuse everybody else's port
- * without looking at the other's sk_reuse value.
- */
-
-#define SK_NO_REUSE 0
-#define SK_CAN_REUSE 1
-#define SK_FORCE_REUSE 2
-
int sk_set_peek_off(struct sock *sk, int val);
static inline int sk_peek_offset(const struct sock *sk, int flags)
@@ -35,4 +35,15 @@ struct __kernel_sockaddr_storage {
#define SOCK_TXREHASH_DISABLED 0
#define SOCK_TXREHASH_ENABLED 1
+/*
+ * SOCK_CAN_REUSE and SOCK_NO_REUSE on a socket mean that the socket is OK
+ * or not whether his port will be reused by someone else. SOCK_FORCE_REUSE
+ * on a socket means that the socket will reuse everybody else's port
+ * without looking at the other's sk_reuse value.
+ */
+
+#define SOCK_NO_REUSE 0
+#define SOCK_CAN_REUSE 1
+#define SOCK_FORCE_REUSE 2
+
#endif /* _UAPI_LINUX_SOCKET_H */
@@ -782,7 +782,7 @@ EXPORT_SYMBOL(sk_mc_loop);
void sock_set_reuseaddr(struct sock *sk)
{
lock_sock(sk);
- sk->sk_reuse = SK_CAN_REUSE;
+ sk->sk_reuse = SOCK_CAN_REUSE;
release_sock(sk);
}
EXPORT_SYMBOL(sock_set_reuseaddr);
@@ -1128,7 +1128,7 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
sock_valbool_flag(sk, SOCK_DBG, valbool);
break;
case SO_REUSEADDR:
- sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
+ sk->sk_reuse = (valbool ? SOCK_CAN_REUSE : SOCK_NO_REUSE);
break;
case SO_REUSEPORT:
sk->sk_reuseport = valbool;
@@ -328,7 +328,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
err = 0;
if (INET_PROTOSW_REUSE & answer_flags)
- sk->sk_reuse = SK_CAN_REUSE;
+ sk->sk_reuse = SOCK_CAN_REUSE;
inet = inet_sk(sk);
inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags);
@@ -335,7 +335,7 @@ inet_csk_find_open_port(const struct sock *sk, struct inet_bind_bucket **tb_ret,
l3mdev = inet_sk_bound_l3mdev(sk);
ports_exhausted:
- attempt_half = (sk->sk_reuse == SK_CAN_REUSE) ? 1 : 0;
+ attempt_half = (sk->sk_reuse == SOCK_CAN_REUSE) ? 1 : 0;
other_half_scan:
inet_sk_get_local_port_range(sk, &low, &high);
high++; /* [32768, 60999] -> [32768, 61000[ */
@@ -548,7 +548,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
if (!found_port) {
if (!hlist_empty(&tb->owners)) {
- if (sk->sk_reuse == SK_FORCE_REUSE ||
+ if (sk->sk_reuse == SOCK_FORCE_REUSE ||
(tb->fastreuse > 0 && reuse) ||
sk_reuseport_match(tb, sk))
check_bind_conflict = false;
@@ -3522,15 +3522,15 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
err = -EPERM;
else if (val == TCP_REPAIR_ON) {
tp->repair = 1;
- sk->sk_reuse = SK_FORCE_REUSE;
+ sk->sk_reuse = SOCK_FORCE_REUSE;
tp->repair_queue = TCP_NO_QUEUE;
} else if (val == TCP_REPAIR_OFF) {
tp->repair = 0;
- sk->sk_reuse = SK_NO_REUSE;
+ sk->sk_reuse = SOCK_NO_REUSE;
tcp_send_window_probe(sk);
} else if (val == TCP_REPAIR_OFF_NO_WP) {
tp->repair = 0;
- sk->sk_reuse = SK_NO_REUSE;
+ sk->sk_reuse = SOCK_NO_REUSE;
} else
err = -EINVAL;
@@ -197,7 +197,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
err = 0;
if (INET_PROTOSW_REUSE & answer_flags)
- sk->sk_reuse = SK_CAN_REUSE;
+ sk->sk_reuse = SOCK_CAN_REUSE;
inet = inet_sk(sk);
inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags);
@@ -1539,7 +1539,7 @@ static int make_receive_sock(struct netns_ipvs *ipvs, int id,
}
*sock_ret = sock;
/* it is equivalent to the REUSEADDR option in user-space */
- sock->sk->sk_reuse = SK_CAN_REUSE;
+ sock->sk->sk_reuse = SOCK_CAN_REUSE;
result = sysctl_sync_sock_size(ipvs);
if (result > 0)
set_sock_size(sock->sk, 0, result);
@@ -282,7 +282,7 @@ struct socket *rds_tcp_listen_init(struct net *net, bool isv6)
goto out;
}
- sock->sk->sk_reuse = SK_CAN_REUSE;
+ sock->sk->sk_reuse = SOCK_CAN_REUSE;
tcp_sock_set_nodelay(sock->sk);
write_lock_bh(&sock->sk->sk_callback_lock);
@@ -1559,7 +1559,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
if (family == PF_INET6)
ip6_sock_set_v6only(sock->sk);
if (type == SOCK_STREAM)
- sock->sk->sk_reuse = SK_CAN_REUSE; /* allow address reuse */
+ sock->sk->sk_reuse = SOCK_CAN_REUSE; /* allow address reuse */
error = kernel_bind(sock, sin, len);
if (error < 0)
goto bummer;
The settings for SO_REUSEADDR are now available via sock_diag. To help userspace understand it's meaning let's add the values to include/uapi/linux/socket.h. Also, rename them from SK_* to SOCK_* to match the convention. These can also be used to interpret the getsockopt() return value from SO_REUSEADDR. Signed-off-by: Jason Baron <jbaron@akamai.com> --- drivers/block/drbd/drbd_receiver.c | 6 +++--- drivers/scsi/iscsi_tcp.c | 2 +- fs/ocfs2/cluster/tcp.c | 2 +- include/net/sock.h | 11 ----------- include/uapi/linux/socket.h | 11 +++++++++++ net/core/sock.c | 4 ++-- net/ipv4/af_inet.c | 2 +- net/ipv4/inet_connection_sock.c | 4 ++-- net/ipv4/tcp.c | 6 +++--- net/ipv6/af_inet6.c | 2 +- net/netfilter/ipvs/ip_vs_sync.c | 2 +- net/rds/tcp_listen.c | 2 +- net/sunrpc/svcsock.c | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-)