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

inet: move inet->recverr_rfc4884 to inet->inet_flags

IP_RECVERR_RFC4884 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 6b5f43ea
...@@ -238,7 +238,6 @@ struct inet_sock { ...@@ -238,7 +238,6 @@ struct inet_sock {
mc_all:1, mc_all:1,
nodefrag:1; nodefrag:1;
__u8 bind_address_no_port:1, __u8 bind_address_no_port:1,
recverr_rfc4884: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
* until first data frame is written * until first data frame is written
...@@ -271,6 +270,7 @@ enum { ...@@ -271,6 +270,7 @@ enum {
INET_FLAGS_RECVFRAGSIZE = 8, INET_FLAGS_RECVFRAGSIZE = 8,
INET_FLAGS_RECVERR = 9, INET_FLAGS_RECVERR = 9,
INET_FLAGS_RECVERR_RFC4884 = 10,
}; };
/* cmsg flags for inet */ /* cmsg flags for inet */
......
...@@ -191,7 +191,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb, ...@@ -191,7 +191,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk_buff *skb,
inet_sockopt.mc_all = inet->mc_all; inet_sockopt.mc_all = inet->mc_all;
inet_sockopt.nodefrag = inet->nodefrag; inet_sockopt.nodefrag = inet->nodefrag;
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->recverr_rfc4884; inet_sockopt.recverr_rfc4884 = inet_test_bit(RECVERR_RFC4884, sk);
inet_sockopt.defer_connect = inet->defer_connect; inet_sockopt.defer_connect = inet->defer_connect;
if (nla_put(skb, INET_DIAG_SOCKOPT, sizeof(inet_sockopt), if (nla_put(skb, INET_DIAG_SOCKOPT, sizeof(inet_sockopt),
&inet_sockopt)) &inet_sockopt))
......
...@@ -433,7 +433,7 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, ...@@ -433,7 +433,7 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
serr->port = port; serr->port = port;
if (skb_pull(skb, payload - skb->data)) { if (skb_pull(skb, payload - skb->data)) {
if (inet_sk(sk)->recverr_rfc4884) if (inet_test_bit(RECVERR_RFC4884, sk))
ipv4_icmp_error_rfc4884(skb, &serr->ee.ee_rfc4884); ipv4_icmp_error_rfc4884(skb, &serr->ee.ee_rfc4884);
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
...@@ -980,6 +980,11 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, ...@@ -980,6 +980,11 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
if (!val) if (!val)
skb_queue_purge(&sk->sk_error_queue); skb_queue_purge(&sk->sk_error_queue);
return 0; return 0;
case IP_RECVERR_RFC4884:
if (val < 0 || val > 1)
return -EINVAL;
inet_assign_bit(RECVERR_RFC4884, sk, val);
return 0;
} }
err = 0; err = 0;
...@@ -1066,11 +1071,6 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname, ...@@ -1066,11 +1071,6 @@ int do_ip_setsockopt(struct sock *sk, int level, int optname,
goto e_inval; goto e_inval;
inet->pmtudisc = val; inet->pmtudisc = val;
break; break;
case IP_RECVERR_RFC4884:
if (val < 0 || val > 1)
goto e_inval;
inet->recverr_rfc4884 = !!val;
break;
case IP_MULTICAST_TTL: case IP_MULTICAST_TTL:
if (sk->sk_type == SOCK_STREAM) if (sk->sk_type == SOCK_STREAM)
goto e_inval; goto e_inval;
...@@ -1575,6 +1575,9 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1575,6 +1575,9 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname,
case IP_RECVERR: case IP_RECVERR:
val = inet_test_bit(RECVERR, sk); val = inet_test_bit(RECVERR, sk);
goto copyval; goto copyval;
case IP_RECVERR_RFC4884:
val = inet_test_bit(RECVERR_RFC4884, sk);
goto copyval;
} }
if (needs_rtnl) if (needs_rtnl)
...@@ -1649,9 +1652,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, ...@@ -1649,9 +1652,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname,
} }
break; break;
} }
case IP_RECVERR_RFC4884:
val = inet->recverr_rfc4884;
break;
case IP_MULTICAST_TTL: case IP_MULTICAST_TTL:
val = inet->mc_ttl; val = inet->mc_ttl;
break; break;
......
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