]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Log the pid of the process deleting an assigned address.
authorRoy Marples <roy@marples.name>
Tue, 6 Mar 2018 08:55:11 +0000 (08:55 +0000)
committerRoy Marples <roy@marples.name>
Tue, 6 Mar 2018 08:55:11 +0000 (08:55 +0000)
This should make debugging easier with third party software.

14 files changed:
src/dhcp.c
src/dhcp.h
src/dhcp6.c
src/dhcp6.h
src/if-bsd.c
src/if-linux.c
src/if-sun.c
src/if.c
src/ipv4.c
src/ipv4.h
src/ipv6.c
src/ipv6.h
src/ipv6nd.c
src/ipv6nd.h

index 096a7c45fcf15e8010488725d08da54ee68d984f..f59b347f10df15671a6215f0fd3e23da67120207 100644 (file)
@@ -3892,7 +3892,7 @@ dhcp_abort(struct interface *ifp)
 }
 
 void
-dhcp_handleifa(int cmd, struct ipv4_addr *ia)
+dhcp_handleifa(int cmd, struct ipv4_addr *ia, pid_t pid)
 {
        struct interface *ifp;
        struct dhcp_state *state;
@@ -3906,8 +3906,8 @@ dhcp_handleifa(int cmd, struct ipv4_addr *ia)
 
        if (cmd == RTM_DELADDR) {
                if (state->addr == ia) {
-                       loginfox("%s: deleted IP address %s",
-                           ifp->name, ia->saddr);
+                       loginfox("%s: pid %d deleted IP address %s",
+                           ifp->name, pid, ia->saddr);
                        state->addr = NULL;
                        /* Don't clear the added state as we need
                         * to drop the lease. */
index 66a8b3d08173f234ea545df40d45811b9ef901d3..b4313d435eabb4ab09eef41fbfee23597332d442 100644 (file)
@@ -254,7 +254,7 @@ int dhcp_get_routes(struct rt_head *, struct interface *);
 ssize_t dhcp_env(char **, const char *, const struct bootp *, size_t,
     const struct interface *);
 
-void dhcp_handleifa(int, struct ipv4_addr *);
+void dhcp_handleifa(int, struct ipv4_addr *, pid_t pid);
 void dhcp_drop(struct interface *, const char *);
 void dhcp_start(struct interface *);
 void dhcp_abort(struct interface *);
index 06d6732763201ccdd0d1baf67bca95ca1b1dbe26..7c35add9440ce894c8a6268bd1dbf6bd31825f08 100644 (file)
@@ -3871,7 +3871,7 @@ dhcp6_dropnondelegates(struct interface *ifp)
 }
 
 void
-dhcp6_handleifa(int cmd, struct ipv6_addr *ia)
+dhcp6_handleifa(int cmd, struct ipv6_addr *ia, pid_t pid)
 {
        struct dhcp6_state *state;
        struct interface *ifp = ia->iface;
@@ -3886,7 +3886,7 @@ dhcp6_handleifa(int cmd, struct ipv6_addr *ia)
                dhcp6_listen(ia->iface->ctx, ia);
 
        if ((state = D6_STATE(ifp)) != NULL)
-               ipv6_handleifa_addrs(cmd, &state->addrs, ia);
+               ipv6_handleifa_addrs(cmd, &state->addrs, ia, pid);
 }
 
 ssize_t
index 098b869bcdb656f74ae60a290b1e97239f12fba3..50b7c9e8e33f3967ef636d81e29fcc4e08650764 100644 (file)
@@ -229,7 +229,7 @@ void dhcp6_renew(struct interface *);
 ssize_t dhcp6_env(char **, const char *, const struct interface *,
     const struct dhcp6_message *, size_t);
 void dhcp6_free(struct interface *);
-void dhcp6_handleifa(int, struct ipv6_addr *);
+void dhcp6_handleifa(int, struct ipv6_addr *, pid_t);
 int dhcp6_dadcompleted(const struct interface *);
 void dhcp6_drop(struct interface *, const char *);
 void dhcp6_dropnondelegates(struct interface *ifp);
index 824d4fd8fac9f509bcd9c98ad59916abcc1eaf76..f259e8218e458e1feadb2fe6e72b18fe90034674 100644 (file)
@@ -1040,6 +1040,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
        struct interface *ifp;
        const struct sockaddr *rti_info[RTAX_MAX];
        int addrflags;
+       pid_t pid;
 
        if ((ifp = if_findindex(ctx->ifaces, ifam->ifam_index)) == NULL)
                return;
@@ -1068,6 +1069,9 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                }
 #endif
        }
+       pid = ifam->ifam_pid;
+#else
+       pid = 0;
 #endif
 
 #ifdef HAVE_IFAM_ADDRFLAGS
@@ -1140,7 +1144,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
 #endif
 
                ipv4_handleifa(ctx, ifam->ifam_type, NULL, ifp->name,
-                   &addr, &mask, &bcast, addrflags);
+                   &addr, &mask, &bcast, addrflags, pid);
                break;
        }
 #endif
