diff options
author | Eric Dumazet <edumazet@google.com> | 2023-09-22 05:42:18 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-10-01 20:39:19 +0200 |
commit | 3523bc91e4b4da39ccf18a0252d13108877ece0a (patch) | |
tree | 83a7d46d042484f5c6ece207408a8193f846db45 /net/ipv4/ip_sockglue.c | |
parent | inet: lockless getsockopt(IP_OPTIONS) (diff) | |
download | linux-3523bc91e4b4da39ccf18a0252d13108877ece0a.tar.xz linux-3523bc91e4b4da39ccf18a0252d13108877ece0a.zip |
inet: lockless getsockopt(IP_MTU)
sk_dst_get() does not require socket lock.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_sockglue.c')
-rw-r--r-- | net/ipv4/ip_sockglue.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 45d89487914a..04579e390ddd 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1620,13 +1620,6 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, return -EFAULT; return 0; } - } - - if (needs_rtnl) - rtnl_lock(); - sockopt_lock_sock(sk); - - switch (optname) { case IP_MTU: { struct dst_entry *dst; @@ -1636,12 +1629,17 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname, val = dst_mtu(dst); dst_release(dst); } - if (!val) { - sockopt_release_sock(sk); + if (!val) return -ENOTCONN; - } - break; + goto copyval; + } } + + if (needs_rtnl) + rtnl_lock(); + sockopt_lock_sock(sk); + + switch (optname) { case IP_UNICAST_IF: val = (__force int)htonl((__u32) inet->uc_index); break; |