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

[Xen-users] vifX.0 has no ip

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-users] vifX.0 has no ip
From: Ognyan Kulev <ogi@xxxxxxxxxxxxxxxx>
Date: Fri, 20 Jan 2006 22:46:49 +0200
Delivery-date: Fri, 20 Jan 2006 20:55:03 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.5 (Windows/20051205)
Hi,

I'm trying to migrate from Xen 2.0.7 to xen-3.0-testing and in 3.0 vifX.0 (X >= 1) don't have ip:s. After I manually set ip address for vifX.0, it works.

In 2.0.7, bridging and a custom network script are used. The network script is attached - I don't know where it came from since I wasn't the one that installed 2.0.7. In 3.0, bridging and original scripts are used. The change in domU configuration is only in the kernel used.

So does anyone have clue what could be the problem?

Regards,
ogi
#!/bin/sh
#============================================================================
# Default Xen network start/stop script.
# Xend calls a network script when it starts.
# The script name to use is defined in /etc/xen/xend-config.sxp
# in the network-script field.
#
# This script creates a bridge (default xen-br0), adds a device
# (default eth0) to it, copies the IP addresses from the device
# to the bridge and adjusts the routes accordingly.
#
# If all goes well, this should ensure that networking stays up.
# However, some configurations are upset by this, especially
# NFS roots. If the bridged setup does not meet your needs,
# configure a different script, for example using routing instead.
#
# Usage:
#
# network (start|stop|status) {VAR=VAL}*
#
# Vars:
#
# bridge     The bridge to use (default xen-br0).
# netdev     The interface to add to the bridge (default eth0).
# antispoof  Whether to use iptables to prevent spoofing (default yes).
#
# start:
# Creates the bridge and enslaves netdev to it.
# Copies the IP addresses from netdev to the bridge.
# Deletes the routes to netdev and adds them on bridge.
#
# stop:
# Removes netdev from the bridge.
# Deletes the routes to bridge and adds them to netdev.
#
# status:
# Print ifconfig for netdev and bridge.
# Print routes.
#
#============================================================================

# Exit if anything goes wrong.
set -e 

# First arg is the operation.
OP=$1
shift

# Pull variables in args in to environment.
for arg ; do export "${arg}" ; done

bridge=${bridge:-xen-br0}
netdev=${netdev:-eth0}
antispoof=${antispoof:-yes}

echo "network $OP bridge=$bridge netdev=$netdev antispoof=$antispoof"

# Usage: transfer_addrs src dst
# Copy all IP addresses (including aliases) from device $src to device $dst.
transfer_addrs () {
    local src=$1
    local dst=$2
    # Don't bother if $dst already has IP addresses.
    if ip addr show dev ${dst} | egrep -q '^ *inet ' ; then
        return
    fi
    # Address lines start with 'inet' and have the device in them.
    # Replace 'inet' with 'ip addr add' and change the device name $src
    # to 'dev $src'. Remove netmask as we'll add routes later.
    ip addr show dev ${src} | egrep '^ *inet ' | sed -e "
s/inet/ip addr add/
s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/[0-9]\+@\1@
s/${src}/dev ${dst}/
" | sh -e
}

# Usage: del_addrs src
del_addrs () {
    local src=$1
    ip addr show dev ${src} | egrep '^ *inet ' | sed -e "
s/inet/ip addr del/
s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/[0-9]\+@\1@
s/${src}/dev ${src}/
" | sh -e
}

# Usage: transfer_routes src dst
# Get all IP routes to device $src, delete them, and
# add the same routes to device $dst.
# The original routes have to be deleted, otherwise adding them
# for $dst fails (duplicate routes).
transfer_routes () {
    local src=$1
    local dst=$2
    # List all routes and grep the ones with $src in.
    # Stick 'ip route del' on the front to delete.
    # Change $src to $dst and use 'ip route add' to add.
    ip route list | grep ${src} | sed -e "
h
s/^/ip route del /
P
g
s/${src}/${dst}/
s/^/ip route add /
P
d
" | sh -e
}

