From b4331f2c353e1bdb91787470319bfe6e4774c484 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Dec 2019 13:54:16 +0000 Subject: [PATCH] Adding support for IPoIb interfaces The patch allow to ifup/ifdown IpoIB interfaces from network-scripts The required config is the following DEVICE=ib0.8005 # ib0 the it IB interface TYPE=Infiniband # the type is Infiniband PKEY=yes # indicator that it's IPoIB interface PKEY_ID=5 # the pkey number --- network-scripts/ifdown | 6 +++++- network-scripts/ifdown-ib | 14 ++++++++++++++ network-scripts/ifup | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 network-scripts/ifdown-ib diff --git a/network-scripts/ifdown b/network-scripts/ifdown index ec05891db..9d9f20df8 100755 --- a/network-scripts/ifdown +++ b/network-scripts/ifdown @@ -71,7 +71,11 @@ if [ ! -x ${OTHERSCRIPT} ]; then fi if [ ! -x ${OTHERSCRIPT} ]; then - OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" + if is_true "${PKEY}" && [ "${TYPE}" = "Infiniband" ] ; then + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-ib" + else + OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" + fi fi exec ${OTHERSCRIPT} ${CONFIG} $2 diff --git a/network-scripts/ifdown-ib b/network-scripts/ifdown-ib new file mode 100755 index 000000000..dec996ac8 --- /dev/null +++ b/network-scripts/ifdown-ib @@ -0,0 +1,14 @@ +#!/bin/bash + +cd /etc/sysconfig/network-scripts +. ./network-functions +CONFIG=${1} +source_config + +if is_true "${PKEY}" && [ "${TYPE}" = "Infiniband" ] ; then + # IPoIB support + if [ -d /sys/devices/virtual/net/${DEVICE} ]; then + ip link del "${DEVICE}" + fi +fi +exit 0 diff --git a/network-scripts/ifup b/network-scripts/ifup index 9c1380bb9..db86f2881 100755 --- a/network-scripts/ifup +++ b/network-scripts/ifup @@ -149,6 +149,29 @@ if is_true "${VLAN}" && is_false "$ISALIAS" && [ -n "$DEVICE" ]; then --prefix "/proc/sys/net/ipv6/conf/${DEVICE}" fi +# IPoIB support +if is_true "${PKEY}" && [ "${TYPE}" = "Infiniband" ] ; then + MATCH='^.+\.[0-9]{1,4}$' + if [[ "${DEVICE}" =~ $MATCH ]]; then + PHYSDEV=${DEVICE%.*} + fi + if ! modprobe ib_ipoib >/dev/null 2>&1 ; then + net_log $"No IPoIB support available in kernel for device ${DEVICE}" + exit 1 + fi + if [ -d /sys/devices/virtual/net/${DEVICE} ]; then + check_device_down ${DEVICE} && { ip -o link set dev ${DEVICE} up; } + else + ip link add dev ${DEVICE} link ${PHYSDEV} type ipoib pkey ${PKEY_ID} || { + (/usr/bin/logger -p daemon.info -t ifup \$"ERROR: could not add + pkey ${PKEY_ID} as ${DEVICE} on dev ${PHYSDEV}" &) & + net_log $"ERROR: could not add pkey ${PKEY_ID} as ${DEVICE} on dev ${PHYSDEV}" + exit 1 + } + fi + exit 0 +fi + if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then DYNCONFIG=true fi