]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
linux: set RTF_HOST correctly when reading kernel routes.
authorRoy Marples <roy@marples.name>
Mon, 2 Jul 2018 21:36:44 +0000 (22:36 +0100)
committerRoy Marples <roy@marples.name>
Mon, 2 Jul 2018 21:36:44 +0000 (22:36 +0100)
Linux has no real concept of host routes, but dhcpcd does purely
for describing them.
As such, mark them has host routes if the netmask if all ones.

src/if-linux.c

index 3196c9df494315cabb2a0db7746f6cfcad021d52..abd4cd526570062153ea49e28873b7bdd614053d 100644 (file)
@@ -430,8 +430,6 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm)
        memset(rt, 0, sizeof(*rt));
        if (rtm->rtm_type == RTN_UNREACHABLE)
                rt->rt_flags |= RTF_REJECT;
-       if (rtm->rtm_scope == RT_SCOPE_HOST)
-               rt->rt_flags |= RTF_HOST;
 
        rta = (struct rtattr *)RTM_RTA(rtm);
        len = RTM_PAYLOAD(nlm);
@@ -491,6 +489,8 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm)
 
        rt->rt_netmask.sa_family = rtm->rtm_family;
        sa_fromprefix(&rt->rt_netmask, rtm->rtm_dst_len);
+       if (sa_is_allones(&rt->rt_netmask))
+               rt->rt_flags |= RTF_HOST;
 
        #if 0
        if (rt->rtp_ifp == NULL && rt->src.s_addr != INADDR_ANY) {