# Usage: create_bridge bridge
create_bridge () {
    local bridge=$1

    # Don't create the bridge if it already exists.
    if ! brctl show | grep -q ${bridge} ; then
        brctl addbr ${bridge}
        brctl stp ${bridge} off
        brctl setfd ${bridge} 0
    fi
    ifconfig ${bridge} up
}

# Usage: add_to_bridge bridge dev
add_to_bridge () {
    local bridge=$1
    local dev=$2
    # Don't add $dev to $bridge if it's already on a bridge.
    if ! brctl show | grep -q ${dev} ; then
        brctl addif ${bridge} ${dev}
    fi
}

# Usage: antispoofing dev bridge
# Set the default forwarding policy for $dev to drop.
# Allow forwarding to the bridge.
antispoofing () {
    local dev=$1
    local bridge=$2

    iptables -P FORWARD DROP
    iptables -A FORWARD -m physdev --physdev-in ${dev} -j ACCEPT
}

# Usage: show_status dev bridge
# Print ifconfig and routes.
show_status () {
    local dev=$1
    local bridge=$2
    
    echo '============================================================'
    ifconfig ${dev}
    ifconfig ${bridge}
    echo ' '
    ip route list
    echo ' '
    route -n
    echo '============================================================'
}

op_start () {
    if [ "${bridge}" == "null" ] ; then
        return
    fi

    create_bridge ${bridge}

    if ifconfig 2>/dev/null | grep -q veth0 ; then
        return
    fi

    if ifconfig veth0 2>/dev/null | grep -q veth0 ; then
        # Propagate MAC address and ARP responsibilities to virtual interface.
        mac=`ifconfig ${netdev} | grep HWadd | sed -e 
's/.*\(..:..:..:..:..:..\).*/\1/'`
        ifconfig veth0 down
        ifconfig veth0 hw ether ${mac}
        ifconfig veth0 arp up
        transfer_addrs ${netdev} veth0
        transfer_routes ${netdev} veth0
        del_addrs ${netdev}
        ifconfig ${netdev} -arp down
        ifconfig ${netdev} hw ether fe:ff:ff:ff:ff:ff up
        # Bring up second half of virtual device and attach it to the bridge.
        ifconfig vif0.0 up
        add_to_bridge ${bridge} vif0.0
    else
        transfer_addrs ${netdev} ${bridge}
        transfer_routes ${netdev} ${bridge}
    fi

    # Attach the real interface to the bridge.
    add_to_bridge ${bridge} ${netdev}
    
    if [ ${antispoof} == 'yes' ] ; then
        antispoofing ${netdev} ${bridge}
    fi
}

op_stop () {
    if [ "${bridge}" == "null" ] ; then
        return
    fi

    brctl delif ${bridge} ${netdev}

    if ifconfig veth0 2>/dev/null | grep -q veth0 ; then
        brctl delif ${bridge} vif0.0
        ifconfig vif0.0 down
        mac=`ifconfig veth0 | grep HWadd | sed -e 
's/.*\(..:..:..:..:..:..\).*/\1/'`
        ifconfig ${netdev} down
        ifconfig ${netdev} hw ether ${mac}
        ifconfig ${netdev} arp up
        transfer_addrs veth0 ${netdev}
        transfer_routes veth0 ${netdev}
        del_addrs veth0
        ifconfig veth0 -arp down
        ifconfig veth0 hw ether 00:00:00:00:00:00
    else
        transfer_routes ${bridge} ${netdev}
    fi
}

case ${OP} in
  start)
        op_start
        ;;
    
    stop)
        op_stop
        ;;

    status)
        show_status ${netdev} ${bridge}
       ;;

    *)
       echo 'Unknown command: ' ${OP}
       echo 'Valid commands are: start, stop, status'
       exit 1
esac
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
<Prev in Thread] Current Thread [Next in Thread>