From patchwork Fri Jul 5 18:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1957437 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" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HE1fV8C2; 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 4WG2qH3GpYz1xr0 for ; Sat, 6 Jul 2024 04:58:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 987014151F; Fri, 5 Jul 2024 18:58:49 +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 HGtKNyWsen3l; Fri, 5 Jul 2024 18:58:48 +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 0C62B414FF Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HE1fV8C2 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0C62B414FF; Fri, 5 Jul 2024 18:58:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7FC31C0A9A; Fri, 5 Jul 2024 18:58:47 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2585BC0A97 for ; Fri, 5 Jul 2024 18:58:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D9211848B3 for ; Fri, 5 Jul 2024 18:58:43 +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 tWJB-v_mtjsw for ; Fri, 5 Jul 2024 18:58:43 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=lorenzo.bianconi@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org D4DDA848A9 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D4DDA848A9 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HE1fV8C2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id D4DDA848A9 for ; Fri, 5 Jul 2024 18:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720205921; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FcCnbbG3EMDYlgZQjtJ8CSokixkRCTFhc+4F5iYVr6c=; b=HE1fV8C21oVSOUA0Zt8+crV3AJd3p5LzM3juNA22iFsgVK1NrsPGCwNRWGMMPyGYTaQJRd glTt9oDdWKN+pWgYTzlhi+/OG2aGbzWghzJWDrErzL+dkgJxEG6BNDUQYCq9ID4uC0husK hB7vMVwRafIzPMtTEn1hxGazqvKmwUY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-A8_BBBO_OqiC9yY8mlyZNA-1; Fri, 05 Jul 2024 14:58:40 -0400 X-MC-Unique: A8_BBBO_OqiC9yY8mlyZNA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4258675a6easo14550965e9.3 for ; Fri, 05 Jul 2024 11:58:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720205919; x=1720810719; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WNNAfZ0ZgoBqtIyxWRCulohMTTPsdqQie9I1UyQr/H4=; b=HUHrIMKfBYyk3OyXLZgvxu5e8GHTcVhY3EzCulNNJQxY6puUaVChG1DvwugSpTfwrC v9/9NaZAmPFYwvpSgRNCPVPkq63l5ROOA9Vqvs7vUGbG4WDYtwawL2sXd1+wIwSqc0zi WsPjbo4al+cTi8f9bHgeMbFe9eBh2+xWnUhGxsKmZdTx6VInC7Oz0XAXPXtxeInZ0Sl2 rJP458uZJcwGrNjCyX+5LmR1Ogxt6XD4jUjJz7j1jx1bU5wBgv1CY2hBa2XE8HVEFP1W AhMgs/HeRWCCxaDTtkbqUFlS6Amk6zUjSZLzVt6ksVOCB4dtnJEK8lTyMsoLeTv6z8DD BfKw== X-Gm-Message-State: AOJu0YzAObIn3KgoH424VcS1gGQlDLdSSmrf7s1QHFE1w3ehB68qbR8u Tj7MBtYbxrEytKoSXtqiCnBcu5Wsc62hNSM9YA5fJq/o3E9pvM9vIOrF6YBm1KYbE6WatlLgAu4 iF0R13A50YilsIR5QuMOuSbk/a0eWf4JI366kG//QdwqTcdggZ3GZgQoCB/4IjRT+NMoaHB3kLe HtS50T5CG/bKKI0f89Tg6Rt2V0yzF+JKeN1f8Ecm8cO10ZwVH1hQ== X-Received: by 2002:a5d:680d:0:b0:35f:24f5:e597 with SMTP id ffacd0b85a97d-3679dd6f62emr3945053f8f.65.1720205919335; Fri, 05 Jul 2024 11:58:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHc1UZETcf+C8h6p4DxBsas+6RJYhPNCtj5Gnd+wqVmwLcrupxpubZ9G9y2/v7Yro30EvlmOw== X-Received: by 2002:a5d:680d:0:b0:35f:24f5:e597 with SMTP id ffacd0b85a97d-3679dd6f62emr3945040f8f.65.1720205919014; Fri, 05 Jul 2024 11:58:39 -0700 (PDT) Received: from localhost (net-188-216-101-142.cust.vodafonedsl.it. [188.216.101.142]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367990b305bsm5502274f8f.115.2024.07.05.11.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 11:58:38 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Fri, 5 Jul 2024 20:58:19 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v5 ovn 3/3] ofctrl: Introduce ecmp_nexthop_monitor. 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: dceara@redhat.com Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Introduce ecmp_nexthop_monitor in ovn-controller in order to track and flush ecmp-symmetric reply ct entires when requested by the CMS (e.g removing the related static routes). Signed-off-by: Lorenzo Bianconi --- controller/ofctrl.c | 54 +++++++++++++++++++++++++++++++++++++ controller/ofctrl.h | 2 ++ controller/ovn-controller.c | 2 ++ tests/system-ovn.at | 8 ++++++ 4 files changed, 66 insertions(+) diff --git a/controller/ofctrl.c b/controller/ofctrl.c index 9d181a782..2c891c049 100644 --- a/controller/ofctrl.c +++ b/controller/ofctrl.c @@ -388,9 +388,17 @@ struct meter_band_entry { static struct shash meter_bands; +#define ECMP_NEXTHOP_IDS_LEN 65535 +static unsigned long *ecmp_nexthop_ids; + static void ofctrl_meter_bands_destroy(void); static void ofctrl_meter_bands_clear(void); +static void ecmp_nexthop_monitor_run( + const struct sbrec_ecmp_nexthop_table *enh_table, + struct ovs_list *msgs); + + /* MFF_* field ID for our Geneve option. In S_TLV_TABLE_MOD_SENT, this is * the option we requested (we don't know whether we obtained it yet). In * S_CLEAR_FLOWS or S_UPDATE_FLOWS, this is really the option we have. */ @@ -429,6 +437,7 @@ ofctrl_init(struct ovn_extend_table *group_table, groups = group_table; meters = meter_table; shash_init(&meter_bands); + ecmp_nexthop_ids = bitmap_allocate(ECMP_NEXTHOP_IDS_LEN); } /* S_NEW, for a new connection. @@ -876,6 +885,7 @@ ofctrl_destroy(void) expr_symtab_destroy(&symtab); shash_destroy(&symtab); ofctrl_meter_bands_destroy(); + bitmap_free(ecmp_nexthop_ids); } uint64_t @@ -2305,6 +2315,47 @@ add_meter(struct ovn_extend_table_info *m_desired, ofctrl_meter_bands_alloc(sb_meter, m_desired, msgs); } +static void +ecmp_nexthop_monitor_flush_ct_entry(uint64_t id, struct ovs_list *msgs) +{ + ovs_u128 mask = { + /* ct_labels.label BITS[96-127] */ + .u64.hi = 0xffffffff00000000, + }; + ovs_u128 nexthop = { + .u64.hi = id << 32, + }; + struct ofp_ct_match match = { + .labels = nexthop, + .labels_mask = mask, + }; + struct ofpbuf *msg = ofp_ct_match_encode(&match, NULL, + rconn_get_version(swconn)); + ovs_list_push_back(msgs, &msg->list_node); +} + +static void +ecmp_nexthop_monitor_run(const struct sbrec_ecmp_nexthop_table *enh_table, + struct ovs_list *msgs) +{ + unsigned long *ids = bitmap_allocate(ECMP_NEXTHOP_IDS_LEN); + + const struct sbrec_ecmp_nexthop *sbrec_ecmp_nexthop; + SBREC_ECMP_NEXTHOP_TABLE_FOR_EACH (sbrec_ecmp_nexthop, enh_table) { + bitmap_set1(ids, sbrec_ecmp_nexthop->id); + } + + int id; + BITMAP_FOR_EACH_1 (id, ECMP_NEXTHOP_IDS_LEN, ecmp_nexthop_ids) { + if (!bitmap_is_set(ids, id)) { + ecmp_nexthop_monitor_flush_ct_entry(id, msgs); + } + } + + bitmap_free(ecmp_nexthop_ids); + ecmp_nexthop_ids = ids; +} + static void installed_flow_add(struct ovn_flow *d, struct ofputil_bundle_ctrl_msg *bc, @@ -2663,6 +2714,7 @@ ofctrl_put(struct ovn_desired_flow_table *lflow_table, struct shash *pending_ct_zones, struct hmap *pending_lb_tuples, struct ovsdb_idl_index *sbrec_meter_by_name, + const struct sbrec_ecmp_nexthop_table *enh_table, uint64_t req_cfg, bool lflows_changed, bool pflows_changed) @@ -2703,6 +2755,8 @@ ofctrl_put(struct ovn_desired_flow_table *lflow_table, /* OpenFlow messages to send to the switch to bring it up-to-date. */ struct ovs_list msgs = OVS_LIST_INITIALIZER(&msgs); + ecmp_nexthop_monitor_run(enh_table, &msgs); + /* Iterate through ct zones that need to be flushed. */ struct shash_node *iter; SHASH_FOR_EACH(iter, pending_ct_zones) { diff --git a/controller/ofctrl.h b/controller/ofctrl.h index 129e3b6ad..33953a8a4 100644 --- a/controller/ofctrl.h +++ b/controller/ofctrl.h @@ -31,6 +31,7 @@ struct ofpbuf; struct ovsrec_bridge; struct ovsrec_open_vswitch_table; struct sbrec_meter_table; +struct sbrec_ecmp_nexthop_table; struct shash; struct ovn_desired_flow_table { @@ -59,6 +60,7 @@ void ofctrl_put(struct ovn_desired_flow_table *lflow_table, struct shash *pending_ct_zones, struct hmap *pending_lb_tuples, struct ovsdb_idl_index *sbrec_meter_by_name, + const struct sbrec_ecmp_nexthop_table *enh_table, uint64_t nb_cfg, bool lflow_changed, bool pflow_changed); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index d4523a25a..e707f03c7 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -6076,6 +6076,8 @@ main(int argc, char *argv[]) &ct_zones_data->pending, &lb_data->removed_tuples, sbrec_meter_by_name, + sbrec_ecmp_nexthop_table_get( + ovnsb_idl_loop.idl), ofctrl_seqno_get_req_cfg(), engine_node_changed(&en_lflow_output), engine_node_changed(&en_pflow_output)); diff --git a/tests/system-ovn.at b/tests/system-ovn.at index 2c4c3f5fb..9effa77b0 100644 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -6229,6 +6229,10 @@ OVS_WAIT_UNTIL([ test $(ovs-ofctl dump-flows br-int | grep -c 'table=OFTABLE_ECMP_NH, n_packets') -eq 0 ]) +# Flush connection tracking entries +ovn-nbctl --wait=hv lr-route-del R1 +AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.1)]) + ovs-ofctl dump-flows br-int OVS_APP_EXIT_AND_WAIT([ovn-controller]) @@ -6437,6 +6441,10 @@ OVS_WAIT_UNTIL([ test $(ovs-ofctl dump-flows br-int | grep -c 'table=OFTABLE_ECMP_NH, n_packets') -eq 0 ]) +# Flush connection tracking entries +check ovn-nbctl --wait=hv lr-route-del R1 +AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd01::2)]) + ovs-ofctl dump-flows br-int OVS_APP_EXIT_AND_WAIT([ovn-controller])