Skip to contentSkip to conversation

ipvsadm: Enable to work display host name of IPv6

PATCH In review Hibari Michiro 3 participants 3 messages Jan 9, 2015 – Jan 16, 2015 IPVS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvsadm: Enable to work display host name of IPv6

So far ipvsadm can not display host name of IPv6.
This patch add process in the case of IPv6 for
addr_to_host function.

---
 ipvsadm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
ipvsadm.c +8 -2
index 72ddc8a..162d4a2 100644
@@ -1770,8 +1770,14 @@ static char * addr_to_host(int af, const void *addr)
 {
 	struct hostent *host;
-	if ((host = gethostbyaddr((char *) addr,
-				  sizeof(struct in_addr), af)) != NULL)
+	if (af == AF_INET)
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in_addr), af);
+	else
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in6_addr), af);
+
+	if (host != NULL)
 		return (char *) host->h_name;
 	else
 		return (char *) NULL;
Signature · 4 lines
1.8.3.1

-- 
Michiro Hibari <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 5 lines · Hibari Michiro

So far ipvsadm can not display host name of IPv6.
This patch add process in the case of IPv6 for
addr_to_host function.

Looks good to me. Still, comment could be
better. Jesper, please apply!

One day we should convert it to getnameinfo()

Quoted 26 lines
---
 ipvsadm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
ipvsadm.c +8 -2
index 72ddc8a..162d4a2 100644
@@ -1770,8 +1770,14 @@ static char * addr_to_host(int af, const void *addr)
 {
 	struct hostent *host;
-	if ((host = gethostbyaddr((char *) addr,
-				  sizeof(struct in_addr), af)) != NULL)
+	if (af == AF_INET)
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in_addr), af);
+	else
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in6_addr), af);
+
+	if (host != NULL)
 		return (char *) host->h_name;
 	else
 		return (char *) NULL;
Signature · 1 line
1.8.3.1

Regards

--
Julian Anastasov <[email protected]>

#2 lore raw
Quoted 10 lines · On Mon, 12 Jan 2015 22:05:13 +0200 (EET) Julian Anastasov <[email protected]> wrote:
Quoted 5 lines · Hibari Michiro

So far ipvsadm can not display host name of IPv6.
This patch add process in the case of IPv6 for
addr_to_host function.

Looks good to me. Still, comment could be
better. Jesper, please apply!

Thanks Hibari Michiro, applied.

But I updated the commit text, see:
https://git.kernel.org/cgit/utils/kernel/ipvsadm/ipvsadm.git/commit/?id=a30224d4a04e63

Quoted 3 lines

One day we should convert it to getnameinfo()

Also added a note to the commit text about this future plan to use getnameinfo().

Quoted 20 lines
Quoted 20 lines
ipvsadm.c +8 -2
index 72ddc8a..162d4a2 100644
@@ -1770,8 +1770,14 @@ static char * addr_to_host(int af, const void *addr)
 {
 	struct hostent *host;
-	if ((host = gethostbyaddr((char *) addr,
-				  sizeof(struct in_addr), af)) != NULL)
+	if (af == AF_INET)
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in_addr), af);
+	else
+		host = gethostbyaddr((char *) addr,
+				     sizeof(struct in6_addr), af);
+
+	if (host != NULL)
 		return (char *) host->h_name;
 	else
 		return (char *) NULL;
Signature · 5 lines
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Sr. Network Kernel Developer at Red Hat
  Author of http://www.iptv-analyzer.org
  LinkedIn: http://www.linkedin.com/in/brouer