[ovs-dev,v2] OVN: add the possibility to configure a static IPv4/IPv6 address and dynamic MAC
diff mbox series

Message ID 20933126291916d06597f5719411deacc6117b14.1553874950.git.lorenzo.bianconi@redhat.com
State New
Headers show
Series
  • [ovs-dev,v2] OVN: add the possibility to configure a static IPv4/IPv6 address and dynamic MAC
Related show

Commit Message

Lorenzo Bianconi March 29, 2019, 3:58 p.m. UTC
Add the possibility to configure a static IPv4 and/or IPv6 address
and get MAC address dynamically allocated. This can be done using the
following commands:

$ovn-nbctl ls-add sw0
$ovn-nbctl set Logical-Switch sw0 other_config:subnet=192.168.0.0/24
$ovn-nbctl set Logical-switch sw0 other_config:ipv6_prefix=2001::0
$ovn-nbctl lsp-add sw0 lsp0 -- lsp-set-addresses lsp0 "dynamic 192.168.0.1 2001::1"

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
Changes since v1:
- rebase on top of current master branch
- fix IPv6 address assignment
---
 NEWS                      |  6 ++-
 ovn/lib/ovn-util.c        |  6 +++
 ovn/northd/ovn-northd.c   | 87 +++++++++++++++++++++++++++++----------
 ovn/ovn-nb.xml            | 24 +++++++++++
 ovn/utilities/ovn-nbctl.c |  2 +
 tests/ovn.at              | 14 +++++++
 6 files changed, 116 insertions(+), 23 deletions(-)

Comments

0-day Robot March 29, 2019, 5 p.m. UTC | #1
Bleep bloop.  Greetings Lorenzo Bianconi, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 82 characters long (recommended limit is 79)
#238 FILE: ovn/ovn-nb.xml:721:
          <dt><code>Keyword "dynamic" followed by an IPv4/IPv6 address</code></dt>

Lines checked: 313, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
Mark Michelson March 29, 2019, 8:54 p.m. UTC | #2
Looks good to me Lorenzo.

Acked-by: Mark Michelson <mmichels@redhat.com>

