@@ -367,6 +367,9 @@ Logical switch port commands:\n\
lsp-set-dhcpv4-options PORT [DHCP_OPTIONS_UUID]\n\
set dhcpv4 options for PORT\n\
lsp-get-dhcpv4-options PORT get the dhcpv4 options for PORT\n\
+ lsp-set-dhcpv6-options PORT [DHCP_OPTIONS_UUID]\n\
+ set dhcpv6 options for PORT\n\
+ lsp-get-dhcpv6-options PORT get the dhcpv6 options for PORT\n\
\n\
Logical router commands:\n\
lr-add [ROUTER] create a logical router named ROUTER\n\
@@ -1236,6 +1239,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 +1276,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 +3443,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,
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 <mmichels@redhat.com> --- ovn/utilities/ovn-nbctl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)