Update most callers with dynamic table/path to use template arguments.

Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
---
 net/core/neighbour.c                | 11 ++++++++---
 net/core/sysctl_net_core.c          |  3 ++-
 net/ieee802154/6lowpan/reassembly.c |  2 +-
 net/ipv4/devinet.c                  |  9 +++++++--
 net/ipv4/route.c                    |  3 ++-
 net/ipv4/sysctl_net_ipv4.c          |  2 +-
 net/ipv6/addrconf.c                 |  7 +++++--
 net/ipv6/sysctl_net_ipv6.c          |  3 ++-
 net/mpls/af_mpls.c                  |  9 ++++++---
 net/netfilter/ipvs/ip_vs_lblc.c     |  3 ++-
 net/netfilter/ipvs/ip_vs_lblcr.c    |  3 ++-
 net/sctp/sysctl.c                   |  3 ++-
 net/smc/smc_sysctl.c                |  2 +-
 net/xfrm/xfrm_sysctl.c              |  2 +-
 14 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 
1349c0eedb642539b28391390fd82f543e004353..bdd67dd879d24f41c95c454ca26d63fd6d8e112b
 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -12,6 +12,7 @@
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define SYSCTL_MODULE_ALIASES_UNIQUE_ID
 
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -3910,11 +3911,15 @@ int neigh_sysctl_register(struct net_device *dev, 
struct neigh_parms *p,
              BUG();
        }
 
-       snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s",
-               p_name, dev_name_source);
+#define path_template "net/%s/neigh/%s"
+       snprintf(neigh_path, sizeof(neigh_path), path_template,
+                p_name, dev_name_source);
        t->sysctl_header = register_net_sysctl_sz(neigh_parms_net(p),
                                                  neigh_path, t->neigh_vars,
-                                                 neigh_vars_size);
+                                                 neigh_vars_size,
+                                                 
neigh_sysctl_template.neigh_vars,
+                                                 path_template);
+#undef path_template
        if (!t->sysctl_header)
                goto free;
 
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 
eb35da3556f4aa00cecd4582ab94e339d2518506..d8dfce6babc337749cde653fb1308f977ba28ef5
 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -821,7 +821,8 @@ static __net_init int sysctl_core_net_init(struct net *net)
                        goto err_dup;
        }
 
-       net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, 
table_size);
+       net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, 
table_size,
+                                                     netns_core_table);
        if (net->core.sysctl_hdr == NULL)
                goto err_reg;
 
diff --git a/net/ieee802154/6lowpan/reassembly.c 
b/net/ieee802154/6lowpan/reassembly.c
index 
ddb6a5817d098eda6b22d802b5f59604b2145ff2..28914524bd0c389877533ed689eaf5af58c46bdd
 100644
--- a/net/ieee802154/6lowpan/reassembly.c
+++ b/net/ieee802154/6lowpan/reassembly.c
@@ -386,7 +386,7 @@ static int __net_init 
lowpan_frags_ns_sysctl_register(struct net *net)
        table[2].data   = &ieee802154_lowpan->fqdir->timeout;
 
        hdr = register_net_sysctl_sz(net, "net/ieee802154/6lowpan", table,
-                                    table_size);
+                                    table_size, lowpan_frags_ns_ctl_table);
        if (hdr == NULL)
                goto err_reg;
 
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 
a90be57c63be1565b2dff51e8264668fd71b9e58..a466163dad7fe7f8b5b1c2897dd5fe548c288442
 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -21,6 +21,7 @@
  *                                     if no match found.
  */
 
+#define SYSCTL_MODULE_ALIASES_UNIQUE_ID
 
 #include <linux/uaccess.h>
 #include <linux/bitops.h>
@@ -2739,9 +2740,13 @@ static int __devinet_sysctl_register(struct net *net, 
char *dev_name,
                t->devinet_vars[i].extra2 = net;
        }
 
-       snprintf(path, sizeof(path), "net/ipv4/conf/%s", dev_name);
+#define path_template "net/ipv4/conf/%s"
+       snprintf(path, sizeof(path), path_template, dev_name);
 
-       t->sysctl_header = register_net_sysctl(net, path, t->devinet_vars);
+       t->sysctl_header = register_net_sysctl(net, path, t->devinet_vars,
+                                              devinet_sysctl.devinet_vars,
+                                              path_template);
+#undef path_template
        if (!t->sysctl_header)
                goto free;
 
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 
604cc51dfd9bc5e7351a93140a9e0699a71e6a4e..d5464c7ef7dacdd47c5cb59ca14f605004c43b49
 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3661,7 +3661,8 @@ static __net_init int sysctl_route_net_init(struct net 
*net)
        tbl[0].extra1 = net;
 
        net->ipv4.route_hdr = register_net_sysctl_sz(net, "net/ipv4/route",
-                                                    tbl, table_size);
+                                                    tbl, table_size,
+                                                    ipv4_route_netns_table);
        if (!net->ipv4.route_hdr)
                goto err_reg;
        return 0;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 
2f0363bca2a88d68276670cfce6fb04398f82bc5..879651f4a57bc1206494a9eb1dd6a3fb752169c9
 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -1696,7 +1696,7 @@ static __net_init int ipv4_sysctl_init_net(struct net 
*net)
        }
 
        net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table,
