From patchwork Tue Aug 7 02:44:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 954332 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HuceWB90"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kzPF5mThz9ryt for ; Tue, 7 Aug 2018 12:44:17 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CB151E1E; Tue, 7 Aug 2018 02:43:53 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1E920DE0 for ; Tue, 7 Aug 2018 02:43:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C56081A0 for ; Tue, 7 Aug 2018 02:43:51 +0000 (UTC) Received: by mail-pf1-f182.google.com with SMTP id l9-v6so7777202pff.9 for ; Mon, 06 Aug 2018 19:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JKGdza63L8xe8c8OjV06fyzAEvkkXadthWMK2AkTmaU=; b=HuceWB90NlhglE2sh6L2SJT7GrRq9m+HjT1WOap/bdDZQfhjQem0L/RXY0eUj2prO3 rdgFo7Lw9kcR7omb7R4AcyZo1mkSYAIFuZ1gOkml5RkirX//g1dVpovyqUFkycA1Pvtg RnWR3uGhZURjGRkAr/QWTp8IM2Qv2PUrZMnxI854yc0TVU4JkxxuhCURbKObYvRWNFAk PH8Wv6PKtQheSN7bWJ6tM6+cp/VM/A56wcYO/tJ8m9TER3mGLRNvZayNVf65/u1vWq2s caqlMmodxUGnL7xtqWfilLvU03ir45KCVAQzssjYJcxikLkTL0MCqNSp5UDaatOsfh0Z Pw1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JKGdza63L8xe8c8OjV06fyzAEvkkXadthWMK2AkTmaU=; b=JAK0Dx3QW3L1A/zhSlkv1Ek8S7tguuqZEBWJNsNC9oH5nx8iYO72VEUvU6sFUFLO+/ Cb4K2Q6LGnQF4zptlhRDWMTOnyxc519AeeE5+n8CEVV07KNsRgeVpdIEIvOD0PqMaNGr iap0OR2c+0cZQSwqCpXpo598EYZNzGE15HHfl65iPRNubmeszWuoY5AzD9EUnH+9TvEH Sm65AC1/FB6bDeteBt2ahRz8xMCV9F2bmk3azHfkY/BzyoheewlZ+eQhavL+ui9oWfmx e0iCS4/n/KzFyVdNJeQAOtx+xBBVuqVc2gO1CnGnLW5AeYIPEPODxERMeangVK7R84P+ 4XXw== X-Gm-Message-State: AOUpUlHDrV3FPtHMUhXYGbIAVC7WSODRaAgulBa938aheRUCxC1BdDLu qn9xE5V+nAIw6gODI05/aETviRpo X-Google-Smtp-Source: AAOMgpfGbw/3Ik7qCMc4/MBRJXt1/WyClMrbXYplkHpzHRT6dnu3xDP+pkF1WUgsuvQgUclT+4GKxw== X-Received: by 2002:a63:5025:: with SMTP id e37-v6mr17003886pgb.341.1533609831196; Mon, 06 Aug 2018 19:43:51 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id y3-v6sm207434pfi.24.2018.08.06.19.43.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 19:43:50 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 6 Aug 2018 19:44:00 -0700 Message-Id: <1533609842-104523-2-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> References: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/3] ovn-northd: Simplify struct ovn_port_group. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Remove the redundant members that's already in nb_pg. Signed-off-by: Han Zhou Acked-by: Mark Michelson --- ovn/northd/ovn-northd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 067d52d..d2a777f 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -3027,8 +3027,6 @@ struct ovn_port_group { struct uuid key; /* nb_pg->header_.uuid. */ const struct nbrec_port_group *nb_pg; struct hmap nb_lswitches; /* NB lswitches related to the port group */ - size_t n_acls; /* Number of ACLs applied to the port group */ - struct nbrec_acl **acls; /* ACLs applied to the port group */ }; static void @@ -3068,8 +3066,8 @@ has_stateful_acl(struct ovn_datapath *od, struct hmap *port_groups) struct ovn_port_group *pg; HMAP_FOR_EACH (pg, key_node, port_groups) { if (ovn_port_group_ls_find(pg, &od->nbs->header_.uuid)) { - for (size_t i = 0; i < pg->n_acls; i++) { - struct nbrec_acl *acl = pg->acls[i]; + for (size_t i = 0; i < pg->nb_pg->n_acls; i++) { + struct nbrec_acl *acl = pg->nb_pg->acls[i]; if (!strcmp(acl->action, "allow-related")) { return true; } @@ -3558,8 +3556,6 @@ ovn_port_group_create(struct hmap *pgs, struct ovn_port_group *pg = xzalloc(sizeof *pg); pg->key = nb_pg->header_.uuid; pg->nb_pg = nb_pg; - pg->n_acls = nb_pg->n_acls; - pg->acls = nb_pg->acls; hmap_init(&pg->nb_lswitches); hmap_insert(pgs, &pg->key_node, uuid_hash(&pg->key)); return pg; @@ -3723,8 +3719,8 @@ build_acls(struct ovn_datapath *od, struct hmap *lflows, struct ovn_port_group *pg; HMAP_FOR_EACH (pg, key_node, port_groups) { if (ovn_port_group_ls_find(pg, &od->nbs->header_.uuid)) { - for (size_t i = 0; i < pg->n_acls; i++) { - consider_acl(lflows, od, pg->acls[i], has_stateful); + for (size_t i = 0; i < pg->nb_pg->n_acls; i++) { + consider_acl(lflows, od, pg->nb_pg->acls[i], has_stateful); } } } From patchwork Tue Aug 7 02:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 954333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QoQsAnZh"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kzPl3gWmz9ryt for ; Tue, 7 Aug 2018 12:44:43 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8AF74E6E; Tue, 7 Aug 2018 02:43:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 18CA6DD9 for ; Tue, 7 Aug 2018 02:43:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 96D471A0 for ; Tue, 7 Aug 2018 02:43:52 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id y10-v6so7788172pfn.8 for ; Mon, 06 Aug 2018 19:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2SCR28CQ/Lo3xo8FCWkKRsEzW7fn5H1zDUVe9PKRDOA=; b=QoQsAnZhQpsBRFLRYqiVxYOMj9BGIIMtOa3Jv36lnejFRUgJ0xXAe6/LOVj7oxDjrX weOIixzIFxPFo1obFPs8UR1zFaMjsoPW6o7hFcdC5w0Niu6YKJBfGklspLemH6gpzfNU aspc8IzDNGot9DGEKaKmMGI17EHTvBp5OyyLmcAw6QF7uKemLLyjAVmZZfou9Xi0Ej3s 40l5V9EDY9ndLajlpa4i4Y6UgyOAi9heMLYpZA7qqSyMoMp0xG4tb+sc3oGpZUx4KZOc nTp7A1PmteMX1WLZIV0MAQImHkNuUuU23lj7S2m8MLh07r9jaztOc4H3CUIkTk9oUohI bSXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2SCR28CQ/Lo3xo8FCWkKRsEzW7fn5H1zDUVe9PKRDOA=; b=A3R1/q33PX2yYB3RbvyyUv14yoR/Nh2ktO/w+MN9tWQF5jaZMj9izUcsyehoB/Ifkl GMOVjwlqmAztJMcni95m0Yz/Adndd1pMFuJF9Do5FhA+WA/zWNqgP1TnBhTfFACI1h7u /umsGe7XY0CkpTCtU9lSkPYAVwH6bITV9IUEnbq10EiNqgYvr5+HwJN8xhXGN++kDaoy hLBxyhRSfk7bYkBlufirfAPkceW+gKmWvJvHqpjEAiACTJ1cJM9CQJliv2Lp2avH+pMm eExz8LVykqxu34c1jTQ7lDnLAaUaE3snyLqoKdx2kHzEnYsavLuTZ80hq6w/MMkAC542 ofUw== X-Gm-Message-State: AOUpUlEZittf8w7d9eMVrGHj5koBx+3IIIXVCgvnGKmLCnx5SaAuHt4m WMnrV60Ghz6fBss1h6P4jdCJ344q X-Google-Smtp-Source: AAOMgpfBl+qWNUG6TcRCxv0mfYCfTLlVvXy9bfC5uM1LqfBDItmFsx1hjDUx2ILTBF+2XaG0YVvqdA== X-Received: by 2002:a63:ef54:: with SMTP id c20-v6mr6836676pgk.368.1533609832033; Mon, 06 Aug 2018 19:43:52 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id y3-v6sm207434pfi.24.2018.08.06.19.43.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 19:43:51 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 6 Aug 2018 19:44:01 -0700 Message-Id: <1533609842-104523-3-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> References: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/3] ovn-northd: Improve efficiency of stateful checking for ACLs on port groups. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Currently in has_stateful_acl(), to check if a datapath has stateful ACLs, it needs to iterate all port groups and check if the current datapath is related to each port group, and then iterate the ACLs on the port group. This is inefficient if there are a lot of port groups. A typical scenario is in OpenStack each tenant will have a default security group which will be mapped as a port group, and the default security group is supposed to contain ports of the tenant only, so most likely only the logical switches belonging to the tenant should be related to the port group, but we are checking all the port groups belonging to all tenants for each datapath. To improve this, a reverse direction of hmap is built from logical switch to port group, so that the iteration is avoided. The time complexity of this function improves from O(P * A) to O(PL * A), P = total number of port groups in NB, PL = number of port groups related to the logical switch, A = number of ACLs. Signed-off-by: Han Zhou Acked-by: Mark Michelson --- ovn/northd/ovn-northd.c | 60 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index d2a777f..ba86bf5 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -439,6 +439,9 @@ struct ovn_datapath { * the "redirect-chassis". */ struct ovn_port *l3redirect_port; struct ovn_port *localnet_port; + + /* Port groups related to the datapath, used only when nbs is NOT NULL. */ + struct hmap nb_pgs; }; struct macam_node { @@ -467,11 +470,14 @@ ovn_datapath_create(struct hmap *datapaths, const struct uuid *key, od->nbs = nbs; od->nbr = nbr; hmap_init(&od->port_tnlids); + hmap_init(&od->nb_pgs); od->port_key_hint = 0; hmap_insert(datapaths, &od->key_node, uuid_hash(&od->key)); return od; } +static void ovn_ls_port_group_destroy(struct hmap *nb_pgs); + static void ovn_datapath_destroy(struct hmap *datapaths, struct ovn_datapath *od) { @@ -483,6 +489,7 @@ ovn_datapath_destroy(struct hmap *datapaths, struct ovn_datapath *od) destroy_tnlids(&od->port_tnlids); bitmap_free(od->ipam_info.allocated_ipv4s); free(od->router_ports); + ovn_ls_port_group_destroy(&od->nb_pgs); free(od); } } @@ -3053,8 +3060,34 @@ ovn_port_group_ls_find(struct ovn_port_group *pg, const struct uuid *ls_uuid) return NULL; } +struct ovn_ls_port_group { + struct hmap_node key_node; /* Index on 'key'. */ + struct uuid key; /* nb_pg->header_.uuid. */ + const struct nbrec_port_group *nb_pg; +}; + +static void +ovn_ls_port_group_add(struct hmap *nb_pgs, + const struct nbrec_port_group *nb_pg) +{ + struct ovn_ls_port_group *ls_pg = xzalloc(sizeof *ls_pg); + ls_pg->key = nb_pg->header_.uuid; + ls_pg->nb_pg = nb_pg; + hmap_insert(nb_pgs, &ls_pg->key_node, uuid_hash(&ls_pg->key)); +} + +static void +ovn_ls_port_group_destroy(struct hmap *nb_pgs) +{ + struct ovn_ls_port_group *ls_pg; + HMAP_FOR_EACH_POP (ls_pg, key_node, nb_pgs) { + free(ls_pg); + } + hmap_destroy(nb_pgs); +} + static bool -has_stateful_acl(struct ovn_datapath *od, struct hmap *port_groups) +has_stateful_acl(struct ovn_datapath *od) { for (size_t i = 0; i < od->nbs->n_acls; i++) { struct nbrec_acl *acl = od->nbs->acls[i]; @@ -3063,25 +3096,23 @@ has_stateful_acl(struct ovn_datapath *od, struct hmap *port_groups) } } - struct ovn_port_group *pg; - HMAP_FOR_EACH (pg, key_node, port_groups) { - if (ovn_port_group_ls_find(pg, &od->nbs->header_.uuid)) { - for (size_t i = 0; i < pg->nb_pg->n_acls; i++) { - struct nbrec_acl *acl = pg->nb_pg->acls[i]; - if (!strcmp(acl->action, "allow-related")) { - return true; - } + struct ovn_ls_port_group *ls_pg; + HMAP_FOR_EACH (ls_pg, key_node, &od->nb_pgs) { + for (size_t i = 0; i < ls_pg->nb_pg->n_acls; i++) { + struct nbrec_acl *acl = ls_pg->nb_pg->acls[i]; + if (!strcmp(acl->action, "allow-related")) { + return true; } } } + return false; } static void -build_pre_acls(struct ovn_datapath *od, struct hmap *lflows, - struct hmap *port_groups) +build_pre_acls(struct ovn_datapath *od, struct hmap *lflows) { - bool has_stateful = has_stateful_acl(od, port_groups); + bool has_stateful = has_stateful_acl(od); /* Ingress and Egress Pre-ACL Table (Priority 0): Packets are * allowed by default. */ @@ -3606,6 +3637,7 @@ build_port_group_lswitches(struct northd_context *ctx, struct hmap *pgs, ovn_port_group_ls_find(pg, &op->od->nbs->header_.uuid); if (!pg_ls) { ovn_port_group_ls_add(pg, op->od->nbs); + ovn_ls_port_group_add(&op->od->nb_pgs, nb_pg); } } } @@ -3615,7 +3647,7 @@ static void build_acls(struct ovn_datapath *od, struct hmap *lflows, struct hmap *port_groups) { - bool has_stateful = has_stateful_acl(od, port_groups); + bool has_stateful = has_stateful_acl(od); /* Ingress and Egress ACL Table (Priority 0): Packets are allowed by * default. A related rule at priority 1 is added below if there @@ -3968,7 +4000,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, continue; } - build_pre_acls(od, lflows, port_groups); + build_pre_acls(od, lflows); build_pre_lb(od, lflows); build_pre_stateful(od, lflows); build_acls(od, lflows, port_groups); From patchwork Tue Aug 7 02:44:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 954334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sDk0Opxg"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kzQF0jNHz9ryt for ; Tue, 7 Aug 2018 12:45:09 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 67088E8D; Tue, 7 Aug 2018 02:43:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id DA1A8E36 for ; Tue, 7 Aug 2018 02:43:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 911931A0 for ; Tue, 7 Aug 2018 02:43:53 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id r5-v6so7096758pgv.0 for ; Mon, 06 Aug 2018 19:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ETxkLUhO5Vn5DEnzs8LGBxTY4GjQvs1ySdSewt0iXQ=; b=sDk0OpxgSlDmbiVI+dGQQ7Md1MwajC1lq9BdtnPyeGHe+oBIaGSOjAFPFpK+Debdu+ Y81UEkDjURcLHSLWvsWPgZiZgyrTwo29uVC9RrJ2cfhHWPN3WTP3xGQZ2qzfFjYMVONY +7qH3H12zOo/2M1axBthn20PCt0ZTJCf41JbPcM5Rn5MYpyeTzTop1Fjp/N8KRmg/yFl HhgVDLOKye2sBkJtdMPxZdweHLDemiaFAXKClRmthfTmQZaluhBrSOsppnq0mZ9SmRtU i4sCbTCxbJXKsjsZns8WQef7L+satZr+18Cg5Ue9WEHAelx3LAfDQwZ7j1QR/lhD41aS Nb6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2ETxkLUhO5Vn5DEnzs8LGBxTY4GjQvs1ySdSewt0iXQ=; b=XljQDHpcLVkAO6zPfwc49U1fjOgQF+z59H+jOf46q8kxhAlZGxEB13y4bBzGHedL4n yACm6rYA1Z4Aj1WhHp6JIO06nzniKpKpzLrzBVrhkeil052eypfPgjVnfVpt2PqvCrR9 RUweGV+UjMFr1IpBxuPslOZg455fPNYZ+ejNAvQEasReUwLTd0pNg17MJY/eB8QEHBDi WEit266O09+l+4DacnO35QezKzzEzZvhnRYlleG8D4T8OYnEvHAhWOqCKxNbua3dLhjE 5+DgipGCorw0A+aUardXKkhx6Tl5BdU/jhBB0qALZm8692sV0FNmKb9p+jqnVNIz5IqP gkdg== X-Gm-Message-State: AOUpUlHFXm8+HkvO51PiYKQ5363ljGz3/CmfgjDHtW6MW6Iz1gZLXmka b+T0A33W54OupzMMpplSyPShYN3H X-Google-Smtp-Source: AAOMgpfgVJLHYhArKKpGO1bCVhG5YozpLTksYFtr4u9TLKQNxs+HpCEEtLYvN6rLVeDFN4GVnWdx/w== X-Received: by 2002:a63:e914:: with SMTP id i20-v6mr16815907pgh.10.1533609832998; Mon, 06 Aug 2018 19:43:52 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id y3-v6sm207434pfi.24.2018.08.06.19.43.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 19:43:52 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Mon, 6 Aug 2018 19:44:02 -0700 Message-Id: <1533609842-104523-4-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> References: <1533609842-104523-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 3/3] ovn-trace: Fix warnings when port is found but not in current datapath. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When port group is used, ovn-trace may print warnings like this: $ ovn-trace ls1 'inport == "lp111" && eth.src == f0:00:00:00:01:11 && eth.dst == f0:00:00:00:01:12 && ip4.src == 192.168.11.1 && ip4.dst == 192.168.11.2 && ip.ttl == 10' 2018-08-02T01:43:23Z|00001|ovntrace|WARN|lp211: not in datapath ls1 2018-08-02T01:43:23Z|00002|ovntrace|WARN|lp211: unknown logical port 2018-08-02T01:43:23Z|00003|ovntrace|WARN|lp221: not in datapath ls1 2018-08-02T01:43:23Z|00004|ovntrace|WARN|lp221: unknown logical port 2018-08-02T01:43:23Z|00005|ovntrace|WARN|lp231: not in datapath ls1 2018-08-02T01:43:23Z|00006|ovntrace|WARN|lp231: unknown logical port There are 2 warnings: For the first one, it might be reasonable before port group is supported, but now since ports in a port group can span across multiple datapaths, this situation is normal, and warning should not be printed. For the second one, it is misleading, and it should not be printed in this situation even before port group is supported. It should be printed only if the port is not found at all. This patch fixes both. Signed-off-by: Han Zhou Acked-by: Mark Michelson --- ovn/utilities/ovn-trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c index 1fd48f2..7ca3d97 100644 --- a/ovn/utilities/ovn-trace.c +++ b/ovn/utilities/ovn-trace.c @@ -1020,7 +1020,9 @@ ovntrace_lookup_port(const void *dp_, const char *port_name, *portp = port->tunnel_key; return true; } - VLOG_WARN("%s: not in datapath %s", port_name, dp->name); + /* The port is found but not in this datapath. It happens when port + * group is used in match conditions. */ + return false; } const struct ovntrace_mcgroup *mcgroup = ovntrace_mcgroup_find_by_name(dp, port_name);