All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/1] net sched actions: decrement module reference count after table flush.
@ 2017-02-24 16:00 Roman Mashak
  2017-02-24 17:58 ` Cong Wang
  2017-02-27  2:29 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Roman Mashak @ 2017-02-24 16:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, Roman Mashak, Jamal Hadi Salim

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
%

Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 net/sched/act_api.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index f219ff3..dfe64f8 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,
 		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);
 
@@ -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;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/1] net sched actions: decrement module reference count after table flush.
  2017-02-24 16:00 [PATCH net 1/1] net sched actions: decrement module reference count after table flush Roman Mashak
@ 2017-02-24 17:58 ` Cong Wang
  2017-02-24 22:10   ` Roman Mashak
  2017-02-27  2:29 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2017-02-24 17:58 UTC (permalink / raw)
  To: Roman Mashak
  Cc: David Miller, Linux Kernel Network Developers, Jamal Hadi Salim

On Fri, Feb 24, 2017 at 8:00 AM, Roman Mashak <mrv@mojatatu.com> wrote:
> 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
> %
>
> Signed-off-by: Roman Mashak <mrv@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

Fixes commit f97017cdefefdb6a0e19266024b0c6f9fd411eeb ?

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/1] net sched actions: decrement module reference count after table flush.
  2017-02-24 17:58 ` Cong Wang
@ 2017-02-24 22:10   ` Roman Mashak
  0 siblings, 0 replies; 4+ messages in thread
From: Roman Mashak @ 2017-02-24 22:10 UTC (permalink / raw)
  To: Cong Wang; +Cc: David Miller, Linux Kernel Network Developers, Jamal Hadi Salim

Cong Wang <xiyou.wangcong@gmail.com> writes:

> On Fri, Feb 24, 2017 at 8:00 AM, Roman Mashak <mrv@mojatatu.com> wrote:
>> 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.

[...]

> Fixes commit f97017cdefefdb6a0e19266024b0c6f9fd411eeb ?

Yes, exactly.

> Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

-- 
Roman Mashak

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net 1/1] net sched actions: decrement module reference count after table flush.
  2017-02-24 16:00 [PATCH net 1/1] net sched actions: decrement module reference count after table flush Roman Mashak
  2017-02-24 17:58 ` Cong Wang
@ 2017-02-27  2:29 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-02-27  2:29 UTC (permalink / raw)
  To: mrv; +Cc: netdev, jhs

From: Roman Mashak <mrv@mojatatu.com>
Date: Fri, 24 Feb 2017 11:00:32 -0500

> 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.
...
> Signed-off-by: Roman Mashak <mrv@mojatatu.com>
> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-27  2:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 16:00 [PATCH net 1/1] net sched actions: decrement module reference count after table flush Roman Mashak
2017-02-24 17:58 ` Cong Wang
2017-02-24 22:10   ` Roman Mashak
2017-02-27  2:29 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.