Skip to contentSkip to conversation

More changes for different address family

PATCH In review Julian Anastasov 2 participants 5 messages Aug 30, 2014 IPVS

lore
Share & tools
lore

Julian Anastasov

author maintainer
#0 lore raw

cover More changes for different address family

Following are 2 patches that support different address family for virtual and real server.

Alex, please test them too.

Julian Anastasov (2):
ipvsadm: restrict different address family
ipvsadm: allow different address family in connection listing

 ipvsadm.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.0
author maintainer
#1 lore raw

PATCH 1/2 ipvsadm: restrict different address family

Now real server can have different address family only for tunneling. For other modes it must match the service.

---
 ipvsadm.c | 6 ++++++
 1 file changed, 6 insertions(+)
ipvsadm.c +6 -0
index d12070e..3000117 100644
@@ -788,6 +788,12 @@ static int process_options(int argc, char **argv, int reading_stdin)
 		    (ce.dest.conn_flags == IP_VS_CONN_F_TUNNEL
 		     || ce.dest.conn_flags == IP_VS_CONN_F_DROUTE))
 			ce.dest.port = ce.svc.port;
+
+		/* Tunneling allows different address family */
+		if (ce.dest.af != ce.svc.af &&
+		    ce.dest.conn_flags != IP_VS_CONN_F_TUNNEL)
+			fail(2, "Different address family is allowed only "
+			     "for tunneling servers");
 	}
 
 	switch (ce.cmd) {
Signature · 1 line
1.9.0
author maintainer
#2 lore raw

PATCH 2/2 ipvsadm: allow different address family in connection listing

In reply to Julian Anastasov

Real server can have different address family, fix it for connection listing.

---
 ipvsadm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
ipvsadm.c +7 -4
index 3000117..7263d03 100644
@@ -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;
Signature · 1 line
1.9.0
#3 lore raw
In reply to Julian Anastasov
Quoted 4 lines · On Sat, 30 Aug 2014 14:35:47 +0300 Julian Anastasov <[email protected]> wrote:

Following are 2 patches that support different address family for virtual and real server.

Alex, please test them too.

Do you want me to apply these right away, or should we wait for Alex'es tests?

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
author maintainer
#4 lore raw

Hello,

Quoted 9 lines · Jesper Dangaard Brouer
Quoted 4 lines · On Sat, 30 Aug 2014 14:35:47 +0300 Julian Anastasov <[email protected]> wrote:

Following are 2 patches that support different address family for virtual and real server.

Alex, please test them too.

Do you want me to apply these right away, or should we wait for Alex'es tests?

Lets wait for the tests. I'll ping you again
if needed.

Regards

--
Julian Anastasov <[email protected]>