pn_dev.c (42249094f79422fbf5ed4b54eeb48ff096809b8f) pn_dev.c (79952bca8619b62c9b1a118238ca16ab41be7760)
1/*
2 * File: pn_dev.c
3 *
4 * Phonet network device
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * Authors: Sakari Ailus <sakari.ailus@nokia.com>

--- 22 unchanged lines hidden (view full) ---

31#include <linux/proc_fs.h>
32#include <linux/if_arp.h>
33#include <net/sock.h>
34#include <net/netns/generic.h>
35#include <net/phonet/pn_dev.h>
36
37struct phonet_routes {
38 struct mutex lock;
1/*
2 * File: pn_dev.c
3 *
4 * Phonet network device
5 *
6 * Copyright (C) 2008 Nokia Corporation.
7 *
8 * Authors: Sakari Ailus <sakari.ailus@nokia.com>

--- 22 unchanged lines hidden (view full) ---

31#include <linux/proc_fs.h>
32#include <linux/if_arp.h>
33#include <net/sock.h>
34#include <net/netns/generic.h>
35#include <net/phonet/pn_dev.h>
36
37struct phonet_routes {
38 struct mutex lock;
39 struct net_device *table[64];
39 struct net_device __rcu *table[64];
40};
41
42struct phonet_net {
43 struct phonet_device_list pndevs;
44 struct phonet_routes routes;
45};
46
47static int phonet_net_id __read_mostly;

--- 222 unchanged lines hidden (view full) ---

270 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
271 unsigned int i;
272 DECLARE_BITMAP(deleted, 64);
273
274 /* Remove left-over Phonet routes */
275 bitmap_zero(deleted, 64);
276 mutex_lock(&pnn->routes.lock);
277 for (i = 0; i < 64; i++)
40};
41
42struct phonet_net {
43 struct phonet_device_list pndevs;
44 struct phonet_routes routes;
45};
46
47static int phonet_net_id __read_mostly;

--- 222 unchanged lines hidden (view full) ---

270 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
271 unsigned int i;
272 DECLARE_BITMAP(deleted, 64);
273
274 /* Remove left-over Phonet routes */
275 bitmap_zero(deleted, 64);
276 mutex_lock(&pnn->routes.lock);
277 for (i = 0; i < 64; i++)
278 if (dev == pnn->routes.table[i]) {
278 if (rcu_access_pointer(pnn->routes.table[i]) == dev) {
279 RCU_INIT_POINTER(pnn->routes.table[i], NULL);
280 set_bit(i, deleted);
281 }
282 mutex_unlock(&pnn->routes.lock);
283
284 if (bitmap_empty(deleted, 64))
285 return; /* short-circuit RCU */
286 synchronize_rcu();

--- 96 unchanged lines hidden (view full) ---

383
384int phonet_route_del(struct net_device *dev, u8 daddr)
385{
386 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
387 struct phonet_routes *routes = &pnn->routes;
388
389 daddr = daddr >> 2;
390 mutex_lock(&routes->lock);
279 RCU_INIT_POINTER(pnn->routes.table[i], NULL);
280 set_bit(i, deleted);
281 }
282 mutex_unlock(&pnn->routes.lock);
283
284 if (bitmap_empty(deleted, 64))
285 return; /* short-circuit RCU */
286 synchronize_rcu();

--- 96 unchanged lines hidden (view full) ---

383
384int phonet_route_del(struct net_device *dev, u8 daddr)
385{
386 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
387 struct phonet_routes *routes = &pnn->routes;
388
389 daddr = daddr >> 2;
390 mutex_lock(&routes->lock);
391 if (dev == routes->table[daddr])
391 if (rcu_access_pointer(routes->table[daddr]) == dev)
392 RCU_INIT_POINTER(routes->table[daddr], NULL);
393 else
394 dev = NULL;
395 mutex_unlock(&routes->lock);
396
397 if (!dev)
398 return -ENOENT;
399 synchronize_rcu();

--- 32 unchanged lines hidden ---
392 RCU_INIT_POINTER(routes->table[daddr], NULL);
393 else
394 dev = NULL;
395 mutex_unlock(&routes->lock);
396
397 if (!dev)
398 return -ENOENT;
399 synchronize_rcu();

--- 32 unchanged lines hidden ---