Hi Mark, On Thu, 2 Nov 2017 15:47:04 -0500 Mark Michelson <[email protected]> wrote:
> This change adds three new options to the Northbound > Logical_Router_Port's ipv6_ra_configs option: > > * send_periodic: If set to "true", then OVN will send periodic router > advertisements out of this router port. > * max_interval: The maximum amount of time to wait between sending > periodic router advertisements. > * min_interval: The minimum amount of time to wait between sending > periodic router advertisements. > > When send_periodic is true, then IPv6 RA configs, as well as some layer > 2 and layer 3 information about the router port, are copied to the > southbound database. From there, ovn-controller can use this information > to know when to send periodic RAs and what to send in them. > > Because periodic RAs originate from each ovn-controller, the new > keep-local flag is set on the packet so that ports don't receive an > overabundance of RAs. > > Signed-off-by: Mark Michelson <[email protected]> > --- [...] > +static struct ipv6_ra_config * > +ipv6_ra_update_config(const struct sbrec_port_binding *pb) > +{ > + struct ipv6_ra_config *config; > + > + config = xzalloc(sizeof *config); > + > + config->max_interval = smap_get_int(&pb->options, "ipv6_ra_max_interval", > + ND_RA_MAX_INTERVAL_DEFAULT); > + config->min_interval = smap_get_int(&pb->options, "ipv6_ra_min_interval", > + ND_RA_MIN_INTERVAL_DEFAULT(config->max_interval)); > + config->mtu = htonl(smap_get_int(&pb->options, "ipv6_ra_mtu", > + ND_MTU_DEFAULT)); > + config->la_flags = ND_PREFIX_ON_LINK; > + > + const char *address_mode = smap_get(&pb->options, > "ipv6_ra_address_mode"); > + if (!address_mode) { > + VLOG_WARN("No address mode specified"); > + goto fail; > + } > + if (!strcmp(address_mode, "dhcpv6_stateless")) { > + config->mo_flags = IPV6_ND_RA_FLAG_OTHER_ADDR_CONFIG; > + } else if (!strcmp(address_mode, "dhcpv6_stateful")) { > + config->mo_flags = IPV6_ND_RA_FLAG_MANAGED_ADDR_CONFIG; > + } else if (!strcmp(address_mode, "slaac")) { > + config->la_flags |= ND_PREFIX_AUTONOMOUS_ADDRESS; > + } else { > + VLOG_WARN("Invalid address mode %s", address_mode); > + goto fail; > + } > + > + const char *prefixes = smap_get(&pb->options, "ipv6_ra_prefixes"); > + if (prefixes) { > + char *prefixes_copy = xstrdup(prefixes); > + char *prefix; > + > + /* Prefixes are in the format: > + * addr/len, where > + * addr is the network prefix > + * and len is the prefix length > + */ > + while ((prefix = strsep(&prefixes_copy, " "))) { > + char *cidr; > + > + cidr = strchr(prefix, '/'); > + if (!cidr) { > + VLOG_WARN("No prefix length on network prefix %s", prefix); > + continue; > + } > + *cidr++ = '\0'; > + > + unsigned int prefix_len; > + prefix_len = atoi(cidr); > + if (prefix_len == 0 || prefix_len > 128) { > + VLOG_WARN("Invalid prefix length %u", prefix_len); > + continue; > + } > + > + struct in6_addr prefix_addr; > + if (!ipv6_parse(prefix, &prefix_addr)) { > + continue; > + } > + > + config->n_prefixes++; > + config->prefixes = xrealloc(config->prefixes, > + config->n_prefixes * sizeof *config->prefixes); > + > + struct ipv6_network_prefix *network; > + network = &config->prefixes[config->n_prefixes - 1]; > + network->addr = prefix_addr; > + network->prefix_len = prefix_len; > + } > + free (prefixes_copy); > + } I think we could use ipv6_parse_cidr() for parsing the prefix. [...] -Jakub _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
