git: 61ba094af4b4 - stable/14 - netfront: fix the support for disabling LRO at boot time

From: Doug Rabson <dfr_at_FreeBSD.org>
Date: Sun, 12 Nov 2023 11:31:15 UTC
The branch stable/14 has been updated by dfr:

URL: https://cgit.FreeBSD.org/src/commit/?id=61ba094af4b4798bf2887c30af5c14d66ead706f

commit 61ba094af4b4798bf2887c30af5c14d66ead706f
Author:     Doug Rabson <dfr@FreeBSD.org>
AuthorDate: 2023-08-12 13:19:47 +0000
Commit:     Doug Rabson <dfr@FreeBSD.org>
CommitDate: 2023-11-12 10:37:16 +0000

    netfront: fix the support for disabling LRO at boot time
    
    The driver has a tunable hw.xn.enable_lro which is intended to control
    whether LRO is enabled. This is currently non-functional - even if its
    set to zero, the driver still requests LRO support from the backend.
    This change fixes the feature so that if enable_lro is set to zero, LRO
    no longer appears in the interface capabilities and LRO is not requested
    from the backend.
    
    PR:             273046
    MFC after:      1 week
    Reviewed by:    royger
    Differential Revision: https://reviews.freebsd.org/D41439
    
    (cherry picked from commit da4b0d6eb06d730487d48e15d2d5e10c56266fd9)
---
 sys/dev/xen/netfront/netfront.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index b4e7722552e6..dafb838cf328 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -2272,7 +2272,7 @@ int
 create_netdev(device_t dev)
 {
 	struct netfront_info *np;
-	int err;
+	int err, cap_enabled;
 	if_t ifp;
 
 	np = device_get_softc(dev);
@@ -2304,7 +2304,11 @@ create_netdev(device_t dev)
 	if_sethwassist(ifp, XN_CSUM_FEATURES);
 	/* Enable all supported features at device creation. */
 	if_setcapabilities(ifp, IFCAP_HWCSUM|IFCAP_TSO4|IFCAP_LRO);
-	if_setcapenable(ifp, if_getcapabilities(ifp));
+	cap_enabled = if_getcapabilities(ifp);
+	if (!xn_enable_lro) {
+		cap_enabled &= ~IFCAP_LRO;
+	}
+	if_setcapenable(ifp, cap_enabled);
 
 	if_sethwtsomax(ifp, 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN));
 	if_sethwtsomaxsegcount(ifp, MAX_TX_REQ_FRAGS);