From patchwork Thu Mar 6 14:12:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 25800 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2BD6B20560 for ; Thu, 6 Mar 2014 14:14:53 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf6532643veb.8 for ; Thu, 06 Mar 2014 06:14:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=u96mJ9uiDpxVjRJkJRIn6Smx8ZmYgsC9HFC9e0yakgo=; b=JhFrg8VS8lF7WEnXG+dTvWULLGBiaC8aOwMipJnKRQoKs2F+jTi/NxG9DxLUH9KAe+ AbHwHR8hlQ5p9QXNeIW5UWU0PBWa7nNw8prrZggwmy/5F6FgATZRCLhrVPyV29O35y7Z Xk7LL3EzTzF/33uBCyQp/UA2MS6YWUD7AoywvWuRRNIf/sWbr+YvONPBN6CjweIuZATS bu1CoL94KeeO4TdiWANlgLVkaDmNuQTCwIh20NU9FECa7fp0MFxergyJna45kKgtf3yM 7romZs85ZmHF3f8xM06P6ZQXkrHnjk72VO02kDXpo94llfoEJDj11ks8fWP8M//HUg01 KbVA== X-Gm-Message-State: ALoCoQmfPkmQNn9PMf5eMWTrUHiqYhs5lbc36RYZHv/9i6x0QySy49eztl/NfIBnMfr/ALki8Fzr X-Received: by 10.236.129.41 with SMTP id g29mr4862019yhi.20.1394115292892; Thu, 06 Mar 2014 06:14:52 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.5 with SMTP id q5ls741770qgd.99.gmail; Thu, 06 Mar 2014 06:14:52 -0800 (PST) X-Received: by 10.58.37.67 with SMTP id w3mr5493040vej.22.1394115292604; Thu, 06 Mar 2014 06:14:52 -0800 (PST) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id e10si1121335vcq.77.2014.03.06.06.14.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Mar 2014 06:14:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so2704105veb.10 for ; Thu, 06 Mar 2014 06:14:52 -0800 (PST) X-Received: by 10.221.53.194 with SMTP id vr2mr36096vcb.41.1394115292507; Thu, 06 Mar 2014 06:14:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp41513vck; Thu, 6 Mar 2014 06:14:52 -0800 (PST) X-Received: by 10.224.7.69 with SMTP id c5mr14264075qac.58.1394115291839; Thu, 06 Mar 2014 06:14:51 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t6si3143685qga.2.2014.03.06.06.14.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 06 Mar 2014 06:14:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WLZ2s-0002n7-IT; Thu, 06 Mar 2014 14:13:10 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WLZ2r-0002my-7n for xen-devel@lists.xen.org; Thu, 06 Mar 2014 14:13:09 +0000 Received: from [85.158.137.68:5668] by server-17.bemta-3.messagelabs.com id E4/48-22569-47288135; Thu, 06 Mar 2014 14:13:08 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1394115185!3299618!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15807 invoked from network); 6 Mar 2014 14:13:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Mar 2014 14:13:06 -0000 X-IronPort-AV: E=Sophos;i="4.97,600,1389744000"; d="scan'208";a="108741397" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 06 Mar 2014 14:12:46 +0000 Received: from norwich.cam.xci-test.com (10.80.248.129) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Thu, 6 Mar 2014 09:12:46 -0500 Received: from spare.cam.xci-test.com ([10.80.2.80] helo=kazak.uk.xensource.com.) by norwich.cam.xci-test.com with esmtp (Exim 4.72) (envelope-from ) id 1WLZ2T-0007Tw-QW; Thu, 06 Mar 2014 14:12:45 +0000 From: Ian Campbell To: Date: Thu, 6 Mar 2014 14:12:45 +0000 Message-ID: <1394115165-28057-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.8.5.2 MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH OSSTEST] CXFabric: Use a vif script hook to (de)register guest mac address X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Since mac table is apparently small this avoids filling it with mac addresses which may never get used. Signed-off-by: Ian Campbell --- Osstest/CXFabric.pm | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Osstest/CXFabric.pm b/Osstest/CXFabric.pm index 866aefe..404c7a6 100644 --- a/Osstest/CXFabric.pm +++ b/Osstest/CXFabric.pm @@ -43,10 +43,7 @@ sub setup_cxfabric($) # is unlikely to be anything other than exactly our marilith box. return unless $ho->{Flags}{'equiv-marilith'}; - my $nr = 8; - - my $prefix = ether_prefix($ho); - logm("Registering $nr MAC addresses with CX fabric using prefix $prefix"); + logm("Setting up CX fabric hook script"); if ( $ho->{Suite} =~ m/wheezy/ ) { @@ -61,24 +58,28 @@ sub setup_cxfabric($) target_install_packages($ho, qw(iproute2)); } - my $banner = '# osstest: register potential guest MACs with CX fabric'; - my $rclocal = "$banner\n"; - # Osstest::TestSupport::select_ether allocates sequentially from $prefix:00:01 - my $i = 0; - while ( $i++ < $nr ) { - $rclocal .= sprintf("bridge fdb add $prefix:%02x:%02x dev eth0\n", - $i >> 8, $i & 0xff); - } - - target_editfile_root($ho, '/etc/rc.local', sub { - my $had_banner = 0; - while (<::EI>) { - $had_banner = 1 if m/^$banner$/; - print ::EO $rclocal if m/^exit 0$/ && !$had_banner; - print ::EO; - } - }); + target_cmd_root($ho, 'mkdir -p /etc/xen/scripts/vif-post.d'); + target_putfilecontents_root_stash($ho,10,<<'END','/etc/xen/scripts/vif-post.d/cxfabric.hook'); +# (De)register the new device with the CX Fabric. Ignore errors from bridge fdb +# since the MAC might already be present etc. +cxfabric() { + local command=$1 + local mac=$(xenstore_read "$XENBUS_PATH/mac") + case $command in + online|add) + log debug "Adding $mac to CXFabric fdb" + do_without_error bridge fdb add $mac dev eth0 + ;; + offline) + log debug "Removing $mac from CXFabric fdb" + do_without_error bridge fdb del $mac dev eth0 + ;; + esac +} +cxfabric $command +END + target_cmd_root($ho, 'chmod +x /etc/xen/scripts/vif-post.d/cxfabric.hook'); } 1;