Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp958346pxy; Sun, 1 Aug 2021 07:42:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCLbeA21xgDUrkfCtYfISSVU6CgzteSqiMqPCe4p9xqr0TOaEv/Q0ulnhReRAtJHww6Bv6 X-Received: by 2002:a17:906:4e44:: with SMTP id g4mr11562851ejw.246.1627828960070; Sun, 01 Aug 2021 07:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627828960; cv=none; d=google.com; s=arc-20160816; b=hR27f5sPYUySBvbATtH8L5Ll4za7Xf+PTOiBBc8q3dRWpAiB4gh9h/jJoN8lYTI9sX Xgl2aKyxwru+kJYeAZzncSVGHNC/segmGaOhuy/GDRFwnK+aAiPhDQmjBYZ/+pwlf9uv VfA/VJRm1l5mOG/gWjl3i5awqcbhrLJLsCuIOhpveBZKbw7cd9O6YoJenMZxlrEozFVA FHNIR/kBWOYn5yrzeq66r7aqPKwjcKLE3bIrB0z39IxeE7/2MS+E2pYBH20Cd4maH5wc BYLKLSWhJIidBf4wO+5UU2Z7sScSjuCtyxnXTFHP83tejtsUQ74Xk4NmpCAN4TgridCp V6ng== 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=J8aiC0VVJOWLgi+07xlKsZTleEZruFfdK/kKUlBEGO4=; b=N0aEOTX8/6Gg26Y6eEFSKjWjTK7Jwe/NIvNcLC3hj3KD3a/9r7/Nz5bT81jN7F3FgM WtclMFZA5KRAETpGONJg0Voug5vkY0AzfHljfTRNd6jr8RyObtHEer/URokcBPNtfIVF NR48VyUa5mfjqAa6WH6/3/C/L29J+m7RtwQcYvNFOyKazc7TRYZZj0RyuZa8JRtf+QUT 1AAcer+wDVhomWmB6HqQqgaeoBcHvsbmF/S+BlR/Jkni6UkFIr6Vm0a62+xrESK0VGgl ZlDAuJhxD8Pce/YH/YLmqyWRkJOmB5eixD7S7TxDJ+k1/yZVvX12VaoHeefEjZt91ssY d1kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m+14xulS; 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 m10si9329567eji.378.2021.08.01.07.42.15; Sun, 01 Aug 2021 07:42:40 -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=m+14xulS; 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 S231975AbhHAOiw (ORCPT + 99 others); Sun, 1 Aug 2021 10:38:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbhHAOiv (ORCPT ); Sun, 1 Aug 2021 10:38:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21FF560EC0; Sun, 1 Aug 2021 14:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627828723; bh=FGFBjq9YabKmgwU/bI9mR68bFsA5bC2U0VYVG88m/G4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m+14xulSFoSHkTFlm6lwVn3IlS7QvZDKznfgvCwQiFzW8oBfN8nLWIISUDU2L7eJ9 ZejrtxUz2o0qwWciBSYJQinFCAS47u2wNtXsoFmPf4430EFu3aRbNMQOQIV6SwI30w Nqa6iEjoxTptMAYNrWrzgAE0yMS/WLc0gLHCkS0+wJLO1kF1hvvfIrYDfjhOMPxvP3 f+BgRkzInqFPwhuMnePiV82Vb3eHKWOwVR97sPHbn8RryNem3lwm/qDvoSA5/12O0u R8m2uQvwJScrOn+A9XK0bZqKLjAiV3w/LIjis//b3o+wTdgG5Bte2wIWcTdqraYMl7 vULbur0Patrwg== Received: by pali.im (Postfix) id C5EC5EF9; Sun, 1 Aug 2021 16:38:40 +0200 (CEST) Date: Sun, 1 Aug 2021 16:38:40 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Andrew Lunn 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: <20210801143840.j6bfvt3zsfb2x7q5@pali> References: <20210731203054.72mw3rbgcjuqbf4j@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sunday 01 August 2021 16:31:33 Andrew Lunn wrote: > On Sat, Jul 31, 2021 at 10:30:54PM +0200, Pali Rohár wrote: > > Hello! > > > > Via rtnetlink API (RTM_NEWLINK/NLM_F_CREATE) it is possible to create a > > new network interface without specifying neither interface name nor id. > > This will let kernel to choose some interface name which does not > > conflicts with any already existing network interface. So seems like > > ideal way if I do not care about interface names. But at some stage it > > is needed to "configure" interface and for this action it is required to > > know interface id or name (as some ioctls use interface name instead of > > id). > > Hi Pali > > Looking at __rtnl_newlink() it looks like you can specify the > dev->ifindex when you request the create. So you can leave the kernel > to pick the name, but pick the if_index from user space. > > Andrew Hello! This has additional issue that I have to choose some free ifindex number and it introduce another race condition that other userspace process may choose same ifindex number. So create request in this case fails if other userspace process is faster... So it has same race condition as specifying interface name.