aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Lenco <milan.lenco@pantheon.tech>2017-11-24 17:12:33 +0100
committerFlorin Coras <florin.coras@gmail.com>2017-11-26 20:48:08 +0000
commit8b9a5d198cc316d36b93f19fee7a351fc3922e4a (patch)
tree5f8cf5b482c6d9795c5d523c82cc89fec16e820d
parent6bcac065b82ef2e48fc23db18534d9dc9a7833a1 (diff)
Fix session rule port endianness.
Change-Id: I43a7ac5b6c33810a465568d1955f400f4ef08786 Signed-off-by: Milan Lenco <milan.lenco@pantheon.tech>
-rw-r--r--src/vnet/ip/ip.c4
-rwxr-xr-xsrc/vnet/session/session_api.c12
-rw-r--r--src/vnet/session/session_rules_table.c18
3 files changed, 18 insertions, 16 deletions
diff --git a/src/vnet/ip/ip.c b/src/vnet/ip/ip.c
index 0c4687d81a1..b6825c30709 100644
--- a/src/vnet/ip/ip.c
+++ b/src/vnet/ip/ip.c
@@ -254,8 +254,8 @@ ip6_mask_to_preflen (ip6_address_t * mask)
u8 first1, first0;
if (mask->as_u64[0] == 0 && mask->as_u64[1] == 0)
return 0;
- first1 = log2_first_set (mask->as_u64[1]);
- first0 = log2_first_set (mask->as_u64[0]);
+ first1 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[1]));
+ first0 = log2_first_set (clib_net_to_host_u64 (mask->as_u64[0]));
if (first1 != 0)
return 128 - first1;
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index e987854bc73..f15d2f6e830 100755
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -834,8 +834,8 @@ vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp)
table_args->lcl.fp_proto = fib_proto;
table_args->rmt.fp_len = mp->rmt_plen;
table_args->rmt.fp_proto = fib_proto;
- table_args->lcl_port = clib_net_to_host_u16 (mp->lcl_port);
- table_args->rmt_port = clib_net_to_host_u16 (mp->rmt_port);
+ table_args->lcl_port = mp->lcl_port;
+ table_args->rmt_port = mp->rmt_port;
table_args->action_index = clib_net_to_host_u32 (mp->action_index);
table_args->is_add = mp->is_add;
mp->tag[sizeof (mp->tag) - 1] = 0;
@@ -879,8 +879,8 @@ send_session_rule_details4 (mma_rule_16_t * rule, u8 is_local,
clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip));
rmp->lcl_plen = ip4_mask_to_preflen (&mask->lcl_ip);
rmp->rmt_plen = ip4_mask_to_preflen (&mask->rmt_ip);
- rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port);
- rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port);
+ rmp->lcl_port = match->lcl_port;
+ rmp->rmt_port = match->rmt_port;
rmp->action_index = clib_host_to_net_u32 (rule->action_index);
rmp->scope =
is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL;
@@ -916,8 +916,8 @@ send_session_rule_details6 (mma_rule_40_t * rule, u8 is_local,
clib_memcpy (rmp->rmt_ip, &match->rmt_ip, sizeof (match->rmt_ip));
rmp->lcl_plen = ip6_mask_to_preflen (&mask->lcl_ip);
rmp->rmt_plen = ip6_mask_to_preflen (&mask->rmt_ip);
- rmp->lcl_port = clib_host_to_net_u16 (match->lcl_port);
- rmp->rmt_port = clib_host_to_net_u16 (match->rmt_port);
+ rmp->lcl_port = match->lcl_port;
+ rmp->rmt_port = match->rmt_port;
rmp->action_index = clib_host_to_net_u32 (rule->action_index);
rmp->scope =
is_local ? SESSION_RULE_SCOPE_LOCAL : SESSION_RULE_SCOPE_GLOBAL;
diff --git a/src/vnet/session/session_rules_table.c b/src/vnet/session/session_rules_table.c
index fa8a056fbf0..abe2a2bb7af 100644
--- a/src/vnet/session/session_rules_table.c
+++ b/src/vnet/session/session_rules_table.c
@@ -128,10 +128,11 @@ format_session_rule4 (u8 * s, va_list * args)
s = format (s, "[%d] rule: %U/%d %d %U/%d %d action: %d tag: %v", ri,
format_ip4_address, &match->lcl_ip,
- ip4_mask_to_preflen (&mask->lcl_ip), match->lcl_port,
- format_ip4_address, &match->rmt_ip,
- ip4_mask_to_preflen (&mask->rmt_ip), match->rmt_port,
- sr->action_index, tag ? tag : null_tag);
+ ip4_mask_to_preflen (&mask->lcl_ip),
+ clib_net_to_host_u16 (match->lcl_port), format_ip4_address,
+ &match->rmt_ip, ip4_mask_to_preflen (&mask->rmt_ip),
+ clib_net_to_host_u16 (match->rmt_port), sr->action_index,
+ tag ? tag : null_tag);
if (vec_len (sr->next_indices))
{
s = format (s, "\n children: ");
@@ -161,10 +162,11 @@ format_session_rule6 (u8 * s, va_list * args)
s = format (s, "[%d] rule: %U/%d %d %U/%d %d action: %d tag: %v", ri,
format_ip6_address, &match->lcl_ip,
- ip6_mask_to_preflen (&mask->lcl_ip), match->lcl_port,
- format_ip6_address, &match->rmt_ip,
- ip6_mask_to_preflen (&mask->rmt_ip), match->rmt_port,
- sr->action_index, tag ? tag : null_tag);
+ ip6_mask_to_preflen (&mask->lcl_ip),
+ clib_net_to_host_u16 (match->lcl_port), format_ip6_address,
+ &match->rmt_ip, ip6_mask_to_preflen (&mask->rmt_ip),
+ clib_net_to_host_u16 (match->rmt_port), sr->action_index,
+ tag ? tag : null_tag);
if (vec_len (sr->next_indices))
{
s = format (s, "\n children: ");