@@ -1171,7 +1175,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
 #endif
 
                ipv6_handleifa(ctx, ifam->ifam_type, NULL,
-                   ifp->name, &addr6, ipv6_prefixlen(&mask6), addrflags);
+                   ifp->name, &addr6, ipv6_prefixlen(&mask6), addrflags, pid);
                break;
        }
 #endif
index 8c8dae31a157e4d4bad7bc0f093531090ada9dc9..152cffedfa362874fefe2b7edac4228544852385 100644 (file)
@@ -609,7 +609,7 @@ link_addr(struct dhcpcd_ctx *ctx, struct interface *ifp, struct nlmsghdr *nlm)
                        rta = RTA_NEXT(rta, len);
                }
                ipv4_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name,
-                   &addr, &net, &brd, ifa->ifa_flags);
+                   &addr, &net, &brd, ifa->ifa_flags, (pid_t)nlm->nlmsg_pid);
                break;
 #endif
 #ifdef INET6
@@ -625,7 +625,8 @@ link_addr(struct dhcpcd_ctx *ctx, struct interface *ifp, struct nlmsghdr *nlm)
                        rta = RTA_NEXT(rta, len);
                }
                ipv6_handleifa(ctx, nlm->nlmsg_type, NULL, ifp->name,
-                   &addr6, ifa->ifa_prefixlen, ifa->ifa_flags);
+                   &addr6, ifa->ifa_prefixlen, ifa->ifa_flags,
+                   (pid_t)nlm->nlmsg_pid);
                break;
 #endif
        }
index e23cfc040105666f1e531842c7c1cab1f440c9e6..dfe7734a83ec760971fbdf8a8e2c622741e570dd 100644 (file)
@@ -684,7 +684,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                ipv4_handleifa(ctx,
                    ifam->ifam_type == RTM_CHGADDR ?
                    RTM_NEWADDR : ifam->ifam_type,
-                   NULL, ifalias, &addr, &mask, &bcast, flags);
+                   NULL, ifalias, &addr, &mask, &bcast, flags, 0);
                break;
        }
 #endif
@@ -712,7 +712,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                ipv6_handleifa(ctx,
                    ifam->ifam_type == RTM_CHGADDR ?
                    RTM_NEWADDR : ifam->ifam_type,
-                   NULL, ifalias, &addr6, ipv6_prefixlen(&mask6), flags);
+                   NULL, ifalias, &addr6, ipv6_prefixlen(&mask6), flags, 0);
                break;
        }
 #endif
index adeb6d921f2f91bec479a158a876495f87745106..e3641ac6b1e2c6bf204b820c57cbab249864abd6 100644 (file)
--- a/src/if.c
+++ b/src/if.c
@@ -234,7 +234,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
 #endif
                        ipv4_handleifa(ctx, RTM_NEWADDR, ifs, ifa->ifa_name,
                                &addr->sin_addr, &net->sin_addr,
-                               brd ? &brd->sin_addr : NULL, addrflags);
+                               brd ? &brd->sin_addr : NULL, addrflags, 0);
                        break;
 #endif
 #ifdef INET6
@@ -258,7 +258,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
 #endif
                        ipv6_handleifa(ctx, RTM_NEWADDR, ifs,
                            ifa->ifa_name, &sin6->sin6_addr,
-                           ipv6_prefixlen(&net6->sin6_addr), addrflags);
+                           ipv6_prefixlen(&net6->sin6_addr), addrflags, 0);
                        break;
 #endif
                }
index eee1c81458d33f8cac8d40ea51b5e03461a52c3c..4e8413ee9a63ddeade549565253f5cc7f22c506f 100644 (file)
@@ -765,7 +765,7 @@ void
 ipv4_handleifa(struct dhcpcd_ctx *ctx,
     int cmd, struct if_head *ifs, const char *ifname,
     const struct in_addr *addr, const struct in_addr *mask,
-    const struct in_addr *brd, const int addrflags)
+    const struct in_addr *brd, int addrflags, pid_t pid)
 {
        struct interface *ifp;
        struct ipv4_state *state;
@@ -831,7 +831,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
 #ifdef ARP
                arp_handleifa(cmd, ia);
 #endif
-               dhcp_handleifa(cmd, ia);
+               dhcp_handleifa(cmd, ia, pid);
        }
 
        if (cmd == RTM_DELADDR)
index bcd0031f93e1aa3806a1924ebd598eab7f8463f1..6e27d918cba90f5a152e8fee729d59daec30ca93 100644 (file)
@@ -131,7 +131,7 @@ struct ipv4_addr *ipv4_findmaskaddr(struct dhcpcd_ctx *,
     const struct in_addr *);
 void ipv4_handleifa(struct dhcpcd_ctx *, int, struct if_head *, const char *,
     const struct in_addr *, const struct in_addr *, const struct in_addr *,
-    int);
+    int, pid_t);
 
 void ipv4_free(struct interface *);
 #else
