History

net: openvswitch: Fix matching zone id for invalid conns arriving from tc

Zone id is not restored if we passed ct and ct rejected the connection, as there is no ct info on the skb. Save the zone from tc skb cb to tc skb extension and pass it on to ovs, use that info to restore the zone id for invalid connections.

Paul Blakey committed 4 years ago

Commit 635d4481 parent 38495953 files · +9 −1Browse files

Unified · Split

3 files
  1. include/linux/skbuff.h +1 −0
  2. net/openvswitch/flow.c +7 −1
  3. net/sched/cls_api.c +1 −0
include/linux/skbuff.h+1−0
@@ -286,6 +286,7 @@ struct nf_bridge_info { · 285 unmodified lines
286286 struct tc_skb_ext {
287287 __u32 chain;
288288 __u16 mru;
289+ __u16 zone;
289290 bool post_ct;
290291 };
291292 #endif
net/openvswitch/flow.c+7−1
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include <net/mpls.h>
3535 #include <net/ndisc.h>
3636 #include <net/nsh.h>
37+#include <net/netfilter/nf_conntrack_zones.h>
3738
3839 #include "conntrack.h"
3940 #include "datapath.h"
@@ -860,6 +861,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, · 820 unmodified lines
860861 #endif
861862 bool post_ct = false;
862863 int res, err;
864+ u16 zone = 0;
863865
864866 /* Extract metadata from packet. */
865867 if (tun_info) {
@@ -898,6 +900,7 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, · 32 unmodified lines
898900 key->recirc_id = tc_ext ? tc_ext->chain : 0;
899901 OVS_CB(skb)->mru = tc_ext ? tc_ext->mru : 0;
900902 post_ct = tc_ext ? tc_ext->post_ct : false;
903+ zone = post_ct ? tc_ext->zone : 0;
901904 } else {
902905 key->recirc_id = 0;
903906 }
@@ -906,8 +909,11 @@ int ovs_flow_key_extract(const struct ip_tunnel_info *tun_info, · 2 unmodified lines
906909 #endif
907910
908911 err = key_extract(skb, key);
909− if (!err)
912+ if (!err) {
910913 ovs_ct_fill_key(skb, key, post_ct); /* Must be after key_extract(). */
914+ if (post_ct && !skb_get_nfct(skb))
915+ key->ct_zone = zone;
916+ }
911917 return err;
912918 }
913919
net/sched/cls_api.c+1−0
@@ -1625,6 +1625,7 @@ int tcf_classify(struct sk_buff *skb, · 1624 unmodified lines
16251625 ext->chain = last_executed_chain;
16261626 ext->mru = cb->mru;
16271627 ext->post_ct = cb->post_ct;
1628+ ext->zone = cb->zone;
16281629 }
16291630
16301631 return ret;