Skip to content

Commit

Permalink
PUSH_MPLS used for push_mpls userspace action
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Varghese committed Mar 12, 2021
1 parent febe0cb commit 727cd01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
26 changes: 9 additions & 17 deletions lib/odp-util.c
Expand Up @@ -7887,7 +7887,7 @@ commit_vlan_action(const struct flow* flow, struct flow *base,
static void
commit_mpls_action(const struct flow *flow, struct flow *base,
struct ofpbuf *odp_actions, bool pending_encap,
bool pending_decap, bool l2_support)
bool pending_decap)
{
int base_n = flow_count_mpls_labels(base, NULL);
int flow_n = flow_count_mpls_labels(flow, NULL);
Expand Down Expand Up @@ -7940,15 +7940,12 @@ commit_mpls_action(const struct flow *flow, struct flow *base,
* than base then some LSEs need to be pushed. */
while (base_n < flow_n) {

if (pending_encap || l2_support) {
if (pending_encap) {
struct ovs_action_add_mpls *mpls;

mpls = nl_msg_put_unspec_zero(odp_actions,
OVS_ACTION_ATTR_ADD_MPLS,
sizeof *mpls);
if (!pending_encap) {
mpls->tun_flags |= OVS_MPLS_L3_TUNNEL_FLAG_MASK;
}
mpls->mpls_ethertype = flow->dl_type;
mpls->mpls_lse = flow->mpls_lse[flow_n - base_n - 1];
} else {
Expand Down Expand Up @@ -8594,8 +8591,7 @@ commit_encap_decap_action(const struct flow *flow,
struct ofpbuf *odp_actions,
struct flow_wildcards *wc,
bool pending_encap, bool pending_decap,
struct ofpbuf *encap_data,
bool mpls_l2_backer_support)
struct ofpbuf *encap_data)
{
if (pending_encap) {
switch (ntohl(flow->packet_type)) {
Expand All @@ -8618,7 +8614,7 @@ commit_encap_decap_action(const struct flow *flow,
break;
case PT_MPLS:
commit_mpls_action(flow, base_flow, odp_actions, pending_encap,
pending_decap, mpls_l2_backer_support);
pending_decap);
break;
default:
/* Only the above protocols are supported for encap.
Expand All @@ -8644,7 +8640,7 @@ commit_encap_decap_action(const struct flow *flow,
break;
case PT_MPLS:
commit_mpls_action(flow, base_flow, odp_actions, pending_encap,
pending_decap, mpls_l2_backer_support);
pending_decap);
break;
default:
/* Checks are done during translation. */
Expand Down Expand Up @@ -8675,8 +8671,7 @@ enum slow_path_reason
commit_odp_actions(const struct flow *flow, struct flow *base,
struct ofpbuf *odp_actions, struct flow_wildcards *wc,
bool use_masked, bool pending_encap, bool pending_decap,
struct ofpbuf *encap_data,
bool mpls_l2_backer_support)
struct ofpbuf *encap_data)
{
/* If you add a field that OpenFlow actions can change, and that is visible
* to the datapath (including all data fields), then you should also add
Expand All @@ -8687,23 +8682,20 @@ commit_odp_actions(const struct flow *flow, struct flow *base,
bool mpls_done = false;

commit_encap_decap_action(flow, base, odp_actions, wc,
pending_encap, pending_decap, encap_data,
mpls_l2_backer_support);
pending_encap, pending_decap, encap_data);
commit_set_ether_action(flow, base, odp_actions, wc, use_masked);
/* Make packet a non-MPLS packet before committing L3/4 actions,
* which would otherwise do nothing. */
if (eth_type_mpls(base->dl_type) && !eth_type_mpls(flow->dl_type)) {
commit_mpls_action(flow, base, odp_actions, false, false,
mpls_l2_backer_support);
commit_mpls_action(flow, base, odp_actions, false, false);
mpls_done = true;
}
commit_set_nsh_action(flow, base, odp_actions, wc, use_masked);
slow1 = commit_set_nw_action(flow, base, odp_actions, wc, use_masked);
commit_set_port_action(flow, base, odp_actions, wc, use_masked);
slow2 = commit_set_icmp_action(flow, base, odp_actions, wc);
if (!mpls_done) {
commit_mpls_action(flow, base, odp_actions, false, false,
mpls_l2_backer_support);
commit_mpls_action(flow, base, odp_actions, false, false);
}
commit_vlan_action(flow, base, odp_actions, wc);
commit_set_priority_action(flow, base, odp_actions, wc, use_masked);
Expand Down
3 changes: 1 addition & 2 deletions lib/odp-util.h
Expand Up @@ -290,8 +290,7 @@ enum slow_path_reason commit_odp_actions(const struct flow *,
bool use_masked,
bool pending_encap,
bool pending_decap,
struct ofpbuf *encap_data,
bool mpls_l2_support);
struct ofpbuf *encap_data);

/* ofproto-dpif interface.
*
Expand Down
4 changes: 2 additions & 2 deletions ofproto/ofproto-dpif-xlate.c
Expand Up @@ -3778,8 +3778,8 @@ xlate_commit_actions(struct xlate_ctx *ctx)
ctx->xout->slow |= commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
ctx->odp_actions, ctx->wc,
use_masked, ctx->pending_encap,
ctx->pending_decap, ctx->encap_data,
ctx->xbridge->support.add_mpls);
ctx->pending_decap, ctx->encap_data);

ctx->pending_encap = false;
ctx->pending_decap = false;
ofpbuf_delete(ctx->encap_data);
Expand Down

0 comments on commit 727cd01

Please sign in to comment.