Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/sched: act_api: fix miss set post_ct for ovs after do conntrack in act_ct

When openvswitch conntrack offload with act_ct action. The first rule
do conntrack in the act_ct in tc subsystem. And miss the next rule in
the tc and fallback to the ovs datapath but miss set post_ct flag
which will lead the ct_state_key with -trk flag.

Fixes: 7baf2429a1a9 ("net/sched: cls_flower add CT_FLAGS_INVALID flag support")
Signed-off-by: wenxu <wenxu@ucloud.cn>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

wenxu and committed by
David S. Miller
d29334c1 ce225298

+14 -6
+1
include/linux/skbuff.h
··· 285 285 struct tc_skb_ext { 286 286 __u32 chain; 287 287 __u16 mru; 288 + bool post_ct; 288 289 }; 289 290 #endif 290 291
+5 -3
net/openvswitch/conntrack.c
··· 271 271 /* This is called to initialize CT key fields possibly coming in from the local 272 272 * stack. 273 273 */ 274 - void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key) 274 + void ovs_ct_fill_key(const struct sk_buff *skb, 275 + struct sw_flow_key *key, 276 + bool post_ct) 275 277 { 276 - ovs_ct_update_key(skb, NULL, key, false, false); 278 + ovs_ct_update_key(skb, NULL, key, post_ct, false); 277 279 } 278 280 279 281 int ovs_ct_put_key(const struct sw_flow_key *swkey, ··· 1334 1332 if (skb_nfct(skb)) { 1335 1333 nf_conntrack_put(skb_nfct(skb)); 1336 1334 nf_ct_set(skb, NULL, IP_CT_UNTRACKED); 1337 - ovs_ct_fill_key(skb, key); 1335 + ovs_ct_fill_key(skb, key, false); 1338 1336 } 1339 1337 1340 1338 return 0;
+4 -2
net/openvswitch/conntrack.h
··· 25 25 const struct ovs_conntrack_info *); 26 26 int ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key); 27 27 28 - void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key); 28 + void ovs_ct_fill_key(const struct sk_buff *skb, struct sw_flow_key *key, 29 + bool post_ct); 29 30 int ovs_ct_put_key(const struct sw_flow_key *swkey, 30 31 const struct sw_flow_key *output, struct sk_buff *skb); 31 32 void ovs_ct_free_action(const struct nlattr *a); ··· 75 74 } 76 75 77 76 static inline void ovs_ct_fill_key(const struct sk_buff *skb, 78 - struct sw_flow_key *key) 77 + struct sw_flow_key *key, 78 + bool post_ct) 79 79 { 80 80 key->ct_state = 0; 81 81 key->ct_zone = 0;
+3 -1
net/openvswitch/flow.c
··· 857 857 #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT) 858 858 struct tc_skb_ext *tc_ext; 859 859 #endif 860 + bool post_ct = false; 860 861 int res, err; 861 862 862 863 /* Extract metadata from packet. */ ··· 896 895 tc_ext = skb_ext_find(skb, TC_SKB_EXT); 897 896 key->recirc_id = tc_ext ? tc_ext->chain : 0; 898 897 OVS_CB(skb)->mru = tc_ext ? tc_ext->mru : 0; 898 + post_ct = tc_ext ? tc_ext->post_ct : false; 899 899 } else { 900 900 key->recirc_id = 0; 901 901 } ··· 906 904 907 905 err = key_extract(skb, key); 908 906 if (!err) 909 - ovs_ct_fill_key(skb, key); /* Must be after key_extract(). */ 907 + ovs_ct_fill_key(skb, key, post_ct); /* Must be after key_extract(). */ 910 908 return err; 911 909 } 912 910
+1
net/sched/cls_api.c
··· 1629 1629 return TC_ACT_SHOT; 1630 1630 ext->chain = last_executed_chain; 1631 1631 ext->mru = qdisc_skb_cb(skb)->mru; 1632 + ext->post_ct = qdisc_skb_cb(skb)->post_ct; 1632 1633 } 1633 1634 1634 1635 return ret;