Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Abstract dst->neighbour accesses behind helpers.

dst_{get,set}_neighbour()

Signed-off-by: David S. Miller <davem@davemloft.net>

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