git: 9185854d1965 - main - ping: Fix the display of Flags/Fragment Offset
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Mar 2023 15:58:18 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=9185854d19658289d0da93bb3af8e49cba184b7e
commit 9185854d19658289d0da93bb3af8e49cba184b7e
Author: Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2023-03-14 15:09:27 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-03-14 15:58:02 +0000
ping: Fix the display of Flags/Fragment Offset
In the IP header, Flags + Fragment Offset is a 16-bit field.
Use ntohs() instead of ntohl(), otherwise the Flags/Fragment Offset
values may not display correctly.
Before (DF set)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 0001 0 0000 40 01 b6a4 192.0.2.1 192.0.2.2
After (DF set)
Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
4 5 00 0054 0001 2 0000 40 01 b6a4 192.0.2.1 192.0.2.2
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38479
---
sbin/ping/ping.c | 6 +++---
sbin/ping/tests/test_ping.py | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 2fc876e50776..00026c33a479 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1680,9 +1680,9 @@ pr_iph(struct ip *ip)
(void)printf(" %1x %1x %02x %04x %04x",
ip->ip_v, ip->ip_hl, ip->ip_tos, ntohs(ip->ip_len),
ntohs(ip->ip_id));
- (void)printf(" %1lx %04lx",
- (u_long) (ntohl(ip->ip_off) & 0xe000) >> 13,
- (u_long) ntohl(ip->ip_off) & 0x1fff);
+ (void)printf(" %1x %04x",
+ (ntohs(ip->ip_off) & 0xe000) >> 13,
+ ntohs(ip->ip_off) & 0x1fff);
(void)printf(" %02x %02x %04x", ip->ip_ttl, ip->ip_p,
ntohs(ip->ip_sum));
memcpy(&ina, &ip->ip_src.s_addr, sizeof ina);
diff --git a/sbin/ping/tests/test_ping.py b/sbin/ping/tests/test_ping.py
index 186790853314..a9b760ff7aca 100644
--- a/sbin/ping/tests/test_ping.py
+++ b/sbin/ping/tests/test_ping.py
@@ -919,7 +919,6 @@ Vr HL TOS Len ID Flg off TTL Pro cks Src Dst
"stderr": "",
"redacted": False,
},
- marks=pytest.mark.skip("XXX currently failing"),
id="_3_1_flags_DF",
),
]