Signed-off-by: Ben Pfaff <b...@nicira.com> --- ovn/ovn-nbctl.8.xml | 14 ++++++++++++++ ovn/ovn-nbctl.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
diff --git a/ovn/ovn-nbctl.8.xml b/ovn/ovn-nbctl.8.xml index 32fd165..5ae8e59 100644 --- a/ovn/ovn-nbctl.8.xml +++ b/ovn/ovn-nbctl.8.xml @@ -138,6 +138,20 @@ output, one per line. </dd> + <dt><code>lport-set-port-security</code> <var>lport</var> [<var>addrs</var>]...</dt> + <dd> + Sets the port security addresses associated with <var>lport</var> to + <var>addrs</var>. Multiple sets of addresses may be set by using + multiple <var>addrs</var> arguments. If no <var>addrs</var> argument + is given, <var>lport</var> will not have port security enabled. + </dd> + + <dt><code>lport-get-port-security</code> <var>lport</var></dt> + <dd> + Lists all the port security addresses associated with <var>lport</var> + on standard output, one per line. + </dd> + <dt><code>lport-get-up</code> <var>lport</var></dt> <dd> Prints the state of <var>lport</var>, either <code>up</code> or diff --git a/ovn/ovn-nbctl.c b/ovn/ovn-nbctl.c index 61ec1e9..e761d6a 100644 --- a/ovn/ovn-nbctl.c +++ b/ovn/ovn-nbctl.c @@ -73,6 +73,9 @@ Logical port commands:\n\ lport-set-macs LPORT [MAC]...\n\ set MAC addresses for LPORT.\n\ lport-get-macs LPORT get a list of MAC addresses on LPORT\n\ + lport-set-port-security LPORT [ADDRS]...\n\ + set port security addresses for LPORT.\n\ + lport-get-port-security LPORT get LPORT's port security addresses\n\ lport-get-up LPORT get state of LPORT ('up' or 'down')\n\ \n\ Options:\n\ @@ -465,6 +468,40 @@ do_lport_get_macs(struct ovs_cmdl_context *ctx) } static void +do_lport_set_port_security(struct ovs_cmdl_context *ctx) +{ + struct nbctl_context *nb_ctx = ctx->pvt; + const char *id = ctx->argv[1]; + const struct nbrec_logical_port *lport; + + lport = lport_by_name_or_uuid(nb_ctx, id); + if (!lport) { + return; + } + + nbrec_logical_port_set_port_security(lport, + (const char **) ctx->argv + 2, ctx->argc - 2); +} + +static void +do_lport_get_port_security(struct ovs_cmdl_context *ctx) +{ + struct nbctl_context *nb_ctx = ctx->pvt; + const char *id = ctx->argv[1]; + const struct nbrec_logical_port *lport; + size_t i; + + lport = lport_by_name_or_uuid(nb_ctx, id); + if (!lport) { + return; + } + + for (i = 0; i < lport->n_port_security; i++) { + printf("%s\n", lport->port_security[i]); + } +} + +static void do_lport_get_up(struct ovs_cmdl_context *ctx) { struct nbctl_context *nb_ctx = ctx->pvt; @@ -637,6 +674,21 @@ static const struct ovs_cmdl_command all_commands[] = { .handler = do_lport_get_macs, }, { + .name = "lport-set-port-security", + .usage = "LPORT [ADDRS]...", + .min_args = 0, + /* Accept however many arguments the system will allow. */ + .max_args = INT_MAX, + .handler = do_lport_set_port_security, + }, + { + .name = "lport-get-port_security", + .usage = "LPORT", + .min_args = 1, + .max_args = 1, + .handler = do_lport_get_port_security, + }, + { .name = "lport-get-up", .usage = "LPORT", .min_args = 1, -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev