Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] ipv4: one more case for non-local saddr in ICMP
@ 2011-08-15 16:21 Julian Anastasov
  2011-08-19 10:43 ` David Miller
  2011-08-25  2:37 ` David Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Julian Anastasov @ 2011-08-15 16:21 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Herbert Xu


	May be there is one more case that we can avoid using
non-local source for ICMP errors: xfrm_lookup, num_xfrms = 0 when
reverse "Flow passes untransformed". Avoid using the input route
if xfrm_lookup returns same dst.

Signed-off-by: Julian Anastasov <ja@ssi.bg>
---

	In fact, should we use local IP in all cases when
sending ICMP? I'm asking it for the following case:

	Large packet is forwarded but is rejected with ICMP FRAG
NEEDED. We usually send ICMP with local saddr instead of the
original non-local destination. What is the role of
this reverse check? May be after xfrm_decode_session_reverse
we should use 'fl4_dec.saddr = fl4->saddr;' so that xfrm_lookup
works with ICMP from local IP? What is right thing to do here?
I don't see code that looks in the embedded header...

--- net-next/net/ipv4/icmp.c	2011-08-15 18:42:21.289899686 +0300
+++ linux/net/ipv4/icmp.c	2011-08-15 18:38:25.816244111 +0300
@@ -379,7 +379,7 @@ static struct rtable *icmp_route_lookup(
 					int type, int code,
 					struct icmp_bxm *param)
 {
-	struct rtable *rt, *rt2;
+	struct rtable *rt, *rt2, *rt3;
 	struct flowi4 fl4_dec;
 	int err;
 
@@ -440,13 +440,18 @@ static struct rtable *icmp_route_lookup(
 	if (err)
 		goto relookup_failed;
 
+	rt3 = rt2;
 	rt2 = (struct rtable *) xfrm_lookup(net, &rt2->dst,
 					    flowi4_to_flowi(&fl4_dec), NULL,
 					    XFRM_LOOKUP_ICMP);
 	if (!IS_ERR(rt2)) {
-		dst_release(&rt->dst);
-		memcpy(fl4, &fl4_dec, sizeof(*fl4));
-		rt = rt2;
+		if (rt2 == rt3 && rt) {
+			dst_release(&rt2->dst);
+		} else {
+			dst_release(&rt->dst);
+			memcpy(fl4, &fl4_dec, sizeof(*fl4));
+			rt = rt2;
+		}
 	} else if (PTR_ERR(rt2) == -EPERM) {
 		if (rt)
 			dst_release(&rt->dst);

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-25  7:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-15 16:21 [PATCH net-next] ipv4: one more case for non-local saddr in ICMP Julian Anastasov
2011-08-19 10:43 ` David Miller
2011-08-20  8:20   ` Herbert Xu
2011-08-23  6:34     ` Julian Anastasov
2011-08-23  6:46       ` Herbert Xu
2011-08-25  2:37 ` David Miller
2011-08-25  7:25   ` Julian Anastasov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox