Commit f04b8d34 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

inet: move inet->nodefrag to inet->inet_flags

IP_NODEFRAG socket option can now be set/read
without locking the socket.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b1c0356a
...@@ -229,7 +229,6 @@ struct inet_sock { ...@@ -229,7 +229,6 @@ struct inet_sock {
__u8 min_ttl; __u8 min_ttl;
__u8 mc_ttl; __u8 mc_ttl;
__u8 pmtudisc; __u8 pmtudisc;
__u8 nodefrag:1;
__u8 bind_address_no_port:1, __u8 bind_address_no_port:1,
defer_connect:1; /* Indicates that fastopen_connect is set defer_connect:1; /* Indicates that fastopen_connect is set
* and cookie exists so we defer connect * and cookie exists so we defer connect
...@@ -270,6 +269,7 @@ enum { ...@@ -270,6 +269,7 @@ enum {
INET_FLAGS_MC_ALL = 14, INET_FLAGS_MC_ALL = 14,
INET_FLAGS_TRANSPARENT = 15, INET_FLAGS_TRANSPARENT = 15,
INET_FLAGS_IS_ICSK = 16, INET_FLAGS_IS_ICSK = 16,
INET_FLAGS_NODEFRAG = 17,
}; };
/* cmsg flags for inet */ /* cmsg flags for inet */
......
...@@ -333,7 +333,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, ...@@ -333,7 +333,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
inet = inet_sk(sk); inet = inet_sk(sk);
inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags); inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags);
inet->nodefrag = 0; inet_clear_bit(NODEFRAG, sk);
if (SOCK_RAW == sock->type) { if (SOCK_RAW == sock->type) {
inet->inet_num = protocol; inet->inet_num = protocol;
......
...@@ -189,7 +189,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb, ...@@ -189,7 +189,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
inet_sockopt.mc_loop = inet_test_bit(MC_LOOP, sk); inet_sockopt.mc_loop = inet_test_bit(MC_LOOP, sk);
inet_sockopt.transparent = inet_test_bit(TRANSPARENT, sk); inet_sockopt.transparent = inet_test_bit(TRANSPARENT, sk);
inet_sockopt.mc_all = inet_test_bit(MC_ALL, sk); inet_sockopt.mc_all = inet_test_bit(MC_ALL, sk);
inet_sockopt.nodefrag = inet->nodefrag; inet_sockopt.nodefrag = inet_test_bit(NODEFRAG, sk);
inet_sockopt.bind_address_no_port = inet->bind_address_no_port; inet_sockopt.bind_address_no_port = inet->bind_address_no_port;
inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk); inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk);
inet_sockopt.defer_connect = inet->defer_connect; inet_sockopt.defer_connect = inet->defer_connect;
......
...@@ -1015,6 +1015,11 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, ...@@ -1015,6 +1015,11 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
goto e_inval; goto e_inval;
inet_assign_bit(TRANSPARENT, sk, val); inet_assign_bit(TRANSPARENT, sk, val);
return 0; return 0;
case IP_NODEFRAG:
if (sk->sk_type != SOCK_RAW)
return -ENOPROTOOPT;
inet_assign_bit(NODEFRAG, sk, val);
return 0;
} }
err = 0; err = 0;
...@@ -1079,13 +1084,6 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, ...@@ -1079,13 +1084,6 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
goto e_inval; goto e_inval;
inet->uc_ttl = val; inet->uc_ttl = val;
break; break;
case IP_NODEFRAG:
if (sk->sk_type != SOCK_RAW) {
err = -ENOPROTOOPT;
break;
}
inet->nodefrag = val ? 1 : 0;
break;
case IP_BIND_ADDRESS_NO_PORT: case IP_BIND_ADDRESS_NO_PORT:
inet->bind_address_no_port = val ? 1 : 0; inet->bind_address_no_port = val ? 1 : 0;
break; break;
...@@ -1586,6 +1584,9 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1586,6 +1584,9 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname,
case IP_TRANSPARENT: case IP_TRANSPARENT:
val = inet_test_bit(TRANSPARENT, sk); val = inet_test_bit(TRANSPARENT, sk);
goto copyval; goto copyval;
case IP_NODEFRAG:
val = inet_test_bit(NODEFRAG, sk);
goto copyval;
} }
if (needs_rtnl) if (needs_rtnl)
...@@ -1633,9 +1634,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1633,9 +1634,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname,
inet->uc_ttl); inet->uc_ttl);
break; break;
} }
case IP_NODEFRAG:
val = inet->nodefrag;
break;
case IP_BIND_ADDRESS_NO_PORT: case IP_BIND_ADDRESS_NO_PORT:
val = inet->bind_address_no_port; val = inet->bind_address_no_port;
break; break;
......
...@@ -66,7 +66,7 @@ static unsigned int ipv4_conntrack_defrag(void *priv, ...@@ -66,7 +66,7 @@ static unsigned int ipv4_conntrack_defrag(void *priv,
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
if (sk && sk_fullsock(sk) && (sk->sk_family == PF_INET) && if (sk && sk_fullsock(sk) && (sk->sk_family == PF_INET) &&
inet_sk(sk)->nodefrag) inet_test_bit(NODEFRAG, sk))
return NF_ACCEPT; return NF_ACCEPT;
#if IS_ENABLED(CONFIG_NF_CONNTRACK) #if IS_ENABLED(CONFIG_NF_CONNTRACK)
......
...@@ -1346,7 +1346,7 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stat ...@@ -1346,7 +1346,7 @@ ip_vs_out_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *stat
if (unlikely(sk && hooknum == NF_INET_LOCAL_OUT && if (unlikely(sk && hooknum == NF_INET_LOCAL_OUT &&
af == AF_INET)) { af == AF_INET)) {
if (sk->sk_family == PF_INET && inet_sk(sk)->nodefrag) if (sk->sk_family == PF_INET && inet_test_bit(NODEFRAG, sk))
return NF_ACCEPT; return NF_ACCEPT;
} }
...@@ -1946,7 +1946,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state ...@@ -1946,7 +1946,7 @@ ip_vs_in_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *state
if (unlikely(sk && hooknum == NF_INET_LOCAL_OUT && if (unlikely(sk && hooknum == NF_INET_LOCAL_OUT &&
af == AF_INET)) { af == AF_INET)) {
if (sk->sk_family == PF_INET && inet_sk(sk)->nodefrag) if (sk->sk_family == PF_INET && inet_test_bit(NODEFRAG, sk))
return NF_ACCEPT; return NF_ACCEPT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment