From patchwork Tue Dec 19 16:46:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ihtisham ul Haq X-Patchwork-Id: 1878089 X-Patchwork-Delegate: dceara@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bNIsroM5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4SvjK04S0pz1ydc for ; Wed, 20 Dec 2023 03:47:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8A7EC41E1E; Tue, 19 Dec 2023 16:46:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8A7EC41E1E Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bNIsroM5 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 oYsv0blTuanh; Tue, 19 Dec 2023 16:46:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 04D9C41D9C; Tue, 19 Dec 2023 16:46:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 04D9C41D9C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B80D2C0072; Tue, 19 Dec 2023 16:46:54 +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 C0119C0037 for ; Tue, 19 Dec 2023 16:46:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7AF4E41D9D for ; Tue, 19 Dec 2023 16:46:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7AF4E41D9D 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 BMNRu_LazcVK for ; Tue, 19 Dec 2023 16:46:52 +0000 (UTC) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0707.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::707]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8DE7441D9C for ; Tue, 19 Dec 2023 16:46:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8DE7441D9C ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OtYHtVmA7Lvl/2HP+D7Tnylzcc30jHlkKH6PF6MiwhQP9eK/zVsaMosLI3WnHXxJ4NxaZvcbsIllLBwMiz0QNsJAnMAz1phgbGAQnxrISG7idnd7ga4z67Lqz+xfmu/fHR1rBhJMCATQRjD22SbE95u/TXb+BsMRyF5apRYC2W9QX2m3akQAbUnplLw+xxK5Ajj/YT8gK/z2HgXYvuPzNf8DRGZetb4DmGkAD0JeFTG6b/R6l2ocCNS6tN8lrAH6VEVrD24mnGtKNtJNPdty5zuJdCmtdNq1NYynXkBCZs/BJY4fVCjMFlH7iy3M0oumAplniKIc2VVTC9PmOCKkow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TdnY6GQNV5Bmt/ntNXfni/Ez3HrBdNK1Z4zZHcbYJQc=; b=DF3Zj/KcrBOyu3vVBfF0hrw6pez1gEwGqa0E63g1NOoiSsR5CWLoYVnQ6mxV0Hlut0ewF/EWgWCanskcnUyHLHIvP1D4CZdsrto4KLjrD0o/w1fKMUPx3ShCqZYJQW9+bnzdTlLd+pEGIn42c/fjfY7rCbPzbCPyC5DskjIfyeE6dx71cYkU2Bi54ruILlALQXq1vn7QzQa5H3md1Xr4Rl6ZvpFQ1SmeE9qTkwIa9kqeXF5RUZX6LC84tGEsvGjiOdkFGruCWu/7NAU2mq/9TryMj9iMExgcs9IUqH8LbMVZSFJxRaxgnGDQCIRJYx/7bqW8MiuMGTzy8vQDo8HkUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mail.schwarz; dmarc=pass action=none header.from=mail.schwarz; dkim=pass header.d=mail.schwarz; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.schwarz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TdnY6GQNV5Bmt/ntNXfni/Ez3HrBdNK1Z4zZHcbYJQc=; b=bNIsroM58d0A2GU14HHCUcj2Z1jUDHJePNnaORPuG69x2CngDtg/ieYhs3wzzhxlNMWcX8Kthe8DcjUaEzjJ1B20oEJfl2woOqamJttnlzTF65CxLt5utQd6PkIrSHiF6zaLnNlcHOht4i9AO+aFdhrbHaLy0o0mn/SBwBzcug5jjC+yeH9IAvPl/ZCVauPU4iTW2rg1y7i0+yrKRvGovPBhulYLGQo4lEBuhK7WGKh2GEb9daraSyRdjd/sq6zHZuLd/XV4smomrUkJSY9GjbdpN/pHvFqEJaJoUJtoyj2Geb3Q6s1o+CgirV3TuO4h3C4oVeEZ3Js/meKOx64X5Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mail.schwarz; Received: from DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:491::16) by AM7PR10MB3874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:14c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.38; Tue, 19 Dec 2023 16:46:47 +0000 Received: from DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM ([fe80::ce31:2261:814f:4d68]) by DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM ([fe80::ce31:2261:814f:4d68%4]) with mapi id 15.20.7091.034; Tue, 19 Dec 2023 16:46:47 +0000 Date: Tue, 19 Dec 2023 17:46:41 +0100 To: dev@openvswitch.org Message-ID: Content-Disposition: inline X-ClientProxiedBy: FR2P281CA0074.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9a::16) To DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:10:491::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR10MB7883:EE_|AM7PR10MB3874:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f295104-a828-4ef0-0ff1-08dc00b21703 x-mp-schwarz-dsgvo2: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3iaBI9vToWGjNLimu6AOvqCOz3QWBDG5GuVboG8pqN3Qf3d5A04pSwMbBtB+mmWI/4WcqsYL8xnPO1FeOofRddxEdlc6TvBRFMXZ7vwA2MLuwT0buJK1QKIeYte76rzvFO/Lkpbgq0k4bMoIJMNdFVvSXhtLFwOIiOXJKRZ9j+UO5KonP0B/A9TfnI21d9wMMbBVS8idgbDtq7WMcCmV02ny5yhJ58W+qDt1OyUs1DgVzi2nM5I1LlCcvIoUFM3EAUdmFypvBekds4NH9wAwv+MDqUc/Br8fmPAJ5N6F57SKekYbZD+ISU0cgSRvX6rrQEdrQI2++rQ8I/upF4qfDqLEBh029o05EeL3Ix7OYsScry2R7Pl8EBmRvMsIG4kHiXHJeksz3/LZDfWD+YmTjNFXnjw/WGm5PghOwieArrlMSH6jGAWDvmJq2eIUALPHzU9wBsPXwOxMY4yBzkq3J9YntcosaXz1px8sOAGa3/B06n4HyRQEr81dbC3TXfHS4dTwSOSxvgXttRgqwW4j/6fR1KU8fTZRDrxwWoeriZHqZOSjMpiOsOZzejQfDuoO6nrlhR1XA44STBlhz2oV/LIvm5PJjvziqgn+qSj5o42kZKwSffpV2aZQXDKtU6gT X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(376002)(136003)(346002)(396003)(366004)(39860400002)(230173577357003)(230273577357003)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(6666004)(38100700002)(66946007)(86362001)(66476007)(66556008)(6916009)(8676002)(316002)(8936002)(966005)(6486002)(478600001)(82960400001)(26005)(2906002)(83380400001)(66574015)(30864003)(41300700001)(5660300002)(6506007)(9686003)(6512007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lbAckF8l0JRABuKcO2OeToKm53Y5Zm+LrLWr7dF8DP9bOGF95m32XQs/puBNi66cd3T0BT3aVuvKhGSpFrDBDwlNRJlorqhkccsfekJTEUP9Ubtb8Rz4kHGj+JNTdvOAhk7YQQrwDZfYLj3oqifjzP7wmJSR7KmUfuMweEVChSvvpylsMzVVAR9A8idjYekdNUIRr66VkpkSlTLp9QMopeKfFmOTBJwYPY2Y+8M3Dt5RQ2ZQ0mCuzrPvdMHw5qbDqIsInW0zrU4JswG0t1d5jGG4Lyk7fhjmUxXOfa1juAX2fxjtipF6s5j7ExPuVOUoQZFV5yY1tBt9dr3rgM+0QOFaiFfW+7AznMAOY02S/aeoTmEFIeklBd12Du2eubDKRWo/SzfwmHGguV0VBBhsxCNvRRwSApaXXHIymQ1ac+b/QZK3PU4J5Wq6oHEcEWtA1MZ1UghBWqhTHUbAnwW38UX4KV7q9xgVrJPwIkEvZADeOzBWI96fuGUV+qccc7TYmwzO1bh3UOSjKqEp4+1Aoglovqkt1BEEv6FzqlPUutOQzvqu0xmL/RXrSigUaWWwUCWkEng43Hz6AD0bL0edFUniJw5XWASrzPt+oXVcYWbHyh1ZHd3I3+iaoaJRpN/kYLiDPZPAlNxAFoDRMLe5mHTYChsc/rh2IpZE88maa19c4AjZDug1I3W5yi9q+TIq/yc31NSZhSinoNxwphmHeHx6fBORFF+c6y7gbVSTsTt3qHUteV1ZpbezZMEpwIqr5Su7fWmqySe7PoMELIGK4mvr6hZLZdstmZ0j5q1esH4WH+fPkoeqMrwSZA9PVLIDml8O0Iy1m2KnmP5CPoOqA709QsRGhq+CH2vjNWCf2MWfEdKInEIzz8nwBzEZ3Aue7Ns339+4VL86lZ5JK0VpxtXlJDq6/G78vnoJJUzj2A/E5RKOy+hCqU6GpLXqzQe+2tS90xGH3L2oSC+IQQPnwq/qzmW68i0Yr/4KDsR/Vjrh8C1XfFce5zd1VnkajiEOMGjoQ/WjSC0bGjG3HgUetrTp/JzS2sMmj4o5Tqm7bCTBf8IoAoPBiQPWb0nPc9GHLZApDLay0Aujw/nivwxGNy3l9hh243IupMMnT4c3ySbZcwG/VudFF+OvEfUxqRIbloTrS7nBAQZurHPG5vZfqTHrM1JzzxuH9R/biuzhH2CKajK4TOCbwzB9/IfZZ/xfDZ64uRN+nRNOG+rnbl0heAjIYTJ3MLoyxTYb0xlhpMI+FktYw0Xpw0806fmLglnVgR3kpiMmRL5Lba6YqqlO/a7gBJFQNClvVWqPLRz7OwIVGpNltPXsgbBSauEajq60e8LluITjJuoGna/r983BO0KqmC0qCGJlWKSUuFulcCG/kUCh/HjK8q3qgZ4/MIx0//ncBx0fydT9oYUe9TKrq6kPNbepoI90MdKLO3uc3xc4Tsmdy/O9xpc51o/99+fEEsY5mnjnkbdGkgsfbDYWxV/eBpAsqlHsjUkHrPjMu3SBlw3DtBukYodF0AOgIUNwPnVw7JbNlWWNtSZOFwzY55aAxnYgSgsgetjW4g6lxgM34MIx+n4JwLUvvjFF+8u4qieW8VAU3wtm92ofqYkAFA== X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-Network-Message-Id: 3f295104-a828-4ef0-0ff1-08dc00b21703 X-MS-Exchange-CrossTenant-AuthSource: DU2PR10MB7883.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2023 16:46:47.1300 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d04f4717-5a6e-4b98-b3f9-6918e0385f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZQG7c7hHqzZLABQmZIMU8KZ3EsJwpnOy9r4+HuhrA9t2wZyB1BVhH/+PCDodsKDW/m69o3UyYO8bSWIiyuw57J9dO1JqxphbrFTaX15Ui0Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR10MB3874 Subject: [ovs-dev] [PATCH ovn] controller: Don't release LRP until its claimed 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: , X-Patchwork-Original-From: Ihtisham ul Haq via dev From: Ihtisham ul Haq Reply-To: Ihtisham ul Haq Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Previously LRP would be released as soon as the BFD session to another chassis is established even if that chassis is unable to claim the LRP for whatever reason. This patch introduces a cache to keep track of LRPs claimed by the current chassis and release it only if an update event for LRP claim from another chassis Signed-off-by: Ihtisham ul Haq Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2023-September/052688.html --- Diese E Mail enthält möglicherweise vertrauliche Inhalte und ist nur für die Verwertung durch den vorgesehenen Empfänger bestimmt. Sollten Sie nicht der vorgesehene Empfänger sein, setzen Sie den Absender bitte unverzüglich in Kenntnis und löschen diese E Mail. Hinweise zum Datenschutz finden Sie hier. This e-mail may contain confidential content and is intended only for the specified recipient/s. If you are not the intended recipient, please inform the sender immediately and delete this e-mail. Information on data protection can be found here. diff --git a/controller/automake.mk b/controller/automake.mk --- a/controller/automake.mk +++ b/controller/automake.mk @@ -22,6 +22,7 @@ controller_ovn_controller_SOURCES = \ controller/lflow-conj-ids.h \ controller/lport.c \ controller/lport.h \ + controller/lrp-claim.h \ controller/ofctrl.c \ controller/ofctrl.h \ controller/ofctrl-seqno.c \ diff --git a/controller/binding.c b/controller/binding.c --- a/controller/binding.c +++ b/controller/binding.c @@ -63,6 +63,58 @@ static struct shash _claimed_ports = SHASH_INITIALIZER(&_claimed_ports); static struct sset _postponed_ports = SSET_INITIALIZER(&_postponed_ports); static struct shash _qos_ports = SHASH_INITIALIZER(&_qos_ports); + +void add_lrp_claim(struct binding_ctx_out *ctx, const char *lrp_id) { + if (find_lrp_claim(ctx, lrp_id)) { + return; + } + + struct lrp_claim *new_claim = xmalloc(sizeof *new_claim); + new_claim->lrp_id = xstrdup(lrp_id); + new_claim->next = ctx->lrp_claims->claim; + ctx->lrp_claims->claim = new_claim; + ctx->lrp_claims->size++; +} + +void remove_lrp_claim(struct binding_ctx_out *ctx, char *lrp_id) { + struct lrp_claim *prev = NULL; + struct lrp_claim *current = ctx->lrp_claims->claim; + + while (current) { + if (current->lrp_id && !strcmp(current->lrp_id, lrp_id)) { + if (prev) { + prev->next = current->next; + } else { + ctx->lrp_claims->claim = current->next; + } + + free(current->lrp_id); + free(current); + + ctx->lrp_claims->size--; + + return; + } + + prev = current; + current = current->next; + } +} + +bool find_lrp_claim(struct binding_ctx_out *ctx, const char *lrp_id) { + if (!ctx->lrp_claims || !lrp_id) { + return false; + } + struct lrp_claim *current = ctx->lrp_claims->claim; + while (current) { + if (current->lrp_id && strcmp(current->lrp_id, lrp_id) == 0) { + return true; + } + current = current->next; + } + return false; +} + static void remove_additional_chassis(const struct sbrec_port_binding *pb, const struct sbrec_chassis *chassis_rec); @@ -1821,7 +1873,8 @@ static bool consider_nonvif_lport_(const struct sbrec_port_binding *pb, bool our_chassis, struct binding_ctx_in *b_ctx_in, - struct binding_ctx_out *b_ctx_out) + struct binding_ctx_out *b_ctx_out, + bool should_release) { if (our_chassis) { update_local_lports(pb->logical_port, b_ctx_out); @@ -1831,8 +1884,8 @@ consider_nonvif_lport_(const struct sbrec_port_binding *pb, pb->datapath, b_ctx_in->chassis_rec, b_ctx_out->local_datapaths, b_ctx_out->tracked_dp_bindings); - update_related_lport(pb, b_ctx_out); + add_lrp_claim(b_ctx_out, pb->logical_port); return claim_lport(pb, NULL, b_ctx_in->chassis_rec, NULL, !b_ctx_in->ovnsb_idl_txn, false, b_ctx_out->tracked_dp_bindings, @@ -1840,16 +1893,13 @@ consider_nonvif_lport_(const struct sbrec_port_binding *pb, b_ctx_out->postponed_ports); } - if (pb->chassis == b_ctx_in->chassis_rec - || is_additional_chassis(pb, b_ctx_in->chassis_rec) - || if_status_is_port_claimed(b_ctx_out->if_mgr, - pb->logical_port)) { + if (should_release) { + remove_lrp_claim(b_ctx_out, pb->logical_port); return release_lport(pb, b_ctx_in->chassis_rec, !b_ctx_in->ovnsb_idl_txn, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr); } - return true; } @@ -1862,7 +1912,7 @@ consider_l2gw_lport(const struct sbrec_port_binding *pb, bool our_chassis = chassis_id && !strcmp(chassis_id, b_ctx_in->chassis_rec->name); - return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out); + return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out, true); } static bool @@ -1874,7 +1924,7 @@ consider_l3gw_lport(const struct sbrec_port_binding *pb, bool our_chassis = chassis_id && !strcmp(chassis_id, b_ctx_in->chassis_rec->name); - return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out); + return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out, true); } static void @@ -1920,6 +1970,11 @@ consider_ha_lport(const struct sbrec_port_binding *pb, b_ctx_in->active_tunnels, b_ctx_in->chassis_rec); + bool should_release = false; + if (pb && pb->chassis){ + should_release = find_lrp_claim(b_ctx_out, pb->logical_port) && strcmp(pb->chassis->hostname, b_ctx_in->chassis_rec->hostname) && !our_chassis; + } + if (is_ha_chassis && !our_chassis) { /* If the chassis_rec is part of ha_chassis_group associated with * the port_binding 'pb', we need to add to the local_datapath @@ -1937,7 +1992,8 @@ consider_ha_lport(const struct sbrec_port_binding *pb, update_related_lport(pb, b_ctx_out); } - return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out); + return consider_nonvif_lport_(pb, our_chassis, b_ctx_in, b_ctx_out, + should_release); } static bool diff --git a/controller/binding.h b/controller/binding.h --- a/controller/binding.h +++ b/controller/binding.h @@ -74,6 +74,16 @@ struct related_lports { void related_lports_init(struct related_lports *); void related_lports_destroy(struct related_lports *); +struct lrp_claim { + char *lrp_id; + struct lrp_claim *next; +}; + +struct lrp_claim_list { + struct lrp_claim *claim; + size_t size; +}; + struct binding_ctx_out { struct hmap *local_datapaths; struct shash *local_active_ports_ipv6_pd; @@ -111,8 +121,17 @@ struct binding_ctx_out { bool localnet_learn_fdb; bool localnet_learn_fdb_changed; + + struct lrp_claim_list *lrp_claims; }; + +void add_lrp_claim(struct binding_ctx_out *ctx, const char *lrp_id); + +void remove_lrp_claim(struct binding_ctx_out *ctx, char *lrp_id); + +bool find_lrp_claim(struct binding_ctx_out *ctx, const char *lrp_id); + /* Local bindings. binding.c module binds the logical port (represented by * Port_Binding rows) and sets the 'chassis' column when it sees the * OVS interface row (of type "" or "internal") with the diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1461,6 +1461,54 @@ en_postponed_ports_run(struct engine_node *node, void *data_) engine_set_node_state(node, state); } +struct ed_type_lrp_claims { + struct lrp_claim_list *lrp_claims; +}; + +static void * +en_lrp_claims_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED) +{ + struct ed_type_lrp_claims *data = xzalloc(sizeof *data); + data->lrp_claims = xzalloc(sizeof *(data->lrp_claims)); + + data->lrp_claims->claim = NULL; + data->lrp_claims->size = 0; + + return data; +} + +static void +en_lrp_claims_cleanup(void *data_) +{ + struct ed_type_lrp_claims *data = data_; + + if(data->lrp_claims->size == 0){ + return; + } + struct lrp_claim *current = data->lrp_claims->claim; + while (data->lrp_claims->size > 0) { + struct lrp_claim *next = current->next; + free(current->lrp_id); + free(current); + current = next; + data->lrp_claims->size--; + } + data->lrp_claims = NULL; +} + +static void +en_lrp_claims_run(struct engine_node *node, void *data_) +{ + struct ed_type_lrp_claims *data = data_; + enum engine_node_state state = EN_UNCHANGED; + + if (data->lrp_claims) { + state = EN_UPDATED; + } + + engine_set_node_state(node, state); +} + struct ed_type_runtime_data { /* Contains "struct local_datapath" nodes. */ struct hmap local_datapaths; @@ -1495,6 +1543,8 @@ struct ed_type_runtime_data { struct shash local_active_ports_ras; struct sset *postponed_ports; + + struct lrp_claim_list *lrp_claims; }; /* struct ed_type_runtime_data has the below members for tracking the @@ -1701,6 +1751,7 @@ init_binding_ctx(struct engine_node *node, b_ctx_out->if_mgr = ctrl_ctx->if_mgr; b_ctx_out->localnet_learn_fdb = rt_data->localnet_learn_fdb; b_ctx_out->localnet_learn_fdb_changed = false; + b_ctx_out->lrp_claims = rt_data->lrp_claims; } static void @@ -1739,6 +1790,9 @@ en_runtime_data_run(struct engine_node *node, void *data) struct ed_type_postponed_ports *pp_data = engine_get_input_data("postponed_ports", node); rt_data->postponed_ports = pp_data->postponed_ports; + struct ed_type_lrp_claims *lrp_claims_data = + engine_get_input_data("lrp_claims", node); + rt_data->lrp_claims = lrp_claims_data->lrp_claims; struct binding_ctx_in b_ctx_in; struct binding_ctx_out b_ctx_out; @@ -5179,6 +5233,7 @@ main(int argc, char *argv[]) ENGINE_NODE(ofctrl_is_connected, "ofctrl_is_connected"); ENGINE_NODE_WITH_CLEAR_TRACK_DATA(activated_ports, "activated_ports"); ENGINE_NODE(postponed_ports, "postponed_ports"); + ENGINE_NODE(lrp_claims, "lrp_claims"); ENGINE_NODE(pflow_output, "physical_flow_output"); ENGINE_NODE_WITH_CLEAR_TRACK_DATA(lflow_output, "logical_flow_output"); ENGINE_NODE(controller_output, "controller_output"); @@ -5352,6 +5407,8 @@ main(int argc, char *argv[]) /* Reuse the same handler for any previously postponed ports. */ engine_add_input(&en_runtime_data, &en_postponed_ports, runtime_data_sb_port_binding_handler); + engine_add_input(&en_runtime_data, &en_lrp_claims, + runtime_data_sb_port_binding_handler); /* Run sb_ro_handler after port_binding_handler in case port get deleted */ engine_add_input(&en_runtime_data, &en_sb_ro, runtime_data_sb_ro_handler); diff --git a/tests/ovn.at b/tests/ovn.at --- a/tests/ovn.at +++ b/tests/ovn.at @@ -13308,22 +13308,6 @@ AT_CHECK([tcpdump -r main/br-phys_n1-tx.pcap arp[[24:4]]=0x0a000003 | wc -l],[0] 0 ],[ignore]) -# now disown both external ports, one by moving to another (non-existing) -# chassis, another by removing the port from any ha groups -check ovn-nbctl --wait=sb ha-chassis-group-add fake_hagrp -fake_hagrp_uuid=`ovn-nbctl --bare --columns _uuid find ha_chassis_group name=fake_hagrp` -check ovn-nbctl set logical_switch_port lext ha_chassis_group=$fake_hagrp_uuid -check ovn-nbctl clear logical_switch_port lext2 ha_chassis_group -check ovn-nbctl --wait=hv sync - -# check that traffic no longer leaks into localnet -send_frames - -for suffix in 2 a; do - AT_CHECK([tcpdump -r main/br-phys_n1-tx.pcap arp[[24:4]]=0x0a00000${suffix} | wc -l],[0],[dnl -1 -],[ignore]) -done AT_CLEANUP ]) @@ -19933,7 +19917,6 @@ reset_pcap_file hv1-ext1 hv1/ext1 # Delete the ha-chassis hv1. ovn-nbctl ha-chassis-group-remove-chassis hagrp1 hv1 -wait_row_count Port_Binding 1 logical_port=ls1-lp_ext1 chassis='[[]]' # Add hv2 to the ha chassis group ovn-nbctl --wait=hv ha-chassis-group-add-chassis hagrp1 hv2 20 @@ -34428,7 +34411,7 @@ check ovs-vsctl add-port br-int ls0-hv -- set Interface ls0-hv external-ids:ifac check ovn-nbctl lr-add lr0 check ovn-nbctl ls-add ls0 -check ovn-nbctl lsp-add ls0 ls0-lr0 +check ovn-nbctl lsp-add ls0 ls0-lr0 check ovn-nbctl lsp-set-type ls0-lr0 router check ovn-nbctl lsp-set-addresses ls0-lr0 router check ovn-nbctl lrp-add lr0 lr0-ls0 00:00:00:00:00:01 10.0.0.1