Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DBD1C10F11 for ; Mon, 22 Apr 2019 14:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2869420656 for ; Mon, 22 Apr 2019 14:51:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Af+texnu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727450AbfDVOvH (ORCPT ); Mon, 22 Apr 2019 10:51:07 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37306 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbfDVOvH (ORCPT ); Mon, 22 Apr 2019 10:51:07 -0400 Received: by mail-qt1-f194.google.com with SMTP id z16so12355708qtn.4 for ; Mon, 22 Apr 2019 07:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=toMnJM+rRriMa5vrnMPH/Z80pmSBOBmiFnRb5Jfk6Vo=; b=Af+texnuAZ04iSAFtFgLlxyHa2oZsp2F7ocnG+LGdJmNjAeWVFareljAC937FdGhS2 NDIsDdnCQL7cLUPxu+dhsq9SxCvdf7HvCZgLv28c4IsFHaz5M27UCo7s22kyTCL2qbnO qZ2ZOipck2QCKPs7OHqshyMgK4ubblAP4LjE0VDkDm74czIuyvtADws/w6yfT3BGeW09 w5JTDyuc6Dnstv+aUGjQCO6fl+wWc1TDW3EKnOFNfgUACQEwzw5v45Jwy2wA3xD0hkkl HOxQxB/GDsqjAL7JR4PQMR81hMTVL/7e4yDEVIJONInNPNwrZZxtvdBiHcdm7niIZbSB nczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=toMnJM+rRriMa5vrnMPH/Z80pmSBOBmiFnRb5Jfk6Vo=; b=WLhKKHtCmEQfpq84ZBKflMeBESz/P8UVpSoTOpIexkQ84SWE/zO2hP+6SmWxI9m+7a BD9dzSNZL5GJqf8l6PWyv8h7Sq3ggMyfnUeqFavY9/mR/aNGIqDtRbAQ08ekbnMWoG0N oy9Pri5f3esfpzxMbIl5SYGC1n/4NIzfjq7KERX1tPJ4eIKPZkIC+DmZ2jp/RxbL/XAj J4RJbBaTzE1EEqBsPTP6NPIdA0HChhBi3OZGVlxJvpDyjBQ2RruBorAFQ8t8PEEzJo86 3xi2g1mja2pryTbVThK2W9tNQz5I0RwpkVLn3im/3yikkWmWLURVsZ1DP4J4NJxJjeUI 2rzw== X-Gm-Message-State: APjAAAWB9iUQrrP9B2/GAj/5+W8Nx5oinzWX3ODEyD39aiXcGcEHWa5a Dmx0zONeMbaBmZJxuatP0H6Igart X-Google-Smtp-Source: APXvYqzudkRDd1sjtwSCan7lKZnIxFFF5IYUEanAe2HEI3vZsmM+aBUXZM0XI8ZWrLPlhTQyr99Iqg== X-Received: by 2002:aed:3143:: with SMTP id 61mr12316769qtg.80.1555944665421; Mon, 22 Apr 2019 07:51:05 -0700 (PDT) Received: from willemb1.nyc.corp.google.com ([2620:0:1003:315:3fa1:a34c:1128:1d39]) by smtp.gmail.com with ESMTPSA id e33sm8177854qta.0.2019.04.22.07.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 07:51:04 -0700 (PDT) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, alan.maguire@oracle.com, Willem de Bruijn Subject: [PATCH bpf-next 1/2] bpf: update skb->protocol in bpf_skb_net_grow Date: Mon, 22 Apr 2019 10:50:58 -0400 Message-Id: <20190422145059.125561-2-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190422145059.125561-1-willemdebruijn.kernel@gmail.com> References: <20190422145059.125561-1-willemdebruijn.kernel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Willem de Bruijn Some tunnels, like sit, change the network protocol of packet. If so, update skb->protocol to match the new type. Signed-off-by: Willem de Bruijn --- net/core/filter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/core/filter.c b/net/core/filter.c index 1833926a63fc1..bd4d498fabfa4 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3047,6 +3047,14 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff, skb_set_transport_header(skb, mac_len + nh_len); } + + /* Match skb->protocol to new outer l3 protocol */ + if (skb->protocol == htons(ETH_P_IP) && + flags & BPF_F_ADJ_ROOM_ENCAP_L3_IPV6) + skb->protocol = htons(ETH_P_IPV6); + else if (skb->protocol == htons(ETH_P_IPV6) && + flags & BPF_F_ADJ_ROOM_ENCAP_L3_IPV4) + skb->protocol = htons(ETH_P_IP); } if (skb_is_gso(skb)) { -- 2.21.0.593.g511ec345e18-goog