Skip to content

Commit

Permalink
net sched actions: decrement module reference count after table flush.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jamal Hadi Salim <[email protected]>
Acked-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Roman Mashak authored and davem330 committed Feb 27, 2017
1 parent 9d25af6 commit edb9d1b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
goto out_module_put;

err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops);
if (err < 0)
if (err <= 0)
goto out_module_put;
if (err == 0)
goto noflush_out;

nla_nest_end(skb, nest);

Expand All @@ -879,7 +877,6 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
out_module_put:
module_put(ops->owner);
err_out:
noflush_out:
kfree_skb(skb);
return err;
}
Expand Down

0 comments on commit edb9d1b

Please sign in to comment.