* [PATCH net] net: diag: document swapped src/dst in udp_dump_one.
@ 2018-10-29 0:15 Lorenzo Colitti
2018-10-29 2:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Colitti @ 2018-10-29 0:15 UTC (permalink / raw)
To: netdev; +Cc: davem, zenczykowski, xemul, dsahern, Lorenzo Colitti
Since its inception, udp_dump_one has had a bug where userspace
needs to swap src and dst addresses and ports in order to find
the socket it wants. This is because it passes the socket source
address to __udp[46]_lib_lookup's saddr argument, but those
functions are intended to find local sockets matching received
packets, so saddr is the remote address, not the local address.
This can no longer be fixed for backwards compatibility reasons,
so add a brief comment explaining that this is the case. This
will avoid confusion and help ensure SOCK_DIAG implementations
of new protocols don't have the same problem.
Fixes: a925aa00a55 ("udp_diag: Implement the get_exact dumping functionality")
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
net/ipv4/udp_diag.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c
index d9ad986c7b..5cbb9be052 100644
--- a/net/ipv4/udp_diag.c
+++ b/net/ipv4/udp_diag.c
@@ -42,6 +42,7 @@ static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
rcu_read_lock();
if (req->sdiag_family == AF_INET)
+ /* src and dst are swapped for historical reasons */
sk = __udp4_lib_lookup(net,
req->id.idiag_src[0], req->id.idiag_sport,
req->id.idiag_dst[0], req->id.idiag_dport,
--
2.19.1.568.g152ad8e336-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: diag: document swapped src/dst in udp_dump_one.
2018-10-29 0:15 [PATCH net] net: diag: document swapped src/dst in udp_dump_one Lorenzo Colitti
@ 2018-10-29 2:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-10-29 2:27 UTC (permalink / raw)
To: lorenzo; +Cc: netdev, zenczykowski, xemul, dsahern
From: Lorenzo Colitti <lorenzo@google.com>
Date: Mon, 29 Oct 2018 09:15:22 +0900
> Since its inception, udp_dump_one has had a bug where userspace
> needs to swap src and dst addresses and ports in order to find
> the socket it wants. This is because it passes the socket source
> address to __udp[46]_lib_lookup's saddr argument, but those
> functions are intended to find local sockets matching received
> packets, so saddr is the remote address, not the local address.
>
> This can no longer be fixed for backwards compatibility reasons,
> so add a brief comment explaining that this is the case. This
> will avoid confusion and help ensure SOCK_DIAG implementations
> of new protocols don't have the same problem.
>
> Fixes: a925aa00a55 ("udp_diag: Implement the get_exact dumping functionality")
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-29 11:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29 0:15 [PATCH net] net: diag: document swapped src/dst in udp_dump_one Lorenzo Colitti
2018-10-29 2:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox