From 0dc996a81bec847de5fff732b5714161ba0cb583 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 15 Apr 2009 10:01:30 -0700 Subject: [PATCH] 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. --- utilities/dpctl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; -- 2.30.2