From patchwork Thu Aug 17 07:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1822182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RRGHc27jgz1yNl for ; Thu, 17 Aug 2023 17:05:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1C7F8821B5; Thu, 17 Aug 2023 07:05:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1C7F8821B5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H2gPF6QS7Jt2; Thu, 17 Aug 2023 07:05:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1869782199; Thu, 17 Aug 2023 07:05:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1869782199 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E221FC0071; Thu, 17 Aug 2023 07:05:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AF53FC0032 for ; Thu, 17 Aug 2023 07:05:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 88369421FB for ; Thu, 17 Aug 2023 07:05:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 88369421FB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TypZbuG1ggBq for ; Thu, 17 Aug 2023 07:05:41 +0000 (UTC) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by smtp4.osuosl.org (Postfix) with ESMTPS id A28B4421EB for ; Thu, 17 Aug 2023 07:05:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A28B4421EB Received: by mail.gandi.net (Postfix) with ESMTPSA id 3209520008; Thu, 17 Aug 2023 07:05:35 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 17 Aug 2023 12:35:22 +0530 Message-Id: <20230817070522.1042799-1-numans@ovn.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn v3] northd: Fix incorrect warning logs when handling port binding changes. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique When changes to port bindings corresponding to router ports are handled by northd engine node, incorrect warning logs (like below) are logged. ---- northd|WARN|A port-binding for lrp0 is created but the LSP is not found. ---- Fix these warnings. Fixes: 3b120ccf7f7c ("northd: Incremental processing of SB port_binding in "northd" node.") CC: Han Zhou Signed-off-by: Numan Siddique Acked-by: Han Zhou --- v2 -> v3 ------ * Checked if type of the 'pb' and return false if its a router port before doing a lookup in the ls_ports map. v1 -> v2 ------- * v1 was not returning false in northd_handle_sb_port_binding_changes() for router port - port bindings because of which IPv6 PD system test was failing. Fixed it in v2. controller/binding.c | 75 -------------------------------- controller/binding.h | 20 +-------- lib/ovn-util.c | 101 +++++++++++++++++++++++++++++++++++++++++++ lib/ovn-util.h | 21 +++++++++ northd/northd.c | 7 +++ 5 files changed, 130 insertions(+), 94 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 3ac0c35df..a521f2828 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -756,7 +756,6 @@ static void binding_lport_clear_port_sec(struct binding_lport *); static bool binding_lport_update_port_sec( struct binding_lport *, const struct sbrec_port_binding *); -static char *get_lport_type_str(enum en_lport_type lport_type); static bool ovs_iface_matches_lport_iface_id_ver( const struct ovsrec_interface *, const struct sbrec_port_binding *); @@ -1055,80 +1054,6 @@ binding_dump_local_bindings(struct local_binding_data *lbinding_data, free(nodes); } -static bool -is_lport_vif(const struct sbrec_port_binding *pb) -{ - return !pb->type[0]; -} - -enum en_lport_type -get_lport_type(const struct sbrec_port_binding *pb) -{ - if (is_lport_vif(pb)) { - if (pb->parent_port && pb->parent_port[0]) { - return LP_CONTAINER; - } - return LP_VIF; - } else if (!strcmp(pb->type, "patch")) { - return LP_PATCH; - } else if (!strcmp(pb->type, "chassisredirect")) { - return LP_CHASSISREDIRECT; - } else if (!strcmp(pb->type, "l3gateway")) { - return LP_L3GATEWAY; - } else if (!strcmp(pb->type, "localnet")) { - return LP_LOCALNET; - } else if (!strcmp(pb->type, "localport")) { - return LP_LOCALPORT; - } else if (!strcmp(pb->type, "l2gateway")) { - return LP_L2GATEWAY; - } else if (!strcmp(pb->type, "virtual")) { - return LP_VIRTUAL; - } else if (!strcmp(pb->type, "external")) { - return LP_EXTERNAL; - } else if (!strcmp(pb->type, "remote")) { - return LP_REMOTE; - } else if (!strcmp(pb->type, "vtep")) { - return LP_VTEP; - } - - return LP_UNKNOWN; -} - -static char * -get_lport_type_str(enum en_lport_type lport_type) -{ - switch (lport_type) { - case LP_VIF: - return "VIF"; - case LP_CONTAINER: - return "CONTAINER"; - case LP_VIRTUAL: - return "VIRTUAL"; - case LP_PATCH: - return "PATCH"; - case LP_CHASSISREDIRECT: - return "CHASSISREDIRECT"; - case LP_L3GATEWAY: - return "L3GATEWAY"; - case LP_LOCALNET: - return "PATCH"; - case LP_LOCALPORT: - return "LOCALPORT"; - case LP_L2GATEWAY: - return "L2GATEWAY"; - case LP_EXTERNAL: - return "EXTERNAL"; - case LP_REMOTE: - return "REMOTE"; - case LP_VTEP: - return "VTEP"; - case LP_UNKNOWN: - return "UNKNOWN"; - } - - OVS_NOT_REACHED(); -} - void set_pb_chassis_in_sbrec(const struct sbrec_port_binding *pb, const struct sbrec_chassis *chassis_rec, diff --git a/controller/binding.h b/controller/binding.h index 235e5860d..24bc84079 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -22,6 +22,7 @@ #include "openvswitch/hmap.h" #include "openvswitch/uuid.h" #include "openvswitch/list.h" +# include "lib/ovn-util.h" #include "sset.h" #include "lport.h" @@ -217,25 +218,6 @@ void port_binding_set_down(const struct sbrec_chassis *chassis_rec, const char *iface_id, const struct uuid *pb_uuid); -/* Corresponds to each Port_Binding.type. */ -enum en_lport_type { - LP_UNKNOWN, - LP_VIF, - LP_CONTAINER, - LP_PATCH, - LP_L3GATEWAY, - LP_LOCALNET, - LP_LOCALPORT, - LP_L2GATEWAY, - LP_VTEP, - LP_CHASSISREDIRECT, - LP_VIRTUAL, - LP_EXTERNAL, - LP_REMOTE -}; - -enum en_lport_type get_lport_type(const struct sbrec_port_binding *); - /* This structure represents a logical port (or port binding) * which is associated with 'struct local_binding'. * diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 080ad4c0c..3a237b7fe 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -1168,3 +1168,104 @@ encode_fqdn_string(const char *fqdn, size_t *len) return encoded; } + +static bool +is_lport_vif(const struct sbrec_port_binding *pb) +{ + return !pb->type[0]; +} + +enum en_lport_type +get_lport_type(const struct sbrec_port_binding *pb) +{ + if (is_lport_vif(pb)) { + if (pb->parent_port && pb->parent_port[0]) { + return LP_CONTAINER; + } + return LP_VIF; + } else if (!strcmp(pb->type, "patch")) { + return LP_PATCH; + } else if (!strcmp(pb->type, "chassisredirect")) { + return LP_CHASSISREDIRECT; + } else if (!strcmp(pb->type, "l3gateway")) { + return LP_L3GATEWAY; + } else if (!strcmp(pb->type, "localnet")) { + return LP_LOCALNET; + } else if (!strcmp(pb->type, "localport")) { + return LP_LOCALPORT; + } else if (!strcmp(pb->type, "l2gateway")) { + return LP_L2GATEWAY; + } else if (!strcmp(pb->type, "virtual")) { + return LP_VIRTUAL; + } else if (!strcmp(pb->type, "external")) { + return LP_EXTERNAL; + } else if (!strcmp(pb->type, "remote")) { + return LP_REMOTE; + } else if (!strcmp(pb->type, "vtep")) { + return LP_VTEP; + } + + return LP_UNKNOWN; +} + +char * +get_lport_type_str(enum en_lport_type lport_type) +{ + switch (lport_type) { + case LP_VIF: + return "VIF"; + case LP_CONTAINER: + return "CONTAINER"; + case LP_VIRTUAL: + return "VIRTUAL"; + case LP_PATCH: + return "PATCH"; + case LP_CHASSISREDIRECT: + return "CHASSISREDIRECT"; + case LP_L3GATEWAY: + return "L3GATEWAY"; + case LP_LOCALNET: + return "LOCALNET"; + case LP_LOCALPORT: + return "LOCALPORT"; + case LP_L2GATEWAY: + return "L2GATEWAY"; + case LP_EXTERNAL: + return "EXTERNAL"; + case LP_REMOTE: + return "REMOTE"; + case LP_VTEP: + return "VTEP"; + case LP_UNKNOWN: + return "UNKNOWN"; + } + + OVS_NOT_REACHED(); +} + +bool +is_pb_router_type(const struct sbrec_port_binding *pb) +{ + enum en_lport_type lport_type = get_lport_type(pb); + + switch (lport_type) { + case LP_PATCH: + case LP_CHASSISREDIRECT: + case LP_L3GATEWAY: + case LP_L2GATEWAY: + return true; + + case LP_VIF: + case LP_CONTAINER: + case LP_VIRTUAL: + case LP_LOCALNET: + case LP_LOCALPORT: + case LP_REMOTE: + case LP_VTEP: + case LP_EXTERNAL: + case LP_UNKNOWN: + return false; + } + + return false; +} diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 5ebdd8adb..b056a6c0e 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -409,4 +409,25 @@ void flow_collector_ids_clear(struct flow_collector_ids *); * The returned pointer has to be freed by caller. */ char *encode_fqdn_string(const char *fqdn, size_t *len); +/* Corresponds to each Port_Binding.type. */ +enum en_lport_type { + LP_UNKNOWN, + LP_VIF, + LP_CONTAINER, + LP_PATCH, + LP_L3GATEWAY, + LP_LOCALNET, + LP_LOCALPORT, + LP_L2GATEWAY, + LP_VTEP, + LP_CHASSISREDIRECT, + LP_VIRTUAL, + LP_EXTERNAL, + LP_REMOTE +}; + +enum en_lport_type get_lport_type(const struct sbrec_port_binding *); +char *get_lport_type_str(enum en_lport_type lport_type); +bool is_pb_router_type(const struct sbrec_port_binding *); + #endif /* OVN_UTIL_H */ diff --git a/northd/northd.c b/northd/northd.c index 9a12a94ae..0a749931e 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -5267,10 +5267,17 @@ northd_handle_sb_port_binding_changes( const struct sbrec_port_binding *pb; static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); SBREC_PORT_BINDING_TABLE_FOR_EACH_TRACKED (pb, sbrec_port_binding_table) { + /* Return false if the 'pb' belongs to a router port. We don't handle + * I-P for router ports yet. */ + if (is_pb_router_type(pb)) { + return false; + } + struct ovn_port *op = ovn_port_find(ls_ports, pb->logical_port); if (op && !op->lsp_can_be_inc_processed) { return false; } + if (sbrec_port_binding_is_new(pb)) { /* Most likely the PB was created by northd and this is the * notification of that trasaction. So we just update the sb