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);
}
}
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)
{
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)