Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2112331rdg; Sun, 13 Aug 2023 09:41:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwHiCQ0jjl2NclfGGHprgL8w7YGF6lmwvmTYPjf0t66Si3C9Rnj9i4+0iEScjXZM6OfM0N X-Received: by 2002:a05:6a20:394a:b0:142:8314:c6f3 with SMTP id r10-20020a056a20394a00b001428314c6f3mr6962706pzg.62.1691944918375; Sun, 13 Aug 2023 09:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691944918; cv=none; d=google.com; s=arc-20160816; b=pKY5UWZxuyukl2CmFBj6V7g4Bz6NXhZ4l4odFQ+cJH7ZxUFZZR6i1JUDedUVdNLxje UsDbgnRsESkvyyOIBiZUY1LctiufXLznUpTrd/8iIduTxM09KDqNuNgzPttcVgq7UtxJ jECAFVQEOughRCkNaoaIBdSxh7cELVjKp7alZd45KRmMt1CxXZnaS+QXWhIIjhbcTa6E pEhYg4WHGIWNlbHKT0BigB78bvGAjsNTc8ly3dwwllrx9ik3BlxcAi1glK/E4EkChLl8 NfhUFdhE984WeHnfLKeQZNnbmk8emkiHpTsTYdWYWNOKGAobGQJUV6F7FuiV00prZCPC +7Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9SpQIg3kZZ05woygy/thX0PyyztQugmVp7VUqfFeJt0=; fh=Bl8PpidnfFPzGgfodGkXyDFAZuW2xxfNIyNkcjgfCwY=; b=h+sO+d0ed1J6Eo/dcjM1e8I0epchUfz9K+eqvsLuO7RuU3EbjO2kHQpZHUtVu3Duke fitJzi65Q7an5Xex6FEf/r9C/jbILT2eZuD1f340HrTQ3ER5ZGnXVq3x9S5I7LT+RWEn cyjkDwBFM6K3oMqQwAf1GYfRHOoi5hED6HEmCFCKWS3BWU+x3AaUYYm6Jt00EL5JPITq oFHk0USOdEEcnI0HgTNYvx3rHPQf0q9aDhdWtfo5bDXB7HjuDSLKv5TcAK4iH/thL+ZD QRq5BTYbrw1vutiswB7kKO1XOn7ZfHJQ8EVBgYW5Y5XiFkuXpMBCY2wxV84d5pl7io/o CaRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E+D6ayEC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b00564c67e66fbsi6561665pgd.842.2023.08.13.09.41.46; Sun, 13 Aug 2023 09:41:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E+D6ayEC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbjHMQIc (ORCPT + 99 others); Sun, 13 Aug 2023 12:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbjHMQIR (ORCPT ); Sun, 13 Aug 2023 12:08:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C433584; Sun, 13 Aug 2023 09:08:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5D73E6385E; Sun, 13 Aug 2023 16:07:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CE37C433C9; Sun, 13 Aug 2023 16:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691942827; bh=xUGXoWAyBi8RvnPW66l+BhmdRQ0+9ggG17KUQfjkeXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+D6ayECLmSgOu/P9QzP+Y26CyREDtjWrrzdbn8Gwdy7i2YhZ4oif0d6FYN8CO8Gd TVtT2yhZeDcVO0NVDQnjgVHrxA2EzRTf5PdwwpAdVeCyeXGjwOpm4dLkpq4t2rVPZS IAgQ0t2zBNVuvAyhkXqKJPF9fPEpvWE8+WkwZjhvYczltz8zOk77xCp6pKdNELSUOy QEqQRRTBK2vogHEm7MgUz/864x5ooLZwt+wabEcy7tpiez8hoL3RUGkEO47AX21uD8 mGmJ3DbVSSQt37qKaBq3fwMyjVBW6904cc5cFQM/okS/BrMPpehvF4Hc+kHHXLBOk1 r8oRHnmzQrnrw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiri Benc , "David S . Miller" , Sasha Levin , edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 11/31] vxlan: generalize vxlan_parse_gpe_hdr and remove unused args Date: Sun, 13 Aug 2023 12:05:44 -0400 Message-Id: <20230813160605.1080385-11-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230813160605.1080385-1-sashal@kernel.org> References: <20230813160605.1080385-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.126 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Benc [ Upstream commit 17a0a64448b568442a101de09575f81ffdc45d15 ] The vxlan_parse_gpe_hdr function extracts the next protocol value from the GPE header and marks GPE bits as parsed. In order to be used in the next patch, split the function into protocol extraction and bit marking. The bit marking is meaningful only in vxlan_rcv; move it directly there. Rename the function to vxlan_parse_gpe_proto to reflect what it now does. Remove unused arguments skb and vxflags. Move the function earlier in the file to allow it to be called from more places in the next patch. Signed-off-by: Jiri Benc Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/vxlan.c | 58 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 129e270e9a7cd..90d656ea8fc6a 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -730,6 +730,32 @@ static int vxlan_fdb_append(struct vxlan_fdb *f, return 1; } +static bool vxlan_parse_gpe_proto(struct vxlanhdr *hdr, __be16 *protocol) +{ + struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)hdr; + + /* Need to have Next Protocol set for interfaces in GPE mode. */ + if (!gpe->np_applied) + return false; + /* "The initial version is 0. If a receiver does not support the + * version indicated it MUST drop the packet. + */ + if (gpe->version != 0) + return false; + /* "When the O bit is set to 1, the packet is an OAM packet and OAM + * processing MUST occur." However, we don't implement OAM + * processing, thus drop the packet. + */ + if (gpe->oam_flag) + return false; + + *protocol = tun_p_to_eth_p(gpe->next_protocol); + if (!*protocol) + return false; + + return true; +} + static struct vxlanhdr *vxlan_gro_remcsum(struct sk_buff *skb, unsigned int off, struct vxlanhdr *vh, size_t hdrlen, @@ -1738,35 +1764,6 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; } -static bool vxlan_parse_gpe_hdr(struct vxlanhdr *unparsed, - __be16 *protocol, - struct sk_buff *skb, u32 vxflags) -{ - struct vxlanhdr_gpe *gpe = (struct vxlanhdr_gpe *)unparsed; - - /* Need to have Next Protocol set for interfaces in GPE mode. */ - if (!gpe->np_applied) - return false; - /* "The initial version is 0. If a receiver does not support the - * version indicated it MUST drop the packet. - */ - if (gpe->version != 0) - return false; - /* "When the O bit is set to 1, the packet is an OAM packet and OAM - * processing MUST occur." However, we don't implement OAM - * processing, thus drop the packet. - */ - if (gpe->oam_flag) - return false; - - *protocol = tun_p_to_eth_p(gpe->next_protocol); - if (!*protocol) - return false; - - unparsed->vx_flags &= ~VXLAN_GPE_USED_BITS; - return true; -} - static bool vxlan_set_mac(struct vxlan_dev *vxlan, struct vxlan_sock *vs, struct sk_buff *skb, __be32 vni) @@ -1867,8 +1864,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * used by VXLAN extensions if explicitly requested. */ if (vs->flags & VXLAN_F_GPE) { - if (!vxlan_parse_gpe_hdr(&unparsed, &protocol, skb, vs->flags)) + if (!vxlan_parse_gpe_proto(&unparsed, &protocol)) goto drop; + unparsed.vx_flags &= ~VXLAN_GPE_USED_BITS; raw_proto = true; } -- 2.40.1