public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Hal Rosenstock <hal-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: "Hefty, Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: "linux-rdma
	(linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org)"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCHv2 13/16 ibacm] ib_acme.c: Support IPv6 addressing in resolve_ip
Date: Thu, 27 Jun 2013 15:14:22 -0400	[thread overview]
Message-ID: <51CC8F0E.7030106@dev.mellanox.co.il> (raw)


Signed-off-by: Hal Rosenstock <hal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
Change since v1:
Rebased

 src/acme.c |   33 ++++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/acme.c b/src/acme.c
index ec1d3d2..5ba5c0a 100644
--- a/src/acme.c
+++ b/src/acme.c
@@ -476,29 +476,52 @@ static int resolve_ip(struct ibv_path_record *path)
 {
 	struct ibv_path_data *paths;
 	struct sockaddr_in src, dest;
+	struct sockaddr_in6 src6, dest6;
 	struct sockaddr *saddr;
 	int ret, count;
+	int is_ipv6_src, is_ipv6_dest;
 
 	if (src_addr) {
+		is_ipv6_src = 0;
 		src.sin_family = AF_INET;
 		ret = inet_pton(AF_INET, src_addr, &src.sin_addr);
 		if (ret <= 0) {
-			printf("inet_pton error on source address (%s): 0x%x\n", src_addr, ret);
-			return -1;
+			src6.sin6_family = AF_INET6;
+			ret = inet_pton(AF_INET6, src_addr, &src6.sin6_addr);
+			if (ret <= 0) {
+				printf("inet_pton error on source address (%s): 0x%x\n", src_addr, ret);
+				return -1;
+			}
+			is_ipv6_src = 1;
 		}
-		saddr = (struct sockaddr *) &src;
+		if (is_ipv6_src)
+			saddr = (struct sockaddr *) &src6;
+		else
+			saddr = (struct sockaddr *) &src;
 	} else {
 		saddr = NULL;
 	}
 
+	is_ipv6_dest = 0;
 	dest.sin_family = AF_INET;
 	ret = inet_pton(AF_INET, dest_addr, &dest.sin_addr);
 	if (ret <= 0) {
-		printf("inet_pton error on destination address (%s): 0x%x\n", dest_addr, ret);
+		dest6.sin6_family = AF_INET6;
+		ret = inet_pton(AF_INET6, dest_addr, &dest6.sin6_addr);
+		if (ret <= 0) {
+			printf("inet_pton error on destination address (%s): 0x%x\n", dest_addr, ret);
+			return -1;
+		}
+		is_ipv6_dest = 1;
+	}
+
+	if (src_addr && is_ipv6_src != is_ipv6_dest) {
+		printf("source and destination address families don't match\n");
 		return -1;
 	}
 
-	ret = ib_acm_resolve_ip(saddr, (struct sockaddr *) &dest,
+	ret = ib_acm_resolve_ip(saddr,
+		(is_ipv6_dest ? (struct sockaddr *) &dest6 : (struct sockaddr *) &dest),
 		&paths, &count, get_resolve_flags());
 	if (ret) {
 		printf("ib_acm_resolve_ip failed: %s\n", strerror(errno));
-- 
1.7.8.2

--
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

                 reply	other threads:[~2013-06-27 19:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51CC8F0E.7030106@dev.mellanox.co.il \
    --to=hal-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox