Date: Sun, 19 Jul 2020 10:53:15 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363320 - in head/sys: fs/nfsclient net netinet6 Message-ID: <202007191053.06JArFsg093352@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Sun Jul 19 10:53:15 2020 New Revision: 363320 URL: https://svnweb.freebsd.org/changeset/base/363320 Log: Temporarly revert r363319 to unbreak the build. Reported by: CI Pointy hat to: melifaro Modified: head/sys/fs/nfsclient/nfs_clvfsops.c head/sys/net/if.c head/sys/net/route.c head/sys/net/route.h head/sys/netinet6/in6_rmx.c head/sys/netinet6/in6_var.h head/sys/netinet6/nd6.c head/sys/netinet6/nd6_rtr.c Modified: head/sys/fs/nfsclient/nfs_clvfsops.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clvfsops.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/fs/nfsclient/nfs_clvfsops.c Sun Jul 19 10:53:15 2020 (r363320) @@ -68,7 +68,6 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/route.h> -#include <net/route/route_ctl.h> #include <netinet/in.h> #include <fs/nfs/nfsport.h> @@ -467,8 +466,6 @@ nfs_mountroot(struct mount *mp) nd->mygateway.sin_addr.s_addr != 0) { struct sockaddr_in mask, sin; struct epoch_tracker et; - struct rt_addrinfo info; - struct rib_cmd_info rc; bzero((caddr_t)&mask, sizeof(mask)); sin = mask; @@ -477,14 +474,10 @@ nfs_mountroot(struct mount *mp) /* XXX MRT use table 0 for this sort of thing */ NET_EPOCH_ENTER(et); CURVNET_SET(TD_TO_VNET(td)); - - bzero((caddr_t)&info, sizeof(info)); - info.rti_flags = RTF_UP | RTF_GATEWAY; - info.rti_info[RTAX_DST] = (struct sockaddr *)&sin; - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&nd->mygateway; - info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; - - error = rib_action(RT_DEFAULT_FIB, RTM_ADD, &info, &rc); + error = rtrequest_fib(RTM_ADD, (struct sockaddr *)&sin, + (struct sockaddr *)&nd->mygateway, + (struct sockaddr *)&mask, + RTF_UP | RTF_GATEWAY, NULL, RT_DEFAULT_FIB); CURVNET_RESTORE(); NET_EPOCH_EXIT(et); if (error) Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/net/if.c Sun Jul 19 10:53:15 2020 (r363320) @@ -80,7 +80,6 @@ #include <net/if_vlan_var.h> #include <net/radix.h> #include <net/route.h> -#include <net/route/route_ctl.h> #include <net/vnet.h> #if defined(INET) || defined(INET6) @@ -1846,7 +1845,6 @@ static int ifa_maintain_loopback_route(int cmd, const char *otype, struct ifaddr *ifa, struct sockaddr *ia) { - struct rib_cmd_info rc; struct epoch_tracker et; int error; struct rt_addrinfo info; @@ -1874,7 +1872,7 @@ ifa_maintain_loopback_route(int cmd, const char *otype info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl; link_init_sdl(ifp, (struct sockaddr *)&null_sdl, ifp->if_type); - error = rib_action(ifp->if_fib, cmd, &info, &rc); + error = rtrequest1_fib(cmd, &info, NULL, ifp->if_fib); NET_EPOCH_EXIT(et); if (rti_ifa != NULL) Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/net/route.c Sun Jul 19 10:53:15 2020 (r363320) @@ -470,7 +470,7 @@ int rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway, struct sockaddr *author, struct ifnet *ifp, int flags, int lifetime_sec) { - struct rib_cmd_info rc; + struct rtentry *rt; int error; struct rt_addrinfo info; struct rt_metrics rti_rmx; @@ -504,7 +504,7 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, s info.rti_mflags |= RTV_EXPIRE; info.rti_rmx = &rti_rmx; - error = rib_action(fibnum, RTM_ADD, &info, &rc); + error = rtrequest1_fib(RTM_ADD, &info, &rt, fibnum); ifa_free(ifa); if (error != 0) { @@ -512,9 +512,9 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, s return (error); } - RT_LOCK(rc.rc_rt); - flags = rc.rc_rt->rt_flags; - RT_UNLOCK(rc.rc_rt); + RT_LOCK(rt); + flags = rt->rt_flags; + RT_UNLOCK(rt); RTSTAT_INC(rts_dynamic); @@ -602,7 +602,33 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst, return (ifa); } +/* + * Do appropriate manipulations of a routing tree given + * all the bits of info needed + */ +int +rtrequest_fib(int req, + struct sockaddr *dst, + struct sockaddr *gateway, + struct sockaddr *netmask, + int flags, + struct rtentry **ret_nrt, + u_int fibnum) +{ + struct rt_addrinfo info; + if (dst->sa_len == 0) + return(EINVAL); + + bzero((caddr_t)&info, sizeof(info)); + info.rti_flags = flags; + info.rti_info[RTAX_DST] = dst; + info.rti_info[RTAX_GATEWAY] = gateway; + info.rti_info[RTAX_NETMASK] = netmask; + return rtrequest1_fib(req, &info, ret_nrt, fibnum); +} + + /* * Copy most of @rt data into @info. * @@ -1122,6 +1148,73 @@ rt_mpath_unlink(struct rib_head *rnh, struct rt_addrin } #endif +int +rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, + u_int fibnum) +{ + const struct sockaddr *dst; + struct rib_head *rnh; + struct rib_cmd_info rc; + int error; + + KASSERT((fibnum < rt_numfibs), ("rtrequest1_fib: bad fibnum")); + KASSERT((info->rti_flags & RTF_RNH_LOCKED) == 0, ("rtrequest1_fib: locked")); + NET_EPOCH_ASSERT(); + + dst = info->rti_info[RTAX_DST]; + + switch (dst->sa_family) { + case AF_INET6: + case AF_INET: + /* We support multiple FIBs. */ + break; + default: + fibnum = RT_DEFAULT_FIB; + break; + } + + /* + * Find the correct routing tree to use for this Address Family + */ + rnh = rt_tables_get_rnh(fibnum, dst->sa_family); + if (rnh == NULL) + return (EAFNOSUPPORT); + + /* + * If we are adding a host route then we don't want to put + * a netmask in the tree, nor do we want to clone it. + */ + if (info->rti_flags & RTF_HOST) + info->rti_info[RTAX_NETMASK] = NULL; + + bzero(&rc, sizeof(struct rib_cmd_info)); + error = 0; + switch (req) { + case RTM_DELETE: + error = del_route(rnh, info, &rc); + break; + case RTM_RESOLVE: + /* + * resolve was only used for route cloning + * here for compat + */ + break; + case RTM_ADD: + error = add_route(rnh, info, &rc); + break; + case RTM_CHANGE: + error = change_route(rnh, info, &rc); + break; + default: + error = EOPNOTSUPP; + } + + if (ret_nrt != NULL) + *ret_nrt = rc.rc_rt; + + return (error); +} + void rt_setmetrics(const struct rt_addrinfo *info, struct rtentry *rt) { @@ -1165,7 +1258,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi struct epoch_tracker et; struct sockaddr *dst; struct sockaddr *netmask; - struct rib_cmd_info rc; + struct rtentry *rt = NULL; struct rt_addrinfo info; int error = 0; int startfib, endfib; @@ -1256,7 +1349,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi if (rn == NULL) error = ESRCH; else { - struct rtentry *rt = RNTORT(rn); + rt = RNTORT(rn); /* * for interface route the gateway * gateway is sockaddr_dl, so @@ -1296,14 +1389,14 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; info.rti_info[RTAX_NETMASK] = netmask; NET_EPOCH_ENTER(et); - error = rib_action(fibnum, cmd, &info, &rc); - if (error == 0 && rc.rc_rt != NULL) { + error = rtrequest1_fib(cmd, &info, &rt, fibnum); + if (error == 0 && rt != NULL) { /* * notify any listening routing agents of the change */ /* TODO: interface routes/aliases */ - rt_newaddrmsg_fib(cmd, ifa, rc.rc_rt, fibnum); + rt_newaddrmsg_fib(cmd, ifa, rt, fibnum); didwork = 1; } NET_EPOCH_EXIT(et); Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/net/route.h Sun Jul 19 10:53:15 2020 (r363320) @@ -411,6 +411,9 @@ int rtinit(struct ifaddr *, int, int); * but this will change.. */ int rtioctl_fib(u_long, caddr_t, u_int); +int rtrequest_fib(int, struct sockaddr *, + struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); +int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); int rib_lookup_info(uint32_t, const struct sockaddr *, uint32_t, uint32_t, struct rt_addrinfo *); void rib_free_info(struct rt_addrinfo *info); Modified: head/sys/netinet6/in6_rmx.c ============================================================================== --- head/sys/netinet6/in6_rmx.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/netinet6/in6_rmx.c Sun Jul 19 10:53:15 2020 (r363320) @@ -185,3 +185,14 @@ in6_detachhead(void **head, int off) } #endif +/* + * Extended API for IPv6 FIB support. + */ +int +in6_rtrequest(int req, struct sockaddr *dst, struct sockaddr *gw, + struct sockaddr *mask, int flags, struct rtentry **ret_nrt, u_int fibnum) +{ + + return (rtrequest_fib(req, dst, gw, mask, flags, ret_nrt, fibnum)); +} + Modified: head/sys/netinet6/in6_var.h ============================================================================== --- head/sys/netinet6/in6_var.h Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/netinet6/in6_var.h Sun Jul 19 10:53:15 2020 (r363320) @@ -915,6 +915,8 @@ void in6_newaddrmsg(struct in6_ifaddr *, int); * Extended API for IPv6 FIB support. */ struct mbuf *ip6_tryforward(struct mbuf *); +int in6_rtrequest(int, struct sockaddr *, struct sockaddr *, + struct sockaddr *, int, struct rtentry **, u_int); #endif /* _KERNEL */ #endif /* _NETINET6_IN6_VAR_H_ */ Modified: head/sys/netinet6/nd6.c ============================================================================== --- head/sys/netinet6/nd6.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/netinet6/nd6.c Sun Jul 19 10:53:15 2020 (r363320) @@ -1564,7 +1564,6 @@ nd6_free_redirect(const struct llentry *ln) int fibnum; struct sockaddr_in6 sin6; struct rt_addrinfo info; - struct rib_cmd_info rc; struct epoch_tracker et; lltable_fill_sa_entry(ln, (struct sockaddr *)&sin6); @@ -1574,7 +1573,7 @@ nd6_free_redirect(const struct llentry *ln) NET_EPOCH_ENTER(et); for (fibnum = 0; fibnum < rt_numfibs; fibnum++) - rib_action(fibnum, RTM_DELETE, &info, &rc); + rtrequest1_fib(RTM_DELETE, &info, NULL, fibnum); NET_EPOCH_EXIT(et); } Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Sun Jul 19 09:29:27 2020 (r363319) +++ head/sys/netinet6/nd6_rtr.c Sun Jul 19 10:53:15 2020 (r363320) @@ -674,8 +674,7 @@ static void defrouter_addreq(struct nd_defrouter *new) { struct sockaddr_in6 def, mask, gate; - struct rt_addrinfo info; - struct rib_cmd_info rc; + struct rtentry *newrt = NULL; unsigned int fibnum; int error; @@ -689,16 +688,11 @@ defrouter_addreq(struct nd_defrouter *new) gate.sin6_addr = new->rtaddr; fibnum = new->ifp->if_fib; - bzero((caddr_t)&info, sizeof(info)); - 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; - - NET_EPOCH_ASSERT(); - error = rib_action(fibnum, RTM_ADD, &info, &rc); - if (rc.rc_rt != NULL) - rt_routemsg(RTM_ADD, rc.rc_rt, new->ifp, 0, fibnum); + error = in6_rtrequest(RTM_ADD, (struct sockaddr *)&def, + (struct sockaddr *)&gate, (struct sockaddr *)&mask, + RTF_GATEWAY, &newrt, fibnum); + if (newrt != NULL) + rt_routemsg(RTM_ADD, newrt, new->ifp, 0, fibnum); if (error == 0) new->installed = 1; } @@ -712,8 +706,7 @@ static void defrouter_delreq(struct nd_defrouter *dr) { struct sockaddr_in6 def, mask, gate; - struct rt_addrinfo info; - struct rib_cmd_info rc; + struct rtentry *oldrt = NULL; struct epoch_tracker et; unsigned int fibnum; @@ -727,16 +720,12 @@ defrouter_delreq(struct nd_defrouter *dr) gate.sin6_addr = dr->rtaddr; fibnum = dr->ifp->if_fib; - bzero((caddr_t)&info, sizeof(info)); - 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; - NET_EPOCH_ENTER(et); - rib_action(fibnum, RTM_DELETE, &info, &rc); - if (rc.rc_rt != NULL) - rt_routemsg(RTM_DELETE, rc.rc_rt, dr->ifp, 0, fibnum); + in6_rtrequest(RTM_DELETE, (struct sockaddr *)&def, + (struct sockaddr *)&gate, + (struct sockaddr *)&mask, RTF_GATEWAY, &oldrt, fibnum); + if (oldrt != NULL) + rt_routemsg(RTM_DELETE, oldrt, dr->ifp, 0, fibnum); NET_EPOCH_EXIT(et); dr->installed = 0; @@ -2020,6 +2009,7 @@ static int nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, struct ifaddr *ifa) { struct sockaddr_dl_short sdl; + struct rtentry *rt; struct sockaddr_in6 mask6; u_long rtflags; int error, a_failure, fibnum, maxfib; @@ -2044,17 +2034,11 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, stru } a_failure = 0; for (; fibnum < maxfib; fibnum++) { - struct rt_addrinfo info; - struct rib_cmd_info rc; - bzero((caddr_t)&info, sizeof(info)); - info.rti_flags = rtflags; - info.rti_info[RTAX_DST] = (struct sockaddr *)&pr->ndpr_prefix; - info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sdl; - info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6; - - NET_EPOCH_ASSERT(); - error = rib_action(fibnum, RTM_ADD, &info, &rc); + rt = NULL; + error = in6_rtrequest(RTM_ADD, + (struct sockaddr *)&pr->ndpr_prefix, (struct sockaddr *)&sdl, + (struct sockaddr *)&mask6, rtflags, &rt, fibnum); if (error != 0) { char ip6buf[INET6_ADDRSTRLEN]; char ip6bufg[INET6_ADDRSTRLEN]; @@ -2077,7 +2061,7 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, stru } pr->ndpr_stateflags |= NDPRF_ONLINK; - rt_routemsg(RTM_ADD, rc.rc_rt, pr->ndpr_ifp, 0, fibnum); + rt_routemsg(RTM_ADD, rt, pr->ndpr_ifp, 0, fibnum); } /* Return the last error we got. */ @@ -2174,6 +2158,7 @@ nd6_prefix_offlink(struct nd_prefix *pr) struct ifnet *ifp = pr->ndpr_ifp; struct nd_prefix *opr; struct sockaddr_in6 sa6, mask6; + struct rtentry *rt; char ip6buf[INET6_ADDRSTRLEN]; uint64_t genid; int fibnum, maxfib, a_failure; @@ -2206,17 +2191,9 @@ nd6_prefix_offlink(struct nd_prefix *pr) a_failure = 0; NET_EPOCH_ENTER(et); for (; fibnum < maxfib; fibnum++) { - struct rt_addrinfo info; - struct rib_cmd_info rc; - - bzero((caddr_t)&info, sizeof(info)); - info.rti_flags = RTF_GATEWAY; - info.rti_info[RTAX_DST] = (struct sockaddr *)&sa6; - info.rti_info[RTAX_GATEWAY] = NULL; - info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask6; - - NET_EPOCH_ASSERT(); - error = rib_action(fibnum, RTM_DELETE, &info, &rc); + rt = NULL; + error = in6_rtrequest(RTM_DELETE, (struct sockaddr *)&sa6, NULL, + (struct sockaddr *)&mask6, 0, &rt, fibnum); if (error != 0) { /* Save last error to return, see rtinit(). */ a_failure = error; @@ -2224,7 +2201,7 @@ nd6_prefix_offlink(struct nd_prefix *pr) } /* report route deletion to the routing socket. */ - rt_routemsg(RTM_DELETE, rc.rc_rt, ifp, 0, fibnum); + rt_routemsg(RTM_DELETE, rt, ifp, 0, fibnum); } NET_EPOCH_EXIT(et); error = a_failure;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007191053.06JArFsg093352>