From c73f4b62daca8b4421b315de76f626e26eec01fd Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Sun, 11 May 2008 08:13:03 +0000 Subject: rtrequest to rtrequest1 conversion in inet6. With that no rtrequest should be left over. OK henning@ --- sys/netinet6/icmp6.c | 32 ++++++++++++++++++-------- sys/netinet6/in6.c | 11 ++++++--- sys/netinet6/in6_ifattach.c | 31 +++++++++++++++++-------- sys/netinet6/nd6.c | 25 ++++++++++++++------- sys/netinet6/nd6_rtr.c | 55 ++++++++++++++++++++++++++++++++------------- 5 files changed, 110 insertions(+), 44 deletions(-) diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index e2a343f77d4..2083fb4c9a0 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.96 2008/03/08 01:52:35 sthen Exp $ */ +/* $OpenBSD: icmp6.c,v 1.97 2008/05/11 08:13:02 claudio Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -2783,12 +2783,14 @@ icmp6_mtudisc_clone(dst) /* If we didn't get a host route, allocate one */ if ((rt->rt_flags & RTF_HOST) == 0) { + struct rt_addrinfo info; struct rtentry *nrt; - error = rtrequest((int) RTM_ADD, dst, - (struct sockaddr *) rt->rt_gateway, - (struct sockaddr *) 0, - RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC, &nrt, 0); + bzero(&info, sizeof(info)); + info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC; + info.rti_info[RTAX_DST] = dst; + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + error = rtrequest1(RTM_ADD, &info, rt->rt_priority, &nrt, 0); if (error) { rtfree(rt); return NULL; @@ -2816,8 +2818,14 @@ icmp6_mtudisc_timeout(rt, r) panic("icmp6_mtudisc_timeout: bad route to timeout"); if ((rt->rt_flags & (RTF_DYNAMIC | RTF_HOST)) == (RTF_DYNAMIC | RTF_HOST)) { - rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt), - rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0, 0); + struct rt_addrinfo info; + + 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_mask(rt); + rtrequest1(RTM_DELETE, &info, rt->rt_priority, NULL, 0); } else { if (!(rt->rt_rmx.rmx_locks & RTV_MTU)) rt->rt_rmx.rmx_mtu = 0; @@ -2833,8 +2841,14 @@ icmp6_redirect_timeout(rt, r) panic("icmp6_redirect_timeout: bad route to timeout"); if ((rt->rt_flags & (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) == (RTF_GATEWAY | RTF_DYNAMIC | RTF_HOST)) { - rtrequest((int) RTM_DELETE, (struct sockaddr *)rt_key(rt), - rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0, 0); + struct rt_addrinfo info; + + 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_mask(rt); + rtrequest1(RTM_DELETE, &info, rt->rt_priority, NULL, 0); } } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 27015a5ce96..e15fd857c37 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.74 2008/05/07 05:14:21 claudio Exp $ */ +/* $OpenBSD: in6.c,v 1.75 2008/05/11 08:13:02 claudio Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -141,6 +141,7 @@ struct multi6_kludge { static void in6_ifloop_request(int cmd, struct ifaddr *ifa) { + struct rt_addrinfo info; struct sockaddr_in6 lo_sa; struct sockaddr_in6 all1_sa; struct rtentry *nrt = NULL; @@ -162,8 +163,12 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa) * which changes the outgoing interface to the loopback interface. * XXX only table 0 for now */ - e = rtrequest(cmd, ifa->ifa_addr, ifa->ifa_addr, - (struct sockaddr *)&all1_sa, RTF_UP|RTF_HOST|RTF_LLINFO, &nrt, 0); + bzero(&info, sizeof(info)); + info.rti_flags = RTF_UP | RTF_HOST | RTF_LLINFO; + info.rti_info[RTAX_DST] = ifa->ifa_addr; + info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&all1_sa; + e = rtrequest1(cmd, &info, RTP_CONNECTED, &nrt, 0); if (e != 0) { log(LOG_ERR, "in6_ifloop_request: " "%s operation failed for %s (errno=%d)\n", diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 073a781ea4e..f8ad0e655a7 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.45 2007/06/08 09:31:38 henning Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.46 2008/05/11 08:13:02 claudio Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -633,7 +633,6 @@ in6_ifdetach(ifp) struct in6_ifaddr *ia, *oia; struct ifaddr *ifa, *next; struct rtentry *rt; - short rtflags; struct sockaddr_in6 sin6; struct in6_multi_mship *imm; @@ -678,12 +677,20 @@ in6_ifdetach(ifp) /* remove from the routing table */ if ((ia->ia_flags & IFA_ROUTE) && (rt = rtalloc1((struct sockaddr *)&ia->ia_addr, 0, 0))) { - rtflags = rt->rt_flags; + struct rt_addrinfo info; + u_int8_t prio; + + bzero(&info, sizeof(info)); + info.rti_flags = rt->rt_flags; + prio = rt->rt_priority; + info.rti_info[RTAX_DST] = + (struct sockaddr *)&ia->ia_addr; + info.rti_info[RTAX_GATEWAY] = + (struct sockaddr *)&ia->ia_addr; + info.rti_info[RTAX_NETMASK] = + (struct sockaddr *)&ia->ia_prefixmask; rtfree(rt); - rtrequest(RTM_DELETE, (struct sockaddr *)&ia->ia_addr, - (struct sockaddr *)&ia->ia_addr, - (struct sockaddr *)&ia->ia_prefixmask, - rtflags, (struct rtentry **)0, 0); + rtrequest1(RTM_DELETE, &info, prio, NULL, 0); } /* remove from the linked list */ @@ -730,8 +737,14 @@ in6_ifdetach(ifp) sin6.sin6_addr.s6_addr16[1] = htons(ifp->if_index); rt = rtalloc1((struct sockaddr *)&sin6, 0, 0); if (rt && rt->rt_ifp == ifp) { - rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt), - rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0, 0); + struct rt_addrinfo info; + + 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_mask(rt); + rtrequest1(RTM_DELETE, &info, rt->rt_priority, NULL, 0); rtfree(rt); } } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 05229c032a1..35906a9e1f1 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.76 2008/05/11 03:50:23 krw Exp $ */ +/* $OpenBSD: nd6.c,v 1.77 2008/05/11 08:13:02 claudio Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -698,6 +698,7 @@ nd6_lookup(addr6, create, ifp) } if (!rt) { if (create && ifp) { + struct rt_addrinfo info; int e; /* @@ -716,12 +717,17 @@ nd6_lookup(addr6, create, ifp) * Create a new route. RTF_LLINFO is necessary * to create a Neighbor Cache entry for the * destination in nd6_rtrequest which will be - * called in rtrequest via ifa->ifa_rtrequest. + * called in rtrequest1 via ifa->ifa_rtrequest. */ - if ((e = rtrequest(RTM_ADD, (struct sockaddr *)&sin6, - ifa->ifa_addr, (struct sockaddr *)&all1_sa, - (ifa->ifa_flags | RTF_HOST | RTF_LLINFO) & - ~RTF_CLONING, &rt, 0)) != 0) { + bzero(&info, sizeof(info)); + info.rti_flags = (ifa->ifa_flags | RTF_HOST | + RTF_LLINFO) & ~RTF_CLONING; + info.rti_info[RTAX_DST] = (struct sockaddr *)&sin6; + info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; + info.rti_info[RTAX_NETMASK] = + (struct sockaddr *)&all1_sa; + if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, + &rt, 0)) != 0) { #if 0 log(LOG_ERR, "nd6_lookup: failed to add route for a " @@ -837,6 +843,7 @@ nd6_free(rt, gc) struct rtentry *rt; int gc; { + struct rt_addrinfo info; struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next; struct in6_addr in6 = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr; struct nd_defrouter *dr; @@ -929,8 +936,10 @@ nd6_free(rt, gc) * caches, and disable the route entry not to be used in already * cached routes. */ - rtrequest(RTM_DELETE, rt_key(rt), (struct sockaddr *)0, - rt_mask(rt), 0, (struct rtentry **)0, 0); + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + rtrequest1(RTM_DELETE, &info, rt->rt_priority, NULL, 0); return (next); } diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 3d38253cc2f..97a04993151 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.44 2007/10/01 16:39:30 krw Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.45 2008/05/11 08:13:02 claudio Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -439,6 +439,7 @@ void defrouter_addreq(new) struct nd_defrouter *new; { + struct rt_addrinfo info; struct sockaddr_in6 def, mask, gate; struct rtentry *newrt = NULL; int s; @@ -447,6 +448,7 @@ defrouter_addreq(new) Bzero(&def, sizeof(def)); Bzero(&mask, sizeof(mask)); Bzero(&gate, sizeof(gate)); /* for safety */ + Bzero(&info, sizeof(info)); def.sin6_len = mask.sin6_len = gate.sin6_len = sizeof(struct sockaddr_in6); @@ -454,10 +456,13 @@ defrouter_addreq(new) gate.sin6_addr = new->rtaddr; gate.sin6_scope_id = 0; /* XXX */ + info.rti_flags = RTF_GATEWAY; + info.rti_info[RTAX_DST] = (struct sockaddr *)&def; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&gate; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; + s = splsoftnet(); - error = rtrequest(RTM_ADD, (struct sockaddr *)&def, - (struct sockaddr *)&gate, (struct sockaddr *)&mask, - RTF_GATEWAY, &newrt, 0); + error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &newrt, 0); if (newrt) { nd6_rtmsg(RTM_ADD, newrt); /* tell user process */ newrt->rt_refcnt--; @@ -535,6 +540,7 @@ static void defrouter_delreq(dr) struct nd_defrouter *dr; { + struct rt_addrinfo info; struct sockaddr_in6 def, mask, gw; struct rtentry *oldrt = NULL; @@ -543,6 +549,7 @@ defrouter_delreq(dr) panic("dr == NULL in defrouter_delreq"); #endif + Bzero(&info, sizeof(info)); Bzero(&def, sizeof(def)); Bzero(&mask, sizeof(mask)); Bzero(&gw, sizeof(gw)); /* for safety */ @@ -553,15 +560,18 @@ defrouter_delreq(dr) gw.sin6_addr = dr->rtaddr; gw.sin6_scope_id = 0; /* XXX */ - rtrequest(RTM_DELETE, (struct sockaddr *)&def, - (struct sockaddr *)&gw, - (struct sockaddr *)&mask, RTF_GATEWAY, &oldrt, 0); + info.rti_flags = RTF_GATEWAY; + info.rti_info[RTAX_DST] = (struct sockaddr *)&def; + info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&gw; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; + + rtrequest1(RTM_DELETE, &info, RTP_CONNECTED, &oldrt, 0); if (oldrt) { nd6_rtmsg(RTM_DELETE, oldrt); if (oldrt->rt_refcnt <= 0) { /* * XXX: borrowed from the RTM_DELETE case of - * rtrequest(). + * rtrequest1(). */ oldrt->rt_refcnt++; rtfree(oldrt); @@ -1409,6 +1419,7 @@ int nd6_prefix_onlink(pr) struct nd_prefix *pr; { + struct rt_addrinfo info; struct ifaddr *ifa; struct ifnet *ifp = pr->ndpr_ifp; struct sockaddr_in6 mask6; @@ -1481,7 +1492,7 @@ nd6_prefix_onlink(pr) bzero(&mask6, sizeof(mask6)); mask6.sin6_len = sizeof(mask6); mask6.sin6_addr = pr->ndpr_mask; - /* rtrequest() will probably set RTF_UP, but we're not sure. */ + /* rtrequest1() will probably set RTF_UP, but we're not sure. */ rtflags = ifa->ifa_flags | RTF_UP; if (nd6_need_cache(ifp)) { /* explicitly set in case ifa_flags does not set the flag. */ @@ -1492,8 +1503,14 @@ nd6_prefix_onlink(pr) */ rtflags &= ~RTF_CLONING; } - error = rtrequest(RTM_ADD, (struct sockaddr *)&pr->ndpr_prefix, - ifa->ifa_addr, (struct sockaddr *)&mask6, rtflags, &rt, 0); + + bzero(&info, sizeof(info)); + info.rti_flags = rtflags; + info.rti_info[RTAX_DST] = (struct sockaddr *)&pr->ndpr_prefix; + info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6; + + error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &rt, 0); if (error == 0) { if (rt != NULL) /* this should be non NULL, though */ nd6_rtmsg(RTM_ADD, rt); @@ -1518,6 +1535,7 @@ int nd6_prefix_offlink(pr) struct nd_prefix *pr; { + struct rt_addrinfo info; int error = 0; struct ifnet *ifp = pr->ndpr_ifp; struct nd_prefix *opr; @@ -1541,8 +1559,10 @@ nd6_prefix_offlink(pr) mask6.sin6_family = AF_INET6; mask6.sin6_len = sizeof(sa6); bcopy(&pr->ndpr_mask, &mask6.sin6_addr, sizeof(struct in6_addr)); - error = rtrequest(RTM_DELETE, (struct sockaddr *)&sa6, NULL, - (struct sockaddr *)&mask6, 0, &rt, 0); + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = (struct sockaddr *)&sa6; + info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6; + error = rtrequest1(RTM_DELETE, &info, RTP_CONNECTED, &rt, 0); if (error == 0) { pr->ndpr_stateflags &= ~NDPRF_ONLINK; @@ -1800,6 +1820,7 @@ rt6_deleteroute(rn, arg) void *arg; { #define SIN6(s) ((struct sockaddr_in6 *)s) + struct rt_addrinfo info; struct rtentry *rt = (struct rtentry *)rn; struct in6_addr *gate = (struct in6_addr *)arg; @@ -1824,8 +1845,12 @@ rt6_deleteroute(rn, arg) if ((rt->rt_flags & RTF_HOST) == 0) return (0); - return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, - rt_mask(rt), rt->rt_flags, 0, 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_mask(rt); + return (rtrequest1(RTM_DELETE, &info, RTP_CONNECTED, NULL, 0)); #undef SIN6 } -- cgit v1.2.3