> > Add the possibility to configure a static IPv4 address and IPv6 prefix > 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" >
Hi Ben, please hold on for a while with this patch since I need to review some bits. I will post a v2. Thanks. Regards, Lorenzo > Signed-off-by: Lorenzo Bianconi <[email protected]> > --- > This patch is based on 'OVN: select a random mac_prefix if not provided' > --- > NEWS | 6 +++++- > ovn/lib/ovn-util.c | 4 ++++ > ovn/northd/ovn-northd.c | 17 ++++++++++++----- > ovn/ovn-nb.xml | 24 ++++++++++++++++++++++++ > 4 files changed, 45 insertions(+), 6 deletions(-) > > diff --git a/NEWS b/NEWS > index b3b347036..0e0ec3fde 100644 > --- a/NEWS > +++ b/NEWS > @@ -18,7 +18,11 @@ Post-v2.11.0 > * New "ovs-appctl dpctl/ipf-get-status" command for userspace datapath > conntrack fragmentation support. > - 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 address/IPv6 prefix and > + get the L2 one allocated dynamically using the following syntax: > + ovn-nbctl lsp-set-addresses <port> "dynamic <IPv4 addr> <IPv6 > addr>" > > v2.11.0 - 19 Feb 2019 > --------------------- > diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c > index aa03919bb..147f11ca0 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,9 @@ 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, 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 373e45573..839c2fe61 100644 > --- a/ovn/northd/ovn-northd.c > +++ b/ovn/northd/ovn-northd.c > @@ -1166,13 +1166,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 || > @@ -1278,6 +1281,7 @@ static void > set_dynamic_updates(const char *addrspec, > struct dynamic_address_update *update) > { > + char ipv6_s[IPV6_SCAN_LEN + 1]; > struct eth_addr mac; > ovs_be32 ip; > int n = 0; > @@ -1290,9 +1294,12 @@ set_dynamic_updates(const char *addrspec, > update->mac = DYNAMIC; > } > > - if (ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n", > + if ((ovs_scan(addrspec, "dynamic "IP_SCAN_FMT"%n", > IP_SCAN_ARGS(&ip), &n) > - && addrspec[n] == '\0') { > + && addrspec[n] == '\0') || > + (ovs_scan(addrspec, "dynamic "IP_SCAN_FMT" "IPV6_SCAN_FMT"%n", > + IP_SCAN_ARGS(&ip), ipv6_s, &n) > + && addrspec[n] == '\0')) { > update->ipv4 = STATIC; > update->static_ip = ip; > } else if (update->op->od->ipam_info.allocated_ipv4s) { > diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml > index 18396507d..273902b43 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 address/IPv6 > prefix</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 address > + and/or IPv6 prefix 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> > -- > 2.20.1 > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
