Skip to content

Commit

Permalink
Fixed VNI table consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Sep 19, 2023
1 parent 827421a commit 77c112f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
3 changes: 0 additions & 3 deletions include/dp_vni.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extern struct rte_hash *vni_handle_tbl;
// TODO: packing?
struct dp_vni_key {
int vni;
int type;
};

struct dp_vni_value {
Expand All @@ -39,7 +38,6 @@ static __rte_always_inline struct rte_rib *dp_get_vni_route4_table(int vni, int
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = DP_IP_PROTO_IPV4,
.vni = vni
};
int ret;
Expand All @@ -61,7 +59,6 @@ static __rte_always_inline struct rte_rib6 *dp_get_vni_route6_table(int vni, int
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = DP_IP_PROTO_IPV6,
.vni = vni
};
int ret;
Expand Down
8 changes: 2 additions & 6 deletions src/dp_vni.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ bool dp_is_vni_route_tbl_available(int vni, int type, int socketid)
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = type,
.vni = vni
};
int ret;
Expand All @@ -50,7 +49,7 @@ static void dp_free_vni_value(struct dp_ref *ref)
{
struct dp_vni_value *vni_value = container_of(ref, struct dp_vni_value, ref_count);

DPS_LOG_DEBUG("Freeing route table", DP_LOG_VNI(vni_value->vni));
DPS_LOG_DEBUG("Freeing VNI", DP_LOG_VNI(vni_value->vni));
if (vni_value->ipv4[vni_value->socketid])
rte_rib_free(vni_value->ipv4[vni_value->socketid]);

Expand Down Expand Up @@ -103,7 +102,6 @@ int dp_create_vni_route_table(int vni, int type, int socketid)
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = type,
.vni = vni
};
int ret;
Expand Down Expand Up @@ -158,7 +156,6 @@ int dp_delete_vni_route_table(int vni, int type)
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = type,
.vni = vni
};
int ret;
Expand All @@ -172,7 +169,7 @@ int dp_delete_vni_route_table(int vni, int type)
if (dp_ref_dec_and_chk_freed(&temp_val->ref_count)) {
ret = rte_hash_del_key(vni_handle_tbl, &vni_key);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot delete VNU key", DP_LOG_RET(ret));
DPS_LOG_ERR("Cannot delete VNI key", DP_LOG_RET(ret));
return DP_ERROR;
}
}
Expand All @@ -184,7 +181,6 @@ int dp_reset_vni_route_table(int vni, int type, int socketid)
{
struct dp_vni_value *temp_val = NULL;
struct dp_vni_key vni_key = {
.type = type,
.vni = vni
};
int ret;
Expand Down
27 changes: 27 additions & 0 deletions test/test_vni.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,30 @@ def test_vni_reset(prepare_ipv4, grpc_client):
"Resetting a vni tainted another vni"

grpc_client.delinterface(VM4.name)


def test_vni_neighnats(prepare_ipv4, grpc_client):
lb_ul_ipv6 = grpc_client.createlb(lb_name, vni1, lb_ip, "tcp/80")
nat1_ipv6 = grpc_client.addnat(VM1.name, nat_vip, 1000, 200)
nat2_ipv6 = grpc_client.addnat(VM2.name, nat_vip, 2000, 3000)

grpc_client.addneighnat(nat_vip, vni1, 3000, 4000, neigh_vni1_ul_ipv6)
grpc_client.addneighnat(nat_vip, vni1, 4000, 5000, neigh_vni1_ul_ipv6)
neighnats = grpc_client.listneighnats(nat_vip)
assert len(neighnats) == 2, \
"List of neighbor NATs is not complete"

grpc_client.delnat(VM2.name)
grpc_client.delnat(VM1.name)
grpc_client.delinterface(VM2.name)
grpc_client.delinterface(VM1.name)
neighnats = grpc_client.listneighnats(nat_vip)
assert len(neighnats) == 2, \
"Neighbor NATs removed prematurely"

# Need to add the VMs back before removing the LB otherwise the VNI will get cleaned up
VM1.ul_ipv6 = grpc_client.addinterface(VM1.name, VM1.pci, VM1.vni, VM1.ip, VM1.ipv6)
VM2.ul_ipv6 = grpc_client.addinterface(VM2.name, VM2.pci, VM2.vni, VM2.ip, VM2.ipv6)

grpc_client.dellb(lb_name)

0 comments on commit 77c112f

Please sign in to comment.