Commit 2e2d190c authored by Sean Hefty's avatar Sean Hefty Committed by Roland Dreier

RDMA/cma: Include AF_IB in loopback and any address checks

Enhance checks for loopback and any address to support AF_IB in
addition to AF_INET and AF_INT6.  This will allow future patches to
use AF_IB when binding and resolving addresses.
Signed-off-by: default avatarSean Hefty <sean.hefty@intel.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent c8dea2f9
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <rdma/rdma_cm.h> #include <rdma/rdma_cm.h>
#include <rdma/rdma_cm_ib.h> #include <rdma/rdma_cm_ib.h>
#include <rdma/rdma_netlink.h> #include <rdma/rdma_netlink.h>
#include <rdma/ib.h>
#include <rdma/ib_cache.h> #include <rdma/ib_cache.h>
#include <rdma/ib_cm.h> #include <rdma/ib_cm.h>
#include <rdma/ib_sa.h> #include <rdma/ib_sa.h>
...@@ -679,26 +680,30 @@ EXPORT_SYMBOL(rdma_init_qp_attr); ...@@ -679,26 +680,30 @@ EXPORT_SYMBOL(rdma_init_qp_attr);
static inline int cma_zero_addr(struct sockaddr *addr) static inline int cma_zero_addr(struct sockaddr *addr)
{ {
struct in6_addr *ip6; switch (addr->sa_family) {
case AF_INET:
if (addr->sa_family == AF_INET) return ipv4_is_zeronet(((struct sockaddr_in *)addr)->sin_addr.s_addr);
return ipv4_is_zeronet( case AF_INET6:
((struct sockaddr_in *)addr)->sin_addr.s_addr); return ipv6_addr_any(&((struct sockaddr_in6 *) addr)->sin6_addr);
else { case AF_IB:
ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr; return ib_addr_any(&((struct sockaddr_ib *) addr)->sib_addr);
return (ip6->s6_addr32[0] | ip6->s6_addr32[1] | default:
ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0; return 0;
} }
} }
static inline int cma_loopback_addr(struct sockaddr *addr) static inline int cma_loopback_addr(struct sockaddr *addr)
{ {
if (addr->sa_family == AF_INET) switch (addr->sa_family) {
return ipv4_is_loopback( case AF_INET:
((struct sockaddr_in *) addr)->sin_addr.s_addr); return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr);
else case AF_INET6:
return ipv6_addr_loopback( return ipv6_addr_loopback(&((struct sockaddr_in6 *) addr)->sin6_addr);
&((struct sockaddr_in6 *) addr)->sin6_addr); case AF_IB:
return ib_addr_loopback(&((struct sockaddr_ib *) addr)->sib_addr);
default:
return 0;
}
} }
static inline int cma_any_addr(struct sockaddr *addr) static inline int cma_any_addr(struct sockaddr *addr)
...@@ -715,9 +720,12 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst) ...@@ -715,9 +720,12 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
case AF_INET: case AF_INET:
return ((struct sockaddr_in *) src)->sin_addr.s_addr != return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
((struct sockaddr_in *) dst)->sin_addr.s_addr; ((struct sockaddr_in *) dst)->sin_addr.s_addr;
default: case AF_INET6:
return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr, return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
&((struct sockaddr_in6 *) dst)->sin6_addr); &((struct sockaddr_in6 *) dst)->sin6_addr);
default:
return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr,
&((struct sockaddr_ib *) dst)->sib_addr);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment