Send Linux-ha-cvs mailing list submissions to
        linux-ha-cvs@lists.linux-ha.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: heartbeat by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)
   2. Linux-HA CVS: resources by andrew from 
      (linux-ha-cvs@lists.linux-ha.org)


----------------------------------------------------------------------

Message: 1
Date: Thu, 24 Aug 2006 10:22:28 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: heartbeat by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : heartbeat

Dir     : linux-ha/heartbeat


Modified Files:
        findif.c 


Log Message:
Backport IPaddr related patch from Mercurial

# HG changeset patch
# User Andrew Beekhof <[EMAIL PROTECTED]>
# Date 1156436268 -7200
# Node ID b91c7d5049fce99731bf93f128a18b31911b740b
# Parent  c29a1f74bd8775d160205bd76821a3f7a5e8f748
Use the non-CIDR netmask form because Linux wont accept the new notation
Add the ability to accept either netmask notation to findif


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/heartbeat/findif.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -3 -r1.60 -r1.61
--- findif.c    20 Apr 2006 09:02:13 -0000      1.60
+++ findif.c    24 Aug 2006 16:22:27 -0000      1.61
@@ -1,4 +1,4 @@
-/* $Id: findif.c,v 1.60 2006/04/20 09:02:13 davidlee Exp $ */
+/* $Id: findif.c,v 1.61 2006/08/24 16:22:27 andrew Exp $ */
 /*
  * findif.c:   Finds an interface which can route a given address
  *
@@ -269,7 +269,7 @@
 ,      unsigned long *best_netmask
 ,      char *errmsg, int errmsglen)
 {
-       char    dest[20], mask[20];
+       char    mask[20];
        char    routecmd[MAXSTR];
        int     best_metric = INT_MAX;  
        char    buf[2048];
@@ -314,14 +314,6 @@
                        strncpy(interface, cp, sizeof(interface));
                        done++;
                }
-
-               if (strstr (buf, "destination:")) {
-                       /*strsep(&cp, ":");cp++;*/
-                       cp = strtok(buf, ":");
-                       cp = strtok(NULL, ":");cp++;
-                       strncpy(dest, cp, sizeof(dest));
-                       done++;
-               }
        }
        fclose(routefd);
 
@@ -343,10 +335,8 @@
 
        /*
         * Solaris (at least) can return the word "default" for mask and dest.
-        * For the moment, let's interpret this pair as:
+        * For the moment, let's interpret this as:
         *      mask: 0.0.0.0
-        *      destination: <original IP>
-        * (Does "dest" ever get used?)
         * This was manifesting itself under "BasicSanityCheck", which tries
         * to use a remote IP number; these typically use the "default" route.
         * Better schemes are warmly invited...
@@ -355,14 +345,8 @@
        if (strncmp(mask, "default", sizeof("default")) == 0) {
                strncpy (mask, "0.0.0.0", sizeof(mask));
        }
-       if (strncmp(dest, "default", sizeof("default")) == 0) {
-               strncpy (dest, address, sizeof(dest));
-       }
 #endif
 
-       /* FIXME ... is this used at all?  Delete? */
-       ConvertQuadToInt  (dest, sizeof(dest));
-
        if (inet_pton(AF_INET, mask, &maskbits) <= 0) {
                snprintf(errmsg, errmsglen,
                  "mask [%s] not valid.", mask);
@@ -642,6 +626,25 @@
 }
 
 int
+octals_to_bits(const char *octal);
+
+int
+octals_to_bits(const char *octals)
+{
+       int bits = 0;
+       int octal_num = 0;
+       if(octals != NULL) {
+               octal_num = (int)strtol(octals, NULL, 10);
+       }
+       while(octal_num >= 1) {
+               bits++;
+               octal_num = octal_num / 2;
+       }
+       return bits;
+}
+
+
+int
 main(int argc, char ** argv) {
 
        char *  iparg = NULL;
@@ -698,6 +701,14 @@
                return(1);
        }
 
+       if(strchr(netmaskbits, '.') != NULL) {
+               int len = strlen(netmaskbits);
+               ConvertQuadToInt(netmaskbits, len);
+               snprintf(netmaskbits, len, "%d",
+                        octals_to_bits(netmaskbits));
+               fprintf(stderr, "Rewrote octal netmask as: %s\n", netmaskbits);
+       }
+       
        /* Validate the netmaskbits field */
        ValidateNetmaskBits (netmaskbits, &netmask);
 
