From patchwork Thu Feb 16 16:28:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143473 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCA04C636CC for ; Thu, 16 Feb 2023 16:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbjBPQ3S (ORCPT ); Thu, 16 Feb 2023 11:29:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjBPQ3P (ORCPT ); Thu, 16 Feb 2023 11:29:15 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25635442CE for ; Thu, 16 Feb 2023 08:29:14 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-532e96672b3so25756737b3.13 for ; Thu, 16 Feb 2023 08:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xaHOszewmcG/9H5yxJLH8P54Tg1PRq8Bi3Xvki6MWRs=; b=qzGfILrcEYGOH0VsrBw6pIPNjj7S7JEb4xE0J22LVnFSP2bY3Xu8KQjsW/jrkaL/qk /a5cf/kt3gsH/9QLS/zRrHhOTl34pmOXak4P/pyauFet5rtcfCaqxjioXQIfNC92Yi8u 1hWmmsst1aGrRPgwScgM11Sv4MVe9yxw0UNgUlZLZJyuSwVYbYG9YtYLThfHMoP96xiR WAZUfbrPJXtQRQS/T7x5md4AntJVu6PTbok41dZmXO0Jp5hJUcN4c/zlCmFpFpOusj+q G0RLHMq+p5mLIlyC+9wjPTmm+jBOhjZ0R8UBjoiv6nM9K/J/GP4UD80+7seAiUgR5nlC wH/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xaHOszewmcG/9H5yxJLH8P54Tg1PRq8Bi3Xvki6MWRs=; b=jTodJPaAGXFT4xf26hmthmuRuLrh+On5rJyiE5cBaTypaSdXtN6qRnAx2HHb8iXA6k vJ6J0CbEHPAFfq8r5EUcOk97Mp993ca7oZNterqhOXJnw/wD+wa8c4mcNFNnfyTGlHyH d/okYGpZ6QYp2835nx7H6CFJjYMVRlYggQt2mWz+zp3oumqIeG6sUqrQCY3zmRkfkjgH QQaNsKfM0Vo78MTxqKI/xxwBbdhRlf0eXrVqJTV3CyWwXo9ruQe0sPB7wAU1QLSMpek1 NPjLdlymQVN9Lon198z/iFh0vsEcmlD66D2q9+1aV7abjTa3s5ov61ELisfevtQe5JL/ ruyg== X-Gm-Message-State: AO0yUKX3KOFWLv7ct4FlIcHc3dVAi+1ks5OReqi78D4timibu0nG7Pha 6h4Hpz8fqTyrN/N+SHqykM43uPSWv4LR7A== X-Google-Smtp-Source: AK7set8XoErGLDR1+YAY3hF3OrtqH41/YuE2OVzIBKO981g2GZOLAM+QdIYho+2sLN23b09AWNjeGwp/C4Rw0A== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a5b:802:0:b0:92a:dcf8:c83f with SMTP id x2-20020a5b0802000000b0092adcf8c83fmr630568ybp.120.1676564953336; Thu, 16 Feb 2023 08:29:13 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:35 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-2-edumazet@google.com> Subject: [PATCH net-next 1/8] ipv6: icmp6: add drop reason support to ndisc_recv_ns() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change ndisc_recv_ns() to return a drop reason. For the moment, return PKT_TOO_SMALL, NOT_SPECIFIED or SKB_CONSUMED. Signed-off-by: Eric Dumazet --- net/ipv6/ndisc.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 9548b5a44714f98975a8b7194bc81cbb0f72697f..039722f83c668ad59eb63ffde98e18ad8947bdcc 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -783,7 +783,7 @@ void ndisc_update(const struct net_device *dev, struct neighbour *neigh, ndisc_ops_update(dev, neigh, flags, icmp6_type, ndopts); } -static void ndisc_recv_ns(struct sk_buff *skb) +static enum skb_drop_reason ndisc_recv_ns(struct sk_buff *skb) { struct nd_msg *msg = (struct nd_msg *)skb_transport_header(skb); const struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; @@ -797,18 +797,17 @@ static void ndisc_recv_ns(struct sk_buff *skb) struct inet6_dev *idev = NULL; struct neighbour *neigh; int dad = ipv6_addr_any(saddr); - bool inc; int is_router = -1; + SKB_DR(reason); u64 nonce = 0; + bool inc; - if (skb->len < sizeof(struct nd_msg)) { - ND_PRINTK(2, warn, "NS: packet too short\n"); - return; - } + if (skb->len < sizeof(struct nd_msg)) + return SKB_DROP_REASON_PKT_TOO_SMALL; if (ipv6_addr_is_multicast(&msg->target)) { ND_PRINTK(2, warn, "NS: multicast target address\n"); - return; + return reason; } /* @@ -817,12 +816,12 @@ static void ndisc_recv_ns(struct sk_buff *skb) */ if (dad && !ipv6_addr_is_solict_mult(daddr)) { ND_PRINTK(2, warn, "NS: bad DAD packet (wrong destination)\n"); - return; + return reason; } if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) { ND_PRINTK(2, warn, "NS: invalid ND options\n"); - return; + return reason; } if (ndopts.nd_opts_src_lladdr) { @@ -830,7 +829,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) if (!lladdr) { ND_PRINTK(2, warn, "NS: invalid link-layer address length\n"); - return; + return reason; } /* RFC2461 7.1.1: @@ -841,7 +840,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) if (dad) { ND_PRINTK(2, warn, "NS: bad DAD packet (link-layer address option)\n"); - return; + return reason; } } if (ndopts.nd_opts_nonce && ndopts.nd_opts_nonce->nd_opt_len == 1) @@ -869,7 +868,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) * so fail our DAD process */ addrconf_dad_failure(skb, ifp); - return; + return reason; } else { /* * This is not a dad solicitation. @@ -901,7 +900,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) idev = in6_dev_get(dev); if (!idev) { /* XXX: count this drop? */ - return; + return reason; } if (ipv6_chk_acast_addr(net, dev, &msg->target) || @@ -958,6 +957,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) true, (ifp != NULL && inc), inc); if (neigh) neigh_release(neigh); + reason = SKB_CONSUMED; } out: @@ -965,6 +965,7 @@ static void ndisc_recv_ns(struct sk_buff *skb) in6_ifa_put(ifp); else in6_dev_put(idev); + return reason; } static int accept_untracked_na(struct net_device *dev, struct in6_addr *saddr) @@ -1781,8 +1782,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) static void pndisc_redo(struct sk_buff *skb) { - ndisc_recv_ns(skb); - kfree_skb(skb); + enum skb_drop_reason reason = ndisc_recv_ns(skb); + + kfree_skb_reason(skb, reason); } static int ndisc_is_multicast(const void *pkey) @@ -1834,7 +1836,7 @@ enum skb_drop_reason ndisc_rcv(struct sk_buff *skb) switch (msg->icmph.icmp6_type) { case NDISC_NEIGHBOUR_SOLICITATION: memset(NEIGH_CB(skb), 0, sizeof(struct neighbour_cb)); - ndisc_recv_ns(skb); + reason = ndisc_recv_ns(skb); break; case NDISC_NEIGHBOUR_ADVERTISEMENT: From patchwork Thu Feb 16 16:28:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143474 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B44C61DA4 for ; Thu, 16 Feb 2023 16:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229557AbjBPQ3U (ORCPT ); Thu, 16 Feb 2023 11:29:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229725AbjBPQ3S (ORCPT ); Thu, 16 Feb 2023 11:29:18 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993354B521 for ; Thu, 16 Feb 2023 08:29:16 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-52ed582a847so25791417b3.1 for ; Thu, 16 Feb 2023 08:29:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Lp1V6Xqu44WWdH2sIdyairYsXMgAdg6Ez6OAouI1moE=; b=DJrf8FZMT3xQE3amPRCcykdqyQchcKQOnwSv1n2t+EcelzP1prrsU/uYS3suwHkVGL aO/Y3fRRIqVGJ6RCBDfHNWKDV5yY4/XmNCsIoOptt7vmjFvD/yusS48wburmvf0L2ZYq x3ZRGsgfRJUJCtxisMa7hHVS2lpUlOOolpkotvuoQ+UaFfjRJEsfJVvNuI56HdpFZO1M ERWmLaMgvDdRX7ELPZONR+uTYlQSPi9Yv4uBa8MoBxlz0fIOZNipSmeIbWDy+J8E1U0b QJ0iOWxLZ1+qYiQlhnNbTXWZ8Gj7mRB/h+xE3BjxkVA4e+oeuPAZ1Dz9w0qYlRpPVb4s ALsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Lp1V6Xqu44WWdH2sIdyairYsXMgAdg6Ez6OAouI1moE=; b=Hut8Q7okdvNbdH+JXZ95lCERea/45B0P7cn7LXyQgSWLTOjsyam7Z6hEKh5ZWSOyyx lLiUrBsTzrmMkCqEfXS0mXxd64pZpyxu4I/UzMthswDxBBI7Hv9qeR5Va9awoMEhWOqm /OOESjiKJMYMtJNs+kt3gWebCzu+qDr20UkLHvCQI6+teU7Ghs65uPWcqAf9wHubSE3N ddY4FZrKEuInw/LbwMUYae04q7xXx8qWLDVYY814gFWebzTNEj5Q020XxOEHYIY8yLLl GpYhRyu1LwBlNs5vUSnnIhpImYtjHnKRVES0A/FpwfRA7fPDrxkE+PVsTJYckosmglQr xXAA== X-Gm-Message-State: AO0yUKVgAk8gS36bbbzswCnFdepFF2lL0A/VwakEzm9q6dLYL1wA6OUb mTQ244lP4SLUykILXfEetK5YYOvCT7rIvA== X-Google-Smtp-Source: AK7set9MQKOl14OvmiOP6pk04mdiURb45YTEojPJwEXFfGRlvsRXjqHR1zw4bh2Td0miv5I1oq8Q4Zp/nz59sA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:1614:b0:8f3:904a:2305 with SMTP id bw20-20020a056902161400b008f3904a2305mr17ybb.2.1676564955263; Thu, 16 Feb 2023 08:29:15 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:36 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-3-edumazet@google.com> Subject: [PATCH net-next 2/8] ipv6: icmp6: add drop reason support to ndisc_recv_na() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change ndisc_recv_na() to return a drop reason. For the moment, return PKT_TOO_SMALL, NOT_SPECIFIED or SKB_CONSUMED. More reasons are added later. Signed-off-by: Eric Dumazet --- net/ipv6/ndisc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 039722f83c668ad59eb63ffde98e18ad8947bdcc..9354cb3669c814166fb3d07b32097f0b00ef42f8 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -987,7 +987,7 @@ static int accept_untracked_na(struct net_device *dev, struct in6_addr *saddr) } } -static void ndisc_recv_na(struct sk_buff *skb) +static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb) { struct nd_msg *msg = (struct nd_msg *)skb_transport_header(skb); struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; @@ -1000,22 +1000,21 @@ static void ndisc_recv_na(struct sk_buff *skb) struct inet6_dev *idev = __in6_dev_get(dev); struct inet6_ifaddr *ifp; struct neighbour *neigh; + SKB_DR(reason); u8 new_state; - if (skb->len < sizeof(struct nd_msg)) { - ND_PRINTK(2, warn, "NA: packet too short\n"); - return; - } + if (skb->len < sizeof(struct nd_msg)) + return SKB_DROP_REASON_PKT_TOO_SMALL; if (ipv6_addr_is_multicast(&msg->target)) { ND_PRINTK(2, warn, "NA: target address is multicast\n"); - return; + return reason; } if (ipv6_addr_is_multicast(daddr) && msg->icmph.icmp6_solicited) { ND_PRINTK(2, warn, "NA: solicited NA is multicasted\n"); - return; + return reason; } /* For some 802.11 wireless deployments (and possibly other networks), @@ -1025,18 +1024,18 @@ static void ndisc_recv_na(struct sk_buff *skb) */ if (!msg->icmph.icmp6_solicited && idev && idev->cnf.drop_unsolicited_na) - return; + return reason; if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) { ND_PRINTK(2, warn, "NS: invalid ND option\n"); - return; + return reason; } if (ndopts.nd_opts_tgt_lladdr) { lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev); if (!lladdr) { ND_PRINTK(2, warn, "NA: invalid link-layer address length\n"); - return; + return reason; } } ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1); @@ -1044,7 +1043,7 @@ static void ndisc_recv_na(struct sk_buff *skb) if (skb->pkt_type != PACKET_LOOPBACK && (ifp->flags & IFA_F_TENTATIVE)) { addrconf_dad_failure(skb, ifp); - return; + return reason; } /* What should we make now? The advertisement is invalid, but ndisc specs say nothing @@ -1060,7 +1059,7 @@ static void ndisc_recv_na(struct sk_buff *skb) "NA: %pM advertised our address %pI6c on %s!\n", eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name); in6_ifa_put(ifp); - return; + return reason; } neigh = neigh_lookup(&nd_tbl, &msg->target, dev); @@ -1121,10 +1120,11 @@ static void ndisc_recv_na(struct sk_buff *skb) */ rt6_clean_tohost(dev_net(dev), saddr); } - + reason = SKB_CONSUMED; out: neigh_release(neigh); } + return reason; } static void ndisc_recv_rs(struct sk_buff *skb) @@ -1840,7 +1840,7 @@ enum skb_drop_reason ndisc_rcv(struct sk_buff *skb) break; case NDISC_NEIGHBOUR_ADVERTISEMENT: - ndisc_recv_na(skb); + reason = ndisc_recv_na(skb); break; case NDISC_ROUTER_SOLICITATION: From patchwork Thu Feb 16 16:28:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143475 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C300C636D7 for ; Thu, 16 Feb 2023 16:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjBPQ3V (ORCPT ); Thu, 16 Feb 2023 11:29:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjBPQ3T (ORCPT ); Thu, 16 Feb 2023 11:29:19 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 949F93D0A3 for ; Thu, 16 Feb 2023 08:29:18 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-527501b56ffso25479177b3.15 for ; Thu, 16 Feb 2023 08:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=i/MC5TmYp0neOUTobGzd9tXonCwOJXMvaxmwjYdzPqU=; b=fN94D7zxBrPS0yuo22Wf7aY85PontTnDnZScllx5pMSLx5WHxE+k3fbWVfgq/oEfYf cePYUftLPl7wU2LP1pdIk3yFuE0cyGlLAJc2ql9CMhLwY3Y/W1+6VOg9Embjm4BFGq+6 7BOtksvXfXpynymKtbtoBzv6KT2tl5SuuNgkARwtBxY4sU+zCusdYDAnMerQ5oR4+xvk qq5GMcIoyjF8Sw7muoe5ugL0/rhIJUctcVV3pzBscTvHVr1MhuZ/tVG+n2a0mvfypmSS YpzaYQNHG2vD1gbulTBGyfTovTPTTnUjL3SKKCdtcqz4MxPi2VEF3fDoGdeQj5hev06t iRQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i/MC5TmYp0neOUTobGzd9tXonCwOJXMvaxmwjYdzPqU=; b=jpk/T1Wiq6TD4UtsR6esitcBwQiiaxtVJC1OEV1u3ix+bm7fxkklvWMRTMZviXF8Oc cQgZ0syR5CoxKDwsixLVkoQlMoYwPi+8YVAjXXROM7IPwkP5BOfUnS9pyigW7J8yMDuk C0DO0Om40z4a4Cv6OwD608seQBBatp9D2e4yxMPWU/nWWzDX+nhquWBzyj9mUW2VSMHo a4nXPSegDkrcrlHJOGEd5dcdNnXNmCSESoAPBdWYkFC6BastUnWYk8eKyaUlFM0dSYVh tVQnCqlsFbMFz88K7ZtV3aPIZpIH27pEBXsMFjnnsq0D2pugeFh3KcV9EGASjdxH9WRB ShSw== X-Gm-Message-State: AO0yUKXePuuspRS5XXHhXrUEhk6rkubGGzTxtoPm2R9lPOuH+o/VBrNT fvZPBG2KG5jJB5KsebVNtxv9iyP19pSWug== X-Google-Smtp-Source: AK7set8HgVzpRlcX6u9ZY0jm5Ki2JPKtn74RE8RZqiGsj2efjG6cwaJhF1kUFzpfwxOI89X+VBdLtd67UWJgRg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a81:af4d:0:b0:52e:b635:5496 with SMTP id x13-20020a81af4d000000b0052eb6355496mr14ywj.2.1676564957355; Thu, 16 Feb 2023 08:29:17 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:37 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-4-edumazet@google.com> Subject: [PATCH net-next 3/8] ipv6: icmp6: add drop reason support to ndisc_recv_rs() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change ndisc_recv_rs() to return a drop reason. For the moment, return PKT_TOO_SMALL, NOT_SPECIFIED or SKB_CONSUMED. More reasons are added later. Signed-off-by: Eric Dumazet --- net/ipv6/ndisc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 9354cb3669c814166fb3d07b32097f0b00ef42f8..514eb8cc78792445dedead3cf0b49df696ce2785 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1127,7 +1127,7 @@ static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb) return reason; } -static void ndisc_recv_rs(struct sk_buff *skb) +static enum skb_drop_reason ndisc_recv_rs(struct sk_buff *skb) { struct rs_msg *rs_msg = (struct rs_msg *)skb_transport_header(skb); unsigned long ndoptlen = skb->len - sizeof(*rs_msg); @@ -1136,14 +1136,15 @@ static void ndisc_recv_rs(struct sk_buff *skb) const struct in6_addr *saddr = &ipv6_hdr(skb)->saddr; struct ndisc_options ndopts; u8 *lladdr = NULL; + SKB_DR(reason); if (skb->len < sizeof(*rs_msg)) - return; + return SKB_DROP_REASON_PKT_TOO_SMALL; idev = __in6_dev_get(skb->dev); if (!idev) { ND_PRINTK(1, err, "RS: can't find in6 device\n"); - return; + return reason; } /* Don't accept RS if we're not in router mode */ @@ -1178,9 +1179,10 @@ static void ndisc_recv_rs(struct sk_buff *skb) NEIGH_UPDATE_F_OVERRIDE_ISROUTER, NDISC_ROUTER_SOLICITATION, &ndopts); neigh_release(neigh); + reason = SKB_CONSUMED; } out: - return; + return reason; } static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt) @@ -1844,7 +1846,7 @@ enum skb_drop_reason ndisc_rcv(struct sk_buff *skb) break; case NDISC_ROUTER_SOLICITATION: - ndisc_recv_rs(skb); + reason = ndisc_recv_rs(skb); break; case NDISC_ROUTER_ADVERTISEMENT: From patchwork Thu Feb 16 16:28:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143476 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92121C636CC for ; Thu, 16 Feb 2023 16:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbjBPQ3Z (ORCPT ); Thu, 16 Feb 2023 11:29:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjBPQ3V (ORCPT ); Thu, 16 Feb 2023 11:29:21 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA7B34C3C9 for ; Thu, 16 Feb 2023 08:29:19 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-532e96672b3so25759797b3.13 for ; Thu, 16 Feb 2023 08:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=G9WPmC9TZove/Rvk7SZkDPC7EExgnnVLdc+ac862vzE=; b=KROH6eTFjpVB4K+41bpVLiaAj7GdJsc2JSzK6OTRzO58V5v3l0qe9IJroqc6JpAxn6 XGYqGN4+DSySPwLXsIPgHaKku8/uF6QpxxX3yIHkELnef0RVa3QfO0/SaUR9RYZhb75m U3f3xldUGFgu0gwh70d2TGffY51Mn1ymjVC6aOxFZkeJsGgxoRPw3LqYaVei34YGf7iU 6FpdsZN0EZi+FLnT0jKNAVRHmIbbbwvx50PI7lIEgfmlmQG+X2/d4e+62hGsp16CLwFU kRuyBpWhexrpG0plVlzFiZiLZGznk+EkxA+cAhzGnMM7yaeG6siY/yW5ZkPRja1cqbb6 PQKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G9WPmC9TZove/Rvk7SZkDPC7EExgnnVLdc+ac862vzE=; b=2H2LjlX+oouBwI4qwXILGoya1lnRs3HVfuEGoT+BULajhFBXVBHm9ahZTVlfLW/hZ2 V149bzEPok09soB5lUXkCg8SiFDI0AAiNY12ae6QT5d1XexUpcY3MUg6PQZ99GwmAjx3 mxfc0cYjj3UdLq0c9qmL8kC+1jMEYkttaYPcpU1KKabqb+/yUJI337KaqZ09AdTAxHVr uaFFxni3SX4N8etOU2YI7GamzhQBBIltwtBFPhP7rEFgwGgOe6I6Daz71vcgZ3lTdLd3 pCJ4LwWPMu73TzzqbZKBF7c3vIk81avgdwnfzfnlLI3TvE9I8wJziaHfDlt17pNIo6EF OICw== X-Gm-Message-State: AO0yUKUr7nM/Y+ngazy5ZG+NCa8nquHb9+qbSlYlHdik+18roGs5FWk1 mQbL+4349YbcHq/V+psdcukzEEEcocqpjw== X-Google-Smtp-Source: AK7set8GFq6BJtbkQwP8VxtpxZzEfV8aY04OyXMCubXoLgIwsqhfln0BZ/tGcZY0rwNpP9MQCV6gzrO2BrNANw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a0d:c842:0:b0:533:80fb:733d with SMTP id k63-20020a0dc842000000b0053380fb733dmr368822ywd.290.1676564959637; Thu, 16 Feb 2023 08:29:19 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:38 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-5-edumazet@google.com> Subject: [PATCH net-next 4/8] ipv6: icmp6: add drop reason support to ndisc_router_discovery() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change ndisc_router_discovery() to return a drop reason. For the moment, return PKT_TOO_SMALL, NOT_SPECIFIED and SKB_CONSUMED. More reasons are added later. Signed-off-by: Eric Dumazet --- net/ipv6/ndisc.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 514eb8cc78792445dedead3cf0b49df696ce2785..7c8ba308ea4979f46cb22d0132b559278b927a5f 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1231,20 +1231,21 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt) rtnl_set_sk_err(net, RTNLGRP_ND_USEROPT, err); } -static void ndisc_router_discovery(struct sk_buff *skb) +static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb) { struct ra_msg *ra_msg = (struct ra_msg *)skb_transport_header(skb); + bool send_ifinfo_notify = false; struct neighbour *neigh = NULL; - struct inet6_dev *in6_dev; + struct ndisc_options ndopts; struct fib6_info *rt = NULL; + struct inet6_dev *in6_dev; u32 defrtr_usr_metric; + unsigned int pref = 0; + __u32 old_if_flags; struct net *net; + SKB_DR(reason); int lifetime; - struct ndisc_options ndopts; int optlen; - unsigned int pref = 0; - __u32 old_if_flags; - bool send_ifinfo_notify = false; __u8 *opt = (__u8 *)(ra_msg + 1); @@ -1256,17 +1257,15 @@ static void ndisc_router_discovery(struct sk_buff *skb) __func__, skb->dev->name); if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { ND_PRINTK(2, warn, "RA: source address is not link-local\n"); - return; - } - if (optlen < 0) { - ND_PRINTK(2, warn, "RA: packet too short\n"); - return; + return reason; } + if (optlen < 0) + return SKB_DROP_REASON_PKT_TOO_SMALL; #ifdef CONFIG_IPV6_NDISC_NODETYPE if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) { ND_PRINTK(2, warn, "RA: from host or unauthorized router\n"); - return; + return reason; } #endif @@ -1278,12 +1277,12 @@ static void ndisc_router_discovery(struct sk_buff *skb) if (!in6_dev) { ND_PRINTK(0, err, "RA: can't find inet6 device for %s\n", skb->dev->name); - return; + return reason; } if (!ndisc_parse_options(skb->dev, opt, optlen, &ndopts)) { ND_PRINTK(2, warn, "RA: invalid ND options\n"); - return; + return reason; } if (!ipv6_accept_ra(in6_dev)) { @@ -1365,7 +1364,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) "RA: %s got default router without neighbour\n", __func__); fib6_info_release(rt); - return; + return reason; } } /* Set default route metric as specified by user */ @@ -1390,7 +1389,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) ND_PRINTK(0, err, "RA: %s failed to add default route\n", __func__); - return; + return reason; } neigh = ip6_neigh_lookup(&rt->fib6_nh->fib_nh_gw6, @@ -1401,7 +1400,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) "RA: %s got default router without neighbour\n", __func__); fib6_info_release(rt); - return; + return reason; } neigh->flags |= NTF_ROUTER; } else if (rt && IPV6_EXTRACT_PREF(rt->fib6_flags) != pref) { @@ -1488,6 +1487,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) NEIGH_UPDATE_F_OVERRIDE_ISROUTER| NEIGH_UPDATE_F_ISROUTER, NDISC_ROUTER_ADVERTISEMENT, &ndopts); + reason = SKB_CONSUMED; } if (!ipv6_accept_ra(in6_dev)) { @@ -1598,6 +1598,7 @@ static void ndisc_router_discovery(struct sk_buff *skb) fib6_info_release(rt); if (neigh) neigh_release(neigh); + return reason; } static void ndisc_redirect_rcv(struct sk_buff *skb) @@ -1850,7 +1851,7 @@ enum skb_drop_reason ndisc_rcv(struct sk_buff *skb) break; case NDISC_ROUTER_ADVERTISEMENT: - ndisc_router_discovery(skb); + reason = ndisc_router_discovery(skb); break; case NDISC_REDIRECT: From patchwork Thu Feb 16 16:28:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143477 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C3CBC636CC for ; Thu, 16 Feb 2023 16:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229606AbjBPQ33 (ORCPT ); Thu, 16 Feb 2023 11:29:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbjBPQ3Y (ORCPT ); Thu, 16 Feb 2023 11:29:24 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D054C3D2 for ; Thu, 16 Feb 2023 08:29:21 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-52ee93d7863so25577227b3.18 for ; Thu, 16 Feb 2023 08:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qU3hlD4BX0FN+8+ix3sQ8tnTKJvLCqBx8tjcQd+e/E0=; b=HMNmpS8lb4Adbv098J+5C8wySj5yjBN/7symAf32phic1krpVSF5JYdoZXDspQhRUZ 4zNJtd6a8x4GBNJU6GB3EskMOgnIJoKOcDRCpNlKi6GgbLHkOx2vyzhwNZal3WMne0vB WAupmPqCkF0y2R4AM+ITIQ2EP1x5G3w+fapjynlEHYF93P8bJsWvAfjBXx1/t/YO1AuS qQQOP2QgQEIHOXVt3YBYFYPUoPjW4Sl19JSPruT/Agn5RyewiyfKrHI21F9G4QG0GWPZ 0dhW1J1a0OhdpIkpCyL0jybbKH+NFivXOeyABEEA/1qI6IDbCfRM8CX1xmo2sdboatMO IhDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qU3hlD4BX0FN+8+ix3sQ8tnTKJvLCqBx8tjcQd+e/E0=; b=b/oD1FYtktxY6U3bRto9FLwigMwzqj3WJcP9nAuOHTe03yDN4MZcMra04fXWJmze15 qFjTsLt6Y8vzidBbcFUVAlmwjtFxlAZ1y02AnVmmHlxYbs9DUUnWSQa+PJwmte3/caxv 4cMBqbEBQETF6papM9IZkVXAUBWBgbeM2e+Mu81uAZnva73baGI6q081D/A/f05glRV6 hv0Hz/2caiS5O5Cq5eTbuu9a0O0ae4/4RDcd2HEJrmTxRlrD6/w4SEBWQi6aK9jeX4jJ tTwitmppRxsEW+EFn5RAoHkqPENz3Amt5V8ureOteE/CRPtfKeP+dSfVQj0/R8/bRHWG 4kXw== X-Gm-Message-State: AO0yUKW5oPCxi190sA6Ab0JLvpoW7rHRGDOGMjDAaz0cIEBS9llfoNAR 2f2twp0d2IerJVfsAI7jQiUh51k3HoLm5w== X-Google-Smtp-Source: AK7set+QfuQdqwL1OJ8DhV0f8s43poKTM7iquoh/79hBVrBkqBOyWsL6jVZVuN8VGZ7TEPODbNrbHMfX2sWogw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a5b:481:0:b0:916:20df:c31a with SMTP id n1-20020a5b0481000000b0091620dfc31amr893131ybp.627.1676564961216; Thu, 16 Feb 2023 08:29:21 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:39 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-6-edumazet@google.com> Subject: [PATCH net-next 5/8] ipv6: icmp6: add drop reason support to ndisc_redirect_rcv() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change ndisc_redirect_rcv() to return a drop reason. For the moment, return PKT_TOO_SMALL, NOT_SPECIFIED and values from icmpv6_notify(). More reasons are added later. Signed-off-by: Eric Dumazet --- net/ipv6/ndisc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 7c8ba308ea4979f46cb22d0132b559278b927a5f..e9776aa6f1675e35273df16e40745779b91d117e 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1601,13 +1601,14 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb) return reason; } -static void ndisc_redirect_rcv(struct sk_buff *skb) +static enum skb_drop_reason ndisc_redirect_rcv(struct sk_buff *skb) { - u8 *hdr; - struct ndisc_options ndopts; struct rd_msg *msg = (struct rd_msg *)skb_transport_header(skb); u32 ndoptlen = skb_tail_pointer(skb) - (skb_transport_header(skb) + offsetof(struct rd_msg, opt)); + struct ndisc_options ndopts; + SKB_DR(reason); + u8 *hdr; #ifdef CONFIG_IPV6_NDISC_NODETYPE switch (skb->ndisc_nodetype) { @@ -1615,31 +1616,31 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) case NDISC_NODETYPE_NODEFAULT: ND_PRINTK(2, warn, "Redirect: from host or unauthorized router\n"); - return; + return reason; } #endif if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) { ND_PRINTK(2, warn, "Redirect: source address is not link-local\n"); - return; + return reason; } if (!ndisc_parse_options(skb->dev, msg->opt, ndoptlen, &ndopts)) - return; + return reason; if (!ndopts.nd_opts_rh) { ip6_redirect_no_header(skb, dev_net(skb->dev), skb->dev->ifindex); - return; + return reason; } hdr = (u8 *)ndopts.nd_opts_rh; hdr += 8; if (!pskb_pull(skb, hdr - skb_transport_header(skb))) - return; + return SKB_DROP_REASON_PKT_TOO_SMALL; - icmpv6_notify(skb, NDISC_REDIRECT, 0, 0); + return icmpv6_notify(skb, NDISC_REDIRECT, 0, 0); } static void ndisc_fill_redirect_hdr_option(struct sk_buff *skb, @@ -1855,7 +1856,7 @@ enum skb_drop_reason ndisc_rcv(struct sk_buff *skb) break; case NDISC_REDIRECT: - ndisc_redirect_rcv(skb); + reason = ndisc_redirect_rcv(skb); break; } From patchwork Thu Feb 16 16:28:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143478 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4196FC61DA4 for ; Thu, 16 Feb 2023 16:29:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjBPQ3i (ORCPT ); Thu, 16 Feb 2023 11:29:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbjBPQ32 (ORCPT ); Thu, 16 Feb 2023 11:29:28 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0154C3F2 for ; Thu, 16 Feb 2023 08:29:24 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-4bdeb1bbeafso25670997b3.4 for ; Thu, 16 Feb 2023 08:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=z2b/pa7BPsxyCxV9qMNryAua+HU599nYF7p3XmEUu+4=; b=UQ/GAf+EPG+O25AxuHkJbSINz/fynjGHdYguQ0IG5MfLwEBNFGMjMvg9CiBEUIGdgY 7V+vSbCObULqW9uXjAu9dBsgH/CfKTGeom6D7Hz5zMPsFQFai8f4/Gv/jKCyB6ozuL78 mJKZEcDABwLDV73U4KkgNwYBDjO9bMa5LrRN/Xj7CDLfzpk18snbGUf+hUDPggA1LXgl xkaCmuqdBckVV2ek2HUsHDMg4dzCtN1+aDE8CfU2llA77wvENiA6agun7sF1CbBQS7NQ 8CJdZI9s3QQbNpPDa0PdKPfaBZK2/RV0rmnkhq8YJr2pR6IexRg5BbyqIHq892tCG24S X/og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z2b/pa7BPsxyCxV9qMNryAua+HU599nYF7p3XmEUu+4=; b=ORrI/i9c14UDbaPjBKpfJIOel8C+7NDia9JirsvgA2+3Z/RAp6vketj1fm97ak9uWv XblQS6Pa6faBUjEekXlxtiSk5uvAabXebgY82ZsaFNBJw1gp8IViieMDpR3F5iuz3sau pj4anhJWp2t+GfIeQ6tofayTSM0iLuHRW25TeB6w7InviUnsuLY0n9SwwM3S5+LfNwLj +PKKm+76HcqHe8wxezbVvAKnJig9l6cG1Dy8rE1fMi1nQcnc+fz9uHguj60x241foU4S FJUEU1AQeO6BGd19noUUPfLrQWowbPoX7Ea0++Haa5+z7d9dSQEV/3T72YfKI1C6PDZB 9wSw== X-Gm-Message-State: AO0yUKWOyrX0Z+ItCM/hWDje+O5+SdP8Yp8hgzXuzdQShDYxnSF6fYMp mZTDF8R2ryRipF3ZBFA76J7o2YRFhmxXsA== X-Google-Smtp-Source: AK7set/OvLrRIdGwlWcIuG2mOT/RQPMwiytjMB4LsxFagDTne5nNc2uFnN2L++PRYxS+HVpvPHXcaU3kSL8yQg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:10f:b0:855:fa17:4f5f with SMTP id o15-20020a056902010f00b00855fa174f5fmr88ybh.1.1676564963202; Thu, 16 Feb 2023 08:29:23 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:40 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-7-edumazet@google.com> Subject: [PATCH net-next 6/8] ipv6: icmp6: add SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This is a generic drop reason for any error detected in ndisc_parse_options(). Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 3 +++ net/ipv6/ndisc.c | 27 ++++++++++----------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index ef3f65d135d375920e88759890947ed0f6e87e10..239a5c0ea83eb6053df55f1ea113f3005ec050b0 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -76,6 +76,7 @@ FN(IPV6_NDISC_FRAG) \ FN(IPV6_NDISC_HOP_LIMIT) \ FN(IPV6_NDISC_BAD_CODE) \ + FN(IPV6_NDISC_BAD_OPTIONS) \ FNe(MAX) /** @@ -330,6 +331,8 @@ enum skb_drop_reason { SKB_DROP_REASON_IPV6_NDISC_HOP_LIMIT, /** @SKB_DROP_REASON_IPV6_NDISC_BAD_CODE: invalid NDISC icmp6 code. */ SKB_DROP_REASON_IPV6_NDISC_BAD_CODE, + /** @SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS: invalid NDISC options. */ + SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index e9776aa6f1675e35273df16e40745779b91d117e..b47e845d66eb8533e2334915fe6f05bed6f84764 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -819,10 +819,8 @@ static enum skb_drop_reason ndisc_recv_ns(struct sk_buff *skb) return reason; } - if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) { - ND_PRINTK(2, warn, "NS: invalid ND options\n"); - return reason; - } + if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) + return SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS; if (ndopts.nd_opts_src_lladdr) { lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev); @@ -1026,10 +1024,9 @@ static enum skb_drop_reason ndisc_recv_na(struct sk_buff *skb) idev->cnf.drop_unsolicited_na) return reason; - if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) { - ND_PRINTK(2, warn, "NS: invalid ND option\n"); - return reason; - } + if (!ndisc_parse_options(dev, msg->opt, ndoptlen, &ndopts)) + return SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS; + if (ndopts.nd_opts_tgt_lladdr) { lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev); if (!lladdr) { @@ -1159,10 +1156,8 @@ static enum skb_drop_reason ndisc_recv_rs(struct sk_buff *skb) goto out; /* Parse ND options */ - if (!ndisc_parse_options(skb->dev, rs_msg->opt, ndoptlen, &ndopts)) { - ND_PRINTK(2, notice, "NS: invalid ND option, ignored\n"); - goto out; - } + if (!ndisc_parse_options(skb->dev, rs_msg->opt, ndoptlen, &ndopts)) + return SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS; if (ndopts.nd_opts_src_lladdr) { lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, @@ -1280,10 +1275,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb) return reason; } - if (!ndisc_parse_options(skb->dev, opt, optlen, &ndopts)) { - ND_PRINTK(2, warn, "RA: invalid ND options\n"); - return reason; - } + if (!ndisc_parse_options(skb->dev, opt, optlen, &ndopts)) + return SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS; if (!ipv6_accept_ra(in6_dev)) { ND_PRINTK(2, info, @@ -1627,7 +1620,7 @@ static enum skb_drop_reason ndisc_redirect_rcv(struct sk_buff *skb) } if (!ndisc_parse_options(skb->dev, msg->opt, ndoptlen, &ndopts)) - return reason; + return SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS; if (!ndopts.nd_opts_rh) { ip6_redirect_no_header(skb, dev_net(skb->dev), From patchwork Thu Feb 16 16:28:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143479 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60795C636CC for ; Thu, 16 Feb 2023 16:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbjBPQ3k (ORCPT ); Thu, 16 Feb 2023 11:29:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjBPQ3b (ORCPT ); Thu, 16 Feb 2023 11:29:31 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE844C3E3 for ; Thu, 16 Feb 2023 08:29:26 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-4fa63c84621so25826297b3.20 for ; Thu, 16 Feb 2023 08:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UXpY1QDBt9x+f4MQsrH92T2bHcD9zbnU39pummnedWg=; b=SHlXcU+57gwSD/X4fens7zV84TkqwG1dymbENDZtW9uvrsz9PrRknYL4X2HOs6EYjq Zcvkl2fZ/atT5i+/UOK/xuim4Lvv5bh/AlYvEdqM7j2gbAPJ44wQDwCUn9YNTS23Cr4L /kQezFkzH8qeMrLXI4Inbclq00nIb6lWLtV5bcwOKuzkVrg7n1dTqFuNipU7oTNZ75fD /igzbKG8enpL5c0lUG+q+v4vhHK9Wp4e3ytwA0q60IO7IA+/01zhy46BZzqq04PuevZB 4xcf9gTVLZ8yviu3RH9gQxnNZq0piwsOSiGRw5rtRIHqYUt/QIMP6CA+jONMcnPd3TjX bXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UXpY1QDBt9x+f4MQsrH92T2bHcD9zbnU39pummnedWg=; b=BFAokpfEy/A2dNBbTLM3evYfn2ce/7hDAqcU6kLS93ZUo5nXwrkpSb71SBnCeqtmyx sQLKndVARiI32vhYb4oTF4R1jBqdFGqBW+IuO5w74VxAtrRDF+nBYEiHY4DglwXlG9nT /dCgmt227wtwgaZY/HQjfAUofLAAypXqVgDlJ1MN+BKI8kS6l+yW/6VZRHtrtz+sauGX n5ejh7O9FeUEnJnj8Mh4LnpzlrTZofdLziJ/FrUWYuhBk2Yen616PAsv8UzHr6CQmhgP i0E/k1R9aJS+0cAkJavILIU1Ld+fQxM7lb9fbHv2urQOwDBoPnKHJav/mekzlI8x+Hqf y8AA== X-Gm-Message-State: AO0yUKXog66UYcTNE0YrtKTdG7wf50+0J5bK+6LAddD5JUgMGbSlbEAi ytpCM9tJIXERTD33UE3hr9x6YAFD8kZNJg== X-Google-Smtp-Source: AK7set9207yRs1hCcf39/YY49kRgKYapCRNng5Dki2Vf1s8ELpYpjHhjLQkhd1c4GcDex6Y81pPmDoqKuohPlg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a5b:3c2:0:b0:8c7:f99b:2a6e with SMTP id t2-20020a5b03c2000000b008c7f99b2a6emr13ybp.6.1676564965330; Thu, 16 Feb 2023 08:29:25 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:41 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-8-edumazet@google.com> Subject: [PATCH net-next 7/8] ipv6: icmp6: add SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Hosts can often receive neighbour discovery messages that are not for them. Use a dedicated drop reason to make clear the packet is dropped for this normal case. Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 5 +++++ net/ipv6/ndisc.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 239a5c0ea83eb6053df55f1ea113f3005ec050b0..c0a3ea806cd5bf3045efd568cafb227dab7f2d3d 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -77,6 +77,7 @@ FN(IPV6_NDISC_HOP_LIMIT) \ FN(IPV6_NDISC_BAD_CODE) \ FN(IPV6_NDISC_BAD_OPTIONS) \ + FN(IPV6_NDISC_NS_OTHERHOST) \ FNe(MAX) /** @@ -333,6 +334,10 @@ enum skb_drop_reason { SKB_DROP_REASON_IPV6_NDISC_BAD_CODE, /** @SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS: invalid NDISC options. */ SKB_DROP_REASON_IPV6_NDISC_BAD_OPTIONS, + /** @SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST: NEIGHBOUR SOLICITATION + * for another host. + */ + SKB_DROP_REASON_IPV6_NDISC_NS_OTHERHOST, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index b47e845d66eb8533e2334915fe6f05bed6f84764..c4be62c99f7371a55e56f4489f822d9c11b007f5 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -921,8 +921,10 @@ static enum skb_drop_reason ndisc_recv_ns(struct sk_buff *skb) pneigh_enqueue(&nd_tbl, idev->nd_parms, n); goto out; } - } else + } else { + SKB_DR_SET(reason, IPV6_NDISC_NS_OTHERHOST); goto out; + } } if (is_router < 0) From patchwork Thu Feb 16 16:28:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13143480 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D02E3C61DA4 for ; Thu, 16 Feb 2023 16:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbjBPQaD (ORCPT ); Thu, 16 Feb 2023 11:30:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjBPQ3h (ORCPT ); Thu, 16 Feb 2023 11:29:37 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE04F59B67 for ; Thu, 16 Feb 2023 08:29:28 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-4cddba76f55so25709907b3.23 for ; Thu, 16 Feb 2023 08:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=283l3a/tUE8xbNSPHcrnWcsNHJnpHUea+yLRapuNfEM=; b=PyCPnTAR5CmphaiVVFWOwcnYbIMmbItu3Q/svukxp5eOxeISF29P7ISVbvxBRfqZMd Po9Va66UDWxst8/WzGYqaKP3Tv/mmZeDRC0d5L3fs0iNOxyGzDSCtOql6HSEps0GGTdM DB2EThIcOcgf8lJvykTyc2lGF6urYP6uoNJa0VNpp2Sk1OjRClYdJLiZSVdprBI4zH4b izzU8/2BON2ZN3JLgCBXLLuQLf0kX+VLAHKEcQIFsR6jwnaHJhBUm24uYEXOMBAw/3FE bCroO2xIwUZn6yh/3VZEr4oIlM9XmmEddX9BX+BlLYcOepMEcWPTme9Z3w7yc9Qom0oW G6GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=283l3a/tUE8xbNSPHcrnWcsNHJnpHUea+yLRapuNfEM=; b=aWiwplVAwy52shE0wyMdK5QGSx5azg2016O9ovpBzz6gXclvg8EhhziW7ZoHOe73Rj MprbRo3Cv+3IUNhfSOF9BvCyPEGgPy2myyML0VqhPy+p95ulSjTF5vjbUuGUNkhf27z1 +uXFqe2TxeMP09CvUEl0BUYQ68Ko7D8KpA//b91hrzd1GsstmiVNzH+2Teew7+y2KOmK NW889NkjqOeTtuECEefa+CIkGZ5wnQdKNHSo4G36aLkUVJUzeNCDLhd39UN+Gj5snnc4 EbJKCs+Wx9iVMI4BUXeQflINTz0m+1mRgGn8JH4DNXXSgVV9iKd0ntym4LdxiVssVwtl N/5Q== X-Gm-Message-State: AO0yUKUm482hyPFR61wszqJrvW9NX3WGrEjKJNfLX85QG7bMwiWyT+hi FX/+C3y3+Ua1r9IzZRreFAF9O06PVC5jXA== X-Google-Smtp-Source: AK7set/bcXHFABRESwvoLYebxeoBrl1oEzgmxH6Ox+JplRk5Bz3AAUNEx3+wVpxH8D5rlv4uxS3xTQix6JjBfg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:8811:0:b0:914:fc5e:bbec with SMTP id c17-20020a258811000000b00914fc5ebbecmr6ybl.13.1676564967464; Thu, 16 Feb 2023 08:29:27 -0800 (PST) Date: Thu, 16 Feb 2023 16:28:42 +0000 In-Reply-To: <20230216162842.1633734-1-edumazet@google.com> Mime-Version: 1.0 References: <20230216162842.1633734-1-edumazet@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230216162842.1633734-9-edumazet@google.com> Subject: [PATCH net-next 8/8] ipv6: icmp6: add drop reason support to icmpv6_echo_reply() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Change icmpv6_echo_reply() to return a drop reason. For the moment, return NOT_SPECIFIED or SKB_CONSUMED. Signed-off-by: Eric Dumazet --- net/ipv6/icmp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index f32bc98155bfb027dd3328eefd4a26a1d067c013..1f53f2a74480c0b8433204b567e7f98ad1216ad6 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -705,7 +705,7 @@ int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, } EXPORT_SYMBOL(ip6_err_gen_icmpv6_unreach); -static void icmpv6_echo_reply(struct sk_buff *skb) +static enum skb_drop_reason icmpv6_echo_reply(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); struct sock *sk; @@ -719,18 +719,19 @@ static void icmpv6_echo_reply(struct sk_buff *skb) struct dst_entry *dst; struct ipcm6_cookie ipc6; u32 mark = IP6_REPLY_MARK(net, skb->mark); + SKB_DR(reason); bool acast; u8 type; if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) && net->ipv6.sysctl.icmpv6_echo_ignore_multicast) - return; + return reason; saddr = &ipv6_hdr(skb)->daddr; acast = ipv6_anycast_destination(skb_dst(skb), saddr); if (acast && net->ipv6.sysctl.icmpv6_echo_ignore_anycast) - return; + return reason; if (!ipv6_unicast_destination(skb) && !(net->ipv6.sysctl.anycast_src_echo_reply && acast)) @@ -804,6 +805,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) } else { icmpv6_push_pending_frames(sk, &fl6, &tmp_hdr, skb->len + sizeof(struct icmp6hdr)); + reason = SKB_CONSUMED; } out_dst_release: dst_release(dst); @@ -811,6 +813,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb) icmpv6_xmit_unlock(sk); out_bh_enable: local_bh_enable(); + return reason; } enum skb_drop_reason icmpv6_notify(struct sk_buff *skb, u8 type, @@ -929,12 +932,12 @@ static int icmpv6_rcv(struct sk_buff *skb) switch (type) { case ICMPV6_ECHO_REQUEST: if (!net->ipv6.sysctl.icmpv6_echo_ignore_all) - icmpv6_echo_reply(skb); + reason = icmpv6_echo_reply(skb); break; case ICMPV6_EXT_ECHO_REQUEST: if (!net->ipv6.sysctl.icmpv6_echo_ignore_all && READ_ONCE(net->ipv4.sysctl_icmp_echo_enable_probe)) - icmpv6_echo_reply(skb); + reason = icmpv6_echo_reply(skb); break; case ICMPV6_ECHO_REPLY: