summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-03-06 08:55:11 +0000
committerRoy Marples <roy@marples.name>2018-03-06 08:55:11 +0000
commitc8d1a4150812b2d01c9cc2e5272a2ba19bc0196f (patch)
tree04a731a655be459cc6fc5d1503a2f5b0b920c159
parent94b342061f5b93b05ca9a43ea30997113da332d3 (diff)
downloaddhcpcd-c8d1a4150812b2d01c9cc2e5272a2ba19bc0196f.tar.xz
Log the pid of the process deleting an assigned address.
This should make debugging easier with third party software.
-rw-r--r--src/dhcp.c6
-rw-r--r--src/dhcp.h2
-rw-r--r--src/dhcp6.c4
-rw-r--r--src/dhcp6.h2
-rw-r--r--src/if-bsd.c8
-rw-r--r--src/if-linux.c5
-rw-r--r--src/if-sun.c4
-rw-r--r--src/if.c4
-rw-r--r--src/ipv4.c4
-rw-r--r--src/ipv4.h2
-rw-r--r--src/ipv6.c14
-rw-r--r--src/ipv6.h5
-rw-r--r--src/ipv6nd.c4
-rw-r--r--src/ipv6nd.h2
14 files changed, 36 insertions, 30 deletions
diff --git a/src/dhcp.c b/src/dhcp.c
index 096a7c45..f59b347f 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -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. */
diff --git a/src/dhcp.h b/src/dhcp.h
index 66a8b3d0..b4313d43 100644
--- a/src/dhcp.h
+++ b/src/dhcp.h
@@ -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 *);
diff --git a/src/dhcp6.c b/src/dhcp6.c
index 06d67327..7c35add9 100644
--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -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
diff --git a/src/dhcp6.h b/src/dhcp6.h
index 098b869b..50b7c9e8 100644
--- a/src/dhcp6.h
+++ b/src/dhcp6.h
@@ -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);
diff --git a/src/if-bsd.c b/src/if-bsd.c
index 824d4fd8..f259e821 100644
--- a/src/if-bsd.c
+++ b/src/if-bsd.c
@@ -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
diff --git a/src/if-linux.c b/src/if-linux.c
index 8c8dae31..152cffed 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -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
}
diff --git a/src/if-sun.c b/src/if-sun.c
index e23cfc04..dfe7734a 100644
--- a/src/if-sun.c
+++ b/src/if-sun.c
@@ -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
diff --git a/src/if.c b/src/if.c
index adeb6d92..e3641ac6 100644
--- 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
}
diff --git a/src/ipv4.c b/src/ipv4.c
index eee1c814..4e8413ee 100644
--- a/src/ipv4.c
+++ b/src/ipv4.c
@@ -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)
diff --git a/src/ipv4.h b/src/ipv4.h
index bcd0031f..6e27d918 100644
--- a/src/ipv4.h
+++ b/src/ipv4.h
@@ -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
diff --git a/src/ipv6.c b/src/ipv6.c
index e235dc1f..615aed22 100644
--- a/src/ipv6.c
+++ b/src/ipv6.c
@@ -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) {
diff --git a/src/ipv6.h b/src/ipv6.h
index c0af797b..e2480e33 100644
--- a/src/ipv6.h
+++ b/src/ipv6.h
@@ -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 *);
diff --git a/src/ipv6nd.c b/src/ipv6nd.c
index bbd02cb6..3fca8848 100644
--- a/src/ipv6nd.c
+++ b/src/ipv6nd.c
@@ -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);
}
}
diff --git a/src/ipv6nd.h b/src/ipv6nd.h
index a9a9d747..7e123e48 100644
--- a/src/ipv6nd.h
+++ b/src/ipv6nd.h
@@ -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 *);