aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/neighbour.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r--net/core/neighbour.c616
1 files changed, 341 insertions, 275 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 50a8c73caf97..8ce8c471d868 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -15,7 +15,6 @@
15 * Harald Welte Add neighbour cache statistics like rtstat 15 * Harald Welte Add neighbour cache statistics like rtstat
16 */ 16 */
17 17
18#include <linux/config.h>
19#include <linux/types.h> 18#include <linux/types.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/module.h> 20#include <linux/module.h>
@@ -30,6 +29,8 @@
30#include <net/neighbour.h> 29#include <net/neighbour.h>
31#include <net/dst.h> 30#include <net/dst.h>
32#include <net/sock.h> 31#include <net/sock.h>
32#include <net/netevent.h>
33#include <net/netlink.h>
33#include <linux/rtnetlink.h> 34#include <linux/rtnetlink.h>
34#include <linux/random.h> 35#include <linux/random.h>
35#include <linux/string.h> 36#include <linux/string.h>
@@ -755,6 +756,7 @@ static void neigh_timer_handler(unsigned long arg)
755 neigh->nud_state = NUD_STALE; 756 neigh->nud_state = NUD_STALE;
756 neigh->updated = jiffies; 757 neigh->updated = jiffies;
757 neigh_suspect(neigh); 758 neigh_suspect(neigh);
759 notify = 1;
758 } 760 }
759 } else if (state & NUD_DELAY) { 761 } else if (state & NUD_DELAY) {
760 if (time_before_eq(now, 762 if (time_before_eq(now,
@@ -763,6 +765,7 @@ static void neigh_timer_handler(unsigned long arg)
763 neigh->nud_state = NUD_REACHABLE; 765 neigh->nud_state = NUD_REACHABLE;
764 neigh->updated = jiffies; 766 neigh->updated = jiffies;
765 neigh_connect(neigh); 767 neigh_connect(neigh);
768 notify = 1;
766 next = neigh->confirmed + neigh->parms->reachable_time; 769 next = neigh->confirmed + neigh->parms->reachable_time;
767 } else { 770 } else {
768 NEIGH_PRINTK2("neigh %p is probed.\n", neigh); 771 NEIGH_PRINTK2("neigh %p is probed.\n", neigh);
@@ -820,6 +823,8 @@ static void neigh_timer_handler(unsigned long arg)
820out: 823out:
821 write_unlock(&neigh->lock); 824 write_unlock(&neigh->lock);
822 } 825 }
826 if (notify)
827 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
823 828
824#ifdef CONFIG_ARPD 829#ifdef CONFIG_ARPD
825 if (notify && neigh->parms->app_probes) 830 if (notify && neigh->parms->app_probes)
@@ -884,7 +889,7 @@ out_unlock_bh:
884 return rc; 889 return rc;
885} 890}
886 891
887static __inline__ void neigh_update_hhs(struct neighbour *neigh) 892static void neigh_update_hhs(struct neighbour *neigh)
888{ 893{
889 struct hh_cache *hh; 894 struct hh_cache *hh;
890 void (*update)(struct hh_cache*, struct net_device*, unsigned char *) = 895 void (*update)(struct hh_cache*, struct net_device*, unsigned char *) =
@@ -927,9 +932,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
927{ 932{
928 u8 old; 933 u8 old;
929 int err; 934 int err;
930#ifdef CONFIG_ARPD
931 int notify = 0; 935 int notify = 0;
932#endif
933 struct net_device *dev; 936 struct net_device *dev;
934 int update_isrouter = 0; 937 int update_isrouter = 0;
935 938
@@ -949,9 +952,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
949 neigh_suspect(neigh); 952 neigh_suspect(neigh);
950 neigh->nud_state = new; 953 neigh->nud_state = new;
951 err = 0; 954 err = 0;
952#ifdef CONFIG_ARPD
953 notify = old & NUD_VALID; 955 notify = old & NUD_VALID;
954#endif
955 goto out; 956 goto out;
956 } 957 }
957 958
@@ -1023,9 +1024,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1023 if (!(new & NUD_CONNECTED)) 1024 if (!(new & NUD_CONNECTED))
1024 neigh->confirmed = jiffies - 1025 neigh->confirmed = jiffies -
1025 (neigh->parms->base_reachable_time << 1); 1026 (neigh->parms->base_reachable_time << 1);
1026#ifdef CONFIG_ARPD
1027 notify = 1; 1027 notify = 1;
1028#endif
1029 } 1028 }
1030 if (new == old) 1029 if (new == old)
1031 goto out; 1030 goto out;
@@ -1057,6 +1056,9 @@ out:
1057 (neigh->flags & ~NTF_ROUTER); 1056 (neigh->flags & ~NTF_ROUTER);
1058 } 1057 }
1059 write_unlock_bh(&neigh->lock); 1058 write_unlock_bh(&neigh->lock);
1059
1060 if (notify)
1061 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
1060#ifdef CONFIG_ARPD 1062#ifdef CONFIG_ARPD
1061 if (notify && neigh->parms->app_probes) 1063 if (notify && neigh->parms->app_probes)
1062 neigh_app_notify(neigh); 1064 neigh_app_notify(neigh);
@@ -1077,7 +1079,7 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl,
1077} 1079}
1078 1080
1079static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst, 1081static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst,
1080 u16 protocol) 1082 __be16 protocol)
1081{ 1083{
1082 struct hh_cache *hh; 1084 struct hh_cache *hh;
1083 struct net_device *dev = dst->dev; 1085 struct net_device *dev = dst->dev;
@@ -1337,14 +1339,10 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1337 neigh_rand_reach_time(tbl->parms.base_reachable_time); 1339 neigh_rand_reach_time(tbl->parms.base_reachable_time);
1338 1340
1339 if (!tbl->kmem_cachep) 1341 if (!tbl->kmem_cachep)
1340 tbl->kmem_cachep = kmem_cache_create(tbl->id, 1342 tbl->kmem_cachep =
1341 tbl->entry_size, 1343 kmem_cache_create(tbl->id, tbl->entry_size, 0,
1342 0, SLAB_HWCACHE_ALIGN, 1344 SLAB_HWCACHE_ALIGN|SLAB_PANIC,
1343 NULL, NULL); 1345 NULL, NULL);
1344
1345 if (!tbl->kmem_cachep)
1346 panic("cannot create neighbour cache");
1347
1348 tbl->stats = alloc_percpu(struct neigh_statistics); 1346 tbl->stats = alloc_percpu(struct neigh_statistics);
1349 if (!tbl->stats) 1347 if (!tbl->stats)
1350 panic("cannot create neighbour cache statistics"); 1348 panic("cannot create neighbour cache statistics");
@@ -1431,53 +1429,70 @@ int neigh_table_clear(struct neigh_table *tbl)
1431 kfree(tbl->phash_buckets); 1429 kfree(tbl->phash_buckets);
1432 tbl->phash_buckets = NULL; 1430 tbl->phash_buckets = NULL;
1433 1431
1432 free_percpu(tbl->stats);
1433 tbl->stats = NULL;
1434
1434 return 0; 1435 return 0;
1435} 1436}
1436 1437
1437int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1438int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1438{ 1439{
1439 struct ndmsg *ndm = NLMSG_DATA(nlh); 1440 struct ndmsg *ndm;
1440 struct rtattr **nda = arg; 1441 struct nlattr *dst_attr;
1441 struct neigh_table *tbl; 1442 struct neigh_table *tbl;
1442 struct net_device *dev = NULL; 1443 struct net_device *dev = NULL;
1443 int err = -ENODEV; 1444 int err = -EINVAL;
1445
1446 if (nlmsg_len(nlh) < sizeof(*ndm))
1447 goto out;
1444 1448
1445 if (ndm->ndm_ifindex && 1449 dst_attr = nlmsg_find_attr(nlh, sizeof(*ndm), NDA_DST);
1446 (dev = dev_get_by_index(ndm->ndm_ifindex)) == NULL) 1450 if (dst_attr == NULL)
1447 goto out; 1451 goto out;
1448 1452
1453 ndm = nlmsg_data(nlh);
1454 if (ndm->ndm_ifindex) {
1455 dev = dev_get_by_index(ndm->ndm_ifindex);
1456 if (dev == NULL) {
1457 err = -ENODEV;
1458 goto out;
1459 }
1460 }
1461
1449 read_lock(&neigh_tbl_lock); 1462 read_lock(&neigh_tbl_lock);
1450 for (tbl = neigh_tables; tbl; tbl = tbl->next) { 1463 for (tbl = neigh_tables; tbl; tbl = tbl->next) {
1451 struct rtattr *dst_attr = nda[NDA_DST - 1]; 1464 struct neighbour *neigh;
1452 struct neighbour *n;
1453 1465
1454 if (tbl->family != ndm->ndm_family) 1466 if (tbl->family != ndm->ndm_family)
1455 continue; 1467 continue;
1456 read_unlock(&neigh_tbl_lock); 1468 read_unlock(&neigh_tbl_lock);
1457 1469
1458 err = -EINVAL; 1470 if (nla_len(dst_attr) < tbl->key_len)
1459 if (!dst_attr || RTA_PAYLOAD(dst_attr) < tbl->key_len)
1460 goto out_dev_put; 1471 goto out_dev_put;
1461 1472
1462 if (ndm->ndm_flags & NTF_PROXY) { 1473 if (ndm->ndm_flags & NTF_PROXY) {
1463 err = pneigh_delete(tbl, RTA_DATA(dst_attr), dev); 1474 err = pneigh_delete(tbl, nla_data(dst_attr), dev);
1464 goto out_dev_put; 1475 goto out_dev_put;
1465 } 1476 }
1466 1477
1467 if (!dev) 1478 if (dev == NULL)
1468 goto out; 1479 goto out_dev_put;
1469 1480
1470 n = neigh_lookup(tbl, RTA_DATA(dst_attr), dev); 1481 neigh = neigh_lookup(tbl, nla_data(dst_attr), dev);
1471 if (n) { 1482 if (neigh == NULL) {
1472 err = neigh_update(n, NULL, NUD_FAILED, 1483 err = -ENOENT;
1473 NEIGH_UPDATE_F_OVERRIDE| 1484 goto out_dev_put;
1474 NEIGH_UPDATE_F_ADMIN);
1475 neigh_release(n);
1476 } 1485 }
1486
1487 err = neigh_update(neigh, NULL, NUD_FAILED,
1488 NEIGH_UPDATE_F_OVERRIDE |
1489 NEIGH_UPDATE_F_ADMIN);
1490 neigh_release(neigh);
1477 goto out_dev_put; 1491 goto out_dev_put;
1478 } 1492 }
1479 read_unlock(&neigh_tbl_lock); 1493 read_unlock(&neigh_tbl_lock);
1480 err = -EADDRNOTAVAIL; 1494 err = -EAFNOSUPPORT;
1495
1481out_dev_put: 1496out_dev_put:
1482 if (dev) 1497 if (dev)
1483 dev_put(dev); 1498 dev_put(dev);
@@ -1487,76 +1502,93 @@ out:
1487 1502
1488int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1503int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1489{ 1504{
1490 struct ndmsg *ndm = NLMSG_DATA(nlh); 1505 struct ndmsg *ndm;
1491 struct rtattr **nda = arg; 1506 struct nlattr *tb[NDA_MAX+1];
1492 struct neigh_table *tbl; 1507 struct neigh_table *tbl;
1493 struct net_device *dev = NULL; 1508 struct net_device *dev = NULL;
1494 int err = -ENODEV; 1509 int err;
1495 1510
1496 if (ndm->ndm_ifindex && 1511 err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL);
1497 (dev = dev_get_by_index(ndm->ndm_ifindex)) == NULL) 1512 if (err < 0)
1498 goto out; 1513 goto out;
1499 1514
1515 err = -EINVAL;
1516 if (tb[NDA_DST] == NULL)
1517 goto out;
1518
1519 ndm = nlmsg_data(nlh);
1520 if (ndm->ndm_ifindex) {
1521 dev = dev_get_by_index(ndm->ndm_ifindex);
1522 if (dev == NULL) {
1523 err = -ENODEV;
1524 goto out;
1525 }
1526
1527 if (tb[NDA_LLADDR] && nla_len(tb[NDA_LLADDR]) < dev->addr_len)
1528 goto out_dev_put;
1529 }
1530
1500 read_lock(&neigh_tbl_lock); 1531 read_lock(&neigh_tbl_lock);
1501 for (tbl = neigh_tables; tbl; tbl = tbl->next) { 1532 for (tbl = neigh_tables; tbl; tbl = tbl->next) {
1502 struct rtattr *lladdr_attr = nda[NDA_LLADDR - 1]; 1533 int flags = NEIGH_UPDATE_F_ADMIN | NEIGH_UPDATE_F_OVERRIDE;
1503 struct rtattr *dst_attr = nda[NDA_DST - 1]; 1534 struct neighbour *neigh;
1504 int override = 1; 1535 void *dst, *lladdr;
1505 struct neighbour *n;
1506 1536
1507 if (tbl->family != ndm->ndm_family) 1537 if (tbl->family != ndm->ndm_family)
1508 continue; 1538 continue;
1509 read_unlock(&neigh_tbl_lock); 1539 read_unlock(&neigh_tbl_lock);
1510 1540
1511 err = -EINVAL; 1541 if (nla_len(tb[NDA_DST]) < tbl->key_len)
1512 if (!dst_attr || RTA_PAYLOAD(dst_attr) < tbl->key_len)
1513 goto out_dev_put; 1542 goto out_dev_put;
1543 dst = nla_data(tb[NDA_DST]);
1544 lladdr = tb[NDA_LLADDR] ? nla_data(tb[NDA_LLADDR]) : NULL;
1514 1545
1515 if (ndm->ndm_flags & NTF_PROXY) { 1546 if (ndm->ndm_flags & NTF_PROXY) {
1547 struct pneigh_entry *pn;
1548
1516 err = -ENOBUFS; 1549 err = -ENOBUFS;
1517 if (pneigh_lookup(tbl, RTA_DATA(dst_attr), dev, 1)) 1550 pn = pneigh_lookup(tbl, dst, dev, 1);
1551 if (pn) {
1552 pn->flags = ndm->ndm_flags;
1518 err = 0; 1553 err = 0;
1554 }
1519 goto out_dev_put; 1555 goto out_dev_put;
1520 } 1556 }
1521 1557
1522 err = -EINVAL; 1558 if (dev == NULL)
1523 if (!dev)
1524 goto out;
1525 if (lladdr_attr && RTA_PAYLOAD(lladdr_attr) < dev->addr_len)
1526 goto out_dev_put; 1559 goto out_dev_put;
1560
1561 neigh = neigh_lookup(tbl, dst, dev);
1562 if (neigh == NULL) {
1563 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
1564 err = -ENOENT;
1565 goto out_dev_put;
1566 }
1527 1567
1528 n = neigh_lookup(tbl, RTA_DATA(dst_attr), dev); 1568 neigh = __neigh_lookup_errno(tbl, dst, dev);
1529 if (n) { 1569 if (IS_ERR(neigh)) {
1530 if (nlh->nlmsg_flags & NLM_F_EXCL) { 1570 err = PTR_ERR(neigh);
1531 err = -EEXIST;
1532 neigh_release(n);
1533 goto out_dev_put; 1571 goto out_dev_put;
1534 } 1572 }
1535
1536 override = nlh->nlmsg_flags & NLM_F_REPLACE;
1537 } else if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
1538 err = -ENOENT;
1539 goto out_dev_put;
1540 } else { 1573 } else {
1541 n = __neigh_lookup_errno(tbl, RTA_DATA(dst_attr), dev); 1574 if (nlh->nlmsg_flags & NLM_F_EXCL) {
1542 if (IS_ERR(n)) { 1575 err = -EEXIST;
1543 err = PTR_ERR(n); 1576 neigh_release(neigh);
1544 goto out_dev_put; 1577 goto out_dev_put;
1545 } 1578 }
1546 }
1547 1579
1548 err = neigh_update(n, 1580 if (!(nlh->nlmsg_flags & NLM_F_REPLACE))
1549 lladdr_attr ? RTA_DATA(lladdr_attr) : NULL, 1581 flags &= ~NEIGH_UPDATE_F_OVERRIDE;
1550 ndm->ndm_state, 1582 }
1551 (override ? NEIGH_UPDATE_F_OVERRIDE : 0) |
1552 NEIGH_UPDATE_F_ADMIN);
1553 1583
1554 neigh_release(n); 1584 err = neigh_update(neigh, lladdr, ndm->ndm_state, flags);
1585 neigh_release(neigh);
1555 goto out_dev_put; 1586 goto out_dev_put;
1556 } 1587 }
1557 1588
1558 read_unlock(&neigh_tbl_lock); 1589 read_unlock(&neigh_tbl_lock);
1559 err = -EADDRNOTAVAIL; 1590 err = -EAFNOSUPPORT;
1591
1560out_dev_put: 1592out_dev_put:
1561 if (dev) 1593 if (dev)
1562 dev_put(dev); 1594 dev_put(dev);
@@ -1566,56 +1598,59 @@ out:
1566 1598
1567static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms) 1599static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms)
1568{ 1600{
1569 struct rtattr *nest = NULL; 1601 struct nlattr *nest;
1570 1602
1571 nest = RTA_NEST(skb, NDTA_PARMS); 1603 nest = nla_nest_start(skb, NDTA_PARMS);
1604 if (nest == NULL)
1605 return -ENOBUFS;
1572 1606
1573 if (parms->dev) 1607 if (parms->dev)
1574 RTA_PUT_U32(skb, NDTPA_IFINDEX, parms->dev->ifindex); 1608 NLA_PUT_U32(skb, NDTPA_IFINDEX, parms->dev->ifindex);
1575 1609
1576 RTA_PUT_U32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt)); 1610 NLA_PUT_U32(skb, NDTPA_REFCNT, atomic_read(&parms->refcnt));
1577 RTA_PUT_U32(skb, NDTPA_QUEUE_LEN, parms->queue_len); 1611 NLA_PUT_U32(skb, NDTPA_QUEUE_LEN, parms->queue_len);
1578 RTA_PUT_U32(skb, NDTPA_PROXY_QLEN, parms->proxy_qlen); 1612 NLA_PUT_U32(skb, NDTPA_PROXY_QLEN, parms->proxy_qlen);
1579 RTA_PUT_U32(skb, NDTPA_APP_PROBES, parms->app_probes); 1613 NLA_PUT_U32(skb, NDTPA_APP_PROBES, parms->app_probes);
1580 RTA_PUT_U32(skb, NDTPA_UCAST_PROBES, parms->ucast_probes); 1614 NLA_PUT_U32(skb, NDTPA_UCAST_PROBES, parms->ucast_probes);
1581 RTA_PUT_U32(skb, NDTPA_MCAST_PROBES, parms->mcast_probes); 1615 NLA_PUT_U32(skb, NDTPA_MCAST_PROBES, parms->mcast_probes);
1582 RTA_PUT_MSECS(skb, NDTPA_REACHABLE_TIME, parms->reachable_time); 1616 NLA_PUT_MSECS(skb, NDTPA_REACHABLE_TIME, parms->reachable_time);
1583 RTA_PUT_MSECS(skb, NDTPA_BASE_REACHABLE_TIME, 1617 NLA_PUT_MSECS(skb, NDTPA_BASE_REACHABLE_TIME,
1584 parms->base_reachable_time); 1618 parms->base_reachable_time);
1585 RTA_PUT_MSECS(skb, NDTPA_GC_STALETIME, parms->gc_staletime); 1619 NLA_PUT_MSECS(skb, NDTPA_GC_STALETIME, parms->gc_staletime);
1586 RTA_PUT_MSECS(skb, NDTPA_DELAY_PROBE_TIME, parms->delay_probe_time); 1620 NLA_PUT_MSECS(skb, NDTPA_DELAY_PROBE_TIME, parms->delay_probe_time);
1587 RTA_PUT_MSECS(skb, NDTPA_RETRANS_TIME, parms->retrans_time); 1621 NLA_PUT_MSECS(skb, NDTPA_RETRANS_TIME, parms->retrans_time);
1588 RTA_PUT_MSECS(skb, NDTPA_ANYCAST_DELAY, parms->anycast_delay); 1622 NLA_PUT_MSECS(skb, NDTPA_ANYCAST_DELAY, parms->anycast_delay);
1589 RTA_PUT_MSECS(skb, NDTPA_PROXY_DELAY, parms->proxy_delay); 1623 NLA_PUT_MSECS(skb, NDTPA_PROXY_DELAY, parms->proxy_delay);
1590 RTA_PUT_MSECS(skb, NDTPA_LOCKTIME, parms->locktime); 1624 NLA_PUT_MSECS(skb, NDTPA_LOCKTIME, parms->locktime);
1591 1625
1592 return RTA_NEST_END(skb, nest); 1626 return nla_nest_end(skb, nest);
1593 1627
1594rtattr_failure: 1628nla_put_failure:
1595 return RTA_NEST_CANCEL(skb, nest); 1629 return nla_nest_cancel(skb, nest);
1596} 1630}
1597 1631
1598static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb, 1632static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,
1599 struct netlink_callback *cb) 1633 u32 pid, u32 seq, int type, int flags)
1600{ 1634{
1601 struct nlmsghdr *nlh; 1635 struct nlmsghdr *nlh;
1602 struct ndtmsg *ndtmsg; 1636 struct ndtmsg *ndtmsg;
1603 1637
1604 nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWNEIGHTBL, sizeof(struct ndtmsg), 1638 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndtmsg), flags);
1605 NLM_F_MULTI); 1639 if (nlh == NULL)
1640 return -ENOBUFS;
1606 1641
1607 ndtmsg = NLMSG_DATA(nlh); 1642 ndtmsg = nlmsg_data(nlh);
1608 1643
1609 read_lock_bh(&tbl->lock); 1644 read_lock_bh(&tbl->lock);
1610 ndtmsg->ndtm_family = tbl->family; 1645 ndtmsg->ndtm_family = tbl->family;
1611 ndtmsg->ndtm_pad1 = 0; 1646 ndtmsg->ndtm_pad1 = 0;
1612 ndtmsg->ndtm_pad2 = 0; 1647 ndtmsg->ndtm_pad2 = 0;
1613 1648
1614 RTA_PUT_STRING(skb, NDTA_NAME, tbl->id); 1649 NLA_PUT_STRING(skb, NDTA_NAME, tbl->id);
1615 RTA_PUT_MSECS(skb, NDTA_GC_INTERVAL, tbl->gc_interval); 1650 NLA_PUT_MSECS(skb, NDTA_GC_INTERVAL, tbl->gc_interval);
1616 RTA_PUT_U32(skb, NDTA_THRESH1, tbl->gc_thresh1); 1651 NLA_PUT_U32(skb, NDTA_THRESH1, tbl->gc_thresh1);
1617 RTA_PUT_U32(skb, NDTA_THRESH2, tbl->gc_thresh2); 1652 NLA_PUT_U32(skb, NDTA_THRESH2, tbl->gc_thresh2);
1618 RTA_PUT_U32(skb, NDTA_THRESH3, tbl->gc_thresh3); 1653 NLA_PUT_U32(skb, NDTA_THRESH3, tbl->gc_thresh3);
1619 1654
1620 { 1655 {
1621 unsigned long now = jiffies; 1656 unsigned long now = jiffies;
@@ -1634,7 +1669,7 @@ static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb,
1634 .ndtc_proxy_qlen = tbl->proxy_queue.qlen, 1669 .ndtc_proxy_qlen = tbl->proxy_queue.qlen,
1635 }; 1670 };
1636 1671
1637 RTA_PUT(skb, NDTA_CONFIG, sizeof(ndc), &ndc); 1672 NLA_PUT(skb, NDTA_CONFIG, sizeof(ndc), &ndc);
1638 } 1673 }
1639 1674
1640 { 1675 {
@@ -1659,55 +1694,50 @@ static int neightbl_fill_info(struct neigh_table *tbl, struct sk_buff *skb,
1659 ndst.ndts_forced_gc_runs += st->forced_gc_runs; 1694 ndst.ndts_forced_gc_runs += st->forced_gc_runs;
1660 } 1695 }
1661 1696
1662 RTA_PUT(skb, NDTA_STATS, sizeof(ndst), &ndst); 1697 NLA_PUT(skb, NDTA_STATS, sizeof(ndst), &ndst);
1663 } 1698 }
1664 1699
1665 BUG_ON(tbl->parms.dev); 1700 BUG_ON(tbl->parms.dev);
1666 if (neightbl_fill_parms(skb, &tbl->parms) < 0) 1701 if (neightbl_fill_parms(skb, &tbl->parms) < 0)
1667 goto rtattr_failure; 1702 goto nla_put_failure;
1668 1703
1669 read_unlock_bh(&tbl->lock); 1704 read_unlock_bh(&tbl->lock);
1670 return NLMSG_END(skb, nlh); 1705 return nlmsg_end(skb, nlh);
1671 1706
1672rtattr_failure: 1707nla_put_failure:
1673 read_unlock_bh(&tbl->lock); 1708 read_unlock_bh(&tbl->lock);
1674 return NLMSG_CANCEL(skb, nlh); 1709 return nlmsg_cancel(skb, nlh);
1675
1676nlmsg_failure:
1677 return -1;
1678} 1710}
1679 1711
1680static int neightbl_fill_param_info(struct neigh_table *tbl, 1712static int neightbl_fill_param_info(struct sk_buff *skb,
1713 struct neigh_table *tbl,
1681 struct neigh_parms *parms, 1714 struct neigh_parms *parms,
1682 struct sk_buff *skb, 1715 u32 pid, u32 seq, int type,
1683 struct netlink_callback *cb) 1716 unsigned int flags)
1684{ 1717{
1685 struct ndtmsg *ndtmsg; 1718 struct ndtmsg *ndtmsg;
1686 struct nlmsghdr *nlh; 1719 struct nlmsghdr *nlh;
1687 1720
1688 nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWNEIGHTBL, sizeof(struct ndtmsg), 1721 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndtmsg), flags);
1689 NLM_F_MULTI); 1722 if (nlh == NULL)
1723 return -ENOBUFS;
1690 1724
1691 ndtmsg = NLMSG_DATA(nlh); 1725 ndtmsg = nlmsg_data(nlh);
1692 1726
1693 read_lock_bh(&tbl->lock); 1727 read_lock_bh(&tbl->lock);
1694 ndtmsg->ndtm_family = tbl->family; 1728 ndtmsg->ndtm_family = tbl->family;
1695 ndtmsg->ndtm_pad1 = 0; 1729 ndtmsg->ndtm_pad1 = 0;
1696 ndtmsg->ndtm_pad2 = 0; 1730 ndtmsg->ndtm_pad2 = 0;
1697 RTA_PUT_STRING(skb, NDTA_NAME, tbl->id);
1698 1731
1699 if (neightbl_fill_parms(skb, parms) < 0) 1732 if (nla_put_string(skb, NDTA_NAME, tbl->id) < 0 ||
1700 goto rtattr_failure; 1733 neightbl_fill_parms(skb, parms) < 0)
1734 goto errout;
1701 1735
1702 read_unlock_bh(&tbl->lock); 1736 read_unlock_bh(&tbl->lock);
1703 return NLMSG_END(skb, nlh); 1737 return nlmsg_end(skb, nlh);
1704 1738errout:
1705rtattr_failure:
1706 read_unlock_bh(&tbl->lock); 1739 read_unlock_bh(&tbl->lock);
1707 return NLMSG_CANCEL(skb, nlh); 1740 return nlmsg_cancel(skb, nlh);
1708
1709nlmsg_failure:
1710 return -1;
1711} 1741}
1712 1742
1713static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl, 1743static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl,
@@ -1723,28 +1753,61 @@ static inline struct neigh_parms *lookup_neigh_params(struct neigh_table *tbl,
1723 return NULL; 1753 return NULL;
1724} 1754}
1725 1755
1756static struct nla_policy nl_neightbl_policy[NDTA_MAX+1] __read_mostly = {
1757 [NDTA_NAME] = { .type = NLA_STRING },
1758 [NDTA_THRESH1] = { .type = NLA_U32 },
1759 [NDTA_THRESH2] = { .type = NLA_U32 },
1760 [NDTA_THRESH3] = { .type = NLA_U32 },
1761 [NDTA_GC_INTERVAL] = { .type = NLA_U64 },
1762 [NDTA_PARMS] = { .type = NLA_NESTED },
1763};
1764
1765static struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] __read_mostly = {
1766 [NDTPA_IFINDEX] = { .type = NLA_U32 },
1767 [NDTPA_QUEUE_LEN] = { .type = NLA_U32 },
1768 [NDTPA_PROXY_QLEN] = { .type = NLA_U32 },
1769 [NDTPA_APP_PROBES] = { .type = NLA_U32 },
1770 [NDTPA_UCAST_PROBES] = { .type = NLA_U32 },
1771 [NDTPA_MCAST_PROBES] = { .type = NLA_U32 },
1772 [NDTPA_BASE_REACHABLE_TIME] = { .type = NLA_U64 },
1773 [NDTPA_GC_STALETIME] = { .type = NLA_U64 },
1774 [NDTPA_DELAY_PROBE_TIME] = { .type = NLA_U64 },
1775 [NDTPA_RETRANS_TIME] = { .type = NLA_U64 },
1776 [NDTPA_ANYCAST_DELAY] = { .type = NLA_U64 },
1777 [NDTPA_PROXY_DELAY] = { .type = NLA_U64 },
1778 [NDTPA_LOCKTIME] = { .type = NLA_U64 },
1779};
1780
1726int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1781int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1727{ 1782{
1728 struct neigh_table *tbl; 1783 struct neigh_table *tbl;
1729 struct ndtmsg *ndtmsg = NLMSG_DATA(nlh); 1784 struct ndtmsg *ndtmsg;
1730 struct rtattr **tb = arg; 1785 struct nlattr *tb[NDTA_MAX+1];
1731 int err = -EINVAL; 1786 int err;
1732 1787
1733 if (!tb[NDTA_NAME - 1] || !RTA_PAYLOAD(tb[NDTA_NAME - 1])) 1788 err = nlmsg_parse(nlh, sizeof(*ndtmsg), tb, NDTA_MAX,
1734 return -EINVAL; 1789 nl_neightbl_policy);
1790 if (err < 0)
1791 goto errout;
1792
1793 if (tb[NDTA_NAME] == NULL) {
1794 err = -EINVAL;
1795 goto errout;
1796 }
1735 1797
1798 ndtmsg = nlmsg_data(nlh);
1736 read_lock(&neigh_tbl_lock); 1799 read_lock(&neigh_tbl_lock);
1737 for (tbl = neigh_tables; tbl; tbl = tbl->next) { 1800 for (tbl = neigh_tables; tbl; tbl = tbl->next) {
1738 if (ndtmsg->ndtm_family && tbl->family != ndtmsg->ndtm_family) 1801 if (ndtmsg->ndtm_family && tbl->family != ndtmsg->ndtm_family)
1739 continue; 1802 continue;
1740 1803
1741 if (!rtattr_strcmp(tb[NDTA_NAME - 1], tbl->id)) 1804 if (nla_strcmp(tb[NDTA_NAME], tbl->id) == 0)
1742 break; 1805 break;
1743 } 1806 }
1744 1807
1745 if (tbl == NULL) { 1808 if (tbl == NULL) {
1746 err = -ENOENT; 1809 err = -ENOENT;
1747 goto errout; 1810 goto errout_locked;
1748 } 1811 }
1749 1812
1750 /* 1813 /*
@@ -1753,165 +1816,178 @@ int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1753 */ 1816 */
1754 write_lock_bh(&tbl->lock); 1817 write_lock_bh(&tbl->lock);
1755 1818
1756 if (tb[NDTA_THRESH1 - 1]) 1819 if (tb[NDTA_PARMS]) {
1757 tbl->gc_thresh1 = RTA_GET_U32(tb[NDTA_THRESH1 - 1]); 1820 struct nlattr *tbp[NDTPA_MAX+1];
1758
1759 if (tb[NDTA_THRESH2 - 1])
1760 tbl->gc_thresh2 = RTA_GET_U32(tb[NDTA_THRESH2 - 1]);
1761
1762 if (tb[NDTA_THRESH3 - 1])
1763 tbl->gc_thresh3 = RTA_GET_U32(tb[NDTA_THRESH3 - 1]);
1764
1765 if (tb[NDTA_GC_INTERVAL - 1])
1766 tbl->gc_interval = RTA_GET_MSECS(tb[NDTA_GC_INTERVAL - 1]);
1767
1768 if (tb[NDTA_PARMS - 1]) {
1769 struct rtattr *tbp[NDTPA_MAX];
1770 struct neigh_parms *p; 1821 struct neigh_parms *p;
1771 u32 ifindex = 0; 1822 int i, ifindex = 0;
1772 1823
1773 if (rtattr_parse_nested(tbp, NDTPA_MAX, tb[NDTA_PARMS - 1]) < 0) 1824 err = nla_parse_nested(tbp, NDTPA_MAX, tb[NDTA_PARMS],
1774 goto rtattr_failure; 1825 nl_ntbl_parm_policy);
1826 if (err < 0)
1827 goto errout_tbl_lock;
1775 1828
1776 if (tbp[NDTPA_IFINDEX - 1]) 1829 if (tbp[NDTPA_IFINDEX])
1777 ifindex = RTA_GET_U32(tbp[NDTPA_IFINDEX - 1]); 1830 ifindex = nla_get_u32(tbp[NDTPA_IFINDEX]);
1778 1831
1779 p = lookup_neigh_params(tbl, ifindex); 1832 p = lookup_neigh_params(tbl, ifindex);
1780 if (p == NULL) { 1833 if (p == NULL) {
1781 err = -ENOENT; 1834 err = -ENOENT;
1782 goto rtattr_failure; 1835 goto errout_tbl_lock;
1783 } 1836 }
1784
1785 if (tbp[NDTPA_QUEUE_LEN - 1])
1786 p->queue_len = RTA_GET_U32(tbp[NDTPA_QUEUE_LEN - 1]);
1787
1788 if (tbp[NDTPA_PROXY_QLEN - 1])
1789 p->proxy_qlen = RTA_GET_U32(tbp[NDTPA_PROXY_QLEN - 1]);
1790
1791 if (tbp[NDTPA_APP_PROBES - 1])
1792 p->app_probes = RTA_GET_U32(tbp[NDTPA_APP_PROBES - 1]);
1793
1794 if (tbp[NDTPA_UCAST_PROBES - 1])
1795 p->ucast_probes =
1796 RTA_GET_U32(tbp[NDTPA_UCAST_PROBES - 1]);
1797 1837
1798 if (tbp[NDTPA_MCAST_PROBES - 1]) 1838 for (i = 1; i <= NDTPA_MAX; i++) {
1799 p->mcast_probes = 1839 if (tbp[i] == NULL)
1800 RTA_GET_U32(tbp[NDTPA_MCAST_PROBES - 1]); 1840 continue;
1801
1802 if (tbp[NDTPA_BASE_REACHABLE_TIME - 1])
1803 p->base_reachable_time =
1804 RTA_GET_MSECS(tbp[NDTPA_BASE_REACHABLE_TIME - 1]);
1805 1841
1806 if (tbp[NDTPA_GC_STALETIME - 1]) 1842 switch (i) {
1807 p->gc_staletime = 1843 case NDTPA_QUEUE_LEN:
1808 RTA_GET_MSECS(tbp[NDTPA_GC_STALETIME - 1]); 1844 p->queue_len = nla_get_u32(tbp[i]);
1845 break;
1846 case NDTPA_PROXY_QLEN:
1847 p->proxy_qlen = nla_get_u32(tbp[i]);
1848 break;
1849 case NDTPA_APP_PROBES:
1850 p->app_probes = nla_get_u32(tbp[i]);
1851 break;
1852 case NDTPA_UCAST_PROBES:
1853 p->ucast_probes = nla_get_u32(tbp[i]);
1854 break;
1855 case NDTPA_MCAST_PROBES:
1856 p->mcast_probes = nla_get_u32(tbp[i]);
1857 break;
1858 case NDTPA_BASE_REACHABLE_TIME:
1859 p->base_reachable_time = nla_get_msecs(tbp[i]);
1860 break;
1861 case NDTPA_GC_STALETIME:
1862 p->gc_staletime = nla_get_msecs(tbp[i]);
1863 break;
1864 case NDTPA_DELAY_PROBE_TIME:
1865 p->delay_probe_time = nla_get_msecs(tbp[i]);
1866 break;
1867 case NDTPA_RETRANS_TIME:
1868 p->retrans_time = nla_get_msecs(tbp[i]);
1869 break;
1870 case NDTPA_ANYCAST_DELAY:
1871 p->anycast_delay = nla_get_msecs(tbp[i]);
1872 break;
1873 case NDTPA_PROXY_DELAY:
1874 p->proxy_delay = nla_get_msecs(tbp[i]);
1875 break;
1876 case NDTPA_LOCKTIME:
1877 p->locktime = nla_get_msecs(tbp[i]);
1878 break;
1879 }
1880 }
1881 }
1809 1882
1810 if (tbp[NDTPA_DELAY_PROBE_TIME - 1]) 1883 if (tb[NDTA_THRESH1])
1811 p->delay_probe_time = 1884 tbl->gc_thresh1 = nla_get_u32(tb[NDTA_THRESH1]);
1812 RTA_GET_MSECS(tbp[NDTPA_DELAY_PROBE_TIME - 1]);
1813 1885
1814 if (tbp[NDTPA_RETRANS_TIME - 1]) 1886 if (tb[NDTA_THRESH2])
1815 p->retrans_time = 1887 tbl->gc_thresh2 = nla_get_u32(tb[NDTA_THRESH2]);
1816 RTA_GET_MSECS(tbp[NDTPA_RETRANS_TIME - 1]);
1817 1888
1818 if (tbp[NDTPA_ANYCAST_DELAY - 1]) 1889 if (tb[NDTA_THRESH3])
1819 p->anycast_delay = 1890 tbl->gc_thresh3 = nla_get_u32(tb[NDTA_THRESH3]);
1820 RTA_GET_MSECS(tbp[NDTPA_ANYCAST_DELAY - 1]);
1821 1891
1822 if (tbp[NDTPA_PROXY_DELAY - 1]) 1892 if (tb[NDTA_GC_INTERVAL])
1823 p->proxy_delay = 1893 tbl->gc_interval = nla_get_msecs(tb[NDTA_GC_INTERVAL]);
1824 RTA_GET_MSECS(tbp[NDTPA_PROXY_DELAY - 1]);
1825
1826 if (tbp[NDTPA_LOCKTIME - 1])
1827 p->locktime = RTA_GET_MSECS(tbp[NDTPA_LOCKTIME - 1]);
1828 }
1829 1894
1830 err = 0; 1895 err = 0;
1831 1896
1832rtattr_failure: 1897errout_tbl_lock:
1833 write_unlock_bh(&tbl->lock); 1898 write_unlock_bh(&tbl->lock);
1834errout: 1899errout_locked:
1835 read_unlock(&neigh_tbl_lock); 1900 read_unlock(&neigh_tbl_lock);
1901errout:
1836 return err; 1902 return err;
1837} 1903}
1838 1904
1839int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) 1905int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
1840{ 1906{
1841 int idx, family; 1907 int family, tidx, nidx = 0;
1842 int s_idx = cb->args[0]; 1908 int tbl_skip = cb->args[0];
1909 int neigh_skip = cb->args[1];
1843 struct neigh_table *tbl; 1910 struct neigh_table *tbl;
1844 1911
1845 family = ((struct rtgenmsg *)NLMSG_DATA(cb->nlh))->rtgen_family; 1912 family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family;
1846 1913
1847 read_lock(&neigh_tbl_lock); 1914 read_lock(&neigh_tbl_lock);
1848 for (tbl = neigh_tables, idx = 0; tbl; tbl = tbl->next) { 1915 for (tbl = neigh_tables, tidx = 0; tbl; tbl = tbl->next, tidx++) {
1849 struct neigh_parms *p; 1916 struct neigh_parms *p;
1850 1917
1851 if (idx < s_idx || (family && tbl->family != family)) 1918 if (tidx < tbl_skip || (family && tbl->family != family))
1852 continue; 1919 continue;
1853 1920
1854 if (neightbl_fill_info(tbl, skb, cb) <= 0) 1921 if (neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).pid,
1922 cb->nlh->nlmsg_seq, RTM_NEWNEIGHTBL,
1923 NLM_F_MULTI) <= 0)
1855 break; 1924 break;
1856 1925
1857 for (++idx, p = tbl->parms.next; p; p = p->next, idx++) { 1926 for (nidx = 0, p = tbl->parms.next; p; p = p->next, nidx++) {
1858 if (idx < s_idx) 1927 if (nidx < neigh_skip)
1859 continue; 1928 continue;
1860 1929
1861 if (neightbl_fill_param_info(tbl, p, skb, cb) <= 0) 1930 if (neightbl_fill_param_info(skb, tbl, p,
1931 NETLINK_CB(cb->skb).pid,
1932 cb->nlh->nlmsg_seq,
1933 RTM_NEWNEIGHTBL,
1934 NLM_F_MULTI) <= 0)
1862 goto out; 1935 goto out;
1863 } 1936 }
1864 1937
1938 neigh_skip = 0;
1865 } 1939 }
1866out: 1940out:
1867 read_unlock(&neigh_tbl_lock); 1941 read_unlock(&neigh_tbl_lock);
1868 cb->args[0] = idx; 1942 cb->args[0] = tidx;
1943 cb->args[1] = nidx;
1869 1944
1870 return skb->len; 1945 return skb->len;
1871} 1946}
1872 1947
1873static int neigh_fill_info(struct sk_buff *skb, struct neighbour *n, 1948static int neigh_fill_info(struct sk_buff *skb, struct neighbour *neigh,
1874 u32 pid, u32 seq, int event, unsigned int flags) 1949 u32 pid, u32 seq, int type, unsigned int flags)
1875{ 1950{
1876 unsigned long now = jiffies; 1951 unsigned long now = jiffies;
1877 unsigned char *b = skb->tail;
1878 struct nda_cacheinfo ci; 1952 struct nda_cacheinfo ci;
1879 int locked = 0; 1953 struct nlmsghdr *nlh;
1880 u32 probes; 1954 struct ndmsg *ndm;
1881 struct nlmsghdr *nlh = NLMSG_NEW(skb, pid, seq, event,
1882 sizeof(struct ndmsg), flags);
1883 struct ndmsg *ndm = NLMSG_DATA(nlh);
1884 1955
1885 ndm->ndm_family = n->ops->family; 1956 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ndm), flags);
1957 if (nlh == NULL)
1958 return -ENOBUFS;
1959
1960 ndm = nlmsg_data(nlh);
1961 ndm->ndm_family = neigh->ops->family;
1886 ndm->ndm_pad1 = 0; 1962 ndm->ndm_pad1 = 0;
1887 ndm->ndm_pad2 = 0; 1963 ndm->ndm_pad2 = 0;
1888 ndm->ndm_flags = n->flags; 1964 ndm->ndm_flags = neigh->flags;
1889 ndm->ndm_type = n->type; 1965 ndm->ndm_type = neigh->type;
1890 ndm->ndm_ifindex = n->dev->ifindex; 1966 ndm->ndm_ifindex = neigh->dev->ifindex;
1891 RTA_PUT(skb, NDA_DST, n->tbl->key_len, n->primary_key); 1967
1892 read_lock_bh(&n->lock); 1968 NLA_PUT(skb, NDA_DST, neigh->tbl->key_len, neigh->primary_key);
1893 locked = 1;
1894 ndm->ndm_state = n->nud_state;
1895 if (n->nud_state & NUD_VALID)
1896 RTA_PUT(skb, NDA_LLADDR, n->dev->addr_len, n->ha);
1897 ci.ndm_used = now - n->used;
1898 ci.ndm_confirmed = now - n->confirmed;
1899 ci.ndm_updated = now - n->updated;
1900 ci.ndm_refcnt = atomic_read(&n->refcnt) - 1;
1901 probes = atomic_read(&n->probes);
1902 read_unlock_bh(&n->lock);
1903 locked = 0;
1904 RTA_PUT(skb, NDA_CACHEINFO, sizeof(ci), &ci);
1905 RTA_PUT(skb, NDA_PROBES, sizeof(probes), &probes);
1906 nlh->nlmsg_len = skb->tail - b;
1907 return skb->len;
1908 1969
1909nlmsg_failure: 1970 read_lock_bh(&neigh->lock);
1910rtattr_failure: 1971 ndm->ndm_state = neigh->nud_state;
1911 if (locked) 1972 if ((neigh->nud_state & NUD_VALID) &&
1912 read_unlock_bh(&n->lock); 1973 nla_put(skb, NDA_LLADDR, neigh->dev->addr_len, neigh->ha) < 0) {
1913 skb_trim(skb, b - skb->data); 1974 read_unlock_bh(&neigh->lock);
1914 return -1; 1975 goto nla_put_failure;
1976 }
1977
1978 ci.ndm_used = now - neigh->used;
1979 ci.ndm_confirmed = now - neigh->confirmed;
1980 ci.ndm_updated = now - neigh->updated;
1981 ci.ndm_refcnt = atomic_read(&neigh->refcnt) - 1;
1982 read_unlock_bh(&neigh->lock);
1983
1984 NLA_PUT_U32(skb, NDA_PROBES, atomic_read(&neigh->probes));
1985 NLA_PUT(skb, NDA_CACHEINFO, sizeof(ci), &ci);
1986
1987 return nlmsg_end(skb, nlh);
1988
1989nla_put_failure:
1990 return nlmsg_cancel(skb, nlh);
1915} 1991}
1916 1992
1917 1993
@@ -1955,7 +2031,7 @@ int neigh_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
1955 int t, family, s_t; 2031 int t, family, s_t;
1956 2032
1957 read_lock(&neigh_tbl_lock); 2033 read_lock(&neigh_tbl_lock);
1958 family = ((struct rtgenmsg *)NLMSG_DATA(cb->nlh))->rtgen_family; 2034 family = ((struct rtgenmsg *) nlmsg_data(cb->nlh))->rtgen_family;
1959 s_t = cb->args[0]; 2035 s_t = cb->args[0];
1960 2036
1961 for (tbl = neigh_tables, t = 0; tbl; tbl = tbl->next, t++) { 2037 for (tbl = neigh_tables, t = 0; tbl; tbl = tbl->next, t++) {
@@ -2334,41 +2410,35 @@ static struct file_operations neigh_stat_seq_fops = {
2334#endif /* CONFIG_PROC_FS */ 2410#endif /* CONFIG_PROC_FS */
2335 2411
2336#ifdef CONFIG_ARPD 2412#ifdef CONFIG_ARPD
2337void neigh_app_ns(struct neighbour *n) 2413static void __neigh_notify(struct neighbour *n, int type, int flags)
2338{ 2414{
2339 struct nlmsghdr *nlh; 2415 struct sk_buff *skb;
2340 int size = NLMSG_SPACE(sizeof(struct ndmsg) + 256); 2416 int err = -ENOBUFS;
2341 struct sk_buff *skb = alloc_skb(size, GFP_ATOMIC);
2342 2417
2343 if (!skb) 2418 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
2344 return; 2419 if (skb == NULL)
2420 goto errout;
2345 2421
2346 if (neigh_fill_info(skb, n, 0, 0, RTM_GETNEIGH, 0) < 0) { 2422 err = neigh_fill_info(skb, n, 0, 0, type, flags);
2423 if (err < 0) {
2347 kfree_skb(skb); 2424 kfree_skb(skb);
2348 return; 2425 goto errout;
2349 } 2426 }
2350 nlh = (struct nlmsghdr *)skb->data; 2427
2351 nlh->nlmsg_flags = NLM_F_REQUEST; 2428 err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
2352 NETLINK_CB(skb).dst_group = RTNLGRP_NEIGH; 2429errout:
2353 netlink_broadcast(rtnl, skb, 0, RTNLGRP_NEIGH, GFP_ATOMIC); 2430 if (err < 0)
2431 rtnl_set_sk_err(RTNLGRP_NEIGH, err);
2354} 2432}
2355 2433
2356static void neigh_app_notify(struct neighbour *n) 2434void neigh_app_ns(struct neighbour *n)
2357{ 2435{
2358 struct nlmsghdr *nlh; 2436 __neigh_notify(n, RTM_GETNEIGH, NLM_F_REQUEST);
2359 int size = NLMSG_SPACE(sizeof(struct ndmsg) + 256); 2437}
2360 struct sk_buff *skb = alloc_skb(size, GFP_ATOMIC);
2361
2362 if (!skb)
2363 return;
2364 2438
2365 if (neigh_fill_info(skb, n, 0, 0, RTM_NEWNEIGH, 0) < 0) { 2439static void neigh_app_notify(struct neighbour *n)
2366 kfree_skb(skb); 2440{
2367 return; 2441 __neigh_notify(n, RTM_NEWNEIGH, 0);
2368 }
2369 nlh = (struct nlmsghdr *)skb->data;
2370 NETLINK_CB(skb).dst_group = RTNLGRP_NEIGH;
2371 netlink_broadcast(rtnl, skb, 0, RTNLGRP_NEIGH, GFP_ATOMIC);
2372} 2442}
2373 2443
2374#endif /* CONFIG_ARPD */ 2444#endif /* CONFIG_ARPD */
@@ -2382,7 +2452,7 @@ static struct neigh_sysctl_table {
2382 ctl_table neigh_neigh_dir[2]; 2452 ctl_table neigh_neigh_dir[2];
2383 ctl_table neigh_proto_dir[2]; 2453 ctl_table neigh_proto_dir[2];
2384 ctl_table neigh_root_dir[2]; 2454 ctl_table neigh_root_dir[2];
2385} neigh_sysctl_template = { 2455} neigh_sysctl_template __read_mostly = {
2386 .neigh_vars = { 2456 .neigh_vars = {
2387 { 2457 {
2388 .ctl_name = NET_NEIGH_MCAST_SOLICIT, 2458 .ctl_name = NET_NEIGH_MCAST_SOLICIT,
@@ -2655,7 +2725,6 @@ void neigh_sysctl_unregister(struct neigh_parms *p)
2655#endif /* CONFIG_SYSCTL */ 2725#endif /* CONFIG_SYSCTL */
2656 2726
2657EXPORT_SYMBOL(__neigh_event_send); 2727EXPORT_SYMBOL(__neigh_event_send);
2658EXPORT_SYMBOL(neigh_add);
2659EXPORT_SYMBOL(neigh_changeaddr); 2728EXPORT_SYMBOL(neigh_changeaddr);
2660EXPORT_SYMBOL(neigh_compat_output); 2729EXPORT_SYMBOL(neigh_compat_output);
2661EXPORT_SYMBOL(neigh_connected_output); 2730EXPORT_SYMBOL(neigh_connected_output);
@@ -2675,11 +2744,8 @@ EXPORT_SYMBOL(neigh_table_clear);
2675EXPORT_SYMBOL(neigh_table_init); 2744EXPORT_SYMBOL(neigh_table_init);
2676EXPORT_SYMBOL(neigh_table_init_no_netlink); 2745EXPORT_SYMBOL(neigh_table_init_no_netlink);
2677EXPORT_SYMBOL(neigh_update); 2746EXPORT_SYMBOL(neigh_update);
2678EXPORT_SYMBOL(neigh_update_hhs);
2679EXPORT_SYMBOL(pneigh_enqueue); 2747EXPORT_SYMBOL(pneigh_enqueue);
2680EXPORT_SYMBOL(pneigh_lookup); 2748EXPORT_SYMBOL(pneigh_lookup);
2681EXPORT_SYMBOL(neightbl_dump_info);
2682EXPORT_SYMBOL(neightbl_set);
2683 2749
2684#ifdef CONFIG_ARPD 2750#ifdef CONFIG_ARPD
2685EXPORT_SYMBOL(neigh_app_ns); 2751EXPORT_SYMBOL(neigh_app_ns);