Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1797141pxy; Mon, 2 Aug 2021 10:25:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNQ7EJq2JLCJOAC3FT4xSbga8QOWahJrmI2zeImA8MTCmBh35TyiE5/jFde73WcF8h79Nx X-Received: by 2002:a05:6e02:1041:: with SMTP id p1mr387539ilj.125.1627925113365; Mon, 02 Aug 2021 10:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627925113; cv=none; d=google.com; s=arc-20160816; b=BWQt84l/faCfDA9FYt5pDAuA9oh0uBb+Bvh1LgBBG7tefOsoftL+Si4qaH26x8UnM0 ZLjPNJ1H6XAd83nCrkAa6yjdSEfSbykpoFuWPFqNwVDe0kfUnX3WzpPjeYu94m9zs+i/ 2+9KeuHIYN08N2iEC6F6XYASp3kz0lsIcmeSNSKxFHJ46P5jdrpLtfNt/qU76CYELQgY zCuxF3PF0oelB5EaWkBV9q6Uex1KyKw4JJZrPJquIsL1B/GEiKKxuUk7dIGl0EKDh/Jv WXfeQs4o5fmPF4N58NL7ts/zrfB/RDHSm/F69vKRzwVChsNdvH4Lx4duVOcYXC3WmyAU AWBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RT4eXRKDCcl8BfK+SX0AGbV1vuzFPyz2KF19rz1kIy8=; b=r1iTkmPN98lnB3OJWImf5PekfBUGFAAYIjO6feaTMUGEvHAdGWJJhS6XLUSH/XYaf7 fhpGSTygQyprXhipMWXroMzqzmZi85j3XQ/kFVdE68C1KC5/XyJp+pV8Rnq9xixb6XKF sQM3uBAyfgzC76SbdGZnzx/bHGesrspcvfuEvyiC2S9ZjG4fCxhjqbMoCugf0k0zSNYK wkJ7Q9Ml19l28GuK1aR1E89z0pNIump0GIIz2K5XNn47smK1CcxocYP9Pp7edBXLI9VO ziycTwEQbkfHSMu3iPm84z5cvO/56NfunxfOGdtuVzFpgfqM80yg/ePJB9w3ucSo+Smq L5Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIjeAMJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k16si1225285ilr.117.2021.08.02.10.25.01; Mon, 02 Aug 2021 10:25:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SIjeAMJJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232056AbhHBRX7 (ORCPT + 99 others); Mon, 2 Aug 2021 13:23:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbhHBRX6 (ORCPT ); Mon, 2 Aug 2021 13:23:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1EFA660FC2; Mon, 2 Aug 2021 17:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627925029; bh=08CK0O9jDcGZbEJKjbVu46c2LdAjn8sY3h2yyecrMeM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SIjeAMJJnVgWp9m3GEnW+1q+Fjj/OrCIjx3WjxEd10Bchn9gUoDa50Sk7tRRmElKs LisaJOVqS+VwK6LHYT3THOsy+AlEK0UDFC5g7nd4qfHK62TLStF8+XpR7S693qRY5U Rd+jghlO3wmkOLCxT+TXaomFsuAu8CssXVLRtIEbhXkbvLC4Wf/+f8N0UnTubjavz3 5923BcpL8sidn49rPd8IGcfErQAK6vs+1Ix5aWfuV8y+1BVx/Qub6+EiWP1oTLYTh8 LUBkS7+FbpixGpifuKrrp5LG8w5lQKH9+MZ2g/RqhvKosaNlugJt/TCVLSp7SG1zeA IPAlLSQiAhIuQ== Received: by pali.im (Postfix) id C0F75B98; Mon, 2 Aug 2021 19:23:46 +0200 (CEST) Date: Mon, 2 Aug 2021 19:23:46 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Guillaume Nault Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: How to find out name or id of newly created interface Message-ID: <20210802172346.yj3ia7czg6o7kgn7@pali> References: <20210731203054.72mw3rbgcjuqbf4j@pali> <20210802100238.GA3756@pc-32.home> <20210802105825.td57b5rd3d6xfxfo@pali> <20210802134320.GB3756@pc-32.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210802134320.GB3756@pc-32.home> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 02 August 2021 15:43:20 Guillaume Nault wrote: > On Mon, Aug 02, 2021 at 12:58:25PM +0200, Pali Rohár wrote: > > On Monday 02 August 2021 12:02:38 Guillaume Nault wrote: > > > > > > So the proper solution is to implement NLM_F_ECHO support for > > > RTM_NEWLINK messages (RTM_NEWROUTE is an example of netlink handler > > > that supports NLM_F_ECHO, see rtmsg_fib()). > > > > Do you know if there is some workaround / other solution which can be > > used by userspace applications now? And also with stable kernels (which > > obviously do not receive this new NLM_F_ECHO support for RTM_NEWLINK)? > > I unfortunately can't think of any clean solution. It might be possible > to create the new interface with attributes very unlikely to be used by > external programs and retrieve the interface name and id by monitoring > link creation messages (like 'ip monitor' does). But at this point it's > probably easier to just set the interface name and retry with a > different name every time it conflicted with an existing device. "set interface name and retry" is what I'm using now... And looks like it is the only stable solution for now. I was already thinking about monitoring link creation messages... if there is not some stable message ordering (e.g. order of response and monitor message) but I have not deduced anything from the code. > Maybe someone else could propose less hacky solutions, but I really > can't think of anything else apart from implementing NLM_F_ECHO.