Skip to content

Commit 3849595

Browse files
Paul Blakeykuba-moo
authored andcommitted
net/sched: flow_dissector: Fix matching on zone id for invalid conns
If ct rejects a flow, it removes the conntrack info from the skb. act_ct sets the post_ct variable so the dissector will see this case as an +tracked +invalid state, but the zone id is lost with the conntrack info. To restore the zone id on such cases, set the last executed zone, via the tc control block, when passing ct, and read it back in the dissector if there is no ct info on the skb (invalid connection). Fixes: 7baf242 ("net/sched: cls_flower add CT_FLAGS_INVALID flag support") Signed-off-by: Paul Blakey <paulb@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ec624fe commit 3849595

5 files changed

Lines changed: 7 additions & 3 deletions

File tree

include/linux/skbuff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ skb_flow_dissect_ct(const struct sk_buff *skb,
13801380
struct flow_dissector *flow_dissector,
13811381
void *target_container,
13821382
u16 *ctinfo_map, size_t mapsize,
1383-
bool post_ct);
1383+
bool post_ct, u16 zone);
13841384
void
13851385
skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
13861386
struct flow_dissector *flow_dissector,

include/net/pkt_sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ struct tc_skb_cb {
198198

199199
u16 mru;
200200
bool post_ct;
201+
u16 zone; /* Only valid if post_ct = true */
201202
};
202203

203204
static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb)

net/core/flow_dissector.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void
238238
skb_flow_dissect_ct(const struct sk_buff *skb,
239239
struct flow_dissector *flow_dissector,
240240
void *target_container, u16 *ctinfo_map,
241-
size_t mapsize, bool post_ct)
241+
size_t mapsize, bool post_ct, u16 zone)
242242
{
243243
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
244244
struct flow_dissector_key_ct *key;
@@ -260,6 +260,7 @@ skb_flow_dissect_ct(const struct sk_buff *skb,
260260
if (!ct) {
261261
key->ct_state = TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
262262
TCA_FLOWER_KEY_CT_FLAGS_INVALID;
263+
key->ct_zone = zone;
263264
return;
264265
}
265266

net/sched/act_ct.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
10491049
skb_push_rcsum(skb, nh_ofs);
10501050

10511051
tc_skb_cb(skb)->post_ct = true;
1052+
tc_skb_cb(skb)->zone = p->zone;
10521053
out_clear:
10531054
if (defrag)
10541055
qdisc_skb_cb(skb)->pkt_len = skb->len;

net/sched/cls_flower.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
311311
{
312312
struct cls_fl_head *head = rcu_dereference_bh(tp->root);
313313
bool post_ct = tc_skb_cb(skb)->post_ct;
314+
u16 zone = tc_skb_cb(skb)->zone;
314315
struct fl_flow_key skb_key;
315316
struct fl_flow_mask *mask;
316317
struct cls_fl_filter *f;
@@ -328,7 +329,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
328329
skb_flow_dissect_ct(skb, &mask->dissector, &skb_key,
329330
fl_ct_info_to_flower_map,
330331
ARRAY_SIZE(fl_ct_info_to_flower_map),
331-
post_ct);
332+
post_ct, zone);
332333
skb_flow_dissect_hash(skb, &mask->dissector, &skb_key);
333334
skb_flow_dissect(skb, &mask->dissector, &skb_key,
334335
FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP);

0 commit comments

Comments
 (0)