aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-07-18 02:09:49 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-18 02:11:35 -0400
commit69cce1d1404968f78b177a0314f5822d5afdbbfb (patch)
tree26223264fd69ea8078d0013fd5a76eb7aeb04c12
parent9cbb7ecbcff85077bb12301aaf4c9b5a56c5993d (diff)
net: Abstract dst->neighbour accesses behind helpers.
dst_{get,set}_neighbour() Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/infiniband/core/addr.c7
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c12
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c42
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c41
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c20
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c8
-rw-r--r--drivers/s390/net/qeth_l3_main.c25
-rw-r--r--drivers/scsi/cxgbi/cxgb3i/cxgb3i.c2
-rw-r--r--drivers/scsi/cxgbi/cxgb4i/cxgb4i.c2
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c4
-rw-r--r--include/net/dst.h18
-rw-r--r--net/atm/clip.c16
-rw-r--r--net/bridge/br_netfilter.c2
-rw-r--r--net/core/dst.c10
-rw-r--r--net/core/neighbour.c7
-rw-r--r--net/decnet/dn_neigh.c2
-rw-r--r--net/decnet/dn_route.c18
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/route.c25
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/ip6_fib.c2
-rw-r--r--net/ipv6/ip6_output.c16
-rw-r--r--net/ipv6/ndisc.c4
-rw-r--r--net/ipv6/route.c39
-rw-r--r--net/ipv6/sit.c4
-rw-r--r--net/sched/sch_teql.c4
-rw-r--r--net/xfrm/xfrm_policy.c2
29 files changed, 200 insertions, 140 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 8e21d457b899..236ad9a89c0a 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -215,7 +215,7 @@ static int addr4_resolve(struct sockaddr_in *src_in,
215 215
216 neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->dst.dev); 216 neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->dst.dev);
217 if (!neigh || !(neigh->nud_state & NUD_VALID)) { 217 if (!neigh || !(neigh->nud_state & NUD_VALID)) {
218 neigh_event_send(rt->dst.neighbour, NULL); 218 neigh_event_send(dst_get_neighbour(&rt->dst), NULL);
219 ret = -ENODATA; 219 ret = -ENODATA;
220 if (neigh) 220 if (neigh)
221 goto release; 221 goto release;
@@ -273,9 +273,10 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
273 goto put; 273 goto put;
274 } 274 }
275 275
276 neigh = dst->neighbour; 276 neigh = dst_get_neighbour(dst);
277 if (!neigh || !(neigh->nud_state & NUD_VALID)) { 277 if (!neigh || !(neigh->nud_state & NUD_VALID)) {
278 neigh_event_send(dst->neighbour, NULL); 278 if (neigh)
279 neigh_event_send(neigh, NULL);
279 ret = -ENODATA; 280 ret = -ENODATA;
280 goto put; 281 goto put;
281 } 282 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 0a5008fbebac..17bf9d95463c 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -1328,6 +1328,7 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
1328 struct iwch_ep *child_ep, *parent_ep = ctx; 1328 struct iwch_ep *child_ep, *parent_ep = ctx;
1329 struct cpl_pass_accept_req *req = cplhdr(skb); 1329 struct cpl_pass_accept_req *req = cplhdr(skb);
1330 unsigned int hwtid = GET_TID(req); 1330 unsigned int hwtid = GET_TID(req);
1331 struct neighbour *neigh;
1331 struct dst_entry *dst; 1332 struct dst_entry *dst;
1332 struct l2t_entry *l2t; 1333 struct l2t_entry *l2t;
1333 struct rtable *rt; 1334 struct rtable *rt;
@@ -1364,7 +1365,8 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
1364 goto reject; 1365 goto reject;
1365 } 1366 }
1366 dst = &rt->dst; 1367 dst = &rt->dst;
1367 l2t = t3_l2t_get(tdev, dst->neighbour, dst->neighbour->dev); 1368 neigh = dst_get_neighbour(dst);
1369 l2t = t3_l2t_get(tdev, neigh, neigh->dev);
1368 if (!l2t) { 1370 if (!l2t) {
1369 printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n", 1371 printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n",
1370 __func__); 1372 __func__);
@@ -1874,10 +1876,11 @@ static int is_loopback_dst(struct iw_cm_id *cm_id)
1874 1876
1875int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 1877int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1876{ 1878{
1877 int err = 0;
1878 struct iwch_dev *h = to_iwch_dev(cm_id->device); 1879 struct iwch_dev *h = to_iwch_dev(cm_id->device);
1880 struct neighbour *neigh;
1879 struct iwch_ep *ep; 1881 struct iwch_ep *ep;
1880 struct rtable *rt; 1882 struct rtable *rt;
1883 int err = 0;
1881 1884
1882 if (is_loopback_dst(cm_id)) { 1885 if (is_loopback_dst(cm_id)) {
1883 err = -ENOSYS; 1886 err = -ENOSYS;
@@ -1933,9 +1936,10 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1933 } 1936 }
1934 ep->dst = &rt->dst; 1937 ep->dst = &rt->dst;
1935 1938
1939 neigh = dst_get_neighbour(ep->dst);
1940
1936 /* get a l2t entry */ 1941 /* get a l2t entry */
1937 ep->l2t = t3_l2t_get(ep->com.tdev, ep->dst->neighbour, 1942 ep->l2t = t3_l2t_get(ep->com.tdev, neigh, neigh->dev);
1938 ep->dst->neighbour->dev);
1939 if (!ep->l2t) { 1943 if (!ep->l2t) {
1940 printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); 1944 printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
1941 err = -ENOMEM; 1945 err = -ENOMEM;
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 31fb44085c9b..77f769d9227d 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -1325,6 +1325,7 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
1325 unsigned int stid = GET_POPEN_TID(ntohl(req->tos_stid)); 1325 unsigned int stid = GET_POPEN_TID(ntohl(req->tos_stid));
1326 struct tid_info *t = dev->rdev.lldi.tids; 1326 struct tid_info *t = dev->rdev.lldi.tids;
1327 unsigned int hwtid = GET_TID(req); 1327 unsigned int hwtid = GET_TID(req);
1328 struct neighbour *neigh;
1328 struct dst_entry *dst; 1329 struct dst_entry *dst;
1329 struct l2t_entry *l2t; 1330 struct l2t_entry *l2t;
1330 struct rtable *rt; 1331 struct rtable *rt;
@@ -1357,11 +1358,11 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
1357 goto reject; 1358 goto reject;
1358 } 1359 }
1359 dst = &rt->dst; 1360 dst = &rt->dst;
1360 if (dst->neighbour->dev->flags & IFF_LOOPBACK) { 1361 neigh = dst_get_neighbour(dst);
1362 if (neigh->dev->flags & IFF_LOOPBACK) {
1361 pdev = ip_dev_find(&init_net, peer_ip); 1363 pdev = ip_dev_find(&init_net, peer_ip);
1362 BUG_ON(!pdev); 1364 BUG_ON(!pdev);
1363 l2t = cxgb4_l2t_get(dev->rdev.lldi.l2t, dst->neighbour, 1365 l2t = cxgb4_l2t_get(dev->rdev.lldi.l2t, neigh, pdev, 0);
1364 pdev, 0);
1365 mtu = pdev->mtu; 1366 mtu = pdev->mtu;
1366 tx_chan = cxgb4_port_chan(pdev); 1367 tx_chan = cxgb4_port_chan(pdev);
1367 smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1; 1368 smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1;
@@ -1372,17 +1373,16 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
1372 rss_qid = dev->rdev.lldi.rxq_ids[cxgb4_port_idx(pdev) * step]; 1373 rss_qid = dev->rdev.lldi.rxq_ids[cxgb4_port_idx(pdev) * step];
1373 dev_put(pdev); 1374 dev_put(pdev);
1374 } else { 1375 } else {
1375 l2t = cxgb4_l2t_get(dev->rdev.lldi.l2t, dst->neighbour, 1376 l2t = cxgb4_l2t_get(dev->rdev.lldi.l2t, neigh, neigh->dev, 0);
1376 dst->neighbour->dev, 0);
1377 mtu = dst_mtu(dst); 1377 mtu = dst_mtu(dst);
1378 tx_chan = cxgb4_port_chan(dst->neighbour->dev); 1378 tx_chan = cxgb4_port_chan(neigh->dev);
1379 smac_idx = (cxgb4_port_viid(dst->neighbour->dev) & 0x7F) << 1; 1379 smac_idx = (cxgb4_port_viid(neigh->dev) & 0x7F) << 1;
1380 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan; 1380 step = dev->rdev.lldi.ntxq / dev->rdev.lldi.nchan;
1381 txq_idx = cxgb4_port_idx(dst->neighbour->dev) * step; 1381 txq_idx = cxgb4_port_idx(neigh->dev) * step;
1382 ctrlq_idx = cxgb4_port_idx(dst->neighbour->dev); 1382 ctrlq_idx = cxgb4_port_idx(neigh->dev);
1383 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan; 1383 step = dev->rdev.lldi.nrxq / dev->rdev.lldi.nchan;
1384 rss_qid = dev->rdev.lldi.rxq_ids[ 1384 rss_qid = dev->rdev.lldi.rxq_ids[
1385 cxgb4_port_idx(dst->neighbour->dev) * step]; 1385 cxgb4_port_idx(neigh->dev) * step];
1386 } 1386 }
1387 if (!l2t) { 1387 if (!l2t) {
1388 printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n", 1388 printk(KERN_ERR MOD "%s - failed to allocate l2t entry!\n",
@@ -1847,6 +1847,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1847 struct c4iw_ep *ep; 1847 struct c4iw_ep *ep;
1848 struct rtable *rt; 1848 struct rtable *rt;
1849 struct net_device *pdev; 1849 struct net_device *pdev;
1850 struct neighbour *neigh;
1850 int step; 1851 int step;
1851 1852
1852 if ((conn_param->ord > c4iw_max_read_depth) || 1853 if ((conn_param->ord > c4iw_max_read_depth) ||
@@ -1908,14 +1909,15 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1908 } 1909 }
1909 ep->dst = &rt->dst; 1910 ep->dst = &rt->dst;
1910 1911
1912 neigh = dst_get_neighbour(ep->dst);
1913
1911 /* get a l2t entry */ 1914 /* get a l2t entry */
1912 if (ep->dst->neighbour->dev->flags & IFF_LOOPBACK) { 1915 if (neigh->dev->flags & IFF_LOOPBACK) {
1913 PDBG("%s LOOPBACK\n", __func__); 1916 PDBG("%s LOOPBACK\n", __func__);
1914 pdev = ip_dev_find(&init_net, 1917 pdev = ip_dev_find(&init_net,
1915 cm_id->remote_addr.sin_addr.s_addr); 1918 cm_id->remote_addr.sin_addr.s_addr);
1916 ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t, 1919 ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t,
1917 ep->dst->neighbour, 1920 neigh, pdev, 0);
1918 pdev, 0);
1919 ep->mtu = pdev->mtu; 1921 ep->mtu = pdev->mtu;
1920 ep->tx_chan = cxgb4_port_chan(pdev); 1922 ep->tx_chan = cxgb4_port_chan(pdev);
1921 ep->smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1; 1923 ep->smac_idx = (cxgb4_port_viid(pdev) & 0x7F) << 1;
@@ -1930,20 +1932,18 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1930 dev_put(pdev); 1932 dev_put(pdev);
1931 } else { 1933 } else {
1932 ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t, 1934 ep->l2t = cxgb4_l2t_get(ep->com.dev->rdev.lldi.l2t,
1933 ep->dst->neighbour, 1935 neigh, neigh->dev, 0);
1934 ep->dst->neighbour->dev, 0);
1935 ep->mtu = dst_mtu(ep->dst); 1936 ep->mtu = dst_mtu(ep->dst);
1936 ep->tx_chan = cxgb4_port_chan(ep->dst->neighbour->dev); 1937 ep->tx_chan = cxgb4_port_chan(neigh->dev);
1937 ep->smac_idx = (cxgb4_port_viid(ep->dst->neighbour->dev) & 1938 ep->smac_idx = (cxgb4_port_viid(neigh->dev) & 0x7F) << 1;
1938 0x7F) << 1;
1939 step = ep->com.dev->rdev.lldi.ntxq / 1939 step = ep->com.dev->rdev.lldi.ntxq /
1940 ep->com.dev->rdev.lldi.nchan; 1940 ep->com.dev->rdev.lldi.nchan;
1941 ep->txq_idx = cxgb4_port_idx(ep->dst->neighbour->dev) * step; 1941 ep->txq_idx = cxgb4_port_idx(neigh->dev) * step;
1942 ep->ctrlq_idx = cxgb4_port_idx(ep->dst->neighbour->dev); 1942 ep->ctrlq_idx = cxgb4_port_idx(neigh->dev);
1943 step = ep->com.dev->rdev.lldi.nrxq / 1943 step = ep->com.dev->rdev.lldi.nrxq /
1944 ep->com.dev->rdev.lldi.nchan; 1944 ep->com.dev->rdev.lldi.nchan;
1945 ep->rss_qid = ep->com.dev->rdev.lldi.rxq_ids[ 1945 ep->rss_qid = ep->com.dev->rdev.lldi.rxq_ids[
1946 cxgb4_port_idx(ep->dst->neighbour->dev) * step]; 1946 cxgb4_port_idx(neigh->dev) * step];
1947 } 1947 }
1948 if (!ep->l2t) { 1948 if (!ep->l2t) {
1949 printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__); 1949 printk(KERN_ERR MOD "%s - cannot alloc l2e.\n", __func__);
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index e74cdf9ef471..73bc18465c9c 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1151,7 +1151,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
1151 } 1151 }
1152 1152
1153 if ((neigh == NULL) || (!(neigh->nud_state & NUD_VALID))) 1153 if ((neigh == NULL) || (!(neigh->nud_state & NUD_VALID)))
1154 neigh_event_send(rt->dst.neighbour, NULL); 1154 neigh_event_send(dst_get_neighbour(&rt->dst), NULL);
1155 1155
1156 ip_rt_put(rt); 1156 ip_rt_put(rt);
1157 return rc; 1157 return rc;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 86addca9ddf6..43f89ba0a908 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -560,9 +560,11 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
560 struct ipoib_dev_priv *priv = netdev_priv(dev); 560 struct ipoib_dev_priv *priv = netdev_priv(dev);
561 struct ipoib_path *path; 561 struct ipoib_path *path;
562 struct ipoib_neigh *neigh; 562 struct ipoib_neigh *neigh;
563 struct neighbour *n;
563 unsigned long flags; 564 unsigned long flags;
564 565
565 neigh = ipoib_neigh_alloc(skb_dst(skb)->neighbour, skb->dev); 566 n = dst_get_neighbour(skb_dst(skb));
567 neigh = ipoib_neigh_alloc(n, skb->dev);
566 if (!neigh) { 568 if (!neigh) {
567 ++dev->stats.tx_dropped; 569 ++dev->stats.tx_dropped;
568 dev_kfree_skb_any(skb); 570 dev_kfree_skb_any(skb);
@@ -571,9 +573,9 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
571 573
572 spin_lock_irqsave(&priv->lock, flags); 574 spin_lock_irqsave(&priv->lock, flags);
573 575
574 path = __path_find(dev, skb_dst(skb)->neighbour->ha + 4); 576 path = __path_find(dev, n->ha + 4);
575 if (!path) { 577 if (!path) {
576 path = path_rec_create(dev, skb_dst(skb)->neighbour->ha + 4); 578 path = path_rec_create(dev, n->ha + 4);
577 if (!path) 579 if (!path)
578 goto err_path; 580 goto err_path;
579 581
@@ -607,7 +609,7 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
607 } 609 }
608 } else { 610 } else {
609 spin_unlock_irqrestore(&priv->lock, flags); 611 spin_unlock_irqrestore(&priv->lock, flags);
610 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb_dst(skb)->neighbour->ha)); 612 ipoib_send(dev, skb, path->ah, IPOIB_QPN(n->ha));
611 return; 613 return;
612 } 614 }
613 } else { 615 } else {
@@ -637,17 +639,20 @@ err_drop:
637static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev) 639static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev)
638{ 640{
639 struct ipoib_dev_priv *priv = netdev_priv(skb->dev); 641 struct ipoib_dev_priv *priv = netdev_priv(skb->dev);
642 struct dst_entry *dst = skb_dst(skb);
643 struct neighbour *n;
640 644
641 /* Look up path record for unicasts */ 645 /* Look up path record for unicasts */
642 if (skb_dst(skb)->neighbour->ha[4] != 0xff) { 646 n = dst_get_neighbour(dst);
647 if (n->ha[4] != 0xff) {
643 neigh_add_path(skb, dev); 648 neigh_add_path(skb, dev);
644 return; 649 return;
645 } 650 }
646 651
647 /* Add in the P_Key for multicasts */ 652 /* Add in the P_Key for multicasts */
648 skb_dst(skb)->neighbour->ha[8] = (priv->pkey >> 8) & 0xff; 653 n->ha[8] = (priv->pkey >> 8) & 0xff;
649 skb_dst(skb)->neighbour->ha[9] = priv->pkey & 0xff; 654 n->ha[9] = priv->pkey & 0xff;
650 ipoib_mcast_send(dev, skb_dst(skb)->neighbour->ha + 4, skb); 655 ipoib_mcast_send(dev, n->ha + 4, skb);
651} 656}
652 657
653static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, 658static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
@@ -712,18 +717,20 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
712{ 717{
713 struct ipoib_dev_priv *priv = netdev_priv(dev); 718 struct ipoib_dev_priv *priv = netdev_priv(dev);
714 struct ipoib_neigh *neigh; 719 struct ipoib_neigh *neigh;
720 struct neighbour *n;
715 unsigned long flags; 721 unsigned long flags;
716 722
717 if (likely(skb_dst(skb) && skb_dst(skb)->neighbour)) { 723 n = dst_get_neighbour(skb_dst(skb));
718 if (unlikely(!*to_ipoib_neigh(skb_dst(skb)->neighbour))) { 724 if (likely(skb_dst(skb) && n)) {
725 if (unlikely(!*to_ipoib_neigh(n))) {
719 ipoib_path_lookup(skb, dev); 726 ipoib_path_lookup(skb, dev);
720 return NETDEV_TX_OK; 727 return NETDEV_TX_OK;
721 } 728 }
722 729
723 neigh = *to_ipoib_neigh(skb_dst(skb)->neighbour); 730 neigh = *to_ipoib_neigh(n);
724 731
725 if (unlikely((memcmp(&neigh->dgid.raw, 732 if (unlikely((memcmp(&neigh->dgid.raw,
726 skb_dst(skb)->neighbour->ha + 4, 733 n->ha + 4,
727 sizeof(union ib_gid))) || 734 sizeof(union ib_gid))) ||
728 (neigh->dev != dev))) { 735 (neigh->dev != dev))) {
729 spin_lock_irqsave(&priv->lock, flags); 736 spin_lock_irqsave(&priv->lock, flags);
@@ -749,7 +756,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
749 return NETDEV_TX_OK; 756 return NETDEV_TX_OK;
750 } 757 }
751 } else if (neigh->ah) { 758 } else if (neigh->ah) {
752 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb_dst(skb)->neighbour->ha)); 759 ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(n->ha));
753 return NETDEV_TX_OK; 760 return NETDEV_TX_OK;
754 } 761 }
755 762
@@ -812,6 +819,8 @@ static int ipoib_hard_header(struct sk_buff *skb,
812 const void *daddr, const void *saddr, unsigned len) 819 const void *daddr, const void *saddr, unsigned len)
813{ 820{
814 struct ipoib_header *header; 821 struct ipoib_header *header;
822 struct dst_entry *dst;
823 struct neighbour *n;
815 824
816 header = (struct ipoib_header *) skb_push(skb, sizeof *header); 825 header = (struct ipoib_header *) skb_push(skb, sizeof *header);
817 826
@@ -823,7 +832,11 @@ static int ipoib_hard_header(struct sk_buff *skb,
823 * destination address onto the front of the skb so we can 832 * destination address onto the front of the skb so we can
824 * figure out where to send the packet later. 833 * figure out where to send the packet later.
825 */ 834 */
826 if ((!skb_dst(skb) || !skb_dst(skb)->neighbour) && daddr) { 835 dst = skb_dst(skb);
836 n = NULL;
837 if (dst)
838 n = dst_get_neighbour(dst);
839 if ((!dst || !n) && daddr) {
827 struct ipoib_pseudoheader *phdr = 840 struct ipoib_pseudoheader *phdr =
828 (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr); 841 (struct ipoib_pseudoheader *) skb_push(skb, sizeof *phdr);
829 memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN); 842 memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 3871ac663554..ecea4fe1ed00 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -258,11 +258,15 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
258 netif_tx_lock_bh(dev); 258 netif_tx_lock_bh(dev);
259 while (!skb_queue_empty(&mcast->pkt_queue)) { 259 while (!skb_queue_empty(&mcast->pkt_queue)) {
260 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue); 260 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue);
261 struct dst_entry *dst = skb_dst(skb);
262 struct neighbour *n = NULL;
263
261 netif_tx_unlock_bh(dev); 264 netif_tx_unlock_bh(dev);
262 265
263 skb->dev = dev; 266 skb->dev = dev;
264 267 if (dst)
265 if (!skb_dst(skb) || !skb_dst(skb)->neighbour) { 268 n = dst_get_neighbour(dst);
269 if (!dst || !n) {
266 /* put pseudoheader back on for next time */ 270 /* put pseudoheader back on for next time */
267 skb_push(skb, sizeof (struct ipoib_pseudoheader)); 271 skb_push(skb, sizeof (struct ipoib_pseudoheader));
268 } 272 }
@@ -715,11 +719,13 @@ void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb)
715 719
716out: 720out:
717 if (mcast && mcast->ah) { 721 if (mcast && mcast->ah) {
718 if (skb_dst(skb) && 722 struct dst_entry *dst = skb_dst(skb);
719 skb_dst(skb)->neighbour && 723 struct neighbour *n = NULL;
720 !*to_ipoib_neigh(skb_dst(skb)->neighbour)) { 724 if (dst)
721 struct ipoib_neigh *neigh = ipoib_neigh_alloc(skb_dst(skb)->neighbour, 725 n = dst_get_neighbour(dst);
722 skb->dev); 726 if (n && !*to_ipoib_neigh(n)) {
727 struct ipoib_neigh *neigh = ipoib_neigh_alloc(n,
728 skb->dev);
723 729
724 if (neigh) { 730 if (neigh) {
725 kref_get(&mcast->ah->ref); 731 kref_get(&mcast->ah->ref);
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index 9db9068d29d2..fa1b450af825 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -971,7 +971,7 @@ static int nb_callback(struct notifier_block *self, unsigned long event,
971 case (NETEVENT_REDIRECT):{ 971 case (NETEVENT_REDIRECT):{
972 struct netevent_redirect *nr = ctx; 972 struct netevent_redirect *nr = ctx;
973 cxgb_redirect(nr->old, nr->new); 973 cxgb_redirect(nr->old, nr->new);
974 cxgb_neigh_update(nr->new->neighbour); 974 cxgb_neigh_update(dst_get_neighbour(nr->new));
975 break; 975 break;
976 } 976 }
977 default: 977 default:
@@ -1116,8 +1116,8 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
1116 struct l2t_entry *e; 1116 struct l2t_entry *e;
1117 struct t3c_tid_entry *te; 1117 struct t3c_tid_entry *te;
1118 1118
1119 olddev = old->neighbour->dev; 1119 olddev = dst_get_neighbour(old)->dev;
1120 newdev = new->neighbour->dev; 1120 newdev = dst_get_neighbour(new)->dev;
1121 if (!is_offloading(olddev)) 1121 if (!is_offloading(olddev))
1122 return; 1122 return;
1123 if (!is_offloading(newdev)) { 1123 if (!is_offloading(newdev)) {
@@ -1134,7 +1134,7 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
1134 } 1134 }
1135 1135
1136 /* Add new L2T entry */ 1136 /* Add new L2T entry */
1137 e = t3_l2t_get(tdev, new->neighbour, newdev); 1137 e = t3_l2t_get(tdev, dst_get_neighbour(new), newdev);
1138 if (!e) { 1138 if (!e) {
1139 printk(KERN_ERR "%s: couldn't allocate new l2t entry!\n", 1139 printk(KERN_ERR "%s: couldn't allocate new l2t entry!\n",
1140 __func__); 1140 __func__);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index fd69da3fa6b4..e2c9ac5fcb36 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2742,9 +2742,14 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2742int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb) 2742int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
2743{ 2743{
2744 int cast_type = RTN_UNSPEC; 2744 int cast_type = RTN_UNSPEC;
2745 2745 struct neighbour *n = NULL;
2746 if (skb_dst(skb) && skb_dst(skb)->neighbour) { 2746 struct dst_entry *dst;
2747 cast_type = skb_dst(skb)->neighbour->type; 2747
2748 dst = skb_dst(skb);
2749 if (dst)
2750 n = dst_get_neighbour(dst);
2751 if (n) {
2752 cast_type = n->type;
2748 if ((cast_type == RTN_BROADCAST) || 2753 if ((cast_type == RTN_BROADCAST) ||
2749 (cast_type == RTN_MULTICAST) || 2754 (cast_type == RTN_MULTICAST) ||
2750 (cast_type == RTN_ANYCAST)) 2755 (cast_type == RTN_ANYCAST))
@@ -2787,6 +2792,9 @@ int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
2787static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, 2792static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2788 struct sk_buff *skb, int ipv, int cast_type) 2793 struct sk_buff *skb, int ipv, int cast_type)
2789{ 2794{
2795 struct neighbour *n = NULL;
2796 struct dst_entry *dst;
2797
2790 memset(hdr, 0, sizeof(struct qeth_hdr)); 2798 memset(hdr, 0, sizeof(struct qeth_hdr));
2791 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; 2799 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3;
2792 hdr->hdr.l3.ext_flags = 0; 2800 hdr->hdr.l3.ext_flags = 0;
@@ -2804,13 +2812,16 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2804 } 2812 }
2805 2813
2806 hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr); 2814 hdr->hdr.l3.length = skb->len - sizeof(struct qeth_hdr);
2815 dst = skb_dst(skb);
2816 if (dst)
2817 n = dst_get_neighbour(dst);
2807 if (ipv == 4) { 2818 if (ipv == 4) {
2808 /* IPv4 */ 2819 /* IPv4 */
2809 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type); 2820 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags4(cast_type);
2810 memset(hdr->hdr.l3.dest_addr, 0, 12); 2821 memset(hdr->hdr.l3.dest_addr, 0, 12);
2811 if ((skb_dst(skb)) && (skb_dst(skb)->neighbour)) { 2822 if (n) {
2812 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = 2823 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
2813 *((u32 *) skb_dst(skb)->neighbour->primary_key); 2824 *((u32 *) n->primary_key);
2814 } else { 2825 } else {
2815 /* fill in destination address used in ip header */ 2826 /* fill in destination address used in ip header */
2816 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) = 2827 *((u32 *) (&hdr->hdr.l3.dest_addr[12])) =
@@ -2821,9 +2832,9 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2821 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type); 2832 hdr->hdr.l3.flags = qeth_l3_get_qeth_hdr_flags6(cast_type);
2822 if (card->info.type == QETH_CARD_TYPE_IQD) 2833 if (card->info.type == QETH_CARD_TYPE_IQD)
2823 hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU; 2834 hdr->hdr.l3.flags &= ~QETH_HDR_PASSTHRU;
2824 if ((skb_dst(skb)) && (skb_dst(skb)->neighbour)) { 2835 if (n) {
2825 memcpy(hdr->hdr.l3.dest_addr, 2836 memcpy(hdr->hdr.l3.dest_addr,
2826 skb_dst(skb)->neighbour->primary_key, 16); 2837 n->primary_key, 16);
2827 } else { 2838 } else {
2828 /* fill in destination address used in ip header */ 2839 /* fill in destination address used in ip header */
2829 memcpy(hdr->hdr.l3.dest_addr, 2840 memcpy(hdr->hdr.l3.dest_addr,
diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
index fc2cdb62f53b..abc7b122e050 100644
--- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
+++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
@@ -985,7 +985,7 @@ static int init_act_open(struct cxgbi_sock *csk)
985 csk->saddr.sin_addr.s_addr = chba->ipv4addr; 985 csk->saddr.sin_addr.s_addr = chba->ipv4addr;
986 986
987 csk->rss_qid = 0; 987 csk->rss_qid = 0;
988 csk->l2t = t3_l2t_get(t3dev, dst->neighbour, ndev); 988 csk->l2t = t3_l2t_get(t3dev, dst_get_neighbour(dst), ndev);
989 if (!csk->l2t) { 989 if (!csk->l2t) {
990 pr_err("NO l2t available.\n"); 990 pr_err("NO l2t available.\n");
991 return -EINVAL; 991 return -EINVAL;
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index f3a4cd7cf782..ae13c4993aa3 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -1160,7 +1160,7 @@ static int init_act_open(struct cxgbi_sock *csk)
1160 cxgbi_sock_set_flag(csk, CTPF_HAS_ATID); 1160 cxgbi_sock_set_flag(csk, CTPF_HAS_ATID);
1161 cxgbi_sock_get(csk); 1161 cxgbi_sock_get(csk);
1162 1162
1163 csk->l2t = cxgb4_l2t_get(lldi->l2t, csk->dst->neighbour, ndev, 0); 1163 csk->l2t = cxgb4_l2t_get(lldi->l2t, dst_get_neighbour(csk->dst), ndev, 0);
1164 if (!csk->l2t) { 1164 if (!csk->l2t) {
1165 pr_err("%s, cannot alloc l2t.\n", ndev->name); 1165 pr_err("%s, cannot alloc l2t.\n", ndev->name);
1166 goto rel_resource; 1166 goto rel_resource;
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index a2a9c7c6c643..77ac217ad5ce 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -492,7 +492,7 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr)
492 goto err_out; 492 goto err_out;
493 } 493 }
494 dst = &rt->dst; 494 dst = &rt->dst;
495 ndev = dst->neighbour->dev; 495 ndev = dst_get_neighbour(dst)->dev;
496 496
497 if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { 497 if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
498 pr_info("multi-cast route %pI4, port %u, dev %s.\n", 498 pr_info("multi-cast route %pI4, port %u, dev %s.\n",
@@ -506,7 +506,7 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr)
506 ndev = ip_dev_find(&init_net, daddr->sin_addr.s_addr); 506 ndev = ip_dev_find(&init_net, daddr->sin_addr.s_addr);
507 mtu = ndev->mtu; 507 mtu = ndev->mtu;
508 pr_info("rt dev %s, loopback -> %s, mtu %u.\n", 508 pr_info("rt dev %s, loopback -> %s, mtu %u.\n",
509 dst->neighbour->dev->name, ndev->name, mtu); 509 dst_get_neighbour(dst)->dev->name, ndev->name, mtu);
510 } 510 }
511 511
512 cdev = cxgbi_device_find_by_netdev(ndev, &port); 512 cdev = cxgbi_device_find_by_netdev(ndev, &port);
diff --git a/include/net/dst.h b/include/net/dst.h
index 0dd7ccbc0dd5..8147206eefb9 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -37,7 +37,7 @@ struct dst_entry {
37 unsigned long _metrics; 37 unsigned long _metrics;
38 unsigned long expires; 38 unsigned long expires;
39 struct dst_entry *path; 39 struct dst_entry *path;
40 struct neighbour *neighbour; 40 struct neighbour *_neighbour;
41#ifdef CONFIG_XFRM 41#ifdef CONFIG_XFRM
42 struct xfrm_state *xfrm; 42 struct xfrm_state *xfrm;
43#else 43#else
@@ -86,6 +86,16 @@ struct dst_entry {
86 }; 86 };
87}; 87};
88 88
89static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst)
90{
91 return dst->_neighbour;
92}
93
94static inline void dst_set_neighbour(struct dst_entry *dst, struct neighbour *neigh)
95{
96 dst->_neighbour = neigh;
97}
98
89extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); 99extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);
90extern const u32 dst_default_metrics[RTAX_MAX]; 100extern const u32 dst_default_metrics[RTAX_MAX];
91 101
@@ -371,8 +381,10 @@ static inline void dst_rcu_free(struct rcu_head *head)
371 381
372static inline void dst_confirm(struct dst_entry *dst) 382static inline void dst_confirm(struct dst_entry *dst)
373{ 383{
374 if (dst) 384 if (dst) {
375 neigh_confirm(dst->neighbour); 385 struct neighbour *n = dst_get_neighbour(dst);
386 neigh_confirm(n);
387 }
376} 388}
377 389
378static inline void dst_link_failure(struct sk_buff *skb) 390static inline void dst_link_failure(struct sk_buff *skb)
diff --git a/net/atm/clip.c b/net/atm/clip.c
index c6cd5318be3f..4bc8c67ecb14 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -362,33 +362,37 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
362 struct net_device *dev) 362 struct net_device *dev)
363{ 363{
364 struct clip_priv *clip_priv = PRIV(dev); 364 struct clip_priv *clip_priv = PRIV(dev);
365 struct dst_entry *dst = skb_dst(skb);
365 struct atmarp_entry *entry; 366 struct atmarp_entry *entry;
367 struct neighbour *n;
366 struct atm_vcc *vcc; 368 struct atm_vcc *vcc;
367 int old; 369 int old;
368 unsigned long flags; 370 unsigned long flags;
369 371
370 pr_debug("(skb %p)\n", skb); 372 pr_debug("(skb %p)\n", skb);
371 if (!skb_dst(skb)) { 373 if (!dst) {
372 pr_err("skb_dst(skb) == NULL\n"); 374 pr_err("skb_dst(skb) == NULL\n");
373 dev_kfree_skb(skb); 375 dev_kfree_skb(skb);
374 dev->stats.tx_dropped++; 376 dev->stats.tx_dropped++;
375 return NETDEV_TX_OK; 377 return NETDEV_TX_OK;
376 } 378 }
377 if (!skb_dst(skb)->neighbour) { 379 n = dst_get_neighbour(dst);
380 if (!n) {
378#if 0 381#if 0
379 skb_dst(skb)->neighbour = clip_find_neighbour(skb_dst(skb), 1); 382 n = clip_find_neighbour(skb_dst(skb), 1);
380 if (!skb_dst(skb)->neighbour) { 383 if (!n) {
381 dev_kfree_skb(skb); /* lost that one */ 384 dev_kfree_skb(skb); /* lost that one */
382 dev->stats.tx_dropped++; 385 dev->stats.tx_dropped++;
383 return 0; 386 return 0;
384 } 387 }
388 dst_set_neighbour(dst, n);
385#endif 389#endif
386 pr_err("NO NEIGHBOUR !\n"); 390 pr_err("NO NEIGHBOUR !\n");
387 dev_kfree_skb(skb); 391 dev_kfree_skb(skb);
388 dev->stats.tx_dropped++; 392 dev->stats.tx_dropped++;
389 return NETDEV_TX_OK; 393 return NETDEV_TX_OK;
390 } 394 }
391 entry = NEIGH2ENTRY(skb_dst(skb)->neighbour); 395 entry = NEIGH2ENTRY(n);
392 if (!entry->vccs) { 396 if (!entry->vccs) {
393 if (time_after(jiffies, entry->expires)) { 397 if (time_after(jiffies, entry->expires)) {
394 /* should be resolved */ 398 /* should be resolved */
@@ -405,7 +409,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
405 } 409 }
406 pr_debug("neigh %p, vccs %p\n", entry, entry->vccs); 410 pr_debug("neigh %p, vccs %p\n", entry, entry->vccs);
407 ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc; 411 ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc;
408 pr_debug("using neighbour %p, vcc %p\n", skb_dst(skb)->neighbour, vcc); 412 pr_debug("using neighbour %p, vcc %p\n", n, vcc);
409 if (entry->vccs->encap) { 413 if (entry->vccs->encap) {
410 void *here; 414 void *here;
411 415
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 1fe43fdf9973..b1a5f9777b7e 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -350,7 +350,7 @@ static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
350 if (!skb->dev) 350 if (!skb->dev)
351 goto free_skb; 351 goto free_skb;
352 dst = skb_dst(skb); 352 dst = skb_dst(skb);
353 neigh = dst->neighbour; 353 neigh = dst_get_neighbour(dst);
354 if (neigh->hh.hh_len) { 354 if (neigh->hh.hh_len) {
355 neigh_hh_bridge(&neigh->hh, skb); 355 neigh_hh_bridge(&neigh->hh, skb);
356 skb->dev = nf_bridge->physindev; 356 skb->dev = nf_bridge->physindev;
diff --git a/net/core/dst.c b/net/core/dst.c
index 4aacc14936a0..14b33baf0733 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -171,7 +171,7 @@ void *dst_alloc(struct dst_ops *ops, struct net_device *dev,
171 dst_init_metrics(dst, dst_default_metrics, true); 171 dst_init_metrics(dst, dst_default_metrics, true);
172 dst->expires = 0UL; 172 dst->expires = 0UL;
173 dst->path = dst; 173 dst->path = dst;
174 dst->neighbour = NULL; 174 dst->_neighbour = NULL;
175#ifdef CONFIG_XFRM 175#ifdef CONFIG_XFRM
176 dst->xfrm = NULL; 176 dst->xfrm = NULL;
177#endif 177#endif
@@ -229,11 +229,11 @@ struct dst_entry *dst_destroy(struct dst_entry * dst)
229 smp_rmb(); 229 smp_rmb();
230 230
231again: 231again:
232 neigh = dst->neighbour; 232 neigh = dst->_neighbour;
233 child = dst->child; 233 child = dst->child;
234 234
235 if (neigh) { 235 if (neigh) {
236 dst->neighbour = NULL; 236 dst->_neighbour = NULL;
237 neigh_release(neigh); 237 neigh_release(neigh);
238 } 238 }
239 239
@@ -363,8 +363,8 @@ static void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
363 dst->dev = dev_net(dst->dev)->loopback_dev; 363 dst->dev = dev_net(dst->dev)->loopback_dev;
364 dev_hold(dst->dev); 364 dev_hold(dst->dev);
365 dev_put(dev); 365 dev_put(dev);
366 if (dst->neighbour && dst->neighbour->dev == dev) { 366 if (dst->_neighbour && dst->_neighbour->dev == dev) {
367 dst->neighbour->dev = dst->dev; 367 dst->_neighbour->dev = dst->dev;
368 dev_hold(dst->dev); 368 dev_hold(dst->dev);
369 dev_put(dev); 369 dev_put(dev);
370 } 370 }
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index cefb8e52615e..8fab9b0bb203 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1153,11 +1153,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1153 1153
1154 while (neigh->nud_state & NUD_VALID && 1154 while (neigh->nud_state & NUD_VALID &&
1155 (skb = __skb_dequeue(&neigh->arp_queue)) != NULL) { 1155 (skb = __skb_dequeue(&neigh->arp_queue)) != NULL) {
1156 struct neighbour *n1 = neigh; 1156 struct dst_entry *dst = skb_dst(skb);
1157 struct neighbour *n2, *n1 = neigh;
1157 write_unlock_bh(&neigh->lock); 1158 write_unlock_bh(&neigh->lock);
1158 /* On shaper/eql skb->dst->neighbour != neigh :( */ 1159 /* On shaper/eql skb->dst->neighbour != neigh :( */
1159 if (skb_dst(skb) && skb_dst(skb)->neighbour) 1160 if (dst && (n2 = dst_get_neighbour(dst)) != NULL)
1160 n1 = skb_dst(skb)->neighbour; 1161 n1 = n2;
1161 n1->output(n1, skb); 1162 n1->output(n1, skb);
1162 write_lock_bh(&neigh->lock); 1163 write_lock_bh(&neigh->lock);
1163 } 1164 }
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
index 5d61e8965b66..0dc3fe61085b 100644
--- a/net/decnet/dn_neigh.c
+++ b/net/decnet/dn_neigh.c
@@ -202,7 +202,7 @@ static int dn_neigh_output_packet(struct sk_buff *skb)
202{ 202{
203 struct dst_entry *dst = skb_dst(skb); 203 struct dst_entry *dst = skb_dst(skb);
204 struct dn_route *rt = (struct dn_route *)dst; 204 struct dn_route *rt = (struct dn_route *)dst;
205 struct neighbour *neigh = dst->neighbour; 205 struct neighbour *neigh = dst_get_neighbour(dst);
206 struct net_device *dev = neigh->dev; 206 struct net_device *dev = neigh->dev;
207 char mac_addr[ETH_ALEN]; 207 char mac_addr[ETH_ALEN];
208 208
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 3b6400d17dc2..9bd45fcb3b8e 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -241,9 +241,11 @@ static int dn_dst_gc(struct dst_ops *ops)
241 */ 241 */
242static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu) 242static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
243{ 243{
244 struct neighbour *n = dst_get_neighbour(dst);
244 u32 min_mtu = 230; 245 u32 min_mtu = 230;
245 struct dn_dev *dn = dst->neighbour ? 246 struct dn_dev *dn;
246 rcu_dereference_raw(dst->neighbour->dev->dn_ptr) : NULL; 247
248 dn = n ? rcu_dereference_raw(n->dev->dn_ptr) : NULL;
247 249
248 if (dn && dn->use_long == 0) 250 if (dn && dn->use_long == 0)
249 min_mtu -= 6; 251 min_mtu -= 6;
@@ -708,7 +710,7 @@ out:
708static int dn_to_neigh_output(struct sk_buff *skb) 710static int dn_to_neigh_output(struct sk_buff *skb)
709{ 711{
710 struct dst_entry *dst = skb_dst(skb); 712 struct dst_entry *dst = skb_dst(skb);
711 struct neighbour *n = dst->neighbour; 713 struct neighbour *n = dst_get_neighbour(dst);
712 714
713 return n->output(n, skb); 715 return n->output(n, skb);
714} 716}
@@ -723,7 +725,7 @@ static int dn_output(struct sk_buff *skb)
723 725
724 int err = -EINVAL; 726 int err = -EINVAL;
725 727
726 if ((neigh = dst->neighbour) == NULL) 728 if ((neigh = dst_get_neighbour(dst)) == NULL)
727 goto error; 729 goto error;
728 730
729 skb->dev = dev; 731 skb->dev = dev;
@@ -840,11 +842,11 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
840 } 842 }
841 rt->rt_type = res->type; 843 rt->rt_type = res->type;
842 844
843 if (dev != NULL && rt->dst.neighbour == NULL) { 845 if (dev != NULL && dst_get_neighbour(&rt->dst) == NULL) {
844 n = __neigh_lookup_errno(&dn_neigh_table, &rt->rt_gateway, dev); 846 n = __neigh_lookup_errno(&dn_neigh_table, &rt->rt_gateway, dev);
845 if (IS_ERR(n)) 847 if (IS_ERR(n))
846 return PTR_ERR(n); 848 return PTR_ERR(n);
847 rt->dst.neighbour = n; 849 dst_set_neighbour(&rt->dst, n);
848 } 850 }
849 851
850 if (dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu) 852 if (dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu)
@@ -1151,7 +1153,7 @@ make_route:
1151 rt->rt_dst_map = fld.daddr; 1153 rt->rt_dst_map = fld.daddr;
1152 rt->rt_src_map = fld.saddr; 1154 rt->rt_src_map = fld.saddr;
1153 1155
1154 rt->dst.neighbour = neigh; 1156 dst_set_neighbour(&rt->dst, neigh);
1155 neigh = NULL; 1157 neigh = NULL;
1156 1158
1157 rt->dst.lastuse = jiffies; 1159 rt->dst.lastuse = jiffies;
@@ -1423,7 +1425,7 @@ make_route:
1423 rt->fld.flowidn_iif = in_dev->ifindex; 1425 rt->fld.flowidn_iif = in_dev->ifindex;
1424 rt->fld.flowidn_mark = fld.flowidn_mark; 1426 rt->fld.flowidn_mark = fld.flowidn_mark;
1425 1427
1426 rt->dst.neighbour = neigh; 1428 dst_set_neighbour(&rt->dst, neigh);
1427 rt->dst.lastuse = jiffies; 1429 rt->dst.lastuse = jiffies;
1428 rt->dst.output = dn_rt_bug; 1430 rt->dst.output = dn_rt_bug;
1429 switch (res.type) { 1431 switch (res.type) {
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 8871067560db..d7bb94c48345 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -731,9 +731,9 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
731 } 731 }
732#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 732#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
733 else if (skb->protocol == htons(ETH_P_IPV6)) { 733 else if (skb->protocol == htons(ETH_P_IPV6)) {
734 struct neighbour *neigh = dst_get_neighbour(skb_dst(skb));
734 const struct in6_addr *addr6; 735 const struct in6_addr *addr6;
735 int addr_type; 736 int addr_type;
736 struct neighbour *neigh = skb_dst(skb)->neighbour;
737 737
738 if (neigh == NULL) 738 if (neigh == NULL)
739 goto tx_error; 739 goto tx_error;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index db296a98b236..be27e609a98b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -204,7 +204,7 @@ static inline int ip_finish_output2(struct sk_buff *skb)
204 skb = skb2; 204 skb = skb2;
205 } 205 }
206 206
207 neigh = dst->neighbour; 207 neigh = dst_get_neighbour(dst);
208 if (neigh) 208 if (neigh)
209 return neigh_output(neigh, skb); 209 return neigh_output(neigh, skb);
210 210
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index bcf9bb508200..1d4cd3b4fd69 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -412,8 +412,10 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
412 "HHUptod\tSpecDst"); 412 "HHUptod\tSpecDst");
413 else { 413 else {
414 struct rtable *r = v; 414 struct rtable *r = v;
415 struct neighbour *n;
415 int len; 416 int len;
416 417
418 n = dst_get_neighbour(&r->dst);
417 seq_printf(seq, "%s\t%08X\t%08X\t%8X\t%d\t%u\t%d\t" 419 seq_printf(seq, "%s\t%08X\t%08X\t%8X\t%d\t%u\t%d\t"
418 "%08X\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X%n", 420 "%08X\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X%n",
419 r->dst.dev ? r->dst.dev->name : "*", 421 r->dst.dev ? r->dst.dev->name : "*",
@@ -427,9 +429,7 @@ static int rt_cache_seq_show(struct seq_file *seq, void *v)
427 dst_metric(&r->dst, RTAX_RTTVAR)), 429 dst_metric(&r->dst, RTAX_RTTVAR)),
428 r->rt_key_tos, 430 r->rt_key_tos,
429 -1, 431 -1,
430 (r->dst.neighbour && 432 (n && (n->nud_state & NUD_CONNECTED)) ? 1 : 0,
431 (r->dst.neighbour->nud_state & NUD_CONNECTED)) ?
432 1 : 0,
433 r->rt_spec_dst, &len); 433 r->rt_spec_dst, &len);
434 434
435 seq_printf(seq, "%*s\n", 127 - len, ""); 435 seq_printf(seq, "%*s\n", 127 - len, "");
@@ -1026,7 +1026,7 @@ static int rt_bind_neighbour(struct rtable *rt)
1026 n = ipv4_neigh_lookup(tbl, dev, nexthop); 1026 n = ipv4_neigh_lookup(tbl, dev, nexthop);
1027 if (IS_ERR(n)) 1027 if (IS_ERR(n))
1028 return PTR_ERR(n); 1028 return PTR_ERR(n);
1029 rt->dst.neighbour = n; 1029 dst_set_neighbour(&rt->dst, n);
1030 1030
1031 return 0; 1031 return 0;
1032} 1032}
@@ -1617,23 +1617,24 @@ static int check_peer_redir(struct dst_entry *dst, struct inet_peer *peer)
1617{ 1617{
1618 struct rtable *rt = (struct rtable *) dst; 1618 struct rtable *rt = (struct rtable *) dst;
1619 __be32 orig_gw = rt->rt_gateway; 1619 __be32 orig_gw = rt->rt_gateway;
1620 struct neighbour *n;
1620 1621
1621 dst_confirm(&rt->dst); 1622 dst_confirm(&rt->dst);
1622 1623
1623 neigh_release(rt->dst.neighbour); 1624 neigh_release(dst_get_neighbour(&rt->dst));
1624 rt->dst.neighbour = NULL; 1625 dst_set_neighbour(&rt->dst, NULL);
1625 1626
1626 rt->rt_gateway = peer->redirect_learned.a4; 1627 rt->rt_gateway = peer->redirect_learned.a4;
1627 if (rt_bind_neighbour(rt) || 1628 rt_bind_neighbour(rt);
1628 !(rt->dst.neighbour->nud_state & NUD_VALID)) { 1629 n = dst_get_neighbour(&rt->dst);
1629 if (rt->dst.neighbour) 1630 if (!n || !(n->nud_state & NUD_VALID)) {
1630 neigh_event_send(rt->dst.neighbour, NULL); 1631 if (n)
1632 neigh_event_send(n, NULL);
1631 rt->rt_gateway = orig_gw; 1633 rt->rt_gateway = orig_gw;
1632 return -EAGAIN; 1634 return -EAGAIN;
1633 } else { 1635 } else {
1634 rt->rt_flags |= RTCF_REDIRECTED; 1636 rt->rt_flags |= RTCF_REDIRECTED;
1635 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, 1637 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n);
1636 rt->dst.neighbour);
1637 } 1638 }
1638 return 0; 1639 return 0;
1639} 1640}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 48cd03df8954..a06c53c14d84 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -656,7 +656,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
656 * layer address of our nexhop router 656 * layer address of our nexhop router
657 */ 657 */
658 658
659 if (rt->dst.neighbour == NULL) 659 if (dst_get_neighbour(&rt->dst) == NULL)
660 ifa->flags &= ~IFA_F_OPTIMISTIC; 660 ifa->flags &= ~IFA_F_OPTIMISTIC;
661 661
662 ifa->idev = idev; 662 ifa->idev = idev;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 158df2365d5e..54a4678955bf 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1455,7 +1455,7 @@ static int fib6_age(struct rt6_info *rt, void *arg)
1455 RT6_TRACE("aging clone %p\n", rt); 1455 RT6_TRACE("aging clone %p\n", rt);
1456 return -1; 1456 return -1;
1457 } else if ((rt->rt6i_flags & RTF_GATEWAY) && 1457 } else if ((rt->rt6i_flags & RTF_GATEWAY) &&
1458 (!(rt->dst.neighbour->flags & NTF_ROUTER))) { 1458 (!(dst_get_neighbour(&rt->dst)->flags & NTF_ROUTER))) {
1459 RT6_TRACE("purging route %p via non-router but gateway\n", 1459 RT6_TRACE("purging route %p via non-router but gateway\n",
1460 rt); 1460 rt);
1461 return -1; 1461 return -1;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index eb50bb07ab2e..8db0e4875ad8 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -135,7 +135,7 @@ static int ip6_finish_output2(struct sk_buff *skb)
135 skb->len); 135 skb->len);
136 } 136 }
137 137
138 neigh = dst->neighbour; 138 neigh = dst_get_neighbour(dst);
139 if (neigh) 139 if (neigh)
140 return neigh_output(neigh, skb); 140 return neigh_output(neigh, skb);
141 141
@@ -385,6 +385,7 @@ int ip6_forward(struct sk_buff *skb)
385 struct ipv6hdr *hdr = ipv6_hdr(skb); 385 struct ipv6hdr *hdr = ipv6_hdr(skb);
386 struct inet6_skb_parm *opt = IP6CB(skb); 386 struct inet6_skb_parm *opt = IP6CB(skb);
387 struct net *net = dev_net(dst->dev); 387 struct net *net = dev_net(dst->dev);
388 struct neighbour *n;
388 u32 mtu; 389 u32 mtu;
389 390
390 if (net->ipv6.devconf_all->forwarding == 0) 391 if (net->ipv6.devconf_all->forwarding == 0)
@@ -459,11 +460,10 @@ int ip6_forward(struct sk_buff *skb)
459 send redirects to source routed frames. 460 send redirects to source routed frames.
460 We don't send redirects to frames decapsulated from IPsec. 461 We don't send redirects to frames decapsulated from IPsec.
461 */ 462 */
462 if (skb->dev == dst->dev && dst->neighbour && opt->srcrt == 0 && 463 n = dst_get_neighbour(dst);
463 !skb_sec_path(skb)) { 464 if (skb->dev == dst->dev && n && opt->srcrt == 0 && !skb_sec_path(skb)) {
464 struct in6_addr *target = NULL; 465 struct in6_addr *target = NULL;
465 struct rt6_info *rt; 466 struct rt6_info *rt;
466 struct neighbour *n = dst->neighbour;
467 467
468 /* 468 /*
469 * incoming and outgoing devices are the same 469 * incoming and outgoing devices are the same
@@ -920,8 +920,11 @@ out:
920static int ip6_dst_lookup_tail(struct sock *sk, 920static int ip6_dst_lookup_tail(struct sock *sk,
921 struct dst_entry **dst, struct flowi6 *fl6) 921 struct dst_entry **dst, struct flowi6 *fl6)
922{ 922{
923 int err;
924 struct net *net = sock_net(sk); 923 struct net *net = sock_net(sk);
924#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
925 struct neighbour *n;
926#endif
927 int err;
925 928
926 if (*dst == NULL) 929 if (*dst == NULL)
927 *dst = ip6_route_output(net, sk, fl6); 930 *dst = ip6_route_output(net, sk, fl6);
@@ -947,7 +950,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
947 * dst entry and replace it instead with the 950 * dst entry and replace it instead with the
948 * dst entry of the nexthop router 951 * dst entry of the nexthop router
949 */ 952 */
950 if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) { 953 n = dst_get_neighbour(*dst);
954 if (n && !(n->nud_state & NUD_VALID)) {
951 struct inet6_ifaddr *ifp; 955 struct inet6_ifaddr *ifp;
952 struct flowi6 fl_gw6; 956 struct flowi6 fl_gw6;
953 int redirect; 957 int redirect;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index a997d414f525..9da6e02eaaeb 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1238,7 +1238,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1238 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev); 1238 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev);
1239 1239
1240 if (rt) 1240 if (rt)
1241 neigh = rt->dst.neighbour; 1241 neigh = dst_get_neighbour(&rt->dst);
1242 1242
1243 if (rt && lifetime == 0) { 1243 if (rt && lifetime == 0) {
1244 neigh_clone(neigh); 1244 neigh_clone(neigh);
@@ -1259,7 +1259,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1259 return; 1259 return;
1260 } 1260 }
1261 1261
1262 neigh = rt->dst.neighbour; 1262 neigh = dst_get_neighbour(&rt->dst);
1263 if (neigh == NULL) { 1263 if (neigh == NULL) {
1264 ND_PRINTK0(KERN_ERR 1264 ND_PRINTK0(KERN_ERR
1265 "ICMPv6 RA: %s() got default router without neighbour.\n", 1265 "ICMPv6 RA: %s() got default router without neighbour.\n",
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c1515a3c1305..2998cb5be90b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -356,7 +356,7 @@ out:
356#ifdef CONFIG_IPV6_ROUTER_PREF 356#ifdef CONFIG_IPV6_ROUTER_PREF
357static void rt6_probe(struct rt6_info *rt) 357static void rt6_probe(struct rt6_info *rt)
358{ 358{
359 struct neighbour *neigh = rt ? rt->dst.neighbour : NULL; 359 struct neighbour *neigh = rt ? dst_get_neighbour(&rt->dst) : NULL;
360 /* 360 /*
361 * Okay, this does not seem to be appropriate 361 * Okay, this does not seem to be appropriate
362 * for now, however, we need to check if it 362 * for now, however, we need to check if it
@@ -404,7 +404,7 @@ static inline int rt6_check_dev(struct rt6_info *rt, int oif)
404 404
405static inline int rt6_check_neigh(struct rt6_info *rt) 405static inline int rt6_check_neigh(struct rt6_info *rt)
406{ 406{
407 struct neighbour *neigh = rt->dst.neighbour; 407 struct neighbour *neigh = dst_get_neighbour(&rt->dst);
408 int m; 408 int m;
409 if (rt->rt6i_flags & RTF_NONEXTHOP || 409 if (rt->rt6i_flags & RTF_NONEXTHOP ||
410 !(rt->rt6i_flags & RTF_GATEWAY)) 410 !(rt->rt6i_flags & RTF_GATEWAY))
@@ -745,7 +745,7 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, const struct in6_add
745 dst_free(&rt->dst); 745 dst_free(&rt->dst);
746 return NULL; 746 return NULL;
747 } 747 }
748 rt->dst.neighbour = neigh; 748 dst_set_neighbour(&rt->dst, neigh);
749 749
750 } 750 }
751 751
@@ -760,7 +760,7 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, const struct in6_a
760 rt->rt6i_dst.plen = 128; 760 rt->rt6i_dst.plen = 128;
761 rt->rt6i_flags |= RTF_CACHE; 761 rt->rt6i_flags |= RTF_CACHE;
762 rt->dst.flags |= DST_HOST; 762 rt->dst.flags |= DST_HOST;
763 rt->dst.neighbour = neigh_clone(ort->dst.neighbour); 763 dst_set_neighbour(&rt->dst, neigh_clone(dst_get_neighbour(&ort->dst)));
764 } 764 }
765 return rt; 765 return rt;
766} 766}
@@ -794,7 +794,7 @@ restart:
794 dst_hold(&rt->dst); 794 dst_hold(&rt->dst);
795 read_unlock_bh(&table->tb6_lock); 795 read_unlock_bh(&table->tb6_lock);
796 796
797 if (!rt->dst.neighbour && !(rt->rt6i_flags & RTF_NONEXTHOP)) 797 if (!dst_get_neighbour(&rt->dst) && !(rt->rt6i_flags & RTF_NONEXTHOP))
798 nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr); 798 nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr);
799 else if (!(rt->dst.flags & DST_HOST)) 799 else if (!(rt->dst.flags & DST_HOST))
800 nrt = rt6_alloc_clone(rt, &fl6->daddr); 800 nrt = rt6_alloc_clone(rt, &fl6->daddr);
@@ -1058,7 +1058,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1058 } 1058 }
1059 1059
1060 rt->rt6i_idev = idev; 1060 rt->rt6i_idev = idev;
1061 rt->dst.neighbour = neigh; 1061 dst_set_neighbour(&rt->dst, neigh);
1062 atomic_set(&rt->dst.__refcnt, 1); 1062 atomic_set(&rt->dst.__refcnt, 1);
1063 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); 1063 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
1064 rt->dst.output = ip6_output; 1064 rt->dst.output = ip6_output;
@@ -1338,12 +1338,12 @@ int ip6_route_add(struct fib6_config *cfg)
1338 rt->rt6i_prefsrc.plen = 0; 1338 rt->rt6i_prefsrc.plen = 0;
1339 1339
1340 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { 1340 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) {
1341 rt->dst.neighbour = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev); 1341 struct neighbour *n = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev);
1342 if (IS_ERR(rt->dst.neighbour)) { 1342 if (IS_ERR(n)) {
1343 err = PTR_ERR(rt->dst.neighbour); 1343 err = PTR_ERR(n);
1344 rt->dst.neighbour = NULL;
1345 goto out; 1344 goto out;
1346 } 1345 }
1346 dst_set_neighbour(&rt->dst, n);
1347 } 1347 }
1348 1348
1349 rt->rt6i_flags = cfg->fc_flags; 1349 rt->rt6i_flags = cfg->fc_flags;
@@ -1574,7 +1574,7 @@ void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src,
1574 dst_confirm(&rt->dst); 1574 dst_confirm(&rt->dst);
1575 1575
1576 /* Duplicate redirect: silently ignore. */ 1576 /* Duplicate redirect: silently ignore. */
1577 if (neigh == rt->dst.neighbour) 1577 if (neigh == dst_get_neighbour(&rt->dst))
1578 goto out; 1578 goto out;
1579 1579
1580 nrt = ip6_rt_copy(rt); 1580 nrt = ip6_rt_copy(rt);
@@ -1590,7 +1590,7 @@ void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src,
1590 nrt->dst.flags |= DST_HOST; 1590 nrt->dst.flags |= DST_HOST;
1591 1591
1592 ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); 1592 ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key);
1593 nrt->dst.neighbour = neigh_clone(neigh); 1593 dst_set_neighbour(&nrt->dst, neigh_clone(neigh));
1594 1594
1595 if (ip6_ins_rt(nrt)) 1595 if (ip6_ins_rt(nrt))
1596 goto out; 1596 goto out;
@@ -1670,7 +1670,7 @@ again:
1670 1. It is connected route. Action: COW 1670 1. It is connected route. Action: COW
1671 2. It is gatewayed route or NONEXTHOP route. Action: clone it. 1671 2. It is gatewayed route or NONEXTHOP route. Action: clone it.
1672 */ 1672 */
1673 if (!rt->dst.neighbour && !(rt->rt6i_flags & RTF_NONEXTHOP)) 1673 if (!dst_get_neighbour(&rt->dst) && !(rt->rt6i_flags & RTF_NONEXTHOP))
1674 nrt = rt6_alloc_cow(rt, daddr, saddr); 1674 nrt = rt6_alloc_cow(rt, daddr, saddr);
1675 else 1675 else
1676 nrt = rt6_alloc_clone(rt, daddr); 1676 nrt = rt6_alloc_clone(rt, daddr);
@@ -2035,7 +2035,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2035 2035
2036 return ERR_CAST(neigh); 2036 return ERR_CAST(neigh);
2037 } 2037 }
2038 rt->dst.neighbour = neigh; 2038 dst_set_neighbour(&rt->dst, neigh);
2039 2039
2040 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 2040 ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
2041 rt->rt6i_dst.plen = 128; 2041 rt->rt6i_dst.plen = 128;
@@ -2400,8 +2400,8 @@ static int rt6_fill_node(struct net *net,
2400 if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) 2400 if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0)
2401 goto nla_put_failure; 2401 goto nla_put_failure;
2402 2402
2403 if (rt->dst.neighbour) 2403 if (dst_get_neighbour(&rt->dst))
2404 NLA_PUT(skb, RTA_GATEWAY, 16, &rt->dst.neighbour->primary_key); 2404 NLA_PUT(skb, RTA_GATEWAY, 16, &dst_get_neighbour(&rt->dst)->primary_key);
2405 2405
2406 if (rt->dst.dev) 2406 if (rt->dst.dev)
2407 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex); 2407 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex);
@@ -2585,6 +2585,7 @@ struct rt6_proc_arg
2585static int rt6_info_route(struct rt6_info *rt, void *p_arg) 2585static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2586{ 2586{
2587 struct seq_file *m = p_arg; 2587 struct seq_file *m = p_arg;
2588 struct neighbour *n;
2588 2589
2589 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen); 2590 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
2590 2591
@@ -2593,9 +2594,9 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2593#else 2594#else
2594 seq_puts(m, "00000000000000000000000000000000 00 "); 2595 seq_puts(m, "00000000000000000000000000000000 00 ");
2595#endif 2596#endif
2596 2597 n = dst_get_neighbour(&rt->dst);
2597 if (rt->dst.neighbour) { 2598 if (n) {
2598 seq_printf(m, "%pi6", rt->dst.neighbour->primary_key); 2599 seq_printf(m, "%pi6", n->primary_key);
2599 } else { 2600 } else {
2600 seq_puts(m, "00000000000000000000000000000000"); 2601 seq_puts(m, "00000000000000000000000000000000");
2601 } 2602 }
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 1cca5761aea9..07bf1085458f 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -677,7 +677,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
677 struct neighbour *neigh = NULL; 677 struct neighbour *neigh = NULL;
678 678
679 if (skb_dst(skb)) 679 if (skb_dst(skb))
680 neigh = skb_dst(skb)->neighbour; 680 neigh = dst_get_neighbour(skb_dst(skb));
681 681
682 if (neigh == NULL) { 682 if (neigh == NULL) {
683 if (net_ratelimit()) 683 if (net_ratelimit())
@@ -702,7 +702,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
702 struct neighbour *neigh = NULL; 702 struct neighbour *neigh = NULL;
703 703
704 if (skb_dst(skb)) 704 if (skb_dst(skb))
705 neigh = skb_dst(skb)->neighbour; 705 neigh = dst_get_neighbour(skb_dst(skb));
706 706
707 if (neigh == NULL) { 707 if (neigh == NULL) {
708 if (net_ratelimit()) 708 if (net_ratelimit())
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 45cd30098e34..a3b7120fcc74 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -229,7 +229,7 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, struct net_device *
229{ 229{
230 struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, 0); 230 struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, 0);
231 struct teql_sched_data *q = qdisc_priv(dev_queue->qdisc); 231 struct teql_sched_data *q = qdisc_priv(dev_queue->qdisc);
232 struct neighbour *mn = skb_dst(skb)->neighbour; 232 struct neighbour *mn = dst_get_neighbour(skb_dst(skb));
233 struct neighbour *n = q->ncache; 233 struct neighbour *n = q->ncache;
234 234
235 if (mn->tbl == NULL) 235 if (mn->tbl == NULL)
@@ -270,7 +270,7 @@ static inline int teql_resolve(struct sk_buff *skb,
270 270
271 if (dev->header_ops == NULL || 271 if (dev->header_ops == NULL ||
272 skb_dst(skb) == NULL || 272 skb_dst(skb) == NULL ||
273 skb_dst(skb)->neighbour == NULL) 273 dst_get_neighbour(skb_dst(skb)) == NULL)
274 return 0; 274 return 0;
275 return __teql_resolve(skb, skb_res, dev); 275 return __teql_resolve(skb, skb_res, dev);
276} 276}
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 5ce74a385525..7803eb6af414 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1497,7 +1497,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
1497 goto free_dst; 1497 goto free_dst;
1498 1498
1499 /* Copy neighbour for reachability confirmation */ 1499 /* Copy neighbour for reachability confirmation */
1500 dst0->neighbour = neigh_clone(dst->neighbour); 1500 dst_set_neighbour(dst0, neigh_clone(dst_get_neighbour(dst)));
1501 1501
1502 xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len); 1502 xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len);
1503 xfrm_init_pmtu(dst_prev); 1503 xfrm_init_pmtu(dst_prev);