diff mbox series

[ovs-dev] northd: allow explicit nat-addresses for distributed gw ports

Message ID 9c27b067a4779d431c19886d1cecdf655872a6dc.1644951848.git.lorenzo.bianconi@redhat.com
State Superseded
Headers show
Series [ovs-dev] northd: allow explicit nat-addresses for distributed gw ports | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Lorenzo Bianconi Feb. 15, 2022, 7:04 p.m. UTC
Allow the CMS to explicitly configure nat addresses to use in
GARP advertising even if the logical switch port is connected
to a distributed gateway router port.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 northd/northd.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/northd/northd.c b/northd/northd.c
index 861812259..4f9c10648 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -3373,6 +3373,8 @@  ovn_port_update_sbrec(struct northd_input *input_data,
                                            "nat-addresses");
             size_t n_nats = 0;
             char **nats = NULL;
+            bool l3dgw_ports = op->peer && op->peer->od &&
+                               op->peer->od->n_l3dgw_ports;
             if (nat_addresses && !strcmp(nat_addresses, "router")) {
                 if (op->peer && op->peer->od
                     && (chassis || op->peer->od->n_l3dgw_ports)) {
@@ -3380,17 +3382,24 @@  ovn_port_update_sbrec(struct northd_input *input_data,
                 }
             /* Only accept manual specification of ethernet address
              * followed by IPv4 addresses on type "l3gateway" ports. */
-            } else if (nat_addresses && chassis) {
+            } else if (nat_addresses && (chassis || l3dgw_ports)) {
                 struct lport_addresses laddrs;
                 if (!extract_lsp_addresses(nat_addresses, &laddrs)) {
                     static struct vlog_rate_limit rl =
                         VLOG_RATE_LIMIT_INIT(1, 1);
                     VLOG_WARN_RL(&rl, "Error extracting nat-addresses.");
                 } else {
+                    struct ds data = DS_EMPTY_INITIALIZER;
+                    ds_put_format(&data, "%s", nat_addresses);
+                    if (l3dgw_ports) {
+                        ds_put_format(&data, " is_chassis_resident(%s)",
+                            op->peer->od->l3dgw_ports[0]->cr_port->json_key);
+                    }
                     destroy_lport_addresses(&laddrs);
                     n_nats = 1;
                     nats = xcalloc(1, sizeof *nats);
-                    nats[0] = xstrdup(nat_addresses);
+                    nats[0] = xstrdup(ds_cstr(&data));
+                    ds_destroy(&data);
                 }
             }