Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Oct 2009 10:06:18 GMT
From:      Mark Round <mark.round@ahc.uk.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/140012: Error in heartbeat-2.1.4_3, find_interface_bsd
Message-ID:  <200910271006.n9RA6II1046325@www.freebsd.org>
Resent-Message-ID: <200910271010.n9RAA3Pn081431@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         140012
>Category:       ports
>Synopsis:       Error in heartbeat-2.1.4_3, find_interface_bsd
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 27 10:10:03 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Mark Round
>Release:        7.1-RELEASE
>Organization:
>Environment:
FreeBSD freebsd1.ahc.uk.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 14:37:25 UTC 2009     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
I am using the heartbeat-2.1.4_3 package, built from ports. There is a problem with the /usr/local/etc/ocf/resource.d/heartbeat/IPaddr script. Inside this file, there is a find_interface_bsd function, which contains a typo in a regex. 

The end result is that it returns true for an IP address, even if it's only a partial match (a substring match). This means that in some circumstances, heartbeat will not start, with an error similar to the following :

2009/10/25_10:20:48 CRITICAL: Resource IPaddr::192.168.1.1/24/bge0 is active, and should not be!
2009/10/25_10:20:48 CRITICAL: Non-idle resources can affect data integrity!


>How-To-Repeat:
- Install heartbeat-2.1.4_3 from ports

- Configure an IP address on an interface, e.g:

ifconfig bge0 172.16.7.120 netmask 255.255.255.0

Now try using the IPaddr script to check for the presence of an IP address that would be matched. As the faulty regex does not include a space at the end, it will return true if the IP address is a _substring_ of the configured ip address :

# /usr/local/etc/ha.d/resource.d/IPaddr 172.16.7.1/24/em0 status
2009/10/27_10:00:00 INFO:  Running OK
INFO:  Running OK

# /usr/local/etc/ha.d/resource.d/IPaddr 172.16.7.12/24/em0 status
2009/10/27_10:00:03 INFO:  Running OK
INFO:  Running OK

Neither of the 172.16.7.1 or 172.16.7.12 IP addresses are actually being handled by that interface, but as they are substrings of the 172.16.7.120 IP address that _is_ being handled, they return true.


>Fix:
This is a problem with the way find_interface_bsd parses the output of ifconfig. By adding a space to the end of the regex, it only then finds exact matches :

Simply patch /usr/local/etc/ocf/resource.d/heartbeat/IPaddr with the following (also attached as a .txt file to this report)

*** IPaddr.orig Tue Oct 27 09:43:11 2009
--- IPaddr      Tue Oct 27 09:43:37 2009
***************
*** 334,338 ****
                      $if_status = ( /UP/ ) ? 1 : 0;
                  }
!                 if ( /^\s+inet\s+${ip}/ ) {
                      if ( $if_status ) {
                          print $if_name;
--- 334,338 ----
                      $if_status = ( /UP/ ) ? 1 : 0;
                  }
!                 if ( /^\s+inet\s+${ip} / ) {
                      if ( $if_status ) {
                          print $if_name;


Patch attached with submission follows:

*** IPaddr.orig Tue Oct 27 09:43:11 2009
--- IPaddr      Tue Oct 27 09:43:37 2009
***************
*** 334,338 ****
                      $if_status = ( /UP/ ) ? 1 : 0;
                  }
!                 if ( /^\s+inet\s+${ip}/ ) {
                      if ( $if_status ) {
                          print $if_name;
--- 334,338 ----
                      $if_status = ( /UP/ ) ? 1 : 0;
                  }
!                 if ( /^\s+inet\s+${ip} / ) {
                      if ( $if_status ) {
                          print $if_name;



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910271006.n9RA6II1046325>