Skip to contentSkip to conversation

ipvs: Use IP_VS_RT_MODE_* instead of magic constants.

PATCH In review David Miller 3 participants 8 messages May 10, 2011 – May 12, 2011

Subsystems (4)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 4/10 ipvs: Use IP_VS_RT_MODE_* instead of magic constants.

---
 net/netfilter/ipvs/ip_vs_xmit.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
net/netfilter/ipvs/ip_vs_xmit.c +12 -5
index 6132b21..c4a19f9 100644
@@ -440,7 +440,8 @@ ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 
 	EnterFunction(10);
 
-	if (!(rt = __ip_vs_get_out_rt_v6(skb, NULL, &iph->daddr, NULL, 0, 2)))
+	if (!(rt = __ip_vs_get_out_rt_v6(skb, NULL, &iph->daddr, NULL, 0,
+					 IP_VS_RT_MODE_NON_LOCAL)))
 		goto tx_error_icmp;
 
 	/* MTU checking */
@@ -632,7 +633,9 @@ ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 	}
 
 	if (!(rt = __ip_vs_get_out_rt_v6(skb, cp->dest, &cp->daddr.in6, NULL,
-					 0, 1|2|4)))
+					 0, (IP_VS_RT_MODE_LOCAL |
+					     IP_VS_RT_MODE_NON_LOCAL |
+					     IP_VS_RT_MODE_RDR))))
 		goto tx_error_icmp;
 	local = __ip_vs_is_local_route6(rt);
 	/*
@@ -875,7 +878,8 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 	EnterFunction(10);
 
 	if (!(rt = __ip_vs_get_out_rt_v6(skb, cp->dest, &cp->daddr.in6,
-					 &saddr, 1, 1|2)))
+					 &saddr, 1, (IP_VS_RT_MODE_LOCAL |
+						     IP_VS_RT_MODE_NON_LOCAL))))
 		goto tx_error_icmp;
 	if (__ip_vs_is_local_route6(rt)) {
 		dst_release(&rt->dst);
@@ -1050,7 +1054,8 @@ ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 	EnterFunction(10);
 
 	if (!(rt = __ip_vs_get_out_rt_v6(skb, cp->dest, &cp->daddr.in6, NULL,
-					 0, 1|2)))
+					 0, (IP_VS_RT_MODE_LOCAL |
+					     IP_VS_RT_MODE_NON_LOCAL))))
 		goto tx_error_icmp;
 	if (__ip_vs_is_local_route6(rt)) {
 		dst_release(&rt->dst);
@@ -1254,7 +1259,9 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
 	 */
 
 	if (!(rt = __ip_vs_get_out_rt_v6(skb, cp->dest, &cp->daddr.in6, NULL,
-					 0, 1|2|4)))
+					 0, (IP_VS_RT_MODE_LOCAL |
+					     IP_VS_RT_MODE_NON_LOCAL |
+					     IP_VS_RT_MODE_RDR))))
 		goto tx_error_icmp;
 
 	local = __ip_vs_is_local_route6(rt);
Signature · 1 line
1.7.5.1
maintainer
#1 lore raw

Fix more IP_VS_RT_MODE_* constants

---

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

