From: Roy Marples Date: Sat, 19 Sep 2020 14:05:51 +0000 (+0100) Subject: Adjust prior so that message is logged before starting dev X-Git-Tag: v9.3.0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f78bde8042dace0e0330a58d430a0c7c8a32199;p=thirdparty%2Fdhcpcd.git Adjust prior so that message is logged before starting dev Also add os_init incase other os need similar in the future. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 1c863b5e..8fbb6212 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -2367,6 +2367,8 @@ printpidfile: } #endif + os_init(); + #if defined(BSD) && defined(INET6) /* Disable the kernel RTADV sysctl as early as possible. */ if (ctx.options & DHCPCD_IPV6 && ctx.options & DHCPCD_IPV6RS) diff --git a/src/dhcpcd.h b/src/dhcpcd.h index 0cf774ce..03449e58 100644 --- a/src/dhcpcd.h +++ b/src/dhcpcd.h @@ -254,10 +254,6 @@ struct dhcpcd_ctx { struct dev *dev; void *dev_handle; #endif - -#ifdef __linux__ - char netns[PATH_MAX]; -#endif }; #ifdef USE_SIGNALS diff --git a/src/if-bsd.c b/src/if-bsd.c index 5e748a4e..98bcda63 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -121,6 +121,12 @@ struct rtm char buffer[sizeof(struct sockaddr_storage) * RTAX_MAX]; }; +int +os_init(void) +{ + return 0; +} + int if_init(__unused struct interface *iface) { diff --git a/src/if-linux.c b/src/if-linux.c index 759b878e..94622d7d 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -145,7 +145,6 @@ struct priv { int route_fd; int generic_fd; uint32_t route_pid; - char netns[PATH_MAX]; }; /* We need this to send a broadcast for InfiniBand. @@ -415,6 +414,18 @@ if_getnetworknamespace(char *buf, size_t len) return bufp; } +int +os_init(void) +{ + char netns[PATH_MAX], *p; + + p = if_getnetworknamespace(netns, sizeof(netns)); + if (p != NULL) + loginfox("network namespace: %s", p); + + return 0; +} + int if_opensockets_os(struct dhcpcd_ctx *ctx) { @@ -465,9 +476,6 @@ if_opensockets_os(struct dhcpcd_ctx *ctx) if (priv->generic_fd == -1) return -1; - if (if_getnetworknamespace(ctx->netns, sizeof(ctx->netns)) != NULL) - logdebugx("network namespace: %s", ctx->netns); - return 0; } diff --git a/src/if-sun.c b/src/if-sun.c index 4f5c1647..be12385a 100644 --- a/src/if-sun.c +++ b/src/if-sun.c @@ -108,6 +108,12 @@ struct rtm static int if_plumb(int, const struct dhcpcd_ctx *, int, const char *); +int +os_init(void) +{ + return 0; +} + int if_init(struct interface *ifp) { diff --git a/src/if.h b/src/if.h index 803f5818..4e8302ba 100644 --- a/src/if.h +++ b/src/if.h @@ -184,6 +184,7 @@ struct if_spec { int if_nametospec(const char *, struct if_spec *); /* The below functions are provided by if-KERNEL.c */ +int os_init(void); int if_conf(struct interface *); int if_init(struct interface *); int if_getssid(struct interface *);