Blob Blame History Raw
From 5b75b36198b1cdf66aa0bee5a0a73f1e591af1b2 Mon Sep 17 00:00:00 2001
Message-Id: <5b75b36198b1cdf66aa0bee5a0a73f1e591af1b2.1611831762.git.lorenzo.bianconi@redhat.com>
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Mon, 25 Jan 2021 14:28:48 +0100
Subject: [PATCH] controller: fix pkt_marking with IP buffering

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

https://bugzilla.redhat.com/show_bug.cgi?id=1857106

Tested-by: Jianlin Shi <jishi@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
---
 controller/pinctrl.c |  5 +++++
 tests/ovn.at         | 10 ++++++++++
 2 files changed, 15 insertions(+)

--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -1398,6 +1398,11 @@ buffered_push_packet(struct buffered_pac
     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);
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -15886,6 +15886,14 @@ ovn-nbctl --wait=hv sync
 ovn-sbctl dump-flows > sbflows2
 AT_CAPTURE_FILE([sbflows2])
 
+# create a route policy for pkt marking
+check ovn-nbctl lr-policy-add lr0 2000 "ip4.src == 192.168.1.3" allow
+policy=$(fetch_column nb:Logical_Router_Policy _uuid priority=2000)
+check 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)
@@ -15896,6 +15904,8 @@ echo $(get_arp_req f00000010204 $fip_ip
 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])