Bug 596823 - syntax error in /etc/sysconfig/network-scripts/ifup-ib
Summary: syntax error in /etc/sysconfig/network-scripts/ifup-ib
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: openib
Version: 5.5
Hardware: All
OS: Linux
high
low
Target Milestone: rc
: ---
Assignee: Jay Fenlason
QA Contact: Network QE
URL:
Whiteboard:
: 670936 673201 (view as bug list)
Depends On:
Blocks: 590060
TreeView+ depends on / blocked
 
Reported: 2010-05-27 15:07 UTC by Karsten Weiss
Modified: 2018-11-14 17:26 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 602941 (view as bug list)
Environment:
Last Closed: 2011-07-21 11:22:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Syntax error fix for /etc/sysconfig/network-scripts/ifup-ib from openib-1.4.1-5.el5 (820 bytes, patch)
2010-05-27 15:07 UTC, Karsten Weiss
no flags Details | Diff
patch for openib-ifup-ib script (211 bytes, text/plain)
2011-03-26 16:15 UTC, IBM Bug Proxy
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1056 0 normal SHIPPED_LIVE openib bug fix update 2011-07-20 15:43:25 UTC

Internal Links: 673201

Description Karsten Weiss 2010-05-27 15:07:24 UTC
Created attachment 417276 [details]
Syntax error fix for /etc/sysconfig/network-scripts/ifup-ib from openib-1.4.1-5.el5

Description of problem:

There is a syntax error in /etc/sysconfig/network-scripts/ifup-ib which
causes the following boot process error message during Infiniband interface initialization:

ifup-ib: line 79: [: too many arguments

The problem is that bash's "-a" (AND) operator is not evaluated lazily i.e. the following construct in ifup-ib does not work correctly if the MTU variable is unset/empty:

        # cap the MTU where we should based upon mode
        if [ -n "${MTU}" -a $MTU -gt 2044 ]; then
            MTU=2044
        fi

This alternative works because the && operator is evaluated lazily:

        # cap the MTU where we should based upon mode
        if [ -n "${MTU}" ] && [ $MTU -gt 2044 ]; then
            MTU=2044
        fi

Another alternative would be this

        # cap the MTU where we should based upon mode
        if [ -n "${MTU}" ]; then
            if [ $MTU -gt 2044 ]; then
                MTU=2044
            fi
        fi

I've attached a patch which fixes the two occurrences of this construct in ifup-ib.

Version-Release number of selected component (if applicable):

# rpm -q openib
openib-1.4.1-5.el5

How reproducible:

Boot a system with an active IB interface which has not MTU
configured explicitly in /etc/sysconfig/network-scripts/ifcfg-ib0.

Steps to Reproduce:
1. Configure an ib0 interface without setting MTU in /etc/sysconfig/network-scripts/ifcfg-ib0
2. Boot the system
3. Watch for the error messages during ib0 interface initialization.
  
Actual results:

ifup-ib: line 79: [: too many arguments

Expected results:

No error message

Additional info:

Test cases:

$ cat MTU-old.sh
#!/bin/bash                                      

MTU=""
if [ -n "${MTU}" -a $MTU -gt 2044 ]; then
        echo 1a                          
else                                     
        echo 1b                          
fi                                       

MTU="2000"
if [ -n "${MTU}" -a $MTU -gt 2044 ]; then
        echo 2a                          
else                                     
        echo 2b                          
fi

MTU="3000"
if [ -n "${MTU}" -a $MTU -gt 2044 ]; then
        echo 3a
else
        echo 3b
fi

$ cat MTU-new.sh
#!/bin/bash

MTU=""
if [ -n "${MTU}" ] && [ $MTU -gt 2044 ]; then
        echo 1a
else
        echo 1b
fi

MTU="2000"
if [ -n "${MTU}" ] && [ $MTU -gt 2044 ]; then
        echo 2a
else
        echo 2b
fi

MTU="3000"
if [ -n "${MTU}" ] && [ $MTU -gt 2044 ]; then
        echo 3a
else
        echo 3b
fi

Test results:

$ ./MTU-old.sh
./MTU-old.sh: line 4: [: too many arguments
1b
2b
3a
$ ./MTU-new.sh
1b
2b
3a

Comment 1 Owen Barton 2010-06-28 23:19:39 UTC
I can confirm that this reproduces on 5.5

Comment 4 Christopher Dale 2010-10-24 20:42:46 UTC
I see that this bug is still listed as 'New'.  Is it ever going to be moved into the production build?

Comment 8 Jay Fenlason 2011-02-03 20:26:29 UTC
*** Bug 670936 has been marked as a duplicate of this bug. ***

Comment 9 Jay Fenlason 2011-02-09 19:00:47 UTC
*** Bug 673201 has been marked as a duplicate of this bug. ***

Comment 12 IBM Bug Proxy 2011-03-26 16:15:31 UTC
------- Comment From sudeeshjohn.com 2010-12-22 11:57 EDT-------
I had communicated this issues to Doug Ledford (dledford), and he says that;

"This patch is the same as how we modified this script for rhel6, so feel free to open a bug, but the patch is not really necessary (simplyreference the rhel6 rdma version of this script instead)"

So RH can use the  fixed version(ifup-ib script version2) of the script  available, in RHEL6.

Thanks....

Comment 13 IBM Bug Proxy 2011-03-26 16:15:43 UTC
Created attachment 487859 [details]
patch for openib-ifup-ib script

Comment 18 IBM Bug Proxy 2011-05-26 10:50:30 UTC
------- Comment From iranna.ankad.com 2011-05-26 06:50 EDT-------
This is verified in RHEL5.7 Beta & confirmed its fixed...closing..

Comment 21 errata-xmlrpc 2011-07-21 11:22:14 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1056.html


Note You need to log in before you can comment on or make changes to this bug.