From nobody Fri May 3 06:26:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=crc.id.au ARC-Seal: i=1; a=rsa-sha256; t=1576205493; cv=none; d=zohomail.com; s=zohoarc; b=IB1IxlNAfxJyowEKJkicW5V6efq0HE0/WdkzjngkzBzQUyX5GNK93nPQsRtbR9tqOlW10cgB50B+GyQjKE6UhZwpZ3x2mDmcl6s0FOBz/kbAay5JXLs47KySRdMmYvhAZ4/LM+xZpLiFyR4NzsbRcjOqZyiN2GvfPM22yp0vkP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576205493; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9pcbMqR78PjTAhQVOboc9iV69OjDTXxEcIxXLNDgYRw=; b=Kw6sanLd12MUr9kksdjJ0xIB026lMcOdl60J6TpmKueWJc2BTIURUdM9yD5iVEUfES20ndhMyuPjx9OZX1bnrGOoG3UG01045T1Br0LTeHwSdf7u8+k02dugZpAdR2AfHfgyYYX9YXYVXjfaXO/twT+mtoJJD/lTbp7Bx9hGjJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576205492756885.01064236764; Thu, 12 Dec 2019 18:51:32 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifb2X-0000dQ-4A; Fri, 13 Dec 2019 02:50:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifb2W-0000dL-8l for xen-devel@lists.xenproject.org; Fri, 13 Dec 2019 02:50:48 +0000 Received: from mail.crc.id.au (unknown [2407:e400:b000:200::25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 57f75dec-1d53-11ea-b6f1-bc764e2007e4; Fri, 13 Dec 2019 02:50:40 +0000 (UTC) Received: from ws19.umd.com.au (2407-e400-b000-202-0-0-0-3-cpe.spintel.net.au [IPv6:2407:e400:b000:202::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.crc.id.au (Postfix) with ESMTPSA id 9B6212006D3; Fri, 13 Dec 2019 13:50:33 +1100 (AEDT) X-Inumbo-ID: 57f75dec-1d53-11ea-b6f1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crc.id.au; s=default; t=1576205433; bh=NeajN4Im7OlnIgZgRJj7CI217KxQZYwgROlhdXd+3cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Bl2OOcpQcx4OVCCYyCmYPybj37UtJ2mAw7GA1gVlQk9XRzKCtW06Ck8P0H/ed9l9t axd1qthxM48ddaCLth993Qkx7788tCpvU9j0wutxJT6A3a7oUqFWJuTpfFdwxvcyHb +o0yLrnaYyYQ7tq/yMoqos/ltSaViPsA5btytgPk= From: Steven Haigh To: netwiz@crc.id.au, xen-devel@lists.xenproject.org Date: Fri, 13 Dec 2019 13:50:23 +1100 Message-Id: X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/2] Tidy up whitespace and formatting in file to be consistent. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Steven Haigh --- tools/hotplug/Linux/xen-network-common.sh | 144 +++++++++++----------- 1 file changed, 70 insertions(+), 74 deletions(-) diff --git a/tools/hotplug/Linux/xen-network-common.sh b/tools/hotplug/Linu= x/xen-network-common.sh index 92ffa603f7..ab76827a64 100644 --- a/tools/hotplug/Linux/xen-network-common.sh +++ b/tools/hotplug/Linux/xen-network-common.sh @@ -26,118 +26,114 @@ # that the virtual device will take once the physical device has # been renamed. =20 -if ! which ifup >/dev/null 2>/dev/null -then - preiftransfer() - { - true - } - ifup() - { - false - } - ifdown() - { - false - } +if ! which ifup >/dev/null 2>/dev/null; then + preiftransfer() + { + true + } + ifup() + { + false + } + ifdown() + { + false + } else - preiftransfer() - { - true - } + preiftransfer() + { + true + } fi =20 =20 first_file() { - t=3D"$1" - shift - for file in $@ - do - if [ "$t" "$file" ] - then - echo "$file" - return - fi - done + t=3D"$1" + shift + for file in $@; do + if [ "$t" "$file" ]; then + echo "$file" + return + fi + done } =20 find_dhcpd_conf_file() { - first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf + first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf } =20 =20 find_dhcpd_init_file() { - first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd} + first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd} } =20 find_dhcpd_arg_file() { - first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp3= -server + first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp3-= server } =20 # configure interfaces which act as pure bridge ports: _setup_bridge_port() { - local dev=3D"$1" - local virtual=3D"$2" - - # take interface down ... - ip link set dev ${dev} down - - if [ $virtual -ne 0 ] ; then - # Initialise a dummy MAC address. We choose the numerically - # largest non-broadcast address to prevent the address getting - # stolen by an Ethernet bridge for STP purposes. - # (FE:FF:FF:FF:FF:FF) - ip link set dev ${dev} address fe:ff:ff:ff:ff:ff || true - fi - - # ... and configure it - ip address flush dev ${dev} + local dev=3D"$1" + local virtual=3D"$2" + + # take interface down ... + ip link set dev ${dev} down + + if [ $virtual -ne 0 ]; then + # Initialise a dummy MAC address. We choose the numerically + # largest non-broadcast address to prevent the address getting + # stolen by an Ethernet bridge for STP purposes. + # (FE:FF:FF:FF:FF:FF) + ip link set dev ${dev} address fe:ff:ff:ff:ff:ff || true + fi + + # ... and configure it + ip address flush dev ${dev} } =20 setup_physical_bridge_port() { - _setup_bridge_port $1 0 + _setup_bridge_port $1 0 } setup_virtual_bridge_port() { - _setup_bridge_port $1 1 + _setup_bridge_port $1 1 } =20 # Usage: create_bridge bridge create_bridge () { - local bridge=3D$1 - - # Don't create the bridge if it already exists. - if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then - brctl addbr ${bridge} - brctl stp ${bridge} off - brctl setfd ${bridge} 0 - fi + local bridge=3D$1 + + # Don't create the bridge if it already exists. + if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then + brctl addbr ${bridge} + brctl stp ${bridge} off + brctl setfd ${bridge} 0 + fi } =20 # Usage: add_to_bridge bridge dev add_to_bridge () { - local bridge=3D$1 - local dev=3D$2 - - # Don't add $dev to $bridge if it's already on a bridge. - if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then - ip link set dev ${dev} up || true - return - fi - brctl addif ${bridge} ${dev} - ip link set dev ${dev} up + local bridge=3D$1 + local dev=3D$2 + + # Don't add $dev to $bridge if it's already on a bridge. + if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then + ip link set dev ${dev} up || true + return + fi + brctl addif ${bridge} ${dev} + ip link set dev ${dev} up } =20 # Usage: set_mtu bridge dev set_mtu () { - local bridge=3D$1 - local dev=3D$2 - mtu=3D"`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`" - if [ -n "$mtu" ] && [ "$mtu" -gt 0 ] - then - ip link set dev ${dev} mtu $mtu || : - fi + local bridge=3D$1 + local dev=3D$2 + mtu=3D"`ip link show dev ${bridge}| awk '/mtu/ { print $5 }'`" + if [ -n "$mtu" ] && [ "$mtu" -gt 0 ]; then + ip link set dev ${dev} mtu $mtu || : + fi } --=20 2.24.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri May 3 06:26:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=crc.id.au ARC-Seal: i=1; a=rsa-sha256; t=1576205493; cv=none; d=zohomail.com; s=zohoarc; b=ShwwK3eUtufvlxnW/kbUFBgJJG9ZDquG1Gjluzsm6OIu7LSBMxOFHwgpht4sYj/enFwk3A/p8upGnKA4v6jGJ4qRF2Deh64Z70i/g/Q25aRR7+WLqlzMJ/A5oAnbulXAkTZ3Ui2QgfcLphLitw8fZ7wPbX56iYhAXGJCJyjw/K8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576205493; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yycNtZggD/8ZSJKweXCfdZBagSxybrDXJq4hRRhr7LA=; b=kEyJgWlZAkiODys8JYf+SCbvM8qODR3aovElizLx7p9flFwq3F8xswjxw9F3aQzvstXQtKKOyyvg+syqQBezT7xB1FqWCeL+x+a18YdxbEvqLchTz5eCm9CwKhfrHRXf4uE3SRoQMo0pu6+hfH/O5EGCUh0PegjLZ0ooEPYwdro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576205492630336.44336423049435; Thu, 12 Dec 2019 18:51:32 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifb2c-0000eF-E6; Fri, 13 Dec 2019 02:50:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifb2b-0000e3-9X for xen-devel@lists.xenproject.org; Fri, 13 Dec 2019 02:50:53 +0000 Received: from mail.crc.id.au (unknown [2407:e400:b000:200::25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 57fc502c-1d53-11ea-b6f1-bc764e2007e4; Fri, 13 Dec 2019 02:50:40 +0000 (UTC) Received: from ws19.umd.com.au (2407-e400-b000-202-0-0-0-3-cpe.spintel.net.au [IPv6:2407:e400:b000:202::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.crc.id.au (Postfix) with ESMTPSA id E420B2006ED; Fri, 13 Dec 2019 13:50:33 +1100 (AEDT) X-Inumbo-ID: 57fc502c-1d53-11ea-b6f1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=crc.id.au; s=default; t=1576205434; bh=ADbmgjdex1YdG5H7zvVLlb7dKaNh3rNzRyAa5oq3YV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fxnutyrs7426cK//HBgsOrjdWEvQAvqZuzTuKVuivjuAeBXZbHXGawM86eSPcEDc0 rDfeS//i3gHG68TtI94NkvwweW3OYvXhMzD+aTLMZDIMU6ReKzQCvsoL0N3bE7ME1P SPcqPTwGnzDhXk6wA9HmUhXdB1CIfyky3ZdtqfcI= From: Steven Haigh To: netwiz@crc.id.au, xen-devel@lists.xenproject.org Date: Fri, 13 Dec 2019 13:50:24 +1100 Message-Id: X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] Use ip for bridge related functions where brctl is not present X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Steven Haigh --- tools/hotplug/Linux/colo-proxy-setup | 30 +++++++++++++++++------ tools/hotplug/Linux/vif-bridge | 19 ++++++++------ tools/hotplug/Linux/vif2 | 12 +++++++-- tools/hotplug/Linux/xen-network-common.sh | 15 +++++++++--- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/tools/hotplug/Linux/colo-proxy-setup b/tools/hotplug/Linux/col= o-proxy-setup index 94e2034452..690021d10a 100755 --- a/tools/hotplug/Linux/colo-proxy-setup +++ b/tools/hotplug/Linux/colo-proxy-setup @@ -76,10 +76,17 @@ function teardown_primary() =20 function setup_secondary() { - do_without_error brctl delif $bridge $vifname - do_without_error brctl addbr $forwardbr - do_without_error brctl addif $forwardbr $vifname - do_without_error brctl addif $forwardbr $forwarddev + if [ -x "/usr/bin/brctl" ]; then + do_without_error brctl delif $bridge $vifname + do_without_error brctl addbr $forwardbr + do_without_error brctl addif $forwardbr $vifname + do_without_error brctl addif $forwardbr $forwarddev + else + do_without_error ip link set $vifname nomaster + do_without_error ip link add name $forwardbr type bridge + do_without_error ip link set $vifname master $forwardbr + do_without_error ip link set $forwarddev master $forwardbr + fi do_without_error ip link set dev $forwardbr up do_without_error modprobe xt_SECCOLO =20 @@ -91,10 +98,17 @@ function setup_secondary() =20 function teardown_secondary() { - do_without_error brctl delif $forwardbr $forwarddev - do_without_error brctl delif $forwardbr $vifname - do_without_error brctl delbr $forwardbr - do_without_error brctl addif $bridge $vifname + if [ -x "/usr/bin/brctl" ]; then + do_without_error brctl delif $forwardbr $forwarddev + do_without_error brctl delif $forwardbr $vifname + do_without_error brctl delbr $forwardbr + do_without_error brctl addif $bridge $vifname + else + do_without_error ip link set $forwarddev nomaster + do_without_error ip link set $vifname nomaster + do_without_error ip link delete $forwardbr type bridge + do_without_error ip link set $vifname master $bridge + fi =20 do_without_error iptables -t mangle -D PREROUTING -m physdev --physdev= -in \ $vifname -j SECCOLO --index $index diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge index 6956dea66a..e035411934 100644 --- a/tools/hotplug/Linux/vif-bridge +++ b/tools/hotplug/Linux/vif-bridge @@ -31,12 +31,13 @@ dir=3D$(dirname "$0") bridge=3D${bridge:-} bridge=3D$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") =20 -if [ -z "$bridge" ] -then - bridge=3D$(brctl show | awk 'NR=3D=3D2{print$1}') - - if [ -z "$bridge" ] - then +if [ -z "$bridge" ]; then + if [ -x "/usr/sbin/brctl" ]; then + bridge=3D$(brctl show | awk 'NR=3D=3D2{print$1}') + else + bridge=3D$(bridge link | cut -d" " -f7) + fi + if [ -z "$bridge" ]; then fatal "Could not find bridge, and none was specified" fi else @@ -82,7 +83,11 @@ case "$command" in ;; =20 offline) - do_without_error brctl delif "$bridge" "$dev" + if [ -x "/usr/sbin/brctl"]; then + do_without_error brctl delif "$bridge" "$dev" + else + do_without_error ip link set "$dev" nomaster + fi do_without_error ifconfig "$dev" down ;; =20 diff --git a/tools/hotplug/Linux/vif2 b/tools/hotplug/Linux/vif2 index 2c155be68c..e36070cbbb 100644 --- a/tools/hotplug/Linux/vif2 +++ b/tools/hotplug/Linux/vif2 @@ -7,13 +7,21 @@ dir=3D$(dirname "$0") bridge=3D$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") if [ -z "$bridge" ] then - nr_bridges=3D$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1)) + if [ -x "/usr/sbin/brctl" ]; then + nr_bridges=3D$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - = 1)) + else + nr_bridges=3D$(bridge link | wc -l) + fi if [ "$nr_bridges" !=3D 1 ] then fatal "no bridge specified, and don't know which one to use ($nr_bridges = found)" fi - bridge=3D$(brctl show | cut -d " + if [ -x "/usr/sbin/brctl" ]; then + bridge=3D$(brctl show | cut -d " " -f 2 | cut -f 1) + else + bridge=3D$(bridge link | cut -d" " -f6) + fi fi =20 command=3D"$1" diff --git a/tools/hotplug/Linux/xen-network-common.sh b/tools/hotplug/Linu= x/xen-network-common.sh index ab76827a64..7833deac6c 100644 --- a/tools/hotplug/Linux/xen-network-common.sh +++ b/tools/hotplug/Linux/xen-network-common.sh @@ -108,9 +108,12 @@ create_bridge () { =20 # Don't create the bridge if it already exists. if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then - brctl addbr ${bridge} - brctl stp ${bridge} off - brctl setfd ${bridge} 0 + if [ -x "/usr/sbin/brctl" ]; then + brctl addbr ${bridge} + brctl stp ${bridge} off + brctl setfd ${bridge} 0 + else + ip link add name ${bridge} type bridge stp_state 0 forward_delay 0 fi } =20 @@ -124,7 +127,11 @@ add_to_bridge () { ip link set dev ${dev} up || true return fi - brctl addif ${bridge} ${dev} + if [ -x "/usr/sbin/brctl" ]; then + brctl addif ${bridge} ${dev} + else + ip link set ${dev} master ${bridge} + fi ip link set dev ${dev} up } =20 --=20 2.24.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel