]> git.baikalelectronics.ru Git - kernel.git/commit
net: sched: flower: fix filter net reference counting
authorVlad Buslov <vladbu@mellanox.com>
Thu, 11 Apr 2019 21:54:19 +0000 (00:54 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 12 Apr 2019 04:32:27 +0000 (21:32 -0700)
commita83ec19d678444c0607880a6e950e1724c718e1d
tree9851f4924bfb3fc2043ada13e53bfda07747ea64
parent14ead275566529a8e03b44e673b71087ba9aafd9
net: sched: flower: fix filter net reference counting

Fix net reference counting in fl_change() and remove redundant call to
tcf_exts_get_net() from __fl_delete(). __fl_put() already tries to get net
before releasing exts and deallocating a filter, so this code caused flower
classifier to obtain net twice per filter that is being deleted.

Implementation of __fl_delete() called tcf_exts_get_net() to pass its
result as 'async' flag to fl_mask_put(). However, 'async' flag is redundant
and only complicates fl_mask_put() implementation. This functionality seems
to be copied from filter cleanup code, where it was added by Cong with
following explanation:

    This patchset tries to fix the race between call_rcu() and
    cleanup_net() again. Without holding the netns refcnt the
    tc_action_net_exit() in netns workqueue could be called before
    filter destroy works in tc filter workqueue. This patchset
    moves the netns refcnt from tc actions to tcf_exts, without
    breaking per-netns tc actions.

This doesn't apply to flower mask, which doesn't call any tc action code
during cleanup. Simplify fl_mask_put() by removing the flag parameter and
always use tcf_queue_work() to free mask objects.

Fixes: 1883d6475ca9 ("net: sched: flower: introduce reference counting for filters")
Fixes: e975bb08390b ("net: sched: flower: insert filter to ht before offloading it to hw")
Fixes: 07fcd89c44b1 ("cls_flower: Support multiple masks per priority")
Reported-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c