From: Ben Pfaff Date: Wed, 15 Apr 2009 17:01:30 +0000 (-0700) Subject: dpctl: When parsing actions, don't let "drop" be preceded by other actions. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dc996a81bec847de5fff732b5714161ba0cb583;p=openvswitch dpctl: When parsing actions, don't let "drop" be preceded by other actions. The dpctl manpage says that "drop" must not be used with other actions, but we were only checking for other actions *after* it, not just ones before it. --- diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 3e0227e7..5fa5fa4b 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -925,9 +925,10 @@ str_to_action(char *str, struct ofpbuf *b) char *act, *arg; char *saveptr = NULL; bool drop = false; + int n_actions; - for (act = strtok_r(str, ", \t\r\n", &saveptr); act; - act = strtok_r(NULL, ", \t\r\n", &saveptr)) + for (act = strtok_r(str, ", \t\r\n", &saveptr), n_actions = 0; act; + act = strtok_r(NULL, ", \t\r\n", &saveptr), n_actions++) { uint16_t port; @@ -963,7 +964,11 @@ str_to_action(char *str, struct ofpbuf *b) } else if (!strcasecmp(act, "drop")) { /* A drop action in OpenFlow occurs by just not setting * an action. */ - drop=true; + drop = true; + if (n_actions) { + ofp_fatal(0, "Drop actions must not be preceded by other " + "actions"); + } #ifdef SUPPORT_SNAT } else if (!strcasecmp(act, "nat")) { struct nx_action_snat *sa;