netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net/sched: act_mirred: Fix infinite loop
@ 2025-11-24 20:08 Jamal Hadi Salim
  2025-11-24 20:08 ` [PATCH net-next 2/2] selftests/tc-testing: Add test cases exercising mirred redirects (with loops) Jamal Hadi Salim
  2025-11-24 22:51 ` [PATCH net-next 1/2] net/sched: act_mirred: Fix infinite loop Jakub Kicinski
  0 siblings, 2 replies; 17+ messages in thread
From: Jamal Hadi Salim @ 2025-11-24 20:08 UTC (permalink / raw)
  To: davem, kuba, edumazet, pabeni
  Cc: jiri, xiyou.wangcong, netdev, dcaratti, Jamal Hadi Salim

When doing multiport mirroring we dont detect infinite loops.

Example (see the first accompanying tdc test):
packet showing up on port0 ingress mirred redirect --> port1 egress
packet showing up on port1 egress mirred redirect --> port0 ingress

Example 2 (see the second accompanying tdc test)
port0 egress --> port1 ingress --> port0 egress

Fix this by remembering the source dev where mirred ran as opposed to
destination/target dev

Fixes: fe946a751d9b ("net/sched: act_mirred: add loop detection")
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/sched/act_mirred.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index f27b583def78..7315179197fd 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -453,7 +453,7 @@ TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,
 		return retval;
 	}
 
-	xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = dev;
+	xmit->sched_mirred_dev[xmit->sched_mirred_nest++] = skb->dev;
 
 	m_mac_header_xmit = READ_ONCE(m->tcfm_mac_header_xmit);
 	m_eaction = READ_ONCE(m->tcfm_eaction);
-- 
2.34.1


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

end of thread, other threads:[~2025-12-10 14:59 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 20:08 [PATCH net-next 1/2] net/sched: act_mirred: Fix infinite loop Jamal Hadi Salim
2025-11-24 20:08 ` [PATCH net-next 2/2] selftests/tc-testing: Add test cases exercising mirred redirects (with loops) Jamal Hadi Salim
2025-11-24 22:51 ` [PATCH net-next 1/2] net/sched: act_mirred: Fix infinite loop Jakub Kicinski
2025-11-25 16:20   ` Jamal Hadi Salim
2025-11-26 16:26     ` Jamal Hadi Salim
2025-11-26 16:40       ` Eric Dumazet
2025-11-26 18:14         ` Jamal Hadi Salim
2025-11-26 18:19           ` Eric Dumazet
2025-11-26 19:00             ` Jamal Hadi Salim
2025-11-26 20:20             ` Jamal Hadi Salim
2025-11-26 20:29               ` Eric Dumazet
2025-11-27 14:45                 ` Jamal Hadi Salim
2025-11-27 15:11                   ` Eric Dumazet
2025-11-27 15:23                     ` Jamal Hadi Salim
2025-11-27 16:21                       ` Jamal Hadi Salim
2025-12-03 14:27                         ` Jamal Hadi Salim
2025-12-10 14:59                           ` Jamal Hadi Salim

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).