]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We can only check rtm_pid for the correct pid - other messages
authorRoy Marples <roy@marples.name>
Mon, 25 Apr 2016 13:03:52 +0000 (13:03 +0000)
committerRoy Marples <roy@marples.name>
Mon, 25 Apr 2016 13:03:52 +0000 (13:03 +0000)
do not have this sadly.

if-bsd.c

index 7ce4001c9007f57622ba7f9f1b0eb7daaaefc6f9..4283e36cf1599b8dce1b0f38ee279a4496a588a9 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -1246,26 +1246,6 @@ if_managelink(struct dhcpcd_ctx *ctx)
        e = msg + bytes;
        for (p = msg; p < e; p += rtm->rtm_msglen) {
                rtm = (void *)p;
-               if (rtm->rtm_type == RTM_MISS)
-                       continue;
-               /* Ignore messages generated by us */
-               if (rtm->rtm_pid == getpid()) {
-                       ctx->options &= ~DHCPCD_RTM_PPID;
-                       continue;
-               }
-               /* Ignore messages sent by the parent process after forking */
-               if ((ctx->options & (DHCPCD_RTM_PPID | DHCPCD_DAEMONISED)) ==
-                   (DHCPCD_RTM_PPID | DHCPCD_DAEMONISED) &&
-                   rtm->rtm_pid == ctx->ppid)
-               {
-                       /* If this is the last successful message sent clear
-                        * the check flag as it's possible another process could
-                        * re-use the same pid and also manipulate the kernel
-                        * routing table. */
-                       if (rtm->rtm_seq == ctx->pseq)
-                               ctx->options &= ~DHCPCD_RTM_PPID;
-                       continue;
-               }
                switch(rtm->rtm_type) {
 #ifdef RTM_IFANNOUNCE
                case RTM_IFANNOUNCE:
@@ -1311,6 +1291,25 @@ if_managelink(struct dhcpcd_ctx *ctx)
                case RTM_ADD:
                case RTM_CHANGE:
                case RTM_DELETE:
+                       /* Ignore messages generated by us */
+                       if (rtm->rtm_pid == getpid()) {
+                               ctx->options &= ~DHCPCD_RTM_PPID;
+                               continue;
+                       }
+                       /* Ignore messages sent by the parent after forking */
+                       if ((ctx->options &
+                           (DHCPCD_RTM_PPID | DHCPCD_DAEMONISED)) ==
+                           (DHCPCD_RTM_PPID | DHCPCD_DAEMONISED) &&
+                           rtm->rtm_pid == ctx->ppid)
+                       {
+                               /* If this is the last successful message sent,
+                                * clear the check flag as it's possible another
+                                * process could re-use the same pid and also
+                                * manipulate therouting table. */
+                               if (rtm->rtm_seq == ctx->pseq)
+                                       ctx->options &= ~DHCPCD_RTM_PPID;
+                               continue;
+                       }
                        cp = (void *)(rtm + 1);
                        sa = (void *)cp;
                        switch (sa->sa_family) {
@@ -1360,6 +1359,9 @@ if_managelink(struct dhcpcd_ctx *ctx)
 #endif
                case RTM_DELADDR:       /* FALLTHROUGH */
                case RTM_NEWADDR:
+                       /* XXX We have no way of knowing who generated these
+                        * messages wich truely sucks because we want to
+                        * avoid listening to our own delete messages. */
                        ifam = (void *)p;
                        ifp = if_findindex(ctx->ifaces, ifam->ifam_index);
                        if (ifp == NULL)