[ovs-dev] [PATCH ovn 2/6 v4] Spin out flow generation into build_dhcpv6_options_flows

Ihar Hrachyshka ihrachys at redhat.com
Mon May 11 14:09:00 UTC 2020


Signed-off-by: Ihar Hrachyshka <ihrachys at redhat.com>
---
 northd/ovn-northd.c | 102 ++++++++++++++++++++++++--------------------
 1 file changed, 56 insertions(+), 46 deletions(-)

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 6dfa21987..6715d38a3 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -6166,6 +6166,60 @@ build_dhcpv4_options_flows(struct ovn_port *op, struct hmap *lflows,
     }
 }
 
+
+static void
+build_dhcpv6_options_flows(struct ovn_port *op, struct hmap *lflows,
+                           struct lport_addresses *lsp_addrs,
+                           const char *json_key, bool is_external)
+{
+    struct ds match = DS_EMPTY_INITIALIZER;
+
+    struct ovsdb_idl_row *stage_hint;
+    if (op->nbsp->dhcpv6_options) {
+        stage_hint = &op->nbsp->dhcpv6_options->header_;
+    } else {
+        stage_hint = NULL;
+    }
+
+    for (size_t j = 0; j < lsp_addrs->n_ipv6_addrs; j++) {
+        struct ds options_action = DS_EMPTY_INITIALIZER;
+        struct ds response_action = DS_EMPTY_INITIALIZER;
+        if (build_dhcpv6_action(
+                op, &lsp_addrs->ipv6_addrs[j].addr,
+                &options_action, &response_action)) {
+            ds_clear(&match);
+            ds_put_format(
+                &match, "inport == %s && eth.src == %s"
+                " && ip6.dst == ff02::1:2 && udp.src == 546 &&"
+                " udp.dst == 547",
+                json_key, lsp_addrs->ea_s);
+
+            if (is_external) {
+                ds_put_format(&match, " && is_chassis_resident(%s)",
+                              op->json_key);
+            }
+
+            ovn_lflow_add_with_hint(lflows, op->od,
+                                    S_SWITCH_IN_DHCP_OPTIONS, 100,
+                                    ds_cstr(&match),
+                                    ds_cstr(&options_action),
+                                    stage_hint);
+
+            /* If REGBIT_DHCP_OPTS_RESULT is set to 1, it means the
+             * put_dhcpv6_opts action is successful */
+            ds_put_cstr(&match, " && "REGBIT_DHCP_OPTS_RESULT);
+            ovn_lflow_add_with_hint(lflows, op->od,
+                                    S_SWITCH_IN_DHCP_RESPONSE, 100,
+                                    ds_cstr(&match),
+                                    ds_cstr(&response_action),
+                                    stage_hint);
+            ds_destroy(&options_action);
+            ds_destroy(&response_action);
+            break;
+        }
+    }
+}
+
 static void
 build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
                     struct hmap *port_groups, struct hmap *lflows,
@@ -6496,52 +6550,8 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports,
             build_dhcpv4_options_flows(op, lflows, &op->lsp_addrs[i], json_key,
                                        is_external);
 
-            struct ovsdb_idl_row *stage_hint;
-            if (op->nbsp->dhcpv6_options) {
-                stage_hint = &op->nbsp->dhcpv6_options->header_;
-            } else {
-                stage_hint = NULL;
-            }
-
-            for (size_t j = 0; j < op->lsp_addrs[i].n_ipv6_addrs; j++) {
-                struct ds options_action = DS_EMPTY_INITIALIZER;
-                struct ds response_action = DS_EMPTY_INITIALIZER;
-                if (build_dhcpv6_action(
-                        op, &op->lsp_addrs[i].ipv6_addrs[j].addr,
-                        &options_action, &response_action)) {
-                    ds_clear(&match);
-                    ds_put_format(
-                        &match, "inport == %s && eth.src == %s"
-                        " && ip6.dst == ff02::1:2 && udp.src == 546 &&"
-                        " udp.dst == 547",
-                        is_external ? op->od->localnet_port->json_key :
-                            op->json_key,
-                        op->lsp_addrs[i].ea_s);
-
-                    if (is_external) {
-                        ds_put_format(&match, " && is_chassis_resident(%s)",
-                                      op->json_key);
-                    }
-
-                    ovn_lflow_add_with_hint(lflows, op->od,
-                                            S_SWITCH_IN_DHCP_OPTIONS, 100,
-                                            ds_cstr(&match),
-                                            ds_cstr(&options_action),
-                                            stage_hint);
-
-                    /* If REGBIT_DHCP_OPTS_RESULT is set to 1, it means the
-                     * put_dhcpv6_opts action is successful */
-                    ds_put_cstr(&match, " && "REGBIT_DHCP_OPTS_RESULT);
-                    ovn_lflow_add_with_hint(lflows, op->od,
-                                            S_SWITCH_IN_DHCP_RESPONSE, 100,
-                                            ds_cstr(&match),
-                                            ds_cstr(&response_action),
-                                            stage_hint);
-                    ds_destroy(&options_action);
-                    ds_destroy(&response_action);
-                    break;
-                }
-            }
+            build_dhcpv6_options_flows(op, lflows, &op->lsp_addrs[i], json_key,
+                                       is_external);
         }
     }
 
-- 
2.26.2



More information about the dev mailing list