aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/ip_output.c14
-rw-r--r--net/ipv4/ipmr.c9
2 files changed, 12 insertions, 11 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index dde51fb72cda..99cd90c22310 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -125,11 +125,9 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
125 struct iphdr *iph; 125 struct iphdr *iph;
126 126
127 /* Build the IP header. */ 127 /* Build the IP header. */
128 if (opt) 128 skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0));
129 iph=(struct iphdr *)skb_push(skb,sizeof(struct iphdr) + opt->optlen); 129 skb_reset_network_header(skb);
130 else 130 iph = skb->nh.iph;
131 iph=(struct iphdr *)skb_push(skb,sizeof(struct iphdr));
132
133 iph->version = 4; 131 iph->version = 4;
134 iph->ihl = 5; 132 iph->ihl = 5;
135 iph->tos = inet->tos; 133 iph->tos = inet->tos;
@@ -143,7 +141,6 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
143 iph->protocol = sk->sk_protocol; 141 iph->protocol = sk->sk_protocol;
144 iph->tot_len = htons(skb->len); 142 iph->tot_len = htons(skb->len);
145 ip_select_ident(iph, &rt->u.dst, sk); 143 ip_select_ident(iph, &rt->u.dst, sk);
146 skb->nh.iph = iph;
147 144
148 if (opt && opt->optlen) { 145 if (opt && opt->optlen) {
149 iph->ihl += opt->optlen>>2; 146 iph->ihl += opt->optlen>>2;
@@ -333,7 +330,9 @@ packet_routed:
333 goto no_route; 330 goto no_route;
334 331
335 /* OK, we know where to send it, allocate and build IP header. */ 332 /* OK, we know where to send it, allocate and build IP header. */
336 iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); 333 skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0));
334 skb_reset_network_header(skb);
335 iph = skb->nh.iph;
337 *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); 336 *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
338 iph->tot_len = htons(skb->len); 337 iph->tot_len = htons(skb->len);
339 if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok) 338 if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok)
@@ -344,7 +343,6 @@ packet_routed:
344 iph->protocol = sk->sk_protocol; 343 iph->protocol = sk->sk_protocol;
345 iph->saddr = rt->rt_src; 344 iph->saddr = rt->rt_src;
346 iph->daddr = rt->rt_dst; 345 iph->daddr = rt->rt_dst;
347 skb->nh.iph = iph;
348 /* Transport layer set skb->h.foo itself. */ 346 /* Transport layer set skb->h.foo itself. */
349 347
350 if (opt && opt->optlen) { 348 if (opt && opt->optlen) {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 45435f0a5d6c..51528d3cc334 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1093,7 +1093,12 @@ static struct notifier_block ip_mr_notifier={
1093 1093
1094static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr) 1094static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
1095{ 1095{
1096 struct iphdr *iph = (struct iphdr *)skb_push(skb,sizeof(struct iphdr)); 1096 struct iphdr *iph;
1097
1098 skb_push(skb, sizeof(struct iphdr));
1099 skb->h.ipiph = skb->nh.iph;
1100 skb_reset_network_header(skb);
1101 iph = skb->nh.iph;
1097 1102
1098 iph->version = 4; 1103 iph->version = 4;
1099 iph->tos = skb->nh.iph->tos; 1104 iph->tos = skb->nh.iph->tos;
@@ -1107,8 +1112,6 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
1107 ip_select_ident(iph, skb->dst, NULL); 1112 ip_select_ident(iph, skb->dst, NULL);
1108 ip_send_check(iph); 1113 ip_send_check(iph);
1109 1114
1110 skb->h.ipiph = skb->nh.iph;
1111 skb->nh.iph = iph;
1112 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 1115 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
1113 nf_reset(skb); 1116 nf_reset(skb);
1114} 1117}