summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-07-08 07:56:51 +0000
committermpi <mpi@openbsd.org>2015-07-08 07:56:51 +0000
commitfaac79873b1e71cb90d17e29da5b962d260ca477 (patch)
treeca7ced0e672ab304016dd855af7e715f9c7c4190
parentunifdef IN6_IFSTAT_STRICT. (diff)
downloadwireguard-openbsd-faac79873b1e71cb90d17e29da5b962d260ca477.tar.xz
wireguard-openbsd-faac79873b1e71cb90d17e29da5b962d260ca477.zip
Use a new RTF_CONNECTED flag for interface (connected) routes.
Recent changes to support multiple interface routes broke the assumption made by all our userland routing daemons concerning interface routes. Historically such routes had a "gateway" sockaddr of type AF_LINK. But to be able to support multiple interface routes as any other multipath routes, they now have a unique "gateway" sockaddr containing their corresponding IP address. This self-describing flag should avoid ambiguity when dealing with interface routes. Issue reported by <mxb AT alumni DOT chalmers DOT se> and benno@ ok claudio@, benno@
-rw-r--r--sys/net/route.h3
-rw-r--r--sys/netinet/in.c7
-rw-r--r--sys/netinet6/nd6_rtr.c8
3 files changed, 9 insertions, 9 deletions
diff --git a/sys/net/route.h b/sys/net/route.h
index 46caaaa91ed..3f6a938653f 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.107 2015/07/08 07:29:24 mpi Exp $ */
+/* $OpenBSD: route.h,v 1.108 2015/07/08 07:56:51 mpi Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -140,6 +140,7 @@ struct rtentry {
#define RTF_MPLS 0x100000 /* MPLS additional infos */
#define RTF_LOCAL 0x200000 /* route to a local address */
#define RTF_BROADCAST 0x400000 /* route associated to a bcast addr. */
+#define RTF_CONNECTED 0x800000 /* interface route */
/* mask of RTF flags that are allowed to be modified by RTM_CHANGE */
#define RTF_FMASK \
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 89c56060bbe..d1fa710c892 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.119 2015/07/06 09:01:58 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.120 2015/07/08 07:56:51 mpi Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -731,7 +731,8 @@ in_insert_prefix(struct in_ifaddr *ia)
struct ifaddr *ifa = &ia->ia_ifa;
int error;
- error = rt_ifa_add(ifa, RTF_UP | RTF_CLONING, ifa->ifa_addr);
+ error = rt_ifa_add(ifa, RTF_UP | RTF_CLONING | RTF_CONNECTED,
+ ifa->ifa_addr);
if (error)
return (error);
@@ -747,7 +748,7 @@ in_remove_prefix(struct in_ifaddr *ia)
{
struct ifaddr *ifa = &ia->ia_ifa;
- rt_ifa_del(ifa, 0, ifa->ifa_addr);
+ rt_ifa_del(ifa, RTF_CLONING | RTF_CONNECTED, ifa->ifa_addr);
if (ia->ia_broadaddr.sin_addr.s_addr != 0)
rt_ifa_del(ifa, RTF_HOST | RTF_BROADCAST, ifa->ifa_broadaddr);
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 9acef421b86..6eeb29149cb 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.107 2015/06/16 11:09:40 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.108 2015/07/08 07:56:51 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -1735,12 +1735,10 @@ nd6_prefix_onlink(struct nd_prefix *pr)
mask6.sin6_len = sizeof(mask6);
mask6.sin6_addr = pr->ndpr_mask;
- /* rtrequest1() will probably set RTF_UP, but we're not sure. */
- rtflags = RTF_UP;
if (nd6_need_cache(ifp))
- rtflags |= RTF_CLONING;
+ rtflags = (RTF_UP | RTF_CLONING | RTF_CONNECTED);
else
- rtflags &= ~RTF_CLONING;
+ rtflags = RTF_UP;
bzero(&info, sizeof(info));
info.rti_flags = rtflags;