From patchwork Wed Feb 3 23:24:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12065705 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 87C22C433DB for ; Wed, 3 Feb 2021 23:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32B9E64F55 for ; Wed, 3 Feb 2021 23:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233234AbhBCXZC (ORCPT ); Wed, 3 Feb 2021 18:25:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbhBCXZA (ORCPT ); Wed, 3 Feb 2021 18:25:00 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B64C0613D6 for ; Wed, 3 Feb 2021 15:24:20 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id u15so733758plf.1 for ; Wed, 03 Feb 2021 15:24:20 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=sJGIJ6AFFiqYqAD2YyawfECDbtzTFn0Yy5uqy/fB82Q=; b=LslCFBH+7QjchyirWchD1IORaXHay0OsIL1w7kHU8fdDmxCJLWHTjhQzgbI9ksuVPp DBs8NVbnQAPauJSLUwQ8J6uc7gMNTIaPdF+fHsWOdKG88sdnxS2VHcQZDlJBFM3K0SYA Nm7BmjCwuNarYq7lRQBcjskNNa9W0iXLmMY40r58a2WAENIswf1B2oNu4VPNvhO5jdPJ D5aTfAKkuF9yn3gE48cYBkoBkzIWq+FpHgIBLbMQYOd8WUUkyOj70GhFoZAQOk//jzZl KVj08HXMBW4EeNQrwoV7a3pJDfnVDhvjTPimjN57rP2x2ujWC5wuDJ8RJT8unew6n/Jx iogQ== 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:mime-version:content-transfer-encoding; bh=sJGIJ6AFFiqYqAD2YyawfECDbtzTFn0Yy5uqy/fB82Q=; b=OswZrqn6d4j1ZzaqvqWsIaIjQf/jlTfrZqvOsd4uNX1HSkdYYwGeio2yTVyuzAc4lr lKlukF4tePc/aBaM/+3rZiji5qETuMo5VVDUtxW8T9kfGs4k98haWR+2D8YUOSTloq28 D0HHXdI8HOLm+kLXBmUhZTYHTFHmfsEFDlmXH5bib0XsjeKF85IMtHEKhQmA/LRK9Ea4 PTP3qYod55QPByOhulkYt6+M1jn1c0Btpw3PlMP2OTvBn4DvodTRA3BNHfseV4joI+Hu Plar3WowCcK2pfYI9pV904+vW96/0kmGMgJ8CAhuyh0v7p/6bqD0+XFXeP0eaeKEDhj3 jQnw== X-Gm-Message-State: AOAM532Fq0VsWt42RHKB95BcULr0/BGKj8DvktwmAoev2o03GSQ2m/FX zkyCrYNZNZ0JPx9KB3F1Dqw= X-Google-Smtp-Source: ABdhPJzaVrRE4p3jSQDbYKdbH3KgHuUUYO7mleJMfl469w5SLN5aeCJ9M8g+WJc56mQQGe87r9l7jw== X-Received: by 2002:a17:90a:7e94:: with SMTP id j20mr5536988pjl.218.1612394659898; Wed, 03 Feb 2021 15:24:19 -0800 (PST) Received: from localhost.localdomain (h134-215-163-197.lapior.broadband.dynamic.tds.net. [134.215.163.197]) by smtp.gmail.com with ESMTPSA id n128sm4122182pga.55.2021.02.03.15.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 15:24:19 -0800 (PST) From: Andreas Roeseler To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH V2 net-next 1/5] icmp: add support for RFC 8335 PROBE Date: Wed, 3 Feb 2021 15:24:18 -0800 Message-Id: <2f3de06143c4191c53be4b96d98759afb5f09a5e.1612393368.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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. Signed-off-by: Andreas Roeseler --- Changes since v1: - Add AFI_IP and AFI_IP6 definitions --- include/uapi/linux/icmp.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h index fb169a50895e..e70bfcc06247 100644 --- a/include/uapi/linux/icmp.h +++ b/include/uapi/linux/icmp.h @@ -66,6 +66,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)/* position of active flag in reply */ +#define EXT_ECHOREPLY_IPV4 (1 << 1)/* position of ipv4 flag in reply */ +#define EXT_ECHOREPLY_IPV6 1 /* position of ipv6 flag in reply */ +#define CTYPE_NAME 1 +#define CTYPE_INDEX 2 +#define CTYPE_ADDR 3 +#define AFI_IP 1 /* Address Family Identifier for IPV4 */ +#define AFI_IP6 2 /* Address Family Identifier for IPV6 */ struct icmphdr { __u8 type; @@ -118,4 +135,11 @@ struct icmp_extobj_hdr { __u8 class_type; }; +/* RFC 8335: 2.1 Header for C-type 3 payload */ +struct icmp_ext_ctype3_hdr { + __u16 afi; + __u8 addrlen; + __u8 reserved; +}; + #endif /* _UAPI_LINUX_ICMP_H */ From patchwork Wed Feb 3 23:24:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12065707 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 89843C433DB for ; Wed, 3 Feb 2021 23:25:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CAA264E06 for ; Wed, 3 Feb 2021 23:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233465AbhBCXZW (ORCPT ); Wed, 3 Feb 2021 18:25:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233440AbhBCXZR (ORCPT ); Wed, 3 Feb 2021 18:25:17 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 208B5C0613ED for ; Wed, 3 Feb 2021 15:24:37 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id y142so864881pfb.3 for ; Wed, 03 Feb 2021 15:24:37 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=6OppbIT1M1gvXOWsdS8QHmLhNPa/v+vgtcvDuscwBAU=; b=MgIpxys16D2vZPui2hhxB+aIYYG86L+CQuBg5f0LIRkcsNCHlO+DoUyHvab0DCUUi3 0FhiDJri1OfeqyWau6C6J/NPTWgjQwjuG+L2N/T5ThR4WjTUNSvRTcA3HJ+IDH7ZTsJb QOCq8RzlOvIvQ3rf1IB+5o36aA9ZbpqhJC+bPkF4gZ0pYXZnk7oHTJUNp8wRAWH/kYvc utulpOPU+SczBpGxZTmHOGWMUp6KqWKml/VmkK+bcL32qT/XEBJYT0MBgUuHctq88H52 ea9d6W4A1UoaRlvAVyghVzUjg5n79TWBz9BUn800SQgeAZaI8E5l8VKBUfYukq4qKhr7 QItQ== 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:mime-version:content-transfer-encoding; bh=6OppbIT1M1gvXOWsdS8QHmLhNPa/v+vgtcvDuscwBAU=; b=d2wGXANHEwWQQ3yDKI7EBYg6RBYF1XxFoBNeiNFe5KflChem4Te3bkglTJz6e7Ix3h ZRNcEFUmDv06d3CgZ46/acEA7Jnr0w8wyz9WIPYURlfV6U5e2o+Uy049Aegn9j+V2X5c yCStDtkYu1D6ZTVGRpM2+Ukyv5vEkFq9zQbGv6O55GTlr/PpDGRHBbQOzMaHNXk9In8G dSiWSZMFoUBmwcebNK5jbdP+WemLxaH0tL65g/IRZWNjx61+iyRG81HyhkoIBZTgoq90 vDMzvrT0R0YnQ051RezZSJ8BYWPlxoe7shwqwVdzw6hzG+n7ldAp/W7YQetIiIBn4nRE M0Aw== X-Gm-Message-State: AOAM530tR14WHvvOG95Txu6+/yOuO6BL6rCOh6Cb42PZ8er43sGkrnR/ 3gOLuIweR9E2SuFJs2vch9g= X-Google-Smtp-Source: ABdhPJwp9iG+8PEPYSZfvM7MBOIDbAcvABg8yz6Qd8zON0xtzf6hGe3fJQC/BVuQbY8YBkgi9jfSSQ== X-Received: by 2002:aa7:8b0f:0:b029:1c0:e782:ba29 with SMTP id f15-20020aa78b0f0000b02901c0e782ba29mr5189137pfd.37.1612394676770; Wed, 03 Feb 2021 15:24:36 -0800 (PST) Received: from localhost.localdomain (h134-215-163-197.lapior.broadband.dynamic.tds.net. [134.215.163.197]) by smtp.gmail.com with ESMTPSA id j123sm3562726pfg.36.2021.02.03.15.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 15:24:36 -0800 (PST) From: Andreas Roeseler To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH V2 net-next 2/5] ICMPV6: add support for RFC 8335 PROBE Date: Wed, 3 Feb 2021 15:24:35 -0800 Message-Id: <4ba5f0996433e2f509db6360bbf9c86e1a25beff.1612393368.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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 in sections 2 and 3 of RFC 8335. Signed-off-by: Andreas Roeseler --- include/uapi/linux/icmpv6.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/icmpv6.h b/include/uapi/linux/icmpv6.h index 0564fd7ccde4..b2a9017ddb2d 100644 --- a/include/uapi/linux/icmpv6.h +++ b/include/uapi/linux/icmpv6.h @@ -140,6 +140,12 @@ 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 Feb 3 23:24:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12065709 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 22741C433E9 for ; Wed, 3 Feb 2021 23:25:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE22D64E06 for ; Wed, 3 Feb 2021 23:25:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233506AbhBCXZ1 (ORCPT ); Wed, 3 Feb 2021 18:25:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbhBCXZY (ORCPT ); Wed, 3 Feb 2021 18:25:24 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4E83C061786 for ; Wed, 3 Feb 2021 15:24:43 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id nm1so596598pjb.3 for ; Wed, 03 Feb 2021 15:24:43 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=vzspAmAcRNQhzg+74nh8k/ZFIHJ7BPO1bSEKZDqWSjE=; b=NW3HcaA3JcBMgPcIclSZxdbmtGVRCtEWA9ymzHdhrtpiycarvIaEzlYjH0u5WX6pbZ gg2urH3JL6IrbywWz1TDJhbJG5aNr9cYEvFqIrnXZZeniUfKa7rRPqZfMmC4XtndvQAJ e8QfF/MiUo4C7VeJW+6jO+C9kBgzYfi6lJKPT4MCAUle+RNpcgqQZdfpsjM0EA8RsPbo jCRfFQwWM+hHNJwLihnKb197Gc5toqoHklMu3QEkovuHgH9CKYlZCNUvppxs5z9bKmvF OWxzMzatJTpBiIlVMTVwjLbbIu9oVwrgMtXCr5a6AP5bSMUbEZexLTFe0CVanHCYpZDl ZvkQ== 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:mime-version:content-transfer-encoding; bh=vzspAmAcRNQhzg+74nh8k/ZFIHJ7BPO1bSEKZDqWSjE=; b=AZJJAhSI5XtEmyUkZviDheltdL/7kA0v3u6oJrZvsgIfY7ZQ53LRsM1QS74CsFEaap e+86KERLsIeGrzcqdrF7WURNgF56Ndps+sOhxGpSFGvS984eVbOk6bZS71gmscYKl/rq J+TRX8gwgVIzvSLtORGT5ohQ9p++Tq/q7tKcYnFTSDPFKu1j6992N4j2cuNTHmDf0Zw7 9C9GXJzPhz6D42QM181R30mGQ4OGcP+nQcYKDi9M7cZa4WsejQ70RKZt8bM/9eXUmHBn C+sVEFyy6pTYD0jd3efvWQc+cSIJuyq65WktAuuzD9ACxLVfGvDp9kY3e765kHoyhqeu iPmA== X-Gm-Message-State: AOAM532N72NJ0b6eibnwYc+2UqRYcGU4GzUnPbMJyMNb84WWJQFNRnqB Vk/e46krOin4yGkSXcZkf8E= X-Google-Smtp-Source: ABdhPJxWGJTH9IKoL+QUVb9loryP9p5JtNHGFJ1SjAC4bcypgRMkbQxHHkWYX5PXbK/3r20fUNf+6g== X-Received: by 2002:a17:902:bd85:b029:e1:bbf:3603 with SMTP id q5-20020a170902bd85b02900e10bbf3603mr5224794pls.29.1612394683306; Wed, 03 Feb 2021 15:24:43 -0800 (PST) Received: from localhost.localdomain (h134-215-163-197.lapior.broadband.dynamic.tds.net. [134.215.163.197]) by smtp.gmail.com with ESMTPSA id i28sm3368870pfk.51.2021.02.03.15.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 15:24:42 -0800 (PST) From: Andreas Roeseler To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH V2 net-next 3/5] net: add sysctl for enabling RFC 8335 PROBE messages Date: Wed, 3 Feb 2021 15:24:41 -0800 Message-Id: <9d167c46fbfb38ab8559695524b5a84449855e1b.1612393368.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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 it is disabled by default. Add sysctl to enable responses to PROBE messages. Signed-off-by: Andreas Roeseler --- Changes since v1: - Combine patches related to sysctl into one patch --- include/net/netns/ipv4.h | 1 + net/ipv4/sysctl_net_ipv4.c | 7 +++++++ 2 files changed, 8 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 e5798b3b59d2..06b7241bc01d 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -599,6 +599,13 @@ 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 + }, { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, From patchwork Wed Feb 3 23:24:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12065711 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 4E27DC433DB for ; Wed, 3 Feb 2021 23:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A28364F43 for ; Wed, 3 Feb 2021 23:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233533AbhBCXZn (ORCPT ); Wed, 3 Feb 2021 18:25:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233089AbhBCXZa (ORCPT ); Wed, 3 Feb 2021 18:25:30 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68DC2C061788 for ; Wed, 3 Feb 2021 15:24:50 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id q131so843575pfq.10 for ; Wed, 03 Feb 2021 15:24:50 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=cCET9WBqWjygW6XCStVpWhmRU/4x/+TmAJlTpAVop6s=; b=SQ/NnBUFo4RBP+SZcYF6aJNvHN4+toqVo2pVayjfIhUfIqCO4/ub8KMpccTkFDAPjy qU7fpUkWRTpLrybjMc9/j2Rh1R2UPlnjFLZjGkXZPvfba4iFSVGFoWyqXjxLtb67VJco nn+6riadAfrhOM4NUPeEmvM/hDq5xwSbPbfGxsHXCwFgO74xOTnB+hkYl3lB4t5si4j9 KSrDjBdP/ru/bK7s1eiToN9WyjQLrlyANF5RMPJhy4a0MPfTMrG+g1Q3ULoTFxEa2COd 05ulfWynInJnp9JXAz/LK8qEJHNBqcirvuiC6LQPZPBJXblHl2YqYuHQxJdUpmi9JwNA revQ== 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:mime-version:content-transfer-encoding; bh=cCET9WBqWjygW6XCStVpWhmRU/4x/+TmAJlTpAVop6s=; b=KhHY4/nJvo/LOUYu7OksXleiQ6xOX7GJqW1T+v1acGWPUqvz1mUsO6MCz5J/IRyeg7 5PBGeUuKjAN13uiiuaLsRZRG/hg6L+94s/7E00Zl/gkmSlb0yRRDADUKqqsXzSrkn+Da qzNO3f4JpJuWWgr7e6Yf/EPxhJRHeR2Aa3F+0jp9NWs0ABGrcwoEegYc8bKk8h44L+4U L0mSKJNKnDYC2tuxbh8mx12YLl/QTcYAd5ccp7n6zIhn3Z8+i6bF/8wM1paz0tvtbsqr /f/rNYmCABdiPY/bgqYyyCzT2HtFCnoOvjdIPpgbPhor01Miv66PtT/waCNtgVqmLy0/ 40BQ== X-Gm-Message-State: AOAM532WTRetv2qpfvwEbGMv1hzYkNxXiMTn8iB5F2fgUBP5CrIW4ALw RZrcVjfJo3xpd0+eL/W70A0= X-Google-Smtp-Source: ABdhPJwkiwkIOyyrApbxYqByTNxmGCHnjOzNDccG44yimVVXxZzA8F+SDed9wXSVCL4qqzXnvyYd8Q== X-Received: by 2002:a63:4443:: with SMTP id t3mr5992878pgk.297.1612394690067; Wed, 03 Feb 2021 15:24:50 -0800 (PST) Received: from localhost.localdomain (h134-215-163-197.lapior.broadband.dynamic.tds.net. [134.215.163.197]) by smtp.gmail.com with ESMTPSA id a6sm2245179pfr.43.2021.02.03.15.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 15:24:49 -0800 (PST) From: Andreas Roeseler To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH V2 net-next 4/5] net: add support for sending RFC 8335 PROBE messages Date: Wed, 3 Feb 2021 15:24:48 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 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 Feb 3 23:24:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Roeseler X-Patchwork-Id: 12065713 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 7C018C433E0 for ; Wed, 3 Feb 2021 23:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3340164F55 for ; Wed, 3 Feb 2021 23:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233514AbhBCXZs (ORCPT ); Wed, 3 Feb 2021 18:25:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbhBCXZh (ORCPT ); Wed, 3 Feb 2021 18:25:37 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01081C061573 for ; Wed, 3 Feb 2021 15:24:57 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id gx20so642992pjb.1 for ; Wed, 03 Feb 2021 15:24:56 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=HqSAslGnKq8CudbvP13enE08AyxXeCOAntNd5UTOUgs=; b=k4d8WLar74wFvSRVCyzfTMRxri/RDbFMAn0adzFlW3RsUyPv2hd6Hi+vOPo+gCPTvh IMYIoUBR1M3xhxybF10AQs4RvXVX5q4wnu94ySkXxbcJknTi2DRx9oTDThDX4QWhY6m8 6UNPrqcvKo3M0EAZviqsb5A9Gy03MtFy/B2aS0/gQLGMVKOVInUrtESo5TMRsy7XI8PO Y4DZSh1ZU1R2AtX1O/ibdD9YxwhHAezUVx7mJurOPMg7hMGmpmkbfwp6Gb+NZ10w+AhM kBmE+i8leMUOplObmnNf7uT/l+kHtY6pmOd5JN7bBr195NY4xyj2Xq6YEer1Whv3NuAM IVCQ== 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:mime-version:content-transfer-encoding; bh=HqSAslGnKq8CudbvP13enE08AyxXeCOAntNd5UTOUgs=; b=MUn84Oh2t910Q8LAi5D/rgQu7UkvZ0CVE5y9R7GAAviAfmcwMDMpmLMx0MBL/saihB 4f07UgEh67Xq2j4gfCXrFcUavOA/GLkFQ/UTnAQa4AU6UkkH3QsDXVM+iECfOovb1PYt 2O3TJ1KjcKPR+40YHPuUZUpAzT9cwk4YW9Px52WyMou/dOQToZWMsXX8QAf+ZaTM5eHD bnfa1CB8NQpsL0EHOX9pnLBWl/r4cYczz1VQifzJHMMeEQfud1/0pMwQN+uu3Q2RG5mS qfVzarA7eSO7wvwsn6u4Wj2sMo1o62F8Nof/KqrdLmf/MIdXX66le4dsByzmOrXrM9wi UfFA== X-Gm-Message-State: AOAM533Wt4Ao+QeCjBh/AUg+gZClDd5a9m5e8DemuU5EtrwuJOvHbY6l ENmMRBozcLiyDre/dtkFxcQ= X-Google-Smtp-Source: ABdhPJzmFOmnB+Y2jkgpUcFL7PP/QlGrjld6gbptU7dYL0V2BGJjI+kCyE6WgsDdt1vJhl7ThZ1flQ== X-Received: by 2002:a17:90b:17c7:: with SMTP id me7mr5352906pjb.205.1612394696613; Wed, 03 Feb 2021 15:24:56 -0800 (PST) Received: from localhost.localdomain (h134-215-163-197.lapior.broadband.dynamic.tds.net. [134.215.163.197]) by smtp.gmail.com with ESMTPSA id j9sm2883268pjn.32.2021.02.03.15.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 15:24:56 -0800 (PST) From: Andreas Roeseler To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org Subject: [PATCH V2 net-next 5/5] icmp: add response to RFC 8335 PROBE messages Date: Wed, 3 Feb 2021 15:24:55 -0800 Message-Id: <7af3da33a7aa540f7878cfcbf5076dcf61d201ef.1612393368.git.andreas.a.roeseler@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Modify the icmp_rcv function to check for PROBE messages and call icmp_echo if a PROBE request is detected. Modify the existing icmp_echo function to respond to both ping and PROBE requests. This was tested using a custom modification of 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). Signed-off-by: Andreas Roeseler --- Changes since v1: - Reorder variable declarations to follow coding style - Switch to functions such as dev_get_by_name and ip_dev_find to lookup net devices --- net/ipv4/icmp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 88 insertions(+), 10 deletions(-) diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 396b492c804f..18f9a2a3bf59 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -983,21 +983,85 @@ static bool icmp_redirect(struct sk_buff *skb) static bool icmp_echo(struct sk_buff *skb) { + struct icmp_bxm icmp_param; struct net *net; + struct net_device *dev; + struct icmp_extobj_hdr *extobj_hdr; + struct icmp_ext_ctype3_hdr *ctype3_hdr; + __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? */ + if (!net->ipv4.sysctl_icmp_echo_enable_probe) + return true; + /* We currently do not support probing off the proxy node */ + if (!(ntohs(icmp_param.data.icmph.un.echo.sequence) & 1)) + return true; + + icmp_param.data.icmph.type = ICMP_EXT_ECHOREPLY; + icmp_param.data.icmph.un.echo.sequence &= htons(0xFF00); + extobj_hdr = (struct icmp_extobj_hdr *)(skb->data + sizeof(struct icmp_ext_hdr)); + ctype3_hdr = (struct icmp_ext_ctype3_hdr *)(extobj_hdr + 1); + status = 0; + switch (extobj_hdr->class_type) { + case CTYPE_NAME: + dev = dev_get_by_name(net, (char *)(extobj_hdr + 1)); + break; + case CTYPE_INDEX: + dev = dev_get_by_index(net, ntohl(*((uint32_t *)(extobj_hdr + 1)))); + break; + case CTYPE_ADDR: + switch (ntohs(ctype3_hdr->afi)) { + case AFI_IP: + dev = ip_dev_find(net, *(__be32 *)(ctype3_hdr + 1)); + break; + case AFI_IP6: + dev = ipv6_dev_find(net, (struct in6_addr *)(ctype3_hdr + 1), dev); + if(dev) dev_hold(dev); + break; + default: + icmp_param.data.icmph.code = ICMP_EXT_MAL_QUERY; + goto send_reply; + } + break; + default: + icmp_param.data.icmph.code = ICMP_EXT_MAL_QUERY; + goto send_reply; + } + if(!dev) { + icmp_param.data.icmph.code = ICMP_EXT_NO_IF; + goto send_reply; + } + /* RFC 8335: 3 the last 8 bits of the Extended Echo Reply Message + * are laid out as follows: + * +-+-+-+-+-+-+-+-+ + * |State|Res|A|4|6| + * +-+-+-+-+-+-+-+-+ + */ + if (dev->flags & IFF_UP) + status |= EXT_ECHOREPLY_ACTIVE; + if (dev->ip_ptr->ifa_list) + status |= EXT_ECHOREPLY_IPV4; + if (!list_empty(&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; } @@ -1087,6 +1151,13 @@ 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 || icmph->type == ICMPV6_EXT_ECHO_REQUEST) + goto probe; + /* * 18 is the highest 'known' ICMP type. Anything else is a mystery * @@ -1096,7 +1167,6 @@ int icmp_rcv(struct sk_buff *skb) if (icmph->type > NR_ICMP_TYPES) goto error; - /* * Parse the ICMP message */ @@ -1123,6 +1193,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; @@ -1136,6 +1207,13 @@ int icmp_rcv(struct sk_buff *skb) error: __ICMP_INC_STATS(net, ICMP_MIB_INERRORS); goto drop; +probe: + /* + * We can't use icmp_pointers[].handler() because the codes for PROBE + * messages are 42 or 160 + */ + success = icmp_echo(skb); + goto success_check; } static bool ip_icmp_error_rfc4884_validate(const struct sk_buff *skb, int off)