From: Michal J. <mi...@ha...> - 2004-08-18 04:22:50
|
On Tue, Aug 17, 2004 at 03:25:06PM -0600, er...@he... wrote: > > How about optional? If the addresses are there, do something, else > ignore the interface and presume some other part of the OS setup has > configured it. Hm, I always though that the reason why this is in a clustermatic config file is that beosrv, and possibly other pieces, need to know on which interface to talk to a cluster and how it is configured. If the other part is not required then indeed this may be configured somewewhere else but this has a much higher probability that something will get out-of-sync. If you will need change something you have to remember to change few different places. > I think it's reasonable to phase it out. This seems like a feasibly but quite radical approach and people will do get some "strange" errors. A global search-and-replace on one file will be not enough to reconfigure networking as you will need to provide a range of IP numbers for cluster nodes. Even if you will not forget about that other location then typos are not something unheard of. > > Yeah, random values are bad. So here is a promissed replacement for finding BCAST without ipcalc. One of reasons I used awk is that it lives in /bin/awk (although some other things presume that /usr/bin is already available). --- beoboot-cm1.9/rc.clustermatic.bk 2004-08-16 09:45:35.000000000 -0600 +++ beoboot-cm1.9/rc.clustermatic 2004-08-17 21:40:04.016426648 -0600 @@ -155,8 +155,22 @@ echo >&2 "Error: No netmask given for interface." exit 1 fi - #BCAST=`ipcalc --broadcast $ADDR $NMSK | sed -e 's/.*=//'` - if ifconfig $IF $ADDR netmask $NMSK; then + BCAST=`echo $ADDR $NMSK | awk ' + function octstonum(octs, a) + { + split(octs, a, /\./); + return ((a[1]*0x100 + a[2])*0x100 + a[3])*0x100 + a[4]; + } + { + bcast = or(octstonum($1), xor(octstonum($2), 0xffffffff)); + printf ("%d.%d.%d.%d", + rshift(and(bcast, 0xff000000), 24), + rshift(and(bcast, 0x00ff0000), 16), + rshift(and(bcast, 0x0000ff00), 8), + and(bcast, 0x000000ff)); + } + '` + if ifconfig $IF $ADDR netmask $NMSK broadcast $BCAST; then Xsuccess else Xfailure The above does work on 64-bit machines too. Actually 'ifconfig' will be just as happy with an output of 'print or(octstonum($1), xor(octstonum($2), 0xffffffff));' for $BCAST so splitting that for octets is not really necessary and is done mostly for benefits of debugging. The following, simpler, patch works equally well.: --- beoboot-cm1.9/rc.clustermatic.bk 2004-08-16 09:45:35.000000000 -0600 +++ beoboot-cm1.9/rc.clustermatic 2004-08-17 22:15:53.438664800 -0600 @@ -155,8 +155,17 @@ echo >&2 "Error: No netmask given for interface." exit 1 fi - #BCAST=`ipcalc --broadcast $ADDR $NMSK | sed -e 's/.*=//'` - if ifconfig $IF $ADDR netmask $NMSK; then + BCAST=`echo $ADDR $NMSK | awk ' + function octstonum(octs, a) + { + split(octs, a, /\./); + return ((a[1]*0x100 + a[2])*0x100 + a[3])*0x100 + a[4]; + } + { + print or (octstonum($1), xor(octstonum($2), 0xffffffff)); + } + '` + if ifconfig $IF $ADDR netmask $NMSK broadcast $BCAST; then Xsuccess else Xfailure Michal |