From patchwork Sun Jan 8 15:12:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyue Wang X-Patchwork-Id: 40516 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1743915wrt; Sun, 8 Jan 2023 07:17:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvB9lzIwKDz0xJg4lnEc0KQMzHPbh+VITBcG89iKl3aeC4tfsYXSOEbK+bysT4gjizznBqK X-Received: by 2002:a17:907:8c8e:b0:7c0:e0d9:c1df with SMTP id td14-20020a1709078c8e00b007c0e0d9c1dfmr51083673ejc.10.1673191034605; Sun, 08 Jan 2023 07:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673191034; cv=none; d=google.com; s=arc-20160816; b=h7iUGPZaOCnOp8oTUIb+3JU/Kv50Sx7p15elOuFOlRouf2kvqMlrpksSv3t/YJnmcE Js64hGyiGtziwISV8aSYTKF3J3Bu6zJaoNmIdfcv2btLRGEyiRCc8AiZiwo33Ul4pk/N VWn3idwjcEE1Y8QjeAnxmh8CoYEzBVvLI8Iva3Cq9tG+N7OKsMGjtBQg5Pqv7kodi8MQ FK06pvFGdIWeHTc14JhFO4v1Q0rHBllCQg4jpq9hbwsYayY8mxVgvVYqpNYoq+gDXxfq kjqMm/VK100ZJHGgymJrkksxoXSiyxajJr4IN5wcVp7Zq2WdmgovROqdT1EjfFaDD7cc K9Mw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=cXUARWNvFBraPR/TqGDbpmKZTuVrv1IucQXTOicOVDo=; b=d2+DCghUEDxdVZJGSq2GeWDNG77jJHhANgM8czwHOLolrchkqu5Jcrf6g81ilzzSbG pAzxqpLdGlMmZNuNHEGAQ9sq7ain+EVKsCDjBC72yN2dJeLC8wTWW0xbF5xrvqOlyZl9 pwWQcYCBytan83zrXayR1KMMLiPrjde3mtz7uH8Gko19M9rCNdsqiLpGYlw0LleogKfg OEckJ1lPB6bxrJQuVyUaobU9NnmVZRx9vjurvXf/gomkY30CrW4fprHAkDNb3UFGaNWL aF79oon1/5pyj/fTLyXONAFvCa8w4Gs9n6VeCtaN+JwHa75KaifO/wneRC69LGEc1LyZ lVgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FqIlfoQ0; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr20-20020a170906d55400b007a8beb3aa4csi7505622ejc.872.2023.01.08.07.16.50; Sun, 08 Jan 2023 07:17:14 -0800 (PST) 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=@intel.com header.s=Intel header.b=FqIlfoQ0; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233404AbjAHPLk (ORCPT + 99 others); Sun, 8 Jan 2023 10:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbjAHPLj (ORCPT ); Sun, 8 Jan 2023 10:11:39 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A7E6265; Sun, 8 Jan 2023 07:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673190698; x=1704726698; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3aSyeGbeMNfHDYKc5OXsAMpLIkaVT1dnok7Bt0nCv9I=; b=FqIlfoQ0wMhk/JOx5a6VgPu+3qZX/eRX88Pm9rJZCSGcJ/p2vEvCyfRo IkqWchwOC/2gPynA3xt56ONgxpTORstYLuj2rSDCUqCDIzLboPr1L91XK S7gHTMdMTtfAi5xjHFriN6beO77fFLy2wilS3QykNW8RwAr5gqpcoz7ab ogKiwh5th7kk64ZupRo+sNBawxKgwBeNM6VddvZbFUZXlB3bM3gyYwPr9 3t0c2VyGerkYjlG7Jc6hi8VzKXWFVLTWf+779mEZs1E5q3WDGtuDqCfxj kWj7I5Q8SVIrANbc+wSeUQbZioIV9IX1lavD23pLhdKCxOSymvrMtV6e9 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="349941525" X-IronPort-AV: E=Sophos;i="5.96,310,1665471600"; d="scan'208";a="349941525" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 07:11:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="658348255" X-IronPort-AV: E=Sophos;i="5.96,310,1665471600"; d="scan'208";a="658348255" Received: from sse-cse-haiyue-nuc.sh.intel.com ([10.239.241.114]) by fmsmga007.fm.intel.com with ESMTP; 08 Jan 2023 07:11:33 -0800 From: Haiyue Wang To: bpf@vger.kernel.org Cc: Haiyue Wang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org (open list:BPF [NETWORKING] (tc BPF, sock_addr)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH bpf-next v1] bpf: Remove the unnecessary insn buffer comparison Date: Sun, 8 Jan 2023 23:12:57 +0800 Message-Id: <20230108151258.96570-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754467962273748546?= X-GMAIL-MSGID: =?utf-8?q?1754467962273748546?= The variable 'insn' is initialized to 'insn_buf' without being changed, only some helper macros are defined, so the insn buffer comparison is unnecessary, just remove it. Signed-off-by: Haiyue Wang Acked-by: Stanislav Fomichev --- net/core/filter.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index ab811293ae5d..d9befa6ba04e 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -6847,9 +6847,6 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type, FIELD)); \ } while (0) - if (insn > insn_buf) - return insn - insn_buf; - switch (si->off) { case offsetof(struct bpf_tcp_sock, rtt_min): BUILD_BUG_ON(sizeof_field(struct tcp_sock, rtt_min) != @@ -10147,9 +10144,6 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type, SOCK_OPS_GET_FIELD(BPF_FIELD, OBJ_FIELD, OBJ); \ } while (0) - if (insn > insn_buf) - return insn - insn_buf; - switch (si->off) { case offsetof(struct bpf_sock_ops, op): *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct bpf_sock_ops_kern,