From: "Timo Teräs" <timo.teras@iki.fi>
To: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
davem@davemloft.net, netdev@vger.kernel.org
Subject: [RFC][PATCH][IPV4] ip_gre: use skb->{mac,network}_header consistently
Date: Tue, 18 Dec 2007 15:59:37 +0200 [thread overview]
Message-ID: <4767D249.5050602@iki.fi> (raw)
In-Reply-To: <20071024100842.GA19369@ms2.inr.ac.ru>
From: Timo Teras <timo.teras@iki.fi>
Make both send and receive paths use consistently skb->*_header:
mac_header = outer IPv4 header
network_header = encapsulated packet (e.g. inner IPv4 header)
Signed-off-by: Timo Teras <timo.teras@iki.fi>
---
Currently in send path:
network_header = outer IPv4 header
transport_header = encapsulated packet
And receive path:
network_header = encapsulated packet
mac_header = GRE header
mac_header used to be the outer IPv4 header on receive path, but it was
broken/changed when skb_reset_mac_header() was introduced.
This also makes ipgre_header_parse() work correctly as it assumes that
mac_header points to the outer IPv4 header always. Though, it returns
zeros for outgoing packets that are tcpdumped from gre tunnel without
explicit local address, since the routing is done in ipgre_tunnel_xmit().
net/ipv4/ip_gre.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 02b02a8..eba1ade 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -613,7 +613,7 @@ static int ipgre_rcv(struct sk_buff *skb)
offset += 4;
}
- skb_reset_mac_header(skb);
+ skb->mac_header = skb->network_header;
__pskb_pull(skb, offset);
skb_reset_network_header(skb);
skb_postpull_rcsum(skb, skb_transport_header(skb), offset);
@@ -826,9 +826,8 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
old_iph = ip_hdr(skb);
}
- skb->transport_header = skb->network_header;
skb_push(skb, gre_hlen);
- skb_reset_network_header(skb);
+ skb_reset_mac_header(skb);
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
IPSKB_REROUTED);
@@ -839,7 +838,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
* Push down and install the IPIP header.
*/
- iph = ip_hdr(skb);
+ iph = (struct iphdr *) skb_mac_header(skb);
iph->version = 4;
iph->ihl = sizeof(struct iphdr) >> 2;
iph->frag_off = df;
@@ -1070,6 +1069,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
__be16 *p = (__be16*)(iph+1);
+ skb_reset_mac_header(skb);
memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
p[0] = t->parms.o_flags;
p[1] = htons(type);
--
1.5.2.5
next prev parent reply other threads:[~2007-12-18 13:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-23 14:31 [PATCH RESEND] ip_gre: sendto/recvfrom NBMA address Timo Teräs
2007-10-23 14:33 ` Patrick McHardy
2007-10-23 15:08 ` Timo Teräs
2007-10-23 15:57 ` Timo Teräs
2007-10-23 16:10 ` Patrick McHardy
2007-10-23 19:03 ` Alexey Kuznetsov
2007-10-24 3:32 ` David Miller
2007-10-23 20:20 ` Alexey Kuznetsov
2007-10-24 5:54 ` Timo Teräs
2007-10-24 10:08 ` Alexey Kuznetsov
2007-12-18 13:59 ` Timo Teräs [this message]
2007-12-19 18:10 ` [PATCH][IPV4] ip_gre: set mac_header correctly in receive path Timo Teräs
2007-12-20 8:11 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4767D249.5050602@iki.fi \
--to=timo.teras@iki.fi \
--cc=davem@davemloft.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).