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

ovs-tc: offload MPLS set actions to TC datapath

Recent modifications to TC allows the modifying of fields within the
outermost MPLS header of a packet. OvS datapath rules impliment an MPLS
set action by supplying a new MPLS header that should overwrite the
current one.

Convert the OvS datapath MPLS set action to a TC modify action and allow
such rules to be offloaded to a TC datapath.

Signed-off-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
John Hurley
2019-07-30 12:05:17 +01:00
committed by Simon Horman
parent 283dcf850d
commit a8f005cf26
3 changed files with 86 additions and 0 deletions

View File

@@ -665,6 +665,23 @@ parse_tc_flower_to_match(struct tc_flower *flower,
push->mpls_lse = mpls_lse;
}
break;
case TC_ACT_MPLS_SET: {
size_t set_offset = nl_msg_start_nested(buf,
OVS_ACTION_ATTR_SET);
struct ovs_key_mpls *set_mpls;
ovs_be32 mpls_lse = 0;
flow_set_mpls_lse_label(&mpls_lse, action->mpls.label);
flow_set_mpls_lse_tc(&mpls_lse, action->mpls.tc);
flow_set_mpls_lse_ttl(&mpls_lse, action->mpls.ttl);
flow_set_mpls_lse_bos(&mpls_lse, action->mpls.bos);
set_mpls = nl_msg_put_unspec_zero(buf, OVS_KEY_ATTR_MPLS,
sizeof *set_mpls);
set_mpls->mpls_lse = mpls_lse;
nl_msg_end_nested(buf, set_offset);
}
break;
case TC_ACT_PEDIT: {
parse_flower_rewrite_to_netlink_action(buf, flower);
}
@@ -789,6 +806,22 @@ netdev_tc_flow_dump_next(struct netdev_flow_dump *dump,
return false;
}
static int
parse_mpls_set_action(struct tc_flower *flower, struct tc_action *action,
const struct nlattr *set)
{
const struct ovs_key_mpls *mpls_set = nl_attr_get(set);
action->mpls.label = mpls_lse_to_label(mpls_set->mpls_lse);
action->mpls.tc = mpls_lse_to_tc(mpls_set->mpls_lse);
action->mpls.ttl = mpls_lse_to_ttl(mpls_set->mpls_lse);
action->mpls.bos = mpls_lse_to_bos(mpls_set->mpls_lse);
action->type = TC_ACT_MPLS_SET;
flower->action_count++;
return 0;
}
static int
parse_put_flow_set_masked_action(struct tc_flower *flower,
struct tc_action *action,
@@ -870,6 +903,10 @@ parse_put_flow_set_action(struct tc_flower *flower, struct tc_action *action,
const struct nlattr *tun_attr;
size_t tun_left, tunnel_len;
if (nl_attr_type(set) == OVS_KEY_ATTR_MPLS) {
return parse_mpls_set_action(flower, action, set);
}
if (nl_attr_type(set) != OVS_KEY_ATTR_TUNNEL) {
return parse_put_flow_set_masked_action(flower, action, set,
set_len, false);