Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2304639rdb; Sun, 3 Dec 2023 10:51:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvc0g1nlXSm7nLhfCFrturtAi3u0BcVvQ10jHnMTLzMoVBQwS3/ftCscBhLkJxzFggIsaf X-Received: by 2002:a05:6a21:1487:b0:18f:97c:977e with SMTP id od7-20020a056a21148700b0018f097c977emr3028098pzb.102.1701629501072; Sun, 03 Dec 2023 10:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701629501; cv=none; d=google.com; s=arc-20160816; b=WXELIQrslq5CixtULcHGaQuQeK59Z/Gv9bXiagoIbVSRATjke8Qf6gT91rz+vhepvW FJPtNv2tRSYTbkzFr5/VqSz2vPEc2ai461t2rb1xFS/75U4y03/YY24nRJqOv6630KuV P4XvetNIa45Gkcnd2IGeH14RC/tql3oXy/h1yrv8hSH12FunEuTbzjoOu475l6avt4jX hUUxgnr/q3yJCE6DAaP7LRTF166RvRga2TsS1cYpJTwLj8h9R02C8RSI4WiNUV6C+2na joziKdUyjqwFsfDQbP9v419N587haj6D1SrDHYyuZX+2mLGLPz46C/v2SgQbpJXFeMIX gfBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=QtIyW3E7F8b3M4DB9PWxzuQJmSmGS9EQPoqv9FPpM1U=; fh=33XtzQ/E2pdadowxwg/0e1DZz7ZaQldbm6WDiovYgRU=; b=d+JjRrZHn5Ijp39eLZsTxxV7c/uQfKVJQ7bsPjMS+4X0cjm9bNsUNVoXIL1xOfOjTB 8QorIW9BqkXj5jY7cJY5btta4nmJpyNFBPz9dDuEmtYlfCPTyEWs4VG+gPIFAXfa1qRw 3K0OEJMEMMDxKk7jJL8kFnjyb384XqFXbqJBQI40kfm+zvL2qDrl9FJZ5nMhD+9CoLgU As3L/Y7ZNco8/S5x8A7/vdHuBaO9xWET5XWZj8Gp5ly+NHwKdDJ6ml34eLl2buhD6wob U3Q0/tkA7DpoW7Zuc22MfZfJMTB88i8QfEPeFxWAl1WT9WInS0wchzAfzMTyoRNLDrGh 5zpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=qW2pjun2; spf=pass (google.com: domain of linux-wireless+bounces-340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a9-20020a656049000000b005b95fbb1750si6763034pgp.113.2023.12.03.10.51.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 10:51:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=qW2pjun2; spf=pass (google.com: domain of linux-wireless+bounces-340-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net 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 EC1F7280D8D for ; Sun, 3 Dec 2023 18:51:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A27517983; Sun, 3 Dec 2023 18:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="qW2pjun2" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:242:246e::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC8CDA; Sun, 3 Dec 2023 10:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=QtIyW3E7F8b3M4DB9PWxzuQJmSmGS9EQPoqv9FPpM1U=; t=1701629492; x=1702839092; b=qW2pjun2tRXyr19yfLBkGwYew6Y3r9bPL8/A1+kUKplDeZ/ ldV0TjT8AuTI6EQf5FdMCs8UydjJ7/wcK16uVGcGEQaPH1/V+ePaTPiXhGh0yDmlt8HXGCY+oypML GxAjWy9sUmxhqQab/5yTX0UilJ8KYQqjIyFrb/DMwTW9xcwNZFJrtGDUIrTXfKsW42OkHEwSrRCIK 96vhJpnlc0s5UUVRTjglvwx0ZmbUJJFOZonjgZHDOKXCuX+j0vB1T+/lXgTwoSD5pDFekeeCb7NZ1 v0W8K6zNHREu+E2lHN39L0kh8ZCp659iMY24kQWvWRrbu1MIDSCjBSR+vqTt0YuA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1r9rYv-0000000DmPt-3GxJ; Sun, 03 Dec 2023 19:51:30 +0100 Message-ID: Subject: Re: [PATCH wireless-next 0/3] netlink carrier race workaround From: Johannes Berg To: Jakub Kicinski Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Date: Sun, 03 Dec 2023 19:51:28 +0100 In-Reply-To: <20231202104655.68138ab4@kernel.org> References: <346b21d87c69f817ea3c37caceb34f1f56255884.camel@sipsolutions.net> <20231201104329.25898-5-johannes@sipsolutions.net> <20231201162844.14d1bbb0@kernel.org> <339c73a6318bf94803a821d5e8ea7d4c736dc78e.camel@sipsolutions.net> <20231202104655.68138ab4@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-malware-bazaar: not-scanned On Sat, 2023-12-02 at 10:46 -0800, Jakub Kicinski wrote: > On Sat, 02 Dec 2023 11:06:36 +0100 Johannes Berg wrote: > > > Would it work if we exposed "linkwatch is pending" / "link is > > > transitioning" bit to user space? =20 > >=20 > > Not sure, not by much or more than what this did? It's basically the > > same, I think: I exposed the carrier_up_count at the kernel time, so if > > userspace hasn't seen an event with a value >=3D that it knows the link= is > > transitioning. >=20 > The benefit being that it'd work for everyone, without having to add > the carrier count in random events? Well, true. You'd still have to add random rtnl_getlink() calls to your userspace, and then wait for an event if it's transitioning? Actually a bit _more_ complicated since then we'd have to do rtnl_getlink() after receiving the assoc event, and then wait if still transitioning. Or I guess we could do it when sending a frame there in the tests, but it's another call into the kernel vs. getting the information we need in the event. But yeah honestly I don't mind that either, and maybe it helps address some other use cases like what Andrew had in mind in his reply to my original thread. > > > Even crazier, would it help if we had rtnl_getlink() run > > > linkwatch for the target link if linkwatch is pending? =20 > >=20 > > Sure, if we were to just synchronize that at the right time (doesn't > > even need to be rtnl_getlink, could be a new operation) that'd solve th= e > > issue too, perhaps more easily. >=20 > I was wondering about the new op, too, but "synchronize things please" > op feels a little hacky. Agree ... but then again it's all a bit hacky. You can even read "carrier is on" when it's really not yet ready... > rtnl_getlink returns link state, so it feels > somewhat natural for it to do the sync, to make sure that what it > returns is in fact correct information. Yeah that's a good point that I just mentioned above though - today the kernel will happily return a state that it's not actually willing to honour yet, i.e. if you actively read the state, you'll see carrier on before the kernel is actually willing to transmit packets on the link. Fixing that _would_ be nice, but I'm somewhat worried that it will cause performance regressions to always sync there? OTOH, it would hopefully not actually have to wait most of the time since link_watch isn't always pending... > rtnl_getlink does return a lot, so maybe a new rtnl_getcarrier op? Does it matter? Just another attribute ... > Or we can make reading sysfs "carrier" do the sync? I think I wouldn't mind now, and perhaps if we want to sync in netlink we should also do this here so that it's consistent, but I'm not sure I'd want this to be the only way to do it, I might imagine that someone might want this in some kind of container that doesn't necessarily have (full) access there? Dunno. We _could_ also use an input attribute on the rtnl_getlink() call to have userspace explicitly opt in to doing the sync before returning information? johannes