From nobody Sat Apr 20 02:47:20 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.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; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1573206243; cv=none; d=zoho.com; s=zohoarc; b=ZVjUEJWfVRmNd6o0x+qUTKfP3q9xAdFU9tyP5Bx/57dGcWkLTocwtm/jKM98JiNKhchuLBHhPpRMg+bh2ID5Ar5oP+Ut9llDwLFPpQH4CNThAHu16TQjHyue62MKdkLQGLoEql+V3eh+Af1djxj/HmNyQqgcvx7d2djFZNVK8yM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573206243; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=h2VQSfwHs+ruLYjw4ACowDwcsfDztF59d2F4te/7K+0=; b=eOTXinv1Iy9SNBfuslqlQ1lD9T3+zhzo+I15btkqmKWdLFYO14WqhBfZimTy5XLRx1a2kFISqoShWUkS1UXLgxYF5FnCwT9YbANDwoLHpdhcZrwIVsZ8WHxop1BSE33CTs6cNJ1pLZY/UjASTzeW6UKkTy35XfADfK4voceeqSg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1573206243021275.32522986899926; Fri, 8 Nov 2019 01:44:03 -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 1iT0mu-0008PM-P5; Fri, 08 Nov 2019 09:42:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iT0mu-0008PD-4S for xen-devel@lists.xenproject.org; Fri, 08 Nov 2019 09:42:40 +0000 Received: from smtp-fw-9102.amazon.com (unknown [207.171.184.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 19a45626-020c-11ea-a1d4-12813bfff9fa; Fri, 08 Nov 2019 09:42:39 +0000 (UTC) Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-859fe132.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 08 Nov 2019 09:42:39 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-859fe132.us-west-2.amazon.com (Postfix) with ESMTPS id 4982C222A05; Fri, 8 Nov 2019 09:42:38 +0000 (UTC) Received: from EX13D32EUC002.ant.amazon.com (10.43.164.94) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 8 Nov 2019 09:42:37 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D32EUC002.ant.amazon.com (10.43.164.94) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 8 Nov 2019 09:42:36 +0000 Received: from u55d8f79c258451.ant.amazon.com (10.125.106.130) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 8 Nov 2019 09:42:35 +0000 X-Inumbo-ID: 19a45626-020c-11ea-a1d4-12813bfff9fa IronPort-SDR: c2+iSJP095cRiIFGgpcEtwz2UYD462FrtmXZzGTQAU8QTxUpJpxDMk10uKq7pRicSyzwzkMNsZ aQzuZf+LQVSw== X-IronPort-AV: E=Sophos;i="5.68,281,1569283200"; d="scan'208";a="5159278" From: To: Date: Fri, 8 Nov 2019 09:42:33 +0000 Message-ID: <1573206153-22090-1-git-send-email-paul@xen.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v3] tools/hotpug: only attempt to call 'ip route' if there is valid command X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Paul Durrant , 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" From: Paul Durrant The vif-route script should only call 'ip route' when 'ipcmd' has been set, otherwise it will fail due to an incorrect command string. This patch also adds routes for 'tap' (i.e. emulated) devices as well as 'vif' (i.e. PV) devices. Empirically offline/online commands relate to 'vif' devices, and add/remove commands relate to 'tap' devices. However, this patch treats them equally and uses ${type_if} to distinguish. By adding cases for add/remove the command list becomes exhaustive and hence 'ipcmd' is guaranteed to be set. Routes for 'tap' and 'vif' devices are distinguished by a route metric. Emulated devices are used by HVM guests until they are unplugged, at which point the PV device becomes active. Thus 'tap' devices should get a higher priority (i.e. lower numbered) metric than 'vif' devices. There is also one small whitespace fix. Signed-off-by: Paul Durrant Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu v3: - Fix Wei's email address - Removed test of ${ipcmd} v2: - Added routes for 'tap' devices - Whitespace fix --- tools/hotplug/Linux/vif-route | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) mode change 100644 =3D> 100755 tools/hotplug/Linux/vif-route diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route old mode 100644 new mode 100755 index c149ffc..05199bf --- a/tools/hotplug/Linux/vif-route +++ b/tools/hotplug/Linux/vif-route @@ -22,12 +22,16 @@ dir=3D$(dirname "$0") main_ip=3D$(dom0_ip) =20 case "${command}" in + add) + ;& online) ifconfig ${dev} ${main_ip} netmask 255.255.255.255 up echo 1 >/proc/sys/net/ipv4/conf/${dev}/proxy_arp ipcmd=3D'add' cmdprefix=3D'' ;; + remove) + ;& offline) do_without_error ifdown ${dev} ipcmd=3D'del' @@ -35,13 +39,23 @@ case "${command}" in ;; esac =20 -if [ "${ip}" ] ; then - # If we've been given a list of IP addresses, then add routes from dom= 0 to - # the guest using those addresses. - for addr in ${ip} ; do - ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} - done -fi +case "${type_if}" in + tap) + metric=3D1 + ;; + vif) + metric=3D2 + ;; + *) + fatal "Unrecognised interface type ${type_if}" + ;; +esac + +# If we've been given a list of IP addresses, then add routes from dom0 to +# the guest using those addresses. +for addr in ${ip} ; do + ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metri= c ${metric} +done =20 handle_iptable =20 @@ -50,5 +64,5 @@ call_hooks vif post log debug "Successful vif-route ${command} for ${dev}." if [ "${command}" =3D "online" ] then - success + success fi --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel