diff options
author | Yi Yang <yi.y.yang@intel.com> | 2018-01-11 13:24:03 +0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-01-11 15:55:03 -0800 |
commit | 491e05c23362fbdb36dad9b575a6a67e41630868 (patch) | |
tree | 105995c36d526a071e9ceadc7ea2fa2e334b8d07 /ofproto/ofproto-dpif-xlate.c | |
parent | 81fdabb94dd7b58e713f27cc1daf5c1794be9e0c (diff) | |
download | openvswitch-491e05c23362fbdb36dad9b575a6a67e41630868.tar.gz |
nsh: add dec_nsh_ttl action
NSH ttl is a 6-bit field ranged from 0 to 63, it should be
decremented by 1 every hop, if it is 0 or it is so after
decremented, the packet should be dropped and a packet-in
message is sent to main controller.
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto/ofproto-dpif-xlate.c')
-rw-r--r-- | ofproto/ofproto-dpif-xlate.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index effa9c23d..896d5e290 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -4647,6 +4647,28 @@ compose_set_mpls_tc_action(struct xlate_ctx *ctx, uint8_t tc) } } +static bool +compose_dec_nsh_ttl_action(struct xlate_ctx *ctx) +{ + struct flow *flow = &ctx->xin->flow; + + if ((flow->packet_type == htonl(PT_NSH)) || + (flow->dl_type == htons(ETH_TYPE_NSH))) { + ctx->wc->masks.nsh.ttl = 0xff; + if (flow->nsh.ttl > 1) { + flow->nsh.ttl--; + return false; + } else { + xlate_controller_action(ctx, UINT16_MAX, OFPR_INVALID_TTL, + 0, NULL, 0); + } + } + + /* Stop processing for current table. */ + xlate_report(ctx, OFT_WARN, "NSH decrement TTL exception"); + return true; +} + static void compose_set_mpls_ttl_action(struct xlate_ctx *ctx, uint8_t ttl) { @@ -5196,6 +5218,7 @@ reversible_actions(const struct ofpact *ofpacts, size_t ofpacts_len) case OFPACT_OUTPUT_TRUNC: case OFPACT_ENCAP: case OFPACT_DECAP: + case OFPACT_DEC_NSH_TTL: return false; } } @@ -5423,6 +5446,7 @@ freeze_unroll_actions(const struct ofpact *a, const struct ofpact *end, case OFPACT_OUTPUT: case OFPACT_CONTROLLER: case OFPACT_DEC_MPLS_TTL: + case OFPACT_DEC_NSH_TTL: case OFPACT_DEC_TTL: /* These actions may generate asynchronous messages, which include * table ID and flow cookie information. */ @@ -5971,6 +5995,7 @@ recirc_for_mpls(const struct ofpact *a, struct xlate_ctx *ctx) case OFPACT_CLONE: case OFPACT_ENCAP: case OFPACT_DECAP: + case OFPACT_DEC_NSH_TTL: case OFPACT_UNROLL_XLATE: case OFPACT_CT: case OFPACT_CT_CLEAR: @@ -6295,6 +6320,12 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, } break; + case OFPACT_DEC_NSH_TTL: + if (compose_dec_nsh_ttl_action(ctx)) { + return; + } + break; + case OFPACT_DEC_TTL: wc->masks.nw_ttl = 0xff; if (compose_dec_ttl(ctx, ofpact_get_DEC_TTL(a))) { |