From patchwork Mon Dec 18 16:45:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Acayan X-Patchwork-Id: 180560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1374373dyi; Mon, 18 Dec 2023 08:46:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQjcNDHUE2AH54NsRTzaq05RugFgRivB+YGDG9Lo71zUQ2K8YRvfXT11X7T79ZF0DrNU1J X-Received: by 2002:a05:6a00:1941:b0:6ce:4941:c52d with SMTP id s1-20020a056a00194100b006ce4941c52dmr18474386pfk.68.1702917964871; Mon, 18 Dec 2023 08:46:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702917964; cv=none; d=google.com; s=arc-20160816; b=OeKNdr7oq+7VrjXhSaQHVsquttbX3RZ4lC1ZG9WYHd8nzDJ9+PIKqruVi2KUQZCvo9 8/fdqBoSfMP8KEwUkV+7TdBX08kDKV+ES54LexdiCI+M0wrysFyiQIuECWvhsyqtwvBH 5juQ9Oaj7z4e+Nc1MLsA6k1HLMU8Q75MmwKeaLMh3rG+5zrSsfo8IpnlFKcAA8feUXcJ eyKqxk5fa/K3wirstQNvKKix/X+CiAUOopGi4q1TrRuwWCo8vQ158qAUBIeAhXErmJoK 4XFmDoAlrkfdVTHoQy0H6RMf1DHTJeeON5+WT+4pSSh7wJbgS+FEN5LJgEIRDBheCC2d oQZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=kZBaEcaOfw2v5PuhZIuGx5Nh4ffB6hmj27S27SIqM0U=; fh=wIS3vq8rL1qEsvq/TpU1Cv+MDBARwitXcGgrCjulS+M=; b=pZqnjDqnMRNclp7TaqH4mtSzNypED7DyIfwlbNVigw46ioFPXCIQcwWathuiynRCRd JHpNhZJf93vS/G3dGH4kqjjq1qNqGUfRjyPGvLWQNHahhfGpdqPKSdNAgzGJ10gWu7WM XUzHFKSicNtJN5h82lrYTvh05qG8TpUd4qHaIselDVzAUi0hU4bN1zdRIehFhbPoxa5x EjGk5cCJ6UxscFHpseO0iJomzJdGomW6syVFH7AbPyUPRTAgMlbYI5Ue2pJDf/N81cVH BrpfX7vtfjVAuX6dFzxKnD6H7jV3W/QiMvfqh23+H6KWyEX7Vx4HrCDhHlPaoSw6n2ze zKrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="RfMt/8N8"; spf=pass (google.com: domain of linux-kernel+bounces-4086-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4086-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bk6-20020a056a02028600b00577616e3ad9si18333395pgb.871.2023.12.18.08.46.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:46:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4086-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="RfMt/8N8"; spf=pass (google.com: domain of linux-kernel+bounces-4086-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4086-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4CA752853E1 for ; Mon, 18 Dec 2023 16:46:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B0AD4FF7D; Mon, 18 Dec 2023 16:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RfMt/8N8" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DEBD6FB6; Mon, 18 Dec 2023 16:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-202ffc46e15so1001485fac.1; Mon, 18 Dec 2023 08:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702917944; x=1703522744; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kZBaEcaOfw2v5PuhZIuGx5Nh4ffB6hmj27S27SIqM0U=; b=RfMt/8N8ISkeYyAid+dJCGNfMapEDGNvi+ZVGVye764Ay7DC+frAaEtcTHbx12jC/I n21pQ+MSCkCS36s4Ko2rJL/nVRipfirxGD4Sw+BbjERSecvyhyH61e4C4dYfcrx8AISG WyXxi6n6xNU4RCHPdRZQjHy3CAE4JrFmYzaiXW0oJktp1P0SGt2x+AbNVct+RssstMSh Xu10SeYTdBZJENrh6cDWNxUDO3VNGxHAYPrdPFmcb6HSrc1gp6cFasZ05CSZXC+B3wYS Wu/DE0yCt741nCd8MjU/f+XUExPJZhir9MNMdJsTtGiFS5osT6XkVW9PPPPp6gn0SE4+ R1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702917944; x=1703522744; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kZBaEcaOfw2v5PuhZIuGx5Nh4ffB6hmj27S27SIqM0U=; b=Sz+t4hxtp5bC3coaHEGmmJRa1Rv9XDCAkyjoVkpq9BQtUN81tUepltsOop77AX3KJH O0A3bNxEme+YwdHsSN+AtKPRkRnkP/B9DRvgEPzawqThHhWtLDM1rnDpqTR/fX92qmGs vq5XjdJNwhhH+2ww09m4rs5+pyvewFVmCrUupRsHrkmyfBFvNGomI1kiFuRVkKkwEVR+ Hgblw/eMRB9iqc5XOL7JMwqhfArI7+dXTMWeJWN9tY3DoeF+uT38bCgif6CIkkG72hio keBPSyo4VRnuZoAs6Eqn29E8GATj6TeAun+qTQZG2bFaupoI0dhp2iEWtKgLBOB5umHR 4KBQ== X-Gm-Message-State: AOJu0YzYss05Ux+psfL0GgohGAjz13iW3oUTZa+dL/EVarR1WTjsJkks 9lJ7cioguxFHHcVxxI14YEw= X-Received: by 2002:a05:6871:890a:b0:203:9e4a:d9c0 with SMTP id ti10-20020a056871890a00b002039e4ad9c0mr1007193oab.31.1702917944490; Mon, 18 Dec 2023 08:45:44 -0800 (PST) Received: from localhost ([2607:fea8:52a3:d200::325c]) by smtp.gmail.com with ESMTPSA id c12-20020ac86e8c000000b004255183b1a4sm9374825qtv.64.2023.12.18.08.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:45:43 -0800 (PST) From: Richard Acayan To: Greg Kroah-Hartman , Hardik Gajjar , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Richard Acayan Subject: [PATCH] usb: gadget: u_ether: Re-attach netif device to mirror detachment Date: Mon, 18 Dec 2023 11:45:33 -0500 Message-ID: <20231218164532.411125-2-mailingradian@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785638908348976052 X-GMAIL-MSGID: 1785638908348976052 In 6.7-rc1, there was a netif_device_detach call added to the gether_disconnect function. This clears the __LINK_STATE_PRESENT bit of the netif device and suppresses pings (ICMP messages) and TCP connection requests from the connected host. If userspace temporarily disconnects the gadget, such as by temporarily removing configuration in the gadget configfs interface, network activity should continue to be processed when the gadget is re-connected. Mirror the netif_device_detach call with a netif_device_attach call in gether_connect to fix re-connecting gadgets. Link: https://gitlab.com/postmarketOS/pmaports/-/tree/6002e51b7090aeeb42947e0ca7ec22278d7227d0/main/postmarketos-base-ui/rootfs-usr-lib-NetworkManager-dispatcher.d-50-tethering.sh Fixes: f49449fbc21e ("usb: gadget: u_ether: Replace netif_stop_queue with netif_device_detach") Signed-off-by: Richard Acayan Tested-by: Luca Weiss Tested-by: Duje Mihanović Tested-by: Ferry Toth [mrfld] Tested-by: From: Andy Shevchenko # Intel Merrifield Tested-by: Andy Shevchenko # Intel Merrifield --- drivers/usb/gadget/function/u_ether.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 9d1c40c152d8..3c5a6f6ac341 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -1163,6 +1163,8 @@ struct net_device *gether_connect(struct gether *link) if (netif_running(dev->net)) eth_start(dev, GFP_ATOMIC); + netif_device_attach(dev->net); + /* on error, disable any endpoints */ } else { (void) usb_ep_disable(link->out_ep);