From owner-svn-src-head@freebsd.org Wed Apr 22 07:53:45 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 307432AA183; Wed, 22 Apr 2020 07:53:45 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 496XkK0XbZz3N8s; Wed, 22 Apr 2020 07:53:45 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DC3AF83E; Wed, 22 Apr 2020 07:53:45 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03M7ri7K061768; Wed, 22 Apr 2020 07:53:44 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03M7riFt061764; Wed, 22 Apr 2020 07:53:44 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202004220753.03M7riFt061764@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Wed, 22 Apr 2020 07:53:44 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: in head/sys: dev/cxgbe/tom netinet X-SVN-Commit-Revision: 360191 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2020 07:53:45 -0000 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 #include #include +#include #include #include #include @@ -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 #include #include +#include #include #include +#include +#include #include #include #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 *);