From patchwork Wed May 13 13:38:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1289304 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=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: 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=Nx4mJO4B; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49MbPg4tkSz9sSW for ; Wed, 13 May 2020 23:39:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9A4AD882F3; Wed, 13 May 2020 13:39:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d1W1WfYshN5P; Wed, 13 May 2020 13:39:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 0CB8988164; Wed, 13 May 2020 13:39:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DF091C088F; Wed, 13 May 2020 13:39:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 39073C016F for ; Wed, 13 May 2020 13:39:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 235FA871D7 for ; Wed, 13 May 2020 13:39:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rwDiexq9qhfU for ; Wed, 13 May 2020 13:39:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DA1B1871FB for ; Wed, 13 May 2020 13:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589377165; 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=YzH844NZDdgcgCAaZfDd/Y7yzoT5BFRqhwkdzHJOwZs=; b=Nx4mJO4BcSjzhUE6XfiDQg1CiXd3PrdHQk8JWFH70nvDH2+VmnHHI7BAfzPwZKOhXPnBQ9 0AT28cSiHv7GyS6niqB98Kc6HxCDvK8lUZME2YcaQd7zWtnwx5oYvvgVSC29rkrQAszvht ZAncNtIRDRhlW+MdcQQn56z7uJcjraY= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-oWfSE40ENRO1Vt-OpwIBCw-1; Wed, 13 May 2020 09:39:20 -0400 X-MC-Unique: oWfSE40ENRO1Vt-OpwIBCw-1 Received: by mail-qt1-f198.google.com with SMTP id e44so17959706qta.9 for ; Wed, 13 May 2020 06:39:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YzH844NZDdgcgCAaZfDd/Y7yzoT5BFRqhwkdzHJOwZs=; b=Gcj+kKgGtVIGqe+E7FbMbHeCiq6xEO22gghDlXP9N+IKwrh3pJAlo+QQqaHtqTgB+A Or8LmG8jf7uH7hl+vqxJx94Xa7fkeGGc6hnSonr4HGkip9xSJzC0A85pNpcjJ4iNiE5k CQWVNxdQhzGuZKIKWsnTfJjq5P5G7mXW5hby00rhyIglUulTtv515nDDTCLdnCWG/bgO c3hu4DMhA1D8KfBSIaIvUkQxFjajZlVUKXToxc71+eWpwIzzzQyTKYzrTL+C3kwhzkqQ omO7Dh9oIbY5rbddUhk/HxlA03BsQd7ABS9T6tsVaBH4te88KD+rysVCqLpOOugvMu2P vDJQ== X-Gm-Message-State: AGi0PubyCAZdEH193YtAPgmxH4GggbBn/rKb/R4CzjFMijFCFrh5jO4F F2IDjsJ9tTVacnvBnjyuBdMdVqMcVBrObz+cb4pe/bhpAoTgVC5paOw9GW+1c68ULgtnoLUB/j8 BTcyr+u7ra3D0 X-Received: by 2002:aed:249c:: with SMTP id t28mr27129427qtc.169.1589377158950; Wed, 13 May 2020 06:39:18 -0700 (PDT) X-Google-Smtp-Source: APiQypLbRHK7cvE6RFQVfFnPVC2rCA/BF9DzVB6UGubShPie+VnPnH0SgiS6mJ2aJ1gYXtDwZfhVjg== X-Received: by 2002:aed:249c:: with SMTP id t28mr27129408qtc.169.1589377158710; Wed, 13 May 2020 06:39:18 -0700 (PDT) Received: from localhost.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.googlemail.com with ESMTPSA id h12sm12048411qtb.19.2020.05.13.06.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 06:39:18 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Wed, 13 May 2020 09:38:49 -0400 Message-Id: <20200513133853.116959-3-ihrachys@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513133853.116959-1-ihrachys@redhat.com> References: <20200513133853.116959-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v7 2/6] Spin out flow generation into build_dhcpv6_options_flows 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" Also remove stage_hint conditional calculation for the moved code section because build_dhcpv6_action already returns false when dhcpv6_options are not set. Signed-off-by: Ihar Hrachyshka --- northd/ovn-northd.c | 96 +++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 14b183e09..339ed2dff 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6191,6 +6191,54 @@ build_dhcpv4_options_flows(struct ovn_port *op, ds_destroy(&match); } +static void +build_dhcpv6_options_flows(struct ovn_port *op, + struct lport_addresses *lsp_addrs, + const char *json_key, bool is_external, + struct hmap *lflows) +{ + struct ds match = DS_EMPTY_INITIALIZER; + + for (size_t j = 0; j < lsp_addrs->n_ipv6_addrs; j++) { + struct ds options_action = DS_EMPTY_INITIALIZER; + struct ds response_action = DS_EMPTY_INITIALIZER; + if (build_dhcpv6_action( + op, &lsp_addrs->ipv6_addrs[j].addr, + &options_action, &response_action)) { + ds_clear(&match); + ds_put_format( + &match, "inport == %s && eth.src == %s" + " && ip6.dst == ff02::1:2 && udp.src == 546 &&" + " udp.dst == 547", + json_key, lsp_addrs->ea_s); + + if (is_external) { + ds_put_format(&match, " && is_chassis_resident(%s)", + op->json_key); + } + + ovn_lflow_add_with_hint(lflows, op->od, + S_SWITCH_IN_DHCP_OPTIONS, 100, + ds_cstr(&match), + ds_cstr(&options_action), + &op->nbsp->dhcpv6_options->header_); + + /* If REGBIT_DHCP_OPTS_RESULT is set to 1, it means the + * put_dhcpv6_opts action is successful */ + ds_put_cstr(&match, " && "REGBIT_DHCP_OPTS_RESULT); + ovn_lflow_add_with_hint(lflows, op->od, + S_SWITCH_IN_DHCP_RESPONSE, 100, + ds_cstr(&match), + ds_cstr(&response_action), + &op->nbsp->dhcpv6_options->header_); + ds_destroy(&options_action); + ds_destroy(&response_action); + break; + } + } + ds_destroy(&match); +} + static void build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, struct hmap *port_groups, struct hmap *lflows, @@ -6521,52 +6569,8 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, build_dhcpv4_options_flows(op, &op->lsp_addrs[i], json_key, is_external, lflows); - struct ovsdb_idl_row *stage_hint; - if (op->nbsp->dhcpv6_options) { - stage_hint = &op->nbsp->dhcpv6_options->header_; - } else { - stage_hint = NULL; - } - - for (size_t j = 0; j < op->lsp_addrs[i].n_ipv6_addrs; j++) { - struct ds options_action = DS_EMPTY_INITIALIZER; - struct ds response_action = DS_EMPTY_INITIALIZER; - if (build_dhcpv6_action( - op, &op->lsp_addrs[i].ipv6_addrs[j].addr, - &options_action, &response_action)) { - ds_clear(&match); - ds_put_format( - &match, "inport == %s && eth.src == %s" - " && ip6.dst == ff02::1:2 && udp.src == 546 &&" - " udp.dst == 547", - is_external ? op->od->localnet_port->json_key : - op->json_key, - op->lsp_addrs[i].ea_s); - - if (is_external) { - ds_put_format(&match, " && is_chassis_resident(%s)", - op->json_key); - } - - ovn_lflow_add_with_hint(lflows, op->od, - S_SWITCH_IN_DHCP_OPTIONS, 100, - ds_cstr(&match), - ds_cstr(&options_action), - stage_hint); - - /* If REGBIT_DHCP_OPTS_RESULT is set to 1, it means the - * put_dhcpv6_opts action is successful */ - ds_put_cstr(&match, " && "REGBIT_DHCP_OPTS_RESULT); - ovn_lflow_add_with_hint(lflows, op->od, - S_SWITCH_IN_DHCP_RESPONSE, 100, - ds_cstr(&match), - ds_cstr(&response_action), - stage_hint); - ds_destroy(&options_action); - ds_destroy(&response_action); - break; - } - } + build_dhcpv6_options_flows(op, &op->lsp_addrs[i], json_key, + is_external, lflows); } }