diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-10-02 12:21:21 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-10-02 12:21:21 +0000 |
commit | f24c8f3415f22204fea5dbc1504cf7874244138d (patch) | |
tree | e32c3a468d2aba9fae368fbf04377919587f9688 | |
parent | 0be45033cb5620385299fd442398807db5bb60bb (diff) |
Local routes that do not translate a protocol address into a link-layer
address should not be flagged with RTF_LLINFO.
With this fix, arp(8) will no longer report an incomplete entry for lo0.
ok claudio@
-rw-r--r-- | sys/net/route.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 4daee68b8b9..a16c04b3151 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.184 2014/10/01 08:38:29 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.185 2014/10/02 12:21:20 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1202,6 +1202,7 @@ void rt_ifa_addloop(struct ifaddr *ifa) { struct rtentry *rt; + u_int flags = RTF_HOST|RTF_LOCAL; /* * If the configured address correspond to the magical "any" @@ -1225,11 +1226,13 @@ rt_ifa_addloop(struct ifaddr *ifa) break; } + if (!ISSET(ifa->ifa_ifp->if_flags, (IFF_LOOPBACK|IFF_POINTOPOINT))) + flags |= RTF_LLINFO; + /* If there is no loopback entry, allocate one. */ rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); - if (rt == NULL || (rt->rt_flags & (RTF_HOST|RTF_LLINFO|RTF_LOCAL)) == 0) - rt_ifa_add(ifa, RTF_UP| RTF_HOST | RTF_LLINFO | RTF_LOCAL, - ifa->ifa_addr); + if (rt == NULL || !ISSET(rt->rt_flags, flags)); + rt_ifa_add(ifa, RTF_UP | flags, ifa->ifa_addr); if (rt) rt->rt_refcnt--; } @@ -1241,6 +1244,7 @@ void rt_ifa_delloop(struct ifaddr *ifa) { struct rtentry *rt; + u_int flags = RTF_HOST|RTF_LOCAL; /* * We do not add local routes for such address, so do not bother @@ -1262,6 +1266,9 @@ rt_ifa_delloop(struct ifaddr *ifa) break; } + if (!ISSET(ifa->ifa_ifp->if_flags, (IFF_LOOPBACK|IFF_POINTOPOINT))) + flags |= RTF_LLINFO; + /* * Before deleting, check if a corresponding local host * route surely exists. With this check, we can avoid to @@ -1271,9 +1278,8 @@ rt_ifa_delloop(struct ifaddr *ifa) * to a shared medium. */ rt = rtalloc1(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); - if (rt != NULL && (rt->rt_flags & (RTF_HOST|RTF_LLINFO|RTF_LOCAL)) != 0) - rt_ifa_del(ifa, RTF_HOST | RTF_LLINFO | RTF_LOCAL, - ifa->ifa_addr); + if (rt != NULL && ISSET(rt->rt_flags, flags)) + rt_ifa_del(ifa, flags, ifa->ifa_addr); if (rt) rt->rt_refcnt--; } |