On Tue, Mar 15, 2022 at 2:28 PM Lorenzo Bianconi
<[email protected]> wrote:
>
> 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 <[email protected]>

Thanks.  Applied to the main branch.

Numan

> ---
> Changes since v1:
> - rebase on top of ovn master
> - add unit test
> ---
>  northd/northd.c | 15 +++++++++++----
>  tests/ovn.at    | 32 ++++++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/northd/northd.c b/northd/northd.c
> index b264fb850..f94239b45 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -3385,6 +3385,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)) {
> @@ -3393,9 +3395,7 @@ ovn_port_update_sbrec(struct northd_input *input_data,
>                      nats = get_nat_addresses(op->peer, &n_nats, false,
>                                               !exclude_lb_vips);
>                  }
> -            /* 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 =
> @@ -3405,7 +3405,14 @@ ovn_port_update_sbrec(struct northd_input *input_data,
>                      destroy_lport_addresses(&laddrs);
>                      n_nats = 1;
>                      nats = xcalloc(1, sizeof *nats);
> -                    nats[0] = xstrdup(nat_addresses);
> +                    struct ds nat_addr = DS_EMPTY_INITIALIZER;
> +                    ds_put_format(&nat_addr, "%s", nat_addresses);
> +                    if (l3dgw_ports) {
> +                        ds_put_format(&nat_addr, " is_chassis_resident(%s)",
> +                            op->peer->od->l3dgw_ports[0]->cr_port->json_key);
> +                    }
> +                    nats[0] = xstrdup(ds_cstr(&nat_addr));
> +                    ds_destroy(&nat_addr);
>                  }
>              }
>
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 9b13a980d..32c812caa 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -8642,6 +8642,38 @@ 
> fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a8
>  
> fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002
>  ])
>
> +# Temporarily remove nat-addresses option to avoid race conditions
> +# due to GARP backoff
> +ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 nat-addresses=""
> +# Let's use gw router port now
> +hv1_uuid=$(ovn-sbctl --bare --columns _uuid list chassis hv1)
> +ovn-nbctl remove logical_router lr0 options chassis
> +ovn-nbctl lrp-set-gateway-chassis lrp0 hv1 20
> +OVS_WAIT_UNTIL([
> +    cr_lrp0_ch=$(ovn-sbctl --bare --columns chassis list port_binding 
> cr-lrp0)
> +    test "$cr_lrp0_ch" = $hv1_uuid
> +])
> +ovn-nbctl lsp-set-options lrp0-rp router-port=lrp0 
> nat-addresses="f0:00:00:00:00:03 192.168.0.3"
> +
> +reset_pcap_file() {
> +    local iface=$1
> +    local pcap_file=$2
> +    ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \
> +options:rxq_pcap=dummy-rx.pcap
> +    rm -f ${pcap_file}*.pcap
> +    ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \
> +options:rxq_pcap=${pcap_file}-rx.pcap
> +}
> +
> +reset_pcap_file snoopvif hv1/snoopvif
> +OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 140])
> +
> +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | 
> trim_zeros > packets
> +AT_CHECK([sort packets], [0], [dnl
> +fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001
> +fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003
> +])
> +
>  OVN_CLEANUP([hv1])
>
>  AT_CLEANUP
> --
> 2.35.1
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to