diff --git a/sys/dev/cxgb/ulp/toecore/toedev.c b/sys/dev/cxgb/ulp/toecore/toedev.c index 07a0d6e94feb..8a6b39f650cd 100644 --- a/sys/dev/cxgb/ulp/toecore/toedev.c +++ b/sys/dev/cxgb/ulp/toecore/toedev.c @@ -119,6 +119,7 @@ int register_tom(struct tom_info *t) { mtx_lock(&offload_db_lock); + toedev_registration_count++; TAILQ_INSERT_HEAD(&offload_module_list, t, entry); mtx_unlock(&offload_db_lock); return 0; diff --git a/sys/netinet/tcp_offload.c b/sys/netinet/tcp_offload.c index ec1fe2382357..604aab02cff1 100644 --- a/sys/netinet/tcp_offload.c +++ b/sys/netinet/tcp_offload.c @@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$"); #include #include +uint32_t toedev_registration_count; + int tcp_offload_connect(struct socket *so, struct sockaddr *nam) { @@ -59,12 +61,15 @@ tcp_offload_connect(struct socket *so, struct sockaddr *nam) struct rtentry *rt; int error; + if (toedev_registration_count == 0) + return (EINVAL); + /* * Look up the route used for the connection to * determine if it uses an interface capable of * offloading the connection. */ - rt = rtalloc1(nam, 1 /*report*/, 0 /*ignflags*/); + rt = rtalloc1(nam, 0 /*report*/, 0 /*ignflags*/); if (rt) RT_UNLOCK(rt); else diff --git a/sys/netinet/toedev.h b/sys/netinet/toedev.h index 4bce203bd94e..7edaca126faa 100644 --- a/sys/netinet/toedev.h +++ b/sys/netinet/toedev.h @@ -34,6 +34,8 @@ #error "no user-serviceable parts inside" #endif +extern uint32_t toedev_registration_count; + /* Parameter values for offload_get_phys_egress(). */ enum { TOE_OPEN,