From: Roy Marples Date: Mon, 9 Oct 2017 19:21:05 +0000 (+0100) Subject: Don't mark statically configured IPv4 routes as DHCP. X-Git-Tag: v7.0.0-rc4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f123d00b56755a223d22bab30a2bef727632d7d;p=thirdparty%2Fdhcpcd.git Don't mark statically configured IPv4 routes as DHCP. --- diff --git a/src/dhcp.c b/src/dhcp.c index 6be689fd..75bcddc7 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -428,7 +428,6 @@ decode_rfc3442_rt(struct rt_head *routes, struct interface *ifp, if ((rt = rt_new(ifp)) == NULL) return -1; - rt->rt_dflags |= RTDF_DHCP; /* If we have ocets then we have a destination and netmask */ dest.s_addr = 0; @@ -633,7 +632,6 @@ get_option_routes(struct rt_head *routes, struct interface *ifp, continue; if ((rt = rt_new(ifp)) == NULL) return -1; - rt->rt_dflags |= RTDF_DHCP; /* A host route is normally set by having the * gateway match the destination or assigned address */ @@ -666,7 +664,6 @@ get_option_routes(struct rt_head *routes, struct interface *ifp, while (p < e) { if ((rt = rt_new(ifp)) == NULL) return -1; - rt->rt_dflags |= RTDF_DHCP; memcpy(&gateway.s_addr, p, sizeof(gateway.s_addr)); p += 4; sa_in_init(&rt->rt_dest, &dest); diff --git a/src/ipv4.c b/src/ipv4.c index eb8e62f2..116fa009 100644 --- a/src/ipv4.c +++ b/src/ipv4.c @@ -266,7 +266,7 @@ inet_dhcproutes(struct rt_head *routes, struct interface *ifp) /* First, add a subnet route. */ if (!(ifp->flags & IFF_POINTOPOINT) && #ifndef BSD - /* BSD adds a route in this instance */ + /* BSD adds a route in this instance */ state->addr->mask.s_addr != INADDR_BROADCAST && #endif state->addr->mask.s_addr != INADDR_ANY) @@ -291,6 +291,7 @@ inet_dhcproutes(struct rt_head *routes, struct interface *ifp) break; if ((rt = rt_new(ifp)) == NULL) return -1; + rt->rt_dflags = RTDF_STATIC; memcpy(rt, r, sizeof(*rt)); TAILQ_INSERT_TAIL(&nroutes, rt, rt_next); } @@ -319,6 +320,8 @@ inet_dhcproutes(struct rt_head *routes, struct interface *ifp) n = 0; TAILQ_FOREACH(rt, &nroutes, rt_next) { rt->rt_mtu = mtu; + if (!(rt->rt_dflags & RTDF_STATIC)) + rt->rt_dflags |= RTDF_DHCP; sa_in_init(&rt->rt_ifa, &state->addr->addr); n++; } diff --git a/src/route.h b/src/route.h index 6080c9d9..9fcd31a8 100644 --- a/src/route.h +++ b/src/route.h @@ -77,6 +77,7 @@ struct rt { #define RTDF_FAKE 0x04 /* Maybe us on lease reboot */ #define RTDF_RA 0x08 /* Router Advertisement */ #define RTDF_DHCP 0x10 /* DHCP route */ +#define RTDF_STATIC 0x20 /* Configured in dhcpcd */ }; TAILQ_HEAD(rt_head, rt);