Skip to content

Commit cd0c4e7

Browse files
congwangdavem330
authored andcommitted
net_sched: refetch skb protocol for each filter
Martin reported a set of filters don't work after changing from reclassify to continue. Looking into the code, it looks like skb protocol is not always fetched for each iteration of the filters. But, as demonstrated by Martin, TC actions could modify skb->protocol, for example act_vlan, this means we have to refetch skb protocol in each iteration, rather than using the one we fetch in the beginning of the loop. This bug is _not_ introduced by commit 3b3ae88 ("net: sched: consolidate tc_classify{,_compat}"), technically, if act_vlan is the only action that modifies skb protocol, then it is commit c7e2b96 ("sched: introduce vlan action") which introduced this bug. Reported-by: Martin Olsson <martin.olsson+netdev@sentorsecurity.com> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f2f98c1 commit cd0c4e7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/sched/cls_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,6 @@ EXPORT_SYMBOL(tcf_block_cb_unregister);
12771277
int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
12781278
struct tcf_result *res, bool compat_mode)
12791279
{
1280-
__be16 protocol = tc_skb_protocol(skb);
12811280
#ifdef CONFIG_NET_CLS_ACT
12821281
const int max_reclassify_loop = 4;
12831282
const struct tcf_proto *orig_tp = tp;
@@ -1287,6 +1286,7 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
12871286
reclassify:
12881287
#endif
12891288
for (; tp; tp = rcu_dereference_bh(tp->next)) {
1289+
__be16 protocol = tc_skb_protocol(skb);
12901290
int err;
12911291

12921292
if (tp->protocol != protocol &&
@@ -1319,7 +1319,6 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
13191319
}
13201320

13211321
tp = first_tp;
1322-
protocol = tc_skb_protocol(skb);
13231322
goto reclassify;
13241323
#endif
13251324
}

0 commit comments

Comments
 (0)