Skip to content

Commit

Permalink
Flush VM's flow table entries after removing an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Sep 4, 2023
1 parent 6ae33f4 commit d273e1b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/dp_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void dp_free_flow(struct dp_ref *ref);
void dp_free_network_nat_port(struct flow_value *cntrack);
void dp_remove_nat_flows(uint16_t port_id, int nat_type); // TODO create proper enum!
void dp_remove_neighnat_flows(uint32_t ipv4, uint32_t vni, uint16_t min_port, uint16_t max_port);
void dp_remove_vm_flows(uint16_t port_id);

hash_sig_t dp_get_conntrack_flow_hash_value(struct flow_key *key);

Expand Down
21 changes: 21 additions & 0 deletions src/dp_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,27 @@ void dp_remove_neighnat_flows(uint32_t ipv4, uint32_t vni, uint16_t min_port, ui
}
}

void dp_remove_vm_flows(uint16_t port_id)
{
struct flow_value *flow_val = NULL;
const void *next_key;
uint32_t iter = 0;
int ret;

while ((ret = rte_hash_iterate(ipv4_flow_tbl, &next_key, (void **)&flow_val, &iter)) != -ENOENT) {
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Iterating flow table failed while removing VM flows", DP_LOG_RET(ret));
return;
}
if (flow_val->created_port_id == port_id) {
if (offload_mode_enabled)
dp_rte_flow_remove(flow_val);
dp_age_out_flow(flow_val);
}
}
}


hash_sig_t dp_get_conntrack_flow_hash_value(struct flow_key *key)
{
//It is not necessary to first test if this key exists, since for now, this function
Expand Down
1 change: 1 addition & 0 deletions src/grpc/dp_grpc_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ static int dp_process_delete_interface(struct dp_grpc_responder *responder)
#ifdef ENABLE_VIRTSVC
dp_virtsvc_del_vm(port_id);
#endif
dp_remove_vm_flows(port_id);
return ret;
}

Expand Down

0 comments on commit d273e1b

Please sign in to comment.