From patchwork Thu Jul 14 21:59:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 648612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rr8jp5Xxcz9s9Z for ; Fri, 15 Jul 2016 07:59:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Hqm233JU; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 05A9810BF9; Thu, 14 Jul 2016 14:59:10 -0700 (PDT) X-Original-To: dev@openvswitch.com Delivered-To: dev@openvswitch.com Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by archives.nicira.com (Postfix) with ESMTPS id B719310BF3 for ; Thu, 14 Jul 2016 14:59:08 -0700 (PDT) Received: by mail-pf0-f194.google.com with SMTP id g202so5396249pfb.1 for ; Thu, 14 Jul 2016 14:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=lmA14e3GW+RcKImkkoeVgmos2gD0jdRx3ZNo9Dgk9Xw=; b=Hqm233JUfvFjtMqMqn8Qa/XH5J6UiI+kNZ+nu9XbrD0tjgd99fMScpFlT+4qtb4pO5 tNaMT8/h+u+HI/VTuJux/LcHg80iea0hDBcRoRsSw9PhbXVImi2Mr2qwACLS6H7yXS0z zTNWPrwDV5G0j5mMkL3WLeI9FMJME6TJoul5BMYIFkfIKDNzCzatGrsPqoEJmAJnjVTw ufY3Co/82rxTEkjI314cVolXBJ9xouV6nULeEQXiBie/20PAlgt/O4ZMBOnTV4LZFW+I brGnvYvWZbCteZNN57pgg7zwlvTAx2YrYemcp3FXv/ax2Ya6GYA10+RXu+0iF+BDlTF2 ZqGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=lmA14e3GW+RcKImkkoeVgmos2gD0jdRx3ZNo9Dgk9Xw=; b=D7ItPaMpiB1FJBARgocT7/vjqNgUDChrCVUSBoYRiUMGzNmOoxJXzVtAnZ2Z4Vvvfu g8vYJCH8eN6QcbCStGscK3n0N4Oz7ONvehOZKkpRVE1rLlpFx4n/OuMfNQa4l33GET1F y6KWUdlgCu2bv/xeL1Essdyu872zpdtKIv0fbeF6rq/HeiMqKq1FxJ0UxbHZCvemW2Uz h0fV8HOLoD+dX3P0q1jiO0n5A294wlfun3/wtTSTsyXNu0bYIpRQpJhY3vtHFZYJ0PR6 Wd1N+crnLJFdKM/zl2ON5ykp4X3N7kCHgqRPGk45Arw794QbnhR+Mb0xIU0X3lKirYFQ UfQg== X-Gm-Message-State: ALyK8tKpf4oqd7dAU31jptgxD7mNLlE/d9ZTUKGp6AX7OZabRazZY50R+E/xp7Y88SDonw== X-Received: by 10.98.38.69 with SMTP id m66mr16158989pfm.57.1468533548047; Thu, 14 Jul 2016 14:59:08 -0700 (PDT) Received: from localhost.localdomain ([208.91.2.3]) by smtp.gmail.com with ESMTPSA id cl15sm6991980pac.15.2016.07.14.14.59.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Jul 2016 14:59:07 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.com Date: Thu, 14 Jul 2016 14:59:00 -0700 Message-Id: <1468533540-66622-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [ovs-dev] [patch_v2] ovs-vtep: Handle tunnel key configuration in any order. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Presently, ovs-vtep expects the datapath tunnel key to be available in the VTEP DB at startup. This may not be the case which is also observed as interrmittent unit test failures. This patch allows for the tunnel key to later appear in the VTEP database. Signed-off-by: Darrell Ball Acked-by: Russell Bryant --- v1->v2: Cleanup the existing code with broken error handling. vtep/ovs-vtep | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep index e52c66f..b32a82a 100644 --- a/vtep/ovs-vtep +++ b/vtep/ovs-vtep @@ -91,7 +91,6 @@ class Logical_Switch(object): self.local_macs = set() self.remote_macs = {} self.unknown_dsts = set() - self.tunnel_key = 0 self.setup_ls() self.replication_mode = "service_node" @@ -99,16 +98,6 @@ class Logical_Switch(object): vlog.info("destroying lswitch %s" % self.name) def setup_ls(self): - column = vtep_ctl("--columns=tunnel_key find logical_switch " - "name=%s" % self.name) - tunnel_key = column.partition(":")[2].strip() - if tunnel_key and isinstance(eval(tunnel_key), six.integer_types): - self.tunnel_key = tunnel_key - vlog.info("using tunnel key %s in %s" - % (self.tunnel_key, self.name)) - else: - self.tunnel_key = 0 - vlog.warn("invalid tunnel key for %s, using 0" % self.name) if ps_type: ovs_vsctl("--may-exist add-br %s -- set Bridge %s datapath_type=%s" @@ -175,7 +164,7 @@ class Logical_Switch(object): del self.ports[lbinding] self.update_flood() - def add_tunnel(self, tunnel): + def add_tunnel(self, tunnel, tunnel_key): global tun_id vlog.info("adding tunnel %s" % tunnel) encap, ip = tunnel.split("/") @@ -189,7 +178,7 @@ class Logical_Switch(object): ovs_vsctl("add-port %s %s -- set Interface %s type=vxlan " "options:key=%s options:remote_ip=%s" - % (self.short_name, tun_name, tun_name, self.tunnel_key, ip)) + % (self.short_name, tun_name, tun_name, tunnel_key, ip)) for i in range(10): port_no = ovs_vsctl("get Interface %s ofport" % tun_name) @@ -259,6 +248,17 @@ class Logical_Switch(object): tunnels = set() parse_ucast = True + column = vtep_ctl("--columns=tunnel_key find logical_switch " + "name=%s" % self.name) + tunnel_key = column.partition(":")[2].strip() + if tunnel_key and isinstance(eval(tunnel_key), six.integer_types): + vlog.info("update_remote_macs: using tunnel key %s in %s" + % (tunnel_key, self.name)) + else: + vlog.info("Invalid tunnel key %s in %s post VTEP DB requery" + % (tunnel_key, self.name)) + return + mac_list = vtep_ctl("list-remote-macs %s" % self.name).splitlines() for line in mac_list: if (line.find("mcast-mac-remote") != -1): @@ -282,7 +282,7 @@ class Logical_Switch(object): old_tunnels = set(self.tunnels.keys()) for tunnel in tunnels.difference(old_tunnels): - self.add_tunnel(tunnel) + self.add_tunnel(tunnel, tunnel_key) for tunnel in old_tunnels.difference(tunnels): self.del_tunnel(tunnel)