netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] flow_dissector: fix byteorder of dissected ICMP ID
@ 2021-03-12 20:08 Alexander Lobakin
  2021-03-14 20:21 ` Jakub Sitnicki
  2021-03-14 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Lobakin @ 2021-03-12 20:08 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Jakub Sitnicki, Alexei Starovoitov, Andrii Nakryiko,
	Vladimir Oltean, Davide Caratti, Guillaume Nault, wenxu,
	Eran Ben Elisha, Matteo Croce, netdev, linux-kernel,
	Alexander Lobakin

flow_dissector_key_icmp::id is of type u16 (CPU byteorder),
ICMP header has its ID field in network byteorder obviously.
Sparse says:

net/core/flow_dissector.c:178:43: warning: restricted __be16 degrades to integer

Convert ID value to CPU byteorder when storing it into
flow_dissector_key_icmp.

Fixes: 5dec597e5cd0 ("flow_dissector: extract more ICMP information")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 net/core/flow_dissector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 2ef2224b3bff..a96a4f5de0ce 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -176,7 +176,7 @@ void skb_flow_get_icmp_tci(const struct sk_buff *skb,
 	 * avoid confusion with packets without such field
 	 */
 	if (icmp_has_id(ih->type))
-		key_icmp->id = ih->un.echo.id ? : 1;
+		key_icmp->id = ih->un.echo.id ? ntohs(ih->un.echo.id) : 1;
 	else
 		key_icmp->id = 0;
 }
--
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-14 22:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 20:08 [PATCH net] flow_dissector: fix byteorder of dissected ICMP ID Alexander Lobakin
2021-03-14 20:21 ` Jakub Sitnicki
2021-03-14 20:44   ` Vladimir Oltean
2021-03-14 21:31     ` David Miller
2021-03-14 22:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).