-                                                   table_size);
+                                                   table_size, ipv4_net_table);
        if (!net->ipv4.ipv4_hdr)
                goto err_reg;
 
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 
9d89be7e0544befb979526fa4f0c4f0ab90582f0..e87c5d2e6e2f49ef4041faa4d8df85f69cabad36
 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -7347,10 +7347,13 @@ static int __addrconf_sysctl_register(struct net *net, 
char *dev_name,
                }
        }
 
-       snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name);
+#define path_template "net/ipv6/conf/%s"
+       snprintf(path, sizeof(path), path_template, dev_name);
 
        p->sysctl_header = register_net_sysctl_sz(net, path, table,
-                                                 table_size);
+                                                 table_size, addrconf_sysctl,
+                                                 path_template);
+#undef path_template
        if (!p->sysctl_header)
                goto free;
 
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 
1a0a36dcdabc1be961d0ab69e5c93b05c53f46a8..75ba17cb7c0ccb4769d61e74220c75d0b3e2bcd9
 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -275,7 +275,8 @@ static int __net_init ipv6_sysctl_net_init(struct net *net)
                goto out_ipv6_route_table;
 
        net->ipv6.sysctl.hdr = register_net_sysctl_sz(net, "net/ipv6",
-                                                     ipv6_table, table_size);
+                                                     ipv6_table, table_size,
+                                                     ipv6_table_template);
        if (!net->ipv6.sysctl.hdr)
                goto out_ipv6_icmp_table;
 
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 
961be5054a039b3d8bcfd22851beb69c21954bc3..f2025bedc543b5b50eb3c7275e26e6adcdf27ae5
 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1446,9 +1446,12 @@ static int mpls_dev_sysctl_register(struct net_device 
*dev,
                table[i].extra2 = net;
        }
 
-       snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
+#define path_template "net/mpls/conf/%s"
+       snprintf(path, sizeof(path), path_template, dev->name);
 
-       mdev->sysctl = register_net_sysctl_sz(net, path, table, table_size);
+       mdev->sysctl = register_net_sysctl_sz(net, path, table, table_size,
+                                             mpls_dev_table, path_template);
+#undef path_template
        if (!mdev->sysctl)
                goto free;
 
@@ -2765,7 +2768,7 @@ static __net_init int mpls_net_init(struct net *net)
                table[i].data = (char *)net + (uintptr_t)table[i].data;
 
        net->mpls.ctl = register_net_sysctl_sz(net, "net/mpls", table,
-                                              table_size);
+                                              table_size, mpls_table);
        if (net->mpls.ctl == NULL) {
                kfree(table);
                return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 
693bcc82ccb77b49bfa28a7facac946f0223aba2..efad701b096341dfe44e621ed647e21fd3bfa486
 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -572,7 +572,8 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
 
        ipvs->lblc_ctl_header = register_net_sysctl_sz(net, "net/ipv4/vs",
                                                       ipvs->lblc_ctl_table,
-                                                      vars_table_size);
+                                                      vars_table_size,
+                                                      vs_vars_table);
        if (!ipvs->lblc_ctl_header) {
                if (!net_eq(net, &init_net))
                        kfree(ipvs->lblc_ctl_table);
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 
f53f05ceea36f02d6d1d435882484005829fe6de..3498e6db6f0d7e9af29a95f1f8ccecd7c8d45cfd
 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -757,7 +757,8 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
 
        ipvs->lblcr_ctl_header = register_net_sysctl_sz(net, "net/ipv4/vs",
                                                        ipvs->lblcr_ctl_table,
-                                                       vars_table_size);
+                                                       vars_table_size,
+                                                       vs_vars_table);
        if (!ipvs->lblcr_ctl_header) {
                if (!net_eq(net, &init_net))
                        kfree(ipvs->lblcr_ctl_table);
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 
2b94c211427de7b2e9aa374033eac26ddd874e14..891fb447ea480ec95fb66a02bf8e086b3efa58c7
 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -605,7 +605,8 @@ int sctp_sysctl_net_register(struct net *net)
        table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans;
 
        net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp",
-                                                        table, table_size);
+                                                        table, table_size,
+                                                        sctp_net_table);
        if (net->sctp.sysctl_header == NULL) {
                kfree(table);
                return -ENOMEM;
diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c
index 
09dad48337f6164f5765fa793412bdebf47e61ca..4b1dc109afa6c62b4640513336d0862bdcd00f8c
 100644
--- a/net/smc/smc_sysctl.c
+++ b/net/smc/smc_sysctl.c
@@ -235,7 +235,7 @@ int __net_init smc_sysctl_net_init(struct net *net)
        }
 
        net->smc.smc_hdr = register_net_sysctl_sz(net, "net/smc", table,
-                                                 table_size);
+                                                 table_size, smc_table);
        if (!net->smc.smc_hdr)
                goto err_reg;
 
diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
index 
357152a50faf10e5c33468c034dd1777e0bed079..34bb2097930b61f711a2cafd614e63b5caac0013
 100644
--- a/net/xfrm/xfrm_sysctl.c
+++ b/net/xfrm/xfrm_sysctl.c
@@ -60,7 +60,7 @@ int __net_init xfrm_sysctl_init(struct net *net)
                table_size = 0;
 
        net->xfrm.sysctl_hdr = register_net_sysctl_sz(net, "net/core", table,
-                                                     table_size);
+                                                     table_size, xfrm_table);
        if (!net->xfrm.sysctl_hdr)
                goto out_register;
        return 0;

-- 
2.47.3


Reply via email to