]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Set DHCP routes as DHCP in supported OS's.
authorRoy Marples <roy@marples.name>
Mon, 9 Oct 2017 19:11:36 +0000 (20:11 +0100)
committerRoy Marples <roy@marples.name>
Mon, 9 Oct 2017 19:11:36 +0000 (20:11 +0100)
src/dhcp.c
src/if-linux.c
src/ipv6.c
src/route.h

index 27951ae404fad7d5b85b171a87edb2257c4dd141..6be689fd8a4e51fe9a68390134c93214a6cf0da9 100644 (file)
@@ -428,7 +428,7 @@ decode_rfc3442_rt(struct rt_head *routes, struct interface *ifp,
 
                if ((rt = rt_new(ifp)) == NULL)
                        return -1;
-               TAILQ_INSERT_TAIL(routes, rt, rt_next);
+               rt->rt_dflags |= RTDF_DHCP;
 
                /* If we have ocets then we have a destination and netmask */
                dest.s_addr = 0;
@@ -461,6 +461,8 @@ decode_rfc3442_rt(struct rt_head *routes, struct interface *ifp,
                /* If CIDR is 32 then it's a host route. */
                if (cidr == 32)
                        rt->rt_flags = RTF_HOST;
+
+               TAILQ_INSERT_TAIL(routes, rt, rt_next);
                n++;
        }
        return n;
@@ -631,6 +633,7 @@ 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 */
@@ -663,6 +666,7 @@ 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);
index debbabaa289b99549a8dd859fa21edc7c2c4a5d5..b5e30eb9aeffe83e101f4076bf086e8f1ffaf50d 100644 (file)
@@ -1225,6 +1225,11 @@ if_route(unsigned char cmd, const struct rt *rt)
                if (rt->rt_dflags & RTDF_RA)
                        nlm.rt.rtm_protocol = RTPROT_RA;
                else
+#endif
+#ifdef RTPROT_DHCP
+               if (rt->rt_dflags & RTDF_DHCP)
+                       nlm.rt.rtm_protocol = RTPROT_DHCP;
+               else
 #endif
                if (rt->rt_dflags & RTDF_IFA_ROUTE)
                        nlm.rt.rtm_protocol = RTPROT_KERNEL;
index a9543dd60053c42ac6f279de5aab9d6598929c97..c98a8f34eca2b5886b5852e1ad7d821ee64d1926 100644 (file)
@@ -2136,10 +2136,8 @@ inet6_makeroute(struct interface *ifp, const struct ra *rap)
 #ifdef HAVE_ROUTE_METRIC
        rt->rt_metric = ifp->metric;
 #endif
-       if (rap != NULL) {
+       if (rap != NULL)
                rt->rt_mtu = rap->mtu;
-               rt->rt_dflags |= RTDF_RA;
-       }
        return rt;
 }
 
@@ -2256,12 +2254,15 @@ inet6_raroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx, int expired,
                        if (addr->prefix_vltime == 0)
                                continue;
                        rt = inet6_makeprefix(rap->iface, rap, addr);
-                       if (rt)
+                       if (rt) {
+                               rt->rt_dflags |= RTDF_RA;
                                TAILQ_INSERT_TAIL(routes, rt, rt_next);
+                       }
                }
                if (rap->lifetime) {
                        rt = inet6_makerouter(rap);
                        if (rt) {
+                               rt->rt_dflags |= RTDF_RA;
                                TAILQ_INSERT_TAIL(routes, rt, rt_next);
                                if (have_default)
                                        *have_default = true;
@@ -2285,8 +2286,10 @@ inet6_dhcproutes(struct rt_head *routes, struct dhcpcd_ctx *ctx,
                if (d6_state && d6_state->state == dstate) {
                        TAILQ_FOREACH(addr, &d6_state->addrs, next) {
                                rt = inet6_makeprefix(ifp, NULL, addr);
-                               if (rt)
+                               if (rt) {
+                                       rt->rt_dflags |= RTDF_DHCP;
                                        TAILQ_INSERT_TAIL(routes, rt, rt_next);
+                               }
                        }
                }
        }
index ec4ea1c384521ff1c16fa98f92c84bbfb6463ad7..6080c9d988e8e9d376e1a06d718c7b83189f3e19 100644 (file)
@@ -76,6 +76,7 @@ struct rt {
 #define        RTDF_IFA_ROUTE          0x02            /* Address generated route */
 #define        RTDF_FAKE               0x04            /* Maybe us on lease reboot  */
 #define        RTDF_RA                 0x08            /* Router Advertisement */
+#define        RTDF_DHCP               0x10            /* DHCP route */
 };
 TAILQ_HEAD(rt_head, rt);