From patchwork Thu May 9 18:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1933560 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 4Vb0Dq6gyQz20fZ for ; Fri, 10 May 2024 04:00:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3BD1483F01; Thu, 9 May 2024 18:00:58 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id N_pjAA1U1Zwx; Thu, 9 May 2024 18:00:57 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 27B3083F03 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 27B3083F03; Thu, 9 May 2024 18:00:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0F1B9C0077; Thu, 9 May 2024 18:00:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1FFB5C0037 for ; Thu, 9 May 2024 18:00:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DE91F83EFE for ; Thu, 9 May 2024 18:00:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Vi9LixZApBxH for ; Thu, 9 May 2024 18:00:53 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=217.70.183.197; helo=relay5-d.mail.gandi.net; envelope-from=numans@ovn.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 38D2D83F01 Authentication-Results: smtp1.osuosl.org; dmarc=none (p=none dis=none) header.from=ovn.org DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 38D2D83F01 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.osuosl.org (Postfix) with ESMTPS id 38D2D83F01 for ; Thu, 9 May 2024 18:00:52 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D0C81C0004; Thu, 9 May 2024 18:00:49 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 9 May 2024 14:00:45 -0400 Message-ID: <20240509180045.1463906-1-numans@ovn.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509180015.1463789-1-numans@ovn.org> References: <20240509180015.1463789-1-numans@ovn.org> MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn v2 1/3] northd: Don't reparse lport's addresses while adding L2_LKUP flows. 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 The addresses are already parsed and stored in the "struct ovn_port"'s lsp_addrs field. Signed-off-by: Numan Siddique --- northd/northd.c | 165 +++++++++++++++++------------------------------- 1 file changed, 59 insertions(+), 106 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 0cabda7ea0..c0f477358a 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -9568,126 +9568,79 @@ build_lswitch_ip_unicast_lookup(struct ovn_port *op, return; } - /* For ports connected to logical routers add flows to bypass the - * broadcast flooding of ARP/ND requests in table 19. We direct the - * requests only to the router port that owns the IP address. - */ - if (lsp_is_router(op->nbsp)) { - build_lswitch_rport_arp_req_flows(op->peer, op->od, op, lflows, - &op->nbsp->header_); - } - bool lsp_clone_to_unknown = lsp_is_clone_to_unknown(op->nbsp); + bool lsp_enabled = lsp_is_enabled(op->nbsp); + const char *action = lsp_enabled + ? ((lsp_clone_to_unknown && op->od->has_unknown) + ? "clone {outport = %s; output; };" + "outport = \""MC_UNKNOWN "\"; output;" + : "outport = %s; output;") + : debug_drop_action(); + ds_clear(actions); + ds_put_format(actions, action, op->json_key); - for (size_t i = 0; i < op->nbsp->n_addresses; i++) { - /* Addresses are owned by the logical port. - * Ethernet address followed by zero or more IPv4 - * or IPv6 addresses (or both). */ - struct eth_addr mac; - bool lsp_enabled = lsp_is_enabled(op->nbsp); - const char *action = lsp_enabled - ? ((lsp_clone_to_unknown && op->od->has_unknown) - ? "clone {outport = %s; output; };" - "outport = \""MC_UNKNOWN "\"; output;" - : "outport = %s; output;") - : debug_drop_action(); - - if (ovs_scan(op->nbsp->addresses[i], - ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(mac))) { - ds_clear(match); - ds_put_format(match, "eth.dst == "ETH_ADDR_FMT, - ETH_ADDR_ARGS(mac)); + if (lsp_is_router(op->nbsp) && op->peer && op->peer->nbrp) { + /* For ports connected to logical routers add flows to bypass the + * broadcast flooding of ARP/ND requests in table 19. We direct the + * requests only to the router port that owns the IP address. + */ + build_lswitch_rport_arp_req_flows(op->peer, op->od, op, lflows, + &op->nbsp->header_); - ds_clear(actions); - ds_put_format(actions, action, op->json_key); - ovn_lflow_add_with_hint(lflows, op->od, - S_SWITCH_IN_L2_LKUP, - 50, ds_cstr(match), - ds_cstr(actions), - &op->nbsp->header_, - op->lflow_ref); - } else if (!strcmp(op->nbsp->addresses[i], "unknown")) { - continue; - } else if (is_dynamic_lsp_address(op->nbsp->addresses[i])) { - if (!op->nbsp->dynamic_addresses - || !ovs_scan(op->nbsp->dynamic_addresses, - ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(mac))) { - continue; - } - ds_clear(match); - ds_put_format(match, "eth.dst == "ETH_ADDR_FMT, - ETH_ADDR_ARGS(mac)); + ds_clear(match); + if (!eth_addr_is_zero(op->proxy_arp_addrs.ea)) { + ds_put_format(match, "eth.dst == { %s, %s }", + op->proxy_arp_addrs.ea_s, + op->peer->lrp_networks.ea_s); + } else { + ds_put_format(match, "eth.dst == %s", op->peer->lrp_networks.ea_s); + } - ds_clear(actions); - ds_put_format(actions, action, op->json_key); - ovn_lflow_add_with_hint(lflows, op->od, - S_SWITCH_IN_L2_LKUP, - 50, ds_cstr(match), - ds_cstr(actions), - &op->nbsp->header_, - op->lflow_ref); - } else if (!strcmp(op->nbsp->addresses[i], "router")) { - if (!op->peer || !op->peer->nbrp - || !ovs_scan(op->peer->nbrp->mac, - ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(mac))) { - continue; - } - ds_clear(match); - ds_put_cstr(match, "eth.dst == "); - if (!eth_addr_is_zero(op->proxy_arp_addrs.ea)) { - ds_put_format(match, - "{ %s, "ETH_ADDR_FMT" }", - op->proxy_arp_addrs.ea_s, - ETH_ADDR_ARGS(mac)); + if (op->peer->od->n_l3dgw_ports && op->od->n_localnet_ports) { + bool add_chassis_resident_check = false; + const char *json_key; + if (is_l3dgw_port(op->peer)) { + /* The peer of this port represents a distributed + * gateway port. The destination lookup flow for the + * router's distributed gateway port MAC address should + * only be programmed on the gateway chassis. */ + add_chassis_resident_check = true; + json_key = op->peer->cr_port->json_key; } else { - ds_put_format(match, ETH_ADDR_FMT, ETH_ADDR_ARGS(mac)); + /* Check if the option 'reside-on-redirect-chassis' + * is set to true on the peer port. If set to true + * and if the logical switch has a localnet port, it + * means the router pipeline for the packets from + * this logical switch should be run on the chassis + * hosting the gateway port. + */ + add_chassis_resident_check = smap_get_bool( + &op->peer->nbrp->options, + "reside-on-redirect-chassis", false) && + op->peer->od->n_l3dgw_ports == 1; + json_key = op->peer->od->l3dgw_ports[0]->cr_port->json_key; } - if (op->peer->od->n_l3dgw_ports - && op->od->n_localnet_ports) { - bool add_chassis_resident_check = false; - const char *json_key; - if (is_l3dgw_port(op->peer)) { - /* The peer of this port represents a distributed - * gateway port. The destination lookup flow for the - * router's distributed gateway port MAC address should - * only be programmed on the gateway chassis. */ - add_chassis_resident_check = true; - json_key = op->peer->cr_port->json_key; - } else { - /* Check if the option 'reside-on-redirect-chassis' - * is set to true on the peer port. If set to true - * and if the logical switch has a localnet port, it - * means the router pipeline for the packets from - * this logical switch should be run on the chassis - * hosting the gateway port. - */ - add_chassis_resident_check = smap_get_bool( - &op->peer->nbrp->options, - "reside-on-redirect-chassis", false) && - op->peer->od->n_l3dgw_ports == 1; - json_key = - op->peer->od->l3dgw_ports[0]->cr_port->json_key; - } - if (add_chassis_resident_check) { - ds_put_format(match, " && is_chassis_resident(%s)", - json_key); - } + if (add_chassis_resident_check) { + ds_put_format(match, " && is_chassis_resident(%s)", json_key); } + } + + ovn_lflow_add_with_hint(lflows, op->od, + S_SWITCH_IN_L2_LKUP, 50, + ds_cstr(match), ds_cstr(actions), + &op->nbsp->header_, + op->lflow_ref); + } else { + for (size_t i = 0; i < op->n_lsp_addrs; i++) { + ds_clear(match); + ds_put_format(match, "eth.dst == %s", op->lsp_addrs[i].ea_s); - ds_clear(actions); - ds_put_format(actions, action, op->json_key); ovn_lflow_add_with_hint(lflows, op->od, S_SWITCH_IN_L2_LKUP, 50, ds_cstr(match), ds_cstr(actions), &op->nbsp->header_, op->lflow_ref); - } else { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); - - VLOG_INFO_RL(&rl, - "%s: invalid syntax '%s' in addresses column", - op->nbsp->name, op->nbsp->addresses[i]); } } }