On Fri, Sep 09, 2016 at 06:39:17AM +0000, Zongkai LI wrote: > This patch adds DHCPv6 stateless option support, to allow ovn native dhcpv6 > work in stateless mode. > > User can add new option dhcpv6_stateless with string value true in > DHCP_Options.options column, to let ovn dhcpv6 only reply other configurations > for DHCPv6 request messages come from VM/VIF ports, and let VM/VIF ports get > their IPv6 addresses configured via stateless way. > > Signed-off-by: Zongkai LI <zealo...@gmail.com>
Seems reasonable enough. It seems like a bit much to clone the whole options structure to possibly delete one element, so I changed the code as below, and then applied this to master. --8<--------------------------cut here-------------------------->8-- diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index fbcc719..62af64b 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -2009,25 +2009,21 @@ build_dhcpv6_action(struct ovn_port *op, struct in6_addr *offer_ip, ds_put_format(options_action, REGBIT_DHCP_OPTS_RESULT" = put_dhcpv6_opts("); - struct smap dhcpv6_options = SMAP_INITIALIZER(&dhcpv6_options); - smap_clone(&dhcpv6_options, &op->nbsp->dhcpv6_options->options); - /* Check whether the dhcpv6 options should be configured as stateful. * Only reply with ia_addr option for dhcpv6 stateful address mode. */ - const char *dhcpv6_stateless = smap_get( - &dhcpv6_options, "dhcpv6_stateless"); - if (!dhcpv6_stateless || strcmp(dhcpv6_stateless, "true")) { + if (!smap_get_bool(&op->nbsp->dhcpv6_options->options, + "dhcpv6_stateless", false)) { char ia_addr[INET6_ADDRSTRLEN + 1]; ipv6_string_mapped(ia_addr, offer_ip); ds_put_format(options_action, "ia_addr = %s, ", ia_addr); } - /* dhcpv6_stateless is not DHCPv6 option, delete it from the smap. */ - smap_remove(&dhcpv6_options, "dhcpv6_stateless"); struct smap_node *node; - SMAP_FOR_EACH (node, &dhcpv6_options) { - ds_put_format(options_action, "%s = %s, ", node->key, node->value); + SMAP_FOR_EACH (node, &op->nbsp->dhcpv6_options->options) { + if (strcmp(node->key, "dhcpv6_stateless")) { + ds_put_format(options_action, "%s = %s, ", node->key, node->value); + } } ds_chomp(options_action, ' '); ds_chomp(options_action, ','); @@ -2039,7 +2035,6 @@ build_dhcpv6_action(struct ovn_port *op, struct in6_addr *offer_ip, "output;", server_mac, server_ip); - smap_destroy(&dhcpv6_options); return true; } _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev