From patchwork Tue Sep 3 14:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1157039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46N8MV1Bxqz9sBF for ; Wed, 4 Sep 2019 00:23:49 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 95E50CA5; Tue, 3 Sep 2019 14:23:09 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C3C129EE for ; Tue, 3 Sep 2019 14:23:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 635E48AD for ; Tue, 3 Sep 2019 14:23:07 +0000 (UTC) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3BA18535D for ; Tue, 3 Sep 2019 14:23:06 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id v4so4386828wmh.9 for ; Tue, 03 Sep 2019 07:23:06 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gg6AJbvna6NdCrQWCL/+apsTV4rOYZFXXD7lb28CS7Q=; b=YvRjAwlat+uEBMHPRIOZ3LfFtQ525M4/nURZzi6YzwiNz/qFMvpLpx7Sz1taDEoAyC lKOo/+0jT8AOMYzpCYYocGQOZ8lNPA+/b5+iIxnexq/bPH9Tuk1pSwKRM5HITF+HScmL NW83Ff0MM1C824TXsZkhuzqOZkbTcyQike0WjGYjXQ7TY0z5TbTgz1p5a/j79fSvsKNa elFHY9j7W/NIuYhMouxanUQtfiShvS1fSTYKp+6CCV26kGH2IapGiEFCfH221XyZUfkg JPgNPpUY9Ja5aqdDEL7/ZBHUzRFlocrgYzmvod+pyOfRVGtfuHFDeFrAan+cmcLCYMQb xSHA== X-Gm-Message-State: APjAAAXwPMPIbULQ3UQgL8HKwzox47QaQHtTElRL8IpJkOXPD2YSjul9 aJKGt9G/vlsnkDDZ2w82qSJsZShwX7y0/a6AS/QREWArfHupmeMgV5ADYLdnSsoE/i5dYhRoway xr4RfUHjiU1nU53pwuQ== X-Received: by 2002:a1c:f103:: with SMTP id p3mr398316wmh.18.1567520585155; Tue, 03 Sep 2019 07:23:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/QiRPsyZtZeDiSN86ZvxSjUsjVsSy/ClMYxbMIXYdWpqjQxpNcsUbyJTS8NHXe1Hntpea0A== X-Received: by 2002:a1c:f103:: with SMTP id p3mr398288wmh.18.1567520584912; Tue, 03 Sep 2019 07:23:04 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id w12sm5254642wrg.47.2019.09.03.07.23.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:23:04 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Tue, 3 Sep 2019 16:22:51 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v5 ovn 1/3] northd: introduce build_empty_lb_event_flow routine X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Lorenzo Bianconi --- northd/ovn-northd.c | 63 ++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 9a2222282..679d36d88 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4014,6 +4014,41 @@ ls_has_dns_records(const struct nbrec_logical_switch *nbs) return false; } +static void +build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows, + struct smap_node *node, char *ip_address, + struct nbrec_load_balancer *lb, uint16_t port, + int addr_family, int pl) +{ + if (!controller_event_en || node->value[0]) { + return; + } + + struct ds match = DS_EMPTY_INITIALIZER; + char *action; + + if (addr_family == AF_INET) { + ds_put_format(&match, "ip4.dst == %s && %s", + ip_address, lb->protocol); + } else { + ds_put_format(&match, "ip6.dst == %s && %s", + ip_address, lb->protocol); + } + if (port) { + ds_put_format(&match, " && %s.dst == %u", lb->protocol, + port); + } + action = xasprintf("trigger_event(event = \"%s\", " + "vip = \"%s\", protocol = \"%s\", " + "load_balancer = \"" UUID_FMT "\");", + event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS), + node->key, lb->protocol, + UUID_ARGS(&lb->header_.uuid)); + ovn_lflow_add(lflows, od, pl, 130, ds_cstr(&match), action); + ds_destroy(&match); + free(action); +} + static void build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) { @@ -4051,32 +4086,8 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) sset_add(&all_ips, ip_address); } - if (controller_event_en && !node->value[0]) { - struct ds match = DS_EMPTY_INITIALIZER; - char *action; - - if (addr_family == AF_INET) { - ds_put_format(&match, "ip4.dst == %s && %s", - ip_address, lb->protocol); - } else { - ds_put_format(&match, "ip6.dst == %s && %s", - ip_address, lb->protocol); - } - if (port) { - ds_put_format(&match, " && %s.dst == %u", lb->protocol, - port); - } - action = xasprintf("trigger_event(event = \"%s\", " - "vip = \"%s\", protocol = \"%s\", " - "load_balancer = \"" UUID_FMT "\");", - event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS), - node->key, lb->protocol, - UUID_ARGS(&lb->header_.uuid)); - ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, 120, - ds_cstr(&match), action); - ds_destroy(&match); - free(action); - } + build_empty_lb_event_flow(od, lflows, node, ip_address, lb, + port, addr_family, S_SWITCH_IN_PRE_LB); free(ip_address);