diff options
| author | Roy Marples <roy@marples.name> | 2016-04-07 20:35:57 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2016-04-07 20:35:57 +0000 |
| commit | d306a8f2df27b629cac51cd6df648262046dcd20 (patch) | |
| tree | 4260a01b6cd62f96c647a781b9cb1941c528f649 /if.c | |
| parent | 0480237e31fb49330bc5d547e1bb863bb94b94d9 (diff) | |
| download | dhcpcd-d306a8f2df27b629cac51cd6df648262046dcd20.tar.xz | |
Linux netlink nlmsg_pid is not process id - only the first socket opened
has that. So after opening the link socket, open a persistent route socket
and record the nlmsg_pid the kernel creates which is guaranteed unique
and won't clash with a process id which can then be ignored by testing it
directly and not that it's some large number.
Diffstat (limited to 'if.c')
| -rw-r--r-- | if.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -89,7 +89,7 @@ int if_opensockets(struct dhcpcd_ctx *ctx) { - if ((ctx->link_fd = if_openlinksocket()) == -1) + if (if_opensockets_os(ctx) == -1) return -1; /* We use this socket for some operations without INET. */ @@ -113,6 +113,23 @@ if_opensockets(struct dhcpcd_ctx *ctx) return 0; } +void +if_closesockets(struct dhcpcd_ctx *ctx) +{ + + if (ctx->pf_inet_fd != -1) + close(ctx->pf_inet_fd); +#ifdef IFLR_ACTIVE + if (ctx->pf_link_fd != -1) + close(ctx->pf_link_fd); +#endif + + if (ctx->priv) { + if_closesockets_os(ctx); + free(ctx->priv); + } +} + int if_carrier(struct interface *ifp) { |
