On Sun, Feb 24, 2019 at 08:40:15PM +0100, Andrew Lunn wrote: > > > This is getting less friendly all the time, and it was never very > > > friendly to start with. We have the strings which represent these link > > > modes in the table used for dumping caps. How about allowing the user > > > to list a comma separate list of modes. > > > > > > ethtool -s lan42 advertise > > > 100000baseKR2/Full,100000baseSR2/Full,100000baseCR2/Full > > > > In my preliminary netlink patchset, I'm adding support for e.g. > > > > ethtool -s eth0 advertise 100baseT/Half off 1000baseT/Full on > > > > I'm not sure what would be more useful, if switching individual modes or > > listing the whole set. After all, we can also support both. But I fully > > agree that the numeric bitmaps are already too inconvenient. > > Hi Michal > > So are you doing a read/modify/write? In that case, off/on makes > sense. For a pure write, i don't see the need for off/on.
When using netlink interface, the read/modify/write cycle is limited to kernel code and is done under rtnl_lock. The netlink interface allows userspace to send only attributes it wants to change and for bit sets (like link modes) to tell kernel which bits it wants to change so that there is no need to read current values first (and open a race window). When using ioctl interface, ethtool does read the value first even now as ETHTOOL_SLINKSETTINGS command uses struct ethtool_link_usettings which has also other members and there is no way to say we only want to change advertised link modes. Michal