diff options
author | Hongjun Ni <hongjun.ni@intel.com> | 2017-01-25 21:58:10 +0800 |
---|---|---|
committer | Hongjun Ni <hongjun.ni@intel.com> | 2017-01-25 21:58:10 +0800 |
commit | 6363b43a2b3d569bb683fdee95b63c681e24cec9 (patch) | |
tree | 14e08409ec4b342cbb5b1fa6c70ef916b75eccea /nsh-plugin/nsh/nsh.c | |
parent | 8ce5ee6eaf800ae88c0b47311197f0cff89dec63 (diff) |
Need to change from host order to net order when encaping nsh header NSHSFC-22v17.01stable/1701
Change-Id: I689c55d0689c4cbc1493432d2e0761a277fe8ec3
Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'nsh-plugin/nsh/nsh.c')
-rw-r--r-- | nsh-plugin/nsh/nsh.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/nsh-plugin/nsh/nsh.c b/nsh-plugin/nsh/nsh.c index c5b9453..b3a3007 100644 --- a/nsh-plugin/nsh/nsh.c +++ b/nsh-plugin/nsh/nsh.c @@ -935,6 +935,20 @@ nsh_plugin_api_hookup (vlib_main_t *vm) } +static void +nsh_header_host_to_net(nsh_header_t *hdr, nsh_header_t *encap_hdr) +{ + hdr->ver_o_c = encap_hdr->ver_o_c; + hdr->length = encap_hdr->length; + hdr->md_type = encap_hdr->md_type; + hdr->next_protocol = encap_hdr->next_protocol; + hdr->nsp_nsi = clib_host_to_net_u32(encap_hdr->nsp_nsi); + hdr->c1 = clib_host_to_net_u32(encap_hdr->c1); + hdr->c2 = clib_host_to_net_u32(encap_hdr->c2); + hdr->c3 = clib_host_to_net_u32(encap_hdr->c3); + hdr->c4 = clib_host_to_net_u32(encap_hdr->c4); + +} static uword @@ -1115,7 +1129,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b0, -(word)encap_hdr_len0); hdr0 = vlib_buffer_get_current(b0); - clib_memcpy(hdr0, encap_hdr0, (word)encap_hdr_len0); + nsh_header_host_to_net(hdr0, encap_hdr0); goto trace0; } @@ -1125,7 +1139,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b0, -(word)encap_hdr_len0); hdr0 = vlib_buffer_get_current(b0); - clib_memcpy(hdr0, encap_hdr0, (word)encap_hdr_len0); + nsh_header_host_to_net(hdr0, encap_hdr0); } trace0: b0->error = error0 ? node->errors[error0] : 0; @@ -1181,7 +1195,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b1, -(word)encap_hdr_len1); hdr1 = vlib_buffer_get_current(b1); - clib_memcpy(hdr1, encap_hdr1, (word)encap_hdr_len1); + nsh_header_host_to_net(hdr1, encap_hdr1); goto trace1; } @@ -1191,7 +1205,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b1, -(word)encap_hdr_len1); hdr1 = vlib_buffer_get_current(b1); - clib_memcpy(hdr1, encap_hdr1, (word)encap_hdr_len1); + nsh_header_host_to_net(hdr1, encap_hdr1); } trace1: b1->error = error1 ? node->errors[error1] : 0; @@ -1312,7 +1326,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b0, -(word)encap_hdr_len0); hdr0 = vlib_buffer_get_current(b0); - clib_memcpy(hdr0, encap_hdr0, (word)encap_hdr_len0); + nsh_header_host_to_net(hdr0, encap_hdr0); goto trace00; } @@ -1322,7 +1336,7 @@ nsh_input_map (vlib_main_t * vm, /* Push new NSH header */ vlib_buffer_advance(b0, -(word)encap_hdr_len0); hdr0 = vlib_buffer_get_current(b0); - clib_memcpy(hdr0, encap_hdr0, (word)encap_hdr_len0); + nsh_header_host_to_net(hdr0, encap_hdr0); } trace00: b0->error = error0 ? node->errors[error0] : 0; |