summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-07-02 22:36:44 +0100
committerRoy Marples <roy@marples.name>2018-07-02 22:36:44 +0100
commite7f46d3a27d7bed1ebdbc1f733afc82660588f4f (patch)
treea8b22c731fcd12f8614d6070f66fbfbd8fa6b87a
parent30cf7d4df73f58341450c6f4751f3ccedad77235 (diff)
downloaddhcpcd-e7f46d3a27d7bed1ebdbc1f733afc82660588f4f.tar.xz
linux: set RTF_HOST correctly when reading kernel routes.
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.
-rw-r--r--src/if-linux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/if-linux.c b/src/if-linux.c
index 3196c9df..abd4cd52 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -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) {