2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

Add OF11 SET MPLS LABEL and SET MPLS TC actions.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
Jarno Rajahalme
2013-10-24 13:19:34 -07:00
committed by Ben Pfaff
parent 6cc17de80f
commit 097d493945
8 changed files with 261 additions and 15 deletions

View File

@@ -438,6 +438,42 @@ parse_dec_ttl(struct ofpbuf *b, char *arg)
return NULL;
}
/* Parses 'arg' as the argument to a "set_mpls_label" action, and appends such
* an action to 'b'.
*
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
static char * WARN_UNUSED_RESULT
parse_set_mpls_label(struct ofpbuf *b, const char *arg)
{
struct ofpact_mpls_label *mpls_label = ofpact_put_SET_MPLS_LABEL(b);
if (*arg == '\0') {
return xstrdup("parse_set_mpls_label: expected label.");
}
mpls_label->label = htonl(atoi(arg));
return NULL;
}
/* Parses 'arg' as the argument to a "set_mpls_tc" action, and appends such an
* action to 'b'.
*
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
static char * WARN_UNUSED_RESULT
parse_set_mpls_tc(struct ofpbuf *b, const char *arg)
{
struct ofpact_mpls_tc *mpls_tc = ofpact_put_SET_MPLS_TC(b);
if (*arg == '\0') {
return xstrdup("parse_set_mpls_tc: expected tc.");
}
mpls_tc->tc = atoi(arg);
return NULL;
}
/* Parses 'arg' as the argument to a "set_mpls_ttl" action, and appends such an
* action to 'ofpacts'.
*
@@ -811,6 +847,16 @@ parse_named_action(enum ofputil_action_code code,
error = parse_dec_ttl(ofpacts, arg);
break;
case OFPUTIL_NXAST_SET_MPLS_LABEL:
case OFPUTIL_OFPAT11_SET_MPLS_LABEL:
error = parse_set_mpls_label(ofpacts, arg);
break;
case OFPUTIL_NXAST_SET_MPLS_TC:
case OFPUTIL_OFPAT11_SET_MPLS_TC:
error = parse_set_mpls_tc(ofpacts, arg);
break;
case OFPUTIL_NXAST_SET_MPLS_TTL:
case OFPUTIL_OFPAT11_SET_MPLS_TTL:
error = parse_set_mpls_ttl(ofpacts, arg);