linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tools: hv: Add clean up function for Ubuntu config
@ 2017-02-24 17:30 Haiyang Zhang
  2017-03-07  1:11 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Haiyang Zhang @ 2017-02-24 17:30 UTC (permalink / raw)
  To: davem, netdev, linux-kernel
  Cc: Haiyang Zhang, KY Srinivasan, Olaf Hering (olaf@aepfle.de), vkuznets

This patch adds a function to clean up duplicate config info
on Ubuntu.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 tools/hv/bondvf.sh |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
index 4aa5369..d85968c 100755
--- a/tools/hv/bondvf.sh
+++ b/tools/hv/bondvf.sh
@@ -101,9 +101,25 @@ function create_bond_cfg_redhat {
 	echo BONDING_OPTS=\"mode=active-backup miimon=100 primary=$2\" >>$fn
 }
 
+function del_eth_cfg_ubuntu {
+	local fn=$cfgdir/interfaces
+	local tmpfl=$(mktemp)
+
+	local nic_start='^[ \t]*(auto|iface|mapping|allow-.*)[ \t]+'$1
+	local nic_end='^[ \t]*(auto|iface|mapping|allow-.*|source)'
+
+	awk "/$nic_end/{x=0} x{next} /$nic_start/{x=1;next} 1"  $fn >$tmpfl
+
+	cp $tmpfl $fn
+
+	rm $tmpfl
+}
+
 function create_eth_cfg_ubuntu {
 	local fn=$cfgdir/interfaces
 
+	del_eth_cfg_ubuntu $1
+
 	echo $'\n'auto $1 >>$fn
 	echo iface $1 inet manual >>$fn
 	echo bond-master $2 >>$fn
@@ -119,6 +135,8 @@ function create_eth_cfg_pri_ubuntu {
 function create_bond_cfg_ubuntu {
 	local fn=$cfgdir/interfaces
 
+	del_eth_cfg_ubuntu $1
+
 	echo $'\n'auto $1 >>$fn
 	echo iface $1 inet dhcp >>$fn
 	echo bond-mode active-backup >>$fn
-- 
1.7.1

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

* Re: [PATCH net-next] tools: hv: Add clean up function for Ubuntu config
  2017-02-24 17:30 [PATCH net-next] tools: hv: Add clean up function for Ubuntu config Haiyang Zhang
@ 2017-03-07  1:11 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-07  1:11 UTC (permalink / raw)
  To: haiyangz; +Cc: netdev, linux-kernel, kys, olaf, vkuznets

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Fri, 24 Feb 2017 17:30:32 +0000

> This patch adds a function to clean up duplicate config info
> on Ubuntu.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Applied, thanks.

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

end of thread, other threads:[~2017-03-07  1:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 17:30 [PATCH net-next] tools: hv: Add clean up function for Ubuntu config Haiyang Zhang
2017-03-07  1:11 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).