diff options
Diffstat (limited to 'include/rdma/ib_addr.h')
-rw-r--r-- | include/rdma/ib_addr.h | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index a0715606ebb2..ce55906b54a0 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -38,8 +38,12 @@ #include <linux/in6.h> #include <linux/if_arp.h> #include <linux/netdevice.h> +#include <linux/inetdevice.h> #include <linux/socket.h> #include <linux/if_vlan.h> +#include <net/ipv6.h> +#include <net/if_inet6.h> +#include <net/ip.h> #include <rdma/ib_verbs.h> #include <rdma/ib_pack.h> #include <net/ipv6.h> @@ -132,20 +136,10 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr) return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0; } -static inline void iboe_mac_vlan_to_ll(union ib_gid *gid, u8 *mac, u16 vid) +static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) { - memset(gid->raw, 0, 16); - *((__be32 *) gid->raw) = cpu_to_be32(0xfe800000); - if (vid < 0x1000) { - gid->raw[12] = vid & 0xff; - gid->raw[11] = vid >> 8; - } else { - gid->raw[12] = 0xfe; - gid->raw[11] = 0xff; - } - memcpy(gid->raw + 13, mac + 3, 3); - memcpy(gid->raw + 8, mac, 3); - gid->raw[8] ^= 2; + return dev->priv_flags & IFF_802_1Q_VLAN ? + vlan_dev_vlan_id(dev) : 0xffff; } static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid) @@ -182,25 +176,20 @@ static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid) return 0; } -static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) -{ - return dev->priv_flags & IFF_802_1Q_VLAN ? - vlan_dev_vlan_id(dev) : 0xffff; -} - static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) { struct net_device *dev; - u16 vid = 0xffff; + struct in_device *ip4; dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if); if (dev) { - vid = rdma_vlan_dev_vlan_id(dev); + ip4 = (struct in_device *)dev->ip_ptr; + if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address) + ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address, + (struct in6_addr *)gid); dev_put(dev); } - - iboe_mac_vlan_to_ll(gid, dev_addr->src_dev_addr, vid); } static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid) |