Hi Alan,
Thanks for getting back to me. I've decided to try to use the _sysctl()
way just because these are going to be stock (hopefully soon) RH 6.0
systems. I'm getting funny results. I've attached the C++
program. Here's the output of my little test program "igmptest":
[root@optimus igmptest]# cat /proc/sys/net/ipv4/igmp_max_memberships
20
[root@optimus igmptest]# ./igmptest 256
Setting NET_IPV4_IGMP_MAX_MEMBERSHIPS = 256
Old value = _
New value = 256
[root@optimus igmptest]# cat /proc/sys/net/ipv4/igmp_max_memberships
3552562
[root@optimus igmptest]# ./igmptest 1000
Setting NET_IPV4_IGMP_MAX_MEMBERSHIPS = 1000
Old value = 256
New value = 1000
[root@optimus igmptest]# cat /proc/sys/net/ipv4/igmp_max_memberships
808464433
Thanks for any help.
Tuan
On Fri, 16 Apr 1999, Alan Cox wrote:
> > I remember the old IP_MAX_MEMBERSHIPS variable in <linux/in.h> under the
> > 2.0 kernels. Under 2.2.5 I think it's been changed to
> > NET_IPV4_IGMP_MAX_MEMBERSHIPS in <linux/sysctl.h>.
> > I used to just recompile the kernel after changing that value from 20 to
> > 256. I guess it's a cleaner way of changing it's value but is _sysctl()
> > the only way I can change it?
>
> echo "256" >/proc/sys/net/ipv4/igmp_max_memberships
>
> is nice and easy from boot scripts
>
>
> Alan
> ---
> "The IETF already has more than enough RFCs that codify the obvious, make
> stupidity illegal, support truth, justice, and the IETF way, and generally
> demonstrate the author is a brilliant and valuable Contributor to The
> Standards Process." -- Vernon Schryver
>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <errno.h>
extern int errno;
#include <linux/unistd.h>
#include <linux/sysctl.h>
_syscall1(int, _sysctl, struct __sysctl_args *, args);
int _sysctl(struct __sysctl_args *args);
int main( int argc, char *argv[] ) {
if ( argc != 2 ) {
cerr << "Usage: " << argv[0] << " <IGMP_MAX_MEMBERSHIPS>" << endl;
exit( 1 );
}
cout << "Setting NET_IPV4_IGMP_MAX_MEMBERSHIPS = " << argv[1] << endl;
#define SIZE(x) sizeof(x)/sizeof(x[0])
#define NAMESZ CTL_MAXNAME
struct __sysctl_args args;
int name[] = { CTL_NET, NET_IPV4, NET_IPV4_IGMP_MAX_MEMBERSHIPS };
char oldval[NAMESZ];
size_t oldlenp = sizeof( oldval );
char newval[NAMESZ];
strcpy( newval, argv[1] );
args.name = name;
args.nlen = SIZE(name);
args.oldval = oldval;
args.oldlenp = &oldlenp;
args.newval = newval;
args.newlen = sizeof( newval );
int rv = _sysctl( &args );
if ( rv == 0 ) {
oldval[ oldlenp ] = '\0';
cout << "Old value = " << oldval << endl;
cout << "New value = " << newval << endl;
}
else {
cerr << "Error _sysctl()" << endl
<< "errno = " << errno << " : " << strerror( errno ) << endl;
}
return( 0 );
}