[ovs-dev] [PATCH ovn] controller I-P: Add missing FDB flows when a datapath is added locally.
numans at ovn.org
numans at ovn.org
Wed Nov 10 14:34:56 UTC 2021
From: Numan Siddique <numans at ovn.org>
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1983111
Fixes: dd94f1266ca4("northd: MAC learning: Add logical flows for fdb.")
Signed-off-by: Numan Siddique <numans at ovn.org>
---
controller/lflow.c | 12 ++++++++
controller/lflow.h | 1 +
controller/ovn-controller.c | 11 +++++++
tests/ovn.at | 59 +++++++++++++++++++++++++++++++++++--
4 files changed, 80 insertions(+), 3 deletions(-)
diff --git a/controller/lflow.c b/controller/lflow.c
index 923d8f0a4..98ccb01dd 100644
--- a/controller/lflow.c
+++ b/controller/lflow.c
@@ -1979,6 +1979,18 @@ lflow_add_flows_for_datapath(const struct sbrec_datapath_binding *dp,
}
}
}
+
+ struct sbrec_fdb *fdb_index_row =
+ sbrec_fdb_index_init_row(l_ctx_in->sbrec_fdb_by_dp_key);
+ sbrec_fdb_index_set_dp_key(fdb_index_row, dp->tunnel_key);
+ const struct sbrec_fdb *fdb_row;
+ SBREC_FDB_FOR_EACH_EQUAL (fdb_row, fdb_index_row,
+ l_ctx_in->sbrec_fdb_by_dp_key) {
+ consider_fdb_flows(fdb_row, l_ctx_in->local_datapaths,
+ l_ctx_out->flow_table);
+ }
+ sbrec_fdb_index_destroy_row(fdb_index_row);
+
lflow_processing_end:
sbrec_logical_flow_index_destroy_row(lf_row);
diff --git a/controller/lflow.h b/controller/lflow.h
index 61ffbc0cc..b3a105f4b 100644
--- a/controller/lflow.h
+++ b/controller/lflow.h
@@ -131,6 +131,7 @@ struct lflow_ctx_in {
struct ovsdb_idl_index *sbrec_logical_flow_by_logical_datapath;
struct ovsdb_idl_index *sbrec_logical_flow_by_logical_dp_group;
struct ovsdb_idl_index *sbrec_port_binding_by_name;
+ struct ovsdb_idl_index *sbrec_fdb_by_dp_key;
const struct sbrec_port_binding_table *port_binding_table;
const struct sbrec_dhcp_options_table *dhcp_options_table;
const struct sbrec_dhcpv6_options_table *dhcpv6_options_table;
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index f223e0f09..c27feffe1 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -2205,6 +2205,11 @@ init_lflow_ctx(struct engine_node *node,
engine_get_input("SB_multicast_group", node),
"name_datapath");
+ struct ovsdb_idl_index *sbrec_fdb_by_dp_key =
+ engine_ovsdb_node_get_index(
+ engine_get_input("SB_fdb", node),
+ "dp_key");
+
struct sbrec_port_binding_table *port_binding_table =
(struct sbrec_port_binding_table *)EN_OVSDB_GET(
engine_get_input("SB_port_binding", node));
@@ -2272,6 +2277,7 @@ init_lflow_ctx(struct engine_node *node,
l_ctx_in->sbrec_logical_flow_by_logical_dp_group =
sbrec_logical_flow_by_dp_group;
l_ctx_in->sbrec_port_binding_by_name = sbrec_port_binding_by_name;
+ l_ctx_in->sbrec_fdb_by_dp_key = sbrec_fdb_by_dp_key;
l_ctx_in->port_binding_table = port_binding_table;
l_ctx_in->dhcp_options_table = dhcp_table;
l_ctx_in->dhcpv6_options_table = dhcpv6_table;
@@ -3146,6 +3152,9 @@ main(int argc, char *argv[])
= ip_mcast_index_create(ovnsb_idl_loop.idl);
struct ovsdb_idl_index *sbrec_igmp_group
= igmp_group_index_create(ovnsb_idl_loop.idl);
+ struct ovsdb_idl_index *sbrec_fdb_by_dp_key
+ = ovsdb_idl_index_create1(ovnsb_idl_loop.idl,
+ &sbrec_fdb_col_dp_key);
struct ovsdb_idl_index *sbrec_fdb_by_dp_key_mac
= ovsdb_idl_index_create2(ovnsb_idl_loop.idl,
&sbrec_fdb_col_mac,
@@ -3364,6 +3373,8 @@ main(int argc, char *argv[])
sbrec_port_binding_by_datapath);
engine_ovsdb_node_add_index(&en_sb_datapath_binding, "key",
sbrec_datapath_binding_by_key);
+ engine_ovsdb_node_add_index(&en_sb_fdb, "dp_key",
+ sbrec_fdb_by_dp_key);
struct ed_type_lflow_output *lflow_output_data =
engine_get_internal_data(&en_lflow_output);
diff --git a/tests/ovn.at b/tests/ovn.at
index 51e0dae0b..cb1ec33f4 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -26660,7 +26660,7 @@ OVN_CLEANUP([hv1])
AT_CLEANUP
])
-AT_SETUP([OVN FDB (MAC learning) - 2 HVs, 2 LS, 1 LR ])
+AT_SETUP([OVN FDB (MAC learning) - 3 HVs, 2 LS, 1 LR ])
ovn_start
# Create the first logical switch with one port
@@ -26739,6 +26739,21 @@ ovs-vsctl -- add-port br-int hv2-vif2 -- \
options:rxq_pcap=hv2/vif2-rx.pcap \
ofport-request=2
+sim_add hv3
+as hv3
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.3
+ovs-vsctl -- add-port br-int hv3-vif1 -- \
+ set interface hv3-vif1 external-ids:iface-id=sw0-p4 \
+ options:tx_pcap=hv3/vif1-tx.pcap \
+ options:rxq_pcap=hv3/vif1-rx.pcap \
+ ofport-request=1
+ovs-vsctl -- add-port br-int hv3-vif2 -- \
+ set interface hv3-vif2 external-ids:iface-id=sw1-p3 \
+ options:tx_pcap=hv3/vif2-tx.pcap \
+ options:rxq_pcap=hv3/vif2-rx.pcap \
+ ofport-request=2
+
OVN_POPULATE_ARP
ip_to_hex() {
@@ -26851,6 +26866,30 @@ AT_CHECK([cat hv2_offlows_table72.txt | grep -v NXST | cut -d ' ' -f8- | sort],
priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG10[[8]]
])
+# Create the logical port sw0-p4 and this should be claimed by
+# hv3 and it should install the fdb flows in table 71 and 72.
+
+check ovn-nbctl lsp-add sw0 sw0-p4
+wait_for_ports_up sw0-p4
+
+#as hv3 ovn-appctl -t ovn-controller recompute
+check ovn-nbctl --wait=hv sync
+
+as hv3 ovs-ofctl dump-flows br-int table=71 > hv3_offlows_table71.txt
+as hv3 ovs-ofctl dump-flows br-int table=72 > hv3_offlows_table72.txt
+
+
+AT_CAPTURE_FILE([hv3_offlows_table71.txt])
+AT_CAPTURE_FILE([hv3_offlows_table72.txt])
+
+AT_CHECK([cat hv3_offlows_table71.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
+priority=100,metadata=0x1,dl_dst=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG15[[]]
+])
+
+AT_CHECK([cat hv3_offlows_table72.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
+priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG10[[8]]
+])
+
# Use the src mac 50:54:00:00:00:14 instead of 50:54:00:00:00:03
src_mac=505400000014
src_ip=$(ip_to_hex 10 0 0 14)
@@ -26867,12 +26906,14 @@ check_column "50:54:00:00:00:13 50:54:00:00:00:14" fdb mac
check_column "$sw0_dpkey $sw0_dpkey" fdb dp_key
check_column "$sw0p1_dpkey $sw0p1_dpkey" fdb port_key
-# Make sure that OVS tables 71 and 72 are populated on both hv1 and hv2.
+# Make sure that OVS tables 71 and 72 are populated on hv1, hv2 and hv3.
as hv1 ovs-ofctl dump-flows br-int table=71 > hv1_offlows_table71.txt
as hv2 ovs-ofctl dump-flows br-int table=71 > hv2_offlows_table71.txt
+as hv3 ovs-ofctl dump-flows br-int table=71 > hv3_offlows_table71.txt
AT_CAPTURE_FILE([hv1_offlows_table71.txt])
AT_CAPTURE_FILE([hv2_offlows_table71.txt])
+AT_CAPTURE_FILE([hv3_offlows_table71.txt])
AT_CHECK([cat hv1_offlows_table71.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
priority=100,metadata=0x1,dl_dst=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG15[[]]
priority=100,metadata=0x1,dl_dst=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG15[[]]
@@ -26883,11 +26924,18 @@ priority=100,metadata=0x1,dl_dst=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG1
priority=100,metadata=0x1,dl_dst=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG15[[]]
])
+AT_CHECK([cat hv3_offlows_table71.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
+priority=100,metadata=0x1,dl_dst=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG15[[]]
+priority=100,metadata=0x1,dl_dst=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG15[[]]
+])
+
as hv1 ovs-ofctl dump-flows br-int table=72 > hv1_offlows_table72.txt
as hv2 ovs-ofctl dump-flows br-int table=72 > hv2_offlows_table72.txt
+as hv3 ovs-ofctl dump-flows br-int table=72 > hv3_offlows_table72.txt
AT_CAPTURE_FILE([hv1_offlows_table72.txt])
AT_CAPTURE_FILE([hv2_offlows_table72.txt])
+AT_CAPTURE_FILE([hv3_offlows_table72.txt])
AT_CHECK([cat hv1_offlows_table72.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG10[[8]]
priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG10[[8]]
@@ -26898,6 +26946,11 @@ priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:13 actions=load:0x1->N
priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG10[[8]]
])
+AT_CHECK([cat hv3_offlows_table72.txt | grep -v NXST | cut -d ' ' -f8- | sort], [0], [dnl
+priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:13 actions=load:0x1->NXM_NX_REG10[[8]]
+priority=100,reg14=0x1,metadata=0x1,dl_src=50:54:00:00:00:14 actions=load:0x1->NXM_NX_REG10[[8]]
+])
+
as hv1 reset_pcap_file hv1-vif1 hv1/vif1
as hv2 reset_pcap_file hv2-vif1 hv2/vif1
@@ -27080,7 +27133,7 @@ AT_CHECK([cat hv1_offlows_table72.txt | grep -v NXST], [1], [dnl
AT_CHECK([cat hv2_offlows_table72.txt | grep -v NXST], [1], [dnl
])
-OVN_CLEANUP([hv1], [hv2])
+OVN_CLEANUP([hv1], [hv2], [hv3])
AT_CLEANUP
])
--
2.33.1
More information about the dev
mailing list