Hi

Configure script doesn't detect correct arguments for route command on debian.
#define ROUTEPARM "-n get"
e.g.
/sbin/route -n get 10.0.0.5
Usage: route [-nNvee] [-FC] [<AF>]           List kernel routing tables
      route [-v] [-FC] {add|del|flush} ...  Modify routing table for AF.

      route {-h|--help} [<AF>]              Detailed usage syntax for
specified AF.
      route {-V|--version}                  Display version/author and exit.
...

This revealed bug of findif:

IPaddr.in:792
   NICINFO=`$IFCMD`
   rc=$?

   if [ $rc != 0 ]; then
       ocf_log err "$IFCMD failed [rc=$rc]."
       return $OCF_ERR_GENERIC
   fi

$IFCMD is command: /usr/lib/heartbeat/findif IP

findif.c:724
rc = (*sr) (address, &in, &addr_out, best_if, ...
The SearchUsingProcRoute() method failed because I had unplugged NIC cable.
SearchUsingRouteCmd(), line 270, there is declared string interface[].
The string "interface:" was not found in /sbin/route output, interface
string remained uninitialized.
On line 360
strncpy(best_if, interface, best_iflen);
the garbage was copied to best_if string, the SearchUsingRouteCmd()
returned zero and this garbage was first word of output of findif.

example of log:
IPaddr[3446]: [3470]: INFO: Using calculated nic for 127.9.2.82: _^H
IPaddr[3448]: [3473]: INFO: Using calculated nic for 127.9.2.83: _^H
IPaddr[3446]: [3482]: DEBUG: Using calculated netmask for 127.9.2.82:
255.255.255.255
IPaddr[3448]: [3487]: DEBUG: Using calculated netmask for 127.9.2.83:
255.255.255.255
IPaddr[3446]: [3488]: DEBUG: Using calculated broadcast for
127.9.2.82: 127.9.2.82
IPaddr[3448]: [3496]: DEBUG: Using calculated broadcast for
127.9.2.83: 127.9.2.83
IPaddr[3446]: [3524]: INFO: eval /sbin/ifconfig _^H:0 127.9.2.82
netmask 255.255.255.255 broadcast 127.9.2.82
lrmd: [3390]: info: RA output: (x_IPaddrL:start:stderr) SIOCSIFADDR:
No such device
IPaddr[3448]: [3535]: INFO: eval /sbin/ifconfig _^H:1 127.9.2.83
netmask 255.255.255.255 broadcast 127.9.2.83
lrmd: [3390]: info: RA output: (x_IPaddrL:start:stderr) _^H:0: ERROR
while getting interface flags: No such device


The attached patch worked fine for me.

IPaddr[8118]: [8137]: ERROR: /usr/local/lib/heartbeat/findif
127.9.2.83 failed [rc=1].
lrmd: [8057]: info: RA output: (x_IPaddrL:start:stderr) No interface found
IPaddr[8117]: [8139]: ERROR: /usr/local/lib/heartbeat/findif
127.9.2.82 failed [rc=1].


Palo
diff -urp d10161/heartbeat/findif.c dev/heartbeat/findif.c
--- d10161/heartbeat/findif.c	2007-02-12 16:51:21.000000000 +0100
+++ dev/heartbeat/findif.c	2007-02-14 00:14:28.000000000 +0100
@@ -275,11 +275,13 @@ SearchUsingRouteCmd (char *address, stru
 
 	
 	/* Open route and get the information */
-	snprintf (routecmd, errmsglen, "%s %s %s", ROUTE, ROUTEPARM, address);
+	snprintf (routecmd, sizeof(routecmd), "%s %s %s"
+	,	ROUTE, ROUTEPARM, address);
 	routefd = popen (routecmd, "r");
 	if (routefd == NULL)
 		return (-1);
 	mask[0] = EOS;
+	interface[0] = EOS;
 
 
 	while ((done < 3) && fgets(buf, sizeof(buf), routefd)) {
@@ -355,6 +357,10 @@ SearchUsingRouteCmd (char *address, stru
 	}
 
 	if ((in->s_addr & maskbits) == (addr_out->s_addr & maskbits)) {
+		if (interface[0] == EOS) {
+			snprintf(errmsg, errmsglen, "No interface found.");
+			return(1);
+		}
 		best_metric = 0;
 		*best_netmask = maskbits;
 		strncpy(best_if, interface, best_iflen);
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to