LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[PATCH 2/2] ipvsadm: allow different address family in connection listin

To: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>
Subject: [PATCH 2/2] ipvsadm: allow different address family in connection listing
Cc: Simon Horman <horms@xxxxxxxxxxxx>, lvs-devel@xxxxxxxxxxxxxxx, lvs-users@xxxxxxxxxxxxxxxxxxxxxx, Alex Gartrell <agartrell@xxxxxx>, kernel-team@xxxxxx
From: Julian Anastasov <ja@xxxxxx>
Date: Sat, 30 Aug 2014 14:35:49 +0300
Real server can have different address family, fix it
for connection listing.

Signed-off-by: Julian Anastasov <ja@xxxxxx>
---
 ipvsadm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ipvsadm.c b/ipvsadm.c
index 3000117..7263d03 100644
--- a/ipvsadm.c
+++ b/ipvsadm.c
@@ -1296,6 +1296,7 @@ static void print_conn(char *buf, unsigned int format)
        char            state[16];
        unsigned int    expires;
        unsigned short  af = AF_INET;
+       unsigned short  daf = AF_INET;
        char            pe_name[IP_VS_PENAME_MAXLEN];
        char            pe_data[IP_VS_PEDATA_MAXLEN];
 
@@ -1320,22 +1321,24 @@ static void print_conn(char *buf, unsigned int format)
 
        if (inet_pton(AF_INET6, temp1, &caddr.in6) > 0) {
                inet_pton(AF_INET6, temp2, &vaddr.in6);
-               inet_pton(AF_INET6, temp3, &daddr.in6);
                af = AF_INET6;
        } else if (inet_pton(AF_INET, temp1, &caddr.ip) > 0) {
                inet_pton(AF_INET, temp2, &vaddr.ip);
-               inet_pton(AF_INET, temp3, &daddr.ip);
        } else {
                caddr.ip = (__u32) htonl(strtoul(temp1, NULL, 16));
                vaddr.ip = (__u32) htonl(strtoul(temp2, NULL, 16));
-               daddr.ip = (__u32) htonl(strtoul(temp3, NULL, 16));
        }
 
+       if (inet_pton(AF_INET6, temp3, &daddr.in6) > 0)
+               daf = AF_INET6;
+       else if (inet_pton(AF_INET, temp3, &daddr.ip) <= 0)
+               daddr.ip = (__u32) htonl(strtoul(temp3, NULL, 16));
+
        if (!(cname = addrport_to_anyname(af, &caddr, cport, proto, format)))
                exit(1);
        if (!(vname = addrport_to_anyname(af, &vaddr, vport, proto, format)))
                exit(1);
-       if (!(dname = addrport_to_anyname(af, &daddr, dport, proto, format)))
+       if (!(dname = addrport_to_anyname(daf, &daddr, dport, proto, format)))
                exit(1);
 
        seconds = expires % 60;
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe lvs-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

<Prev in Thread] Current Thread [Next in Thread>