From 14b900d3c9ce952896c670b56b72b25f6cb38574 Mon Sep 17 00:00:00 2001 From: Moshe Levi Date: Mon, 1 Feb 2016 18:22:04 +0200 Subject: [PATCH] Adding InfiniBand Support This patch update the find_interface to lookup for InfiniBand interface according to it's BOOTIF Closes-Bug: #1532534 Change-Id: I21b91cfd10888ac036f6347a0a44cdca422830a6 --- .../extra-data.d/scripts/d/init-func | 19 ++++++++++++++++--- .../ramdisk-base/init.d/20-init-variables | 19 +++++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/elements/ramdisk-base/extra-data.d/scripts/d/init-func b/elements/ramdisk-base/extra-data.d/scripts/d/init-func index 0012d031..ff68a927 100755 --- a/elements/ramdisk-base/extra-data.d/scripts/d/init-func +++ b/elements/ramdisk-base/extra-data.d/scripts/d/init-func @@ -161,11 +161,24 @@ function partition_name() { function find_interface() { local mac=$1 - eth=`ifconfig -a | grep -i "$mac" | awk {' print $1 '} | head -n 1` - if [ -n "$eth" ]; then - echo "$eth" + local interface + interface=$(ip link show | grep -B1 -i $mac | awk '/mtu/ { print $2 }') + if [ -n "$interface" ]; then + echo "${interface%:}" return 0 else + # Note(moshele): try to find the InfinBand interface by + # matching the InfinBand MAC upper and lower + # 3 octets to the GUID lower and upper 3 octets. + local upper_octs=${mac:0:8} + local lower_octs=${mac:9:16} + ib_re="${upper_octs}:[A-F0-9][A-F0-9]:[A-F0-9][A-F0-9]:${lower_octs}" + interface=$(ip link show | grep -B1 -i ${ib_re} | grep mtu | \ + awk {'print $2'}) + if [ -n "$interface" ]; then + echo "${interface%:}" + return 0 + fi return 1 fi } diff --git a/elements/ramdisk-base/init.d/20-init-variables b/elements/ramdisk-base/init.d/20-init-variables index 405b2563..e5bfb9de 100644 --- a/elements/ramdisk-base/init.d/20-init-variables +++ b/elements/ramdisk-base/init.d/20-init-variables @@ -16,8 +16,23 @@ fi readonly _BOOTIF_=$(get_kernel_parameter BOOTIF) readonly _IP_=$(get_kernel_parameter ip) -readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | \ - sed -e "s/^01://g" | tr 'a-f' 'A-F') + +# _BOOTIF_ is the hardware type with the MAC address +# see http://www.syslinux.org/wiki/index.php/PXELINUX +if [[ $_BOOTIF_ =~ ^20.* && ${#_BOOTIF_} == 20 ]]; then + # InfiniBand hardware type is 20 with InfiniBand MAC + # For example InfiniBand GID: + # 80:00:02:08:fe:80:00:00:00:00:00:00:f4:52:14:03:00:3a:16:b1 + # is converted to BOOTIF 20:f4:52:14:3a:16:b1 + MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | \ + sed -e "s/^20://g" | tr 'a-f' 'A-F') +else + # Ethernet BOOTIF hardware type is 01 with MAC + MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | \ + sed -e "s/^01://g" | tr 'a-f' 'A-F') +fi + +readonly BOOT_MAC_ADDRESS=$MAC_ADDRESS # If bootloader did not pass on network info, we fallback to a kernel # parameter to locate the address of the boot server.