diff options
Diffstat (limited to 'net/phonet/pn_dev.c')
-rw-r--r-- | net/phonet/pn_dev.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index 9b4ced6e0968..c33da6576942 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c | |||
@@ -46,9 +46,16 @@ struct phonet_net { | |||
46 | 46 | ||
47 | int phonet_net_id __read_mostly; | 47 | int phonet_net_id __read_mostly; |
48 | 48 | ||
49 | static struct phonet_net *phonet_pernet(struct net *net) | ||
50 | { | ||
51 | BUG_ON(!net); | ||
52 | |||
53 | return net_generic(net, phonet_net_id); | ||
54 | } | ||
55 | |||
49 | struct phonet_device_list *phonet_device_list(struct net *net) | 56 | struct phonet_device_list *phonet_device_list(struct net *net) |
50 | { | 57 | { |
51 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 58 | struct phonet_net *pnn = phonet_pernet(net); |
52 | return &pnn->pndevs; | 59 | return &pnn->pndevs; |
53 | } | 60 | } |
54 | 61 | ||
@@ -261,7 +268,7 @@ static int phonet_device_autoconf(struct net_device *dev) | |||
261 | 268 | ||
262 | static void phonet_route_autodel(struct net_device *dev) | 269 | static void phonet_route_autodel(struct net_device *dev) |
263 | { | 270 | { |
264 | struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); | 271 | struct phonet_net *pnn = phonet_pernet(dev_net(dev)); |
265 | unsigned i; | 272 | unsigned i; |
266 | DECLARE_BITMAP(deleted, 64); | 273 | DECLARE_BITMAP(deleted, 64); |
267 | 274 | ||
@@ -313,7 +320,7 @@ static struct notifier_block phonet_device_notifier = { | |||
313 | /* Per-namespace Phonet devices handling */ | 320 | /* Per-namespace Phonet devices handling */ |
314 | static int __net_init phonet_init_net(struct net *net) | 321 | static int __net_init phonet_init_net(struct net *net) |
315 | { | 322 | { |
316 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 323 | struct phonet_net *pnn = phonet_pernet(net); |
317 | 324 | ||
318 | if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) | 325 | if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) |
319 | return -ENOMEM; | 326 | return -ENOMEM; |
@@ -326,7 +333,7 @@ static int __net_init phonet_init_net(struct net *net) | |||
326 | 333 | ||
327 | static void __net_exit phonet_exit_net(struct net *net) | 334 | static void __net_exit phonet_exit_net(struct net *net) |
328 | { | 335 | { |
329 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 336 | struct phonet_net *pnn = phonet_pernet(net); |
330 | struct net_device *dev; | 337 | struct net_device *dev; |
331 | unsigned i; | 338 | unsigned i; |
332 | 339 | ||
@@ -376,7 +383,7 @@ void phonet_device_exit(void) | |||
376 | 383 | ||
377 | int phonet_route_add(struct net_device *dev, u8 daddr) | 384 | int phonet_route_add(struct net_device *dev, u8 daddr) |
378 | { | 385 | { |
379 | struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); | 386 | struct phonet_net *pnn = phonet_pernet(dev_net(dev)); |
380 | struct phonet_routes *routes = &pnn->routes; | 387 | struct phonet_routes *routes = &pnn->routes; |
381 | int err = -EEXIST; | 388 | int err = -EEXIST; |
382 | 389 | ||
@@ -393,7 +400,7 @@ int phonet_route_add(struct net_device *dev, u8 daddr) | |||
393 | 400 | ||
394 | int phonet_route_del(struct net_device *dev, u8 daddr) | 401 | int phonet_route_del(struct net_device *dev, u8 daddr) |
395 | { | 402 | { |
396 | struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); | 403 | struct phonet_net *pnn = phonet_pernet(dev_net(dev)); |
397 | struct phonet_routes *routes = &pnn->routes; | 404 | struct phonet_routes *routes = &pnn->routes; |
398 | 405 | ||
399 | daddr = daddr >> 2; | 406 | daddr = daddr >> 2; |
@@ -413,7 +420,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr) | |||
413 | 420 | ||
414 | struct net_device *phonet_route_get(struct net *net, u8 daddr) | 421 | struct net_device *phonet_route_get(struct net *net, u8 daddr) |
415 | { | 422 | { |
416 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 423 | struct phonet_net *pnn = phonet_pernet(net); |
417 | struct phonet_routes *routes = &pnn->routes; | 424 | struct phonet_routes *routes = &pnn->routes; |
418 | struct net_device *dev; | 425 | struct net_device *dev; |
419 | 426 | ||
@@ -428,7 +435,7 @@ struct net_device *phonet_route_get(struct net *net, u8 daddr) | |||
428 | 435 | ||
429 | struct net_device *phonet_route_output(struct net *net, u8 daddr) | 436 | struct net_device *phonet_route_output(struct net *net, u8 daddr) |
430 | { | 437 | { |
431 | struct phonet_net *pnn = net_generic(net, phonet_net_id); | 438 | struct phonet_net *pnn = phonet_pernet(net); |
432 | struct phonet_routes *routes = &pnn->routes; | 439 | struct phonet_routes *routes = &pnn->routes; |
433 | struct net_device *dev; | 440 | struct net_device *dev; |
434 | 441 | ||