From patchwork Tue Mar 12 15:59:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1911164 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=PkjUV09W; 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 4TvJJb5VqHz1yWy for ; Wed, 13 Mar 2024 03:00:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CA3D9414EF; Tue, 12 Mar 2024 16:00:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mTsfSIakQ4Jw; Tue, 12 Mar 2024 16:00:25 +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 3A8E9414BE 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=PkjUV09W Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3A8E9414BE; Tue, 12 Mar 2024 16:00:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F129EC0DD5; Tue, 12 Mar 2024 16:00:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6913AC0037 for ; Tue, 12 Mar 2024 16:00:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 578DA4075F for ; Tue, 12 Mar 2024 16:00:19 +0000 (UTC) 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 js63ojJuhQ2N for ; Tue, 12 Mar 2024 16:00:17 +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 smtp4.osuosl.org 104584060E Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 104584060E Authentication-Results: smtp4.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=PkjUV09W Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 104584060E for ; Tue, 12 Mar 2024 16:00:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710259215; 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=wRFhTY07xVXeAe4/Tu3MXdEZo28IU4hE7CVkofoEO8A=; b=PkjUV09WnsdBWOCr1XtHs0Fvz1OmSm5UcWTUmBjCxFVpyoQnz9LZcTi4N4lvWwupZSVl1Y YFbOdeyr51r5q5EhYw4ISDo8NNz1879UYy/UV9oTZE1Z1J+Py8xcvQe1vLIaPeJsuA+9AV 8NsE/1iV6WqldtpsB37S8T+8MTrKAXI= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-WVEjYF3BObq--puvz5-Utg-1; Tue, 12 Mar 2024 12:00:12 -0400 X-MC-Unique: WVEjYF3BObq--puvz5-Utg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-33e6d40893fso2690084f8f.3 for ; Tue, 12 Mar 2024 09:00:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710259211; x=1710864011; 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=YbZUyGkr7hKo1jRXfwOCFjcuZX/RgU7aGEHuixjZbuY=; b=nf5OPaF9q2WQO6+nAW3FCxwP/w1oDSQ7MkVgHEzDhGfN+HKgqodwQx6ytmjArmOalJ BInYAe3hwdr74WS67hE8ZMlx9VRchV68cUHnzX6I60fV0WoBtWecmJLAn1JXPWPAEsA2 +t1AL6QMuXx+/qcOiflXBHT8nbJEmUYWRAHdcyAMyOKCKlsjMw2+lCSkg6JxYPTFqRvG GD7imC3FCzW8tHnFZv/dzGQcnxeX7j9VLBot9bnIytjCj1L8Z4FbVXT/lZBsVBqniNJR q37iD3JF64WwOCqEXhtgSAbMqhY/H4MN0jaLjcPb5jrDGxpf1waCK/IgwzNKtAlFTYC0 haKQ== X-Gm-Message-State: AOJu0Yz/QyiaQRAVPhaJo9p8PUuCfKfzK+xJ9OC35tMKlrl2Db98S5dH mClNkMGJDIJSbtWFUJOXbETZHftXw6ZTVwMaeB2uFikOot3+hwYh+kvQHJSTJxYeIG9EPsB7/3F d7so+1gmri1vH5oH6Q3rZ16B2ppEeFZ8TJMIi391395t6H3QvWl8364ZEDUouAupYU0MXkeF6E0 EyAs4mJ86M5ty4AYCm460/lNqLNelkXw0dBeDWotow0vm8 X-Received: by 2002:a5d:5f89:0:b0:33d:29d5:d970 with SMTP id dr9-20020a5d5f89000000b0033d29d5d970mr555620wrb.45.1710259211067; Tue, 12 Mar 2024 09:00:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYk5CqBO0uLk6NpPwsCXx9/O6ifLQSrR9x4Eh8czVf07AjRzPIfzSZSHO+pB1Ze4SmU5aLUg== X-Received: by 2002:a5d:5f89:0:b0:33d:29d5:d970 with SMTP id dr9-20020a5d5f89000000b0033d29d5d970mr555580wrb.45.1710259210286; Tue, 12 Mar 2024 09:00:10 -0700 (PDT) Received: from localhost (net-93-71-3-198.cust.vodafonedsl.it. [93.71.3.198]) by smtp.gmail.com with ESMTPSA id cm22-20020a5d5f56000000b0033e99b7cfa8sm4673478wrb.13.2024.03.12.09.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 09:00:09 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Tue, 12 Mar 2024 16:59:59 +0100 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v2 3/3] ofctrl: Introduce ecmp_nexthop_monitor. 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" 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 | 101 ++++++++++++++ controller/ofctrl.h | 2 + controller/ovn-controller.c | 2 + tests/system-ovn-kmod.at | 266 ++++++++++++++++++++++++++++++++++++ tests/system-ovn.at | 4 + 5 files changed, 375 insertions(+) diff --git a/controller/ofctrl.c b/controller/ofctrl.c index f14cd79a8..a10b0f567 100644 --- a/controller/ofctrl.c +++ b/controller/ofctrl.c @@ -388,9 +388,24 @@ struct meter_band_entry { static struct shash meter_bands; +static struct hmap ecmp_nexthop_map; +struct ecmp_nexthop_entry { + struct hmap_node node; + bool erase; + + char *nexthop; + int id; +}; + static void ofctrl_meter_bands_destroy(void); static void ofctrl_meter_bands_clear(void); +static void ecmp_nexthop_monitor_destroy(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 +444,7 @@ ofctrl_init(struct ovn_extend_table *group_table, groups = group_table; meters = meter_table; shash_init(&meter_bands); + hmap_init(&ecmp_nexthop_map); } /* S_NEW, for a new connection. @@ -883,6 +899,7 @@ ofctrl_destroy(void) expr_symtab_destroy(&symtab); shash_destroy(&symtab); ofctrl_meter_bands_destroy(); + ecmp_nexthop_monitor_destroy(); } uint64_t @@ -2306,6 +2323,87 @@ add_meter(struct ovn_extend_table_info *m_desired, ofctrl_meter_bands_alloc(sb_meter, m_desired, msgs); } +static void +ecmp_nexthop_monitor_free_entry(struct ecmp_nexthop_entry *e, + struct ovs_list *msgs) +{ + if (msgs) { + ovs_u128 mask = { + /* ct_labels.label BITS[96-127] */ + .u64.hi = 0xffffffff00000000, + }; + uint64_t id = e->id; + 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); + } + free(e->nexthop); + free(e); +} + +static void +ecmp_nexthop_monitor_destroy(void) +{ + struct ecmp_nexthop_entry *e; + HMAP_FOR_EACH_POP (e, node, &ecmp_nexthop_map) { + ecmp_nexthop_monitor_free_entry(e, NULL); + } + hmap_destroy(&ecmp_nexthop_map); +} + +static struct ecmp_nexthop_entry * +ecmp_nexthop_monitor_lookup(char *nexthop) +{ + uint32_t hash = hash_string(nexthop, 0); + struct ecmp_nexthop_entry *e; + + HMAP_FOR_EACH_WITH_HASH (e, node, hash, &ecmp_nexthop_map) { + if (!strcmp(e->nexthop, nexthop)) { + return e; + } + } + return NULL; +} + +static void +ecmp_nexthop_monitor_run(const struct sbrec_ecmp_nexthop_table *enh_table, + struct ovs_list *msgs) +{ + struct ecmp_nexthop_entry *e; + HMAP_FOR_EACH (e, node, &ecmp_nexthop_map) { + e->erase = true; + } + + const struct sbrec_ecmp_nexthop *sbrec_ecmp_nexthop; + SBREC_ECMP_NEXTHOP_TABLE_FOR_EACH (sbrec_ecmp_nexthop, enh_table) { + e = ecmp_nexthop_monitor_lookup(sbrec_ecmp_nexthop->nexthop); + if (!e) { + e = xzalloc(sizeof *e); + e->nexthop = xstrdup(sbrec_ecmp_nexthop->nexthop); + e->id = sbrec_ecmp_nexthop->id; + uint32_t hash = hash_string(e->nexthop, 0); + hmap_insert(&ecmp_nexthop_map, &e->node, hash); + } else { + e->erase = false; + } + } + + HMAP_FOR_EACH_SAFE (e, node, &ecmp_nexthop_map) { + if (e->erase) { + hmap_remove(&ecmp_nexthop_map, &e->node); + ecmp_nexthop_monitor_free_entry(e, msgs); + } + } + +} + static void installed_flow_add(struct ovn_flow *d, struct ofputil_bundle_ctrl_msg *bc, @@ -2664,6 +2762,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) @@ -2704,6 +2803,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 502c73da6..e08b354f4 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 1c9960c70..28cac2683 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -5945,6 +5945,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-kmod.at b/tests/system-ovn-kmod.at index 14fe4ecec..88c196874 100644 --- a/tests/system-ovn-kmod.at +++ b/tests/system-ovn-kmod.at @@ -1054,3 +1054,269 @@ OVS_TRAFFIC_VSWITCHD_STOP([" "]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ECMP symmetric reply - kmod]) +AT_KEYWORDS([ecmp]) + +CHECK_CONNTRACK() +ovn_start + +OVS_TRAFFIC_VSWITCHD_START() +ADD_BR([br-int]) + +# Set external-ids in br-int needed for ovn-controller +ovs-vsctl \ + -- set Open_vSwitch . external-ids:system-id=hv1 \ + -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \ + -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \ + -- set bridge br-int fail-mode=secure other-config:disable-in-band=true + +# Start ovn-controller +start_daemon ovn-controller + +# Logical network: +# Alice is connected to gateway router R1. R1 is connected to two "external" +# routers, R2 and R3 via an "ext" switch. +# Bob is connected to both R2 and R3. R1 contains two ECMP routes, one through R2 +# and one through R3, to Bob. +# +# alice -- R1 -- ext ---- R2 +# | \ +# | bob +# | / +# + ----- R3 +# +# For this test, Bob sends request traffic through R2 to Alice. We want to ensure that +# all response traffic from Alice is routed through R2 as well. + +ovn-nbctl create Logical_Router name=R1 options:chassis=hv1 +ovn-nbctl create Logical_Router name=R2 +ovn-nbctl create Logical_Router name=R3 + +ovn-nbctl ls-add alice +ovn-nbctl ls-add bob +ovn-nbctl ls-add ext + +# connect alice to R1 +ovn-nbctl lrp-add R1 alice 00:00:01:01:02:03 10.0.0.1/24 fd01::1/64 +ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ + type=router options:router-port=alice addresses='"00:00:01:01:02:03"' + +# connect bob to R2 +ovn-nbctl lrp-add R2 R2_bob 00:00:02:01:02:03 172.16.0.2/16 fd07::2/64 +ovn-nbctl lsp-add bob rp2-bob -- set Logical_Switch_Port rp2-bob \ + type=router options:router-port=R2_bob addresses='"00:00:02:01:02:03"' + +# connect bob to R3 +ovn-nbctl lrp-add R3 R3_bob 00:00:02:01:02:04 172.16.0.3/16 fd07::3/64 +ovn-nbctl lsp-add bob rp3-bob -- set Logical_Switch_Port rp3-bob \ + type=router options:router-port=R3_bob addresses='"00:00:02:01:02:04"' + +# Connect R1 to ext +ovn-nbctl lrp-add R1 R1_ext 00:00:04:01:02:03 20.0.0.1/24 fd02::1/64 +ovn-nbctl lsp-add ext r1-ext -- set Logical_Switch_Port r1-ext \ + type=router options:router-port=R1_ext addresses='"00:00:04:01:02:03"' + +# Connect R2 to ext +ovn-nbctl lrp-add R2 R2_ext 00:00:04:01:02:04 20.0.0.2/24 fd02::2/64 +ovn-nbctl lsp-add ext r2-ext -- set Logical_Switch_Port r2-ext \ + type=router options:router-port=R2_ext addresses='"00:00:04:01:02:04"' + +# Connect R3 to ext +ovn-nbctl lrp-add R3 R3_ext 00:00:04:01:02:05 20.0.0.3/24 fd02::3/64 +ovn-nbctl lsp-add ext r3-ext -- set Logical_Switch_Port r3-ext \ + type=router options:router-port=R3_ext addresses='"00:00:04:01:02:05"' + +# Install ECMP routes for alice. +ovn-nbctl --ecmp-symmetric-reply --policy="src-ip" lr-route-add R1 10.0.0.0/24 20.0.0.2 +ovn-nbctl --ecmp-symmetric-reply --policy="src-ip" lr-route-add R1 10.0.0.0/24 20.0.0.3 + +# Static Routes +ovn-nbctl lr-route-add R2 10.0.0.0/24 20.0.0.1 +ovn-nbctl lr-route-add R3 10.0.0.0/24 20.0.0.1 + +# Logical port 'alice1' in switch 'alice'. +ADD_NAMESPACES(alice1) +# Only send 1 router solicitation as any additional ones can cause datapath +# flows to get evicted, causing unexpected failures below. +NS_CHECK_EXEC([alice1], [sysctl -w net.ipv6.conf.default.router_solicitations=1], [0], [dnl +net.ipv6.conf.default.router_solicitations = 1 +]) +ADD_VETH(alice1, alice1, br-int, "10.0.0.2/24", "f0:00:00:01:02:04", \ + "10.0.0.1") +NS_CHECK_EXEC([alice1], [ip -6 addr add fd01::2/64 dev alice1 nodad]) +NS_CHECK_EXEC([alice1], [ip -6 route add default via fd01::1]) +NS_CHECK_EXEC([alice1], [ip -6 neigh add fd01::1 lladdr 00:00:01:01:02:03 dev alice1], [0]) +ovn-nbctl lsp-add alice alice1 \ +-- lsp-set-addresses alice1 "f0:00:00:01:02:04 10.0.0.2 fd01::2" + +# Logical port 'bob1' in switch 'bob'. +ADD_NAMESPACES(bob1) +# Only send 1 router solicitation as any additional ones can cause datapath +# flows to get evicted, causing unexpected failures below. +NS_CHECK_EXEC([bob1], [sysctl -w net.ipv6.conf.default.router_solicitations=1], [0], [dnl +net.ipv6.conf.default.router_solicitations = 1 +]) +ADD_VETH(bob1, bob1, br-int, "172.16.0.1/16", "f0:00:00:01:02:06", \ + "172.16.0.2") +NS_CHECK_EXEC([bob1], [ip -6 addr add fd07::1/64 dev bob1 nodad]) +NS_CHECK_EXEC([bob1], [ip -6 route add default via fd07::2]) +NS_CHECK_EXEC([bob1], [ip -6 neigh add fd07::2 lladdr 00:00:02:01:02:03 dev bob1]) +NS_CHECK_EXEC([bob1], [ip -6 neigh add fd07::3 lladdr 00:00:01:01:02:04 dev bob1]) + +# Add neighbour MAC addresses to avoid sending IPv6 NS messages which could +# cause datapath flows to be evicted +ovn-nbctl lsp-add bob bob1 \ +-- lsp-set-addresses bob1 "f0:00:00:01:02:06 172.16.0.1 fd07::1" + +# Ensure ovn-controller is caught up +ovn-nbctl --wait=hv sync + +on_exit 'ovs-ofctl dump-flows br-int' + +NETNS_DAEMONIZE([alice1], [nc -l -k 80], [alice1.pid]) +NS_CHECK_EXEC([bob1], [nc -z 10.0.0.2 80], [0]) +NS_CHECK_EXEC([bob1], [ping -q -c 3 -i 0.3 -w 2 10.0.0.2 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +# Ensure conntrack entry is present. We should not try to predict +# the tunnel key for the output port, so we strip it from the labels +# and just ensure that the known ethernet address is present. +AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.1) | \ +sed -e 's/zone=[[0-9]]*/zone=/' | +sed -e 's/mark=[[0-9]]*/mark=/' | +sed -e 's/labels=0x[[0-9]]/labels=0x?/'], [0], [dnl +icmp,orig=(src=172.16.0.1,dst=10.0.0.2,id=,type=8,code=0),reply=(src=10.0.0.2,dst=172.16.0.1,id=,type=0,code=0),zone=,mark=,labels=0x?000000000401020400000000 +tcp,orig=(src=172.16.0.1,dst=10.0.0.2,sport=,dport=),reply=(src=10.0.0.2,dst=172.16.0.1,sport=,dport=),zone=,mark=,labels=0x?000000000401020400000000,protoinfo=(state=) +]) + +# Ensure datapaths show conntrack states as expected +# Like with conntrack entries, we shouldn't try to predict +# port binding tunnel keys. So omit them from expected labels. +AT_CHECK([ovs-appctl dpctl/dump-flows | sed -e 's/label=0x[[0-9]]/label=0x?/' | \ +grep 'ct_state(+new-est-rpl+trk).*ct(.*label=0x?000000000401020400000000/.*)' -c], [0], [dnl +2 +]) +AT_CHECK([[ovs-appctl dpctl/dump-flows | sed -e 's/ct_label(0x[0-9]/ct_label(0x?/' | \ +grep 'ct_state(-new+est+rpl+trk).*ct_label(0x?000000000401020400000000)' -c]], [0], [dnl +2 +]) + +# Flush conntrack entries for easier output parsing of next test. +AT_CHECK([ovs-appctl dpctl/flush-conntrack]) +# Change bob1 L2 address anche check the reply is properly updated. +ovn-nbctl set Logical_Router_Port R2_ext mac='"00:00:10:01:02:04"' +ovn-nbctl set Logical_Switch_Port r2-ext \ + type=router options:router-port=R2_ext addresses='"00:00:10:01:02:04"' + +# Wait for ovn-controller before sending traffic +ovn-nbctl --wait=hv sync + +NS_CHECK_EXEC([bob1], [nc -z 10.0.0.2 80], [0]) +NS_CHECK_EXEC([bob1], [ping -q -c 3 -i 0.3 -w 2 10.0.0.2 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) +AT_CHECK([ovs-appctl dpctl/dump-flows | sed -e 's/label=0x[[0-9]]/label=0x?/' | \ +grep 'ct_state(+new-est-rpl+trk).*ct(.*label=0x?000000001001020400000000/.*)' -c], [0], [dnl +2 +]) +AT_CHECK([[ovs-appctl dpctl/dump-flows | sed -e 's/ct_label(0x[0-9]/ct_label(0x?/' | \ +grep 'ct_state(-new+est+rpl+trk).*ct_label(0x?000000001001020400000000)' -c]], [0], [dnl +2 +]) + +AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep 1001020400000000 | FORMAT_CT(172.16.0.1) | \ +sed -e 's/zone=[[0-9]]*/zone=/' | +sed -e 's/mark=[[0-9]]*/mark=/' | +sed -e 's/labels=0x[[0-9]]/labels=0x?/' | sort], [0], [dnl +icmp,orig=(src=172.16.0.1,dst=10.0.0.2,id=,type=8,code=0),reply=(src=10.0.0.2,dst=172.16.0.1,id=,type=0,code=0),zone=,mark=,labels=0x?000000001001020400000000 +tcp,orig=(src=172.16.0.1,dst=10.0.0.2,sport=,dport=),reply=(src=10.0.0.2,dst=172.16.0.1,sport=,dport=),zone=,mark=,labels=0x?000000001001020400000000,protoinfo=(state=) +]) +# Check entries in table 76 and 77 expires w/o traffic +OVS_WAIT_UNTIL([ +test $(ovs-ofctl dump-flows br-int | grep -c 'table=OFTABLE_ECMP_NH_MAC, n_packets') -eq 0 +]) +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)]) + +# Install ECMP routes for alice. +ovn-nbctl --ecmp-symmetric-reply --policy="src-ip" lr-route-add R1 fd01::/126 fd02::2 +ovn-nbctl --ecmp-symmetric-reply --policy="src-ip" lr-route-add R1 fd01::/126 fd02::3 + +# Static Routes +ovn-nbctl lr-route-add R2 fd01::/64 fd02::1 +ovn-nbctl lr-route-add R3 fd01::/64 fd02::1 + +NETNS_DAEMONIZE([alice1], [nc -6 -l -k 8080], [alice2.pid]) +NS_CHECK_EXEC([bob1], [nc -6 -z fd01::2 8080], [0]) +NS_CHECK_EXEC([bob1], [ping -q -c 3 -i 0.3 -w 2 fd01::2 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +# Ensure conntrack entry is present. We should not try to predict +# the tunnel key for the output port, so we strip it from the labels +# and just ensure that the known ethernet address is present. +AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fd01::2) | \ +sed -e 's/zone=[[0-9]]*/zone=/' | +sed -e 's/mark=[[0-9]]*/mark=/' | +sed -e 's/labels=0x[[0-9]]/labels=0x?/' | sort], [0], [dnl +icmpv6,orig=(src=fd07::1,dst=fd01::2,id=,type=128,code=0),reply=(src=fd01::2,dst=fd07::1,id=,type=129,code=0),zone=,mark=,labels=0x?000000001001020400000000 +tcp,orig=(src=fd07::1,dst=fd01::2,sport=,dport=),reply=(src=fd01::2,dst=fd07::1,sport=,dport=),zone=,mark=,labels=0x?000000001001020400000000,protoinfo=(state=) +]) + +# Flush conntrack entries for easier output parsing of next test. +AT_CHECK([ovs-appctl dpctl/flush-conntrack]) + +# Change bob1 L2 address anche check the reply is properly updated. +ovn-nbctl set Logical_Router_Port R2_ext mac='"00:00:10:01:02:04"' +ovn-nbctl --wait=hv set Logical_Switch_Port r2-ext \ + type=router options:router-port=R2_ext addresses='"00:00:10:01:02:04"' + +NS_CHECK_EXEC([bob1], [nc -6 -z fd01::2 8080], [0]) +NS_CHECK_EXEC([bob1], [ping -q -c 3 -i 0.3 -w 2 fd01::2 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep 1001020400000000 | FORMAT_CT(fd01::2) | \ +sed -e 's/zone=[[0-9]]*/zone=/' | +sed -e 's/mark=[[0-9]]*/mark=/' | +sed -e 's/labels=0x[[0-9]]/labels=0x?/'], [0], [dnl +icmpv6,orig=(src=fd07::1,dst=fd01::2,id=,type=128,code=0),reply=(src=fd01::2,dst=fd07::1,id=,type=129,code=0),zone=,mark=,labels=0x?000000001001020400000000 +tcp,orig=(src=fd07::1,dst=fd01::2,sport=,dport=),reply=(src=fd01::2,dst=fd07::1,sport=,dport=),zone=,mark=,labels=0x?000000001001020400000000,protoinfo=(state=) +]) + +# Flush connection tracking entries +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]) + +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as ovn-nb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as northd +OVS_APP_EXIT_AND_WAIT([ovn-northd]) + +as +OVS_TRAFFIC_VSWITCHD_STOP(["/failed to query port patch-.*/d +/connection dropped.*/d"]) + +AT_CLEANUP +]) diff --git a/tests/system-ovn.at b/tests/system-ovn.at index 7ae54113a..a0f375141 100644 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -6178,6 +6178,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])