'up 0 0' \
'noflood NO_FLOOD 0' \
'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
- 'flood PORT_DOWN LINK_DOWN'
+ 'flood PORT_DOWN LINK_DOWN' \
+ 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
+ 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
+ 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
+ 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
+ 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
+ 'up NO_RECV 0' \
+ 'receive 0 0'
do
set $command_config_state
command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
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 \fBup\fR
+.IQ \fBdown\fR
+Enable or disable the interface. This is equivalent to \fBifconfig
+up\fR or \fBifconfig down\fR 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
+The \fBshow\fR command displays (among other information) the
+configuration that \fBmod\-port\fR changes.
.
.IP "\fBget\-frags \fIswitch\fR"
Prints \fIswitch\fR's fragment handling mode. See \fBset\-frags\fR,
static void
do_mod_port(int argc OVS_UNUSED, char *argv[])
{
+ struct ofp_config_flag {
+ const char *name; /* The flag's name. */
+ enum ofputil_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", OFPUTIL_PC_PORT_DOWN, false },
+ { "down", OFPUTIL_PC_PORT_DOWN, true },
+ { "stp", OFPUTIL_PC_NO_STP, false },
+ { "receive", OFPUTIL_PC_NO_RECV, false },
+ { "receive-stp", OFPUTIL_PC_NO_RECV_STP, false },
+ { "flood", OFPUTIL_PC_NO_FLOOD, false },
+ { "forward", OFPUTIL_PC_NO_FWD, false },
+ { "packet-in", OFPUTIL_PC_NO_PACKET_IN, false },
+ };
+
+ const struct ofp_config_flag *flag;
enum ofputil_protocol protocol;
struct ofputil_port_mod pm;
struct ofputil_phy_port pp;
struct vconn *vconn;
+ const char *command;
+ bool not;
fetch_ofputil_phy_port(argv[1], argv[2], &pp);
pm.mask = 0;
pm.advertise = 0;
- if (!strcasecmp(argv[3], "up")) {
- pm.mask |= OFPUTIL_PC_PORT_DOWN;
- } else if (!strcasecmp(argv[3], "down")) {
- pm.mask |= OFPUTIL_PC_PORT_DOWN;
- pm.config |= OFPUTIL_PC_PORT_DOWN;
- } else if (!strcasecmp(argv[3], "flood")) {
- pm.mask |= OFPUTIL_PC_NO_FLOOD;
- } else if (!strcasecmp(argv[3], "noflood")) {
- pm.mask |= OFPUTIL_PC_NO_FLOOD;
- pm.config |= OFPUTIL_PC_NO_FLOOD;
- } else if (!strcasecmp(argv[3], "forward")) {
- pm.mask |= OFPUTIL_PC_NO_FWD;
- } else if (!strcasecmp(argv[3], "noforward")) {
- pm.mask |= OFPUTIL_PC_NO_FWD;
- pm.config |= OFPUTIL_PC_NO_FWD;
+ if (!strncasecmp(argv[3], "no-", 3)) {
+ command = argv[3] + 3;
+ not = true;
+ } else if (!strncasecmp(argv[3], "no", 2)) {
+ command = argv[3] + 2;
+ not = true;
} else {
- ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
+ command = argv[3];
+ not = false;
+ }
+ for (flag = flags; flag < &flags[ARRAY_SIZE(flags)]; flag++) {
+ if (!strcasecmp(command, flag->name)) {
+ pm.mask = flag->bit;
+ pm.config = flag->on ^ not ? flag->bit : 0;
+ goto found;
+ }
}
+ ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
+found:
protocol = open_vconn(argv[1], &vconn);
transact_noreply(vconn, ofputil_encode_port_mod(&pm, protocol));
vconn_close(vconn);