diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-12-26 15:02:06 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-12-26 15:05:10 +0000 |
commit | 731bfa9f180388e4081b64afb94c357643600238 (patch) | |
tree | 37678c46eacf0578d1f9b74553769c7112426cad /usr.bin | |
parent | c2c8e360d8c0b8712158d334686d88f052aef819 (diff) | |
download | src-731bfa9f180388e4081b64afb94c357643600238.tar.gz src-731bfa9f180388e4081b64afb94c357643600238.zip |
netstat: fix nhop prepend printing.
If present, print nexthop L2 prepend data in hex.
MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/netstat/nhops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/netstat/nhops.c b/usr.bin/netstat/nhops.c index 51bed6e23c0f..8fc8db9e7b85 100644 --- a/usr.bin/netstat/nhops.c +++ b/usr.bin/netstat/nhops.c @@ -312,8 +312,10 @@ print_nhop_entry_sysctl(const char *name, struct rt_msghdr *rtm, struct nhop_ext xo_emit("{t:refcount/%*lu} ", wid_refcnt, nh->nh_refcount); if (Wflag && nh->prepend_len) { - char *prepend_hex = "AABBCCDDEE"; - xo_emit(" {:nhop-prepend/%*s}", wid_prepend, prepend_hex); + int max_bytes = MIN(nh->prepend_len, sizeof(buffer) / 2 - 1); + for (int i = 0; i < max_bytes; i++) + snprintf(&buffer[i * 2], 3, "%02X", nh->nh_prepend[i]); + xo_emit(" {:nhop-prepend/%*s}", wid_prepend, buffer); } xo_emit("\n"); |