* [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros
@ 2025-03-19 21:25 Eric Dumazet
2025-03-23 16:53 ` Simon Horman
2025-03-25 15:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-03-19 21:25 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Simon Horman, netdev, eric.dumazet, Eric Dumazet
ip6_rcv_core() is using:
__IP6_ADD_STATS(net, idev,
IPSTATS_MIB_NOECTPKTS +
(ipv6_get_dsfield(hdr) & INET_ECN_MASK),
max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
This is currently evaluating both expressions twice.
Fix _DEVADD() and _DEVUPD() macros to evaluate their arguments once.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ipv6.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 9614006f483c9700168c9734f71440980c09017f..2ccdf85f34f16404157b1cd551c874fdfb20f52a 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -246,17 +246,20 @@ extern int sysctl_mld_qrv;
#define _DEVADD(net, statname, mod, idev, field, val) \
({ \
struct inet6_dev *_idev = (idev); \
+ unsigned long _field = (field); \
+ unsigned long _val = (val); \
if (likely(_idev != NULL)) \
- mod##SNMP_ADD_STATS((_idev)->stats.statname, (field), (val)); \
- mod##SNMP_ADD_STATS((net)->mib.statname##_statistics, (field), (val));\
+ mod##SNMP_ADD_STATS((_idev)->stats.statname, _field, _val); \
+ mod##SNMP_ADD_STATS((net)->mib.statname##_statistics, _field, _val);\
})
#define _DEVUPD(net, statname, mod, idev, field, val) \
({ \
struct inet6_dev *_idev = (idev); \
+ unsigned long _val = (val); \
if (likely(_idev != NULL)) \
- mod##SNMP_UPD_PO_STATS((_idev)->stats.statname, field, (val)); \
- mod##SNMP_UPD_PO_STATS((net)->mib.statname##_statistics, field, (val));\
+ mod##SNMP_UPD_PO_STATS((_idev)->stats.statname, field, _val); \
+ mod##SNMP_UPD_PO_STATS((net)->mib.statname##_statistics, field, _val);\
})
/* MIBs */
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros
2025-03-19 21:25 [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros Eric Dumazet
@ 2025-03-23 16:53 ` Simon Horman
2025-03-25 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-03-23 16:53 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, David Ahern, netdev,
eric.dumazet
On Wed, Mar 19, 2025 at 09:25:16PM +0000, Eric Dumazet wrote:
> ip6_rcv_core() is using:
>
> __IP6_ADD_STATS(net, idev,
> IPSTATS_MIB_NOECTPKTS +
> (ipv6_get_dsfield(hdr) & INET_ECN_MASK),
> max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
>
> This is currently evaluating both expressions twice.
>
> Fix _DEVADD() and _DEVUPD() macros to evaluate their arguments once.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros
2025-03-19 21:25 [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros Eric Dumazet
2025-03-23 16:53 ` Simon Horman
@ 2025-03-25 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-25 15:00 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, dsahern, horms, netdev, eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 19 Mar 2025 21:25:16 +0000 you wrote:
> ip6_rcv_core() is using:
>
> __IP6_ADD_STATS(net, idev,
> IPSTATS_MIB_NOECTPKTS +
> (ipv6_get_dsfield(hdr) & INET_ECN_MASK),
> max_t(unsigned short, 1, skb_shinfo(skb)->gso_segs));
>
> [...]
Here is the summary with links:
- [net-next] ipv6: fix _DEVADD() and _DEVUPD() macros
https://git.kernel.org/netdev/net-next/c/b709857ecbf5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-25 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 21:25 [PATCH net-next] ipv6: fix _DEVADD() and _DEVUPD() macros Eric Dumazet
2025-03-23 16:53 ` Simon Horman
2025-03-25 15:00 ` 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).