ip6_gre: reload ipv6h in prepare_ip6gre_xmit_ipv6 [Linux 4.19.66]

This Linux kernel change "ip6_gre: reload ipv6h in prepare_ip6gre_xmit_ipv6" is included in the Linux 4.19.66 release. This change is authored by Haishuang Yan <yanhaishuang [at] cmss.chinamobile.com> on Wed Jul 24 20:00:42 2019 +0800. The commit for this change in Linux stable tree is fdcefa4 (patch) which is from upstream commit 3bc817d. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 3bc817d.

ip6_gre: reload ipv6h in prepare_ip6gre_xmit_ipv6

[ Upstream commit 3bc817d665ac6d9de89f59df522ad86f5b5dfc03 ]

Since ip6_tnl_parse_tlv_enc_lim() can call pskb_may_pull()
which may change skb->data, so we need to re-load ipv6h at
the right place.

Fixes: 898b29798e36 ("ip6_gre: Refactor ip6gre xmit codes")
Cc: William Tu <[email protected]>
Signed-off-by: Haishuang Yan <[email protected]>
Acked-by: William Tu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/ipv6/ip6_gre.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 01ecd51..a53ef07 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -680,12 +680,13 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
                    struct flowi6 *fl6, __u8 *dsfield,
                    int *encap_limit)
-   struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+   struct ipv6hdr *ipv6h;
    struct ip6_tnl *t = netdev_priv(dev);
    __u16 offset;

    offset = ip6_tnl_parse_tlv_enc_lim(skb, skb_network_header(skb));
    /* ip6_tnl_parse_tlv_enc_lim() might have reallocated skb->head */
+   ipv6h = ipv6_hdr(skb);

    if (offset > 0) {
        struct ipv6_tlv_tnl_enc_lim *tel;

Leave a Reply

Your email address will not be published. Required fields are marked *