From patchwork Wed Mar 24 18:17:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161983 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B79B0C433E4 for ; Wed, 24 Mar 2021 18:18:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D87B61A0F for ; Wed, 24 Mar 2021 18:18:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237483AbhCXSSY (ORCPT ); Wed, 24 Mar 2021 14:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237126AbhCXSRu (ORCPT ); Wed, 24 Mar 2021 14:17:50 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48DFEC061763 for ; Wed, 24 Mar 2021 11:17:50 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id f9so21767131oiw.5 for ; Wed, 24 Mar 2021 11:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bBO2cd1qd3fbWL44FOOcOnUmpEptHmAjPUxtPNN1Qro=; b=BGA+FZ6tiBV2pFUuuR6ngyXsVTwOMfGKhsGGHFUZu+PDql6qa+KwPqZzM1m+ovzcL7 cyGA5zazACxzAc4tRdYeYrs9hHrqIRxgVZJbwWlHFXaO2l+e5l70W/mNdvJcdnxrbwvv ZTY9CQfDzV3+Rfl5QM6VuaEr8dLCbqkkcDMuohY/lyQ+rU5fhkeO5o+UjSEHuvxpHV5S Fsp6QRCHOOJ6egla51xQNR7B/4HbjIjd++0AsXfadJCzTlHHR4/iwEO3baZ5E6Akr0c2 bYVP0O+xP+0GwxXFW8XRgoGHFTgDF8J7thTB9fVxJhxg2pM+EgufNcBiTB9wRiOxtmXe Uhkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bBO2cd1qd3fbWL44FOOcOnUmpEptHmAjPUxtPNN1Qro=; b=ghTIaxetbFJ7jTGvj4up+pBCuCBQXzYZ4u3oOH6hsEIbr9y7vI/CigDb2uWxHePY3Y VUBEbslK7bYm8qxcR+wfpvBZEXYbw4/fKnZoi3sn5LcW16UMvx6//Sk8dPUYx6kAGUXS gh8+o7opGX8ahE5+cGLkbiHhxNckYgXwGJzCe1gvCqg0rHawqezXNPE1U6PnRPw3LjLu bdAL67py6f8jynURtKrdoW51lFP93famSuvWzUmgU8RHVvuG0V1mzmMGqf7eEffp3HSD Ta1jlKrliioxfMRj1bkTxPnT+a0QOSZNcIbVrtjndxxkx6iM1CphyXbcUBNJ4NdvCk+N A4Vg== X-Gm-Message-State: AOAM530Y320rCNrVQpcAze/BgsfrKWaEty9ULA7l01OXkEtWKmFn/cj+ Uu/u7vEPKQSDFJmaZAa8poJwYNKGo2U= X-Google-Smtp-Source: ABdhPJzI40yEj8HAfT75RBX5bkP9bqlwBf4R+fIifCox1G1+OePDc5IOD5cknIif9D9JBe7J5Ibi7Q== X-Received: by 2002:a05:6808:907:: with SMTP id w7mr3279935oih.94.1616609869482; Wed, 24 Mar 2021 11:17:49 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id x20sm431187oiv.35.2021.03.24.11.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:17:49 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 1/6] icmp: add support for RFC 8335 PROBE Date: Wed, 24 Mar 2021 11:17:47 -0700 Message-Id: <558c61137abc5c8b016e2b23050ad37c36f2b4eb.1616608328.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add definitions for PROBE ICMP types and codes. Add AFI definitions for IP and IPV6 as specified by IANA Add a struct to represent the additional header when probing by IP address (ctype == 3) for use in parsing incoming PROBE messages Add a struct to represent the entire Interface Identification Object (IIO) section of an incoming PROBE packet Signed-off-by: Andreas Roeseler --- Changes: v1 -> v2: - Add AFI_IP and AFI_IP6 definitions v2 -> v3: Suggested by Willem de Bruijn - Add prefix for PROBE specific defined variables - Create struct icmp_ext_echo_iio for parsing incoming packet v3 -> v4: - Use in_addr instead of __be32 for storing IPV4 addresses - Use IFNAMSIZ to statically allocate space for name in icmp_ext_echo_iio v4 -> v5: - Use __be32 instead of __u32 in defined structs --- include/uapi/linux/icmp.h | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h index fb169a50895e..222325d1d80e 100644 --- a/include/uapi/linux/icmp.h +++ b/include/uapi/linux/icmp.h @@ -20,6 +20,9 @@ #include #include +#include +#include +#include #define ICMP_ECHOREPLY 0 /* Echo Reply */ #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ @@ -66,6 +69,23 @@ #define ICMP_EXC_TTL 0 /* TTL count exceeded */ #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ +/* Codes for EXT_ECHO (PROBE) */ +#define ICMP_EXT_ECHO 42 +#define ICMP_EXT_ECHOREPLY 43 +#define ICMP_EXT_MAL_QUERY 1 /* Malformed Query */ +#define ICMP_EXT_NO_IF 2 /* No such Interface */ +#define ICMP_EXT_NO_TABLE_ENT 3 /* No such Table Entry */ +#define ICMP_EXT_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */ + +/* Constants for EXT_ECHO (PROBE) */ +#define EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply message */ +#define EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply message */ +#define EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply message */ +#define EXT_ECHO_CTYPE_NAME 1 +#define EXT_ECHO_CTYPE_INDEX 2 +#define EXT_ECHO_CTYPE_ADDR 3 +#define ICMP_AFI_IP 1 /* Address Family Identifier for ipv4 */ +#define ICMP_AFI_IP6 2 /* Address Family Identifier for ipv6 */ struct icmphdr { __u8 type; @@ -118,4 +138,26 @@ struct icmp_extobj_hdr { __u8 class_type; }; +/* RFC 8335: 2.1 Header for c-type 3 payload */ +struct icmp_ext_echo_ctype3_hdr { + __be16 afi; + __u8 addrlen; + __u8 reserved; +}; + +/* RFC 8335: 2.1 Interface Identification Object */ +struct icmp_ext_echo_iio { + struct icmp_extobj_hdr extobj_hdr; + union { + char name[IFNAMSIZ]; + __be32 ifindex; + struct { + struct icmp_ext_echo_ctype3_hdr ctype3_hdr; + union { + struct in_addr ipv4_addr; + struct in6_addr ipv6_addr; + } ip_addr; + } addr; + } ident; +}; #endif /* _UAPI_LINUX_ICMP_H */ From patchwork Wed Mar 24 18:17:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161987 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDF43C433E9 for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1480619F8 for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237501AbhCXSS0 (ORCPT ); Wed, 24 Mar 2021 14:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237430AbhCXSR4 (ORCPT ); Wed, 24 Mar 2021 14:17:56 -0400 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D30EC061763 for ; Wed, 24 Mar 2021 11:17:56 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id h6-20020a0568300346b02901b71a850ab4so23928153ote.6 for ; Wed, 24 Mar 2021 11:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lio5CHdjePdGCdvRLilg1iaYE0Vy2lHPlsFlnZ4SNRQ=; b=SPAlecpI+cV6d+tuXtjpbrSrLILyPD42CX8AEAk8IlCHJKJGmH8Fz6YoE1gjyDCLKn KUnDFWBYi69g90Q21qwvZ/I0HYN5a4uJFQ7KK860Sw1quoneqlRbg88yQhyolJ2ULRqM yQ64hdYHxObkcoXXGFfi4NaV+Xj+NvBI9UNXCLnoT5FZOn2QTfTArX/aRyzy1NLHzkQ2 yylnCHQk4PoPSEPQQEaB4PFYg6FaLrnYKHCMYoqaHn+QojgiKlu1iPBvMsLTRA9Ks+F8 lBvX+9wcasTKj7JzNd3dJA7L3pGoXgIJX3QXXV9LJxkYWvxuwwp1UUADomY1ouDQTxrF 4dqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Lio5CHdjePdGCdvRLilg1iaYE0Vy2lHPlsFlnZ4SNRQ=; b=oruiZZ2j4IlfdDkVp3Et5ONklCUedPQKeq+U+1khOKzZ9fFya5jeak2EMXPla/TYl+ Mh3I2KOj6JzssmWxiXPuXqb60qaJz8k0rrt+dLdJpSKGsbRXcHVUX8aGlgrZL4oeEDIY L7qQACzwgdjak2mgI8w5ESXMgXuOGlQ7BTAenps0XkJWq8fAlMkunil6Qx6tTWOVPqL+ NrPKwNki2xzdAhBcBwatm88C8s/4T6PcvNGOMueIxfTLQYQNZLocPk0QNYcT9YuTG6yf 1tWZ2O9aYrIxihyoLqdFdeU0xzfueeUZ2v9CgFDrJtccr0sDLOKojGxuyOhNHZHuZYMw 7/vg== X-Gm-Message-State: AOAM531aKkUqR2lll8K4fWebHMlfn7xD4v/FTYjANKN56m/dsCzUt78V FW54i8b5G7ddUp1XkXnVX+voXeryI3M= X-Google-Smtp-Source: ABdhPJxsPdjMZq6YVfoQJS/Sg1AE+16rDRycTX9Dr5PIRzmxWdPdFLPpTsq+tnSfS2ucnpjXXuWV7Q== X-Received: by 2002:a9d:4048:: with SMTP id o8mr4177639oti.152.1616609875891; Wed, 24 Mar 2021 11:17:55 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id z8sm694590otp.14.2021.03.24.11.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:17:55 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 2/6] ICMPV6: add support for RFC 8335 PROBE Date: Wed, 24 Mar 2021 11:17:53 -0700 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add definitions for the ICMPV6 type of Extended Echo Request and Extended Echo Reply, as defined by sections 2 and 3 of RFC 8335. Signed-off-by: Andreas Roeseler --- include/uapi/linux/icmpv6.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/uapi/linux/icmpv6.h b/include/uapi/linux/icmpv6.h index 0564fd7ccde4..ecaece3af38d 100644 --- a/include/uapi/linux/icmpv6.h +++ b/include/uapi/linux/icmpv6.h @@ -140,6 +140,9 @@ struct icmp6hdr { #define ICMPV6_UNK_OPTION 2 #define ICMPV6_HDR_INCOMP 3 +/* Codes for EXT_ECHO (PROBE) */ +#define ICMPV6_EXT_ECHO_REQUEST 160 +#define ICMPV6_EXT_ECHO_REPLY 161 /* * constants for (set|get)sockopt */ From patchwork Wed Mar 24 18:18:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161989 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEDE6C433EA for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C145261A1B for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237505AbhCXSS2 (ORCPT ); Wed, 24 Mar 2021 14:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237442AbhCXSSD (ORCPT ); Wed, 24 Mar 2021 14:18:03 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 367F5C061763 for ; Wed, 24 Mar 2021 11:18:03 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id y19-20020a0568301d93b02901b9f88a238eso23911622oti.11 for ; Wed, 24 Mar 2021 11:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GIz2Ptd4zKdP/hveDJ9Ox2s4W0sXpgyIYI77/Jp1I5E=; b=TTEYA7Q+WZynb4uZMEKSWTVwfFVND4hIJbhvYEcUXTsAlCFVz533OBEyuxcInG0KJj TB7nkS54oHNNWV0qcgpKyaD5oA6Ar/ItfHnrFRSi7/7JytVYC2tpTBwUBxgMvKedJHPT HNvc55HIAr/d7o1ObZ1D6Stzc1LrxotbVPPUGXPUpriQ+KpgK3ONg+D5BMlQwZpRer7i pn/yrlp8mtLUpiWFz97/xAsoUG3uEOU6ciuOIxC9Iy3gBJH9jYWoBVmndp+XIXbKh1q1 0ErC1oivo2F7yTB4e1ys68M3Q3z+y0l5m+kbvMqxWHtfIhq1NdUXFWZgF28ZrCf8Cwdq Iv7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GIz2Ptd4zKdP/hveDJ9Ox2s4W0sXpgyIYI77/Jp1I5E=; b=NIPhu6zV73PeaOU9XnJMNzkTzLkvcN109686xfj5d1U2QhB0ke4PWxVRYhMeTU1ATo 0k+U5ASKNMxreB17Mi/nzeflmFbQLCr0s3nlpjxQBVGH9ezy7PMyjXPBzPi02c1HMcmJ SmGQe+UeRlUoCMpzdltYkdCeQ0vmIfZe3kGqtiwax4+bZ9dmMQtHIEU6dEaCx5OaI5kR u1xTv6nGGIMd4wBlmJc1CRVZqx1GwU8wkk5BDXN6hliuwqnFhDXbcR254dgY9Qi7p4w2 l1z13T/XKOc/pl516HojYaCI1nQNQUdbn3WC7V0fj8OedBdvacrnkSFSt3gJ4Nz8jIk8 5rmg== X-Gm-Message-State: AOAM532xhdFAEal8lMzQ2BES+eOB4JoaRxO0q5omkS6vXf3fRuseyeTN HQGt3af263i3PaYSmuFnxJ9xuC13QfY= X-Google-Smtp-Source: ABdhPJynafuHruBxRlQHvJvj9kf1+yrsRJQw9QZ5moapku+n8qcDy6zHdVUwAYsHhjC1USjcU/I3lw== X-Received: by 2002:a9d:6ad9:: with SMTP id m25mr4257410otq.267.1616609882506; Wed, 24 Mar 2021 11:18:02 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id f192sm545583oig.48.2021.03.24.11.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:18:02 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 3/6] net: add sysctl for enabling RFC 8335 PROBE messages Date: Wed, 24 Mar 2021 11:18:00 -0700 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Section 8 of RFC 8335 specifies potential security concerns of responding to PROBE requests, and states that nodes that support PROBE functionality MUST be able to enable/disable responses and that responses MUST be disabled by default Signed-off-by: Andreas Roeseler --- Changes: v1 -> v2: - Combine patches related to sysctl v2 -> v3: Suggested by Willem de Bruijn - Use proc_dointvec_minmax with zero and one --- include/net/netns/ipv4.h | 1 + net/ipv4/sysctl_net_ipv4.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 70a2a085dd1a..362388ab40c8 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -85,6 +85,7 @@ struct netns_ipv4 { #endif int sysctl_icmp_echo_ignore_all; + int sysctl_icmp_echo_enable_probe; int sysctl_icmp_echo_ignore_broadcasts; int sysctl_icmp_ignore_bogus_error_responses; int sysctl_icmp_ratelimit; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index f55095d3ed16..fec3f142d8c9 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -599,6 +599,15 @@ static struct ctl_table ipv4_net_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, + { + .procname = "icmp_echo_enable_probe", + .data = &init_net.ipv4.sysctl_icmp_echo_enable_probe, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, From patchwork Wed Mar 24 18:18:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161985 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0D73C433EC for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D074661A27 for ; Wed, 24 Mar 2021 18:18:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237510AbhCXSSa (ORCPT ); Wed, 24 Mar 2021 14:18:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237446AbhCXSSK (ORCPT ); Wed, 24 Mar 2021 14:18:10 -0400 Received: from mail-oo1-xc2e.google.com (mail-oo1-xc2e.google.com [IPv6:2607:f8b0:4864:20::c2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB67C061763 for ; Wed, 24 Mar 2021 11:18:10 -0700 (PDT) Received: by mail-oo1-xc2e.google.com with SMTP id 125-20020a4a1a830000b02901b6a144a417so6040396oof.13 for ; Wed, 24 Mar 2021 11:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BzVco/Eg/onFpe1i6nNSzFOzajJSuv5MLzRUu8zpDpk=; b=ug0ww+4Ujt8NAMxgDUbsMQHavK1ILbGdSNkJ7JaQVT4ANw+VKRe2BBOye5IOLD3qoZ ymmgkBjzY75m9JuZhmh5yEQNJxTK5jcKDm1IZRTTHR98pj/1BMqX887eMpYRM6zJ2cgX QfJ1Mwf2ae6doIdFmXHFhx4Wl+VnmG73mNx+EncklPveUfe8hFOkEsP5x+IKSjWOHIVE exLJta/29UJ6ziuaXVKYJxSVtvdu6AeTLccLWEXz6Z7hNjeLvJg2dNCix792ak7poLR5 lfec1RQI5bpodUF0ZQGau0sGMkn5Nu24LKnYApRbnk+Lrxef59aLdploURd4NJKK0DOx ITPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BzVco/Eg/onFpe1i6nNSzFOzajJSuv5MLzRUu8zpDpk=; b=anFJP5f228zT3oggdDopHfAw8QdVcVApFa7zF6/MA63KBSGy7uu3ngpjJLEdXXNwL9 Odxx7Qnd0vWRLSbKih+2bi61IFmM9tkBUR8dqQRiAR3NiYGHFQ+QL6x11gs+RBGL1cF7 wbeJxS69DKG+IoHeBU2rZRlb0b33FCUYJQ9VxruzbYghIyXikp4RnwXaUJGKLfF0G1iE O6Tfh7n+rbHm2e+lwf8nV95chlmRl/Sgr6JLUEk2U7TuO0VHxgzE58KF6sAe7q5Va5rA 3kLhp9o9nTa2iYLZGoWqrzR6ikZ9Z7ZolrvHnOSyESSLDia4Pp25qN0a5rGc0hQKxYkk tfMw== X-Gm-Message-State: AOAM532E8tJy7KCgs/uQTLY4aCCQEb9rkZPqDQSg0FV9CRAoFi3MK7j8 NpUEigdR90LGdRpOAmrCQ2HizN720lc= X-Google-Smtp-Source: ABdhPJx3DV8Q/57EZrzuQzDDG35i2v06ztmcO9ygjlKLpPWgR7IeY5jFGxh7Hrwf7gkHLMGnZPSb5A== X-Received: by 2002:a4a:d24c:: with SMTP id e12mr3846458oos.73.1616609889831; Wed, 24 Mar 2021 11:18:09 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id n13sm701718otk.61.2021.03.24.11.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:18:09 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 4/6] net: add support for sending RFC 8335 PROBE messages Date: Wed, 24 Mar 2021 11:18:07 -0700 Message-Id: <34d0ca051b01f52f5bf80b7f170d5101548826dc.1616608328.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Modify the ping_supported function to support PROBE message types. This allows tools such as the ping command in the iputils package to be modified to send PROBE requests through the existing framework for sending ping requests. Signed-off-by: Andreas Roeseler --- net/ipv4/ping.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 8b943f85fff9..1c9f71a37258 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -453,7 +453,9 @@ EXPORT_SYMBOL_GPL(ping_bind); static inline int ping_supported(int family, int type, int code) { return (family == AF_INET && type == ICMP_ECHO && code == 0) || - (family == AF_INET6 && type == ICMPV6_ECHO_REQUEST && code == 0); + (family == AF_INET && type == ICMP_EXT_ECHO && code == 0) || + (family == AF_INET6 && type == ICMPV6_ECHO_REQUEST && code == 0) || + (family == AF_INET6 && type == ICMPV6_EXT_ECHO_REQUEST && code == 0); } /* From patchwork Wed Mar 24 18:18:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161991 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 360DBC433E0 for ; Wed, 24 Mar 2021 18:19:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F28B561A16 for ; Wed, 24 Mar 2021 18:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237271AbhCXSSz (ORCPT ); Wed, 24 Mar 2021 14:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237457AbhCXSST (ORCPT ); Wed, 24 Mar 2021 14:18:19 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B44E6C061763 for ; Wed, 24 Mar 2021 11:18:17 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 31-20020a9d00220000b02901b64b9b50b1so23901864ota.9 for ; Wed, 24 Mar 2021 11:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jsFMOnHTaYqx7LeUFb/5lV47lLjS2I+zclun6rcpJ+Y=; b=gTw8KTPi/aBDaFC8XKZMZ8enrhuJykPcqryaOyH1jSWxn6oas8gNXV+hB7C1gh7v1j 79LCPxERE/QzLEPc7R5OOIHcEG3y/7G6gPRVTnMTzUKc0ufMMzHX9Pt2TOUlXb9KZOwg AABz7DuT0Myk7X139svwcKl5fqt9rpsHx3LF4mNoctOriYki8rS+6sC+LWbvpJ7I4QJF 4CF7wY/adGy+qyEdSaJCqk2eo4bHQitTczuIKy/sj8sptQm3gDh9fkiOtvbOttKTad9m TKrwzAJsyT+AQeGYTB7eiZnCK9gUHPCfUbULR6EhpaChu0a3KV/u9iCdKs8VI8C+w3uL zfkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jsFMOnHTaYqx7LeUFb/5lV47lLjS2I+zclun6rcpJ+Y=; b=FnCpYNwJ+eoduScnp40c9Pga+KF/j5JamjfDjbOQPT3Bfjy4cca0mFnFGbR03ZYM9+ 5eF5KpZ+lDarAjHgdu6PRr1kyZgvkfUJzZDDzey8KB+EiybUgmt+M517Hva3Kvse8Ah5 z2sECnbBxeqqtUFNZ6r95AEAjAVvw4iCkFwQ1l2D18I9765sSKgXOoDsJqzjygp/FvHM Nb2t+hpu0ru+Ip7Ktq0qD2cLFnda2uVUNN55cLi8uBsflqcphVm9v4Q4WXaucOiTm6LR LRG1Lh7OJGf7+OaQ9ye/5WXZa59lkw5wSBAvh5rBrbjSXkhYyR7OHlHscwf1pGgAOOHj g7Gw== X-Gm-Message-State: AOAM530ArZN9SWRgXdeNeJpLmqzvsxd9FyIRoiR9DCLaoWa1Zr/wTtKC SszhbcTqKJbsIgs/5luTrCRC2ZRzi3Q= X-Google-Smtp-Source: ABdhPJxNRiaqEPHZ4446iO97Ka0Afrb8K1VYjZOcgU5QnSS3Yv3XH+42ZG3Zc+0/Jz84BHDLpEfDsQ== X-Received: by 2002:a9d:37b4:: with SMTP id x49mr4122422otb.237.1616609897070; Wed, 24 Mar 2021 11:18:17 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id h59sm707942otb.29.2021.03.24.11.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:18:16 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 5/6] ipv6: add ipv6_dev_find to stubs Date: Wed, 24 Mar 2021 11:18:14 -0700 Message-Id: <2d1a2ac63ae19879557526a1ca5dc37a04d1a076.1616608328.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add ipv6_dev_find to ipv6_stub to allow lookup of net_devices by IPV6 address in net/ipv4/icmp.c. Signed-off-by: Andreas Roeseler --- include/net/ipv6_stubs.h | 2 ++ net/ipv6/addrconf_core.c | 7 +++++++ net/ipv6/af_inet6.c | 1 + 3 files changed, 10 insertions(+) diff --git a/include/net/ipv6_stubs.h b/include/net/ipv6_stubs.h index 8fce558b5fea..afbce90c4480 100644 --- a/include/net/ipv6_stubs.h +++ b/include/net/ipv6_stubs.h @@ -66,6 +66,8 @@ struct ipv6_stub { int (*ipv6_fragment)(struct net *net, struct sock *sk, struct sk_buff *skb, int (*output)(struct net *, struct sock *, struct sk_buff *)); + struct net_device *(*ipv6_dev_find)(struct net *net, const struct in6_addr *addr, + struct net_device *dev); }; extern const struct ipv6_stub *ipv6_stub __read_mostly; diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c index c70c192bc91b..8f0b6024eba8 100644 --- a/net/ipv6/addrconf_core.c +++ b/net/ipv6/addrconf_core.c @@ -198,6 +198,12 @@ static int eafnosupport_ipv6_fragment(struct net *net, struct sock *sk, struct s return -EAFNOSUPPORT; } +static struct net_device *eafnosupport_ipv6_dev_find(struct net *net, const struct in6_addr *addr, + struct net_device *dev) +{ + return ERR_PTR(-EAFNOSUPPORT); +} + const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) { .ipv6_dst_lookup_flow = eafnosupport_ipv6_dst_lookup_flow, .ipv6_route_input = eafnosupport_ipv6_route_input, @@ -209,6 +215,7 @@ const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) { .fib6_nh_init = eafnosupport_fib6_nh_init, .ip6_del_rt = eafnosupport_ip6_del_rt, .ipv6_fragment = eafnosupport_ipv6_fragment, + .ipv6_dev_find = eafnosupport_ipv6_dev_find, }; EXPORT_SYMBOL_GPL(ipv6_stub); diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 802f5111805a..f0b860aecc2f 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -1032,6 +1032,7 @@ static const struct ipv6_stub ipv6_stub_impl = { #endif .nd_tbl = &nd_tbl, .ipv6_fragment = ip6_fragment, + .ipv6_dev_find = ipv6_dev_find, }; static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = { From patchwork Wed Mar 24 18:18:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12161993 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 X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C04EC433E2 for ; Wed, 24 Mar 2021 18:19:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BC0F61A1B for ; Wed, 24 Mar 2021 18:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237521AbhCXSS4 (ORCPT ); Wed, 24 Mar 2021 14:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237485AbhCXSSY (ORCPT ); Wed, 24 Mar 2021 14:18:24 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE53C0613DE for ; Wed, 24 Mar 2021 11:18:24 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 91-20020a9d08640000b0290237d9c40382so2607568oty.12 for ; Wed, 24 Mar 2021 11:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rb4Aj52dwtBiCMiyyeXYam8IwXeqFhQXyisyxJGdRHg=; b=nFFNrxq5qFcyQvL+R0ibv30KGIl/gFG0qW6/Hs2ZkfoAICa+DBGJjQd4sN6TyH5Uvw idK7qejKUiBRNobodlPDVfxMtWWaeg3/l02d3WCKTrJSSdnCAXFbi+6ykfx9Lp+L0mOE 1zXgQIGw48V2kF0wYLzyPaamaN6wc7nM9Px0oCy6wrLKEMsS9i4v6dZ2dNfwZNHP5IAV ipxht7sPKgu2RsY9i1eS6SNU4jFXa/6O3ntbxPgsl1ypOapzqtdnx7b55PFsTciFkP4c Qbqo7nZKN2jv59Ma4zXwTAz+ymCVKEoiQgKnH3b7SrnG9R6E1S462zpMiR8v2t68B+oW LRPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rb4Aj52dwtBiCMiyyeXYam8IwXeqFhQXyisyxJGdRHg=; b=Y15PAbYlDQ9QGv5JEzK19Ym3ye3mKzY3JGHku5dO2P7UEQ8ZXCI5dhVO5bH6XjNI1n 98AHv/km0A5rHPfj5GBvbza/scPYFY7tdgspFjXI5jJFB7kPwDLlZA5Dl9/TuDXt47+A UKmFsWAzKn7caEPU9wj47M9wu715iC6En9rIPjwcHwjEY3q6vJDUA9NamIa/P1yl4dDA Bh5I3IXgN9I4prR7tCS19QS++M4d8S9YsM8iJEoMWbmhygkFSTfyUkxp3TDzyTAzC/4v gBNX7j3vAzozEX/5kUSG8uRFhnUKqw49X+T0ag9tcXtaKoi7rKSOd3s2JbwEgbxzMx01 jCQA== X-Gm-Message-State: AOAM531Lj9ab5z7SiFZIORPL2Nc42/JWVtbqwBBQ5WUb7qRUM+xzat1s ig/LJBo01HET/bgIzFXjrFOJEtK9dD8= X-Google-Smtp-Source: ABdhPJz3EfKXpV/6amhbpOoycJz5Fwk+A0bFMaVjPjlvkebHpTi5FD1u3k8MJKd/dkKUljOYYowQog== X-Received: by 2002:a9d:740c:: with SMTP id n12mr4186237otk.21.1616609903687; Wed, 24 Mar 2021 11:18:23 -0700 (PDT) Received: from clinic20-Precision-T3610.hsd1.ut.comcast.net ([2601:681:8800:baf9:abb9:79f4:f528:e200]) by smtp.googlemail.com with ESMTPSA id n10sm445062otj.36.2021.03.24.11.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 11:18:23 -0700 (PDT) From: Andreas Roeseler To: netdev@vger.kernel.org Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, Andreas Roeseler Subject: [PATCH net-next V5 6/6] icmp: add response to RFC 8335 PROBE messages Date: Wed, 24 Mar 2021 11:18:21 -0700 Message-Id: <77658f2ff9f9de796ae2386f60b2a372882befa6.1616608328.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Modify the icmp_rcv function to check PROBE messages and call icmp_echo if a PROBE request is detected. Modify the existing icmp_echo function to respond ot both ping and PROBE requests. This was tested using a custom modification to the iputils package and wireshark. It supports IPV4 probing by name, ifindex, and probing by both IPV4 and IPV6 addresses. It currently does not support responding to probes off the proxy node (see RFC 8335 Section 2). The modification to the iputils package is still in development and can be found here: https://github.com/Juniper-Clinic-2020/iputils.git. It supports full sending functionality of PROBE requests, but currently does not parse the response messages, which is why Wireshark is required to verify the sent and recieved PROBE messages. The modification adds the ``-e'' flag to the command which allows the user to specify the interface identifier to query the probed host. An example usage would be <./ping -4 -e 1 [destination]> to send a PROBE request of ifindex 1 to the destination node. Signed-off-by: Andreas Roeseler --- Changes: v1 -> v2: - Reorder variable declarations to follow coding style - Switch to functions such as dev_get_by_name and ip_dev_find to lookup net devices v2 -> v3: Suggested by Willem de Bruijn - Add verification of incoming messages before looking up netdev Reported-by: kernel test robot Reported-by: Dan Carpenter - Include net/addrconf.h library for ipv6_dev_find v3 -> v4: Suggested by Willem de Bruijn - Use skb_header_pointer to verify fields in incoming message - Add check to ensure that extobj_hdr.length is valid - Check to ensure object payload is padded with ASCII NULL characters when probing by name, as specified by RFC 8335 - Statically allocate buff using IFNAMSIZ - Add rcu blocking around ipv6_dev_find - Use __in_dev_get_rcu to access IPV4 addresses of identified net_device - Remove check for ICMPV6 PROBE types v4 -> v5: - Statically allocate buff to size IFNAMSIZ on declaration - Remove goto probe in favor of single branch - Remove strict check for incoming PROBE requests padding to nearest 32-bit boundary Reported-by: kernel test robot - Use rcu_dereference when accessing i6_ptr in net_device --- net/ipv4/icmp.c | 127 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 114 insertions(+), 13 deletions(-) diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 616e2dc1c8fa..2acf7d3a66cb 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -971,7 +971,7 @@ static bool icmp_redirect(struct sk_buff *skb) } /* - * Handle ICMP_ECHO ("ping") requests. + * Handle ICMP_ECHO ("ping") and ICMP_EXT_ECHO ("PROBE") requests. * * RFC 1122: 3.2.2.6 MUST have an echo server that answers ICMP echo * requests. @@ -979,27 +979,118 @@ static bool icmp_redirect(struct sk_buff *skb) * included in the reply. * RFC 1812: 4.3.3.6 SHOULD have a config option for silently ignoring * echo requests, MUST have default=NOT. + * RFC 8335: 8 MUST have a config option to enable/disable ICMP + * Extended Echo Functionality, MUST be disabled by default * See also WRT handling of options once they are done and working. */ static bool icmp_echo(struct sk_buff *skb) { + struct icmp_ext_hdr *ext_hdr, _ext_hdr; + struct icmp_ext_echo_iio *iio, _iio; + struct icmp_bxm icmp_param; + struct net_device *dev; + char buff[IFNAMSIZ]; struct net *net; + u16 ident_len; + u8 status; net = dev_net(skb_dst(skb)->dev); - if (!net->ipv4.sysctl_icmp_echo_ignore_all) { - struct icmp_bxm icmp_param; + /* should there be an ICMP stat for ignored echos? */ + if (net->ipv4.sysctl_icmp_echo_ignore_all) + return true; + + icmp_param.data.icmph = *icmp_hdr(skb); + icmp_param.skb = skb; + icmp_param.offset = 0; + icmp_param.data_len = skb->len; + icmp_param.head_len = sizeof(struct icmphdr); - icmp_param.data.icmph = *icmp_hdr(skb); + if (icmp_param.data.icmph.type == ICMP_ECHO) { icmp_param.data.icmph.type = ICMP_ECHOREPLY; - icmp_param.skb = skb; - icmp_param.offset = 0; - icmp_param.data_len = skb->len; - icmp_param.head_len = sizeof(struct icmphdr); - icmp_reply(&icmp_param, skb); + goto send_reply; } - /* should there be an ICMP stat for ignored echos? */ - return true; + if (!net->ipv4.sysctl_icmp_echo_enable_probe) + return true; + /* We currently only support probing interfaces on the proxy node + * Check to ensure L-bit is set + */ + if (!(ntohs(icmp_param.data.icmph.un.echo.sequence) & 1)) + return true; + /* Clear status bits in reply message */ + icmp_param.data.icmph.un.echo.sequence &= htons(0xFF00); + icmp_param.data.icmph.type = ICMP_EXT_ECHOREPLY; + ext_hdr = skb_header_pointer(skb, 0, sizeof(_ext_hdr), &_ext_hdr); + iio = skb_header_pointer(skb, sizeof(_ext_hdr), sizeof(_iio), &_iio); + if (!ext_hdr || !iio) + goto send_mal_query; + if (ntohs(iio->extobj_hdr.length) <= sizeof(iio->extobj_hdr)) + goto send_mal_query; + ident_len = ntohs(iio->extobj_hdr.length) - sizeof(iio->extobj_hdr); + status = 0; + dev = NULL; + switch (iio->extobj_hdr.class_type) { + case EXT_ECHO_CTYPE_NAME: + if (ident_len >= IFNAMSIZ) + goto send_mal_query; + memset(buff, 0, sizeof(buff)); + memcpy(buff, &iio->ident.name, ident_len); + dev = dev_get_by_name(net, buff); + break; + case EXT_ECHO_CTYPE_INDEX: + if (ident_len != sizeof(iio->ident.ifindex)) + goto send_mal_query; + dev = dev_get_by_index(net, ntohl(iio->ident.ifindex)); + break; + case EXT_ECHO_CTYPE_ADDR: + if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) + + iio->ident.addr.ctype3_hdr.addrlen) + goto send_mal_query; + switch (ntohs(iio->ident.addr.ctype3_hdr.afi)) { + case ICMP_AFI_IP: + if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) + + sizeof(struct in_addr)) + goto send_mal_query; + dev = ip_dev_find(net, iio->ident.addr.ip_addr.ipv4_addr.s_addr); + break; +#if IS_ENABLED(CONFIG_IPV6) + case ICMP_AFI_IP6: + if (ident_len != sizeof(iio->ident.addr.ctype3_hdr) + + sizeof(struct in6_addr)) + goto send_mal_query; + rcu_read_lock(); + dev = ipv6_stub->ipv6_dev_find(net, &iio->ident.addr.ip_addr.ipv6_addr, dev); + if (dev) + dev_hold(dev); + rcu_read_unlock(); + break; +#endif + default: + goto send_mal_query; + } + break; + default: + goto send_mal_query; + } + if (!dev) { + icmp_param.data.icmph.code = ICMP_EXT_NO_IF; + goto send_reply; + } + /* Fill bits in reply message */ + if (dev->flags & IFF_UP) + status |= EXT_ECHOREPLY_ACTIVE; + if (__in_dev_get_rcu(dev) && __in_dev_get_rcu(dev)->ifa_list) + status |= EXT_ECHOREPLY_IPV4; + if (!list_empty(&rcu_dereference(dev->ip6_ptr)->addr_list)) + status |= EXT_ECHOREPLY_IPV6; + dev_put(dev); + icmp_param.data.icmph.un.echo.sequence |= htons(status); +send_reply: + icmp_reply(&icmp_param, skb); + return true; +send_mal_query: + icmp_param.data.icmph.code = ICMP_EXT_MAL_QUERY; + goto send_reply; } /* @@ -1088,6 +1179,16 @@ int icmp_rcv(struct sk_buff *skb) icmph = icmp_hdr(skb); ICMPMSGIN_INC_STATS(net, icmph->type); + + /* Check for ICMP Extended Echo (PROBE) messages */ + if (icmph->type == ICMP_EXT_ECHO) { + /* We can't use icmp_pointers[].handler() because it is an array of + * size NR_ICMP_TYPES + 1 (19 elements) and PROBE has code 42. + */ + success = icmp_echo(skb); + goto success_check; + } + /* * 18 is the highest 'known' ICMP type. Anything else is a mystery * @@ -1097,7 +1198,6 @@ int icmp_rcv(struct sk_buff *skb) if (icmph->type > NR_ICMP_TYPES) goto error; - /* * Parse the ICMP message */ @@ -1123,7 +1223,7 @@ int icmp_rcv(struct sk_buff *skb) } success = icmp_pointers[icmph->type].handler(skb); - +success_check: if (success) { consume_skb(skb); return NET_RX_SUCCESS; @@ -1340,6 +1440,7 @@ static int __net_init icmp_sk_init(struct net *net) /* Control parameters for ECHO replies. */ net->ipv4.sysctl_icmp_echo_ignore_all = 0; + net->ipv4.sysctl_icmp_echo_enable_probe = 0; net->ipv4.sysctl_icmp_echo_ignore_broadcasts = 1; /* Control parameter - ignore bogus broadcast responses? */