[Pkg-xen-devel] Bug#1067151: xen-utils-common: vif-openvswitch ignores MTU

Aleksi Suhonen debian-reportbug-2024 at ssd.axu.tm
Tue Mar 19 11:21:41 GMT 2024


Package: src:xen
Version: 4.17.3+10-g091466ba55-1~deb12u1
Severity: wishlist

I wasn't sure if this script comes from Debian or Xen or somewhere else, 
so I thought it safest to report it here.

/etc/xen/scripts/vif-bridge handles MTU settings in the vif, but the 
otherwise similar /etc/xen/scripts/vif-openvswitch does not. I added it 
in, here's the diff-c and the full fixed file is also attached.

*** vif-openvswitch.orig        2024-03-19 11:53:13.000000000 +0200
--- vif-openvswitch     2024-03-19 11:56:17.000000000 +0200
***************
*** 89,94 ****
--- 89,95 ----
       add|online)
           check_tools
           setup_virtual_bridge_port $dev
+         set_mtu "$bridge" "$dev" "$type_if"
           add_to_openvswitch $dev
           ;;



-- 
	Aleksi Suhonen

	() ascii ribbon campaign
	/\ support plain text e-mail
-------------- next part --------------
#!/bin/bash
#============================================================================
# ${XEN_SCRIPT_DIR}/vif-openvswitch
#
# Script for configuring a vif in openvswitch mode.
#
# Usage:
# vif-openvswitch (add|remove|online|offline)
#
# Environment vars:
# vif         vif interface name (required).
# XENBUS_PATH path to this device's details in the XenStore (required).
#
# Read from the store:
# bridge  openvswitch to add the vif to (required).
# ip      list of IP networks for the vif, space-separated (optional).
#
# up:
# Enslaves the vif interface to the bridge and adds iptables rules
# for its ip addresses (if any).
#
# down:
# Removes the vif interface from the bridge and removes the iptables
# rules for its ip addresses (if any).
#============================================================================

dir=$(dirname "$0")
. "$dir/vif-common.sh"

check_tools()
{
    if ! command -v ovs-vsctl > /dev/null 2>&1; then
        fatal "Unable to find ovs-vsctl tool"
    fi
    if ! command -v ip > /dev/null 2>&1; then
        fatal "Unable to find ip tool"
    fi
}
openvswitch_external_id() {
    local dev=$1
    local key=$2
    local value=$3

    echo "-- set interface $dev external-ids:\"$key\"=\"$value\""
}

openvswitch_external_id_all() {
    local dev=$1
    local frontend_id=$(xenstore_read "$XENBUS_PATH/frontend-id")
    local vm_path=$(xenstore_read "/local/domain/${frontend_id}/vm")
    local name=$(xenstore_read "${vm_path}/name")
    openvswitch_external_id $dev "xen-vm-name" "$name"
    local uuid=$(xenstore_read "${vm_path}/uuid")
    openvswitch_external_id $dev "xen-vm-uuid" "$uuid"
    local mac=$(xenstore_read "$XENBUS_PATH/mac")
    openvswitch_external_id $dev "attached-mac" "$mac"
}

add_to_openvswitch () {
    local dev=$1
    local bridge="$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")"
    local tag trunk

    if [[ $bridge =~ ^([^.:]+)(\.([[:digit:]]+))?(:([[:digit:]]+(:[[:digit:]]+)*))?$ ]]; then
        bridge="${BASH_REMATCH[1]}"
        tag="${BASH_REMATCH[3]}"
        trunk="${BASH_REMATCH[5]//:/,}"
    else
        fatal "No valid bridge was specified"
    fi

    if [ $trunk ]; then
        local trunk_arg="trunk=$trunk"
    fi

    if [ $tag ]; then
        local tag_arg="tag=$tag"
    fi

    local vif_details="$(openvswitch_external_id_all $dev)"

    do_or_die ovs-vsctl --timeout=30 \
        -- --if-exists del-port $dev \
        -- add-port "$bridge" $dev $tag_arg $trunk_arg $vif_details
    do_or_die ip link set $dev up
}

case "$command" in
    add|online)
        check_tools
        setup_virtual_bridge_port $dev
        set_mtu "$bridge" "$dev" "$type_if"
        add_to_openvswitch $dev
        ;;

    remove|offline)
        do_without_error ovs-vsctl --timeout=30 \
            -- --if-exists del-port $dev
        do_without_error ip link set $dev down
        ;;
esac

if [ "$type_if" = vif ]; then
    handle_iptable
fi

log debug "Successful vif-openvswitch $command for $dev."
if [ "$type_if" = vif -a "$command" = "online" ]; then
    success
fi


More information about the Pkg-xen-devel mailing list