5f9769
From 5b75b36198b1cdf66aa0bee5a0a73f1e591af1b2 Mon Sep 17 00:00:00 2001
5f9769
Message-Id: <5b75b36198b1cdf66aa0bee5a0a73f1e591af1b2.1611831762.git.lorenzo.bianconi@redhat.com>
5f9769
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5f9769
Date: Mon, 25 Jan 2021 14:28:48 +0100
5f9769
Subject: [PATCH] controller: fix pkt_marking with IP buffering
5f9769
5f9769
Reload pkt_marking metadata for cloned packets during ARP/ND address
5f9769
resolution.
5f9769
5f9769
https://bugzilla.redhat.com/show_bug.cgi?id=1857106
5f9769
5f9769
Tested-by: Jianlin Shi <jishi@redhat.com>
5f9769
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
5f9769
Signed-off-by: Numan Siddique <numans@ovn.org>
5f9769
---
5f9769
 controller/pinctrl.c |  5 +++++
5f9769
 tests/ovn.at         | 10 ++++++++++
5f9769
 2 files changed, 15 insertions(+)
5f9769
5f9769
--- a/controller/pinctrl.c
5f9769
+++ b/controller/pinctrl.c
5f9769
@@ -1398,6 +1398,11 @@ buffered_push_packet(struct buffered_pac
5f9769
     ofpbuf_init(&bi->ofpacts, 4096);
5f9769
 
5f9769
     reload_metadata(&bi->ofpacts, md);
5f9769
+    /* reload pkt_mark field */
5f9769
+    const struct mf_field *pkt_mark_field = mf_from_id(MFF_PKT_MARK);
5f9769
+    union mf_value pkt_mark_value;
5f9769
+    mf_get_value(pkt_mark_field, &md->flow, &pkt_mark_value);
5f9769
+    ofpact_put_set_field(&bi->ofpacts, pkt_mark_field, &pkt_mark_value, NULL);
5f9769
     bi->ofp_port = md->flow.in_port.ofp_port;
5f9769
 
5f9769
     struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(&bi->ofpacts);
5f9769
--- a/tests/ovn.at
5f9769
+++ b/tests/ovn.at
5f9769
@@ -15886,6 +15886,14 @@ ovn-nbctl --wait=hv sync
5f9769
 ovn-sbctl dump-flows > sbflows2
5f9769
 AT_CAPTURE_FILE([sbflows2])
5f9769
 
5f9769
+# create a route policy for pkt marking
5f9769
+check ovn-nbctl lr-policy-add lr0 2000 "ip4.src == 192.168.1.3" allow
5f9769
+policy=$(fetch_column nb:Logical_Router_Policy _uuid priority=2000)
5f9769
+check ovn-nbctl set logical_router_policy $policy options:pkt_mark=100
5f9769
+as hv2
5f9769
+# add a flow in egress pipeline to check pkt marking
5f9769
+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)"
5f9769
+
5f9769
 dst_ip=$(ip_to_hex 172 16 2 10)
5f9769
 fip_ip=$(ip_to_hex 172 16 1 2)
5f9769
 src_ip=$(ip_to_hex 192 168 1 3)
5f9769
@@ -15896,6 +15904,8 @@ echo $(get_arp_req f00000010204 $fip_ip
5f9769
 send_arp_reply 2 1 $gw_router_mac f00000010204 $gw_router_ip $fip_ip
5f9769
 echo "${gw_router_mac}f0000001020408004500001c00004000fe0121b4${fip_ip}${dst_ip}${data}" >> expected
5f9769
 
5f9769
+AT_CHECK([as hv2 ovs-ofctl dump-flows br-int table=32 | grep pkt_mark=0x64 | grep -q n_packets=1],[0])
5f9769
+
5f9769
 OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected])
5f9769
 
5f9769
 OVN_CLEANUP([hv1],[hv2])