diff options
Diffstat (limited to 'net/core/netprio_cgroup.c')
-rw-r--r-- | net/core/netprio_cgroup.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c index 3a9fd4826b75..4dacc44637ef 100644 --- a/net/core/netprio_cgroup.c +++ b/net/core/netprio_cgroup.c | |||
@@ -58,11 +58,12 @@ static int get_prioidx(u32 *prio) | |||
58 | 58 | ||
59 | spin_lock_irqsave(&prioidx_map_lock, flags); | 59 | spin_lock_irqsave(&prioidx_map_lock, flags); |
60 | prioidx = find_first_zero_bit(prioidx_map, sizeof(unsigned long) * PRIOIDX_SZ); | 60 | prioidx = find_first_zero_bit(prioidx_map, sizeof(unsigned long) * PRIOIDX_SZ); |
61 | if (prioidx == sizeof(unsigned long) * PRIOIDX_SZ) { | ||
62 | spin_unlock_irqrestore(&prioidx_map_lock, flags); | ||
63 | return -ENOSPC; | ||
64 | } | ||
61 | set_bit(prioidx, prioidx_map); | 65 | set_bit(prioidx, prioidx_map); |
62 | spin_unlock_irqrestore(&prioidx_map_lock, flags); | 66 | spin_unlock_irqrestore(&prioidx_map_lock, flags); |
63 | if (prioidx == sizeof(unsigned long) * PRIOIDX_SZ) | ||
64 | return -ENOSPC; | ||
65 | |||
66 | atomic_set(&max_prioidx, prioidx); | 67 | atomic_set(&max_prioidx, prioidx); |
67 | *prio = prioidx; | 68 | *prio = prioidx; |
68 | return 0; | 69 | return 0; |
@@ -107,7 +108,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len) | |||
107 | static void update_netdev_tables(void) | 108 | static void update_netdev_tables(void) |
108 | { | 109 | { |
109 | struct net_device *dev; | 110 | struct net_device *dev; |
110 | u32 max_len = atomic_read(&max_prioidx); | 111 | u32 max_len = atomic_read(&max_prioidx) + 1; |
111 | struct netprio_map *map; | 112 | struct netprio_map *map; |
112 | 113 | ||
113 | rtnl_lock(); | 114 | rtnl_lock(); |
@@ -270,7 +271,6 @@ static int netprio_device_event(struct notifier_block *unused, | |||
270 | { | 271 | { |
271 | struct net_device *dev = ptr; | 272 | struct net_device *dev = ptr; |
272 | struct netprio_map *old; | 273 | struct netprio_map *old; |
273 | u32 max_len = atomic_read(&max_prioidx); | ||
274 | 274 | ||
275 | /* | 275 | /* |
276 | * Note this is called with rtnl_lock held so we have update side | 276 | * Note this is called with rtnl_lock held so we have update side |
@@ -278,11 +278,6 @@ static int netprio_device_event(struct notifier_block *unused, | |||
278 | */ | 278 | */ |
279 | 279 | ||
280 | switch (event) { | 280 | switch (event) { |
281 | |||
282 | case NETDEV_REGISTER: | ||
283 | if (max_len) | ||
284 | extend_netdev_table(dev, max_len); | ||
285 | break; | ||
286 | case NETDEV_UNREGISTER: | 281 | case NETDEV_UNREGISTER: |
287 | old = rtnl_dereference(dev->priomap); | 282 | old = rtnl_dereference(dev->priomap); |
288 | RCU_INIT_POINTER(dev->priomap, NULL); | 283 | RCU_INIT_POINTER(dev->priomap, NULL); |