* [PATCH 1/3] netprio_cgroup: fix an off-by-one bug
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
@ 2012-02-10 15:43 ` Neil Horman
2012-02-10 15:43 ` [PATCH 2/3] netprio_cgroup: don't allocate prio table when a device is registered Neil Horman
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2012-02-10 15:43 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Li Zefan, David S. Miller
# mount -t cgroup xxx /mnt
# mkdir /mnt/tmp
# cat /mnt/tmp/net_prio.ifpriomap
lo 0
eth0 0
virbr0 0
# echo 'lo 999' > /mnt/tmp/net_prio.ifpriomap
# cat /mnt/tmp/net_prio.ifpriomap
lo 999
eth0 0
virbr0 4101267344
We got weired output, because we exceeded the boundary of the array.
We may even crash the kernel..
Origionally-authored-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
---
net/core/netprio_cgroup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 9ae183a..72c6387 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -108,7 +108,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
static void update_netdev_tables(void)
{
struct net_device *dev;
- u32 max_len = atomic_read(&max_prioidx);
+ u32 max_len = atomic_read(&max_prioidx) + 1;
struct netprio_map *map;
rtnl_lock();
--
1.7.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] netprio_cgroup: don't allocate prio table when a device is registered
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
2012-02-10 15:43 ` [PATCH 1/3] netprio_cgroup: fix an off-by-one bug Neil Horman
@ 2012-02-10 15:43 ` Neil Horman
2012-02-10 15:43 ` [PATCH 3/3] netprio_cgroup: fix wrong memory access when NETPRIO_CGROUP=m Neil Horman
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2012-02-10 15:43 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Li Zefan, David S. Miller
So we delay the allocation till the priority is set through cgroup,
and this makes skb_update_priority() faster when it's not set.
This also eliminates an off-by-one bug similar with the one fixed
in the previous patch.
Origionally-authored-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
---
net/core/netprio_cgroup.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 72c6387..4dacc44 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -271,7 +271,6 @@ static int netprio_device_event(struct notifier_block *unused,
{
struct net_device *dev = ptr;
struct netprio_map *old;
- u32 max_len = atomic_read(&max_prioidx);
/*
* Note this is called with rtnl_lock held so we have update side
@@ -279,11 +278,6 @@ static int netprio_device_event(struct notifier_block *unused,
*/
switch (event) {
-
- case NETDEV_REGISTER:
- if (max_len)
- extend_netdev_table(dev, max_len);
- break;
case NETDEV_UNREGISTER:
old = rtnl_dereference(dev->priomap);
RCU_INIT_POINTER(dev->priomap, NULL);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] netprio_cgroup: fix wrong memory access when NETPRIO_CGROUP=m
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
2012-02-10 15:43 ` [PATCH 1/3] netprio_cgroup: fix an off-by-one bug Neil Horman
2012-02-10 15:43 ` [PATCH 2/3] netprio_cgroup: don't allocate prio table when a device is registered Neil Horman
@ 2012-02-10 15:43 ` Neil Horman
2012-02-10 20:09 ` [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes David Miller
2012-02-15 2:22 ` Li Zefan
4 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2012-02-10 15:43 UTC (permalink / raw)
To: netdev; +Cc: Neil Horman, Li Zefan, David S. Miller
When the netprio_cgroup module is not loaded, net_prio_subsys_id
is -1, and so sock_update_prioidx() accesses cgroup_subsys array
with negative index subsys[-1].
Make the code resembles cls_cgroup code, which is bug free.
Origionally-authored-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
---
include/net/netprio_cgroup.h | 48 +++++++++++++++++++++++++++++++++++-------
net/core/sock.c | 7 +----
2 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h
index 7b2d431..d58fdec 100644
--- a/include/net/netprio_cgroup.h
+++ b/include/net/netprio_cgroup.h
@@ -37,19 +37,51 @@ extern int net_prio_subsys_id;
extern void sock_update_netprioidx(struct sock *sk);
-static inline struct cgroup_netprio_state
- *task_netprio_state(struct task_struct *p)
+#if IS_BUILTIN(CONFIG_NETPRIO_CGROUP)
+
+static inline u32 task_netprioidx(struct task_struct *p)
{
-#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
- return container_of(task_subsys_state(p, net_prio_subsys_id),
- struct cgroup_netprio_state, css);
-#else
- return NULL;
-#endif
+ struct cgroup_netprio_state *state;
+ u32 idx;
+
+ rcu_read_lock();
+ state = container_of(task_subsys_state(p, net_prio_subsys_id),
+ struct cgroup_netprio_state, css);
+ idx = state->prioidx;
+ rcu_read_unlock();
+ return idx;
+}
+
+#elif IS_MODULE(CONFIG_NETPRIO_CGROUP)
+
+static inline u32 task_netprioidx(struct task_struct *p)
+{
+ struct cgroup_netprio_state *state;
+ int subsys_id;
+ u32 idx = 0;
+
+ rcu_read_lock();
+ subsys_id = rcu_dereference_index_check(net_prio_subsys_id,
+ rcu_read_lock_held());
+ if (subsys_id >= 0) {
+ state = container_of(task_subsys_state(p, subsys_id),
+ struct cgroup_netprio_state, css);
+ idx = state->prioidx;
+ }
+ rcu_read_unlock();
+ return idx;
}
#else
+static inline u32 task_netprioidx(struct task_struct *p)
+{
+ return 0;
+}
+
+#endif /* CONFIG_NETPRIO_CGROUP */
+
+#else
#define sock_update_netprioidx(sk)
#endif
diff --git a/net/core/sock.c b/net/core/sock.c
index 3e81fd2..02f8dfe 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1171,13 +1171,10 @@ EXPORT_SYMBOL(sock_update_classid);
void sock_update_netprioidx(struct sock *sk)
{
- struct cgroup_netprio_state *state;
if (in_interrupt())
return;
- rcu_read_lock();
- state = task_netprio_state(current);
- sk->sk_cgrp_prioidx = state ? state->prioidx : 0;
- rcu_read_unlock();
+
+ sk->sk_cgrp_prioidx = task_netprioidx(current);
}
EXPORT_SYMBOL_GPL(sock_update_netprioidx);
#endif
--
1.7.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
` (2 preceding siblings ...)
2012-02-10 15:43 ` [PATCH 3/3] netprio_cgroup: fix wrong memory access when NETPRIO_CGROUP=m Neil Horman
@ 2012-02-10 20:09 ` David Miller
2012-02-10 20:28 ` Neil Horman
2012-02-15 2:22 ` Li Zefan
4 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2012-02-10 20:09 UTC (permalink / raw)
To: nhorman; +Cc: netdev, lizf
From: Neil Horman <nhorman@tuxdriver.com>
Date: Fri, 10 Feb 2012 10:43:35 -0500
> About 2 weeks ago, Li Zefan posted a series of cleanups and fixes for cls_cgroup
> and netprio_cgroup. It was requested that the cleanups and fixes be separated
> into two different series and reposted. Its been about 2 weeks, and after
> pinging the author a few times and getting no response, I've decided to repost
> the fixes for netprio myself, as they're important and I don't want them to be
> forgotten or otherwise fall through the cracks.
>
> Origionally-authored-by: Li Zefan <lizf@cn.fujitsu.com>
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com
> CC: Li Zefan <lizf@cn.fujitsu.com>
> CC: "David S. Miller" <davem@davemloft.net>
All applied, thanks Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes
2012-02-10 20:09 ` [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes David Miller
@ 2012-02-10 20:28 ` Neil Horman
0 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2012-02-10 20:28 UTC (permalink / raw)
To: David Miller; +Cc: netdev, lizf
On Fri, Feb 10, 2012 at 03:09:07PM -0500, David Miller wrote:
> From: Neil Horman <nhorman@tuxdriver.com>
> Date: Fri, 10 Feb 2012 10:43:35 -0500
>
> > About 2 weeks ago, Li Zefan posted a series of cleanups and fixes for cls_cgroup
> > and netprio_cgroup. It was requested that the cleanups and fixes be separated
> > into two different series and reposted. Its been about 2 weeks, and after
> > pinging the author a few times and getting no response, I've decided to repost
> > the fixes for netprio myself, as they're important and I don't want them to be
> > forgotten or otherwise fall through the cracks.
> >
> > Origionally-authored-by: Li Zefan <lizf@cn.fujitsu.com>
> > Signed-off-by: Neil Horman <nhorman@tuxdriver.com
> > CC: Li Zefan <lizf@cn.fujitsu.com>
> > CC: "David S. Miller" <davem@davemloft.net>
>
> All applied, thanks Neil.
Thanks!
Neil
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
` (3 preceding siblings ...)
2012-02-10 20:09 ` [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes David Miller
@ 2012-02-15 2:22 ` Li Zefan
2012-02-15 11:49 ` Neil Horman
4 siblings, 1 reply; 7+ messages in thread
From: Li Zefan @ 2012-02-15 2:22 UTC (permalink / raw)
To: Neil Horman; +Cc: netdev, David S. Miller
Neil Horman wrote:
> About 2 weeks ago, Li Zefan posted a series of cleanups and fixes for cls_cgroup
> and netprio_cgroup. It was requested that the cleanups and fixes be separated
> into two different series and reposted. Its been about 2 weeks, and after
> pinging the author a few times and getting no response, I've decided to repost
> the fixes for netprio myself, as they're important and I don't want them to be
> forgotten or otherwise fall through the cracks.
>
Thanks for the reposting.
I was off office for a few days for some reason, and just came back to work.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes
2012-02-15 2:22 ` Li Zefan
@ 2012-02-15 11:49 ` Neil Horman
0 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2012-02-15 11:49 UTC (permalink / raw)
To: Li Zefan; +Cc: netdev, David S. Miller
On Wed, Feb 15, 2012 at 10:22:28AM +0800, Li Zefan wrote:
> Neil Horman wrote:
> > About 2 weeks ago, Li Zefan posted a series of cleanups and fixes for cls_cgroup
> > and netprio_cgroup. It was requested that the cleanups and fixes be separated
> > into two different series and reposted. Its been about 2 weeks, and after
> > pinging the author a few times and getting no response, I've decided to repost
> > the fixes for netprio myself, as they're important and I don't want them to be
> > forgotten or otherwise fall through the cracks.
> >
>
> Thanks for the reposting.
>
> I was off office for a few days for some reason, and just came back to work.
>
No worries, thank you for checking back.
Neil
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-02-15 11:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com>
2012-02-10 15:43 ` [PATCH 1/3] netprio_cgroup: fix an off-by-one bug Neil Horman
2012-02-10 15:43 ` [PATCH 2/3] netprio_cgroup: don't allocate prio table when a device is registered Neil Horman
2012-02-10 15:43 ` [PATCH 3/3] netprio_cgroup: fix wrong memory access when NETPRIO_CGROUP=m Neil Horman
2012-02-10 20:09 ` [PATCH 0/3] netprio_cgroup: some miscelaneous off by one fixes David Miller
2012-02-10 20:28 ` Neil Horman
2012-02-15 2:22 ` Li Zefan
2012-02-15 11:49 ` Neil Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).