2002-03-21 12:16:55

by Frank Schäfer

[permalink] [raw]
Subject: Documentation or software - bug?

Hi there,

I try to set up a box without procfs, thus I've to set some kernel
parameters using _sysctl().

I wrote a little quick-n-dirty program to set at least integer and
struct ( or better array ) parameters.

I can set all struct, integer and boolean values with this program
except ip_forward.

Due to the docs ip_forward is a BOOLEAN parameter, so the length of the
value array for _sysctl should be 1.

... but ...

in ${KERNELSRC}/net/ipv4/sysctl_net_ipv4.c I find:
snip -->
<-- snap
static int ipv4_sysctl_forward_strategy(ctl_table *table ...
snip -->
<-- snap
if (newlen != sizeof(int))
return -EINVAL;
snip -->

If the config file for my program looks like this:
# CTL_NET IPV4 FORWARD : YES
3 5 8 : 1
I get ``Invalid argument'' from my program.
If the config file for my program looks like this:
3 5 8 : 1 1 1 1
it works and I have a ``1'' in /proc/sys/net/ipv4/ip_forward.
... sure sizeof(int) is 4 on my machine.

My question:
Is there something wrong with the documentation, and NET_IPV4_FORWARD
awaits 4 integers to set/unset IP forwarding, or is something wrong in
sysctl_net_ipv4.c, or did I understand something wrong, and my program
has to be written in some other kind?

My program itself is in the attachment.

Thanks for every help
Frank

PS:
If the configuration file looks like this:
3 5 16 1 : 1
(the ``3 5 8'' is due to sysctl.h only for compatibility with 2.0
kernels, and I run an 2.4.16) i get ENODIR.


Attachments:
sysctl.c (4.26 kB)

2002-04-07 06:41:13

by Randy.Dunlap

[permalink] [raw]
Subject: RE: Documentation or software - bug?


Hi,

Here's my conclusion/opinion.

All of the (networking) BOOLEAN parameters expect newlen (in the
sysctl system call) to be sizeof(int), not 1, but (your) sysctl
program executes the syscall with newlen = 1.

It ([your] sysctl program) should be modified to pass
BOOLEANs as int's.
In other words, BOOLEAN doesn't imply length = 1.

~Randy

---------- Forwarded message ----------

Hi there,

I try to set up a box without procfs, thus I've to set some kernel
parameters using _sysctl().

I wrote a little quick-n-dirty program to set at least integer and
struct ( or better array ) parameters.

I can set all struct, integer and boolean values with this program
except ip_forward.

Due to the docs ip_forward is a BOOLEAN parameter, so the length of the
value array for _sysctl should be 1.

... but ...

in ${KERNELSRC}/net/ipv4/sysctl_net_ipv4.c I find:
snip -->
<-- snap
static int ipv4_sysctl_forward_strategy(ctl_table *table ...
snip -->
<-- snap
if (newlen != sizeof(int))
return -EINVAL;
snip -->

If the config file for my program looks like this:
# CTL_NET IPV4 FORWARD : YES
3 5 8 : 1
I get ``Invalid argument'' from my program.
If the config file for my program looks like this:
3 5 8 : 1 1 1 1
it works and I have a ``1'' in /proc/sys/net/ipv4/ip_forward.
... sure sizeof(int) is 4 on my machine.

My question:
Is there something wrong with the documentation, and NET_IPV4_FORWARD
awaits 4 integers to set/unset IP forwarding, or is something wrong in
sysctl_net_ipv4.c, or did I understand something wrong, and my program
has to be written in some other kind?

My program itself is in the attachment.

Thanks for every help
Frank

PS:
If the configuration file looks like this:
3 5 16 1 : 1
(the ``3 5 8'' is due to sysctl.h only for compatibility with 2.0
kernels, and I run an 2.4.16) i get ENODIR.


Attachments:
sysctl.c (4.26 kB)

2002-04-09 07:14:05

by Frank Schäfer

[permalink] [raw]
Subject: RE: Documentation or software - bug?

On Sun, 2002-04-07 at 08:38, Randy.Dunlap wrote:
>
> Hi,
>
> Here's my conclusion/opinion.
>
> All of the (networking) BOOLEAN parameters expect newlen (in the
> sysctl system call) to be sizeof(int), not 1, but (your) sysctl
> program executes the syscall with newlen = 1.
>

> ---------- Forwarded message ----------
>
> Hi there,
>
> I try to set up a box without procfs, thus I've to set some kernel
> parameters using _sysctl().
>
Hi,

I've figured out this already, but thanks for you'r time

Regards
Frank