summaryrefslogtreecommitdiffstats
path: root/tools/hv
diff options
context:
space:
mode:
authorsixiao@microsoft.com <sixiao@microsoft.com>2017-07-14 10:47:20 -0700
committerDavid S. Miller <davem@davemloft.net>2017-07-16 16:36:01 -0700
commit1c3a044c6013b7fcf4738129a1141c9c1994bb86 (patch)
tree969bebd4740b577fe1855f701837a9d9a24a66b8 /tools/hv
parent98524e04e0500a04fc461195c99e4385001fc18f (diff)
downloadlinux-1c3a044c6013b7fcf4738129a1141c9c1994bb86.tar.bz2
tools: hv: ignore a NIC if it has been configured
Let bondvf.sh ignore this NIC if it has been configured, to prevent user configuration from being overwritten unexpectly. Signed-off-by: Simon Xiao <sixiao@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/hv')
-rwxr-xr-xtools/hv/bondvf.sh27
1 files changed, 25 insertions, 2 deletions
diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
index 89b25068cd98..80f102860cf8 100755
--- a/tools/hv/bondvf.sh
+++ b/tools/hv/bondvf.sh
@@ -211,6 +211,30 @@ function create_bond {
echo $'\nBond name:' $bondname
+ if [ $distro == ubuntu ]
+ then
+ local mainfn=$cfgdir/interfaces
+ local s="^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+${bondname}"
+
+ grep -E "$s" $mainfn
+ if [ $? -eq 0 ]
+ then
+ echo "WARNING: ${bondname} has been configured already"
+ return
+ fi
+ elif [ $distro == redhat ] || [ $distro == suse ]
+ then
+ local fn=$cfgdir/ifcfg-$bondname
+ if [ -f $fn ]
+ then
+ echo "WARNING: ${bondname} has been configured already"
+ return
+ fi
+ else
+ echo "Unsupported Distro: ${distro}"
+ return
+ fi
+
echo configuring $primary
create_eth_cfg_pri_$distro $primary $bondname
@@ -219,8 +243,6 @@ function create_bond {
echo creating: $bondname with primary slave: $primary
create_bond_cfg_$distro $bondname $primary $secondary
-
- let bondcnt=bondcnt+1
}
for (( i=0; i < $eth_cnt-1; i++ ))
@@ -228,5 +250,6 @@ do
if [ -n "${list_match[$i]}" ]
then
create_bond ${list_eth[$i]} ${list_match[$i]}
+ let bondcnt=bondcnt+1
fi
done