Re: [PATCH 11/14] networking: Update to register_net_sysctl_sz

From: Joel Granados
Date: Thu Jul 27 2023 - 08:34:02 EST


On Wed, Jul 26, 2023 at 11:05:24AM -0700, Luis Chamberlain wrote:
> On Wed, Jul 26, 2023 at 04:06:31PM +0200, Joel Granados wrote:
> > This is part of the effort to remove the sentinel (last empty) element
> > from the ctl_table arrays. We update to the new function and pass it the
> > array size. Care is taken to mirror the NULL assignments with a size of
> > zero (for the unprivileged users). An additional size function was added
> > to the following files in order to calculate the size of an array that
> > is defined in another file:
> > include/net/ipv6.h
> > net/ipv6/icmp.c
> > net/ipv6/route.c
> > net/ipv6/sysctl_net_ipv6.c
> >
>
> Same here as with the other patches, the "why" and size impact should go here.
> I'll skip mentioning that in the other patches.
Indeed. FYI: I answered in your original feedback.

>
> > diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> > index bf6e81d56263..5bad14b3c71e 100644
> > --- a/net/mpls/af_mpls.c
> > +++ b/net/mpls/af_mpls.c
> > @@ -1396,6 +1396,40 @@ static const struct ctl_table mpls_dev_table[] = {
> > { }
> > };
> >
> > +static int mpls_platform_labels(struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos);
> > +#define MPLS_NS_SYSCTL_OFFSET(field) \
> > + (&((struct net *)0)->field)
> > +
> > +static const struct ctl_table mpls_table[] = {
> > + {
> > + .procname = "platform_labels",
> > + .data = NULL,
> > + .maxlen = sizeof(int),
> > + .mode = 0644,
> > + .proc_handler = mpls_platform_labels,
> > + },
> > + {
> > + .procname = "ip_ttl_propagate",
> > + .data = MPLS_NS_SYSCTL_OFFSET(mpls.ip_ttl_propagate),
> > + .maxlen = sizeof(int),
> > + .mode = 0644,
> > + .proc_handler = proc_dointvec_minmax,
> > + .extra1 = SYSCTL_ZERO,
> > + .extra2 = SYSCTL_ONE,
> > + },
> > + {
> > + .procname = "default_ttl",
> > + .data = MPLS_NS_SYSCTL_OFFSET(mpls.default_ttl),
> > + .maxlen = sizeof(int),
> > + .mode = 0644,
> > + .proc_handler = proc_dointvec_minmax,
> > + .extra1 = SYSCTL_ONE,
> > + .extra2 = &ttl_max,
> > + },
> > + { }
> > +};
>
> Unless we hear otherwise from networking folks, I think this move alone
> should probably go as a separate patch with no functional changes to
> make the changes easier to review / bisect.

Ok. I'll take it out in its own commit and prepend it as a preparation
patch.

thx for the feedback
Best

Joel Granados

Attachment: signature.asc
Description: PGP signature