Skip to contentSkip to conversation

ipvs: fix AF assignment in ip_vs_conn_new()

PATCH RESEND Superseded Michal Kubecek 3 participants 6 messages Jan 29, 2014 – Feb 4, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 ipvs: fix AF assignment in ip_vs_conn_new()

If a fwmark is passed to ip_vs_conn_new(), it is passed in vaddr, not daddr. Therefore we should set AF to AF_UNSPEC in vaddr assignment (like we do in ip_vs_ct_in_get()).

---
(first time it didn't reach all recipients due to a malformed header)

---
 net/netfilter/ipvs/ip_vs_conn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +4 -4
index 59a1a85..282b39b 100644
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, vaddr);
+	cp->vport	   = p->vport;
+	ip_vs_addr_set(p->af, &cp->daddr, p->daddr);
 	cp->dport          = dport;
 	cp->flags	   = flags;
 	cp->fwmark         = fwmark;
Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

Hello,

Quoted 17 lines · Michal Kubecek

If a fwmark is passed to ip_vs_conn_new(), it is passed in vaddr, not daddr. Therefore we should set AF to AF_UNSPEC in vaddr assignment (like we do in ip_vs_ct_in_get()).

---
(first time it didn't reach all recipients due to a malformed header)

---
 net/netfilter/ipvs/ip_vs_conn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +0 -0
index 59a1a85..282b39b 100644

net/netfilter/ipvs/ip_vs_conn.c ip_vs_conn_new(const struct ip_vs_conn_param *p, · line 876

Quoted 10 lines
net/netfilter/ipvs/ip_vs_conn.c +2 -4
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, vaddr);
	Patch does not compile due to vaddr and p->daddr

usage but you are in the right direction. Such change should fix a problem where connection templates don't get full IPv6 address for the real server, only the first 4 bytes are copied and as result it works only for IPv4.

Quoted 7 lines
net/netfilter/ipvs/ip_vs_conn.c +2 -0
+	cp->vport	   = p->vport;
+	ip_vs_addr_set(p->af, &cp->daddr, p->daddr);
 	cp->dport          = dport;
 	cp->flags	   = flags;
 	cp->fwmark         = fwmark;
Signature · 1 line
1.8.1.4

Regards

--
Julian Anastasov <[email protected]>

#2 lore raw
Quoted 17 lines · Julian Anastasov
Quoted 5 lines
net/netfilter/ipvs/ip_vs_conn.c +0 -0
index 59a1a85..282b39b 100644

net/netfilter/ipvs/ip_vs_conn.c ip_vs_conn_new(const struct ip_vs_conn_param *p, · line 876

Quoted 10 lines
net/netfilter/ipvs/ip_vs_conn.c +2 -4
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, vaddr);
	Patch does not compile due to vaddr and p->daddr
Quoted 4 lines

usage but you are in the right direction. Such change should fix a problem where connection templates don't get full IPv6 address for the real server, only the first 4 bytes are copied and as result it works only for IPv4.

Sorry for that, looks like I ran the test build after adapting to current code with a config which didn't actually compile this file. I'll send a v2 after testing a fixed version and I'll also extend the commit message to describe the outcome.

Michal Kubecek

#3 lore raw

PATCH v2 1/1 ipvs: fix AF assignment in ip_vs_conn_new()

In reply to Julian Anastasov

If a fwmark is passed to ip_vs_conn_new(), it is passed in vaddr, not daddr. Therefore we should set AF to AF_UNSPEC in vaddr assignment (like we do in ip_vs_ct_in_get()), otherwise we may copy only first 4 bytes of an IPv6 address into cp->daddr.

v2: fix messed up {d,v}addr and p->{d,v}addr, add info about the outcome (thanks to Julian Anastasov)

---
 net/netfilter/ipvs/ip_vs_conn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +4 -4
index 59a1a85..a8eb0a8 100644
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, p->vaddr);
+	cp->vport	   = p->vport;
+	ip_vs_addr_set(p->af, &cp->daddr, daddr);
 	cp->dport          = dport;
 	cp->flags	   = flags;
 	cp->fwmark         = fwmark;
Signature · 1 line
1.8.1.4
maintainer Acked-by on v2 1/1
#4 lore raw

Hello,

Quoted 10 lines · Michal Kubecek

If a fwmark is passed to ip_vs_conn_new(), it is passed in vaddr, not daddr. Therefore we should set AF to AF_UNSPEC in vaddr assignment (like we do in ip_vs_ct_in_get()), otherwise we may copy only first 4 bytes of an IPv6 address into cp->daddr.

v2: fix messed up {d,v}addr and p->{d,v}addr, add info about the outcome (thanks to Julian Anastasov)

Looks like problem comes from
commit be8be9eccbf2d908a7e56b3f7a71105cd88da06b "ipvs: Fix IPv4 FWMARK virtual services" (2.6.30).

Quoted 26 lines
---
 net/netfilter/ipvs/ip_vs_conn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +4 -4
index 59a1a85..a8eb0a8 100644
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, p->vaddr);
+	cp->vport	   = p->vport;
+	ip_vs_addr_set(p->af, &cp->daddr, daddr);
 	cp->dport          = dport;
 	cp->flags	   = flags;
 	cp->fwmark         = fwmark;
Signature · 1 line
1.8.1.4

Regards

--
Julian Anastasov <[email protected]>

maintainer
#5 lore raw
Quoted 13 lines · Julian Anastasov

Hello,

Quoted 8 lines · Michal Kubecek

If a fwmark is passed to ip_vs_conn_new(), it is passed in vaddr, not daddr. Therefore we should set AF to AF_UNSPEC in vaddr assignment (like we do in ip_vs_ct_in_get()), otherwise we may copy only first 4 bytes of an IPv6 address into cp->daddr.

v2: fix messed up {d,v}addr and p->{d,v}addr, add info about the outcome (thanks to Julian Anastasov)

Quoted 8 lines
Quoted 2 lines

Looks like problem comes from
commit be8be9eccbf2d908a7e56b3f7a71105cd88da06b "ipvs: Fix IPv4 FWMARK virtual services" (2.6.30).

Thanks, I'll queue this up.

Quoted 33 lines
Quoted 27 lines
---
 net/netfilter/ipvs/ip_vs_conn.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_conn.c +4 -4
index 59a1a85..a8eb0a8 100644
@@ -871,11 +871,11 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
 	cp->protocol	   = p->protocol;
 	ip_vs_addr_set(p->af, &cp->caddr, p->caddr);
 	cp->cport	   = p->cport;
-	ip_vs_addr_set(p->af, &cp->vaddr, p->vaddr);
-	cp->vport	   = p->vport;
-	/* proto should only be IPPROTO_IP if d_addr is a fwmark */
+	/* proto should only be IPPROTO_IP if p->vaddr is a fwmark */
 	ip_vs_addr_set(p->protocol == IPPROTO_IP ? AF_UNSPEC : p->af,
-		       &cp->daddr, daddr);
+		       &cp->vaddr, p->vaddr);
+	cp->vport	   = p->vport;
+	ip_vs_addr_set(p->af, &cp->daddr, daddr);
 	cp->dport          = dport;
 	cp->flags	   = flags;
 	cp->fwmark         = fwmark;
Signature · 1 line
1.8.1.4

Regards

--
Julian Anastasov <[email protected]>