diff options
-rw-r--r-- | src/plugins/snat/nat64_db.c | 21 | ||||
-rw-r--r-- | src/vnet/ip/ip4_to_ip6.h | 14 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/plugins/snat/nat64_db.c b/src/plugins/snat/nat64_db.c index d9989c96036..d15761d2109 100644 --- a/src/plugins/snat/nat64_db.c +++ b/src/plugins/snat/nat64_db.c @@ -107,6 +107,8 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe) nat64_db_bib_entry_key_t bibe_key; clib_bihash_kv_24_8_t kv; nat64_db_bib_entry_t *bib; + u32 *ste_to_be_free = 0, *ste_index, bibe_index; + nat64_db_st_entry_t *st, *ste; switch (bibe->proto) { @@ -114,6 +116,7 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe) #define _(N, i, n, s) \ case SNAT_PROTOCOL_##N: \ bib = db->bib._##n##_bib; \ + st = db->st._##n##_st; \ break; foreach_snat_protocol #undef _ @@ -123,6 +126,21 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe) return; } + bibe_index = bibe - bib; + + /* delete ST entries for static BIB entry */ + if (bibe->is_static) + { + pool_foreach (ste, st, ( + { + if (ste->bibe_index == bibe_index) + vec_add1 (ste_to_be_free, ste - st);} + )); + vec_foreach (ste_index, ste_to_be_free) + nat64_db_st_entry_free (db, pool_elt_at_index (st, ste_index[0])); + vec_free (ste_to_be_free); + } + /* delete hash lookup */ bibe_key.addr.as_u64[0] = bibe->in_addr.as_u64[0]; bibe_key.addr.as_u64[1] = bibe->in_addr.as_u64[1]; @@ -146,6 +164,7 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe) /* delete from pool */ pool_put (bib, bibe); + } nat64_db_bib_entry_t * @@ -480,7 +499,7 @@ nad64_db_st_free_expired (nat64_db_t * db, u32 now) vec_add1 (ste_to_be_free, ste - st); \ })); \ vec_foreach (ste_index, ste_to_be_free) \ - pool_put_index (st, ste_index[0]); \ + nat64_db_st_entry_free (db, pool_elt_at_index(st, ste_index[0])); \ vec_free (ste_to_be_free); \ ste_to_be_free = 0; foreach_snat_protocol diff --git a/src/vnet/ip/ip4_to_ip6.h b/src/vnet/ip/ip4_to_ip6.h index 965d27c3393..dad35230b12 100644 --- a/src/vnet/ip/ip4_to_ip6.h +++ b/src/vnet/ip/ip4_to_ip6.h @@ -367,11 +367,15 @@ icmp_to_icmp6 (vlib_buffer_t * p, ip4_to_ip6_set_fn_t fn, void *ctx, sizeof (*inner_frag)); } - csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[0]); - csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[1]); - csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[0]); - csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[1]); - *inner_L4_checksum = ip_csum_fold (csum); + /* UDP checksum is optional */ + if (csum) + { + csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[0]); + csum = ip_csum_add_even (csum, inner_ip6->src_address.as_u64[1]); + csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[0]); + csum = ip_csum_add_even (csum, inner_ip6->dst_address.as_u64[1]); + *inner_L4_checksum = ip_csum_fold (csum); + } } else { |