On 3/29/19 11:58 AM, Lorenzo Bianconi wrote:
> Add the possibility to configure a static IPv4 and/or IPv6 address
> and get MAC address dynamically allocated. This can be done using the
> following commands:
> 
> $ovn-nbctl ls-add sw0
> $ovn-nbctl set Logical-Switch sw0 other_config:subnet=192.168.0.0/24
> $ovn-nbctl set Logical-switch sw0 other_config:ipv6_prefix=2001::0
> $ovn-nbctl lsp-add sw0 lsp0 -- lsp-set-addresses lsp0 "dynamic 192.168.0.1 2001::1"
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---
> Changes since v1:
> - rebase on top of current master branch
> - fix IPv6 address assignment
> ---
>   NEWS                      |  6 ++-
>   ovn/lib/ovn-util.c        |  6 +++
>   ovn/northd/ovn-northd.c   | 87 +++++++++++++++++++++++++++++----------
>   ovn/ovn-nb.xml            | 24 +++++++++++
>   ovn/utilities/ovn-nbctl.c |  2 +
>   tests/ovn.at              | 14 +++++++
>   6 files changed, 116 insertions(+), 23 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 1e4744dbd..be7ea7fac 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -23,7 +23,11 @@ Post-v2.11.0
>          See section 4.1.15 of ovsdb-server(7) for details of related OVSDB
>          protocol extension.
>      - OVN:
> -     * Select IPAM mac_prefix in a random manner if not provided by the user
> +     * IPAM/MACAM:
> +       - select IPAM mac_prefix in a random manner if not provided by the user
> +       - add the capability to specify a static IPv4 and/or IPv6 address and
> +         get the L2 one allocated dynamically using the following syntax:
> +           ovn-nbctl lsp-set-addresses <port> "dynamic <IPv4 addr> <IPv6 addr>"
>      - New QoS type "linux-netem" on Linux.
>   
>   v2.11.0 - 19 Feb 2019
> diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c
> index aa03919bb..6497d3273 100644
> --- a/ovn/lib/ovn-util.c
> +++ b/ovn/lib/ovn-util.c
> @@ -80,6 +80,7 @@ add_ipv6_netaddr(struct lport_addresses *laddrs, struct in6_addr addr,
>   bool
>   is_dynamic_lsp_address(const char *address)
>   {
> +    char ipv6_s[IPV6_SCAN_LEN + 1];
>       struct eth_addr ea;
>       ovs_be32 ip;
>       int n;
> @@ -87,6 +88,11 @@ is_dynamic_lsp_address(const char *address)
>               || (ovs_scan(address, "dynamic "IP_SCAN_FMT"%n",
>                            IP_SCAN_ARGS(&ip), &n)
>                            && address[n] == '\0')
> +            || (ovs_scan(address, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
> +                         IP_SCAN_ARGS(&ip), ipv6_s, &n)
> +                         && address[n] == '\0')
> +            || (ovs_scan(address, "dynamic "IPV6_SCAN_FMT"%n",
> +                         ipv6_s, &n) && address[n] == '\0')
>               || (ovs_scan(address, ETH_ADDR_SCAN_FMT" dynamic%n",
>                            ETH_ADDR_SCAN_ARGS(ea), &n) && address[n] == '\0'));
>   }
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> index 05b8aad4f..31f10cfca 100644
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -1100,6 +1100,7 @@ struct dynamic_address_update {
>       struct lport_addresses current_addresses;
>       struct eth_addr static_mac;
>       ovs_be32 static_ip;
> +    struct in6_addr static_ipv6;
>       enum dynamic_update_type mac;
>       enum dynamic_update_type ipv4;
>       enum dynamic_update_type ipv6;
> @@ -1166,13 +1167,16 @@ dynamic_ip4_changed(const char *lsp_addrs,
>            */
>           return DYNAMIC;
>       } else {
> +        char ipv6_s[IPV6_SCAN_LEN + 1];
>           ovs_be32 new_ip;
>           int n = 0;
>   
> -        if (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT"%n",
> +        if ((ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT"%n",
>                        IP_SCAN_ARGS(&new_ip), &n)
> -            && lsp_addrs[n] == '\0') {
> -
> +             && lsp_addrs[n] == '\0') ||
> +            (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
> +                      IP_SCAN_ARGS(&new_ip), ipv6_s, &n)
> +             && lsp_addrs[n] == '\0')) {
>               index = ntohl(new_ip) - ipam->start_ipv4;
>               if (ntohl(new_ip) < ipam->start_ipv4 ||
>                   index > ipam->total_ipv4s ||
> @@ -1190,9 +1194,11 @@ dynamic_ip4_changed(const char *lsp_addrs,
>   }
>   
>   static enum dynamic_update_type
> -dynamic_ip6_changed(struct dynamic_address_update *update)
> +dynamic_ip6_changed(const char *lsp_addrs,
> +                    struct dynamic_address_update *update)
>   {
>       bool dynamic_ip6 = update->op->od->ipam_info.ipv6_prefix_set;
> +    struct eth_addr ea;
>   
>       if (!dynamic_ip6) {
>           if (update->current_addresses.n_ipv6_addrs) {
> @@ -1204,22 +1210,43 @@ dynamic_ip6_changed(struct dynamic_address_update *update)
>           }
>       }
>   
> -    if (update->mac != NONE) {
> -        /* IPv6 address is based on MAC, so if MAC has been updated,
> -         * then we have to update IPv6 address too.
> -         */
> -        return DYNAMIC;
> -    }
> -
> -    if (!update->current_addresses.n_ipv6_addrs) {
> +    if (!update->current_addresses.n_ipv6_addrs ||
> +        ovs_scan(lsp_addrs, ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(ea))) {
>           /* IPv6 was previously static but now is dynamic */
>           return DYNAMIC;
>       }
>   
> -    struct in6_addr masked = ipv6_addr_bitand(
> -        &update->current_addresses.ipv6_addrs[0].addr,
> -        &update->op->od->ipam_info.ipv6_prefix);
> -    if (!IN6_ARE_ADDR_EQUAL(&masked, &update->op->od->ipam_info.ipv6_prefix)) {
> +    const struct lport_addresses *cur_addresses;
> +    char ipv6_s[IPV6_SCAN_LEN + 1];
> +    ovs_be32 new_ip;
> +    int n = 0;
> +
> +    if ((ovs_scan(lsp_addrs, "dynamic "IPV6_SCAN_FMT"%n",
> +                  ipv6_s, &n) && lsp_addrs[n] == '\0') ||
> +        (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
> +                  IP_SCAN_ARGS(&new_ip), ipv6_s, &n)
> +         && lsp_addrs[n] == '\0')) {
> +        struct in6_addr ipv6;
> +
> +        if (!ipv6_parse(ipv6_s, &ipv6)) {
> +            return DYNAMIC;
> +        }
> +
> +        struct in6_addr masked = ipv6_addr_bitand(&ipv6,
> +                &update->op->od->ipam_info.ipv6_prefix);
> +        if (!IN6_ARE_ADDR_EQUAL(&masked,
> +                                &update->op->od->ipam_info.ipv6_prefix)) {
> +            return DYNAMIC;
> +        }
> +
> +        cur_addresses = &update->current_addresses;
> +
> +        if (!IN6_ARE_ADDR_EQUAL(&cur_addresses->ipv6_addrs[0].addr,
> +                                &ipv6)) {
> +            update->static_ipv6 = ipv6;
> +            return STATIC;
> +        }
> +    } else if (update->mac != NONE) {
>           return DYNAMIC;
>       }
>   
> @@ -1237,7 +1264,7 @@ dynamic_addresses_check_for_updates(const char *lsp_addrs,
>   {
>       update->mac = dynamic_mac_changed(lsp_addrs, update);
>       update->ipv4 = dynamic_ip4_changed(lsp_addrs, update);
> -    update->ipv6 = dynamic_ip6_changed(update);
> +    update->ipv6 = dynamic_ip6_changed(lsp_addrs, update);
>       if (update->mac == NONE &&
>           update->ipv4 == NONE &&
>           update->ipv6 == NONE) {
> @@ -1278,6 +1305,8 @@ static void
>   set_dynamic_updates(const char *addrspec,
>                       struct dynamic_address_update *update)
>   {
> +    bool has_ipv4 = false, has_ipv6 = false;
> +    char ipv6_s[IPV6_SCAN_LEN + 1];
>       struct eth_addr mac;
>       ovs_be32 ip;
>       int n = 0;
> @@ -1290,9 +1319,19 @@ set_dynamic_updates(const char *addrspec,
>           update->mac = DYNAMIC;
>       }
>   
> -    if (ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n",
> -                 IP_SCAN_ARGS(&ip), &n)
> -        && addrspec[n] == '\0') {
> +    if ((ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n",
> +                 IP_SCAN_ARGS(&ip), &n) && addrspec[n] == '\0')) {
> +        has_ipv4 = true;
> +    } else if ((ovs_scan(addrspec, "dynamic "IPV6_SCAN_FMT"%n",
> +                         ipv6_s, &n) && addrspec[n] == '\0')) {
> +        has_ipv6 = true;
> +    } else if ((ovs_scan(addrspec, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
> +                         IP_SCAN_ARGS(&ip), ipv6_s, &n)
> +               && addrspec[n] == '\0')) {
> +        has_ipv4 = has_ipv6 = true;
> +    }
> +
> +    if (has_ipv4) {
>           update->ipv4 = STATIC;
>           update->static_ip = ip;
>       } else if (update->op->od->ipam_info.allocated_ipv4s) {
> @@ -1300,7 +1339,10 @@ set_dynamic_updates(const char *addrspec,
>       } else {
>           update->ipv4 = NONE;
>       }
> -    if (update->op->od->ipam_info.ipv6_prefix_set) {
> +
> +    if (has_ipv6 && ipv6_parse(ipv6_s, &update->static_ipv6)) {
> +        update->ipv6 = STATIC;
> +    } else if (update->op->od->ipam_info.ipv6_prefix_set) {
>           update->ipv6 = DYNAMIC;
>       } else {
>           update->ipv6 = NONE;
> @@ -1351,7 +1393,8 @@ update_dynamic_addresses(struct dynamic_address_update *update)
>       case REMOVE:
>           break;
>       case STATIC:
> -        OVS_NOT_REACHED();
> +        ip6 = update->static_ipv6;
> +        break;
>       case DYNAMIC:
>           in6_generate_eui64(mac, &update->od->ipam_info.ipv6_prefix, &ip6);
>           break;
> diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
> index 61a57110a..160b0c218 100644
> --- a/ovn/ovn-nb.xml
> +++ b/ovn/ovn-nb.xml
> @@ -718,6 +718,30 @@
>               </dl>
>             </dd>
>   
> +          <dt><code>Keyword "dynamic" followed by an IPv4/IPv6 address</code></dt>
> +          <dd>
> +
> +            <p>
> +              The keyword <code>dynamic</code> followed by an IPv4/IPv6
> +              address indicates that <code>ovn-northd</code> should choose
> +              a dynamic ethernet address and use the provided IPv4/IPv6 address
> +              as network address.
> +            </p>
> +
> +            <p>
> +              Examples:
> +            </p>
> +
> +            <dl>
> +              <dt><code>dynamic 192.168.0.1 2001::1</code></dt>
> +              <dd>
> +                This indicates that <code>ovn-northd</code> should allocate
> +                a unique MAC address and use the provided IPv4/IPv6 address
> +                for the related port
> +              </dd>
> +            </dl>
> +          </dd>
> +
>             <dt><code>router</code></dt>
>             <dd>
>               <p>
> diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
> index 2727b410a..4cb923abe 100644
> --- a/ovn/utilities/ovn-nbctl.c
> +++ b/ovn/utilities/ovn-nbctl.c
> @@ -1533,6 +1533,7 @@ nbctl_lsp_set_addresses(struct ctl_context *ctx)
>   
>       int i;
>       for (i = 2; i < ctx->argc; i++) {
> +        char ipv6_s[IPV6_SCAN_LEN + 1];
>           struct eth_addr ea;
>           ovs_be32 ip;
>   
> @@ -1540,6 +1541,7 @@ nbctl_lsp_set_addresses(struct ctl_context *ctx)
>               && strcmp(ctx->argv[i], "router")
>               && !ovs_scan(ctx->argv[i], ETH_ADDR_SCAN_FMT,
>                            ETH_ADDR_SCAN_ARGS(ea))
> +            && !ovs_scan(ctx->argv[i], "dynamic "IPV6_SCAN_FMT, ipv6_s)
>               && !ovs_scan(ctx->argv[i], "dynamic "IP_SCAN_FMT,
>                            IP_SCAN_ARGS(&ip))) {
>               ctl_error(ctx, "%s: Invalid address format. See ovn-nb(5). "
> diff --git a/tests/ovn.at b/tests/ovn.at
> index e7746cb0f..d20806bb1 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -5976,6 +5976,20 @@ mac_prefix=$(ovn-nbctl --wait=sb get NB_Global . options:mac_prefix | tr -d \")
>   port_addr=$(ovn-nbctl get Logical-Switch-Port p91 dynamic_addresses | tr -d \")
>   AT_CHECK([test "$port_addr" = "${mac_prefix}:00:00:09"], [0], [])
>   
> +ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="00:11:22"
> +ovn-nbctl ls-add sw10
> +ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:ipv6_prefix="ae01::"
> +ovn-nbctl --wait=sb lsp-add sw10 p101 -- lsp-set-addresses p101 "dynamic ae01::1"
> +AT_CHECK([ovn-nbctl get Logical-Switch-Port p101 dynamic_addresses], [0],
> +    ["00:11:22:00:00:0a ae01::1"
> +])
> +
> +ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:subnet=192.168.110.0/24
> +ovn-nbctl --wait=sb lsp-add sw10 p102 -- lsp-set-addresses p102 "dynamic 192.168.110.10 ae01::2"
> +AT_CHECK([ovn-nbctl get Logical-Switch-Port p102 dynamic_addresses], [0],
> +    ["00:11:22:a8:6e:0b 192.168.110.10 ae01::2"
> +])
> +
>   as ovn-sb
>   OVS_APP_EXIT_AND_WAIT([ovsdb-server])
>   
>
Ben Pfaff April 16, 2019, 8:54 p.m. UTC | #3
On Fri, Mar 29, 2019 at 04:58:57PM +0100, Lorenzo Bianconi wrote:
> Add the possibility to configure a static IPv4 and/or IPv6 address
> and get MAC address dynamically allocated. This can be done using the
> following commands:
> 
> $ovn-nbctl ls-add sw0
> $ovn-nbctl set Logical-Switch sw0 other_config:subnet=192.168.0.0/24
> $ovn-nbctl set Logical-switch sw0 other_config:ipv6_prefix=2001::0
> $ovn-nbctl lsp-add sw0 lsp0 -- lsp-set-addresses lsp0 "dynamic 192.168.0.1 2001::1"
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---
> Changes since v1:
> - rebase on top of current master branch
> - fix IPv6 address assignment

Thanks, applied to master.

Patch
diff mbox series

diff --git a/NEWS b/NEWS
index 1e4744dbd..be7ea7fac 100644
--- a/NEWS
+++ b/NEWS
@@ -23,7 +23,11 @@  Post-v2.11.0
        See section 4.1.15 of ovsdb-server(7) for details of related OVSDB
        protocol extension.
    - OVN:
-     * Select IPAM mac_prefix in a random manner if not provided by the user
+     * IPAM/MACAM:
+       - select IPAM mac_prefix in a random manner if not provided by the user
+       - add the capability to specify a static IPv4 and/or IPv6 address and
+         get the L2 one allocated dynamically using the following syntax:
+           ovn-nbctl lsp-set-addresses <port> "dynamic <IPv4 addr> <IPv6 addr>"
    - New QoS type "linux-netem" on Linux.
 
 v2.11.0 - 19 Feb 2019
diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c
index aa03919bb..6497d3273 100644
--- a/ovn/lib/ovn-util.c
+++ b/ovn/lib/ovn-util.c
@@ -80,6 +80,7 @@  add_ipv6_netaddr(struct lport_addresses *laddrs, struct in6_addr addr,
 bool
 is_dynamic_lsp_address(const char *address)
 {
+    char ipv6_s[IPV6_SCAN_LEN + 1];
     struct eth_addr ea;
     ovs_be32 ip;
     int n;
@@ -87,6 +88,11 @@  is_dynamic_lsp_address(const char *address)
             || (ovs_scan(address, "dynamic "IP_SCAN_FMT"%n",
                          IP_SCAN_ARGS(&ip), &n)
                          && address[n] == '\0')
+            || (ovs_scan(address, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
+                         IP_SCAN_ARGS(&ip), ipv6_s, &n)
+                         && address[n] == '\0')
+            || (ovs_scan(address, "dynamic "IPV6_SCAN_FMT"%n",
+                         ipv6_s, &n) && address[n] == '\0')
             || (ovs_scan(address, ETH_ADDR_SCAN_FMT" dynamic%n",
                          ETH_ADDR_SCAN_ARGS(ea), &n) && address[n] == '\0'));
 }
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 05b8aad4f..31f10cfca 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1100,6 +1100,7 @@  struct dynamic_address_update {
     struct lport_addresses current_addresses;
     struct eth_addr static_mac;
     ovs_be32 static_ip;
+    struct in6_addr static_ipv6;
     enum dynamic_update_type mac;
     enum dynamic_update_type ipv4;
     enum dynamic_update_type ipv6;
@@ -1166,13 +1167,16 @@  dynamic_ip4_changed(const char *lsp_addrs,
          */
         return DYNAMIC;
     } else {
+        char ipv6_s[IPV6_SCAN_LEN + 1];
         ovs_be32 new_ip;
         int n = 0;
 
-        if (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT"%n",
+        if ((ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT"%n",
                      IP_SCAN_ARGS(&new_ip), &n)
-            && lsp_addrs[n] == '\0') {
-
+             && lsp_addrs[n] == '\0') ||
+            (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
+                      IP_SCAN_ARGS(&new_ip), ipv6_s, &n)
+             && lsp_addrs[n] == '\0')) {
             index = ntohl(new_ip) - ipam->start_ipv4;
             if (ntohl(new_ip) < ipam->start_ipv4 ||
                 index > ipam->total_ipv4s ||
@@ -1190,9 +1194,11 @@  dynamic_ip4_changed(const char *lsp_addrs,
 }
 
 static enum dynamic_update_type
-dynamic_ip6_changed(struct dynamic_address_update *update)
+dynamic_ip6_changed(const char *lsp_addrs,
+                    struct dynamic_address_update *update)
 {
     bool dynamic_ip6 = update->op->od->ipam_info.ipv6_prefix_set;
+    struct eth_addr ea;
 
     if (!dynamic_ip6) {
         if (update->current_addresses.n_ipv6_addrs) {
@@ -1204,22 +1210,43 @@  dynamic_ip6_changed(struct dynamic_address_update *update)
         }
     }
 
-    if (update->mac != NONE) {
-        /* IPv6 address is based on MAC, so if MAC has been updated,
-         * then we have to update IPv6 address too.
-         */
-        return DYNAMIC;
-    }
-
-    if (!update->current_addresses.n_ipv6_addrs) {
+    if (!update->current_addresses.n_ipv6_addrs ||
+        ovs_scan(lsp_addrs, ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(ea))) {
         /* IPv6 was previously static but now is dynamic */
         return DYNAMIC;
     }
 
-    struct in6_addr masked = ipv6_addr_bitand(
-        &update->current_addresses.ipv6_addrs[0].addr,
-        &update->op->od->ipam_info.ipv6_prefix);
-    if (!IN6_ARE_ADDR_EQUAL(&masked, &update->op->od->ipam_info.ipv6_prefix)) {
+    const struct lport_addresses *cur_addresses;
+    char ipv6_s[IPV6_SCAN_LEN + 1];
+    ovs_be32 new_ip;
+    int n = 0;
+
+    if ((ovs_scan(lsp_addrs, "dynamic "IPV6_SCAN_FMT"%n",
+                  ipv6_s, &n) && lsp_addrs[n] == '\0') ||
+        (ovs_scan(lsp_addrs, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
+                  IP_SCAN_ARGS(&new_ip), ipv6_s, &n)
+         && lsp_addrs[n] == '\0')) {
+        struct in6_addr ipv6;
+
+        if (!ipv6_parse(ipv6_s, &ipv6)) {
+            return DYNAMIC;
+        }
+
+        struct in6_addr masked = ipv6_addr_bitand(&ipv6,
+                &update->op->od->ipam_info.ipv6_prefix);
+        if (!IN6_ARE_ADDR_EQUAL(&masked,
+                                &update->op->od->ipam_info.ipv6_prefix)) {
+            return DYNAMIC;
+        }
+
+        cur_addresses = &update->current_addresses;
+
+        if (!IN6_ARE_ADDR_EQUAL(&cur_addresses->ipv6_addrs[0].addr,
+                                &ipv6)) {
+            update->static_ipv6 = ipv6;
+            return STATIC;
+        }
+    } else if (update->mac != NONE) {
         return DYNAMIC;
     }
 
@@ -1237,7 +1264,7 @@  dynamic_addresses_check_for_updates(const char *lsp_addrs,
 {
     update->mac = dynamic_mac_changed(lsp_addrs, update);
     update->ipv4 = dynamic_ip4_changed(lsp_addrs, update);
-    update->ipv6 = dynamic_ip6_changed(update);
+    update->ipv6 = dynamic_ip6_changed(lsp_addrs, update);
     if (update->mac == NONE &&
         update->ipv4 == NONE &&
         update->ipv6 == NONE) {
@@ -1278,6 +1305,8 @@  static void
 set_dynamic_updates(const char *addrspec,
                     struct dynamic_address_update *update)
 {
+    bool has_ipv4 = false, has_ipv6 = false;
+    char ipv6_s[IPV6_SCAN_LEN + 1];
     struct eth_addr mac;
     ovs_be32 ip;
     int n = 0;
@@ -1290,9 +1319,19 @@  set_dynamic_updates(const char *addrspec,
         update->mac = DYNAMIC;
     }
 
-    if (ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n",
-                 IP_SCAN_ARGS(&ip), &n)
-        && addrspec[n] == '\0') {
+    if ((ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n",
+                 IP_SCAN_ARGS(&ip), &n) && addrspec[n] == '\0')) {
+        has_ipv4 = true;
+    } else if ((ovs_scan(addrspec, "dynamic "IPV6_SCAN_FMT"%n",
+                         ipv6_s, &n) && addrspec[n] == '\0')) {
+        has_ipv6 = true;
+    } else if ((ovs_scan(addrspec, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n",
+                         IP_SCAN_ARGS(&ip), ipv6_s, &n)
+               && addrspec[n] == '\0')) {
+        has_ipv4 = has_ipv6 = true;
+    }
+
+    if (has_ipv4) {
         update->ipv4 = STATIC;
         update->static_ip = ip;
     } else if (update->op->od->ipam_info.allocated_ipv4s) {
@@ -1300,7 +1339,10 @@  set_dynamic_updates(const char *addrspec,
     } else {
         update->ipv4 = NONE;
     }
-    if (update->op->od->ipam_info.ipv6_prefix_set) {
+
+    if (has_ipv6 && ipv6_parse(ipv6_s, &update->static_ipv6)) {
+        update->ipv6 = STATIC;
+    } else if (update->op->od->ipam_info.ipv6_prefix_set) {
         update->ipv6 = DYNAMIC;
     } else {
         update->ipv6 = NONE;
@@ -1351,7 +1393,8 @@  update_dynamic_addresses(struct dynamic_address_update *update)
     case REMOVE:
         break;
     case STATIC:
-        OVS_NOT_REACHED();
+        ip6 = update->static_ipv6;
+        break;
     case DYNAMIC:
         in6_generate_eui64(mac, &update->od->ipam_info.ipv6_prefix, &ip6);
         break;
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 61a57110a..160b0c218 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -718,6 +718,30 @@ 
             </dl>
           </dd>
 
+          <dt><code>Keyword "dynamic" followed by an IPv4/IPv6 address</code></dt>
+          <dd>
+
+            <p>
+              The keyword <code>dynamic</code> followed by an IPv4/IPv6
+              address indicates that <code>ovn-northd</code> should choose
+              a dynamic ethernet address and use the provided IPv4/IPv6 address
+              as network address.
+            </p>
+
+            <p>
+              Examples:
+            </p>
+
+            <dl>
+              <dt><code>dynamic 192.168.0.1 2001::1</code></dt>
+              <dd>
+                This indicates that <code>ovn-northd</code> should allocate
+                a unique MAC address and use the provided IPv4/IPv6 address
+                for the related port
+              </dd>
+            </dl>
+          </dd>
+
           <dt><code>router</code></dt>
           <dd>
             <p>
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 2727b410a..4cb923abe 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1533,6 +1533,7 @@  nbctl_lsp_set_addresses(struct ctl_context *ctx)
 
     int i;
     for (i = 2; i < ctx->argc; i++) {
+        char ipv6_s[IPV6_SCAN_LEN + 1];
         struct eth_addr ea;
         ovs_be32 ip;
 
@@ -1540,6 +1541,7 @@  nbctl_lsp_set_addresses(struct ctl_context *ctx)
             && strcmp(ctx->argv[i], "router")
             && !ovs_scan(ctx->argv[i], ETH_ADDR_SCAN_FMT,
                          ETH_ADDR_SCAN_ARGS(ea))
+            && !ovs_scan(ctx->argv[i], "dynamic "IPV6_SCAN_FMT, ipv6_s)
             && !ovs_scan(ctx->argv[i], "dynamic "IP_SCAN_FMT,
                          IP_SCAN_ARGS(&ip))) {
             ctl_error(ctx, "%s: Invalid address format. See ovn-nb(5). "
diff --git a/tests/ovn.at b/tests/ovn.at
index e7746cb0f..d20806bb1 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -5976,6 +5976,20 @@  mac_prefix=$(ovn-nbctl --wait=sb get NB_Global . options:mac_prefix | tr -d \")
 port_addr=$(ovn-nbctl get Logical-Switch-Port p91 dynamic_addresses | tr -d \")
 AT_CHECK([test "$port_addr" = "${mac_prefix}:00:00:09"], [0], [])
 
+ovn-nbctl --wait=hv set NB_Global . options:mac_prefix="00:11:22"
+ovn-nbctl ls-add sw10
+ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:ipv6_prefix="ae01::"
+ovn-nbctl --wait=sb lsp-add sw10 p101 -- lsp-set-addresses p101 "dynamic ae01::1"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p101 dynamic_addresses], [0],
+    ["00:11:22:00:00:0a ae01::1"
+])
+
+ovn-nbctl --wait=sb set Logical-Switch sw10 other_config:subnet=192.168.110.0/24
+ovn-nbctl --wait=sb lsp-add sw10 p102 -- lsp-set-addresses p102 "dynamic 192.168.110.10 ae01::2"
+AT_CHECK([ovn-nbctl get Logical-Switch-Port p102 dynamic_addresses], [0],
+    ["00:11:22:a8:6e:0b 192.168.110.10 ae01::2"
+])
+
 as ovn-sb
 OVS_APP_EXIT_AND_WAIT([ovsdb-server])