MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcp_offload_connect

Function tcp_offload_connect

freebsd/netinet/tcp_offload.c:62–111  ·  view source on GitHub ↗

* Provide an opportunity for a TOE driver to offload. */

Source from the content-addressed store, hash-verified

60 * Provide an opportunity for a TOE driver to offload.
61 */
62int
63tcp_offload_connect(struct socket *so, struct sockaddr *nam)
64{
65 struct ifnet *ifp;
66 struct toedev *tod;
67 struct nhop_object *nh;
68 struct epoch_tracker et;
69 int error = EOPNOTSUPP;
70
71 INP_WLOCK_ASSERT(sotoinpcb(so));
72 KASSERT(nam->sa_family == AF_INET || nam->sa_family == AF_INET6,
73 ("%s: called with sa_family %d", __func__, nam->sa_family));
74
75 if (registered_toedevs == 0)
76 return (error);
77
78 NET_EPOCH_ENTER(et);
79 nh = NULL;
80#ifdef INET
81 if (nam->sa_family == AF_INET)
82 nh = fib4_lookup(0, ((struct sockaddr_in *)nam)->sin_addr,
83 NHR_NONE, 0, 0);
84#endif
85#if defined(INET) && defined(INET6)
86 else
87#endif
88#ifdef INET6
89 if (nam->sa_family == AF_INET6)
90 nh = fib6_lookup(0, &((struct sockaddr_in6 *)nam)->sin6_addr,
91 NHR_NONE, 0, 0);
92#endif
93 if (nh == NULL) {
94 NET_EPOCH_EXIT(et);
95 return (EHOSTUNREACH);
96 }
97
98 ifp = nh->nh_ifp;
99
100 if (nam->sa_family == AF_INET && !(ifp->if_capenable & IFCAP_TOE4))
101 goto done;
102 if (nam->sa_family == AF_INET6 && !(ifp->if_capenable & IFCAP_TOE6))
103 goto done;
104
105 tod = TOEDEV(ifp);
106 if (tod != NULL)
107 error = tod->tod_connect(tod, so, nh, nam);
108done:
109 NET_EPOCH_EXIT(et);
110 return (error);
111}
112
113void
114tcp_offload_listen_start(struct tcpcb *tp)

Callers 2

tcp_usr_connectFunction · 0.85
tcp6_usr_connectFunction · 0.85

Calls 2

fib4_lookupFunction · 0.85
fib6_lookupFunction · 0.85

Tested by

no test coverage detected