From patchwork Fri Aug 2 15:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shibir Basak X-Patchwork-Id: 1968400 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=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=aJEtOTSS; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=Jq7wVWj4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4Wb8Mp5qXfz1yZl for ; Sat, 3 Aug 2024 01:07:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D9D4A40298; Fri, 2 Aug 2024 15:07:48 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id CsA6OIHXOkYD; Fri, 2 Aug 2024 15:07:46 +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 smtp2.osuosl.org 82CFE4023B Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=proofpoint20171006 header.b=aJEtOTSS; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=nutanix.com header.i=@nutanix.com header.a=rsa-sha256 header.s=selector1 header.b=Jq7wVWj4 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 82CFE4023B; Fri, 2 Aug 2024 15:07:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 52153C002B; Fri, 2 Aug 2024 15:07:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2B85C002A for ; Fri, 2 Aug 2024 15:07:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8486A403EB for ; Fri, 2 Aug 2024 15:07:45 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id bqMjoMlaaUEf for ; Fri, 2 Aug 2024 15:07:43 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=148.163.151.68; helo=mx0a-002c1b01.pphosted.com; envelope-from=shibir.basak@nutanix.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 769434023B Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=nutanix.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 769434023B Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by smtp2.osuosl.org (Postfix) with ESMTPS id 769434023B for ; Fri, 2 Aug 2024 15:07:42 +0000 (UTC) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4727mHnB028976 for ; Fri, 2 Aug 2024 08:07:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=proofpoint20171006; bh=aHGV9a+C8HzfD 9VhLrPg+A9jM1+vriHtuY8rQKIYqgU=; b=aJEtOTSSgX+3K3nU/Q3FqGd0Rive5 rQFQHTgkI2dG0ndzVqJ9cvCVBL4DrfjSoQlXdTzOimQve9s+PgM1g2ZM3moQpwSE ikLUpJP7Jd74kEzTGzliLdvT2ssuZXPJHbZiqLKlbJdM1XDU+kS+6zw0HD6BEqEV 84G+tYqtVAdJ6Q1zr70TG1cuHKBU8NfIaGRcxO28m9ADFjJ8lCzJBxs0efgtiy4i fOwQI9eTlVhGQJ/IGlcdFR9Iz3Qk/Xgg2tOCWDQf2X6j2IAYxkqxyflmbMUCQk+x l5Sum1SLlDhFCaWn0aw+WTwMORtL2KY2s1X7X4Aod/8t6nnyqHny/eUyw== Received: from dm1pr04cu001.outbound.protection.outlook.com (mail-centralusazlp17010006.outbound.protection.outlook.com [40.93.13.6]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 40q9cgyahw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Aug 2024 08:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l/HC6524onDPBjJcUV/vQFD4Mor+5HEwJoEG/0ZSfz4392EVl+/LCMQD4Gels27ItwnVgj7SiXRnwYtYJbC/LQKVgS/9V1xaEZnpNNkKPw2WyX9eryxHOU9p6ulQYesdKkOIPxxbt2IB78P5nXc/IbOPgv9VKVchGKhe8P64ujl2TZ5VtE2hneRzim4jqKwX0VrFujRKPE/V6r66Ucgvn8ce+Qg84OuAWx5HRSr5CefWslpNYv8L8zE6xgAj29EL5OPZuoUUgf8hlBdX5vHpLCk1+o50D+kz79WAHW4q9MTjnnzuWXiNMo4SqtptRrF2Eh3YHjO1GuRZlCb55z8pdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=aHGV9a+C8HzfD9VhLrPg+A9jM1+vriHtuY8rQKIYqgU=; b=npF5lGIKmUT4v5oRNRHx0Mwt3Xcvn1fIsoyKosaRkRub7Phc9WqOLXosrGhB3PIjOBhbQ1k5nxqo87NSQnHTobzgIaWZYcUoWhnM8Xl4ZxtOt+HiSMX4klVgcXRU3vxSyqBkqJ4L7IXIlkV73kFyYLAvL82MLN5i2QpT2tcHH5pD4vL0WfW2uS0tRHvgR/ja9kW56onB1o898k/zeNf51tuDqrGt2MLGSeibFUu896RZw2m3DT1Ia8TcFcLr40DMSR4UlFN9yqd251hChWN8MvLOpq0NjJs1ECo4DcM3+fg5U/CVOXpo6oC6imzKx1hrY74pstocR9TJKuXcHXeySA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aHGV9a+C8HzfD9VhLrPg+A9jM1+vriHtuY8rQKIYqgU=; b=Jq7wVWj4ABsQ1nmJwKwrXbgCShdWehBCdgYXlVk38JuNzo8bRRV/F13IMAvmm5Vp7/umSlkFxWO7oBvoNOFQIpl79wttEzLuMwJfpvXxEtFKcTVvyevPuX4mr6UhRy+NOWYsOUVBN1OPuzBVO+mFIlT4gNWg7rvKSDusyYOOgebmtM7NQ21UVrjjaG7kXmakCqAXI69lqxGeEsa4uKBibW4VQJgVE304h40kAXkQXayYEgtpscQpaBG0A+HfYc8Uw/Q70RtNXpcI8ZZ5UnkEHdrC352O/Yc8IPsdyz3KP3AwQyhLb5P/kZ5X/fbFyD8kQ9LA+VU2pILG16aVHT9ODw== Received: from DM6PR02MB5529.namprd02.prod.outlook.com (2603:10b6:5:30::11) by PH0PR02MB8780.namprd02.prod.outlook.com (2603:10b6:510:f3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.23; Fri, 2 Aug 2024 15:07:38 +0000 Received: from DM6PR02MB5529.namprd02.prod.outlook.com ([fe80::baa7:c095:e8a8:5c0c]) by DM6PR02MB5529.namprd02.prod.outlook.com ([fe80::baa7:c095:e8a8:5c0c%4]) with mapi id 15.20.7828.016; Fri, 2 Aug 2024 15:07:37 +0000 From: Shibir Basak To: dev@openvswitch.org Date: Fri, 2 Aug 2024 15:07:28 +0000 Message-Id: <20240802150728.130030-1-shibir.basak@nutanix.com> X-Mailer: git-send-email 2.22.3 X-ClientProxiedBy: BYAPR01CA0001.prod.exchangelabs.com (2603:10b6:a02:80::14) To DM6PR02MB5529.namprd02.prod.outlook.com (2603:10b6:5:30::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR02MB5529:EE_|PH0PR02MB8780:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d430fc3-fd9d-4eb8-6227-08dcb304d8aa x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|366016|376014|1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DxVdzY+YWb9u9gGg3tGXXrNKtYJqrQ0PRB/a1qF+d8ce6vNn36JmIF8+j5wRIQl495LLF3qeKRHskR0H7ZSb000muttDgHRwbPNRKsawgq4d9IeVZnKQiYrXC4ZJVvpBLu10WOVH8p0BzhJHlhJqvCAv6ugZWnrvPokrWvQFVK/J7eZHRJDuGmEJxsrlpyiG1jYSpCWFWQ8e2OUeNMuQiMDsAIvwILYtn9wtuBDA7+OllCaNLBkyFzUq5uEyPz1ofxtPwbaOMinEJo+EN9cbaymgJaJggJqpUeVQd1XG806C+mrNNCxU9ROBfbDRGtk4fTYb+LPbSWIamuQWY/YAozQDQPbvN4wMg3t08y0+r0nsO+elT7ERHo4gBlUFA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR02MB5529.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(366016)(376014)(1800799024)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uuwxeMj0ksGye4lbqMRsTKmAhAJcK+TiPvByfuE76uR5AqZer3FZ4YsNsps6pOFJKa5eJ1CvilDq/2ufmn/UNkD/nCT5/OyOGNYoR042Ui4hzQSsRE5DDHwU/LjeorFoM+SV3vo96vblOLnI2616M9bydsV3m6WQqlvfbJ7hvgjHcwXk8nRSb2jJwBo9uHg8M2rMrvY72uqhB6BwO2YkslDSIRL9FXz/mkIs4dD5r+zL7peBhU4WZKhNwVBmub9Im0J3YdgpeDM9msd8r/AVXWnRHBUDHhWEUDdwA4GUw3XTwEqIaN4yeIec5Deslj9jgyC8UP27lLSieS0JdsEhpSyz60Gqt/AGvg7DjQqjb5wUBh0Gc6kpBqFzTG7ho7xllD218/dMjZnCbdXe/Vu2HGhk95+j6K+DZAsu8v+BHRaOtJ4Ju4S6778l/zmyMc3QKD/nagxmV/3OLq02sN25VUPB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Lrs4A8mWPtNVGOIpGvskRuAp+n0wdknwRS9uhOqG75pFhuRvCQLq7pdmhOMi+TUmSpHx6m58wlA== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d430fc3-fd9d-4eb8-6227-08dcb304d8aa X-MS-Exchange-CrossTenant-AuthSource: DM6PR02MB5529.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2024 15:07:37.8287 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wFm3ifzfz4lMB9hBWLWwpQ6g1aoEPvRm1w2QzcDaTyD0ps7I5MeO+Uy1xNjT2nGsCxSX0afMiSyhMcDz6JL6FmMJbXWjoVo6S01zky5OWhg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR02MB8780 X-Proofpoint-ORIG-GUID: QTC2eOgYcM3AF2Jfy09G7RzOI7NW23CF X-Proofpoint-GUID: QTC2eOgYcM3AF2Jfy09G7RzOI7NW23CF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_10,2024-08-02_01,2024-05-17_01 X-Proofpoint-Spam-Reason: safe Subject: [ovs-dev] [PATCH ovn] controller: Cleanup FDB entries when a VIF goes down. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shibir Basak Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When a VIF port goes down, all FDB entries associated with it are deleted. This helps is reducing traffic outage due to stale FDB entries present until the lsp is removed. Acked-by: Naveen Yerramneni Signed-off-by: Shibir Basak Acked-by: Naveen Yerramneni Signed-off-by: Shibir Basak Acked-by: Naveen Yerramneni Signed-off-by: Shibir Basak Acked-by: Naveen Yerramneni Signed-off-by: Shibir Basak Acked-by: Naveen Yerramneni Signed-off-by: Shibir Basak --- controller/ovn-controller.c | 5 ++++ controller/pinctrl.c | 40 ++++++++++++++++++++------ controller/pinctrl.h | 1 + lib/automake.mk | 4 ++- lib/fdb.c | 33 +++++++++++++++++++++ lib/fdb.h | 26 +++++++++++++++++ tests/ovn.at | 57 +++++++++++++++++++++++++++++++++++++ 7 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 lib/fdb.c create mode 100644 lib/fdb.h diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 6a7cca673..2acdddd09 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -4936,6 +4936,10 @@ main(int argc, char *argv[]) = ovsdb_idl_index_create2(ovnsb_idl_loop.idl, &sbrec_fdb_col_mac, &sbrec_fdb_col_dp_key); + struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port + = ovsdb_idl_index_create2(ovnsb_idl_loop.idl, + &sbrec_fdb_col_port_key, + &sbrec_fdb_col_dp_key); struct ovsdb_idl_index *sbrec_mac_binding_by_datapath = mac_binding_by_datapath_index_create(ovnsb_idl_loop.idl); struct ovsdb_idl_index *sbrec_static_mac_binding_by_datapath @@ -5645,6 +5649,7 @@ main(int argc, char *argv[]) sbrec_igmp_group, sbrec_ip_multicast, sbrec_fdb_by_dp_key_mac, + sbrec_fdb_by_dp_and_port, sbrec_dns_table_get(ovnsb_idl_loop.idl), sbrec_controller_event_table_get( ovnsb_idl_loop.idl), diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 7cbb0cf81..9e37e1693 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -62,6 +62,7 @@ #include "lflow.h" #include "ip-mcast.h" #include "ovn-sb-idl.h" +#include "lib/fdb.h" VLOG_DEFINE_THIS_MODULE(pinctrl); @@ -236,6 +237,7 @@ static void send_garp_rarp_prepare( struct ovsdb_idl_index *sbrec_port_binding_by_datapath, struct ovsdb_idl_index *sbrec_port_binding_by_name, struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip, + struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, const struct ovsrec_bridge *, const struct sbrec_chassis *, const struct hmap *local_datapaths, @@ -4145,6 +4147,7 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_igmp_groups, struct ovsdb_idl_index *sbrec_ip_multicast_opts, struct ovsdb_idl_index *sbrec_fdb_by_dp_key_mac, + struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, const struct sbrec_dns_table *dns_table, const struct sbrec_controller_event_table *ce_table, const struct sbrec_service_monitor_table *svc_mon_table, @@ -4166,7 +4169,8 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, sbrec_port_binding_by_key, chassis); send_garp_rarp_prepare(ovnsb_idl_txn, sbrec_port_binding_by_datapath, sbrec_port_binding_by_name, - sbrec_mac_binding_by_lport_ip, br_int, chassis, + sbrec_mac_binding_by_lport_ip, + sbrec_fdb_by_dp_and_port, br_int, chassis, local_datapaths, active_tunnels, ovs_table); prepare_ipv6_ras(local_active_ports_ras, sbrec_port_binding_by_name); prepare_ipv6_prefixd(ovnsb_idl_txn, sbrec_port_binding_by_name, @@ -5017,7 +5021,6 @@ wait_put_mac_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn) } } - /* * Send gratuitous/reverse ARP for vif on localnet. * @@ -5034,6 +5037,7 @@ struct garp_rarp_data { * announcement (in msecs). */ uint32_t dp_key; /* Datapath used to output this GARP. */ uint32_t port_key; /* Port to inject the GARP into. */ + bool enabled; /* is garp/rarp announcement enabled */ }; /* Contains GARPs/RARPs to be sent. Protected by pinctrl_mutex*/ @@ -5054,7 +5058,7 @@ destroy_send_garps_rarps(void) /* Runs with in the main ovn-controller thread context. */ static void add_garp_rarp(const char *name, const struct eth_addr ea, ovs_be32 ip, - uint32_t dp_key, uint32_t port_key) + uint32_t dp_key, uint32_t port_key, bool enabled) { struct garp_rarp_data *garp_rarp = xmalloc(sizeof *garp_rarp); garp_rarp->ea = ea; @@ -5063,6 +5067,7 @@ add_garp_rarp(const char *name, const struct eth_addr ea, ovs_be32 ip, garp_rarp->backoff = 1000; /* msec. */ garp_rarp->dp_key = dp_key; garp_rarp->port_key = port_key; + garp_rarp->enabled = enabled; shash_add(&send_garp_rarp_data, name, garp_rarp); /* Notify pinctrl_handler so that it can wakeup and process @@ -5081,6 +5086,8 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, bool garp_continuous) { volatile struct garp_rarp_data *garp_rarp = NULL; + bool is_garp_rarp_enabled = !smap_get_bool(&binding_rec->options, + "disable_garp_rarp", false); /* Skip localports as they don't need to be announced */ if (!strcmp(binding_rec->type, "localport")) { @@ -5104,6 +5111,7 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, if (garp_rarp) { garp_rarp->dp_key = binding_rec->datapath->tunnel_key; garp_rarp->port_key = binding_rec->tunnel_key; + garp_rarp->enabled = is_garp_rarp_enabled; if (garp_max_timeout != garp_rarp_max_timeout || garp_continuous != garp_rarp_continuous) { /* reset backoff */ @@ -5114,7 +5122,8 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, add_garp_rarp(name, laddrs->ea, laddrs->ipv4_addrs[i].addr, binding_rec->datapath->tunnel_key, - binding_rec->tunnel_key); + binding_rec->tunnel_key, + is_garp_rarp_enabled); send_garp_locally(ovnsb_idl_txn, sbrec_mac_binding_by_lport_ip, local_datapaths, binding_rec, laddrs->ea, @@ -5134,6 +5143,7 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, if (garp_rarp) { garp_rarp->dp_key = binding_rec->datapath->tunnel_key; garp_rarp->port_key = binding_rec->tunnel_key; + garp_rarp->enabled = is_garp_rarp_enabled; if (garp_max_timeout != garp_rarp_max_timeout || garp_continuous != garp_rarp_continuous) { /* reset backoff */ @@ -5143,7 +5153,8 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, } else { add_garp_rarp(name, laddrs->ea, 0, binding_rec->datapath->tunnel_key, - binding_rec->tunnel_key); + binding_rec->tunnel_key, + is_garp_rarp_enabled); } free(name); } @@ -5159,6 +5170,7 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, if (garp_rarp) { garp_rarp->dp_key = binding_rec->datapath->tunnel_key; garp_rarp->port_key = binding_rec->tunnel_key; + garp_rarp->enabled = is_garp_rarp_enabled; if (garp_max_timeout != garp_rarp_max_timeout || garp_continuous != garp_rarp_continuous) { /* reset backoff */ @@ -5184,7 +5196,8 @@ send_garp_rarp_update(struct ovsdb_idl_txn *ovnsb_idl_txn, add_garp_rarp(binding_rec->logical_port, laddrs.ea, ip, binding_rec->datapath->tunnel_key, - binding_rec->tunnel_key); + binding_rec->tunnel_key, + is_garp_rarp_enabled); if (ip) { send_garp_locally(ovnsb_idl_txn, sbrec_mac_binding_by_lport_ip, local_datapaths, binding_rec, laddrs.ea, ip); @@ -6547,6 +6560,10 @@ send_garp_rarp_run(struct rconn *swconn, long long int *send_garp_rarp_time) long long int current_time = time_msec(); *send_garp_rarp_time = LLONG_MAX; SHASH_FOR_EACH (iter, &send_garp_rarp_data) { + struct garp_rarp_data *garp_rarp = iter->data; + if (!garp_rarp->enabled) { + continue; + } long long int next_announce = send_garp_rarp(swconn, iter->data, current_time); if (*send_garp_rarp_time > next_announce) { @@ -6562,6 +6579,7 @@ send_garp_rarp_prepare(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_port_binding_by_datapath, struct ovsdb_idl_index *sbrec_port_binding_by_name, struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip, + struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *chassis, const struct hmap *local_datapaths, @@ -6597,12 +6615,18 @@ send_garp_rarp_prepare(struct ovsdb_idl_txn *ovnsb_idl_txn, &nat_ip_keys, &local_l3gw_ports, chassis, active_tunnels, &nat_addresses); + /* For deleted ports and deleted nat ips, remove from * send_garp_rarp_data. */ struct shash_node *iter; SHASH_FOR_EACH_SAFE (iter, &send_garp_rarp_data) { if (!sset_contains(&localnet_vifs, iter->name) && !sset_contains(&nat_ip_keys, iter->name)) { + struct garp_rarp_data *data = iter->data; + /* Cleanup FDB entries for inactive ports */ + delete_fdb_entries(sbrec_fdb_by_dp_and_port, + data->dp_key, + data->port_key); send_garp_rarp_delete(iter->name); } } @@ -6612,7 +6636,7 @@ send_garp_rarp_prepare(struct ovsdb_idl_txn *ovnsb_idl_txn, SSET_FOR_EACH (iface_id, &localnet_vifs) { const struct sbrec_port_binding *pb = lport_lookup_by_name( sbrec_port_binding_by_name, iface_id); - if (pb && !smap_get_bool(&pb->options, "disable_garp_rarp", false)) { + if (pb) { send_garp_rarp_update(ovnsb_idl_txn, sbrec_mac_binding_by_lport_ip, local_datapaths, pb, &nat_addresses, @@ -6625,7 +6649,7 @@ send_garp_rarp_prepare(struct ovsdb_idl_txn *ovnsb_idl_txn, SSET_FOR_EACH (gw_port, &local_l3gw_ports) { const struct sbrec_port_binding *pb = lport_lookup_by_name(sbrec_port_binding_by_name, gw_port); - if (pb && !smap_get_bool(&pb->options, "disable_garp_rarp", false)) { + if (pb) { send_garp_rarp_update(ovnsb_idl_txn, sbrec_mac_binding_by_lport_ip, local_datapaths, pb, &nat_addresses, garp_max_timeout, garp_continuous); diff --git a/controller/pinctrl.h b/controller/pinctrl.h index 3462b670c..6613c87e4 100644 --- a/controller/pinctrl.h +++ b/controller/pinctrl.h @@ -49,6 +49,7 @@ void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_igmp_groups, struct ovsdb_idl_index *sbrec_ip_multicast_opts, struct ovsdb_idl_index *sbrec_fdb_by_dp_key_mac, + struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, const struct sbrec_dns_table *, const struct sbrec_controller_event_table *, const struct sbrec_service_monitor_table *, diff --git a/lib/automake.mk b/lib/automake.mk index b69e854b0..3ff098331 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -49,7 +49,9 @@ lib_libovn_la_SOURCES = \ lib/stopwatch-names.h \ lib/vif-plug-provider.h \ lib/vif-plug-provider.c \ - lib/vif-plug-providers/dummy/vif-plug-dummy.c + lib/vif-plug-providers/dummy/vif-plug-dummy.c \ + lib/fdb.c \ + lib/fdb.h nodist_lib_libovn_la_SOURCES = \ lib/ovn-dirs.c \ lib/ovn-nb-idl.c \ diff --git a/lib/fdb.c b/lib/fdb.c new file mode 100644 index 000000000..00e3ac902 --- /dev/null +++ b/lib/fdb.c @@ -0,0 +1,33 @@ +/* Copyright (c) 2024, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "lib/fdb.h" + +void +delete_fdb_entries(struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, + uint32_t dp_key, uint32_t port_key) +{ + struct sbrec_fdb *target = + sbrec_fdb_index_init_row(sbrec_fdb_by_dp_and_port); + sbrec_fdb_index_set_dp_key(target, dp_key); + sbrec_fdb_index_set_port_key(target, port_key); + + struct sbrec_fdb *fdb_e; + SBREC_FDB_FOR_EACH_EQUAL (fdb_e, target, sbrec_fdb_by_dp_and_port) { + sbrec_fdb_delete(fdb_e); + } + sbrec_fdb_index_destroy_row(target); +} diff --git a/lib/fdb.h b/lib/fdb.h new file mode 100644 index 000000000..7b64bc7f2 --- /dev/null +++ b/lib/fdb.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2024, Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OVN_FDB_H +#define OVN_FDB_H 1 + +#include "ovsdb-idl.h" +#include "ovn-sb-idl.h" + +void +delete_fdb_entries(struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port, + uint32_t dp_key, uint32_t port_key); + +#endif diff --git a/tests/ovn.at b/tests/ovn.at index b31afbfb3..a0df87196 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -31706,6 +31706,63 @@ OVN_CLEANUP([hv1], [hv2], [hv3]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([OVN FDB cleanup when vif goes down]) +ovn_start + +net_add n1 + +AT_CHECK([ovn-nbctl ls-add ls0]) + +AT_CHECK([ovn-nbctl lsp-add ls0 ln_port]) +AT_CHECK([ovn-nbctl lsp-set-addresses ln_port unknown]) +AT_CHECK([ovn-nbctl lsp-set-type ln_port localnet]) +AT_CHECK([ovn-nbctl lsp-set-options ln_port network_name=physnet1]) +AT_CHECK([ovn-nbctl set logical_switch_port ln_port options:localnet_learn_fdb=true]) + +AT_CHECK([ovn-nbctl lsp-add ls0 vif0]) +AT_CHECK([ovn-nbctl lsp-set-addresses vif0 "00:00:00:00:10:10 192.168.10.10" unknown]) + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.1 +ovs-vsctl -- add-port br-int vif0 -- \ + set interface vif0 external-ids:iface-id=vif0 \ + options:tx_pcap=hv1/vif0-tx.pcap \ + options:rxq_pcap=hv1/vif0-rx.pcap \ + ofport-request=1 +ovs-vsctl -- add-port br-phys ext0 -- \ + set interface ext0 \ + options:tx_pcap=hv1/ext0-tx.pcap \ + options:rxq_pcap=hv1/ext0-rx.pcap \ + ofport-request=2 +ovs-vsctl set open . external_ids:ovn-bridge-mappings=physnet1:br-phys + + +wait_for_ports_up +ls0_key=$(fetch_column datapath_binding tunnel_key external_ids:name=ls0) +vif0_key=$(fetch_column port_binding tunnel_key logical_port=vif0) + +ovn-sbctl create FDB mac="00\:00\:00\:00\:10\:10" dp_key=$ls0_key port_key=$vif0_key +ovn-sbctl create FDB mac="00\:00\:00\:00\:20\:20" dp_key=$ls0_key port_key=$vif0_key + +ovn-sbctl list fdb +# vif going down should purge all relevant FDB entries +ovs-vsctl del-port br-int vif0 +OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up vif0` = xdown]) +AT_CHECK([ovn-nbctl --wait=hv sync]) +ovn-sbctl list fdb +OVS_WAIT_UNTIL([test $(ovn-sbctl list fdb | grep -c "00:00:00:00:10:10") = 0]) +OVS_WAIT_UNTIL([test $(ovn-sbctl list fdb | grep -c "00:00:00:00:20:20") = 0]) + +# vif0 should not be a local datapath in hv1 as vif0 is down +# Hence ln_port should not be a related port. +OVN_CLEANUP([hv1 +ln_port]) +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([container port changed to normal port and then deleted]) ovn_start