diff mbox

[net-next,1/2] ip_gre: increase inner ip header ID during segmentation

Message ID 1363948292-9902-1-git-send-email-amwang@redhat.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Amerigo Wang March 22, 2013, 10:31 a.m. UTC
From: Cong Wang <amwang@redhat.com>

According to the previous discussion [1] on netdev list, DaveM insists
we should increase the IP header ID for each segmented packets.
This patch fixes it.

Cc: Pravin B Shelar <pshelar@nicira.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

1. http://marc.info/?t=136384172700001&r=1&w=2

---
 net/ipv4/gre.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

Comments

David Miller March 22, 2013, 2:24 p.m. UTC | #1
From: Cong Wang <amwang@redhat.com>
Date: Fri, 22 Mar 2013 18:31:31 +0800

> From: Cong Wang <amwang@redhat.com>
> 
> According to the previous discussion [1] on netdev list, DaveM insists
> we should increase the IP header ID for each segmented packets.
> This patch fixes it.
> 
> Cc: Pravin B Shelar <pshelar@nicira.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pravin B Shelar March 22, 2013, 5:12 p.m. UTC | #2
On Fri, Mar 22, 2013 at 3:31 AM, Cong Wang <amwang@redhat.com> wrote:
> From: Cong Wang <amwang@redhat.com>
>
> According to the previous discussion [1] on netdev list, DaveM insists
> we should increase the IP header ID for each segmented packets.
> This patch fixes it.
>

Outer IP header ids are incremented in inet_gso_segment for GRE. So it
is already done. In any case I don't think we should increment
IP-Identification in GRE handler, This is layering violation.
This breaks GRE with IPV6 payload.

> Cc: Pravin B Shelar <pshelar@nicira.com>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>
>
> 1. http://marc.info/?t=136384172700001&r=1&w=2
>
> ---
>  net/ipv4/gre.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
> index 7a4c710..e20631c 100644
> --- a/net/ipv4/gre.c
> +++ b/net/ipv4/gre.c
> @@ -125,8 +125,9 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
>         netdev_features_t enc_features;
>         int ghl = GRE_HEADER_SECTION;
>         struct gre_base_hdr *greh;
> +       struct iphdr *iph;
>         int mac_len = skb->mac_len;
> -       int tnl_hlen;
> +       int tnl_hlen, id;
>         bool csum;
>
>         if (unlikely(skb_shinfo(skb)->gso_type &
> @@ -170,6 +171,8 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
>         skb_set_network_header(skb, skb_inner_network_offset(skb));
>         skb->mac_len = skb_inner_network_offset(skb);
>
> +       iph = ip_hdr(skb);
> +       id = ntohs(iph->id);
>         /* segment inner packet. */
>         enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
>         segs = skb_mac_gso_segment(skb, enc_features);
> @@ -179,6 +182,8 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
>         skb = segs;
>         tnl_hlen = skb_tnl_header_len(skb);
>         do {
> +               iph = (struct iphdr *)skb->data;
> +               iph->id = htons(id++);
>                 __skb_push(skb, ghl);
>                 if (csum) {
>                         __be32 *pcsum;
> --
> 1.7.7.6
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Amerigo Wang March 23, 2013, 3:25 a.m. UTC | #3
On Fri, 2013-03-22 at 10:12 -0700, Pravin Shelar wrote:
> On Fri, Mar 22, 2013 at 3:31 AM, Cong Wang <amwang@redhat.com> wrote:
> > From: Cong Wang <amwang@redhat.com>
> >
> > According to the previous discussion [1] on netdev list, DaveM insists
> > we should increase the IP header ID for each segmented packets.
> > This patch fixes it.
> >
> 
> Outer IP header ids are incremented in inet_gso_segment for GRE. So it
> is already done. In any case I don't think we should increment
> IP-Identification in GRE handler, This is layering violation.
> This breaks GRE with IPV6 payload.

I knew, $subject mentions this increases the *inner* IP header ID, not
outer one.

But you are probably right that we should check for IPv4, I will send
patch to fix it.

Thanks.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
index 7a4c710..e20631c 100644
--- a/net/ipv4/gre.c
+++ b/net/ipv4/gre.c
@@ -125,8 +125,9 @@  static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 	netdev_features_t enc_features;
 	int ghl = GRE_HEADER_SECTION;
 	struct gre_base_hdr *greh;
+	struct iphdr *iph;
 	int mac_len = skb->mac_len;
-	int tnl_hlen;
+	int tnl_hlen, id;
 	bool csum;
 
 	if (unlikely(skb_shinfo(skb)->gso_type &
@@ -170,6 +171,8 @@  static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 	skb_set_network_header(skb, skb_inner_network_offset(skb));
 	skb->mac_len = skb_inner_network_offset(skb);
 
+	iph = ip_hdr(skb);
+	id = ntohs(iph->id);
 	/* segment inner packet. */
 	enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);
 	segs = skb_mac_gso_segment(skb, enc_features);
@@ -179,6 +182,8 @@  static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
 	skb = segs;
 	tnl_hlen = skb_tnl_header_len(skb);
 	do {
+		iph = (struct iphdr *)skb->data;
+		iph->id = htons(id++);
 		__skb_push(skb, ghl);
 		if (csum) {
 			__be32 *pcsum;