Skip to content

Commit

Permalink
Free the defer data in case of errors
Browse files Browse the repository at this point in the history
To make sure that we flush all the packets that are queued in a flow
entry, we run a defer function. If for any reason this defer was not
scheduled (because the function was called with no hold queue), the
defer data has to be freed.

Change-Id: Ideabe252ff6c56c6e01ccbc3a27044bac09933f3
Closes-BUG: #1436798
  • Loading branch information
anandhk-juniper committed Jul 29, 2015
1 parent ea1acbc commit 086fa60
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions dp-core/vr_flow.c
Expand Up @@ -109,7 +109,7 @@ vr_valid_link_local_port(struct vrouter *router, int family,
if (proto == VR_IP_PROTO_UDP)
tmp += (router->vr_link_local_ports_size * 8 / 2);

data = router->vr_link_local_ports[(tmp /8)];
data = router->vr_link_local_ports[(tmp / 8)];
if (data & (1 << (tmp % 8)))
return true;

Expand All @@ -120,7 +120,6 @@ static void
vr_clear_link_local_port(struct vrouter *router, int family,
int proto, int port)
{

unsigned char *data;
unsigned int tmp;

Expand All @@ -138,15 +137,16 @@ vr_clear_link_local_port(struct vrouter *router, int family,
if (proto == VR_IP_PROTO_UDP)
tmp += (router->vr_link_local_ports_size * 8 / 2);

data = &router->vr_link_local_ports[(tmp /8)];
data = &router->vr_link_local_ports[(tmp / 8)];
*data &= (~(1 << (tmp % 8)));

return;
}

static void
vr_set_link_local_port(struct vrouter *router, int family,
int proto, int port)
{

unsigned char *data;
unsigned int tmp;

Expand All @@ -164,8 +164,10 @@ vr_set_link_local_port(struct vrouter *router, int family,
if (proto == VR_IP_PROTO_UDP)
tmp += (router->vr_link_local_ports_size * 8 / 2);

data = &router->vr_link_local_ports[tmp /8];
data = &router->vr_link_local_ports[tmp / 8];
*data |= (1 << (tmp % 8));

return;
}

static void
Expand Down Expand Up @@ -203,7 +205,11 @@ vr_reset_flow_entry(struct vrouter *router, struct vr_flow_entry *fe,
unsigned int index)
{
memset(&fe->fe_stats, 0, sizeof(fe->fe_stats));
memset(&fe->fe_hold_list, 0, sizeof(fe->fe_hold_list));;
if (fe->fe_hold_list) {
vr_printf("vrouter: Potential memory leak @ %s:%d\n",
__FILE__, __LINE__);
}
fe->fe_hold_list = NULL;
fe->fe_key.flow_key_len = 0;
fe->fe_type = VP_TYPE_NULL;
memset(&fe->fe_key, 0, sizeof(fe->fe_key));
Expand Down Expand Up @@ -328,6 +334,7 @@ vr_flow_queue_free_defer(struct vr_flow_md *flmd, struct vr_flow_queue *vfq)

vdd->vdd_data = (void *)vfq;
vr_defer(flmd->flmd_router, vr_flow_queue_free, (void *)vdd);
flmd->flmd_defer_data = NULL;

return;
}
Expand Down Expand Up @@ -1127,6 +1134,11 @@ vr_flow_flush(void *arg)
}

exit_flush:
if (flmd->flmd_defer_data) {
vr_put_defer_data(flmd->flmd_defer_data);
flmd->flmd_defer_data = NULL;
}

vr_free(flmd, VR_FLOW_METADATA_OBJECT);

return;
Expand Down Expand Up @@ -1757,6 +1769,8 @@ vr_link_local_ports_reset(struct vrouter *router)
memset(router->vr_link_local_ports,
0, router->vr_link_local_ports_size);
}

return;
}

static void
Expand All @@ -1767,6 +1781,8 @@ vr_link_local_ports_exit(struct vrouter *router)
router->vr_link_local_ports = NULL;
router->vr_link_local_ports_size = 0;
}

return;
}

static int
Expand Down

0 comments on commit 086fa60

Please sign in to comment.