@@ -911,6 +922,17 @@
 
 /* 
  * $Log: findif.c,v $
+ * Revision 1.61  2006/08/24 16:22:27  andrew
+ * Backport IPaddr related patch from Mercurial
+ *
+ * # HG changeset patch
+ * # User Andrew Beekhof <[EMAIL PROTECTED]>
+ * # Date 1156436268 -7200
+ * # Node ID b91c7d5049fce99731bf93f128a18b31911b740b
+ * # Parent  c29a1f74bd8775d160205bd76821a3f7a5e8f748
+ * Use the non-CIDR netmask form because Linux wont accept the new notation
+ * Add the ability to accept either netmask notation to findif
+ *
  * Revision 1.60  2006/04/20 09:02:13  davidlee
  * A ':' in an interface name is probably an error (but for now treat as a 
mere warning).
  *




------------------------------

Message: 2
Date: Thu, 24 Aug 2006 10:22:28 -0600 (MDT)
From: linux-ha-cvs@lists.linux-ha.org
Subject: [Linux-ha-cvs] Linux-HA CVS: resources by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : resources

Dir     : linux-ha/resources/OCF


Modified Files:
        IPaddr.in 


Log Message:
Backport IPaddr related patch from Mercurial

# HG changeset patch
# User Andrew Beekhof <[EMAIL PROTECTED]>
# Date 1156436268 -7200
# Node ID b91c7d5049fce99731bf93f128a18b31911b740b
# Parent  c29a1f74bd8775d160205bd76821a3f7a5e8f748
Use the non-CIDR netmask form because Linux wont accept the new notation
Add the ability to accept either netmask notation to findif


===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/resources/OCF/IPaddr.in,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -3 -r1.51 -r1.52
--- IPaddr.in   16 Aug 2006 11:40:50 -0000      1.51
+++ IPaddr.in   24 Aug 2006 16:22:27 -0000      1.52
@@ -119,6 +119,18 @@
 <content type="string" default=""/>
 </parameter>
 
+<parameter name="netmask">
+<longdesc lang="en">
+The netmask for the interface in CIDR format.
+(e.g., 255.255.255.0 and not 24)
+
+If unspecified, the script will also try to determine this from the
+routing table.
+</longdesc>
+<shortdesc lang="en">netmask</shortdesc>
+<content type="string" default=""/>
+</parameter>
+
 <parameter name="broadcast">
 <longdesc lang="en">
 Broadcast address associated with the IP. If left empty, the script will
@@ -496,6 +508,7 @@
   esac
 
   # Use "eval $CMD" (not "$CMD"): it might be a chain of two or more commands.
+  echo $CMD
   eval $CMD
   rc=$?
   if [ $rc != 0 ]; then
@@ -594,7 +607,7 @@
     fi
 
     add_interface "$OCF_RESKEY_ip" "$OCF_RESKEY_nic" "$NIC_unique" \
-                "$OCF_RESKEY_cidr_netmask" "$OCF_RESKEY_broadcast"
+                "$OCF_RESKEY_netmask" "$OCF_RESKEY_broadcast"
     rc=$?
     if [ $rc != 0 ]; then
        ocf_log err "Could not add $OCF_RESKEY_ip to $OCF_RESKEY_nic: $rc"
@@ -752,16 +765,16 @@
             ;;
     esac
 
-    if [ ! -z "$OCF_RESKEY_netmask" -a -z "$OCF_RESKEY_cidr_netmask" ]; then
-       OCF_RESKEY_cidr_netmask=$OCF_RESKEY_netmask
-    fi
-
     #
     # $FINDIF can NOT deal with the condition of empty intermediate 
parameters. 
     #
-    IFCMD="$FINDIF -C $OCF_RESKEY_ip"
-    if [ -n "$OCF_RESKEY_cidr_netmask" ]; then
-       IFCMD="$IFCMD/$OCF_RESKEY_cidr_netmask"
+    IFCMD="$FINDIF $OCF_RESKEY_ip"
+    if [ -n "$OCF_RESKEY_cidr_netmask" -o -n "$OCF_RESKEY_netmask" ]; then
+       if [ -n "$OCF_RESKEY_netmask" ]; then
+           IFCMD="$IFCMD/$OCF_RESKEY_netmask"
+       else
+           IFCMD="$IFCMD/$OCF_RESKEY_cidr_netmask"
+       fi
        if [ -n "$OCF_RESKEY_nic" ]; then
            IFCMD="$IFCMD/$OCF_RESKEY_nic"
            if [ -n "$OCF_RESKEY_broadcast" ]; then
@@ -789,13 +802,13 @@
     fi
 
     tmp=`echo "$NICINFO" | cut -f2 | cut -d ' ' -f2`
-    if [ "x$OCF_RESKEY_cidr_netmask" = "x" ]; then
-       ocf_log info "Using calculated cidr netmask for ${OCF_RESKEY_ip}: $tmp"
-       OCF_RESKEY_cidr_netmask=$tmp
-
-    elif [ x$tmp != x${OCF_RESKEY_cidr_netmask} ]; then
-       ocf_log err "Invalid parameter value: netmask [$OCF_RESKEY_cidr_netmask 
[Calculated netmask: $tmp]"
-       return $OCF_ERR_ARGS
+    if [ "x$OCF_RESKEY_netmask" = "x" ]; then
+       ocf_log info "Using calculated netmask for ${OCF_RESKEY_ip}: $tmp"
+       OCF_RESKEY_netmask=$tmp
+# We cant do this because netmask used to take the CIDR form...
+#    elif [ x$tmp != x${OCF_RESKEY_netmask} ]; then
+#      ocf_log err "Invalid parameter value: netmask [$OCF_RESKEY_netmask 
[Calculated netmask: $tmp]"
+#      return $OCF_ERR_ARGS
     fi
     
     tmp=`echo "$NICINFO" | cut -f3 | cut -d ' ' -f2`




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
Linux-ha-cvs@lists.linux-ha.org
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 33, Issue 85
********************************************

Reply via email to