aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-05-27 21:30:21 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-28 16:11:01 -0400
commit351638e7deeed2ec8ce451b53d33921b3da68f83 (patch)
tree175dfff289b5e3baecffbc7e97d1884e9a18345c /net/core
parentb1098bbe1b24d5d90cff92fbd716d2ef4bed2cff (diff)
net: pass info struct via netdevice notifier
So far, only net_device * could be passed along with netdevice notifier event. This patch provides a possibility to pass custom structure able to provide info that event listener needs to know. Signed-off-by: Jiri Pirko <jiri@resnulli.us> v2->v3: fix typo on simeth shortened dev_getter shortened notifier_info struct name v1->v2: fix notifier_call parameter in call_netdevice_notifier() Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c56
-rw-r--r--net/core/drop_monitor.c4
-rw-r--r--net/core/dst.c2
-rw-r--r--net/core/fib_rules.c4
-rw-r--r--net/core/netprio_cgroup.c2
-rw-r--r--net/core/pktgen.c2
-rw-r--r--net/core/rtnetlink.c2
7 files changed, 54 insertions, 18 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 5f747974ac58..54fce6006a83 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1391,6 +1391,20 @@ void dev_disable_lro(struct net_device *dev)
1391} 1391}
1392EXPORT_SYMBOL(dev_disable_lro); 1392EXPORT_SYMBOL(dev_disable_lro);
1393 1393
1394static void netdev_notifier_info_init(struct netdev_notifier_info *info,
1395 struct net_device *dev)
1396{
1397 info->dev = dev;
1398}
1399
1400static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val,
1401 struct net_device *dev)
1402{
1403 struct netdev_notifier_info info;
1404
1405 netdev_notifier_info_init(&info, dev);
1406 return nb->notifier_call(nb, val, &info);
1407}
1394 1408
1395static int dev_boot_phase = 1; 1409static int dev_boot_phase = 1;
1396 1410
@@ -1423,7 +1437,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
1423 goto unlock; 1437 goto unlock;
1424 for_each_net(net) { 1438 for_each_net(net) {
1425 for_each_netdev(net, dev) { 1439 for_each_netdev(net, dev) {
1426 err = nb->notifier_call(nb, NETDEV_REGISTER, dev); 1440 err = call_netdevice_notifier(nb, NETDEV_REGISTER, dev);
1427 err = notifier_to_errno(err); 1441 err = notifier_to_errno(err);
1428 if (err) 1442 if (err)
1429 goto rollback; 1443 goto rollback;
@@ -1431,7 +1445,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
1431 if (!(dev->flags & IFF_UP)) 1445 if (!(dev->flags & IFF_UP))
1432 continue; 1446 continue;
1433 1447
1434 nb->notifier_call(nb, NETDEV_UP, dev); 1448 call_netdevice_notifier(nb, NETDEV_UP, dev);
1435 } 1449 }
1436 } 1450 }
1437 1451
@@ -1447,10 +1461,11 @@ rollback:
1447 goto outroll; 1461 goto outroll;
1448 1462
1449 if (dev->flags & IFF_UP) { 1463 if (dev->flags & IFF_UP) {
1450 nb->notifier_call(nb, NETDEV_GOING_DOWN, dev); 1464 call_netdevice_notifier(nb, NETDEV_GOING_DOWN,
1451 nb->notifier_call(nb, NETDEV_DOWN, dev); 1465 dev);
1466 call_netdevice_notifier(nb, NETDEV_DOWN, dev);
1452 } 1467 }
1453 nb->notifier_call(nb, NETDEV_UNREGISTER, dev); 1468 call_netdevice_notifier(nb, NETDEV_UNREGISTER, dev);
1454 } 1469 }
1455 } 1470 }
1456 1471
@@ -1488,10 +1503,11 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
1488 for_each_net(net) { 1503 for_each_net(net) {
1489 for_each_netdev(net, dev) { 1504 for_each_netdev(net, dev) {
1490 if (dev->flags & IFF_UP) { 1505 if (dev->flags & IFF_UP) {
1491 nb->notifier_call(nb, NETDEV_GOING_DOWN, dev); 1506 call_netdevice_notifier(nb, NETDEV_GOING_DOWN,
1492 nb->notifier_call(nb, NETDEV_DOWN, dev); 1507 dev);
1508 call_netdevice_notifier(nb, NETDEV_DOWN, dev);
1493 } 1509 }
1494 nb->notifier_call(nb, NETDEV_UNREGISTER, dev); 1510 call_netdevice_notifier(nb, NETDEV_UNREGISTER, dev);
1495 } 1511 }
1496 } 1512 }
1497unlock: 1513unlock:
@@ -1501,6 +1517,25 @@ unlock:
1501EXPORT_SYMBOL(unregister_netdevice_notifier); 1517EXPORT_SYMBOL(unregister_netdevice_notifier);
1502 1518
1503/** 1519/**
1520 * call_netdevice_notifiers_info - call all network notifier blocks
1521 * @val: value passed unmodified to notifier function
1522 * @dev: net_device pointer passed unmodified to notifier function
1523 * @info: notifier information data
1524 *
1525 * Call all network notifier blocks. Parameters and return value
1526 * are as for raw_notifier_call_chain().
1527 */
1528
1529int call_netdevice_notifiers_info(unsigned long val, struct net_device *dev,
1530 struct netdev_notifier_info *info)
1531{
1532 ASSERT_RTNL();
1533 netdev_notifier_info_init(info, dev);
1534 return raw_notifier_call_chain(&netdev_chain, val, info);
1535}
1536EXPORT_SYMBOL(call_netdevice_notifiers_info);
1537
1538/**
1504 * call_netdevice_notifiers - call all network notifier blocks 1539 * call_netdevice_notifiers - call all network notifier blocks
1505 * @val: value passed unmodified to notifier function 1540 * @val: value passed unmodified to notifier function
1506 * @dev: net_device pointer passed unmodified to notifier function 1541 * @dev: net_device pointer passed unmodified to notifier function
@@ -1511,8 +1546,9 @@ EXPORT_SYMBOL(unregister_netdevice_notifier);
1511 1546
1512int call_netdevice_notifiers(unsigned long val, struct net_device *dev) 1547int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
1513{ 1548{
1514 ASSERT_RTNL(); 1549 struct netdev_notifier_info info;
1515 return raw_notifier_call_chain(&netdev_chain, val, dev); 1550
1551 return call_netdevice_notifiers_info(val, dev, &info);
1516} 1552}
1517EXPORT_SYMBOL(call_netdevice_notifiers); 1553EXPORT_SYMBOL(call_netdevice_notifiers);
1518 1554
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index d23b6682f4e9..5e78d44333b9 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -295,9 +295,9 @@ static int net_dm_cmd_trace(struct sk_buff *skb,
295} 295}
296 296
297static int dropmon_net_event(struct notifier_block *ev_block, 297static int dropmon_net_event(struct notifier_block *ev_block,
298 unsigned long event, void *ptr) 298 unsigned long event, void *ptr)
299{ 299{
300 struct net_device *dev = ptr; 300 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
301 struct dm_hw_stat_delta *new_stat = NULL; 301 struct dm_hw_stat_delta *new_stat = NULL;
302 struct dm_hw_stat_delta *tmp; 302 struct dm_hw_stat_delta *tmp;
303 303
diff --git a/net/core/dst.c b/net/core/dst.c
index df9cc810ec8e..ca4231ec7347 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -372,7 +372,7 @@ static void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
372static int dst_dev_event(struct notifier_block *this, unsigned long event, 372static int dst_dev_event(struct notifier_block *this, unsigned long event,
373 void *ptr) 373 void *ptr)
374{ 374{
375 struct net_device *dev = ptr; 375 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
376 struct dst_entry *dst, *last = NULL; 376 struct dst_entry *dst, *last = NULL;
377 377
378 switch (event) { 378 switch (event) {
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index d5a9f8ead0d8..21735440c44a 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -705,9 +705,9 @@ static void detach_rules(struct list_head *rules, struct net_device *dev)
705 705
706 706
707static int fib_rules_event(struct notifier_block *this, unsigned long event, 707static int fib_rules_event(struct notifier_block *this, unsigned long event,
708 void *ptr) 708 void *ptr)
709{ 709{
710 struct net_device *dev = ptr; 710 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
711 struct net *net = dev_net(dev); 711 struct net *net = dev_net(dev);
712 struct fib_rules_ops *ops; 712 struct fib_rules_ops *ops;
713 713
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index 0777d0aa18c3..e533259dce3c 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -261,7 +261,7 @@ struct cgroup_subsys net_prio_subsys = {
261static int netprio_device_event(struct notifier_block *unused, 261static int netprio_device_event(struct notifier_block *unused,
262 unsigned long event, void *ptr) 262 unsigned long event, void *ptr)
263{ 263{
264 struct net_device *dev = ptr; 264 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
265 struct netprio_map *old; 265 struct netprio_map *old;
266 266
267 /* 267 /*
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 11f2704c3810..795498fd4587 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1921,7 +1921,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
1921static int pktgen_device_event(struct notifier_block *unused, 1921static int pktgen_device_event(struct notifier_block *unused,
1922 unsigned long event, void *ptr) 1922 unsigned long event, void *ptr)
1923{ 1923{
1924 struct net_device *dev = ptr; 1924 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1925 struct pktgen_net *pn = net_generic(dev_net(dev), pg_net_id); 1925 struct pktgen_net *pn = net_generic(dev_net(dev), pg_net_id);
1926 1926
1927 if (pn->pktgen_exiting) 1927 if (pn->pktgen_exiting)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a08bd2b7fe3f..49c14451d8ab 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2667,7 +2667,7 @@ static void rtnetlink_rcv(struct sk_buff *skb)
2667 2667
2668static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr) 2668static int rtnetlink_event(struct notifier_block *this, unsigned long event, void *ptr)
2669{ 2669{
2670 struct net_device *dev = ptr; 2670 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
2671 2671
2672 switch (event) { 2672 switch (event) {
2673 case NETDEV_UP: 2673 case NETDEV_UP: