Skip to content

Commit e8d3d78

Browse files
vbnogueiradavem330
authored andcommitted
net: sched: cls_u32: Undo refcount decrement in case update failed
In the case of an update, when TCA_U32_LINK is set, u32_set_parms will decrement the refcount of the ht_down (struct tc_u_hnode) pointer present in the older u32 filter which we are replacing. However, if u32_replace_hw_knode errors out, the update command fails and that ht_down pointer continues decremented. To fix that, when u32_replace_hw_knode fails, check if ht_down's refcount was decremented and undo the decrement. Fixes: d34e3e1 ("net: cls_u32: Add support for skip-sw flag to tc u32 classifier.") Signed-off-by: Victor Nogueira <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Reviewed-by: Pedro Tammela <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9cb36fa commit e8d3d78

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

net/sched/cls_u32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,13 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
928928
if (err) {
929929
u32_unbind_filter(tp, new, tb);
930930

931+
if (tb[TCA_U32_LINK]) {
932+
struct tc_u_hnode *ht_old;
933+
934+
ht_old = rtnl_dereference(n->ht_down);
935+
if (ht_old)
936+
ht_old->refcnt++;
937+
}
931938
__u32_destroy_key(new);
932939
return err;
933940
}

0 commit comments

Comments
 (0)