From patchwork Thu May 19 20:17:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1633512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L41PN5bSvz9sGG for ; Fri, 20 May 2022 06:17:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EDF4361330; Thu, 19 May 2022 20:17:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NruxbMmlHHM3; Thu, 19 May 2022 20:17:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 3AFB861328; Thu, 19 May 2022 20:17:41 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 110B3C0039; Thu, 19 May 2022 20:17:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id B1FCDC002D for ; Thu, 19 May 2022 20:17:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AF80461328 for ; Thu, 19 May 2022 20:17:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dtq3WvTCdifG for ; Thu, 19 May 2022 20:17:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by smtp3.osuosl.org (Postfix) with ESMTPS id ABB5D606C6 for ; Thu, 19 May 2022 20:17:38 +0000 (UTC) Received: (Authenticated sender: numans@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 2A5AA20009; Thu, 19 May 2022 20:17:35 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 19 May 2022 16:17:33 -0400 Message-Id: <20220519201733.2184302-1-numans@ovn.org> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn] tests: Fix failing test case - "Port security lflows" 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" From: Numan Siddique Also added a few comments in the port security related functions in controller/lflow.c Fixes: 94974a02bfd5("northd: Add generic port security logical flows.") Signed-off-by: Numan Siddique --- controller/lflow.c | 16 +++++++++++++++- tests/ovn-northd.at | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/controller/lflow.c b/controller/lflow.c index e968231492..7a3419305a 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -2731,7 +2731,13 @@ lflow_handle_flows_for_lport(const struct sbrec_port_binding *pb, return false; } - /* Program the port security flows. */ + /* Program the port security flows. + * Note: All the port security OF rules are added using the 'uuid' + * of the port binding. Right now port binding 'uuid' is used in + * the logical flow table (l_ctx_out->flow_table) only for port + * security flows. Later if new flows are added using the + * port binding'uuid', then this function should handle it properly. + */ ofctrl_remove_flows(l_ctx_out->flow_table, &pb->header_.uuid); if (pb->n_port_security && shash_find(l_ctx_in->binding_lports, @@ -3399,6 +3405,10 @@ build_out_port_sec_ip4_flows(const struct sbrec_port_binding *pb, struct ovn_desired_flow_table *flow_table) { if (!ps_addr->n_ipv4_addrs && !ps_addr->n_ipv6_addrs) { + /* No IPv4 and no IPv6 addresses in the port security. + * Both IPv4 and IPv6 traffic should be delivered to the + * lport. build_out_port_sec_no_ip_flows() takes care of + * adding the required flow(s) to allow. */ return; } @@ -3493,6 +3503,10 @@ build_out_port_sec_ip6_flows(const struct sbrec_port_binding *pb, struct ovn_desired_flow_table *flow_table) { if (!ps_addr->n_ipv4_addrs && !ps_addr->n_ipv6_addrs) { + /* No IPv4 and no IPv6 addresses in the port security. + * Both IPv4 and IPv6 traffic should be delivered to the + * lport. build_out_port_sec_no_ip_flows() takes care of + * adding the required flow(s) to allow. */ return; } diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 0912e3bec4..5bd0935e72 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -7404,8 +7404,8 @@ AT_CHECK([cat sw0flows | grep -e port_sec | sort | sed 's/table=./table=?/' ], [ table=? (ls_in_check_port_sec), priority=100 , match=(eth.src[[40]]), action=(drop;) table=? (ls_in_check_port_sec), priority=100 , match=(vlan.present), action=(drop;) table=? (ls_in_check_port_sec), priority=50 , match=(1), action=(reg0[[15]] = check_in_port_sec(); next;) - table=? (ls_in_check_port_sec), priority=50 , match=(inport == "sw0p1"), action=(reg0[[14]] = 1; next(pipeline=ingress, table=16);) table=? (ls_in_check_port_sec), priority=70 , match=(inport == "localnetport"), action=(set_queue(10); reg0[[15]] = check_in_port_sec(); next;) + table=? (ls_in_check_port_sec), priority=70 , match=(inport == "sw0p1"), action=(reg0[[14]] = 1; next(pipeline=ingress, table=16);) table=? (ls_in_check_port_sec), priority=70 , match=(inport == "sw0p2"), action=(set_queue(10); reg0[[15]] = check_in_port_sec(); next;) table=? (ls_in_apply_port_sec), priority=0 , match=(1), action=(next;) table=? (ls_in_apply_port_sec), priority=50 , match=(reg0[[15]] == 1), action=(drop;)