It sure would be nice if we could see the PID of the process that added
routes.  Heck, route(8) even tries to print them already.

Add the fields to the appropriate struct, and while here, document which
fields are in sync.

(requested by krw@)

OK?


Index: net/if.h
===================================================================
RCS file: /cvs/openbsd/src/sys/net/if.h,v
retrieving revision 1.177
diff -u -p -u -p -r1.177 if.h
--- net/if.h    10 Jun 2016 20:33:29 -0000      1.177
+++ net/if.h    19 Jul 2016 13:41:53 -0000
@@ -267,6 +267,7 @@ struct if_msghdr {
        int     ifm_addrs;      /* like rtm_addrs */
        int     ifm_flags;      /* value of if_flags */
        int     ifm_xflags;
+       pid_t   ifam_pid;       /* identify sender */
        struct  if_data ifm_data;/* statistics and other data about if */
 };
 
@@ -286,6 +287,7 @@ struct ifa_msghdr {
        int     ifam_addrs;     /* like rtm_addrs */
        int     ifam_flags;     /* value of ifa_flags */
        int     ifam_metric;    /* value of ifa_metric */
+       pid_t   ifam_pid;       /* identify sender */
 };
 
 /*
Index: net/route.h
===================================================================
RCS file: /cvs/openbsd/src/sys/net/route.h,v
retrieving revision 1.141
diff -u -p -u -p -r1.141 route.h
--- net/route.h 13 Jul 2016 08:40:46 -0000      1.141
+++ net/route.h 19 Jul 2016 13:42:38 -0000
@@ -201,6 +201,7 @@ struct rt_msghdr {
        int     rtm_flags;      /* flags, incl. kern & message, e.g. DONE */
        int     rtm_fmask;      /* bitmask used in RTM_CHANGE message */
        pid_t   rtm_pid;        /* identify sender */
+/* above matches if_msghdr and ifa_msghdr */
        int     rtm_seq;        /* for sender to identify action */
        int     rtm_errno;      /* why failed */
        u_int   rtm_inits;      /* which metrics we are initializing */
Index: net/rtsock.c
===================================================================
RCS file: /cvs/openbsd/src/sys/net/rtsock.c,v
retrieving revision 1.194
diff -u -p -u -p -r1.194 rtsock.c
--- net/rtsock.c        11 Jul 2016 13:06:31 -0000      1.194
+++ net/rtsock.c        19 Jul 2016 13:43:20 -0000
@@ -1043,6 +1043,7 @@ rt_msg1(int type, struct rt_addrinfo *rt
        rtm->rtm_hdrlen = hlen;
        rtm->rtm_version = RTM_VERSION;
        rtm->rtm_type = type;
+       rtm->rtm_pid = curproc->p_p->ps_pid;
        return (m);
 }
 
@@ -1115,6 +1116,7 @@ again:
                rtm->rtm_type = type;
                rtm->rtm_msglen = len;
                rtm->rtm_hdrlen = hlen;
+               rtm->rtm_pid = curproc->p_p->ps_pid;
        }
        return (len);
 }


-- 
Vote for ME -- I'm well-tapered, half-cocked, ill-conceived and
TAX-DEFERRED!

Reply via email to