Skip to content

Commit

Permalink
net: sched: act_mirred: Reset ct info when mirror/redirect skb
Browse files Browse the repository at this point in the history
When mirror/redirect a skb to a different port, the ct info should be reset
for reclassification. Or the pkts will match unexpected rules. For example,
with following topology and commands:

    -----------
              |
       veth0 -+-------
              |
       veth1 -+-------
              |
   ------------

 tc qdisc add dev veth0 clsact
 # The same with "action mirred egress mirror dev veth1" or "action mirred ingress redirect dev veth1"
 tc filter add dev veth0 egress chain 1 protocol ip flower ct_state +trk action mirred ingress mirror dev veth1
 tc filter add dev veth0 egress chain 0 protocol ip flower ct_state -inv action ct commit action goto chain 1
 tc qdisc add dev veth1 clsact
 tc filter add dev veth1 ingress chain 0 protocol ip flower ct_state +trk action drop

 ping <remove ip via veth0> &
 tc -s filter show dev veth1 ingress

With command 'tc -s filter show', we can find the pkts were dropped on
veth1.

Fixes: b57dc7c ("net/sched: Introduce action ct")
Signed-off-by: Roi Dayan <[email protected]>
Signed-off-by: Hangbin Liu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
liuhangbin authored and davem330 committed Aug 9, 2021
1 parent 605bb44 commit d09c548
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/sched/act_mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
goto out;
}

/* All mirred/redirected skbs should clear previous ct info */
nf_reset_ct(skb2);

want_ingress = tcf_mirred_act_wants_ingress(m_eaction);

expects_nh = want_ingress || !m_mac_header_xmit;
Expand Down

0 comments on commit d09c548

Please sign in to comment.