Re: [PATCH net-next v3] net: Add sysfs atttribute for max_mtu
From: Andrew Lunn
Date: Thu May 09 2024 - 16:28:27 EST
On Thu, May 09, 2024 at 03:12:25PM +0530, Ratheesh Kannoth wrote:
> On 2024-05-09 at 14:41:23, Shradha Gupta (shradhagupta@xxxxxxxxxxxxxxxxxxx) wrote:
> > For drivers like MANA, max_mtu value is populated with the value of
> > maximum MTU that the underlying hardware can support.
> IIUC, this reads dev->mtu.
I think you are misunderstanding the code.
> > +NETDEVICE_SHOW_RO(max_mtu, fmt_dec);
/* generate a show function for simple field */
#define NETDEVICE_SHOW(field, format_string) \
static ssize_t format_##field(const struct net_device *dev, char *buf) \
{ \
return sysfs_emit(buf, format_string, dev->field); \
} \
static ssize_t field##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
return netdev_show(dev, attr, buf, format_##field); \
} \
#define NETDEVICE_SHOW_RO(field, format_string) \
NETDEVICE_SHOW(field, format_string); \
static DEVICE_ATTR_RO(field)
So field is max_mtu, so that dev->field gets expanded to dev->max_mtu.
> you can read the same using ifconfig
We stopped using ifconfig years ago. You actually mean "ip link show"
> or any thing that uses SIOCGIFMTU. why do you need to add a new sysfs ?
SIOCGIFMTU is still implemented, but obsolete, replaced by netlink, as
Eric pointed out.
Andrew