Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3520921pxb; Mon, 24 Jan 2022 11:17:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzehGq8KAxcH9bUAx5CwMkFHTlS/4ntUHMVCTMHr1Mj910x03iFx1VCws8oMIO1d0zjqnd8 X-Received: by 2002:a62:e803:0:b0:4c9:ef34:1adb with SMTP id c3-20020a62e803000000b004c9ef341adbmr3417144pfi.76.1643051866928; Mon, 24 Jan 2022 11:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643051866; cv=none; d=google.com; s=arc-20160816; b=Q785ID1+BPR7cheFwSYM+cjNH01kLA65tfoTqXxcWqBxETZe/kXJTRTxDejMfGiblX WEuOw4sIYaT7rnxOezPaxfCpoPuKa+fkTZQVmna03xnWQIgSzjClBerziQhJuBpfu9Fp GRijgrN1XNt2GBQQnYIIG/0WmJWzBkUgEeh/2keAz/qRiWT6QmIrI86LDVwQ7eE3EjE2 99qrkOgS/4wkvM2ZEfYOu3rIVvlFcil7keS3koNJS7fCtdmEgNQ2mTOcW/YgKDqz1Iny +U8WaRUV+ZtID1MqmMuOtiN9BD8flwWquFH8xVuReATUigO5QKqIKQylb2yL9Bz7KiWz ohdw== 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=bbIwpa2HKtPGNZ5ti6tjdrZrFRI38QINO2+UYVbJdYQ=; b=eW7TuOh8FYwiJDsuuR8AHhBCwM70UKsF1MKY579QO83cDBJVWNkXrLd2jXOSR7NtzN 32t3+HnOqia5huqZMmzbyThhPzZZTHfbdk0nzyGytiEtoZLoB968FiXa1lT8uOPwSX2s P6TtiohYklPG8piRZABexr0QggOodBPeM0H4CowK1ML9TydrK8YJjOw7T6uA3jKLBlbk dScq0q2i0/pUlo37gdu0z1M7JuStUHbWilL9xMEYHMAiIPO6a+GyHYk1aonH+tCApfWC +vvfTtJiHNav5i491WZeScCmG6zyoRTc0ORDnClw+dg9hHTD52zMzPIictxi8piCRXv/ /XSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gpbMAew2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z137si16211770pgz.224.2022.01.24.11.17.25; Mon, 24 Jan 2022 11:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gpbMAew2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243078AbiAXNQN (ORCPT + 99 others); Mon, 24 Jan 2022 08:16:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243076AbiAXNQK (ORCPT ); Mon, 24 Jan 2022 08:16:10 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5B4CC06173B; Mon, 24 Jan 2022 05:16:10 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id i8so15311473pgt.13; Mon, 24 Jan 2022 05:16:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bbIwpa2HKtPGNZ5ti6tjdrZrFRI38QINO2+UYVbJdYQ=; b=gpbMAew2b+vep0adLFGdhSjoUwwNOu28ixF3C0IeCEeM5JPO6jrF2HDDOvEPFG7ZQf R+pU1pDKEiz5etn0ehviAZAOtOWOHQoA9XyxU3ifCHvhYpLJ6emkYe1NdgsVUcZxVRNn 08hGdgYxJU7/5Sdz8U2XJWTE7QTDuGvaJ4zBT/rIUvtktNKGeX5HK4d/JzIr0YT9KZeA Lgj0APiQTTqjvTPXjya2RPtZh9dSP4GRiWAYYWhRlAR6BwUz83fiaeJr9aF56HnXorb3 Nvb0tOiMJiLNcl+/igxrqHbj3wY1bRXl5x1hOxwSgbmLqo8G4P/T4XzC6euLzWDA0kUG Sl7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bbIwpa2HKtPGNZ5ti6tjdrZrFRI38QINO2+UYVbJdYQ=; b=o1yCYmjzPpWVJQX9+SJEkHvG4DWEbQzPZ87zDiEci7ch/jXsc2KvUSk7H/pRLwxdLe Zl547OpSIaUILF+pA8ozis00s3D4TXnfYz10sjOxPM1dvNBqAwBzowbuj5IFMz63HJUC ihpcKvExFZ/rpnbZZPG2LkSTi0AZJUzUTkxwumvA1EgfpLC639UYY4t58F8i4jgI7iBZ Mu22Hs1+V1YsaebQqxDBGiio/B9FfeZIYnu0L87tXuit9Vpq2PU2aY+r7FhsrBLL31cd 5xFoY1e6pByFSBirvBTxmwhOLYGLOdimSe7qcbzt5mzRRs/hApNEP+xf3qNjYk3KxM/j EGjg== X-Gm-Message-State: AOAM533IhHSPNnWloYUgxetzN5He5nxki9s60WnCbOfDVSEBYeyPEK6M s12DDD1ZMdrCjby2E8iVbC8= X-Received: by 2002:a65:63c2:: with SMTP id n2mr11567070pgv.609.1643030170430; Mon, 24 Jan 2022 05:16:10 -0800 (PST) Received: from localhost.localdomain ([43.132.141.9]) by smtp.gmail.com with ESMTPSA id j11sm16508806pfu.55.2022.01.24.05.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 05:16:09 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de, imagedong@tencent.com, edumazet@google.com, alobakin@pm.me, paulb@nvidia.com, pabeni@redhat.com, talalahmad@google.com, haokexin@gmail.com, keescook@chromium.org, memxor@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, cong.wang@bytedance.com Subject: [PATCH net-next 4/6] net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu() Date: Mon, 24 Jan 2022 21:15:36 +0800 Message-Id: <20220124131538.1453657-5-imagedong@tencent.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220124131538.1453657-1-imagedong@tencent.com> References: <20220124131538.1453657-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Menglong Dong Replace kfree_skb() with kfree_skb_reason() in ip_protocol_deliver_rcu(). Following new drop reasons are introduced: SKB_DROP_REASON_XFRM_POLICY SKB_DROP_REASON_IP_NOPROTO Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 2 ++ include/trace/events/skb.h | 2 ++ net/ipv4/ip_input.c | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8942d32c0657..603f77ef2170 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -328,6 +328,8 @@ enum skb_drop_reason { SKB_DROP_REASON_IP_RPFILTER, SKB_DROP_REASON_EARLY_DEMUX, SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, + SKB_DROP_REASON_XFRM_POLICY, + SKB_DROP_REASON_IP_NOPROTO, SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 1dcdcc92cf08..e8369b8e8430 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -25,6 +25,8 @@ EM(SKB_DROP_REASON_EARLY_DEMUX, EARLY_DEMUX) \ EM(SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, \ UNICAST_IN_L2_MULTICAST) \ + EM(SKB_DROP_REASON_XFRM_POLICY, XFRM_POLICY) \ + EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index a4afb367cf02..376c96cfd5d1 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -196,7 +196,8 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol) if (ipprot) { if (!ipprot->no_policy) { if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { - kfree_skb(skb); + kfree_skb_reason(skb, + SKB_DROP_REASON_XFRM_POLICY); return; } nf_reset_ct(skb); @@ -215,7 +216,7 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol) icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PROT_UNREACH, 0); } - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_IP_NOPROTO); } else { __IP_INC_STATS(net, IPSTATS_MIB_INDELIVERS); consume_skb(skb); -- 2.34.1