From: Justin Pettit Date: Tue, 14 Apr 2009 00:41:33 +0000 (-0700) Subject: Add support for explicitly specifying a "drop" action when adding a flow. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8826ef578229bc910b339ce9e578825f95a7380;p=openvswitch Add support for explicitly specifying a "drop" action when adding a flow. When adding a flow entry with dpctl, the user specifies a set of actions to execute when a match occurs. If none are specified, then the packet is implicitly dropped by OpenFlow. When dumping these flows, the output of dpctl shows an action of "drop". However, dpctl did not support adding a flow with an explicit "drop" action. This fixes that lack of symmetry. --- diff --git a/utilities/dpctl.8.in b/utilities/dpctl.8.in index 4ddc48a9..f3b33403 100644 --- a/utilities/dpctl.8.in +++ b/utilities/dpctl.8.in @@ -434,6 +434,10 @@ Outputs the packet on the ``local port,'' which corresponds to the \fBof\fIn\fR network device (see \fBCONTACTING THE CONTROLLER\fR in \fBsecchan\fR(8) for information on the \fBof\fIn\fR network device). +.IP \fBdrop\fR +Discards the packet, so no further processing or forwarding takes place. +If a drop action is used, no other actions may be specified. + .IP \fBmod_vlan_vid\fR:\fIvlan_vid\fR Modifies the VLAN id on a packet. The VLAN tag is added or modified as necessary to match the value specified. If the VLAN tag is added, diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 6d334e2a..26e5160d 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -912,12 +912,17 @@ str_to_action(char *str, struct ofpbuf *b) { char *act, *arg; char *saveptr = NULL; + bool drop = false; for (act = strtok_r(str, ", \t\r\n", &saveptr); act; act = strtok_r(NULL, ", \t\r\n", &saveptr)) { uint16_t port; + if (drop) { + ofp_fatal(0, "Drop actions must not be followed by other actions"); + } + /* Arguments are separated by colons */ arg = strchr(act, ':'); if (arg) { @@ -943,6 +948,10 @@ str_to_action(char *str, struct ofpbuf *b) put_dl_addr_action(b, OFPAT_SET_DL_DST, arg); } else if (!strcasecmp(act, "output")) { put_output_action(b, str_to_u32(arg)); + } else if (!strcasecmp(act, "drop")) { + /* A drop action in OpenFlow occurs by just not setting + * an action. */ + drop=true; #ifdef SUPPORT_SNAT } else if (!strcasecmp(act, "nat")) { struct nx_action_snat *sa;