diff options
author | David S. Miller <davem@davemloft.net> | 2011-07-18 02:09:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-18 02:11:35 -0400 |
commit | 69cce1d1404968f78b177a0314f5822d5afdbbfb (patch) | |
tree | 26223264fd69ea8078d0013fd5a76eb7aeb04c12 /drivers/infiniband/ulp/ipoib | |
parent | 9cbb7ecbcff85077bb12301aaf4c9b5a56c5993d (diff) |
net: Abstract dst->neighbour accesses behind helpers.
dst_{get,set}_neighbour()
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/infiniband/ulp/ipoib')
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 41 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 20 |
2 files changed, 40 insertions, 21 deletions
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: | |||
637 | static void ipoib_path_lookup(struct sk_buff *skb, struct net_device *dev) | 639 | static 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 | ||
653 | static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev, | 658 | static 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 | ||
716 | out: | 720 | out: |
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); |