[ovs-dev] [bug 7550 9/9] ovs-ofctl: Support all OFPPC_* flags in "mod-port" command.
Ben Pfaff
blp at nicira.com
Wed Dec 21 21:03:57 UTC 2011
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
NEWS | 2 +
utilities/ovs-ofctl.8.in | 53 +++++++++++++++++++++++++++++----------------
utilities/ovs-ofctl.c | 49 +++++++++++++++++++++++++++--------------
3 files changed, 68 insertions(+), 36 deletions(-)
diff --git a/NEWS b/NEWS
index 376b1a3..f3836f0 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ port-v1.4.0
- OpenFlow:
- Added an OpenFlow action NXAST_CONTROLLER that offers
additional features over output to OFPP_CONTROLLER.
+ - ovs-ofctl:
+ - "mod-port" command can now control all OpenFlow config flags.
v1.4.0 - xx xxx xxxx
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 40e173a..50f421a 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -74,29 +74,44 @@ following:
.
.RS
.IP \fBup\fR
-Enables the interface. This is equivalent to ``ifconfig up'' on a Unix
-system.
-.
-.IP \fBdown\fR
-Disables the interface. This is equivalent to ``ifconfig down'' on a Unix
-system.
+.IQ \fBdown\fR
+Enable or disable the interface. This is equivalent to ``ifconfig
+up'' or ``ifconfig down'' on a Unix system.
+.
+.IP \fBstp\fR
+.IQ \fBno\-stp\fR
+Enable or disable 802.1D spanning tree protocol (STP) on the
+interface. OpenFlow implementations that don't support STP will
+refuse to enable it.
+.
+.IP \fBreceive\fR
+.IQ \fBno\-receive\fR
+.IQ \fBreceive\-stp\fR
+.IQ \fBno\-receive\-stp\fR
+Enable or disable OpenFlow processing of packets received on this
+interface. When packet processing is disabled, packets will be
+dropped instead of being processed through the OpenFlow table. The
+\fBreceive\fR or \fBno\-receive\fR setting applies to all packets
+except 802.1D spanning tree packets, which are separately controlled
+by \fBreceive\-stp\fR or \fBno\-receive\-stp\fR.
.
.IP \fBforward\fR
-Allows forwarding of traffic on this interface. This is the default posture
-for all ports.
-.
-.IP \fBnoforward\fR
-Disallows forwarding of traffic on this interface.
+.IQ \fBno\-forward\fR
+Allow or disallow forwarding of traffic to this interface. By
+default, forwarding is enabled.
.
.IP \fBflood\fR
-When a \fIflood\fR action is specified, traffic will be sent out this
-interface. This is the default posture for monitored ports.
-.
-.IP \fBnoflood\fR
-When a \fIflood\fR action is specified, traffic will not be sent out
-this interface. This is primarily useful to prevent loops when a
-spanning tree protocol is not in use.
-.
+.IQ \fBno\-flood\fR
+Controls whether an OpenFlow \fBflood\fR action will send traffic out
+this interface. By default, flooding is enabled. Disabling flooding
+is primarily useful to prevent loops when a spanning tree protocol is
+not in use.
+.
+.IP \fBpacket\-in\fR
+.IQ \fBno\-packet\-in\fR
+Controls whether packets received on this interface that do not match
+a flow table entry generate a ``packet in'' message to the OpenFlow
+controller. By default, ``packet in'' messages are enabled.
.RE
.
.IP "\fBget\-frags \fIswitch\fR"
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index cf77300..86054ad 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -815,6 +815,23 @@ do_probe(int argc OVS_UNUSED, char *argv[])
static void
do_mod_port(int argc OVS_UNUSED, char *argv[])
{
+ struct ofp_config_flag {
+ const char *name; /* The flag's name. */
+ enum ofp_port_config bit; /* Bit to turn on or off. */
+ bool on; /* Value to set the bit to. */
+ };
+ static const struct ofp_config_flag flags[] = {
+ { "up", OFPPC_PORT_DOWN, false },
+ { "down", OFPPC_PORT_DOWN, true },
+ { "stp", OFPPC_NO_STP, false },
+ { "receive", OFPPC_NO_RECV, false },
+ { "receive-stp", OFPPC_NO_RECV_STP, false },
+ { "flood", OFPPC_NO_FLOOD, false },
+ { "forward", OFPPC_NO_FWD, false },
+ { "packet-in", OFPPC_NO_PACKET_IN, false },
+ };
+
+ const struct ofp_config_flag *flag;
struct ofp_port_mod *opm;
struct ofp_phy_port opp;
struct ofpbuf *request;
@@ -829,25 +846,23 @@ do_mod_port(int argc OVS_UNUSED, char *argv[])
opm->mask = htonl(0);
opm->advertise = htonl(0);
- if (!strcasecmp(argv[3], "up")) {
- opm->mask |= htonl(OFPPC_PORT_DOWN);
- } else if (!strcasecmp(argv[3], "down")) {
- opm->mask |= htonl(OFPPC_PORT_DOWN);
- opm->config |= htonl(OFPPC_PORT_DOWN);
- } else if (!strcasecmp(argv[3], "flood")) {
- opm->mask |= htonl(OFPPC_NO_FLOOD);
- } else if (!strcasecmp(argv[3], "noflood")) {
- opm->mask |= htonl(OFPPC_NO_FLOOD);
- opm->config |= htonl(OFPPC_NO_FLOOD);
- } else if (!strcasecmp(argv[3], "forward")) {
- opm->mask |= htonl(OFPPC_NO_FWD);
- } else if (!strcasecmp(argv[3], "noforward")) {
- opm->mask |= htonl(OFPPC_NO_FWD);
- opm->config |= htonl(OFPPC_NO_FWD);
- } else {
- ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
+ for (flag = flags; flag < &flags[ARRAY_SIZE(flags)]; flag++) {
+ if (!strcasecmp(argv[3], flag->name)) {
+ opm->mask = htonl(flag->bit);
+ opm->config = htonl(flag->on ? flag->bit : 0);
+ goto found;
+ } else if ((!strncasecmp(argv[3], "no-", 3)
+ && !strcasecmp(argv[3] + 3, flag->name)) ||
+ (!strncasecmp(argv[3], "no", 2)
+ && !strcasecmp(argv[3] + 2, flag->name))) {
+ opm->mask = htonl(flag->bit);
+ opm->config = htonl(flag->on ? 0 : flag->bit);
+ goto found;
+ }
}
+ ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
+found:
open_vconn(argv[1], &vconn);
transact_noreply(vconn, request);
vconn_close(vconn);
--
1.7.2.5
More information about the dev
mailing list