Re: How to find out name or id of newly created interface
From: Andrew Lunn
Date: Sun Aug 01 2021 - 10:31:41 EST
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