~alpine/devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[alpine-devel] [PATCH] alpine-conf: modify setup-interfaces to create simple bridges

Roger Pau Monne <roger.pau@entel.upc.edu>
Details
Message ID
<1325182586-2051-1-git-send-email-roger.pau@entel.upc.edu>
Sender timestamp
1325182586
DKIM signature
missing
Download raw message
Patch: +41 -4
Modified setup-interfaces to create simple bridges (works only with
one interface per bridge). Useful when setting up a Xen system, since
interfaces need to be bridged in order for guests to have networking.
Some distributions automatically create one bridge for each interface
when Xen is installed, but I think this is too aggressive.
---
 setup-interfaces.in |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/setup-interfaces.in b/setup-interfaces.in
index b461529..f78b23b 100755
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -5,6 +5,7 @@ PREFIX=

. $PREFIX/lib/libalpine.sh

bridges=""

detect_interfaces() {
	ip addr | grep -v ' lo:' | awk -F : '/^[0-9]*:/ { print $2}'
@@ -42,7 +43,26 @@ config_iface() {
	local address
	local netmask
	local gateway
	local bridge
	local conf=$prefix$iface.conf
	local answer

	while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do
		echon "Do you want to bridge the interface $iface? [no] "
		default_read answer no
	done

	if [ "$answer" = "yes" ]; then
		bridge="br"`echo $iface | sed 's/[^0-9]//g'`
		while [ 1 ]; do
			echon "Name of the bridge you would like to create: [$bridge] "
			default_read bridge $bridge
			`echo "$bridges" | grep -q "$bridge"` || break
			echo "Name already in use, please choose another one"
		done
		echo "bridge=${bridge}" > $conf
		bridges="$bridges $bridge"
	fi

	# use ipcalc to validate the address. we do accept /mask
	# we are no interested in the result, only error code, so
@@ -55,7 +75,7 @@ config_iface() {
		[ "$address" = "abort" ] && return
		if [ "$address" = "dhcp" ] ; then
			HAS_DHCP=yes
			echo "type=dhcp" > $conf
			echo "type=dhcp" >> $conf
			rm $iface.noconf
			return
		fi
@@ -87,7 +107,7 @@ config_iface() {
		[ -z "$gateway" ] && break
	done
	
	echo "type=static" > $conf
	echo "type=static" >> $conf
	echo "address=${address%%/*}" >> $conf  #strip off /mask if there
	echo "netmask=$netmask" >> $conf
	echo "gateway=$gateway" >> $conf
@@ -146,8 +166,20 @@ prompt_for_interfaces() {
		iface=`basename $i .conf`
		iface=${iface#[0-9]*~}
		. ./$i
		echo "auto $iface" >> interfaces
		echo "iface $iface inet $type" >> interfaces
		if [ -n "$bridge" ]; then
			echo "auto $iface $bridge" >> interfaces
			echo "" >> interfaces
			echo "iface $iface inet manual" >> interfaces
			echo -e "\tup ip link set \$IFACE up" >> interfaces
			echo -e "\tdown ip link set \$IFACE down" >> interfaces
			echo "" >> interfaces
			echo "iface $bridge inet $type" >> interfaces
			echo -e "\tpre-up brctl addbr $bridge" >> interfaces
			echo -e "\tpre-up brctl addif $bridge $iface" >> interfaces
		else
			echo "auto $iface" >> interfaces
			echo "iface $iface inet $type" >> interfaces
		fi
		case $type in
		dhcp)
			[ -n "$hostname" ] \
@@ -160,7 +192,12 @@ prompt_for_interfaces() {
				&& echo -e "\tgateway $gateway" >> interfaces
			;;
		esac
		if [ -n "$bridge" ]; then
			echo -e "\tpost-down brctl delif $bridge $iface" >> interfaces
			echo -e "\tpost-down brctl delbr $bridge" >> interfaces
		fi
		echo "" >> interfaces
		bridge=""
	done
	
	while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do
-- 
1.7.7.1



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Details
Message ID
<CAFivhPmcQVuR5pL2VzJCwdn9zvd4tkcNawyZGFS+yUDva=L+Ew@mail.gmail.com>
In-Reply-To
<1325182586-2051-1-git-send-email-roger.pau@entel.upc.edu> (view parent)
Sender timestamp
1325183294
DKIM signature
missing
Download raw message
Hi,

2011/12/29 Roger Pau Monne <roger.pau@entel.upc.edu>:
> Modified setup-interfaces to create simple bridges (works only with
> one interface per bridge). Useful when setting up a Xen system, since
> interfaces need to be bridged in order for guests to have networking.
> Some distributions automatically create one bridge for each interface
> when Xen is installed, but I think this is too aggressive.

Yup, I think that is deprecated by xen devs too. The XL stack tries to
avoid messing with the OS networking setup. It used to be a PITA if
you have many bridges.

Does anyone have OpenVswitch on Alpine yet?
Because in practice I'll often have lacp+vlans and then quite a few
bridges per Vlan, things being made worse by issues with the bridges
(low general performance and lacp load balancing)

Greetings,
Florian


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20111230103649.7c25684e@ncopa-desktop.nor.wtbts.net>
In-Reply-To
<1325182586-2051-1-git-send-email-roger.pau@entel.upc.edu> (view parent)
Sender timestamp
1325237809
DKIM signature
missing
Download raw message
On Thu, 29 Dec 2011 19:16:26 +0100
Roger Pau Monne <roger.pau@entel.upc.edu> wrote:

> Modified setup-interfaces to create simple bridges (works only with
> one interface per bridge). Useful when setting up a Xen system, since
> interfaces need to be bridged in order for guests to have networking.
> Some distributions automatically create one bridge for each interface
> when Xen is installed, but I think this is too aggressive.

Nice!

as mentioned in IRC, I think we should check only ask for bridge in
case its a xen dom0. I want try keep number of questions down to
minimum.

Thanks!

-nc

> ---
>  setup-interfaces.in |   45
> +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 41
> insertions(+), 4 deletions(-)
> 
> diff --git a/setup-interfaces.in b/setup-interfaces.in
> index b461529..f78b23b 100755
> --- a/setup-interfaces.in
> +++ b/setup-interfaces.in
> @@ -5,6 +5,7 @@ PREFIX=
>  
>  . $PREFIX/lib/libalpine.sh
>  
> +bridges=""
>  
>  detect_interfaces() {
>  	ip addr | grep -v ' lo:' | awk -F : '/^[0-9]*:/ { print $2}'
> @@ -42,7 +43,26 @@ config_iface() {
>  	local address
>  	local netmask
>  	local gateway
> +	local bridge
>  	local conf=$prefix$iface.conf
> +	local answer
> +
> +	while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do
> +		echon "Do you want to bridge the interface $iface?
> [no] "
> +		default_read answer no
> +	done
> +
> +	if [ "$answer" = "yes" ]; then
> +		bridge="br"`echo $iface | sed 's/[^0-9]//g'`
> +		while [ 1 ]; do
> +			echon "Name of the bridge you would like to
> create: [$bridge] "
> +			default_read bridge $bridge
> +			`echo "$bridges" | grep -q "$bridge"` ||
> break
> +			echo "Name already in use, please choose
> another one"
> +		done
> +		echo "bridge=${bridge}" > $conf
> +		bridges="$bridges $bridge"
> +	fi
>  
>  	# use ipcalc to validate the address. we do accept /mask
>  	# we are no interested in the result, only error code, so
> @@ -55,7 +75,7 @@ config_iface() {
>  		[ "$address" = "abort" ] && return
>  		if [ "$address" = "dhcp" ] ; then
>  			HAS_DHCP=yes
> -			echo "type=dhcp" > $conf
> +			echo "type=dhcp" >> $conf
>  			rm $iface.noconf
>  			return
>  		fi
> @@ -87,7 +107,7 @@ config_iface() {
>  		[ -z "$gateway" ] && break
>  	done
>  	
> -	echo "type=static" > $conf
> +	echo "type=static" >> $conf
>  	echo "address=${address%%/*}" >> $conf  #strip off /mask if
> there echo "netmask=$netmask" >> $conf
>  	echo "gateway=$gateway" >> $conf
> @@ -146,8 +166,20 @@ prompt_for_interfaces() {
>  		iface=`basename $i .conf`
>  		iface=${iface#[0-9]*~}
>  		. ./$i
> -		echo "auto $iface" >> interfaces
> -		echo "iface $iface inet $type" >> interfaces
> +		if [ -n "$bridge" ]; then
> +			echo "auto $iface $bridge" >> interfaces
> +			echo "" >> interfaces
> +			echo "iface $iface inet manual" >> interfaces
> +			echo -e "\tup ip link set \$IFACE up" >>
> interfaces
> +			echo -e "\tdown ip link set \$IFACE down" >>
> interfaces
> +			echo "" >> interfaces
> +			echo "iface $bridge inet $type" >> interfaces
> +			echo -e "\tpre-up brctl addbr $bridge" >>
> interfaces
> +			echo -e "\tpre-up brctl addif $bridge
> $iface" >> interfaces
> +		else
> +			echo "auto $iface" >> interfaces
> +			echo "iface $iface inet $type" >> interfaces
> +		fi
>  		case $type in
>  		dhcp)
>  			[ -n "$hostname" ] \
> @@ -160,7 +192,12 @@ prompt_for_interfaces() {
>  				&& echo -e "\tgateway $gateway" >>
> interfaces ;;
>  		esac
> +		if [ -n "$bridge" ]; then
> +			echo -e "\tpost-down brctl delif $bridge
> $iface" >> interfaces
> +			echo -e "\tpost-down brctl delbr $bridge" >>
> interfaces
> +		fi
>  		echo "" >> interfaces
> +		bridge=""
>  	done
>  	
>  	while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)