All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-10 21:23 ` Haiyang Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-10 21:23 UTC (permalink / raw)
  To: davem, netdev
  Cc: haiyangz, kys, olaf, vkuznets, linux-kernel, driverdev-devel

This script helps to create bonding network devices based on synthetic NIC
(the virtual network adapter usually provided by Hyper-V) and the matching
VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
function as one network device, and fail over to the synthetic NIC if VF is
down.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
v2: Make it to be distro neutral.
---
 tools/hv/bondvf.sh |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100755 tools/hv/bondvf.sh

diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
new file mode 100755
index 0000000..ec7abf1
--- /dev/null
+++ b/tools/hv/bondvf.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# The script helps creating bonding network devices based on synthetic NIC
+# (the virtual network adapter usually provided by Hyper-V) and the matching
+# VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
+# function as one network device, and fail over to the synthetic NIC if VF is
+# down.
+#
+# Usage:
+# - After configured vSwitch and vNIC with SRIOV, start Linux virtual
+#   machine (VM)
+# - Run this script on the VM. It will list the NIC pairs which should be
+#   bonded together. Also indicates which one should be the primary slave.
+# - User may create bonding NIC configurations based on the Distro manual.
+#   The bonding mode shoudl be "active-backup".
+#   Then, reboot the VM, so that the bonding config are enabled.
+#
+
+sysdir=/sys/class/net
+netvsc_cls={f8615163-df3e-46c5-913f-f2d2f965ed0e}
+bondcnt=0
+
+# Get a list of ethernet names
+list_eth=(`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`)
+eth_cnt=${#list_eth[@]}
+
+echo List of net devices:
+
+# Get the MAC addresses
+for (( i=0; i < $eth_cnt; i++ ))
+do
+	list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address`
+	echo ${list_eth[$i]}, ${list_mac[$i]}
+done
+
+# Find NIC with matching MAC
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+	for (( j=i+1; j < $eth_cnt; j++ ))
+	do
+		if [ "${list_mac[$i]}" = "${list_mac[$j]}" ]
+		then
+			list_match[$i]=${list_eth[$j]}
+			break
+		fi
+	done
+done
+
+function create_bond_cfg {
+	echo $'\nBond name:' $1
+	echo should include primary slave: $2, secondary slave: $3
+}
+
+function create_bond {
+	local bondname=bond$bondcnt
+
+	local class_id1=`cat $sysdir/$1/device/class_id 2>/dev/null`
+	local class_id2=`cat $sysdir/$2/device/class_id 2>/dev/null`
+
+	if [ "$class_id1" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $2 $1
+	elif [ "$class_id2" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $1 $2
+	else
+		return 0
+	fi
+
+	let bondcnt=bondcnt+1
+}
+
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+        if [ -n "${list_match[$i]}" ]
+        then
+		create_bond ${list_eth[$i]} ${list_match[$i]}
+        fi
+done
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next, v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-10 21:23 ` Haiyang Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-10 21:23 UTC (permalink / raw)
  To: davem, netdev; +Cc: olaf, haiyangz, driverdev-devel, linux-kernel

This script helps to create bonding network devices based on synthetic NIC
(the virtual network adapter usually provided by Hyper-V) and the matching
VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
function as one network device, and fail over to the synthetic NIC if VF is
down.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
v2: Make it to be distro neutral.
---
 tools/hv/bondvf.sh |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100755 tools/hv/bondvf.sh

diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
new file mode 100755
index 0000000..ec7abf1
--- /dev/null
+++ b/tools/hv/bondvf.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# The script helps creating bonding network devices based on synthetic NIC
+# (the virtual network adapter usually provided by Hyper-V) and the matching
+# VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
+# function as one network device, and fail over to the synthetic NIC if VF is
+# down.
+#
+# Usage:
+# - After configured vSwitch and vNIC with SRIOV, start Linux virtual
+#   machine (VM)
+# - Run this script on the VM. It will list the NIC pairs which should be
+#   bonded together. Also indicates which one should be the primary slave.
+# - User may create bonding NIC configurations based on the Distro manual.
+#   The bonding mode shoudl be "active-backup".
+#   Then, reboot the VM, so that the bonding config are enabled.
+#
+
+sysdir=/sys/class/net
+netvsc_cls={f8615163-df3e-46c5-913f-f2d2f965ed0e}
+bondcnt=0
+
+# Get a list of ethernet names
+list_eth=(`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`)
+eth_cnt=${#list_eth[@]}
+
+echo List of net devices:
+
+# Get the MAC addresses
+for (( i=0; i < $eth_cnt; i++ ))
+do
+	list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address`
+	echo ${list_eth[$i]}, ${list_mac[$i]}
+done
+
+# Find NIC with matching MAC
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+	for (( j=i+1; j < $eth_cnt; j++ ))
+	do
+		if [ "${list_mac[$i]}" = "${list_mac[$j]}" ]
+		then
+			list_match[$i]=${list_eth[$j]}
+			break
+		fi
+	done
+done
+
+function create_bond_cfg {
+	echo $'\nBond name:' $1
+	echo should include primary slave: $2, secondary slave: $3
+}
+
+function create_bond {
+	local bondname=bond$bondcnt
+
+	local class_id1=`cat $sysdir/$1/device/class_id 2>/dev/null`
+	local class_id2=`cat $sysdir/$2/device/class_id 2>/dev/null`
+
+	if [ "$class_id1" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $2 $1
+	elif [ "$class_id2" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $1 $2
+	else
+		return 0
+	fi
+
+	let bondcnt=bondcnt+1
+}
+
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+        if [ -n "${list_match[$i]}" ]
+        then
+		create_bond ${list_eth[$i]} ${list_match[$i]}
+        fi
+done
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net-next, v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-10 21:23 ` Haiyang Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-10 21:23 UTC (permalink / raw)
  To: davem, netdev; +Cc: olaf, haiyangz, driverdev-devel, linux-kernel

This script helps to create bonding network devices based on synthetic NIC
(the virtual network adapter usually provided by Hyper-V) and the matching
VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
function as one network device, and fail over to the synthetic NIC if VF is
down.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
v2: Make it to be distro neutral.
---
 tools/hv/bondvf.sh |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100755 tools/hv/bondvf.sh

diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
new file mode 100755
index 0000000..ec7abf1
--- /dev/null
+++ b/tools/hv/bondvf.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# The script helps creating bonding network devices based on synthetic NIC
+# (the virtual network adapter usually provided by Hyper-V) and the matching
+# VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
+# function as one network device, and fail over to the synthetic NIC if VF is
+# down.
+#
+# Usage:
+# - After configured vSwitch and vNIC with SRIOV, start Linux virtual
+#   machine (VM)
+# - Run this script on the VM. It will list the NIC pairs which should be
+#   bonded together. Also indicates which one should be the primary slave.
+# - User may create bonding NIC configurations based on the Distro manual.
+#   The bonding mode shoudl be "active-backup".
+#   Then, reboot the VM, so that the bonding config are enabled.
+#
+
+sysdir=/sys/class/net
+netvsc_cls={f8615163-df3e-46c5-913f-f2d2f965ed0e}
+bondcnt=0
+
+# Get a list of ethernet names
+list_eth=(`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`)
+eth_cnt=${#list_eth[@]}
+
+echo List of net devices:
+
+# Get the MAC addresses
+for (( i=0; i < $eth_cnt; i++ ))
+do
+	list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address`
+	echo ${list_eth[$i]}, ${list_mac[$i]}
+done
+
+# Find NIC with matching MAC
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+	for (( j=i+1; j < $eth_cnt; j++ ))
+	do
+		if [ "${list_mac[$i]}" = "${list_mac[$j]}" ]
+		then
+			list_match[$i]=${list_eth[$j]}
+			break
+		fi
+	done
+done
+
+function create_bond_cfg {
+	echo $'\nBond name:' $1
+	echo should include primary slave: $2, secondary slave: $3
+}
+
+function create_bond {
+	local bondname=bond$bondcnt
+
+	local class_id1=`cat $sysdir/$1/device/class_id 2>/dev/null`
+	local class_id2=`cat $sysdir/$2/device/class_id 2>/dev/null`
+
+	if [ "$class_id1" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $2 $1
+	elif [ "$class_id2" = "$netvsc_cls" ]
+	then
+		create_bond_cfg $bondname $1 $2
+	else
+		return 0
+	fi
+
+	let bondcnt=bondcnt+1
+}
+
+for (( i=0; i < $eth_cnt-1; i++ ))
+do
+        if [ -n "${list_match[$i]}" ]
+        then
+		create_bond ${list_eth[$i]} ${list_match[$i]}
+        fi
+done
-- 
1.7.4.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
  2016-06-10 21:23 ` Haiyang Zhang
  (?)
@ 2016-06-11  1:13   ` David Miller
  -1 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2016-06-11  1:13 UTC (permalink / raw)
  To: haiyangz; +Cc: netdev, kys, olaf, vkuznets, linux-kernel, driverdev-devel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Fri, 10 Jun 2016 14:23:12 -0700

> This script helps to create bonding network devices based on synthetic NIC
> (the virtual network adapter usually provided by Hyper-V) and the matching
> VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> function as one network device, and fail over to the synthetic NIC if VF is
> down.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> v2: Make it to be distro neutral.

This tool doesn't configure anything.

It fishes information out of sysfs and prints it out.

I don't think this is useful, not appropriate for the kernel
tools subdirectory at all.

When I said make it distro neutral, that meant if you wanted to submit
this again you were expected to do the hard work of making it
configure things properly on all major distributions.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-11  1:13   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2016-06-11  1:13 UTC (permalink / raw)
  To: haiyangz; +Cc: olaf, netdev, driverdev-devel, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Fri, 10 Jun 2016 14:23:12 -0700

> This script helps to create bonding network devices based on synthetic NIC
> (the virtual network adapter usually provided by Hyper-V) and the matching
> VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> function as one network device, and fail over to the synthetic NIC if VF is
> down.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> v2: Make it to be distro neutral.

This tool doesn't configure anything.

It fishes information out of sysfs and prints it out.

I don't think this is useful, not appropriate for the kernel
tools subdirectory at all.

When I said make it distro neutral, that meant if you wanted to submit
this again you were expected to do the hard work of making it
configure things properly on all major distributions.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-11  1:13   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2016-06-11  1:13 UTC (permalink / raw)
  To: haiyangz; +Cc: olaf, netdev, driverdev-devel, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Fri, 10 Jun 2016 14:23:12 -0700

> This script helps to create bonding network devices based on synthetic NIC
> (the virtual network adapter usually provided by Hyper-V) and the matching
> VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> function as one network device, and fail over to the synthetic NIC if VF is
> down.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> ---
> v2: Make it to be distro neutral.

This tool doesn't configure anything.

It fishes information out of sysfs and prints it out.

I don't think this is useful, not appropriate for the kernel
tools subdirectory at all.

When I said make it distro neutral, that meant if you wanted to submit
this again you were expected to do the hard work of making it
configure things properly on all major distributions.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
  2016-06-11  1:13   ` David Miller
  (?)
@ 2016-06-11 18:55     ` Haiyang Zhang
  -1 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-11 18:55 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, KY Srinivasan, olaf, vkuznets, linux-kernel, driverdev-devel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Friday, June 10, 2016 9:14 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: netdev@vger.kernel.org; KY Srinivasan <kys@microsoft.com>;
> olaf@aepfle.de; vkuznets@redhat.com; linux-kernel@vger.kernel.org;
> driverdev-devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding
> synthetic and VF NICs
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Fri, 10 Jun 2016 14:23:12 -0700
> 
> > This script helps to create bonding network devices based on synthetic NIC
> > (the virtual network adapter usually provided by Hyper-V) and the
> matching
> > VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> > function as one network device, and fail over to the synthetic NIC if VF is
> > down.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > v2: Make it to be distro neutral.
> 
> This tool doesn't configure anything.
> 
> It fishes information out of sysfs and prints it out.
> 
> I don't think this is useful, not appropriate for the kernel
> tools subdirectory at all.
> 
> When I said make it distro neutral, that meant if you wanted to submit
> this again you were expected to do the hard work of making it
> configure things properly on all major distributions.

The major distros supported by Hyper-V include RHEL, SLES, and Ubuntu.
I will put them into the configuration scripts -- is this sufficient?

Thanks,
- Haiyang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-11 18:55     ` Haiyang Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-11 18:55 UTC (permalink / raw)
  To: David Miller; +Cc: olaf, netdev, driverdev-devel, linux-kernel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Friday, June 10, 2016 9:14 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: netdev@vger.kernel.org; KY Srinivasan <kys@microsoft.com>;
> olaf@aepfle.de; vkuznets@redhat.com; linux-kernel@vger.kernel.org;
> driverdev-devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding
> synthetic and VF NICs
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Fri, 10 Jun 2016 14:23:12 -0700
> 
> > This script helps to create bonding network devices based on synthetic NIC
> > (the virtual network adapter usually provided by Hyper-V) and the
> matching
> > VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> > function as one network device, and fail over to the synthetic NIC if VF is
> > down.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > v2: Make it to be distro neutral.
> 
> This tool doesn't configure anything.
> 
> It fishes information out of sysfs and prints it out.
> 
> I don't think this is useful, not appropriate for the kernel
> tools subdirectory at all.
> 
> When I said make it distro neutral, that meant if you wanted to submit
> this again you were expected to do the hard work of making it
> configure things properly on all major distributions.

The major distros supported by Hyper-V include RHEL, SLES, and Ubuntu.
I will put them into the configuration scripts -- is this sufficient?

Thanks,
- Haiyang

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs
@ 2016-06-11 18:55     ` Haiyang Zhang
  0 siblings, 0 replies; 9+ messages in thread
From: Haiyang Zhang @ 2016-06-11 18:55 UTC (permalink / raw)
  To: David Miller; +Cc: olaf, netdev, driverdev-devel, linux-kernel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Friday, June 10, 2016 9:14 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: netdev@vger.kernel.org; KY Srinivasan <kys@microsoft.com>;
> olaf@aepfle.de; vkuznets@redhat.com; linux-kernel@vger.kernel.org;
> driverdev-devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next,v2] tools: hv: Add a script to help bonding
> synthetic and VF NICs
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Fri, 10 Jun 2016 14:23:12 -0700
> 
> > This script helps to create bonding network devices based on synthetic NIC
> > (the virtual network adapter usually provided by Hyper-V) and the
> matching
> > VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
> > function as one network device, and fail over to the synthetic NIC if VF is
> > down.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> > ---
> > v2: Make it to be distro neutral.
> 
> This tool doesn't configure anything.
> 
> It fishes information out of sysfs and prints it out.
> 
> I don't think this is useful, not appropriate for the kernel
> tools subdirectory at all.
> 
> When I said make it distro neutral, that meant if you wanted to submit
> this again you were expected to do the hard work of making it
> configure things properly on all major distributions.

The major distros supported by Hyper-V include RHEL, SLES, and Ubuntu.
I will put them into the configuration scripts -- is this sufficient?

Thanks,
- Haiyang

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-11 19:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-10 21:23 [PATCH net-next,v2] tools: hv: Add a script to help bonding synthetic and VF NICs Haiyang Zhang
2016-06-10 21:23 ` [PATCH net-next, v2] " Haiyang Zhang
2016-06-10 21:23 ` Haiyang Zhang
2016-06-11  1:13 ` [PATCH net-next,v2] " David Miller
2016-06-11  1:13   ` David Miller
2016-06-11  1:13   ` David Miller
2016-06-11 18:55   ` Haiyang Zhang
2016-06-11 18:55     ` Haiyang Zhang
2016-06-11 18:55     ` Haiyang Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.