From 0aac6d71229a647e27a0967f7d66e97819f0a741 Mon Sep 17 00:00:00 2001 From: yinyongkang Date: Thu, 7 Jul 2022 17:26:52 +0800 Subject: [PATCH] ping: document '%'-notation for IPv6 link-local scope address, print warning, man: add destination --- ...tation-for-IPv6-link-local-scope-add.patch | 149 ++++++++++++++++++ iputils.spec | 9 +- 2 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 0001-ping-document-notation-for-IPv6-link-local-scope-add.patch diff --git a/0001-ping-document-notation-for-IPv6-link-local-scope-add.patch b/0001-ping-document-notation-for-IPv6-link-local-scope-add.patch new file mode 100644 index 0000000..45673dd --- /dev/null +++ b/0001-ping-document-notation-for-IPv6-link-local-scope-add.patch @@ -0,0 +1,149 @@ +From 018636e71838b0f4ef18cf5e98333a8d7bbd465a Mon Sep 17 00:00:00 2001 +From: yinyongkang +Date: Thu, 7 Jul 2022 17:20:31 +0800 +Subject: [PATCH] ping: document '%'-notation for IPv6 link-local scope + address, print warning, man: add destination + +man/ping: Use "ICMP datagram socket" +man/ping: Add "IPV6 LINK-LOCAL DESTINATIONS" section +ping: Print warning on missing '%'-notation +man/arping: Mention IPv4 only and ndisc6(8) +--- + doc/arping.xml | 9 +++++++++ + doc/ping.xml | 42 +++++++++++++++++++++++++++++++++++++++++- + ping/ping.c | 11 ++++++++++- + ping/ping6_common.c | 2 +- + 4 files changed, 61 insertions(+), 3 deletions(-) + +diff --git a/doc/arping.xml b/doc/arping.xml +index 9adbc0c..354e98e 100644 +--- a/doc/arping.xml ++++ b/doc/arping.xml +@@ -58,6 +58,11 @@ xml:id="man.arping"> + interface by ARP packets, using + source address + source. ++ arping supports IPv4 addresses only. For IPv6, see ++ ++ ndisc6 ++ 8 ++ . + + + +@@ -227,6 +232,10 @@ xml:id="man.arping"> + + SEE ALSO + ++ ++ ndisc6 ++ 8 ++ , + + ping + 8 +diff --git a/doc/ping.xml b/doc/ping.xml +index 61b8a5e..3171bad 100644 +--- a/doc/ping.xml ++++ b/doc/ping.xml +@@ -118,6 +118,46 @@ xml:id="man.ping"> + IPv6 source routing was deprecated (RFC5095). + + ++ ++ ++ IPV6 LINK-LOCAL DESTINATIONS ++ ++ For IPv6, when the destination address has link-local scope and ++ ping is using ICMP datagram sockets, ++ the output interface must be specified. ++ When ping is using raw sockets, it is not strictly ++ necessary to specify the output interface but it should be done to avoid ++ ambiguity when there are multiple possible output interfaces. ++ There are two ways to specify the output interface: ++ ++ ++ ++ • using the ++ % notation ++ ++ ++ The destination address is postfixed with ++ % ++ and the output interface name or ifindex, for example: ++ ping fe80::5054:ff:fe70:67bc%eth0 ++ ping fe80::5054:ff:fe70:67bc%2 ++ ++ ++ ++ ++ • using the ++ -I option ++ ++ ++ When using ICMP datagram sockets, ++ this method is only supported on some kernel versions: 5.17, ++ 5.15.19, 5.10.96, 5.4.176, 4.19.228, 4.14.265. ++ Also it is not supported on musl libc. ++ ++ ++ ++ ++ + + + OPTIONS +@@ -923,7 +963,7 @@ xml:id="man.ping"> + ping requires CAP_NET_RAW capability to be + executed 1) if the program is used for non-echo queries (See + option), or 2) if kernel does not support +- non-raw ICMP sockets, or 3) if the user is not allowed to ++ ICMP datagram sockets, or 3) if the user is not allowed to + create an ICMP echo socket. The program may be used as set-uid + root. + +diff --git a/ping/ping.c b/ping/ping.c +index 4f18875..43e6901 100644 +--- a/ping/ping.c ++++ b/ping/ping.c +@@ -44,7 +44,7 @@ + * Public Domain. Distribution Unlimited. + * Bugs - + * More statistics could always be gathered. +- * If kernel does not support non-raw ICMP sockets, ++ * If kernel does not support ICMP datagram sockets, + * this program has to run SUID to ROOT or with + * net_cap_raw enabled. + */ +@@ -556,6 +556,15 @@ main(int argc, char **argv) + int target_ai_family = hints.ai_family; + hints.ai_family = AF_UNSPEC; + ++ unsigned char buf[sizeof(struct in6_addr)]; ++ if (!strchr(target, '%') && sock6.socktype == SOCK_DGRAM && ++ inet_pton(AF_INET6, target, buf) > 0 && ++ (IN6_IS_ADDR_LINKLOCAL(buf) || IN6_IS_ADDR_MC_LINKLOCAL(buf))) { ++ error(0, 0, _( ++ "Warning: IPv6 link-local address on ICMP datagram socket may require ifname or scope-id" ++ " => use: address%%")); ++ } ++ + ret_val = getaddrinfo(target, NULL, &hints, &result); + if (ret_val) + error(2, 0, "%s: %s", target, gai_strerror(ret_val)); +diff --git a/ping/ping6_common.c b/ping/ping6_common.c +index 7a43ef6..5d7b6d5 100644 +--- a/ping/ping6_common.c ++++ b/ping/ping6_common.c +@@ -53,7 +53,7 @@ + * Public Domain. Distribution Unlimited. + * Bugs - + * More statistics could always be gathered. +- * If kernel does not support non-raw ICMP sockets or ++ * If kernel does not support ICMP datagram sockets or + * if -N option is used, this program has to run SUID to ROOT or + * with net_cap_raw enabled. + */ +-- +2.33.0 + diff --git a/iputils.spec b/iputils.spec index 78d0741..1a2ff25 100644 --- a/iputils.spec +++ b/iputils.spec @@ -1,6 +1,6 @@ Name: iputils Version: 20210722 -Release: 6 +Release: 7 Summary: Network monitoring tools including ping License: BSD and GPLv2+ URL: https://github.com/iputils/iputils @@ -23,6 +23,7 @@ Patch0007: arping-Fix-exit-code-on-w-option.patch Patch0008: backport-ping-Print-reply-from-Subnet-Router-anycast-address.patch Patch0009: backport-ping-Print-reply-with-wrong-source-with-warning.patch Patch0010: backport-ping-Fix-potential-memory-leakage.patch +Patch0011: 0001-ping-document-notation-for-IPv6-link-local-scope-add.patch BuildRequires: gcc meson libidn2-devel openssl-devel libcap-devel libxslt BuildRequires: docbook5-style-xsl systemd iproute glibc-kernheaders gettext @@ -121,6 +122,12 @@ install -cp ifenslave.8 ${RPM_BUILD_ROOT}%{_mandir}/man8/ %{_unitdir}/ninfod.service %changelog +* Thu Jul 7 2022 yinyongkang - 20210722-7 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:ping: document '%'-notation for IPv6 link-local scope address, print warning, man: add destination + * Mon Jun 20 2022 lvgenggeng - 20210722-6 - Type:bugfix - ID:NA -- Gitee