mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
sysctl: sysctl_binary.c Fix compilation when !CONFIG_NET
dev_get_by_index does not exist when the network stack is not compiled in, so only include the code to follow wild card paths when the network stack is present. I have shuffled the code around a little to make it clear that dev_put is called after dev_get_by_index showing that there is no leak. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
2fb10732c3
commit
63395b6597
1 changed files with 21 additions and 16 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <linux/pid_namespace.h>
|
#include <linux/pid_namespace.h>
|
||||||
#include <linux/file.h>
|
#include <linux/file.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
|
#include <linux/netdevice.h>
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL_SYSCALL
|
#ifdef CONFIG_SYSCTL_SYSCALL
|
||||||
|
|
||||||
|
@ -1250,9 +1251,12 @@ out:
|
||||||
static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
|
static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
|
||||||
{
|
{
|
||||||
const struct bin_table *table = &bin_root_table[0];
|
const struct bin_table *table = &bin_root_table[0];
|
||||||
struct net *net = current->nsproxy->net_ns;
|
|
||||||
int ctl_name;
|
int ctl_name;
|
||||||
|
|
||||||
|
/* The binary sysctl tables have a small maximum depth so
|
||||||
|
* there is no danger of overflowing our path as it PATH_MAX
|
||||||
|
* bytes long.
|
||||||
|
*/
|
||||||
memcpy(path, "sys/", 4);
|
memcpy(path, "sys/", 4);
|
||||||
path += 4;
|
path += 4;
|
||||||
|
|
||||||
|
@ -1263,30 +1267,31 @@ repeat:
|
||||||
name++;
|
name++;
|
||||||
nlen--;
|
nlen--;
|
||||||
for ( ; table->convert; table++) {
|
for ( ; table->convert; table++) {
|
||||||
struct net_device *dev = NULL;
|
int len = 0;
|
||||||
const char *procname = NULL;
|
|
||||||
|
|
||||||
/* Use the well known sysctl number to proc name mapping */
|
/* Use the well known sysctl number to proc name mapping */
|
||||||
if (ctl_name == table->ctl_name)
|
if (ctl_name == table->ctl_name) {
|
||||||
procname = table->procname;
|
len = strlen(table->procname);
|
||||||
|
memcpy(path, table->procname, len);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_NET
|
||||||
/*
|
/*
|
||||||
* For a wild card entry map from ifindex to network
|
* For a wild card entry map from ifindex to network
|
||||||
* device name.
|
* device name.
|
||||||
*/
|
*/
|
||||||
else if (!table->ctl_name) {
|
else if (!table->ctl_name) {
|
||||||
|
struct net *net = current->nsproxy->net_ns;
|
||||||
|
struct net_device *dev;
|
||||||
dev = dev_get_by_index(net, ctl_name);
|
dev = dev_get_by_index(net, ctl_name);
|
||||||
if (dev)
|
if (dev) {
|
||||||
procname = dev->name;
|
len = strlen(dev->name);
|
||||||
}
|
memcpy(path, dev->name, len);
|
||||||
if (procname) {
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen(procname);
|
|
||||||
memcpy(path, procname, len);
|
|
||||||
path += len;
|
|
||||||
if (dev)
|
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (len) {
|
||||||
|
path += len;
|
||||||
if (table->child) {
|
if (table->child) {
|
||||||
*path++ = '/';
|
*path++ = '/';
|
||||||
table = table->child;
|
table = table->child;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue