[ovs-dev] [PATCH ovn] controller: fix pkt_marking with IP buffering

Lorenzo Bianconi lorenzo.bianconi at redhat.com
Wed Jan 20 15:37:53 UTC 2021


Reload pkt_marking metadata for cloned packets during ARP/ND address
resolution.

https://bugzilla.redhat.com/show_bug.cgi?id=1857106
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
---
 controller/pinctrl.c |  5 +++++
 tests/ovn.at         | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index 5f72c0e07..dcf6b4af5 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -1399,6 +1399,11 @@ buffered_push_packet(struct buffered_packets *bp,
     ofpbuf_init(&bi->ofpacts, 4096);
 
     reload_metadata(&bi->ofpacts, md);
+    /* reload pkt_mark field */
+    const struct mf_field *pkt_mark_field = mf_from_id(MFF_PKT_MARK);
+    union mf_value pkt_mark_value;
+    mf_get_value(pkt_mark_field, &md->flow, &pkt_mark_value);
+    ofpact_put_set_field(&bi->ofpacts, pkt_mark_field, &pkt_mark_value, NULL);
     bi->ofp_port = md->flow.in_port.ofp_port;
 
     struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(&bi->ofpacts);
diff --git a/tests/ovn.at b/tests/ovn.at
index 8f884241d..894a4294e 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -15987,6 +15987,14 @@ ovn-nbctl --wait=hv sync
 ovn-sbctl dump-flows > sbflows2
 AT_CAPTURE_FILE([sbflows2])
 
+# create a route policy for pkt marking
+ovn-nbctl lr-policy-add lr0 2000 "ip4.src == 192.168.1.3" allow
+policy=$(ovn-nbctl --bare --columns _uuid find logical_router_policy priority=2000)
+ovn-nbctl set logical_router_policy $policy options:pkt_mark=100
+as hv2
+# add a flow in egress pipeline to check pkt marking
+ovs-ofctl --protocols=OpenFlow13 add-flow br-int "table=32,priority=200,ip,nw_src=172.16.1.2,pkt_mark=0x64 actions=resubmit(,33)"
+
 dst_ip=$(ip_to_hex 172 16 2 10)
 fip_ip=$(ip_to_hex 172 16 1 2)
 src_ip=$(ip_to_hex 192 168 1 3)
@@ -15997,6 +16005,8 @@ echo $(get_arp_req f00000010204 $fip_ip $gw_router_ip) >> expected
 send_arp_reply 2 1 $gw_router_mac f00000010204 $gw_router_ip $fip_ip
 echo "${gw_router_mac}f0000001020408004500001c00004000fe0121b4${fip_ip}${dst_ip}${data}" >> expected
 
+AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep pkt_mark=0x64 | grep -q n_packets=1],[0])
+
 OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
 
 OVN_CLEANUP([hv1],[hv2])
-- 
2.29.2



More information about the dev mailing list