From 2150c9bad20b6c122f8e3168485a2dcadedd27e8 Mon Sep 17 00:00:00 2001 From: kn Date: Wed, 9 Nov 2022 18:00:02 +0000 Subject: [PATCH] ndp, route, netstat: adjust ipv6 address width It has been annoying me for too long that fully specififed GUAs (2001:0db8:3333:4444:5555:6666:7777:8888) mess up alignment. systat(1)'s netstat is the only view that has a big enough limit and thus never misaligns. Unify ndp(8), route(8) and netstat(1) views to always align nicely. Feedback OK claudio --- sbin/route/show.c | 9 +++++---- usr.bin/netstat/show.c | 9 +++++---- usr.sbin/ndp/ndp.c | 7 +++++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sbin/route/show.c b/sbin/route/show.c index aac7844c7be..1b1a695a7c2 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.120 2022/06/19 13:59:22 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.121 2022/11/09 18:00:02 kn Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -220,9 +220,9 @@ p_rttables(int af, u_int tableid, char prio) /* * column widths; each followed by one space * width of destination/gateway column - * strlen("fe80::aaaa:bbbb:cccc:dddd@gif0") == 30, strlen("/128") == 4 + * strlen("2001:0db8:3333:4444:5555:6666:7777:8888") == 39 */ -#define WID_GW(af) ((af) == AF_INET6 ? 30 : 18) +#define WID_GW(af) ((af) == AF_INET6 ? 39 : 18) int WID_DST(int af) @@ -232,7 +232,8 @@ WID_DST(int af) case AF_MPLS: return 9; case AF_INET6: - return 34; + /* WID_GW() + strlen("/128") == 4 */ + return 43; default: return 18; } diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index a9745569eac..d7a1dd3e623 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.59 2022/06/19 13:59:22 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.60 2022/11/09 18:00:02 kn Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -166,9 +166,9 @@ p_rttables(int af, u_int tableid) /* * column widths; each followed by one space * width of destination/gateway column - * strlen("fe80::aaaa:bbbb:cccc:dddd@gif0") == 30, strlen("/128") == 4 + * strlen("2001:0db8:3333:4444:5555:6666:7777:8888") == 39 */ -#define WID_GW(af) ((af) == AF_INET6 ? 30 : 18) +#define WID_GW(af) ((af) == AF_INET6 ? 39 : 18) int WID_DST(int af) @@ -178,7 +178,8 @@ WID_DST(int af) case AF_MPLS: return 9; case AF_INET6: - return 34; + /* WID_GW() + strlen("/128") == 4 */ + return 43; default: return 18; } diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 802fff19914..8b3cfeeb300 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndp.c,v 1.103 2021/03/02 05:34:20 jsg Exp $ */ +/* $OpenBSD: ndp.c,v 1.104 2022/11/09 18:00:02 kn Exp $ */ /* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */ /* @@ -457,7 +457,10 @@ delete: return 0; } -#define W_ADDR 36 +/* + * strlen("2001:0db8:3333:4444:5555:6666:7777:8888") == 39 + */ +#define W_ADDR 39 #define W_LL 17 #define W_IF 7 -- 2.20.1