sysctl() and NET_IPV4_FORWARD

From: Hasso Tepper
Date: Mon Dec 22 2003 - 14:03:23 EST


Simple test attached fails with 2.4.x (tested with 2.4.23 and 2.4.19).
It works with 2.6 (tested with 2.6.0-test11-mm1). Writing works in
both 2.4 and 2.6, only reading is problem in 2.4.

Am I doing something wrong? Or is it bug?

regards,

--
Hasso Tepper
Elion Enterprises Ltd.
WAN administrator
#include <stdio.h>
#include <stdlib.h>
#include <sys/sysctl.h>
#include <linux/sysctl.h>

int main(int argc, char **argv)
{
int name[] = {CTL_NET, NET_IPV4, NET_IPV4_FORWARD};
int namelen = 3;
int readval, error;
size_t len = sizeof(readval);

error = sysctl (name, namelen, &readval, &len, NULL, 0);
if (error) {
fprintf(stderr, "sysctl(): %s\n", strerror(error));
exit(1);
}
printf("Current value: %i\n", readval);
exit(0);
}