Add nhop to the ifa_rtrequest() callback.

With the upcoming multipath changes described in D24141,
 rt->rt_nhop can potentially point to a nexthop group instead of
 an individual nhop.
To simplify caller handling of such cases, change ifa_rtrequest() callback
 to pass changed nhop directly.

Differential Revision:	https://reviews.freebsd.org/D24604
This commit is contained in:
melifaro 2020-04-29 19:28:56 +00:00
parent c24a037915
commit 2338a28d9e
3 changed files with 12 additions and 9 deletions

View File

@ -61,6 +61,7 @@
*/
struct rtentry; /* ifa_rtrequest */
struct nhop_object; /* ifa_rtrequest */
struct rt_addrinfo; /* ifa_rtrequest */
struct socket;
struct carp_if;
@ -551,7 +552,8 @@ struct ifaddr {
struct carp_softc *ifa_carp; /* pointer to CARP data */
CK_STAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */
void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
(int, struct rtentry *, struct rt_addrinfo *);
(int, struct rtentry *, struct nhop_object *,
struct rt_addrinfo *);
u_short ifa_flags; /* mostly rt_flags for cloning */
#define IFA_ROUTE RTF_UP /* route installed */
#define IFA_RTSELF RTF_HOST /* loopback route to self installed */

View File

@ -1239,7 +1239,7 @@ rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info)
*/
ifa = rt->rt_ifa;
if (ifa != NULL && ifa->ifa_rtrequest != NULL)
ifa->ifa_rtrequest(RTM_DELETE, rt, info);
ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop, info);
/*
* One more rtentry floating around that is not
@ -1761,7 +1761,7 @@ add_route(struct rib_head *rnh, struct rt_addrinfo *info,
* allow it to do that as well.
*/
if (ifa->ifa_rtrequest)
ifa->ifa_rtrequest(RTM_ADD, rt, info);
ifa->ifa_rtrequest(RTM_ADD, rt, rt->rt_nhop, info);
/*
* actually return a resultant rtentry and
@ -1886,7 +1886,8 @@ change_route(struct rib_head *rnh, struct rt_addrinfo *info,
if (info->rti_ifa != NULL && info->rti_ifa != rt->rt_ifa &&
rt->rt_ifa != NULL) {
if (rt->rt_ifa->ifa_rtrequest != NULL)
rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, info);
rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop,
info);
ifa_free(rt->rt_ifa);
rt->rt_ifa = NULL;
}
@ -1910,7 +1911,7 @@ change_route(struct rib_head *rnh, struct rt_addrinfo *info,
rt->rt_flags |= info->rti_flags & RTF_FMASK;
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL)
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info);
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, nh, info);
/* Alter route MTU if necessary */
if (rt->rt_ifp != NULL) {

View File

@ -138,7 +138,8 @@ static void nd6_free_redirect(const struct llentry *);
static void nd6_llinfo_timer(void *);
static void nd6_llinfo_settimer_locked(struct llentry *, long);
static void clear_llinfo_pqueue(struct llentry *);
static void nd6_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
static void nd6_rtrequest(int, struct rtentry *, struct nhop_object *,
struct rt_addrinfo *);
static int nd6_resolve_slow(struct ifnet *, int, struct mbuf *,
const struct sockaddr_in6 *, u_char *, uint32_t *, struct llentry **);
static int nd6_need_cache(struct ifnet *);
@ -1562,13 +1563,12 @@ nd6_free_redirect(const struct llentry *ln)
* processing.
*/
void
nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info)
nd6_rtrequest(int req, struct rtentry *rt, struct nhop_object *nh,
struct rt_addrinfo *info)
{
struct sockaddr_in6 *gateway;
struct nd_defrouter *dr;
struct nhop_object *nh;
nh = rt->rt_nhop;
gateway = &nh->gw6_sa;
switch (req) {