Skip to content

Commit ab41a2c

Browse files
ebiedermdavem330
authored andcommitted
net: Implement register_net_sysctl.
Right now all of the networking sysctl registrations are running in a compatibiity mode. The natvie sysctl registration api takes a cstring for a path and a simple ctl_table. Implement register_net_sysctl so that we can register network sysctls without needing to use compatiblity code in the sysctl core. Switching from a ctl_path to a cstring results in less boiler plate and denser code that is a little easier to read. I would simply have changed the arguments to register_net_sysctl_table instead of keeping two functions in parallel but gcc will allow a ctl_path pointer to be passed to a char * pointer with only issuing a warning resulting in completely incorrect code can be built. Since I have to change the function name I am taking advantage of the situation to let both register_net_sysctl and register_net_sysctl_table live for a short time in parallel which makes clean conversion patches a bit easier to read and write. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 167de77 commit ab41a2c

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎include/net/net_namespace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
287287
const struct ctl_path *path, struct ctl_table *table);
288288
extern struct ctl_table_header *register_net_sysctl_rotable(
289289
const struct ctl_path *path, struct ctl_table *table);
290+
extern struct ctl_table_header *register_net_sysctl(struct net *net,
291+
const char *path, struct ctl_table *table);
290292
extern void unregister_net_sysctl_table(struct ctl_table_header *header);
291293

292294
#endif /* __NET_NET_NAMESPACE_H */

‎net/sysctl_net.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ struct ctl_table_header *register_net_sysctl_rotable(const
117117
}
118118
EXPORT_SYMBOL_GPL(register_net_sysctl_rotable);
119119

120+
struct ctl_table_header *register_net_sysctl(struct net *net,
121+
const char *path, struct ctl_table *table)
122+
{
123+
return __register_sysctl_table(&net->sysctls, path, table);
124+
}
125+
EXPORT_SYMBOL_GPL(register_net_sysctl);
126+
120127
void unregister_net_sysctl_table(struct ctl_table_header *header)
121128
{
122129
unregister_sysctl_table(header);

0 commit comments

Comments
 (0)