Mercurial > hg > dhcpcd
changeset 4255:8524a8375483 draft
Linux: Improve interface renaming
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Sun, 15 Apr 2018 13:36:36 +0000 |
| parents | b5adecac4668 |
| children | 4cc5f8d94727 |
| files | src/if-linux.c |
| diffstat | 1 files changed, 9 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if-linux.c Sun Apr 15 14:23:49 2018 +0100 +++ b/src/if-linux.c Sun Apr 15 13:36:36 2018 +0000 @@ -652,23 +652,6 @@ return 0; } -static int -handle_rename(struct dhcpcd_ctx *ctx, unsigned int ifindex, const char *ifname) -{ - struct interface *ifp; - - TAILQ_FOREACH(ifp, ctx->ifaces, next) { - if (ifp->index == ifindex && strcmp(ifp->name, ifname)) { - dhcpcd_handleinterface(ctx, -1, ifp->name); - /* Let dev announce the interface for renaming */ - if (!dev_listening(ctx)) - dhcpcd_handleinterface(ctx, 1, ifname); - return 1; - } - } - return 0; -} - #ifdef INET6 static int link_neigh(struct dhcpcd_ctx *ctx, __unused struct interface *ifp, @@ -783,12 +766,9 @@ return 0; } - /* Check for interface name change */ - if (handle_rename(ctx, (unsigned int)ifi->ifi_index, ifn)) - return 0; - /* Check for a new interface */ - if ((ifp = if_find(ctx->ifaces, ifn)) == NULL) { + ifp = if_findindex(ctx->ifaces, (unsigned int)ifi->ifi_index); + if (ifp == NULL) { /* If are listening to a dev manager, let that announce * the interface rather than the kernel. */ if (dev_listening(ctx) < 1) @@ -796,6 +776,13 @@ return 0; } + /* Handle interface being renamed */ + if (strcmp(ifp->name, ifn) != 0) { + dhcpcd_handleinterface(ctx, -1, ifn); + dhcpcd_handleinterface(ctx, 1, ifn); + return 0; + } + /* Re-read hardware address and friends */ if (!(ifi->ifi_flags & IFF_UP) && hwaddr) { uint8_t l;
