looks good to me - did you push it upstream yet?
On 5/1/07, Simon Horman <[EMAIL PROTECTED]> wrote:
Here is my take on a fix for this problem.
--
Horms
H: http://www.vergenet.net/~horms/
W: http://www.valinux.co.jp/en/
Subject: Remove bashim from IPaddr
From: Simon Horman <[EMAIL PROTECTED]>
Use sed instead of cut + bashism to calculate a MAC if one isn't provided.
Signed-off-by: Simon Horman <[EMAIL PROTECTED]>
diff -r 75fa88f5e100 resources/OCF/IPaddr2.in
--- a/resources/OCF/IPaddr2.in Tue May 01 12:41:29 2007 +0900
+++ b/resources/OCF/IPaddr2.in Tue May 01 13:07:49 2007 +0900
@@ -348,16 +348,19 @@ ip_init() {
fi
IP_CIP="yes"
if [ -z "$IF_MAC" ]; then
- # Choose a hash.
- IF_MAC=`echo $BASEIP $NETMASK $BRDCAST | md5sum | cut
-c 1-12`
- # Make it properly delimited, anything non-numeric will do, ":"
and "-" are preferred.
-
IF_MAC=${IF_MAC:0:2}:${IF_MAC:2:2}:${IF_MAC:4:2}:${IF_MAC:6:2}:${IF_MAC:8:2}:${IF_MAC:10:2}
- # For $IF_MAC to be a multicast Ethernet address, the
first octet must be an odd number.
- case ${IF_MAC:1:1} in
- 0|2|4|6|8|a|A|c|C|e|E)
- IF_MAC=${IF_MAC:0:1}1${IF_MAC:2}
- ;;
- esac
+ # Choose a MAC
+ # 1. Concatenate some input together
+ # 2. This doesn't need to be a cryptographically
+ # secure hash.
+ # 3. Drop everything after the first 6 octets (12 chars)
+ # 4. Delimit the octets with ':'
+ # 5. Make sure the first octet is odd,
+ # so the result is a multicast MAC
+ IF_MAC=`echo $BASEIP $NETMASK $BRDCAST | \
+ md5sum | \
+ sed -e 's#\(............\).*#\1#' \
+ -e 's#..#&:#g; s#:$##' \
+ -e 's#^\(.\)[02468aAcCeE]#\11#'`
fi
IP_CIP_FILE="/proc/net/ipt_CLUSTERIP/$BASEIP"
fi
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/