mirror of
https://github.com/rsmarples/dhcpcd.git
synced 2024-11-23 18:14:09 +08:00
Provide TAILQ_FOREACH_REVERSE_SAFE if not defined.
When removing routes, do it in reverse order.
This commit is contained in:
parent
7e5b6d033e
commit
6855bff4c4
5
configure
vendored
5
configure
vendored
@ -213,6 +213,7 @@ if [ -n "$DEBUG" -a "$DEBUG" != no -a "$DEBUG" != false ]; then
|
||||
elif [ -z "$DEBUG" -a -d .git ]; then
|
||||
printf "Found git ... "
|
||||
DEBUG=yes
|
||||
echo "CFLAGS+= -ggdb" >>$CONFIG_MK
|
||||
else
|
||||
DEBUG=no
|
||||
fi
|
||||
@ -404,6 +405,10 @@ if [ "$TAILQ_FOREACH_SAFE" = no ]; then
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((next) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (next))
|
||||
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((prev) = TAILQ_PREV((var), headname, field), 1);\
|
||||
(var) = (prev))
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
2
ipv6.c
2
ipv6.c
@ -437,6 +437,7 @@ ipv6_build_routes(void)
|
||||
* If we own the default route, but not RA management itself
|
||||
* then we need to preserve the last best default route we had */
|
||||
TAILQ_FOREACH_REVERSE_SAFE(rt, routes, rt6head, next, rtn) {
|
||||
TAILQ_REMOVE(routes, rt, next);
|
||||
if (find_route6(nrs, rt) == NULL) {
|
||||
if (!have_default &&
|
||||
(options & DHCPCD_IPV6RA_OWN_DEFAULT) &&
|
||||
@ -451,6 +452,7 @@ ipv6_build_routes(void)
|
||||
}
|
||||
free(rt);
|
||||
}
|
||||
|
||||
free(routes);
|
||||
routes = nrs;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user