net/netfilter/ipvs/ip_vs_xmit.c renamed from linux/net/netfilter/ipvs/ip_vs_xmit.c +3 -4
diff -urp net-next-2.6-7ef73bc/linux/net/netfilter/ipvs/ip_vs_xmit.c linux/net/netfilter/ipvs/ip_vs_xmit.c
@@ -230,8 +230,6 @@ out_err:
 
 /*
  * Get route to destination or remote server
- * rt_mode: flags, &1=Allow local dest, &2=Allow non-local dest,
- *	    &4=Allow redirect from remote daddr to local
  */
 static struct rt6_info *
 __ip_vs_get_out_rt_v6(struct sk_buff *skb, struct ip_vs_dest *dest,
@@ -275,13 +273,14 @@ __ip_vs_get_out_rt_v6(struct sk_buff *sk
 	}
 
 	local = __ip_vs_is_local_route6(rt);
-	if (!((local ? 1 : 2) & rt_mode)) {
+	if (!((local ? IP_VS_RT_MODE_LOCAL : IP_VS_RT_MODE_NON_LOCAL) &
+	      rt_mode)) {
 		IP_VS_DBG_RL("Stopping traffic to %s address, dest: %pI6\n",
 			     local ? "local":"non-local", daddr);
 		dst_release(&rt->dst);
 		return NULL;
 	}
-	if (local && !(rt_mode & 4) &&
+	if (local && !(rt_mode & IP_VS_RT_MODE_RDR) &&
 	    !((ort = (struct rt6_info *) skb_dst(skb)) &&
 	      __ip_vs_is_local_route6(ort))) {
 		IP_VS_DBG_RL("Redirect from non-local address %pI6 to local "
author maintainer
#2 lore raw

From: Julian Anastasov <[email protected]>
Date: Wed, 11 May 2011 01:26:09 +0300 (EEST)

Quoted 9 lines

Fix more IP_VS_RT_MODE_* constants

---

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

Thanks Julian.

What I'm going to do is hold back the IPVS parts of the patches I posted last night. In particular, I'll integrate this into the original patch #4.

And then we can work through the reimplementation ideas you posted to me in private email.

If you could post those ideas here on the list I'd appreciate it, so others can follow along and provide feedback.

Thanks!

maintainer
#3 lore raw

Hello,

Quoted 15 lines · David Miller
Quoted 8 lines

Fix more IP_VS_RT_MODE_* constants

---

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

Thanks Julian.

What I'm going to do is hold back the IPVS parts of the patches I posted last night. In particular, I'll integrate this into the original patch #4.

Quoted 5 lines

And then we can work through the reimplementation ideas you posted to me in private email.

If you could post those ideas here on the list I'd appreciate it, so others can follow along and provide feedback.

I think, I included the main things in the comments
with patch 7. I forgot to tell that I'll do some IPVS-IPv4 tests tomorrow. May be Hans will test the patches too.

Regards

--
Julian Anastasov <[email protected]>

#4 lore raw

Hi

Quoted 23 lines · On Wednesday 11 May 2011 01:24:42 Julian Anastasov wrote:

Hello,

Quoted 18 lines · David Miller
Quoted 8 lines

Fix more IP_VS_RT_MODE_* constants

---

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

Thanks Julian.

What I'm going to do is hold back the IPVS parts of the patches I posted last night. In particular, I'll integrate this into the original patch #4.

And then we can work through the reimplementation ideas you posted to me in private email.

Quoted 6 lines
Quoted 2 lines

If you could post those ideas here on the list I'd appreciate it, so others can follow along and provide feedback.

I think, I included the main things in the comments
with patch 7. I forgot to tell that I'll do some IPVS-IPv4 tests tomorrow. May be Hans will test the patches too.

It all looks good to me, I'll do some tests today.

Quoted 5 lines

Regards

--
Julian Anastasov <[email protected]>

Signature · 2 lines
Regards
Hans Schillstrom <[email protected]>
maintainer
#5 lore raw
In reply to David Miller

Hello,

Quoted 4 lines · David Miller
Quoted 3 lines

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

Quoted 8 lines

Thanks Julian.

What I'm going to do is hold back the IPVS parts of the patches I posted last night. In particular, I'll integrate this into the original patch #4.

And then we can work through the reimplementation ideas you posted to me in private email.

My simple tests do not show any problems with patches
4, 5 and the new 6 and 7. I tested TUN mode for rt_src/rt_dst and DR/NAT for rt_dst replacement, related ICMP is relayed properly. So, we should be ok but I'll do more tests in the following days because the list with possible combinations for testing is too long: different forwarding mode (DR/TUN/NAT), local or remote real server, local or remote client,
In or Out related ICMP, Passive or Active FTP...

Regards

--
Julian Anastasov <[email protected]>

#6 lore raw
Quoted 18 lines · On Thursday 12 May 2011 01:32:09 Julian Anastasov wrote:

Hello,

Quoted 4 lines · David Miller
Quoted 3 lines

Following patch can be used after patch 4, eg. as
number 6 because patches 4 and 5 are ok and we are going to replace patches 6 and 7.

Quoted 8 lines

Thanks Julian.

What I'm going to do is hold back the IPVS parts of the patches I posted last night. In particular, I'll integrate this into the original patch #4.

And then we can work through the reimplementation ideas you posted to me in private email.

Quoted 9 lines

My simple tests do not show any problems with patches
4, 5 and the new 6 and 7. I tested TUN mode for rt_src/rt_dst and DR/NAT for rt_dst replacement, related ICMP is relayed properly. So, we should be ok but I'll do more tests in the following days because the list with possible combinations for testing is too long: different forwarding mode (DR/TUN/NAT), local or remote real server, local or remote client,
In or Out related ICMP, Passive or Active FTP...

I will try to test the Backup/Failover aspects of above

Signature · 2 lines
Regards
Hans Schillstrom <[email protected]>
author maintainer
#7 lore raw
In reply to Julian Anastasov

From: Julian Anastasov <[email protected]>
Date: Thu, 12 May 2011 02:32:09 +0300 (EEST)

Quoted 8 lines

My simple tests do not show any problems with patches
4, 5 and the new 6 and 7. I tested TUN mode for rt_src/rt_dst and DR/NAT for rt_dst replacement, related ICMP is relayed properly. So, we should be ok but I'll do more tests in the following days because the list with possible combinations for testing is too long: different forwarding mode (DR/TUN/NAT), local or remote real server, local or remote client,
In or Out related ICMP, Passive or Active FTP...

Julian, I integrated your work and pushed 3 patches to net-next-2.6

1) Original patch #4 with your followup integrated
2) Original patch #5
3) You're replacement for original patch #6 and #7

Let me know if there are any followup fixes that we need to work on.

Thanks!