Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp470523pxy; Sat, 31 Jul 2021 13:35:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUn/wThuxG52eEEc0EzqNtHcXMeQqovBl/EnaKwVP5e/oLZxmdqFOZglRp8HdVDyiZ2saF X-Received: by 2002:a5e:a908:: with SMTP id c8mr4136195iod.116.1627763731576; Sat, 31 Jul 2021 13:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627763731; cv=none; d=google.com; s=arc-20160816; b=dhXrGpxaV3TVXTe2eS06iKwMD5PILlWXBfEN63WSUJvmJuBYKGMz5kYG7KErQfG5Oj 2QY8hQp/yWxxL41KISqRIGjCQKZV1FmXPM4c/6adZAEcYegFlGOQMe/u92nbhWwXKmpA dwW4UlKqsIonLcUb4aVy7coJCTu6ZkBVIW99UVbGlyp9kQ+G9RAn1lKvGD+Ea3uhy/zc 3irEYSEdLEsoKT7joyYOpVFN689hD7i+Kr00s4LM/gKF5aqAxy7oGVOe25dIuYd8XZ6o MFbeOkTH0dIbPdXpxwhuJODOINyFcqZCzGhhcTx58UFS8v1EE4AL52xxc9C8J2BO9sXl jADg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:to:from:date:dkim-signature; bh=66QtAShc7VIevIPQeozjmro+dtz929C8X+1cefYhXGw=; b=Oe3RS/9mCB6s7+Jy/DF5vjBvxwIr2RIWUWRzYpLbzBBaLscYP6Kd0Sdd4ypAyJIvuX yCkeC/oh+Qee3EEAZoM3ZM+8MzIrUmWu7ZL2jLfdiANTUT34fKFzJlHJIhQWHn8gVRnv M9BaUH5bxNWJSeP9j+WYTA/u8IcPi7+dSK2dObtcHUfRfScVQJmyh67b98/8P/RPnCiS g6OQGuTbBHYfWRSZBVuPaQKGk3e9i6wAdrq79rbnsRyMxJhINs7pXpOqiGucor9mr1pV Kb9zK1/yEXn7jL3tXXsIqEWu/jq7D02SS6jPALTsLzo2z073l+pNn2XxxhKA9kOmbfcO MlaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jpXy4eLh; 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 q14si7031208ils.147.2021.07.31.13.35.07; Sat, 31 Jul 2021 13:35:31 -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=jpXy4eLh; 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 S230470AbhGaUbE (ORCPT + 99 others); Sat, 31 Jul 2021 16:31:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbhGaUbE (ORCPT ); Sat, 31 Jul 2021 16:31:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 443E660E09; Sat, 31 Jul 2021 20:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627763457; bh=66QtAShc7VIevIPQeozjmro+dtz929C8X+1cefYhXGw=; h=Date:From:To:Subject:From; b=jpXy4eLhxc9H4eLj4+CqqB5SRG2ItW5x24+sX0mpl9fNrJKHFFrsWZnyBWYEZII2y HbFtfCjLdZz+pkpd3JfcX9dVoO43CPCqA+52PfsPVO3TwfZS67AahueS5JpaPTbgNh gvsh561xO5gntoAgdovJfezk6oYcUZXc/Dvb6rDDXpgx6fvlRXxLOX5LnMpeXpuEf9 rdiSufOq4kUNnIaumz+8zLmQG4WKP+2nD/3reZ3L3nQDKq0cN/VvijyKkeeeRJktjo 5wvbobi6JxmS9XvEZojYhJdMkAO41JkpdA5J99AVdqlTvobTc/cvVovAquWuwyGPIm hPhWJ8e74jXyg== Received: by pali.im (Postfix) id B1A91941; Sat, 31 Jul 2021 22:30:54 +0200 (CEST) Date: Sat, 31 Jul 2021 22:30:54 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: How to find out name or id of newly created interface Message-ID: <20210731203054.72mw3rbgcjuqbf4j@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). And now I would like to know, how to race-free find out interface name (or id) of this newly created interface? Response to RTM_NEWLINK/NLM_F_CREATE packet from kernel contains only buffer with struct nlmsgerr where is just error number (zero for success) without any additional information. I can send another rtnetlink packet to request list of all existing network interfaces and expect that the interface with the highest id was that one which was created. But it is racy as another process may meanwhile create another network interface or it may delete this my newly created one, prior I send this followup packet.