Based on work by Pravin Shelar.

Once the GTP headers have been the removed, the SKB protocol should be
set to that of the inner packet.

Signed-off-by: Jonas Bonn <jo...@norrbonn.se>
---
 drivers/net/gtp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 7ab8540e46d2..8aab46ec8a94 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -197,6 +197,20 @@ static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff 
*skb,
         * calculate the transport header.
         */
        skb_reset_network_header(skb);
+       if (pskb_may_pull(skb, sizeof(struct iphdr))) {
+               struct iphdr *iph;
+
+               iph = ip_hdr(skb);
+               if (iph->version == 4) {
+                       netdev_dbg(pctx->dev, "inner pkt: ipv4");
+                       skb->protocol = htons(ETH_P_IP);
+               } else if (iph->version == 6) {
+                       netdev_dbg(pctx->dev, "inner pkt: ipv6");
+                       skb->protocol = htons(ETH_P_IPV6);
+               } else {
+                       netdev_dbg(pctx->dev, "inner pkt error: Unknown type");
+               }
+       }
 
        skb->dev = pctx->dev;
 
-- 
2.27.0

Reply via email to