aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/pnat
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/nat/pnat')
-rw-r--r--src/plugins/nat/pnat/pnat.h5
-rw-r--r--src/plugins/nat/pnat/pnat_cli.c4
2 files changed, 4 insertions, 5 deletions
diff --git a/src/plugins/nat/pnat/pnat.h b/src/plugins/nat/pnat/pnat.h
index c5869ce3ca6..af64fceb4d1 100644
--- a/src/plugins/nat/pnat/pnat.h
+++ b/src/plugins/nat/pnat/pnat.h
@@ -109,12 +109,11 @@ static inline void
pnat_calc_key(u32 sw_if_index, pnat_attachment_point_t attachment,
ip4_address_t src, ip4_address_t dst, u8 protocol, u16 sport,
u16 dport, pnat_mask_fast_t mask, clib_bihash_kv_16_8_t *kv) {
- kv->key[0] = kv->key[1] = 0;
kv->key[0] = (u64)src.as_u32 << 32 | dst.as_u32;
kv->key[0] &= mask.as_u64[0];
- kv->key[1] |=
+ kv->key[1] =
(u64)protocol << 56 | (u64)sw_if_index << 36 | (u64)attachment << 32;
- kv->key[1] |= sport << 16 | dport;
+ kv->key[1] |= (u32)sport << 16 | dport;
kv->key[1] &= mask.as_u64[1];
}
diff --git a/src/plugins/nat/pnat/pnat_cli.c b/src/plugins/nat/pnat/pnat_cli.c
index 2d389013c08..84dfd8d5fc4 100644
--- a/src/plugins/nat/pnat/pnat_cli.c
+++ b/src/plugins/nat/pnat/pnat_cli.c
@@ -97,12 +97,12 @@ uword unformat_pnat_5tuple(unformat_input_t *input, va_list *args) {
else if (unformat(input, "dst %U", unformat_ip4_address, &t->dst))
t->mask |= PNAT_DA;
else if (unformat(input, "sport %d", &sport)) {
- if (sport < 0 || sport > 65535)
+ if (sport == 0 || sport > 65535)
return 0;
t->mask |= PNAT_SPORT;
t->sport = sport;
} else if (unformat(input, "dport %d", &dport)) {
- if (dport < 0 || dport > 65535)
+ if (dport == 0 || dport > 65535)
return 0;
t->mask |= PNAT_DPORT;
t->dport = dport;