Date: Wed, 22 Apr 2020 07:53:44 +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: r360191 - in head/sys: dev/cxgbe/tom netinet Message-ID: <202004220753.03M7riFt061764@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Wed Apr 22 07:53:43 2020 New Revision: 360191 URL: https://svnweb.freebsd.org/changeset/base/360191 Log: Convert TOE routing lookups to the new routing KPI. Reviewed by: np Differential Revision: https://reviews.freebsd.org/D24388 Modified: head/sys/dev/cxgbe/tom/t4_connect.c head/sys/dev/cxgbe/tom/t4_tom.h head/sys/netinet/tcp_offload.c head/sys/netinet/toecore.c head/sys/netinet/toecore.h Modified: head/sys/dev/cxgbe/tom/t4_connect.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_connect.c Wed Apr 22 07:47:04 2020 (r360190) +++ head/sys/dev/cxgbe/tom/t4_connect.c Wed Apr 22 07:53:43 2020 (r360191) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <net/if_types.h> #include <net/if_vlan_var.h> #include <net/route.h> +#include <net/route/nhop.h> #include <netinet/in.h> #include <netinet/in_pcb.h> #include <netinet/ip.h> @@ -226,13 +227,13 @@ act_open_cpl_size(struct adapter *sc, int isipv6) * rtalloc1, RT_UNLOCK on rt. */ int -t4_connect(struct toedev *tod, struct socket *so, struct rtentry *rt, +t4_connect(struct toedev *tod, struct socket *so, struct nhop_object *nh, struct sockaddr *nam) { struct adapter *sc = tod->tod_softc; struct toepcb *toep = NULL; struct wrqe *wr = NULL; - struct ifnet *rt_ifp = rt->rt_ifp; + struct ifnet *rt_ifp = nh->nh_ifp; struct vi_info *vi; int qid_atid, rc, isipv6; struct inpcb *inp = sotoinpcb(so); @@ -277,7 +278,7 @@ t4_connect(struct toedev *tod, struct socket *so, stru DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM); toep->l2te = t4_l2t_get(vi->pi, rt_ifp, - rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway : nam); + nh->nh_flags & NHF_GATEWAY ? &nh->gw_sa : nam); if (toep->l2te == NULL) DONT_OFFLOAD_ACTIVE_OPEN(ENOMEM); Modified: head/sys/dev/cxgbe/tom/t4_tom.h ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.h Wed Apr 22 07:47:04 2020 (r360190) +++ head/sys/dev/cxgbe/tom/t4_tom.h Wed Apr 22 07:53:43 2020 (r360191) @@ -370,7 +370,7 @@ int add_tid_to_history(struct adapter *, u_int); /* t4_connect.c */ void t4_init_connect_cpl_handlers(void); void t4_uninit_connect_cpl_handlers(void); -int t4_connect(struct toedev *, struct socket *, struct rtentry *, +int t4_connect(struct toedev *, struct socket *, struct nhop_object *, struct sockaddr *); void act_open_failure_cleanup(struct adapter *, u_int, u_int); Modified: head/sys/netinet/tcp_offload.c ============================================================================== --- head/sys/netinet/tcp_offload.c Wed Apr 22 07:47:04 2020 (r360190) +++ head/sys/netinet/tcp_offload.c Wed Apr 22 07:53:43 2020 (r360191) @@ -41,8 +41,11 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/if_var.h> #include <net/route.h> +#include <net/route/nhop.h> #include <netinet/in.h> #include <netinet/in_pcb.h> +#include <netinet/in_fib.h> +#include <netinet6/in6_fib.h> #include <netinet/tcp.h> #include <netinet/tcp_offload.h> #define TCPOUTFLAGS @@ -60,7 +63,8 @@ tcp_offload_connect(struct socket *so, struct sockaddr { struct ifnet *ifp; struct toedev *tod; - struct rtentry *rt; + struct nhop_object *nh; + struct epoch_tracker et; int error = EOPNOTSUPP; INP_WLOCK_ASSERT(sotoinpcb(so)); @@ -70,13 +74,20 @@ tcp_offload_connect(struct socket *so, struct sockaddr if (registered_toedevs == 0) return (error); - rt = rtalloc1(nam, 0, 0); - if (rt) - RT_UNLOCK(rt); - else + NET_EPOCH_ENTER(et); + nh = NULL; + if (nam->sa_family == AF_INET) + nh = fib4_lookup(0, ((struct sockaddr_in *)nam)->sin_addr, + NHR_NONE, 0, 0); + else if (nam->sa_family == AF_INET6) + nh = fib6_lookup(0, &((struct sockaddr_in6 *)nam)->sin6_addr, + NHR_NONE, 0, 0); + if (nh == NULL) { + NET_EPOCH_EXIT(et); return (EHOSTUNREACH); + } - ifp = rt->rt_ifp; + ifp = nh->nh_ifp; if (nam->sa_family == AF_INET && !(ifp->if_capenable & IFCAP_TOE4)) goto done; @@ -85,9 +96,9 @@ tcp_offload_connect(struct socket *so, struct sockaddr tod = TOEDEV(ifp); if (tod != NULL) - error = tod->tod_connect(tod, so, rt, nam); + error = tod->tod_connect(tod, so, nh, nam); done: - RTFREE(rt); + NET_EPOCH_EXIT(et); return (error); } Modified: head/sys/netinet/toecore.c ============================================================================== --- head/sys/netinet/toecore.c Wed Apr 22 07:47:04 2020 (r360190) +++ head/sys/netinet/toecore.c Wed Apr 22 07:53:43 2020 (r360191) @@ -77,7 +77,7 @@ static eventhandler_tag lle_event_eh; static int toedev_connect(struct toedev *tod __unused, struct socket *so __unused, - struct rtentry *rt __unused, struct sockaddr *nam __unused) + struct nhop_object *nh __unused, struct sockaddr *nam __unused) { return (ENOTSUP); @@ -138,7 +138,7 @@ toedev_l2_update(struct toedev *tod __unused, struct i static void toedev_route_redirect(struct toedev *tod __unused, struct ifnet *ifp __unused, - struct rtentry *rt0 __unused, struct rtentry *rt1 __unused) + struct nhop_object *nh0 __unused, struct nhop_object *nh1 __unused) { return; Modified: head/sys/netinet/toecore.h ============================================================================== --- head/sys/netinet/toecore.h Wed Apr 22 07:47:04 2020 (r360190) +++ head/sys/netinet/toecore.h Wed Apr 22 07:53:43 2020 (r360191) @@ -41,6 +41,7 @@ struct tcpopt; struct tcphdr; struct in_conninfo; struct tcp_info; +struct nhop_object; struct ktls_session; struct toedev { @@ -51,7 +52,7 @@ struct toedev { * Active open. If a failure occurs, it is reported back by the driver * via toe_connect_failed. */ - int (*tod_connect)(struct toedev *, struct socket *, struct rtentry *, + int (*tod_connect)(struct toedev *, struct socket *, struct nhop_object *, struct sockaddr *); /* Passive open. */ @@ -95,7 +96,7 @@ struct toedev { /* XXX. Route has been redirected. */ void (*tod_route_redirect)(struct toedev *, struct ifnet *, - struct rtentry *, struct rtentry *); + struct nhop_object *, struct nhop_object *); /* Syncache interaction. */ void (*tod_syncache_added)(struct toedev *, void *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004220753.03M7riFt061764>