diff options
author | Eric Dumazet <edumazet@google.com> | 2023-09-22 03:42:18 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-10-01 19:39:19 +0100 |
commit | 3523bc91e4b4da39ccf18a0252d13108877ece0a (patch) | |
tree | 83a7d46d042484f5c6ece207408a8193f846db45 /net/ipv4/ip_sockglue.c | |
parent | a4725d0d893599253a4bb283fdabdd4a66d9451d (diff) | |
download | linux-3523bc91e4b4da39ccf18a0252d13108877ece0a.tar.gz linux-3523bc91e4b4da39ccf18a0252d13108877ece0a.tar.bz2 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; |