From: "Yajun Deng" <yajun.deng@linux.dev>
To: "Jakub Kicinski" <kuba@kernel.org>
Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
horms@kernel.org, andrew+netdev@lunn.ch, netdev@vger.kernel.org
Subject: Re: [PATCH net-next] net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id)
Date: Sat, 17 May 2025 02:24:17 +0000 [thread overview]
Message-ID: <3f8cd57a8c9456bf65fe7d83e48f090f2dfa2999@linux.dev> (raw)
In-Reply-To: <20250516152611.5945afae@kernel.org>
May 17, 2025 at 6:26 AM, "Jakub Kicinski" <kuba@kernel.org> wrote:
>
> On Thu, 15 May 2025 21:02:05 +0800 Yajun Deng wrote:
>
> >
> > +static struct attribute *netdev_phys_attrs[] __ro_after_init = {
> >
>
> Why __ro_after_init and not const? I can't find the reason with
>
> a quick grep. This is just an array of pointers, not objects.
>
These attributes in net_class_attrs had __ro_after_init before this patch.
> >
> > + &dev_attr_phys_port_id.attr,
> >
> > + &dev_attr_phys_port_name.attr,
> >
> > + &dev_attr_phys_switch_id.attr,
> >
> > + NULL,
> >
> > +};
> >
> > +
> >
> > +static umode_t netdev_phys_is_visible(struct kobject *kobj,
> >
> > + struct attribute *attr, int index)
> >
> > +{
> >
> > + struct device *dev = kobj_to_dev(kobj);
> >
> > + struct net_device *netdev = to_net_dev(dev);
> >
> > +
> >
> > + if (attr == &dev_attr_phys_port_id.attr) {
> >
> > + /* The check is also done in dev_get_phys_port_id; this helps returning
> >
> > + * early without hitting the locking section below.
> >
> > + */
> >
> > + if (!netdev->netdev_ops->ndo_get_phys_port_id)
> >
> > + return 0;
> >
> > + } else if (attr == &dev_attr_phys_port_name.attr) {
> >
> > + /* The checks are also done in dev_get_phys_port_name; this helps
> >
> > + * returning early without hitting the locking section below.
> >
> > + */
> >
> > + if (!netdev->netdev_ops->ndo_get_phys_port_name &&
> >
> > + !netdev->devlink_port)
> >
> > + return 0;
> >
> > + } else if (attr == &dev_attr_phys_switch_id.attr) {
> >
> > + /* The checks are also done in dev_get_phys_port_name; this helps
> >
> > + * returning early without hitting the locking section below. This works
> >
> > + * because recurse is false when calling dev_get_port_parent_id.
> >
> > + */
> >
> > + if (!netdev->netdev_ops->ndo_get_port_parent_id &&
> >
> > + !netdev->devlink_port)
> >
> > + return 0;
> >
>
> I'm slightly worried some user space depends on the files existing,
>
> but maybe ENOENT vs EOPNOTSUPP doesn't make a big difference.
>
> Can you remove the comments, tho? I don't think they add much value.
>
Okay.
> --
>
> pw-bot: cr
>
prev parent reply other threads:[~2025-05-17 2:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 13:02 [PATCH net-next] net: sysfs: Implement is_visible for phys_(port_id, port_name, switch_id) Yajun Deng
2025-05-16 22:26 ` Jakub Kicinski
2025-05-17 2:24 ` Yajun Deng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f8cd57a8c9456bf65fe7d83e48f090f2dfa2999@linux.dev \
--to=yajun.deng@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.