net_sched: unset TCQ_F_CAN_BYPASS when adding filters
Subsystems (3)
PATCH 1/1 net_sched: unset TCQ_F_CAN_BYPASS when adding filters
For qdisc's that support TC filters and set TCQ_F_CAN_BYPASS, notably fq_codel, it makes no sense to let packets bypass the TC filters we setup in any scenario, otherwise our packets steering policy could not be enforced.
This can be easily reproduced with the following script:
ip li add dev dummy0 type dummy
ifconfig dummy0 up
tc qd add dev dummy0 root fq_codel
tc filter add dev dummy0 parent 8001: protocol arp basic action mirred egress redirect dev lo tc filter add dev dummy0 parent 8001: protocol ip basic action mirred egress redirect dev lo ping -I dummy0 192.168.112.1
Without this patch, packets are sent directly to dummy0 without hitting any of the filters. With this patch, packets are redirected to loopback as expected.
This fix is not perfect, it only unsets the flag but does not set it back because we have to save the information somewhere in the qdisc if we really want that.
--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_api.c +1 -0
@@ -2152,6 +2152,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,tfilter_notify (net, skb, n, tp, block, q, parent, fh,RTM_NEWTFILTER , false, rtnl_held);tfilter_put (tp, fh); + q->flags &= ~TCQ_F_CAN_BYPASS ; } errout:
Signature · 1 line
2.21.0
Quoted 35 lines · Cong Wang
For qdisc's that support TC filters and set
TCQ_F_CAN_BYPASS, notablyfq_codel, it makes no sense to let packets bypass the TC filters we setup in any scenario, otherwise our packets steering policy could not be enforced.This can be easily reproduced with the following script:
ip li add dev dummy0 type dummy
ifconfig dummy0 up
tc qd add dev dummy0 rootfq_codel
tc filter add dev dummy0 parent 8001: protocol arp basic action mirred egress redirect dev lo tc filter add dev dummy0 parent 8001: protocol ip basic action mirred egress redirect dev lo ping -I dummy0 192.168.112.1Without this patch, packets are sent directly to dummy0 without hitting any of the filters. With this patch, packets are redirected to loopback as expected.
This fix is not perfect, it only unsets the flag but does not set it back because we have to save the information somewhere in the qdisc if we really want that.
Fixes 4b549a2ef4be ("fq_codel: Fair Queue Codel AQM")Cc Eric Dumazet <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)net/sched/cls_api.c +0
-0
net/sched/cls_api.c static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, · line 2158
Quoted 7 lines
net/sched/cls_api.c +1
-0@@ -2152,6 +2152,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,tfilter_notify (net, skb, n, tp, block, q, parent, fh,RTM_NEWTFILTER , false, rtnl_held);tfilter_put (tp, fh); + q->flags &= ~TCQ_F_CAN_BYPASS ; } errout:
Strange, because sfq and fq_codel are roughly the same for TCQ_F_CAN_BYPASS handling.
Why is fq_codel_bind() not effective ?
If not effective, sfq had the same issue, so the Fixes: tag needs to be refined, maybe to commit 23624935e0c4 net_sched: TCQ_F_CAN_BYPASS generalization
Quoted 44 lines · Eric Dumazet
Quoted 40 lines · Cong Wang
For qdisc's that support TC filters and set
TCQ_F_CAN_BYPASS, notablyfq_codel, it makes no sense to let packets bypass the TC filters we setup in any scenario, otherwise our packets steering policy could not be enforced.This can be easily reproduced with the following script:
ip li add dev dummy0 type dummy
ifconfig dummy0 up
tc qd add dev dummy0 rootfq_codel
tc filter add dev dummy0 parent 8001: protocol arp basic action mirred egress redirect dev lo tc filter add dev dummy0 parent 8001: protocol ip basic action mirred egress redirect dev lo ping -I dummy0 192.168.112.1Without this patch, packets are sent directly to dummy0 without hitting any of the filters. With this patch, packets are redirected to loopback as expected.
This fix is not perfect, it only unsets the flag but does not set it back because we have to save the information somewhere in the qdisc if we really want that.
Fixes 4b549a2ef4be ("fq_codel: Fair Queue Codel AQM")Cc Eric Dumazet <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)net/sched/cls_api.c +1
-0@@ -2152,6 +2152,7 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,tfilter_notify (net, skb, n, tp, block, q, parent, fh,RTM_NEWTFILTER , false, rtnl_held);tfilter_put (tp, fh); + q->flags &= ~TCQ_F_CAN_BYPASS ; }
Quoted 6 lines
net/sched/cls_api.c static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n, · line 2158
Quoted 2 lines
net/sched/cls_api.c +0
-0errout:Strange, because sfq and
fq_codelare roughly the same forTCQ_F_CAN_BYPASShandling.Why is
fq_codel_bind()not effective ?
Because I don't have class id set in the filter.
Quoted 4 lines
If not effective, sfq had the same issue, so the Fixes: tag needs to be refined, maybe to commit
23624935e0c4net_sched:TCQ_F_CAN_BYPASSgeneralization
Yeah, I think it is probably a better commit here.
Thanks.