]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
if: No more need for interface sorting
authorRoy Marples <roy@marples.name>
Mon, 4 Mar 2019 11:48:04 +0000 (11:48 +0000)
committerRoy Marples <roy@marples.name>
Mon, 4 Mar 2019 11:48:04 +0000 (11:48 +0000)
src/dhcp6.c
src/dhcpcd.c
src/if.c
src/if.h

index 6e83a70fdf2f6826053eb85a1af4a7568c3dfcc6..da5242fd58e04183f0487edc60e077a5dac5314c 100644 (file)
@@ -2825,20 +2825,6 @@ dhcp6_delegate_prefix(struct interface *ifp)
                        struct dhcp6_state *s = D6_STATE(ifd);
 
                        ipv6_addaddrs(&s->addrs);
-
-                       /*
-                        * Can't add routes here because that will trigger
-                        * interface sorting which may break the current
-                        * enumeration.
-                        * This doesn't really matter thanks to DaD because
-                        * calling the script will be delayed and routes
-                        * will get re-built if needed first.
-                        * This only cause minor confusion when dhcpcd is
-                        * restarted and confirms a lease where prior delegation
-                        * has already been assigned, because it will log it
-                        * added routes after the script has run.
-                        * The routes should still be there and fine though.
-                        */
                        dhcp6_script_try_run(ifd, 1);
                }
        }
index 384107a80c283d1d1009909f9d4f55ee8be86abd..f79271401a09d85e8ad86f6f5074178e5da51681 100644 (file)
@@ -2092,7 +2092,6 @@ printpidfile:
        free_options(&ctx, ifo);
        ifo = NULL;
 
-       if_sortinterfaces(&ctx);
        TAILQ_FOREACH(ifp, ctx.ifaces, next) {
                if (ifp->active)
                        eloop_timeout_add_sec(ctx.eloop, 0,
index 95067c773eeac4371894f60ea7b1dd5b67013e4e..d58ecb8affb6179c49e76c3aabaa84ba498a3527 100644 (file)
--- a/src/if.c
+++ b/src/if.c
@@ -720,87 +720,6 @@ if_domtu(const struct interface *ifp, short int mtu)
        return ifr.ifr_mtu;
 }
 
-/* Interface comparer for working out ordering. */
-static int
-if_cmp(const struct interface *si, const struct interface *ti)
-{
-#ifdef INET
-       int r;
-#endif
-
-       /* Check active first */
-       if (si->active > ti->active)
-               return -1;
-       if (si->active < ti->active)
-               return 1;
-
-       /* Check carrier status next */
-       if (si->carrier > ti->carrier)
-               return -1;
-       if (si->carrier < ti->carrier)
-               return 1;
-#ifdef INET
-       if (D_STATE_RUNNING(si) && !D_STATE_RUNNING(ti))
-               return -1;
-       if (!D_STATE_RUNNING(si) && D_STATE_RUNNING(ti))
-               return 1;
-#endif
-#ifdef INET6
-       if (RS_STATE_RUNNING(si) && !RS_STATE_RUNNING(ti))
-               return -1;
-       if (!RS_STATE_RUNNING(si) && RS_STATE_RUNNING(ti))
-               return 1;
-#endif
-#ifdef DHCP6
-       if (D6_STATE_RUNNING(si) && !D6_STATE_RUNNING(ti))
-               return -1;
-       if (!D6_STATE_RUNNING(si) && D6_STATE_RUNNING(ti))
-               return 1;
-#endif
-
-#ifdef INET
-       /* Special attention needed here due to states and IPv4LL. */
-       if ((r = ipv4_ifcmp(si, ti)) != 0)
-               return r;
-#endif
-
-       /* Finally, metric */
-       if (si->metric < ti->metric)
-               return -1;
-       if (si->metric > ti->metric)
-               return 1;
-       return 0;
-}
-
-/* Sort the interfaces into a preferred order - best first, worst last. */
-void
-if_sortinterfaces(struct dhcpcd_ctx *ctx)
-{
-       struct if_head sorted;
-       struct interface *ifp, *ift;
-
-       if (ctx->ifaces == NULL ||
-           (ifp = TAILQ_FIRST(ctx->ifaces)) == NULL ||
-           TAILQ_NEXT(ifp, next) == NULL)
-               return;
-
-       TAILQ_INIT(&sorted);
-       TAILQ_REMOVE(ctx->ifaces, ifp, next);
-       TAILQ_INSERT_HEAD(&sorted, ifp, next);
-       while ((ifp = TAILQ_FIRST(ctx->ifaces))) {
-               TAILQ_REMOVE(ctx->ifaces, ifp, next);
-               TAILQ_FOREACH(ift, &sorted, next) {
-                       if (if_cmp(ifp, ift) == -1) {
-                               TAILQ_INSERT_BEFORE(ift, ifp, next);
-                               break;
-                       }
-               }
-               if (ift == NULL)
-                       TAILQ_INSERT_TAIL(&sorted, ifp, next);
-       }
-       TAILQ_CONCAT(ctx->ifaces, &sorted, next);
-}
-
 struct interface *
 if_findifpfromcmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg, int *hoplimit)
 {
index 2f20764c01f401830c9565f7e28fe37d4aec0dc0..1aac439b81af584602f6a7e464fdbe0e5b37588e 100644 (file)
--- a/src/if.h
+++ b/src/if.h
@@ -122,7 +122,6 @@ void if_deletestaleaddrs(struct if_head *);
 struct interface *if_find(struct if_head *, const char *);
 struct interface *if_findindex(struct if_head *, unsigned int);
 struct interface *if_loopback(struct dhcpcd_ctx *);
-void if_sortinterfaces(struct dhcpcd_ctx *);
 void if_free(struct interface *);
 int if_domtu(const struct interface *, short int);
 #define if_getmtu(ifp) if_domtu((ifp), 0)