From patchwork Tue Feb 15 03:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=LnWh1BYR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS440v86z9sFv for ; Tue, 15 Feb 2022 14:58:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9F45C82B1E; Tue, 15 Feb 2022 03:58:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00vAFWJJejzx; Tue, 15 Feb 2022 03:58:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4B43782EB5; Tue, 15 Feb 2022 03:58:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E75A0C0078; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 138CEC007B for ; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A85FF405EF for ; Tue, 15 Feb 2022 03:57:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 wFsNOkjfjQ-n for ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 362DC408E9 for ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897475; 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=UhPTflWOznNFTT5iLU8NjWX/s8XRLBJydHrw98NudyU=; b=LnWh1BYR3EtXOiqxCPCNbPCO7zsRu2U1YKSB3LYu37XpOj8hEqsf/mTTmzzOT883BlGGyP li+MeOBAoiYuByInT3cEWL/4jPsC1PQGjaZDU4RHnhG2l/xPN3L6kiLpuSuE9JanmJixq/ uMV4pZHN3VCcoFSTzZGO9uzogjIEORw= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-101-gqprk0rbPYqxMiWuyzWqZA-1; Mon, 14 Feb 2022 22:57:53 -0500 X-MC-Unique: gqprk0rbPYqxMiWuyzWqZA-1 Received: by mail-qv1-f72.google.com with SMTP id kd18-20020a056214401200b0042de5c14702so1836654qvb.12 for ; Mon, 14 Feb 2022 19:57:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UhPTflWOznNFTT5iLU8NjWX/s8XRLBJydHrw98NudyU=; b=WTThwGqEGJT1GdRvaJhpJsX30uIti6FP3YvqgxAs8FG2DdusNQayG5CtjfxhinzfQM lT6F2iOkMfAk0W715eIMjykRlqsDKk0ntiEe1SDP4PgHlTpghT0bBd0UO7bwcETrXgTD 1d3Qam7aw8mOHui/X8aPvVjYvhAwUJdHpwzomp62oL+jLnUpv3ps2HAW5qVNntxBgE3u 09A7mNl/c/aSCttghVC/0g5jnc9Zq8/zzgUCX3yfhUIc6JqGkFmVg3MpUk5FOaQALR+m WV2dgLViMOLrubcw/Bq6aFZmg6Fv0SKVkiCLuX6R3jZvpbVDUGlHAlXhRO8/wJbwK08Q OVZw== X-Gm-Message-State: AOAM53008ZTpSRVTcyUkg2J2KJX/ZIzR6FZob/nXENEB7YJ7SIVgPOXr 2mf7hSOSg4PexMK2T+l7BTs4bHm7Cd3MjEBHfp27NEHgg7Y1li2AEQ0yTAToJYPTXbRTmVArJQ+ YW7uBOfJGoz8MGPcTcHuWRAKfWG48vn955XuUZIoEmKsnmRDBYG+3iTjU8aYcEQNe X-Received: by 2002:a05:622a:607:: with SMTP id z7mr1447023qta.281.1644897473048; Mon, 14 Feb 2022 19:57:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmgHKKaEcVLB+x7sLDrwMG7n/m7tePZJeBrbuDbcuEYsIUZ/lGU1pltG1jpfJ2NSAghPII3A== X-Received: by 2002:a05:622a:607:: with SMTP id z7mr1447008qta.281.1644897472619; Mon, 14 Feb 2022 19:57:52 -0800 (PST) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id br30sm16753001qkb.67.2022.02.14.19.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:51 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:29 +0000 Message-Id: <20220215035737.1820679-8-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-1-ihrachys@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ihrachys@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 07/15] Introduce match_outport_dp_and_port_keys in physical.c 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" This helper prepares a 'match' struct to match against a datapath and a port key. All existing spots in the file that use such a 'match' struct were updated. It will also be reused later. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 65 +++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 7ad142293..e0afd83ab 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -277,6 +277,15 @@ put_remote_port_redirect_bridged(const struct } +static void +match_outport_dp_and_port_keys(struct match *match, + uint32_t dp_key, uint32_t port_key) +{ + match_init_catchall(match); + match_set_metadata(match, htonll(dp_key)); + match_set_reg(match, MFF_LOG_OUTPORT - MFF_REG0, port_key); +} + static void put_remote_port_redirect_overlay(const struct sbrec_port_binding *binding, @@ -670,7 +679,6 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index * a. Flow replaces ingress router port mac with a chassis mac. * b. Flow appends the vlan id localnet port is configured with. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); ovs_assert(rport_binding->n_mac == 1); @@ -684,8 +692,7 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index } /* Replace Router mac flow */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_dl_src(&match, router_port_mac); replace_mac = ofpact_put_SET_ETH_SRC(ofpacts_p); @@ -723,12 +730,10 @@ put_local_common_flows(uint32_t dp_key, * table 39. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (zone_ids) { if (zone_ids->ct) { @@ -786,10 +791,8 @@ put_local_common_flows(uint32_t dp_key, * */ bool nested_container = parent_pb ? true: false; - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (!nested_container) { match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_ALLOW_LOOPBACK, MLF_ALLOW_LOOPBACK); @@ -820,11 +823,8 @@ put_local_common_flows(uint32_t dp_key, * ports even if they don't have any child ports which is * unnecessary. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, - parent_pb->tunnel_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_NESTED_CONTAINER, MLF_NESTED_CONTAINER); @@ -920,10 +920,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_local_common_flows(dp_key, binding, NULL, &binding_zones, ofpacts_p, flow_table); - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); size_t clone_ofs = ofpacts_p->size; struct ofpact_nest *clone = ofpact_put_CLONE(ofpacts_p); @@ -966,10 +964,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * output port is changed from the "chassisredirect" port to the * underlying distributed port. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); const char *distributed_port = smap_get_def(&binding->options, "distributed-port", ""); @@ -1203,10 +1199,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * ======================= * * Deliver the packet to the local vif. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (tag) { /* For containers sitting behind a local vif, tag the packets * before delivering them. */ @@ -1240,10 +1234,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, */ if (!strcmp(binding->type, "localnet")) { /* do not forward traffic from localport to localnet port */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCALPORT, MLF_LOCALPORT); ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 160, @@ -1251,10 +1243,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, ofpacts_p, &binding->header_.uuid); /* Drop LOCAL_ONLY traffic leaking through localnet ports. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCAL_ONLY, MLF_LOCAL_ONLY); ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 160, @@ -1293,10 +1283,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, continue; } - match_init_catchall(&match); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, - port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCALPORT, MLF_LOCALPORT); match_set_dl_dst(&match, peer_mac); @@ -1318,12 +1305,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * to connected localnet port and resubmits to same table. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); put_load(localnet_port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, ofpacts_p); @@ -1346,12 +1331,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * flow matches an output port that includes a logical port on a remote * hypervisor, and tunnels the packet to that hypervisor. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (redirect_type && !strcasecmp(redirect_type, "bridged")) { put_remote_port_redirect_bridged(binding, local_datapaths, @@ -1433,11 +1416,9 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct sset remote_chassis = SSET_INITIALIZER(&remote_chassis); struct sset vtep_chassis = SSET_INITIALIZER(&vtep_chassis); - struct match match; - match_init_catchall(&match); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, mc->tunnel_key); + struct match match; + match_outport_dp_and_port_keys(&match, dp_key, mc->tunnel_key); /* Go through all of the ports in the multicast group: *