cls-flower does not include the ports in the 1rst ipv4/6 fragments. Thus, if fragments are to be allowed, then port based rules have no choice but to allow all fragments destined to all ports. Let's include ports in the 1rst fragment. Thus, fragmented packets can be allowed/blocked by adding a rule which allows/blocks specific ports and allows all non-first ip fragments (via setting ip_flags to frag/nofirstfrag).
Cc: Jamal Hadi Salim <j...@mojatatu.com> Cc: Cong Wang <xiyou.wangc...@gmail.com> Cc: Jiri Pirko <j...@resnulli.us> Signed-off-by: Jason Baron <jba...@akamai.com> --- net/core/flow_dissector.c | 4 +++- net/sched/cls_flower.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 0aeb335..bfd554e 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -1446,7 +1446,9 @@ bool __skb_flow_dissect(const struct net *net, break; } - if (!(key_control->flags & FLOW_DIS_IS_FRAGMENT)) + if (!(key_control->flags & FLOW_DIS_IS_FRAGMENT) || + ((key_control->flags & FLOW_DIS_FIRST_FRAG) && + (FLOW_DISSECTOR_F_PARSE_1ST_FRAG & flags))) __skb_flow_dissect_ports(skb, flow_dissector, target_container, data, nhoff, ip_proto, hlen); diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 96f5999..e16227a 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -317,7 +317,8 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, skb_flow_dissect_ct(skb, &mask->dissector, &skb_key, fl_ct_info_to_flower_map, ARRAY_SIZE(fl_ct_info_to_flower_map)); - skb_flow_dissect(skb, &mask->dissector, &skb_key, 0); + skb_flow_dissect(skb, &mask->dissector, &skb_key, + FLOW_DISSECTOR_F_PARSE_1ST_FRAG); fl_set_masked_key(&skb_mkey, &skb_key, mask); -- 2.7.4