summaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_diag.c
diff options
context:
space:
mode:
authorCraig Gallek <kraig@google.com>2015-06-17 10:59:10 -0400
committerDavid S. Miller <davem@davemloft.net>2015-06-21 10:16:50 -0700
commite0df02e0c2118892b302e8248dbbb21698bedfed (patch)
treeea0483402fab420afc7dd5732018c0d3d10d9265 /net/ipv4/inet_diag.c
parentb7d3282a245f44286b88e436b1d08c518cdf4569 (diff)
downloadlinux-e0df02e0c2118892b302e8248dbbb21698bedfed.tar.gz
linux-e0df02e0c2118892b302e8248dbbb21698bedfed.tar.bz2
linux-e0df02e0c2118892b302e8248dbbb21698bedfed.zip
sock_diag: fetch source port from inet_sock
When an inet_sock is destroyed, its source port (sk_num) is set to zero as part of the unhash procedure. In order to supply a source port as part of the NETLINK_SOCK_DIAG socket destruction broadcasts, the source port number must be read from inet_sport instead. Tested: ss -E Signed-off-by: Craig Gallek <kraig@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_diag.c')
-rw-r--r--net/ipv4/inet_diag.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 21985d8d41e7..ba6a80f90e7d 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -1095,6 +1095,8 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk)
r = nlmsg_data(nlh);
memset(r, 0, sizeof(*r));
inet_diag_msg_common_fill(r, sk);
+ if (sk->sk_type == SOCK_DGRAM || sk->sk_type == SOCK_STREAM)
+ r->id.idiag_sport = inet_sk(sk)->inet_sport;
r->idiag_state = sk->sk_state;
if ((err = nla_put_u8(skb, INET_DIAG_PROTOCOL, sk->sk_protocol))) {