Index: sys/net/iflib.c =================================================================== --- sys/net/iflib.c +++ sys/net/iflib.c @@ -2467,13 +2467,28 @@ } #if defined(INET6) || defined(INET) +static void +iflib_set_lro_possible(struct lro_ctrl *lc, bool *v4, bool *v6) +{ + CURVNET_SET(lc->ifp->if_vnet); + if (VNET(ip6_forwarding) == 0) + *v6 = true; + else + *v6 = false; + if (VNET(ipforwarding) == 0) + *v4 = true; + else + *v4 = false; + CURVNET_RESTORE(); +} + /* * Returns true if it's possible this packet could be LROed. * if it returns false, it is guaranteed that tcp_lro_rx() * would not return zero. */ static bool -iflib_check_lro_possible(struct lro_ctrl *lc, struct mbuf *m) +iflib_check_lro_possible(struct mbuf *m, bool v4_lro_possible, bool v6_lro_possible) { struct ether_header *eh; uint16_t eh_type; @@ -2483,32 +2498,21 @@ switch (eh_type) { #if defined(INET6) case ETHERTYPE_IPV6: - { - CURVNET_SET(lc->ifp->if_vnet); - if (VNET(ip6_forwarding) == 0) { - CURVNET_RESTORE(); - return true; - } - CURVNET_RESTORE(); - break; - } + return v6_lro_possible; #endif #if defined (INET) case ETHERTYPE_IP: - { - CURVNET_SET(lc->ifp->if_vnet); - if (VNET(ipforwarding) == 0) { - CURVNET_RESTORE(); - return true; - } - CURVNET_RESTORE(); - break; - } + return v4_lro_possible; #endif } return false; } +#else +static void +iflib_set_lro_possible(struct lro_ctrl *lc __unused, bool *v4 __unused, bool *v6 __unused) +{ +} #endif static bool @@ -2525,6 +2529,7 @@ struct ifnet *ifp; int lro_enabled; bool lro_possible = false; + bool v4_lro_possible, v6_lro_possible; /* * XXX early demux data packets so that if_input processing only handles @@ -2601,6 +2606,8 @@ __iflib_fl_refill_lt(ctx, fl, budget + 8); lro_enabled = (if_getcapenable(ifp) & IFCAP_LRO); + if (lro_enabled) + iflib_set_lro_possible(&rxq->ifr_lc, &v4_lro_possible, &v6_lro_possible); mt = mf = NULL; while (mh != NULL) { m = mh; @@ -2615,7 +2622,7 @@ #if defined(INET6) || defined(INET) if (lro_enabled) { if (!lro_possible) { - lro_possible = iflib_check_lro_possible(&rxq->ifr_lc, m); + lro_possible = iflib_check_lro_possible(m, v4_lro_possible, v6_lro_possible); if (lro_possible && mf != NULL) { ifp->if_input(ifp, mf); DBG_COUNTER_INC(rx_if_input);