Skip to content

Commit c10ffe9

Browse files
Roman Mashakgregkh
authored andcommitted
net sched actions: decrement module reference count after table flush.
[ Upstream commit edb9d1bff4bbe19b8ae0e71b1f38732591a9eeb2 ] When tc actions are loaded as a module and no actions have been installed, flushing them would result in actions removed from the memory, but modules reference count not being decremented, so that the modules would not be unloaded. Following is example with GACT action: % sudo modprobe act_gact % lsmod Module Size Used by act_gact 16384 0 % % sudo tc actions ls action gact % % sudo tc actions flush action gact % lsmod Module Size Used by act_gact 16384 1 % sudo tc actions flush action gact % lsmod Module Size Used by act_gact 16384 2 % sudo rmmod act_gact rmmod: ERROR: Module act_gact is in use .... After the fix: % lsmod Module Size Used by act_gact 16384 0 % % sudo tc actions add action pass index 1 % sudo tc actions add action pass index 2 % sudo tc actions add action pass index 3 % lsmod Module Size Used by act_gact 16384 3 % % sudo tc actions flush action gact % lsmod Module Size Used by act_gact 16384 0 % % sudo tc actions flush action gact % lsmod Module Size Used by act_gact 16384 0 % sudo rmmod act_gact % lsmod Module Size Used by % Fixes: f97017c ("net-sched: Fix actions flushing") Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 676fe97 commit c10ffe9

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

net/sched/act_api.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,10 +820,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
820820
goto out_module_put;
821821

822822
err = a.ops->walk(skb, &dcb, RTM_DELACTION, &a);
823-
if (err < 0)
823+
if (err <= 0)
824824
goto out_module_put;
825-
if (err == 0)
826-
goto noflush_out;
827825

828826
nla_nest_end(skb, nest);
829827

@@ -840,7 +838,6 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
840838
out_module_put:
841839
module_put(a.ops->owner);
842840
err_out:
843-
noflush_out:
844841
kfree_skb(skb);
845842
return err;
846843
}

0 commit comments

Comments
 (0)