On Fri, 10 Nov 2023 12:05:13 -0800 Jakub Kicinski <kuba@xxxxxxxxxx> wrote: > On Fri, 10 Nov 2023 00:43:55 +0000 Long Li wrote: > > The code above needs to work with and without netvsc (the possible > > master device) present. > > I don't think that's a reasonable requirement for the kernel code. > > The auto-bonding already puts the kernel into business of guessing > policy, which frankly we shouldn't be in. > > Having the kernel guess even harder that there will be a master, > but it's not there yet, is not reasonable. > I wrote the netvsc automatic VF code almost six years ago. So let me give a little history. The original support of VF's was done by using a bonding device and script. Haiyang worked hard to get to work but it could not work on many distro's and had lots of races and problems. Jakub is right that in an ideal world, this could all be managed by userspace. But the management of network devices in Linux is a dumpster fire! Every distro invents there own solution, last time I counted there were six different tools claiming to be the "one network device manager to rule them all". And that doesn't include all the custom scripts and vendor appliances. The users requirements were: - VF networking should work out of the box - VF networking should require no userspace changes - It must work with legacy enterprise distro's - The first network device must show up as eth0 and it must work. The Linux ecosystem of userspace but the kernel is a common base. It was much easier for Microsoft to tell partners to "use these upstream kernel components" and it will work. Windows and BSD OS's have a tight binding between kernel and management from userspace, therefore it is possible to handle things in userspace. There are still problems (as Long indicated in the patch) because the VF device does appear in the list of network devices. And getting the transparent VF support to work in the face of all the trash of userspace scripts is hard. Part of the problem is that the state model of Linux network devices is fractured and poorly documented. The IFF_SLAVE flag is already used to indicate device is managed by another driver. It keeps IPv6 from doing local address assignment and existing userspace should be looking at it. The problem was that userspace must not see a non-flagged VF device, or it will get confused. Microsoft should have exposed only one device in hardware. Other vendors only expose the VF device and hairpin packets any pre-processed packets. Part of the problem here is that VF firmware needs to be updated (too often) and it is a requirement that VM's do not lose connectivity. Ideally, several things should happen: - Linux should support hiding devices managed by another device - the naming of device roles needs to not be master/slave.