From d7adfdf549f2545b5bb5c03a75222a217e45902a Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Fri, 8 Mar 2024 10:42:13 -0600 Subject: [PATCH] udev scripts: Support network interfaces rename on DPU only Avoid renaming network interfaces unless operating on a BlueField DPU. Signed-off-by: Vladimir Sokolovsky --- udev/scripts/auxdev-sf-netdev-rename | 7 +++++++ udev/scripts/sf-rep-netdev-rename | 7 +++++++ udev/scripts/vf-net-link-name.sh | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/udev/scripts/auxdev-sf-netdev-rename b/udev/scripts/auxdev-sf-netdev-rename index 705a356..2726737 100755 --- a/udev/scripts/auxdev-sf-netdev-rename +++ b/udev/scripts/auxdev-sf-netdev-rename @@ -15,6 +15,13 @@ SFNUM=$1 IFINDEX=$2 +PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin + +is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0` +if [ $is_bf -ne 1 ]; then + exit 0 +fi + for sf_ndev in `ls /sys/class/net/`; do _ifindex=`cat /sys/class/net/$sf_ndev/ifindex | head -1 2>/dev/null` if [ "$_ifindex" = "$IFINDEX" ] diff --git a/udev/scripts/sf-rep-netdev-rename b/udev/scripts/sf-rep-netdev-rename index 130201e..b1ec209 100755 --- a/udev/scripts/sf-rep-netdev-rename +++ b/udev/scripts/sf-rep-netdev-rename @@ -3,6 +3,13 @@ PORT_NAME=$1 IFINDEX=$2 +PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin + +is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0` +if [ $is_bf -ne 1 ]; then + exit 0 +fi + for rep_ndev in `ls /sys/class/net/`; do _ifindex=`cat /sys/class/net/$rep_ndev/ifindex | head -1 2>/dev/null` if [ "$_ifindex" = "$IFINDEX" ] diff --git a/udev/scripts/vf-net-link-name.sh b/udev/scripts/vf-net-link-name.sh index de21682..05cc30f 100755 --- a/udev/scripts/vf-net-link-name.sh +++ b/udev/scripts/vf-net-link-name.sh @@ -7,7 +7,12 @@ PORT_NAME=`echo ${1} | sed -e "s/c[[:digit:]]\+//"` IFINDEX=$3 # need the PATH for BF ARM lspci to work -PATH=/bin:/sbin:/usr/bin:/usr/sbin +PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin + +is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0` +if [ $is_bf -ne 1 ]; then + exit 0 +fi if [[ "$ID_NET_DRIVER" != *"mlx5"* ]]; then exit 1 @@ -46,7 +51,6 @@ function get_mh_bf_rep_name() { done } -is_bf=`lspci -s 00:00.0 2> /dev/null | grep -wq "PCI bridge: Mellanox Technologies" && echo 1 || echo 0` if [ $is_bf -eq 1 ]; then num_of_pf=`lspci 2> /dev/null | grep -w "network" | wc -l` if [ $num_of_pf -gt 2 ]; then