summaryrefslogtreecommitdiff
path: root/sys/netinet6/nd6_rtr.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-06-09 12:56:45 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-06-09 12:56:45 +0000
commitfc77128692a5f0fb03085fc33d6ed756520089e7 (patch)
tree9ab3234059541ed4ae9936d3f53638dc0d70b517 /sys/netinet6/nd6_rtr.c
parentd360538bb2d58e3ac0bca9799d4bd9cb59c0b4ac (diff)
Replace rtrequest(RTM_DELETE...) rtrequest_delete() and do not even
try to remove a route from the table if it is and invalid cache. This is a step towards decoupling code dealing with userland and kernel inserted routes. ok bluhm@
Diffstat (limited to 'sys/netinet6/nd6_rtr.c')
-rw-r--r--sys/netinet6/nd6_rtr.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index ec22c1c71df..ff087ae81b8 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.160 2017/06/07 13:28:02 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.161 2017/06/09 12:56:44 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -716,7 +716,7 @@ defrouter_delreq(struct nd_defrouter *dr)
info.rti_info[RTAX_GATEWAY] = sin6tosa(&gw);
info.rti_info[RTAX_NETMASK] = sin6tosa(&mask);
- error = rtrequest(RTM_DELETE, &info, RTP_DEFAULT, &rt,
+ error = rtrequest_delete(&info, RTP_DEFAULT, dr->ifp, &rt,
dr->ifp->if_rdomain);
if (error == 0) {
KERNEL_LOCK();
@@ -2040,10 +2040,11 @@ rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
int
rt6_deleteroute(struct rtentry *rt, void *arg, unsigned int id)
{
+ struct ifnet *ifp;
struct rt_addrinfo info;
struct in6_addr *gate = (struct in6_addr *)arg;
struct sockaddr_in6 sa_mask;
- int error;
+ int error = 0;
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
return (0);
@@ -2066,14 +2067,16 @@ rt6_deleteroute(struct rtentry *rt, void *arg, unsigned int id)
if ((rt->rt_flags & RTF_HOST) == 0)
return (0);
- bzero(&info, sizeof(info));
- info.rti_flags = rt->rt_flags;
- info.rti_info[RTAX_DST] = rt_key(rt);
- info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
- info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
- error = rtrequest(RTM_DELETE, &info, RTP_ANY, NULL, id);
- if (error != 0)
- return (error);
+ ifp = if_get(rt->rt_ifidx);
+ if (ifp != NULL) {
+ bzero(&info, sizeof(info));
+ info.rti_flags = rt->rt_flags;
+ info.rti_info[RTAX_DST] = rt_key(rt);
+ info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
+ info.rti_info[RTAX_NETMASK] = rt_plen2mask(rt, &sa_mask);
+ error = rtrequest_delete(&info, RTP_ANY, ifp, NULL, id);
+ }
+ if_put(ifp);
- return (EAGAIN);
+ return (error != 0 ? error : EAGAIN);
}