From c56fd7ebd442c7986826dad06c7aff402bafb144 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 30 Nov 2011 19:00:53 +0000 Subject: [PATCH] --- yaml --- r: 278320 b: refs/heads/master c: 84f9307c5da84a7c8513e7607dc8427d2cbd63e3 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/net/flow.h | 5 ++++- trunk/net/ipv4/ip_output.c | 21 +++++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index f2078136a2d0..f70d7edba948 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 898f73585bbe4bdbb471636ecdede071f7473e51 +refs/heads/master: 84f9307c5da84a7c8513e7607dc8427d2cbd63e3 diff --git a/trunk/include/net/flow.h b/trunk/include/net/flow.h index a09447749e2d..9192d690b562 100644 --- a/trunk/include/net/flow.h +++ b/trunk/include/net/flow.h @@ -59,8 +59,11 @@ struct flowi4 { #define flowi4_proto __fl_common.flowic_proto #define flowi4_flags __fl_common.flowic_flags #define flowi4_secid __fl_common.flowic_secid - __be32 daddr; + + /* (saddr,daddr) must be grouped, same order as in IP header */ __be32 saddr; + __be32 daddr; + union flowi_uli uli; #define fl4_sport uli.ports.sport #define fl4_dport uli.ports.dport diff --git a/trunk/net/ipv4/ip_output.c b/trunk/net/ipv4/ip_output.c index 0bc95f3977d2..0d5e5672f3d1 100644 --- a/trunk/net/ipv4/ip_output.c +++ b/trunk/net/ipv4/ip_output.c @@ -319,6 +319,20 @@ int ip_output(struct sk_buff *skb) !(IPCB(skb)->flags & IPSKB_REROUTED)); } +/* + * copy saddr and daddr, possibly using 64bit load/stores + * Equivalent to : + * iph->saddr = fl4->saddr; + * iph->daddr = fl4->daddr; + */ +static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4) +{ + BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) != + offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr)); + memcpy(&iph->saddr, &fl4->saddr, + sizeof(fl4->saddr) + sizeof(fl4->daddr)); +} + int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl) { struct sock *sk = skb->sk; @@ -381,8 +395,8 @@ int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl) iph->frag_off = 0; iph->ttl = ip_select_ttl(inet, &rt->dst); iph->protocol = sk->sk_protocol; - iph->saddr = fl4->saddr; - iph->daddr = fl4->daddr; + ip_copy_addrs(iph, fl4); + /* Transport layer set skb->h.foo itself. */ if (inet_opt && inet_opt->opt.optlen) { @@ -1337,8 +1351,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk, ip_select_ident(iph, &rt->dst, sk); iph->ttl = ttl; iph->protocol = sk->sk_protocol; - iph->saddr = fl4->saddr; - iph->daddr = fl4->daddr; + ip_copy_addrs(iph, fl4); if (opt) { iph->ihl += opt->optlen>>2;