From: Ben Pfaff Date: Thu, 18 Oct 2012 18:12:38 +0000 (-0700) Subject: ofp-actions: Prefer OFPAT11_DEC_TTL to NXAST_DEC_TTL for OpenFlow 1.1+. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9908606290852fc4d29132c843d9f17938cce7d8;p=openvswitch ofp-actions: Prefer OFPAT11_DEC_TTL to NXAST_DEC_TTL for OpenFlow 1.1+. When "dec_ttl" is specified as the name of an action, in OpenFlow 1.1 and later we should prefer to use the standardized action, rather than the Nicira extension. Reported-by: Isaku Yamahata Signed-off-by: Ben Pfaff Reviewed-by: Isaku Yamahata --- diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index b774a61e..ae20f8e3 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1425,6 +1425,19 @@ ofpact_output_to_openflow11(const struct ofpact_output *output, oao->max_len = htons(output->max_len); } +static void +ofpact_dec_ttl_to_openflow11(const struct ofpact_cnt_ids *dec_ttl, + struct ofpbuf *out) +{ + if (dec_ttl->n_controllers == 1 && dec_ttl->cnt_ids[0] == 0 + && (!dec_ttl->ofpact.compat || + dec_ttl->ofpact.compat == OFPUTIL_OFPAT11_DEC_NW_TTL)) { + ofputil_put_OFPAT11_DEC_NW_TTL(out); + } else { + ofpact_dec_ttl_to_nxast(dec_ttl, out); + } +} + static void ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) { @@ -1486,11 +1499,7 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) break; case OFPACT_DEC_TTL: - if (a->compat == OFPUTIL_OFPAT11_DEC_NW_TTL) { - ofputil_put_OFPAT11_DEC_NW_TTL(out); - } else { - ofpact_to_nxast(a, out); - } + ofpact_dec_ttl_to_openflow11(ofpact_get_DEC_TTL(a), out); break; case OFPACT_CLEAR_ACTIONS: diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index a9d70de1..f8cbcc67 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -279,13 +279,12 @@ parse_controller(struct ofpbuf *b, char *arg) } static void -parse_noargs_dec_ttl(struct ofpbuf *b, enum ofputil_action_code compat) +parse_noargs_dec_ttl(struct ofpbuf *b) { struct ofpact_cnt_ids *ids; uint16_t id = 0; ids = ofpact_put_DEC_TTL(b); - ids->ofpact.compat = compat; ofpbuf_put(b, &id, sizeof id); ids = b->l2; ids->n_controllers++; @@ -293,10 +292,10 @@ parse_noargs_dec_ttl(struct ofpbuf *b, enum ofputil_action_code compat) } static void -parse_dec_ttl(struct ofpbuf *b, char *arg, enum ofputil_action_code compat) +parse_dec_ttl(struct ofpbuf *b, char *arg) { if (*arg == '\0') { - parse_noargs_dec_ttl(b, compat); + parse_noargs_dec_ttl(b); } else { struct ofpact_cnt_ids *ids; char *cntr; @@ -516,7 +515,7 @@ parse_named_action(enum ofputil_action_code code, const struct flow *flow, break; case OFPUTIL_NXAST_DEC_TTL: - parse_dec_ttl(ofpacts, arg, code); + parse_dec_ttl(ofpacts, arg); break; case OFPUTIL_NXAST_FIN_TIMEOUT: