Page MenuHomeFreeBSD

ping: pr_iph() improvements
ClosedPublic

Authored by jlduran_gmail.com on Apr 13 2023, 5:54 PM.
Tags
None
Referenced Files
F81902594: D39561.diff
Mon, Apr 22, 10:00 PM
Unknown Object (File)
Dec 20 2023, 6:17 AM
Unknown Object (File)
Dec 12 2023, 3:12 AM
Unknown Object (File)
Nov 6 2023, 5:40 PM
Unknown Object (File)
Oct 9 2023, 4:12 PM
Unknown Object (File)
Oct 9 2023, 4:12 PM
Unknown Object (File)
Jun 21 2023, 2:28 PM
Unknown Object (File)
Jun 16 2023, 3:52 AM

Details

Summary

Very early on, the Src/Dst IP addresses were printed in hex notation (%08x), which will always be 8-characters wide. It was later changed to use a dot-decimal notation. Depending on the IP address length, the Src and Dst headers may require a different padding. Use the source and destination IP lengths as padding for the headers.

Also, print an Opts (options) header, if there are options present. It has been abbreviated to Opts to match the length of the previous Data header, removed in ef9e6dc7eebe9830511602904d3ef5218d964080.

Print the header info such that no trailing spaces are produced. As some git workflows may automatically trim them, and make the tests fail (see 25b86f8559c2e7076daff56933217e95cd4398d4).

Before
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
 4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2␣
After
Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst
 4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2

And with options:

Before
Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
 4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2 01...
After
Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst Opts
 4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2 01...
Test Plan
kyua test -k /usr/tests/Kyuafile sbin/ping/ping_test
kyua test -k /usr/tests/Kyuafile sbin/ping/test_ping.py

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable