svn commit: r360014 - in head/sys: net netinet netinet6

Alexander V. Chernikov melifaro at FreeBSD.org
Thu Apr 16 17:20:20 UTC 2020


Author: melifaro
Date: Thu Apr 16 17:20:18 2020
New Revision: 360014
URL: https://svnweb.freebsd.org/changeset/base/360014

Log:
  Add nhop parameter to rti_filter callback.
  
  One of the goals of the new routing KPI defined in r359823 is to
   entirely hide`struct rtentry` from the consumers. It will allow to
   improve routing subsystem internals and deliver more features much faster.
  This change is one of the ongoing changes to eliminate direct
   struct rtentry field accesses.
  
  Additionally, with the followup multipath changes, single rtentry can point
   to multiple nexthops.
  
  With that in mind, convert rti_filter callback used when traversing the
   routing table to accept pair (rt, nhop) instead of nexthop.
  
  Reviewed by:	ae
  Differential Revision:	https://reviews.freebsd.org/D24440

Modified:
  head/sys/net/route.c
  head/sys/net/route.h
  head/sys/net/route_temporal.c
  head/sys/netinet/in_rmx.c
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/net/route.c
==============================================================================
--- head/sys/net/route.c	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/net/route.c	Thu Apr 16 17:20:18 2020	(r360014)
@@ -143,7 +143,8 @@ EVENTHANDLER_LIST_DEFINE(rt_addrmsg);
 
 static int rt_getifa_fib(struct rt_addrinfo *, u_int);
 static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *);
-static int rt_ifdelroute(const struct rtentry *rt, void *arg);
+static int rt_ifdelroute(const struct rtentry *rt, const struct nhop_object *,
+    void *arg);
 static struct rtentry *rt_unlinkrte(struct rib_head *rnh,
     struct rt_addrinfo *info, int *perror);
 static void rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info);
@@ -1124,6 +1125,7 @@ rt_foreach_fib_walk_del(int family, rt_filter_f_t *fil
  *
  * Arguments:
  *	rt	pointer to rtentry
+ *	nh	pointer to nhop
  *	arg	argument passed to rnh->rnh_walktree() - detaching interface
  *
  * Returns:
@@ -1131,11 +1133,11 @@ rt_foreach_fib_walk_del(int family, rt_filter_f_t *fil
  *	errno	failed - reason indicated
  */
 static int
-rt_ifdelroute(const struct rtentry *rt, void *arg)
+rt_ifdelroute(const struct rtentry *rt, const struct nhop_object *nh, void *arg)
 {
 	struct ifnet	*ifp = arg;
 
-	if (rt->rt_ifp != ifp)
+	if (nh->nh_ifp != ifp)
 		return (0);
 
 	/*
@@ -1203,7 +1205,7 @@ rt_unlinkrte(struct rib_head *rnh, struct rt_addrinfo 
 	}
 
 	if (info->rti_filter != NULL) {
-		if (info->rti_filter(rt, info->rti_filterdata) == 0) {
+		if (info->rti_filter(rt, rt->rt_nhop, info->rti_filterdata)==0){
 			/* Not matched */
 			*perror = ENOENT;
 			return (NULL);

Modified: head/sys/net/route.h
==============================================================================
--- head/sys/net/route.h	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/net/route.h	Thu Apr 16 17:20:18 2020	(r360014)
@@ -346,7 +346,8 @@ struct rt_msghdr {
 #define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest addr */
 #define RTAX_MAX	8	/* size of array to allocate */
 
-typedef int rt_filter_f_t(const struct rtentry *, void *);
+typedef int rt_filter_f_t(const struct rtentry *, const struct nhop_object *,
+    void *);
 
 struct rt_addrinfo {
 	int	rti_addrs;			/* Route RTF_ flags */

Modified: head/sys/net/route_temporal.c
==============================================================================
--- head/sys/net/route_temporal.c	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/net/route_temporal.c	Thu Apr 16 17:20:18 2020	(r360014)
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
  * Updates time of the next nearest route expiration as a side effect.
  */
 static int
-expire_route(const struct rtentry *rt, void *arg)
+expire_route(const struct rtentry *rt, const struct nhop_object *nh, void *arg)
 {
 	time_t *next_callout;
 

Modified: head/sys/netinet/in_rmx.c
==============================================================================
--- head/sys/netinet/in_rmx.c	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/netinet/in_rmx.c	Thu Apr 16 17:20:18 2020	(r360014)
@@ -228,14 +228,15 @@ struct in_ifadown_arg {
 };
 
 static int
-in_ifadownkill(const struct rtentry *rt, void *xap)
+in_ifadownkill(const struct rtentry *rt, const struct nhop_object *nh,
+    void *xap)
 {
 	struct in_ifadown_arg *ap = xap;
 
-	if (rt->rt_ifa != ap->ifa)
+	if (nh->nh_ifa != ap->ifa)
 		return (0);
 
-	if ((rt->rt_flags & RTF_STATIC) != 0 && ap->del == 0)
+	if ((nhop_get_rtflags(nh) & RTF_STATIC) != 0 && ap->del == 0)
 		return (0);
 
 	return (1);

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/netinet6/nd6.c	Thu Apr 16 17:20:18 2020	(r360014)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/route/nhop.h>
 #include <net/vnet.h>
 
 #include <netinet/in.h>
@@ -1526,14 +1527,15 @@ nd6_free(struct llentry **lnp, int gc)
 }
 
 static int
-nd6_isdynrte(const struct rtentry *rt, void *xap)
+nd6_isdynrte(const struct rtentry *rt, const struct nhop_object *nh, void *xap)
 {
 
-	if (rt->rt_flags == (RTF_UP | RTF_HOST | RTF_DYNAMIC))
+	if (nh->nh_flags & NHF_REDIRECT)
 		return (1);
 
 	return (0);
 }
+
 /*
  * Remove the rtentry for the given llentry,
  * both of which were installed by a redirect.

Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c	Thu Apr 16 16:59:37 2020	(r360013)
+++ head/sys/netinet6/nd6_rtr.c	Thu Apr 16 17:20:18 2020	(r360014)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <net/if_types.h>
 #include <net/if_dl.h>
 #include <net/route.h>
+#include <net/route/nhop.h>
 #include <net/route_var.h>
 #include <net/radix.h>
 #include <net/vnet.h>
@@ -2392,15 +2393,16 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege
 }
 
 static int
-rt6_deleteroute(const struct rtentry *rt, void *arg)
+rt6_deleteroute(const struct rtentry *rt, const struct nhop_object *nh,
+    void *arg)
 {
-#define SIN6(s)	((struct sockaddr_in6 *)s)
 	struct in6_addr *gate = (struct in6_addr *)arg;
+	int nh_rt_flags;
 
-	if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)
+	if (nh->gw_sa.sa_family != AF_INET6)
 		return (0);
 
-	if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) {
+	if (!IN6_ARE_ADDR_EQUAL(gate, &nh->gw6_sa.sin6_addr)) {
 		return (0);
 	}
 
@@ -2409,14 +2411,15 @@ rt6_deleteroute(const struct rtentry *rt, void *arg)
 	 * XXX: this seems to be a bit ad-hoc. Should we consider the
 	 * 'cloned' bit instead?
 	 */
-	if ((rt->rt_flags & RTF_STATIC) != 0)
+	nh_rt_flags = nhop_get_rtflags(nh);
+	if ((nh_rt_flags & RTF_STATIC) != 0)
 		return (0);
 
 	/*
 	 * We delete only host route. This means, in particular, we don't
 	 * delete default route.
 	 */
-	if ((rt->rt_flags & RTF_HOST) == 0)
+	if ((nh_rt_flags & RTF_HOST) == 0)
 		return (0);
 
 	return (1);


More information about the svn-src-all mailing list