X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=utilities%2Fovs-ofctl.c;h=204e9582f22975dd5877eced8a78f9b3b432c9fa;hb=80bc2072c0f8b105142f7f30f202809127af87a5;hp=69f8adfd93721401a969261489df165d94782d76;hpb=abaad8cf1b5089e17a4af0ab1ff644bfcf63cad9;p=openvswitch diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 69f8adfd..204e9582 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -405,6 +405,20 @@ str_to_u32(const char *str) return value; } +static uint64_t +str_to_u64(const char *str) +{ + char *tail; + uint64_t value; + + errno = 0; + value = strtoull(str, &tail, 0); + if (errno == EINVAL || errno == ERANGE || *tail) { + ovs_fatal(0, "invalid numeric format %s", str); + } + return value; +} + static void str_to_mac(const char *str, uint8_t mac[6]) { @@ -627,6 +641,12 @@ str_to_action(char *str, struct ofpbuf *b) struct ofp_action_nw_tos *nt; nt = put_action(b, sizeof *nt, OFPAT_SET_NW_TOS); nt->nw_tos = str_to_u32(arg); + } else if (!strcasecmp(act, "resubmit")) { + struct nx_action_resubmit *nar; + nar = put_action(b, sizeof *nar, OFPAT_VENDOR); + nar->vendor = htonl(NX_VENDOR_ID); + nar->subtype = htons(NXAST_RESUBMIT); + nar->in_port = htons(str_to_u32(arg)); } else if (!strcasecmp(act, "output")) { put_output_action(b, str_to_u32(arg)); } else if (!strcasecmp(act, "drop")) { @@ -643,7 +663,7 @@ str_to_action(char *str, struct ofpbuf *b) /* Unless a numeric argument is specified, we send the whole * packet to the controller. */ - if (arg && (strspn(act, "0123456789") == strlen(act))) { + if (arg && (strspn(arg, "0123456789") == strlen(arg))) { oao->max_len = htons(str_to_u32(arg)); } else { oao->max_len = htons(UINT16_MAX); @@ -760,9 +780,9 @@ str_to_flow(char *string, struct ofp_match *match, struct ofpbuf *actions, if (!act_str) { ovs_fatal(0, "must specify an action"); } - *(act_str-1) = '\0'; + *act_str = '\0'; - act_str = strchr(act_str, '='); + act_str = strchr(act_str + 1, '='); if (!act_str) { ovs_fatal(0, "must specify an action"); } @@ -804,7 +824,7 @@ str_to_flow(char *string, struct ofp_match *match, struct ofpbuf *actions, } else if (hard_timeout && !strcmp(name, "hard_timeout")) { *hard_timeout = atoi(value); } else if (cookie && !strcmp(name, "cookie")) { - *cookie = atoi(value); + *cookie = str_to_u64(value); } else if (parse_field(name, &f)) { void *data = (char *) match + f->offset; if (!strcmp(value, "*") || !strcmp(value, "ANY")) {