aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Mashak <mrv@mojatatu.com>2017-02-24 11:00:32 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-26 21:28:41 -0500
commitedb9d1bff4bbe19b8ae0e71b1f38732591a9eeb2 (patch)
tree89cf1aa87136da826df09247688ad8294bc9c741
parent9d25af69b3cfa2f88559efa0c1a4b4f18724694b (diff)
net sched actions: decrement module reference count after table flush.
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: f97017cdefef ("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>
-rw-r--r--net/sched/act_api.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index f219ff325ed4..dfe64f81cb16 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -859,10 +859,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
859 goto out_module_put; 859 goto out_module_put;
860 860
861 err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops); 861 err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops);
862 if (err < 0) 862 if (err <= 0)
863 goto out_module_put; 863 goto out_module_put;
864 if (err == 0)
865 goto noflush_out;
866 864
867 nla_nest_end(skb, nest); 865 nla_nest_end(skb, nest);
868 866
@@ -879,7 +877,6 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
879out_module_put: 877out_module_put:
880 module_put(ops->owner); 878 module_put(ops->owner);
881err_out: 879err_out:
882noflush_out:
883 kfree_skb(skb); 880 kfree_skb(skb);
884 return err; 881 return err;
885} 882}