netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ipv4: Respect 'saddr' and 'daddr' args to ip_build_and_send_pkt().
@ 2011-04-26 22:12 David Miller
  2011-04-27 21:03 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2011-04-26 22:12 UTC (permalink / raw)
  To: netdev


This function ignores the passed in addresses and forces their
settings using rt->rt_dst and rt->rt_src.

There is never a reason to do this, because the socket of the
callers of this function must know what addresses it is using.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/ip_output.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index bdad3d6..e0d0d5d 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -158,8 +158,8 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
 	else
 		iph->frag_off = 0;
 	iph->ttl      = ip_select_ttl(inet, &rt->dst);
-	iph->daddr    = rt->rt_dst;
-	iph->saddr    = rt->rt_src;
+	iph->daddr    = daddr;
+	iph->saddr    = saddr;
 	iph->protocol = sk->sk_protocol;
 	ip_select_ident(iph, &rt->dst, sk);
 
-- 
1.7.4.5


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

* Re: [PATCH 1/4] ipv4: Respect 'saddr' and 'daddr' args to ip_build_and_send_pkt().
  2011-04-26 22:12 [PATCH 1/4] ipv4: Respect 'saddr' and 'daddr' args to ip_build_and_send_pkt() David Miller
@ 2011-04-27 21:03 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-04-27 21:03 UTC (permalink / raw)
  To: netdev

From: David Miller <davem@davemloft.net>
Date: Tue, 26 Apr 2011 15:12:00 -0700 (PDT)

> 
> This function ignores the passed in addresses and forces their
> settings using rt->rt_dst and rt->rt_src.
> 
> There is never a reason to do this, because the socket of the
> callers of this function must know what addresses it is using.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>

I did not end up applying this one to net-next-2.6, it's not correct.
It would break things when the source routing is enabled on the
socket.

When that happens, we look up the route to the SRR options's first
entry, not the actual final destination.  And that initial SRR option
address is the destination IP address we need to use in the IP header
this we need to use rt->rt_{src,dst}.

This could be implemented properly by doing something like:

	if (opt && opt->srr)
		iph->daddr = x;
	else
		iph->daddr = daddr;

I'll think about it.

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

end of thread, other threads:[~2011-04-27 21:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26 22:12 [PATCH 1/4] ipv4: Respect 'saddr' and 'daddr' args to ip_build_and_send_pkt() David Miller
2011-04-27 21:03 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).