On Sat, Apr 07, 2018 at 12:29:37PM +0200, Peter J. Philipp wrote:
> I introduce the -r flag to fstat in order to display rdomains on sockets in
> order to find the right iked.  The fix is simple but because some peoples
> scripts may depend on the old output I made it an extra flag.

Is is a rdomain?  I think rtable is the correct name here.

If we print the rtable only when is not the default, we can avoid
an extra option, don't break many scripts, and make more obvious
if something is non standard.

root     nc         43785    3* rtable 7 internet dgram udp *:12345

bluhm

Index: usr.bin/fstat/fstat.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.bin/fstat/fstat.c,v
retrieving revision 1.92
diff -u -p -r1.92 fstat.c
--- usr.bin/fstat/fstat.c       6 Apr 2018 14:05:06 -0000       1.92
+++ usr.bin/fstat/fstat.c       7 Apr 2018 11:04:54 -0000
@@ -724,6 +724,10 @@ socktrans(struct kinfo_file *kf)
                stype = stypename[kf->so_type];
        }
 
+       printf("*");
+       if (kf->inp_rtableid)
+               printf(" rtable %u", kf->inp_rtableid);
+
        /*
         * protocol specific formatting
         *
@@ -737,18 +741,18 @@ socktrans(struct kinfo_file *kf)
         */
        switch (kf->so_family) {
        case AF_INET:
-               printf("* internet %s", stype);
+               printf(" internet %s", stype);
                getinetproto(kf->so_protocol);
                print_inet_details(kf);
                break;
        case AF_INET6:
-               printf("* internet6 %s", stype);
+               printf(" internet6 %s", stype);
                getinetproto(kf->so_protocol);
                print_inet6_details(kf);
                break;
        case AF_UNIX:
                /* print address of pcb and connected pcb */
-               printf("* unix %s", stype);
+               printf(" unix %s", stype);
                if (kf->so_pcb) {
                        printf(" ");
                        hide((void *)(uintptr_t)kf->so_pcb);
@@ -769,19 +773,19 @@ socktrans(struct kinfo_file *kf)
                break;
        case AF_MPLS:
                /* print protocol number and socket address */
-               printf("* mpls %s", stype);
+               printf(" mpls %s", stype);
                printf(" %d ", kf->so_protocol);
                hide((void *)(uintptr_t)kf->f_data);
                break;
        case AF_ROUTE:
                /* print protocol number and socket address */
-               printf("* route %s", stype);
+               printf(" route %s", stype);
                printf(" %d ", kf->so_protocol);
                hide((void *)(uintptr_t)kf->f_data);
                break;
        default:
                /* print protocol number and socket address */
-               printf("* %d %s", kf->so_family, stype);
+               printf(" %d %s", kf->so_family, stype);
                printf(" %d ", kf->so_protocol);
                hide((void *)(uintptr_t)kf->f_data);
        }

Reply via email to