From patchwork Wed Dec 14 23:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 33406 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp24808wrn; Wed, 14 Dec 2022 15:30:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6uphqR3HbfmsY4Vq4WvONpPLUv50WfEvHG3ScdV8JBjtfgcph6ZmXRk6HeBDxpa0C0ErAr X-Received: by 2002:a05:6402:1711:b0:46c:ec97:b453 with SMTP id y17-20020a056402171100b0046cec97b453mr21435819edu.12.1671060658234; Wed, 14 Dec 2022 15:30:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671060658; cv=none; d=google.com; s=arc-20160816; b=BuJI9YIXbWBK+uPVsv0r0FPP32Fttq6KDS4Bzm53mLK+wuGQV9cGRTXLu5btpusZPv mxi7jrl5ARje7SEm3M50wFPHs+xdzvrt7zIg+JW/zqHO438sCGHx3lLIDYW/K1bUnnkB gvZRufwrJwmwPqu5lbhD53WFwlglsdc3P7tg9XSpKSgDPnXd578lHplpMOVHKKWEsJtx Ldv5LR2MTTcJjCeAueXmsHmis+SsyM5gvorATkauWflWHJ/a88mYYtXLHifxW/BDYMmJ WvqKXzVQKy6QNRlrkUtx37EJKlKxvSwjbhY470uaHzDNlZu4lkXAxWQR9RRVZ2v9U08O ketA== 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 :feedback-id:dkim-signature:dkim-signature; bh=zXM0VhlCciX8F/i6KXAGG0kiwhCDpeRhU1M+a6/y414=; b=Ek7vORGZdPTjb+1v+d7OpgOoMrTJEuSqVpuR+2Wb4pgA7Y7VhJqyoD+/WgZEZxb16l 4CaHuBnKp5WndOuic97P50abR55JFEpEep5xBGkD20RPvNvLoTsYsYK7llwy1X/Pj28P fl/C7qHRrOJrVf+uB6RXNUNkQe2NAqFl6KPnk/9vF31SBtmTiBKukiuWxgWplsjPe57I 0bsWYz69zZvI53hNBbly5lFxSh0qtzko5KDjaizdaHE8CsGFK7SJNh4k96rbmifMgPqs wJzA9Opr/Jy99mEP8dYU9Uveip3e6VXDQiDXMqf5THsaAtJCJOK4f8UERPhV8Vo18PD+ sJTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm1 header.b=QAz90bIS; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=L5TwVjkU; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020aa7d44b000000b0046aa4908162si12157372edr.46.2022.12.14.15.30.02; Wed, 14 Dec 2022 15:30:58 -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=@dxuuu.xyz header.s=fm1 header.b=QAz90bIS; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=L5TwVjkU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiLNX2b (ORCPT + 99 others); Wed, 14 Dec 2022 18:28:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbiLNX2D (ORCPT ); Wed, 14 Dec 2022 18:28:03 -0500 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2DE3B9FF; Wed, 14 Dec 2022 15:26:07 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 3697C32008FF; Wed, 14 Dec 2022 18:26:06 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 14 Dec 2022 18:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1671060365; x=1671146765; bh=zX M0VhlCciX8F/i6KXAGG0kiwhCDpeRhU1M+a6/y414=; b=QAz90bISldXoMkbDut O6BP+qovTz0JRF8nw6ZqC82EAec+qLHrfd0V1PBGZSOPN2FKC+/uwB37Oi/4XcD/ c6GtmKrA8CXBp2hdUWCyi18rKgfT9n+R0mgEvcv+vUAMOCMTiRXcee211MCdZlhv 4i9F9/2aoL1/8pppDmpMpc/xjNJxsfuKpwsandLTN7G/kGB7MYrhF+B9MXHKViz9 fHDtJTwAK3KpadTK02ubYecuPk5TSZkYSoxuR5CxFWUGmQMMbnlsVs+AyaEaojUf TRoMpuElUVQP9CvQY9L2Oo9msep1Q6A1l/D2fW91zVvMcQLgdBcsuTWGKShQOVU6 JqJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1671060365; x=1671146765; bh=zXM0VhlCciX8F /i6KXAGG0kiwhCDpeRhU1M+a6/y414=; b=L5TwVjkUGMM+MIORXLq7Py8MuNRDx LxXLyrTqwsx5teMAoBH2G4L22AC0MQkTzOlh+wuh+bARDcyvaHvJ0ULHvspfkN/x cH4SpzWTjBtyg4hcWtpOZuEiwJlB5W831slPn061IxX3Zkb95jXO5kX9NEh3joFg KQix3/AZbpJLmCcIRJ72fXxzy2fPWzHRi144eXGTMDdUHynpebQ+zjnhuOaVk1Mf TeiUQBoIkssQwKP+lOZwdwiilyhZlD0fVHpqkt96Asa4OU6ViyqITN786834egis YFql6TRxBTSTYl7eXcRb9osdqr2sar5xoq6SZNeFHS5klE7O5Yb2ruqBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeggddtjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredt tdenucfhrhhomhepffgrnhhivghlucgiuhcuoegugihusegugihuuhhurdighiiiqeenuc ggtffrrghtthgvrhhnpefgfefggeejhfduieekvdeuteffleeifeeuvdfhheejleejjeek gfffgefhtddtteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Dec 2022 18:26:04 -0500 (EST) From: Daniel Xu To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hideaki YOSHIFUJI , David Ahern Cc: ppenkov@aviatrix.com, dbird@aviatrix.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH bpf-next 1/6] ip: frags: Return actual error codes from ip_check_defrag() Date: Wed, 14 Dec 2022 16:25:28 -0700 Message-Id: X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_PDS_OTHER_BAD_TLD 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?1752234101045664112?= X-GMAIL-MSGID: =?utf-8?q?1752234101045664112?= Once we wrap ip_check_defrag() in a kfunc, it may be useful for progs to know the exact error condition ip_check_defrag() encountered. Signed-off-by: Daniel Xu --- drivers/net/macvlan.c | 2 +- net/ipv4/ip_fragment.c | 11 ++++++----- net/packet/af_packet.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 99a971929c8e..b8310e13d7e1 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -456,7 +456,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) unsigned int hash; skb = ip_check_defrag(dev_net(skb->dev), skb, IP_DEFRAG_MACVLAN); - if (!skb) + if (IS_ERR(skb)) return RX_HANDLER_CONSUMED; *pskb = skb; eth = eth_hdr(skb); diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 69c00ffdcf3e..7406c6b6376d 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -514,6 +514,7 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user) struct iphdr iph; int netoff; u32 len; + int err; if (skb->protocol != htons(ETH_P_IP)) return skb; @@ -535,15 +536,15 @@ struct sk_buff *ip_check_defrag(struct net *net, struct sk_buff *skb, u32 user) if (skb) { if (!pskb_may_pull(skb, netoff + iph.ihl * 4)) { kfree_skb(skb); - return NULL; + return ERR_PTR(-ENOMEM); } - if (pskb_trim_rcsum(skb, netoff + len)) { + if ((err = pskb_trim_rcsum(skb, netoff + len))) { kfree_skb(skb); - return NULL; + return ERR_PTR(err); } memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); - if (ip_defrag(net, skb, user)) - return NULL; + if ((err = ip_defrag(net, skb, user))) + return ERR_PTR(err); skb_clear_hash(skb); } } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 41c4ccc3a5d6..cf706f98448e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1472,7 +1472,7 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev, if (fanout_has_flag(f, PACKET_FANOUT_FLAG_DEFRAG)) { skb = ip_check_defrag(net, skb, IP_DEFRAG_AF_PACKET); - if (!skb) + if (IS_ERR(skb)) return 0; } switch (f->type) {