Skip to content

Commit

Permalink
net/cxgbe: fix L2T leak in filter error and free path
Browse files Browse the repository at this point in the history
[ upstream commit e0e1496 ]

Free up Layer 2 Table (L2T) entry properly during filter create
failure and filter delete.

Fixes: 1decc62 ("net/cxgbe: add flow operations to offload VLAN actions")

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
  • Loading branch information
chelsiocudbg authored and kevintraynor committed Sep 4, 2020
1 parent 7dbae10 commit 0264763
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions drivers/net/cxgbe/cxgbe_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ static void clear_filter(struct filter_entry *f)
if (f->clipt)
cxgbe_clip_release(f->dev, f->clipt);

if (f->l2t)
cxgbe_l2t_release(f->l2t);

if (f->fs.mask.macidx)
cxgbe_mpstcam_remove(pi, f->fs.val.macidx);

Expand Down Expand Up @@ -730,19 +733,6 @@ static int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
unsigned int port_id = ethdev2pinfo(dev)->port_id;
int ret;

/*
* If the new filter requires loopback Destination MAC and/or VLAN
* rewriting then we need to allocate a Layer 2 Table (L2T) entry for
* the filter.
*/
if (f->fs.newvlan) {
/* allocate L2T entry for new filter */
f->l2t = cxgbe_l2t_alloc_switching(f->dev, f->fs.vlan,
f->fs.eport, f->fs.dmac);
if (!f->l2t)
return -ENOMEM;
}

ctrlq = &adapter->sge.ctrlq[port_id];
mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool);
if (!mbuf) {
Expand Down Expand Up @@ -1047,6 +1037,19 @@ int cxgbe_set_filter(struct rte_eth_dev *dev, unsigned int filter_id,
}
}

/* If the new filter requires loopback Destination MAC and/or VLAN
* rewriting then we need to allocate a Layer 2 Table (L2T) entry for
* the filter.
*/
if (f->fs.newvlan) {
f->l2t = cxgbe_l2t_alloc_switching(f->dev, f->fs.vlan,
f->fs.eport, f->fs.dmac);
if (!f->l2t) {
ret = -ENOMEM;
goto free_tid;
}
}

/*
* Attempt to set the filter. If we don't succeed, we clear
* it and return the failure.
Expand Down

0 comments on commit 0264763

Please sign in to comment.