OVN offers a shortcut to set DHCPv4 options on a logical switch port, but it did not offer the same for DHCPv6. This commit adds a similar option for DHCPv6.
Signed-off-by: Mark Michelson <[email protected]> --- ovn/utilities/ovn-nbctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 0488318c4..8dcb15e35 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -1236,6 +1236,30 @@ nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx) } static void +nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx) +{ + const char *id = ctx->argv[1]; + const struct nbrec_logical_switch_port *lsp; + + lsp = lsp_by_name_or_uuid(ctx, id, true); + const struct nbrec_dhcp_options *dhcp_opt = NULL; + if (ctx->argc == 3) { + dhcp_opt = dhcp_options_get(ctx, ctx->argv[2], true); + } + + if (dhcp_opt) { + struct in6_addr ip; + unsigned int plen; + char *error = ipv6_parse_cidr(dhcp_opt->cidr, &ip, &plen); + if (error) { + free(error); + ctl_fatal("DHCP options cidr '%s' is not IPv6", dhcp_opt->cidr); + } + } + nbrec_logical_switch_port_set_dhcpv6_options(lsp, dhcp_opt); +} + +static void nbctl_lsp_get_dhcpv4_options(struct ctl_context *ctx) { const char *id = ctx->argv[1]; @@ -1249,6 +1273,20 @@ nbctl_lsp_get_dhcpv4_options(struct ctl_context *ctx) } } +static void +nbctl_lsp_get_dhcpv6_options(struct ctl_context *ctx) +{ + const char *id = ctx->argv[1]; + const struct nbrec_logical_switch_port *lsp; + + lsp = lsp_by_name_or_uuid(ctx, id, true); + if (lsp->dhcpv6_options) { + ds_put_format(&ctx->output, UUID_FMT " (%s)\n", + UUID_ARGS(&lsp->dhcpv6_options->header_.uuid), + lsp->dhcpv6_options->cidr); + } +} + enum { DIR_FROM_LPORT, DIR_TO_LPORT @@ -3402,6 +3440,10 @@ static const struct ctl_command_syntax nbctl_commands[] = { nbctl_lsp_set_dhcpv4_options, NULL, "", RW }, { "lsp-get-dhcpv4-options", 1, 1, "PORT", NULL, nbctl_lsp_get_dhcpv4_options, NULL, "", RO }, + { "lsp-set-dhcpv6-options", 1, 2, "PORT [DHCP_OPT_UUID]", NULL, + nbctl_lsp_set_dhcpv6_options, NULL, "", RW }, + { "lsp-get-dhcpv6-options", 1, 1, "PORT", NULL, + nbctl_lsp_get_dhcpv6_options, NULL, "", RO }, /* logical router commands. */ { "lr-add", 0, 1, "[ROUTER]", NULL, nbctl_lr_add, NULL, -- 2.13.3 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
