From 17553f27baa1d1883bed0d099f20e979cecd4a4c Mon Sep 17 00:00:00 2001 From: Yi Yang Date: Thu, 11 Jan 2018 13:24:01 +0800 Subject: nsh: add new flow key 'ttl' IETF NSH draft added a new filed ttl in NSH header, this patch is to add new nsh key 'ttl' for it. Signed-off-by: Yi Yang Signed-off-by: Ben Pfaff --- lib/nx-match.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/nx-match.c') diff --git a/lib/nx-match.c b/lib/nx-match.c index 8f2a442e9..aa7691ae9 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -1022,6 +1022,7 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, const struct flow *flow = &match->flow; const size_t start_len = b->size; ovs_be16 dl_type = get_dl_type(flow); + ovs_be32 spi_mask; int match_len; int i; @@ -1157,13 +1158,22 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, /* Network Service Header */ nxm_put_8m(&ctx, MFF_NSH_FLAGS, oxm, flow->nsh.flags, match->wc.masks.nsh.flags); + nxm_put_8m(&ctx, MFF_NSH_TTL, oxm, flow->nsh.ttl, + match->wc.masks.nsh.ttl); nxm_put_8m(&ctx, MFF_NSH_MDTYPE, oxm, flow->nsh.mdtype, match->wc.masks.nsh.mdtype); nxm_put_8m(&ctx, MFF_NSH_NP, oxm, flow->nsh.np, match->wc.masks.nsh.np); - nxm_put_32m(&ctx, MFF_NSH_SPI, oxm, flow->nsh.spi, - match->wc.masks.nsh.spi); - nxm_put_8m(&ctx, MFF_NSH_SI, oxm, flow->nsh.si, match->wc.masks.nsh.si); + spi_mask = nsh_path_hdr_to_spi(match->wc.masks.nsh.path_hdr); + if (spi_mask == htonl(NSH_SPI_MASK >> NSH_SPI_SHIFT)) { + spi_mask = OVS_BE32_MAX; + } + nxm_put_32m(&ctx, MFF_NSH_SPI, oxm, + nsh_path_hdr_to_spi(flow->nsh.path_hdr), + spi_mask); + nxm_put_8m(&ctx, MFF_NSH_SI, oxm, + nsh_path_hdr_to_si(flow->nsh.path_hdr), + nsh_path_hdr_to_si(match->wc.masks.nsh.path_hdr)); for (int i = 0; i < 4; i++) { nxm_put_32m(&ctx, MFF_NSH_C1 + i, oxm, flow->nsh.context[i], match->wc.masks.nsh.context[i]); -- cgit v1.2.1