|
|
5f9769 |
From a6b4b14ac1b6523f85fb13a7f259d9698a70444f Mon Sep 17 00:00:00 2001
|
|
|
5f9769 |
Message-Id: <a6b4b14ac1b6523f85fb13a7f259d9698a70444f.1610458802.git.lorenzo.bianconi@redhat.com>
|
|
|
5f9769 |
In-Reply-To: <f21c1b7a467a691847b5552d4570af706fcc5bb0.1610458802.git.lorenzo.bianconi@redhat.com>
|
|
|
5f9769 |
References: <f21c1b7a467a691847b5552d4570af706fcc5bb0.1610458802.git.lorenzo.bianconi@redhat.com>
|
|
|
5f9769 |
From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
|
|
|
5f9769 |
Date: Tue, 5 Jan 2021 17:49:35 +0000
|
|
|
5f9769 |
Subject: [PATCH 08/16] ovn-northd: split build_lswitch_output_port_sec into
|
|
|
5f9769 |
iterators.
|
|
|
5f9769 |
|
|
|
5f9769 |
Split build_lswitch_output_port_sec into a per port and per
|
|
|
5f9769 |
datapath iterator. Migrate to the relevant per-port and
|
|
|
5f9769 |
per-datapath loops.
|
|
|
5f9769 |
|
|
|
5f9769 |
Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
|
|
|
5f9769 |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
5f9769 |
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
5f9769 |
---
|
|
|
5f9769 |
northd/ovn-northd.c | 82 ++++++++++++++++++++-------------------------
|
|
|
5f9769 |
1 file changed, 37 insertions(+), 45 deletions(-)
|
|
|
5f9769 |
|
|
|
5f9769 |
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
|
|
|
5f9769 |
index 27a788095..92300e017 100644
|
|
|
5f9769 |
--- a/northd/ovn-northd.c
|
|
|
5f9769 |
+++ b/northd/ovn-northd.c
|
|
|
5f9769 |
@@ -4917,51 +4917,47 @@ build_lswitch_input_port_sec_od(
|
|
|
5f9769 |
}
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
+/* Egress table 8: Egress port security - IP (priorities 90 and 80)
|
|
|
5f9769 |
+ * if port security enabled.
|
|
|
5f9769 |
+ *
|
|
|
5f9769 |
+ * Egress table 9: Egress port security - L2 (priorities 50 and 150).
|
|
|
5f9769 |
+ *
|
|
|
5f9769 |
+ * Priority 50 rules implement port security for enabled logical port.
|
|
|
5f9769 |
+ *
|
|
|
5f9769 |
+ * Priority 150 rules drop packets to disabled logical ports, so that
|
|
|
5f9769 |
+ * they don't even receive multicast or broadcast packets.
|
|
|
5f9769 |
+ */
|
|
|
5f9769 |
static void
|
|
|
5f9769 |
-build_lswitch_output_port_sec(struct hmap *ports, struct hmap *datapaths,
|
|
|
5f9769 |
- struct hmap *lflows)
|
|
|
5f9769 |
+build_lswitch_output_port_sec_op(struct ovn_port *op,
|
|
|
5f9769 |
+ struct hmap *lflows,
|
|
|
5f9769 |
+ struct ds *match,
|
|
|
5f9769 |
+ struct ds *actions)
|
|
|
5f9769 |
{
|
|
|
5f9769 |
- struct ds actions = DS_EMPTY_INITIALIZER;
|
|
|
5f9769 |
- struct ds match = DS_EMPTY_INITIALIZER;
|
|
|
5f9769 |
- struct ovn_port *op;
|
|
|
5f9769 |
|
|
|
5f9769 |
- /* Egress table 8: Egress port security - IP (priorities 90 and 80)
|
|
|
5f9769 |
- * if port security enabled.
|
|
|
5f9769 |
- *
|
|
|
5f9769 |
- * Egress table 9: Egress port security - L2 (priorities 50 and 150).
|
|
|
5f9769 |
- *
|
|
|
5f9769 |
- * Priority 50 rules implement port security for enabled logical port.
|
|
|
5f9769 |
- *
|
|
|
5f9769 |
- * Priority 150 rules drop packets to disabled logical ports, so that
|
|
|
5f9769 |
- * they don't even receive multicast or broadcast packets.
|
|
|
5f9769 |
- */
|
|
|
5f9769 |
- HMAP_FOR_EACH (op, key_node, ports) {
|
|
|
5f9769 |
- if (!op->nbsp || lsp_is_external(op->nbsp)) {
|
|
|
5f9769 |
- continue;
|
|
|
5f9769 |
- }
|
|
|
5f9769 |
+ if (op->nbsp && (!lsp_is_external(op->nbsp))) {
|
|
|
5f9769 |
|
|
|
5f9769 |
- ds_clear(&actions);
|
|
|
5f9769 |
- ds_clear(&match);
|
|
|
5f9769 |
+ ds_clear(actions);
|
|
|
5f9769 |
+ ds_clear(match);
|
|
|
5f9769 |
|
|
|
5f9769 |
- ds_put_format(&match, "outport == %s", op->json_key);
|
|
|
5f9769 |
+ ds_put_format(match, "outport == %s", op->json_key);
|
|
|
5f9769 |
if (lsp_is_enabled(op->nbsp)) {
|
|
|
5f9769 |
build_port_security_l2("eth.dst", op->ps_addrs, op->n_ps_addrs,
|
|
|
5f9769 |
- &match);
|
|
|
5f9769 |
+ match);
|
|
|
5f9769 |
|
|
|
5f9769 |
if (!strcmp(op->nbsp->type, "localnet")) {
|
|
|
5f9769 |
const char *queue_id = smap_get(&op->sb->options,
|
|
|
5f9769 |
"qdisc_queue_id");
|
|
|
5f9769 |
if (queue_id) {
|
|
|
5f9769 |
- ds_put_format(&actions, "set_queue(%s); ", queue_id);
|
|
|
5f9769 |
+ ds_put_format(actions, "set_queue(%s); ", queue_id);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
}
|
|
|
5f9769 |
- ds_put_cstr(&actions, "output;");
|
|
|
5f9769 |
+ ds_put_cstr(actions, "output;");
|
|
|
5f9769 |
ovn_lflow_add_with_hint(lflows, op->od, S_SWITCH_OUT_PORT_SEC_L2,
|
|
|
5f9769 |
- 50, ds_cstr(&match), ds_cstr(&actions),
|
|
|
5f9769 |
+ 50, ds_cstr(match), ds_cstr(actions),
|
|
|
5f9769 |
&op->nbsp->header_);
|
|
|
5f9769 |
} else {
|
|
|
5f9769 |
ovn_lflow_add_with_hint(lflows, op->od, S_SWITCH_OUT_PORT_SEC_L2,
|
|
|
5f9769 |
- 150, ds_cstr(&match), "drop;",
|
|
|
5f9769 |
+ 150, ds_cstr(match), "drop;",
|
|
|
5f9769 |
&op->nbsp->header_);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
@@ -4969,23 +4965,20 @@ build_lswitch_output_port_sec(struct hmap *ports, struct hmap *datapaths,
|
|
|
5f9769 |
build_port_security_ip(P_OUT, op, lflows, &op->nbsp->header_);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
}
|
|
|
5f9769 |
+}
|
|
|
5f9769 |
|
|
|
5f9769 |
- /* Egress tables 8: Egress port security - IP (priority 0)
|
|
|
5f9769 |
- * Egress table 9: Egress port security L2 - multicast/broadcast
|
|
|
5f9769 |
- * (priority 100). */
|
|
|
5f9769 |
- struct ovn_datapath *od;
|
|
|
5f9769 |
- HMAP_FOR_EACH (od, key_node, datapaths) {
|
|
|
5f9769 |
- if (!od->nbs) {
|
|
|
5f9769 |
- continue;
|
|
|
5f9769 |
- }
|
|
|
5f9769 |
-
|
|
|
5f9769 |
+/* Egress tables 8: Egress port security - IP (priority 0)
|
|
|
5f9769 |
+ * Egress table 9: Egress port security L2 - multicast/broadcast
|
|
|
5f9769 |
+ * (priority 100). */
|
|
|
5f9769 |
+static void
|
|
|
5f9769 |
+build_lswitch_output_port_sec_od(struct ovn_datapath *od,
|
|
|
5f9769 |
+ struct hmap *lflows)
|
|
|
5f9769 |
+{
|
|
|
5f9769 |
+ if (od->nbs) {
|
|
|
5f9769 |
ovn_lflow_add(lflows, od, S_SWITCH_OUT_PORT_SEC_IP, 0, "1", "next;");
|
|
|
5f9769 |
ovn_lflow_add(lflows, od, S_SWITCH_OUT_PORT_SEC_L2, 100, "eth.mcast",
|
|
|
5f9769 |
"output;");
|
|
|
5f9769 |
}
|
|
|
5f9769 |
-
|
|
|
5f9769 |
- ds_destroy(&match);
|
|
|
5f9769 |
- ds_destroy(&actions);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
static void
|
|
|
5f9769 |
@@ -6768,8 +6761,7 @@ is_vlan_transparent(const struct ovn_datapath *od)
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
static void
|
|
|
5f9769 |
-build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
|
|
|
5f9769 |
- struct hmap *lflows)
|
|
|
5f9769 |
+build_lswitch_flows(struct hmap *datapaths, struct hmap *lflows)
|
|
|
5f9769 |
{
|
|
|
5f9769 |
/* This flow table structure is documented in ovn-northd(8), so please
|
|
|
5f9769 |
* update ovn-northd.8.xml if you change anything. */
|
|
|
5f9769 |
@@ -6790,8 +6782,6 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
|
|
|
5f9769 |
}
|
|
|
5f9769 |
}
|
|
|
5f9769 |
|
|
|
5f9769 |
- build_lswitch_output_port_sec(ports, datapaths, lflows);
|
|
|
5f9769 |
-
|
|
|
5f9769 |
ds_destroy(&match);
|
|
|
5f9769 |
ds_destroy(&actions);
|
|
|
5f9769 |
}
|
|
|
5f9769 |
@@ -11351,6 +11341,7 @@ build_lswitch_and_lrouter_iterate_by_od(struct ovn_datapath *od,
|
|
|
5f9769 |
build_lswitch_dns_lookup_and_response(od, lsi->lflows);
|
|
|
5f9769 |
build_lswitch_dhcp_and_dns_defaults(od, lsi->lflows);
|
|
|
5f9769 |
build_lswitch_destination_lookup_bmcast(od, lsi->lflows, &lsi->actions);
|
|
|
5f9769 |
+ build_lswitch_output_port_sec_od(od, lsi->lflows);
|
|
|
5f9769 |
|
|
|
5f9769 |
/* Build Logical Router Flows. */
|
|
|
5f9769 |
build_adm_ctrl_flows_for_lrouter(od, lsi->lflows);
|
|
|
5f9769 |
@@ -11391,6 +11382,8 @@ build_lswitch_and_lrouter_iterate_by_op(struct ovn_port *op,
|
|
|
5f9769 |
build_lswitch_external_port(op, lsi->lflows);
|
|
|
5f9769 |
build_lswitch_ip_unicast_lookup(op, lsi->lflows, lsi->mcgroups,
|
|
|
5f9769 |
&lsi->actions, &lsi->match);
|
|
|
5f9769 |
+ build_lswitch_output_port_sec_op(op, lsi->lflows,
|
|
|
5f9769 |
+ &lsi->actions, &lsi->match);
|
|
|
5f9769 |
|
|
|
5f9769 |
/* Build Logical Router Flows. */
|
|
|
5f9769 |
build_adm_ctrl_flows_for_lrouter_port(op, lsi->lflows, &lsi->match,
|
|
|
5f9769 |
@@ -11462,8 +11455,7 @@ build_lswitch_and_lrouter_flows(struct hmap *datapaths, struct hmap *ports,
|
|
|
5f9769 |
ds_destroy(&lsi.match);
|
|
|
5f9769 |
ds_destroy(&lsi.actions);
|
|
|
5f9769 |
|
|
|
5f9769 |
- /* Legacy lswitch build - to be migrated. */
|
|
|
5f9769 |
- build_lswitch_flows(datapaths, ports, lflows);
|
|
|
5f9769 |
+ build_lswitch_flows(datapaths, lflows);
|
|
|
5f9769 |
|
|
|
5f9769 |
/* Legacy lrouter build - to be migrated. */
|
|
|
5f9769 |
build_lrouter_flows(datapaths, ports, lflows, meter_groups, lbs);
|
|
|
5f9769 |
--
|
|
|
5f9769 |
2.29.2
|
|
|
5f9769 |
|