* [PATCHv3 rdma-core 3/3] ibacm: In acm_util.c:acm_if_iter_sys, try IPv4 if IPv6 doesn't find any appropriate interfaces
@ 2017-10-25 16:51 Hal Rosenstock
[not found] ` <18b32f97-973a-1eb1-ac57-a5e06287d723-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Hal Rosenstock @ 2017-10-25 16:51 UTC (permalink / raw)
To: Hefty, Sean; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
This can occur when IPv6 is disabled.
In the case where ipv6 is disabled in kernel, the socket is created
but the ioctl fails.
Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
Change since v2:
Updated commit message to clarify that it's ioctl not socket call which fails when IPv6 is disabled
Changes since v1:
Handle AF_INET6 socket and ioctl errors more "locally" rather than looping around entire routine
Also, remove loop on no interfaces found
ibacm/src/acm_util.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/ibacm/src/acm_util.c b/ibacm/src/acm_util.c
index b50fd74..ad454f2 100644
--- a/ibacm/src/acm_util.c
+++ b/ibacm/src/acm_util.c
@@ -127,6 +127,7 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx)
struct ifconf *ifc;
struct ifreq *ifr;
char ip_str[INET6_ADDRSTRLEN];
+ int family = AF_INET6;
int s, ret, i, len;
uint16_t pkey;
union ibv_gid sgid;
@@ -135,9 +136,13 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx)
size_t addr_len;
char *alias_sep;
- s = socket(AF_INET6, SOCK_DGRAM, 0);
- if (!s)
- return -1;
+ s = socket(family, SOCK_DGRAM, 0);
+ if (!s) {
+ family = AF_INET;
+ s = socket(family, SOCK_DGRAM, 0);
+ if (!s)
+ return -1;
+ }
len = sizeof(*ifc) + sizeof(*ifr) * 64;
ifc = malloc(len);
@@ -150,9 +155,21 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx)
ifc->ifc_len = len - sizeof(*ifc);
ifc->ifc_req = (struct ifreq *) (ifc + 1);
+retry_ioctl:
ret = ioctl(s, SIOCGIFCONF, ifc);
if (ret < 0) {
- acm_log(0, "ioctl ifconf error: %s\n", strerror(errno));
+ acm_log(0, "ioctl IPv%s ifconf error: %s\n",
+ (family == AF_INET6) ? "6" : "4", strerror(errno));
+ if (family == AF_INET6) {
+ close(s);
+ family = AF_INET;
+ s = socket(family, SOCK_DGRAM, 0);
+ if (!s) {
+ free(ifc);
+ return ret;
+ }
+ goto retry_ioctl;
+ }
goto out2;
}
@@ -207,5 +224,4 @@ out2:
out1:
close(s);
return ret;
-
}
--
2.8.4
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv3 rdma-core 3/3] ibacm: In acm_util.c:acm_if_iter_sys, try IPv4 if IPv6 doesn't find any appropriate interfaces
[not found] ` <18b32f97-973a-1eb1-ac57-a5e06287d723-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2017-10-25 19:05 ` Doug Ledford
0 siblings, 0 replies; 2+ messages in thread
From: Doug Ledford @ 2017-10-25 19:05 UTC (permalink / raw)
To: Hal Rosenstock, Hefty, Sean
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Wed, 2017-10-25 at 12:51 -0400, Hal Rosenstock wrote:
> This can occur when IPv6 is disabled.
>
> In the case where ipv6 is disabled in kernel, the socket is created
> but the ioctl fails.
>
> Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Thanks, applied.
--
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-25 19:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-25 16:51 [PATCHv3 rdma-core 3/3] ibacm: In acm_util.c:acm_if_iter_sys, try IPv4 if IPv6 doesn't find any appropriate interfaces Hal Rosenstock
[not found] ` <18b32f97-973a-1eb1-ac57-a5e06287d723-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2017-10-25 19:05 ` Doug Ledford
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.