diff options
author | 2019-02-10 22:32:26 +0000 | |
---|---|---|
committer | 2019-02-10 22:32:26 +0000 | |
commit | 62cb75b3d3b9b47dc6f600ff7c083b7204d49739 (patch) | |
tree | c5b1fab62317cb8db7fb1034e3abca13f3977c81 | |
parent | Simplify NFS check (diff) | |
download | wireguard-openbsd-62cb75b3d3b9b47dc6f600ff7c083b7204d49739.tar.xz wireguard-openbsd-62cb75b3d3b9b47dc6f600ff7c083b7204d49739.zip |
remove the implict RTF_MPATH flag that rt_ifa_add() sets on new routes.
MPLS interfaces (ab)use rt_ifa_add for adding the local MPLS label
that they listen on for incoming packets, while every other use of
rt_ifa_add is for adding addresses on local interfaces. MPLS does
this cos the addresses involved are in basically the same shape as
ones used for setting up local addresses.
It is appropriate for interfaces to want RTF_MPATH on local addresses,
but in the MPLS case it means you can have multiple local things
listening on the same label, which doesn't actually work. mpe in
particular keeps track of in use labels to it can handle collisions,
however, mpw does not. It is currently possible to have multiple
mpw interfaces on the same local label, and sharing the same label
as mpe or possible normal forwarding labels.
Moving the RTF_MPATH flag out of rt_ifa_add means all the callers
that still want it need to pass it themselves. The mpe and mpw
callers are left alone without the flag, and will now get EEXIST
from rt_ifa_add when a label is already in use.
ok (and a huge amount of patience and help) mpi@
claudio@ is ok with the idea, but saw a much much earlier solution
to the problem
-rw-r--r-- | sys/net/route.c | 6 | ||||
-rw-r--r-- | sys/netinet/in.c | 9 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.c | 4 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 8 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 4 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 2 |
6 files changed, 18 insertions, 15 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index ff3142d6548..657e507a4e4 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.379 2018/11/23 16:24:11 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.380 2019/02/10 22:32:26 dlg Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1042,7 +1042,7 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) memset(&info, 0, sizeof(info)); info.rti_ifa = ifa; - info.rti_flags = flags | RTF_MPATH; + info.rti_flags = flags; info.rti_info[RTAX_DST] = dst; if (flags & RTF_LLINFO) info.rti_info[RTAX_GATEWAY] = sdltosa(ifp->if_sadl); @@ -1177,7 +1177,7 @@ rt_ifa_addlocal(struct ifaddr *ifa) /* If there is no local entry, allocate one. */ rt = rtalloc(ifa->ifa_addr, 0, ifa->ifa_ifp->if_rdomain); if (rt == NULL || ISSET(rt->rt_flags, flags) != flags) - error = rt_ifa_add(ifa, flags, ifa->ifa_addr); + error = rt_ifa_add(ifa, flags | RTF_MPATH, ifa->ifa_addr); rtfree(rt); return (error); diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 49fe289999f..64ed3ee50b9 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.160 2018/07/11 21:18:23 nayden Exp $ */ +/* $OpenBSD: in.c,v 1.161 2019/02/10 22:32:26 dlg Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -694,7 +694,7 @@ in_purgeaddr(struct ifaddr *ifa) int in_addhost(struct in_ifaddr *ia, struct sockaddr_in *dst) { - return rt_ifa_add(&ia->ia_ifa, RTF_HOST, sintosa(dst)); + return rt_ifa_add(&ia->ia_ifa, RTF_HOST | RTF_MPATH, sintosa(dst)); } int @@ -712,12 +712,13 @@ in_insert_prefix(struct in_ifaddr *ia) struct ifaddr *ifa = &ia->ia_ifa; int error; - error = rt_ifa_add(ifa, RTF_CLONING | RTF_CONNECTED, ifa->ifa_addr); + error = rt_ifa_add(ifa, RTF_CLONING | RTF_CONNECTED | RTF_MPATH, + ifa->ifa_addr); if (error) return (error); if (ia->ia_broadaddr.sin_addr.s_addr != 0) - error = rt_ifa_add(ifa, RTF_HOST | RTF_BROADCAST, + error = rt_ifa_add(ifa, RTF_HOST | RTF_BROADCAST | RTF_MPATH, ifa->ifa_broadaddr); return (error); diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 3efae2186e7..e56eea13914 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.123 2018/10/10 11:46:59 reyk Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.124 2019/02/10 22:32:26 dlg Exp $ */ /* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */ /* @@ -1308,7 +1308,7 @@ rt_mcast_add(struct ifnet *ifp, struct sockaddr *origin, struct sockaddr *group) return (NULL); } - rv = rt_ifa_add(ifa, RTF_HOST | RTF_MULTICAST, group); + rv = rt_ifa_add(ifa, RTF_HOST | RTF_MULTICAST | RTF_MPATH, group); if (rv != 0) { DPRINTF("rt_ifa_add failed (%d)", rv); return (NULL); diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index da31e0e7922..29b325dbf8c 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.228 2018/10/05 07:06:09 florian Exp $ */ +/* $OpenBSD: in6.c,v 1.229 2019/02/10 22:32:26 dlg Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -376,7 +376,8 @@ in6_ioctl_change_ifaddr(u_long cmd, caddr_t data, struct ifnet *ifp) break; /* No need to install a connected route. */ } - error = rt_ifa_add(&ia6->ia_ifa, RTF_CLONING | RTF_CONNECTED, + error = rt_ifa_add(&ia6->ia_ifa, + RTF_CLONING | RTF_CONNECTED | RTF_MPATH, ia6->ia_ifa.ifa_addr); if (error) { in6_purgeaddr(&ia6->ia_ifa); @@ -982,7 +983,8 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia6, int newhost) if ((ifp->if_flags & IFF_POINTOPOINT) && plen == 128 && ia6->ia_dstaddr.sin6_family == AF_INET6) { ifa = &ia6->ia_ifa; - error = rt_ifa_add(ifa, RTF_HOST, ifa->ifa_dstaddr); + error = rt_ifa_add(ifa, RTF_HOST | RTF_MPATH, + ifa->ifa_dstaddr); if (error != 0) return (error); ia6->ia_flags |= IFA_ROUTE; diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 5640c8d95ec..77da29d7d1a 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.111 2018/10/05 07:06:09 florian Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.112 2019/02/10 22:32:26 dlg Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -374,7 +374,7 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct in6_addr *ifid) return (0); /* No need to install a connected route. */ } - flags = RTF_CONNECTED; + flags = RTF_CONNECTED | RTF_MPATH; if ((ifp->if_flags & IFF_POINTOPOINT) == 0) flags |= RTF_CLONING; diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 089cddb4502..3171c631174 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1241,7 +1241,7 @@ mrt6_mcast6_add(struct ifnet *ifp, struct sockaddr *origin, return NULL; } - rv = rt_ifa_add(ifa, RTF_HOST | RTF_MULTICAST, group); + rv = rt_ifa_add(ifa, RTF_HOST | RTF_MULTICAST | RTF_MPATH, group); if (rv != 0) { DPRINTF("rt_ifa_add failed %d", rv); return NULL; |