diff mbox

[v4,2/7] ipv6 addrconf: remove addrconf_sysctl_hop_limit()

Message ID 1474801390-6891-3-git-send-email-zenczykowski@gmail.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Maciej Żenczykowski Sept. 25, 2016, 11:03 a.m. UTC
From: Maciej Żenczykowski <maze@google.com>

replace with extra1/2 magic

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 net/ipv6/addrconf.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

Comments

Erik Kline Sept. 26, 2016, 9:14 a.m. UTC | #1
On 25 September 2016 at 20:03, Maciej Żenczykowski
<zenczykowski@gmail.com> wrote:
> From: Maciej Żenczykowski <maze@google.com>
>
> replace with extra1/2 magic
>
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
> ---
>  net/ipv6/addrconf.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 11fa1a5564d4..3a835495fb53 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -5467,20 +5467,6 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
>  }
>
>  static
> -int addrconf_sysctl_hop_limit(struct ctl_table *ctl, int write,
> -                              void __user *buffer, size_t *lenp, loff_t *ppos)
> -{
> -       struct ctl_table lctl;
> -       int min_hl = 1, max_hl = 255;
> -
> -       lctl = *ctl;
> -       lctl.extra1 = &min_hl;
> -       lctl.extra2 = &max_hl;
> -
> -       return proc_dointvec_minmax(&lctl, write, buffer, lenp, ppos);
> -}
> -
> -static
>  int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
>                         void __user *buffer, size_t *lenp, loff_t *ppos)
>  {
> @@ -5713,6 +5699,9 @@ int addrconf_sysctl_ignore_routes_with_linkdown(struct ctl_table *ctl,
>         return ret;
>  }
>
> +static int one = 1;
> +static int two_five_five = 255;

Should these be const as well?

> +
>  static const struct ctl_table addrconf_sysctl[] = {
>         {
>                 .procname       = "forwarding",
> @@ -5726,7 +5715,9 @@ static const struct ctl_table addrconf_sysctl[] = {
>                 .data           = &ipv6_devconf.hop_limit,
>                 .maxlen         = sizeof(int),
>                 .mode           = 0644,
> -               .proc_handler   = addrconf_sysctl_hop_limit,
> +               .proc_handler   = proc_dointvec_minmax,
> +               .extra1         = &one,
> +               .extra2         = &two_five_five,
>         },
>         {
>                 .procname       = "mtu",
> --
> 2.8.0.rc3.226.g39d4020
>
Maciej Żenczykowski Sept. 26, 2016, 9:37 a.m. UTC | #2
>> +static int one = 1;
>> +static int two_five_five = 255;
>
> Should these be const as well?

It would be nice, but you actually get compile time warnings if you do that.
diff mbox

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 11fa1a5564d4..3a835495fb53 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5467,20 +5467,6 @@  int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
 }
 
 static
-int addrconf_sysctl_hop_limit(struct ctl_table *ctl, int write,
-                              void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-	struct ctl_table lctl;
-	int min_hl = 1, max_hl = 255;
-
-	lctl = *ctl;
-	lctl.extra1 = &min_hl;
-	lctl.extra2 = &max_hl;
-
-	return proc_dointvec_minmax(&lctl, write, buffer, lenp, ppos);
-}
-
-static
 int addrconf_sysctl_mtu(struct ctl_table *ctl, int write,
 			void __user *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -5713,6 +5699,9 @@  int addrconf_sysctl_ignore_routes_with_linkdown(struct ctl_table *ctl,
 	return ret;
 }
 
+static int one = 1;
+static int two_five_five = 255;
+
 static const struct ctl_table addrconf_sysctl[] = {
 	{
 		.procname	= "forwarding",
@@ -5726,7 +5715,9 @@  static const struct ctl_table addrconf_sysctl[] = {
 		.data		= &ipv6_devconf.hop_limit,
 		.maxlen		= sizeof(int),
 		.mode		= 0644,
-		.proc_handler	= addrconf_sysctl_hop_limit,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &one,
+		.extra2		= &two_five_five,
 	},
 	{
 		.procname	= "mtu",