index e235dc1ff0565cc51e3affa57a6f49f4ec50e34d..615aed2229c32ac9ab9585a4d379eba4f55ee1af 100644 (file)
@@ -566,7 +566,7 @@ ipv6_checkaddrflags(void *arg)
                /* Simulate the kernel announcing the new address. */
                ipv6_handleifa(ia->iface->ctx, RTM_NEWADDR,
                    ia->iface->ctx->ifaces, ia->iface->name,
-                   &ia->addr, ia->prefix_len, flags);
+                   &ia->addr, ia->prefix_len, flags, 0);
        } else {
                /* Still tentative? Check again in a bit. */
                struct timespec tv;
@@ -1063,7 +1063,7 @@ ipv6_getstate(struct interface *ifp)
 void
 ipv6_handleifa(struct dhcpcd_ctx *ctx,
     int cmd, struct if_head *ifs, const char *ifname,
-    const struct in6_addr *addr, uint8_t prefix_len, int addrflags)
+    const struct in6_addr *addr, uint8_t prefix_len, int addrflags, pid_t pid)
 {
        struct interface *ifp;
        struct ipv6_state *state;
@@ -1174,8 +1174,8 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
        }
 
        if (ia != NULL) {
-               ipv6nd_handleifa(cmd, ia);
-               dhcp6_handleifa(cmd, ia);
+               ipv6nd_handleifa(cmd, ia, pid);
+               dhcp6_handleifa(cmd, ia, pid);
 
                /* Done with the ia now, so free it. */
                if (cmd == RTM_DELADDR)
@@ -1705,7 +1705,7 @@ ipv6_ctxfree(struct dhcpcd_ctx *ctx)
 
 int
 ipv6_handleifa_addrs(int cmd,
-    struct ipv6_addrhead *addrs, const struct ipv6_addr *addr)
+    struct ipv6_addrhead *addrs, const struct ipv6_addr *addr, pid_t pid)
 {
        struct ipv6_addr *ia, *ian;
        uint8_t found, alldadcompleted;
@@ -1722,8 +1722,8 @@ ipv6_handleifa_addrs(int cmd,
                switch (cmd) {
                case RTM_DELADDR:
                        if (ia->flags & IPV6_AF_ADDED) {
-                               logwarnx("%s: deleted address %s",
-                                   ia->iface->name, ia->saddr);
+                               logwarnx("%s: pid %d deleted address %s",
+                                   ia->iface->name, pid, ia->saddr);
                                ia->flags &= ~IPV6_AF_ADDED;
                        }
                        if (ia->flags & IPV6_AF_DELEGATED) {
index c0af797bdf6e07a504c2ef1957adfa7015169d18..e2480e335c298a7b4b6d45887427ff0fb3efc367 100644 (file)
@@ -237,8 +237,9 @@ void ipv6_deleteaddr(struct ipv6_addr *);
 void ipv6_freedrop_addrs(struct ipv6_addrhead *, int,
     const struct interface *);
 void ipv6_handleifa(struct dhcpcd_ctx *ctx, int, struct if_head *,
-    const char *, const struct in6_addr *, uint8_t, int);
-int ipv6_handleifa_addrs(int, struct ipv6_addrhead *, const struct ipv6_addr *);
+    const char *, const struct in6_addr *, uint8_t, int, pid_t);
+int ipv6_handleifa_addrs(int, struct ipv6_addrhead *, const struct ipv6_addr *,
+    pid_t);
 struct ipv6_addr *ipv6_iffindaddr(struct interface *,
     const struct in6_addr *, int);
 int ipv6_hasaddr(const struct interface *);
index bbd02cb6089f856434ea7838247add81bf4b271a..3fca884857e2110c7afc01277c3a92c86ee56d62 100644 (file)
@@ -1291,7 +1291,7 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
 }
 
 void
-ipv6nd_handleifa(int cmd, struct ipv6_addr *addr)
+ipv6nd_handleifa(int cmd, struct ipv6_addr *addr, pid_t pid)
 {
        struct ra *rap;
 
@@ -1303,7 +1303,7 @@ ipv6nd_handleifa(int cmd, struct ipv6_addr *addr)
        TAILQ_FOREACH(rap, addr->iface->ctx->ra_routers, next) {
                if (rap->iface != addr->iface)
                        continue;
-               ipv6_handleifa_addrs(cmd, &rap->addrs, addr);
+               ipv6_handleifa_addrs(cmd, &rap->addrs, addr, pid);
        }
 }
 
index a9a9d747e79b2bee1822a306c07b8bd73ec3ba2f..7e123e48d5fd3d973e2c2f26f6afee6c3c6776e6 100644 (file)
@@ -97,7 +97,7 @@ ssize_t ipv6nd_free(struct interface *);
 void ipv6nd_expirera(void *arg);
 int ipv6nd_hasra(const struct interface *);
 int ipv6nd_hasradhcp(const struct interface *);
-void ipv6nd_handleifa(int, struct ipv6_addr *);
+void ipv6nd_handleifa(int, struct ipv6_addr *, pid_t);
 int ipv6nd_dadcompleted(const struct interface *);
 void ipv6nd_expire(struct interface *, uint32_t);
 void ipv6nd_drop(struct interface *);