summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.c b/src/plugins/nat/nat44-ed/nat44_ed.c
index 2e4c791ef80..ed93f6cc55f 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed.c
@@ -286,8 +286,7 @@ nat44_ed_resolve_nat_addr_len (snat_address_t *ap,
{
ap->addr_len = ia->address_length;
ap->sw_if_index = i->sw_if_index;
- ap->net.as_u32 = (ap->addr.as_u32 >> (32 - ap->addr_len))
- << (32 - ap->addr_len);
+ ap->net.as_u32 = ap->addr.as_u32 & ip4_main.fib_masks[ap->addr_len];
nat_log_debug ("pool addr %U binds to -> sw_if_idx: %u net: %U/%u",
format_ip4_address, &ap->addr, ap->sw_if_index,
@@ -334,8 +333,7 @@ nat44_ed_bind_if_addr_to_nat_addr (u32 sw_if_index)
{
ap->addr_len = ia->address_length;
ap->sw_if_index = sw_if_index;
- ap->net.as_u32 = (ap->addr.as_u32 >> (32 - ap->addr_len))
- << (32 - ap->addr_len);
+ ap->net.as_u32 = ap->addr.as_u32 & ip4_main.fib_masks[ap->addr_len];
nat_log_debug ("pool addr %U binds to -> sw_if_idx: %u net: %U/%u",
format_ip4_address, &ap->addr, ap->sw_if_index,
@@ -3434,8 +3432,8 @@ nat44_ed_add_del_interface_address_cb (ip4_main_t *im, uword opaque,
{
ap->addr_len = address_length;
ap->sw_if_index = sw_if_index;
- ap->net.as_u32 = (ap->addr.as_u32 >> (32 - ap->addr_len))
- << (32 - ap->addr_len);
+ ap->net.as_u32 =
+ ap->addr.as_u32 & ip4_main.fib_masks[ap->addr_len];
nat_log_debug (
"pool addr %U binds to -> sw_if_idx: %u net: %U/%u",