From patchwork Thu Nov 7 16:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11233425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E87E41390 for ; Thu, 7 Nov 2019 17:00:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDE842077C for ; Thu, 7 Nov 2019 17:00:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDE842077C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iSl7B-0007ng-J6; Thu, 07 Nov 2019 16:58:33 +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 1iSl7A-0007nb-QD for xen-devel@lists.xenproject.org; Thu, 07 Nov 2019 16:58:32 +0000 X-Inumbo-ID: d4644b0a-017f-11ea-a1ca-12813bfff9fa Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d4644b0a-017f-11ea-a1ca-12813bfff9fa; Thu, 07 Nov 2019 16:58:32 +0000 (UTC) IronPort-SDR: I7uB3tDteLS/Q3I/5I7ytLetmQ5r+HzfAq12xHdJtwfaoB1aC5H/3hrRw4qwcuCCmRf5YmwKdT ilocNNNJC+tg== X-IronPort-AV: E=Sophos;i="5.68,278,1569283200"; d="scan'208";a="2694206" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 07 Nov 2019 16:58:25 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-27fb8269.us-east-1.amazon.com (Postfix) with ESMTPS id 2930AA27F8; Thu, 7 Nov 2019 16:58:24 +0000 (UTC) Received: from EX13D32EUB003.ant.amazon.com (10.43.166.165) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 7 Nov 2019 16:58:23 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13D32EUB003.ant.amazon.com (10.43.166.165) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 7 Nov 2019 16:58:22 +0000 Received: from u55d8f79c258451.ant.amazon.com (10.125.106.130) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 7 Nov 2019 16:58:20 +0000 From: To: Date: Thu, 7 Nov 2019 16:58:14 +0000 Message-ID: <1573145894-13305-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 v2] 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: Wei Liu , Paul Durrant , Ian Jackson 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 by making use of the 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. NOTE: 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. Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu --- tools/hotplug/Linux/vif-route | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) mode change 100644 => 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..e71acae --- a/tools/hotplug/Linux/vif-route +++ b/tools/hotplug/Linux/vif-route @@ -22,12 +22,16 @@ dir=$(dirname "$0") main_ip=$(dom0_ip) 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='add' cmdprefix='' ;; + remove) + ;& offline) do_without_error ifdown ${dev} ipcmd='del' @@ -35,11 +39,23 @@ case "${command}" in ;; esac -if [ "${ip}" ] ; then +case "${type_if}" in + tap) + metric=1 + ;; + vif) + metric=2 + ;; + *) + fatal "Unrecognised interface type ${type_if}" + ;; +esac + +if [ "${ipcmd}" ] ; then # 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} + ${cmdprefix} ip route ${ipcmd} ${addr} dev ${dev} src ${main_ip} metric ${metric} done fi @@ -50,5 +66,5 @@ call_hooks vif post log debug "Successful vif-route ${command} for ${dev}." if [ "${command}" = "online" ] then - success + success fi