WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] Network-bridge with VLAN

To: "Gael Reignier" <gael@xxxxxxxxxx>
Subject: Re: [Xen-users] Network-bridge with VLAN
From: "Alain Barthe" <ab266061@xxxxxxxxx>
Date: Wed, 12 Nov 2008 13:49:50 +0100
Cc: xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 12 Nov 2008 04:50:33 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=6yCG7uTJTezgLNhUgpYEoPRIReY3hNdvB6dc2m4BvW0=; b=RqdqUxjzAeItxk/dvFOQrZBFMOmdwL9AvZ6kzhU5BwhLsY/YV1Q7HGFbtuxc5qRQVZ Joe8VELmH/zndJgDOWJkhIZluIU6lOv0wjvOkV0xNalUySOC7BwFMkBtOcez5OQNWpX9 xP8eA5XcvReAMRSex/D4FDJsisx9ilQpPb1u0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=BGnqZPpqyTJ7IfoblYLsBSp0bq2EmUeW8Y17iDQnFyoAqrGjDIfwJmz2LOtlmgYgd0 drTF7GpygrHFUA8/2P+vSeHtlwsPuy+l3KkgKwOYzVRe4uofBZKC5kFEVvESB4mgFGVE u5HZce7V4HMi68wPe10cbQCdt5tu1wiL0xhXo=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49134ECE.8040504@xxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <49134ECE.8040504@xxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
2008/11/6 Gael Reignier <gael@xxxxxxxxxx>

Any help will be much appreciate as this issue starts to drive me crazy
and I do not know where to start looking... so if you spot any problem
or that I should do something else, just let me know :-) 

Before you get crazy, try this script, I spent several weeks to get it working.
The first part dynamically create the VLAN IF (eth0.x) and the associated bridge (xenbrx). The second one creates config files to make it up at the next reboot.

This is the script (sorry for french comments):

--->8---
#!/bin/bash
# A. Barthe -- jeu nov 22 14:14:18 CET 2007
# Script de fabrication dynamique d'un VLAN pour un dom0 xen
# Parametres: <vlan tag> [device] (device par defaut: eth0)
#

#DEBUG=echo

script=$(basename $0)
USAGE="Usage: $script <vlan tag> [device] (device par defaut: eth0)"

if [ $# -ne 1 -a $# -ne 2 ]; then
    echo $USAGE >&2
    exit 1
fi

#--------------------------------------------------------------------
# FABRICATION DYNAMIQUE DU VLAN ET DU BRIDGE ASSOCIE

vtag=$1
dev=${2:-eth0}

ifconfig | grep -q p$dev || {
    echo "p$dev: interface non trouvee" >&2
    exit 1
}

# Creation du VLAN sur pethx
$DEBUG modprobe 8021q
$DEBUG vconfig add p$dev $vtag || {
    echo "Echec a la creation du VLAN" >&2
    exit 1
}

# Renommage de pethx.y en ethx.y
$DEBUG ip link set p$dev.$vtag name $dev.$vtag

# Recuperation de la MAC de $dev
mac=$(ifconfig $dev | head -1 | awk '{print $NF}')

# Affectation de la MAC a l'interface just created
ip link set $dev.$vtag address $mac

# Configuration du VLAN
$DEBUG ip link set $dev.$vtag promisc on
$DEBUG ip link set $dev.$vtag multicast on
$DEBUG ip link set $dev.$vtag arp on

# Creation du bridge et ajout du VLAN dessus
$DEBUG brctl addbr xenbr$vtag
$DEBUG brctl addif xenbr$vtag $dev.$vtag

# Demarrage du VLAN et du bridge
$DEBUG ifconfig $dev.$vtag up
$DEBUG ifconfig xenbr$vtag up

#--------------------------------------------------------------------
# FABRICATION DES FICHIERS DE DEMARRAGE POUR QUE CA MARCHE AU REBOOT

root="/etc/sysconfig/network-scripts"
#root="toto"
baseif="ifcfg-"

iffile="$root/$baseif$dev"
test -f $iffile || {
    echo "$iffile: fichier non trouve" >&2
    exit 1
}

# Rajout du flag VLAN dans le fichier de demarrage de l'interface
grep -q "VLAN=yes" $iffile || echo "VLAN=yes" >> $iffile

# Fabrication du fichier de demarrage du vlan
vlanfile="$iffile.$vtag"
cat > $vlanfile <<EOF
DEVICE=$dev.$vtag
BOOTPROTO=none
>TYPE=Ethernet
VLAN=yes
BRIDGE=xenbr$vtag
EOF

# Fabrication du fichier de demarrage du bridge associe
brfile="$root/${baseif}xenbr$vtag"
cat > $brfile <<EOF
DEVICE=xenbr$vtag
BOOTPROTO=none
>TYPE=Bridge
EOF

# Et voila...
echo "Le VLAN $dev.$vtag et le bridge xenbr$vtag ont bien ete crees."
--->8---

Hope this helps.

Alain.
 


So thanks a million in advance for any of your help!

Cheers
Gael







_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users