From patchwork Thu May 16 16:05:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1100652 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 454c373D49z9s7h for ; Fri, 17 May 2019 02:15:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 04E33C8B; Thu, 16 May 2019 16:14:55 +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 20778C5C for ; Thu, 16 May 2019 16:14:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 09D788BF for ; Thu, 16 May 2019 16:06:05 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id d9so4083297wrx.0 for ; Thu, 16 May 2019 09:06:05 -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=+kkdKixDHXTxhyHdMWl4P0FRXcymjzZ6nFS+F5LC6AE=; b=W62VNmmT2stiVgoDy3uQbYbpQqZaaFsexili7vgU1ak9WwBM84Y8gHFbXP/Ekst/Ey nbIv7VItpV9Z1hBMHa1rZ7E/wLkJmH/JCqEgW+a5rlqHwJUzmsisgY42TmVcD3lvsXmN XZ1OQdWk/z05waxNhigWEhS//gr1W23rAlChH4sVS0Bk1f7Ntykbqvcah1HoH5wtnMWJ FUwL8SJtB1QxWn0ITcNnBZikDK65uiF1U/ae3962sEWZfcl641FtmejCXrejy0efvc0B 8sMfnTwIP1ujnkLkttzwzegqqTJZQL0ldFyn8neUeWsh4KOIoUSjTkyBwfPK0km2VONY +Jag== X-Gm-Message-State: APjAAAWIuiBtnBFLpiBMVN7PtqE6hcGqAmip5a4C1YMicv5r4FHXShj2 fK3lS3y2AgNgPjuX9e5mxlXbRufoaWE= X-Google-Smtp-Source: APXvYqx2cb/1jiE4m4nRkeFsnKMEeqluSN/mwwhG6sHTf/8YwABoMF3qXLbm08AhuxWfMa9pQ910Wg== X-Received: by 2002:adf:8189:: with SMTP id 9mr27940354wra.71.1558022764436; Thu, 16 May 2019 09:06: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 s10sm4751362wrt.66.2019.05.16.09.06.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 16 May 2019 09:06:01 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Thu, 16 May 2019 18:05:26 +0200 Message-Id: <3dee06d0e487e6472b0f4acad8a8b3d9fd2eb899.1558021382.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE 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] [RFC 3/3] OVN: use send_event action to report 'empty_lb_rule' events 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 Add northd logical flows in order to reports that the controller received an IP packet for LB rule witn no backends. This configuration is used by OpenShift to spin up a idle POD Signed-off-by: Mark Michelson Co-authored-by: Mark Michelson Signed-off-by: Lorenzo Bianconi --- ovn/northd/ovn-northd.c | 32 ++++++++++++++++++++ ovn/ovn-nb.xml | 5 ++++ tests/ovn.at | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index de0c06d4b..16b38db0a 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -70,6 +70,8 @@ static const char *unixctl_path; static struct hmap macam = HMAP_INITIALIZER(&macam); static struct eth_addr mac_prefix; +static bool controller_event_en; + #define MAX_OVN_TAGS 4096 /* Pipeline stages. */ @@ -3571,6 +3573,33 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) sset_add(&all_ips, ip_address); } + if (controller_event_en && !strlen(node->value)) { + struct ds match = DS_EMPTY_INITIALIZER; + char *action; + + if (addr_family == AF_INET) { + ds_put_format(&match, "ip && ip4.dst == %s && %s", + ip_address, lb->protocol); + } else { + ds_put_format(&match, "ip && ip6.dst == %s && %s", + ip_address, lb->protocol); + } + if (port) { + ds_put_format(&match, " && %s.dst == %u", lb->protocol, + port); + } + action = xasprintf("send_event(event = %d, vip = \"%s\", " + "protocol = \"%s\", " + "load_balancer = \"" UUID_FMT "\");", + 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); + continue; + } + free(ip_address); /* Ignore L4 port information in the key because fragmented packets @@ -8044,6 +8073,9 @@ ovnnb_db_run(struct northd_context *ctx, smap_destroy(&options); } + controller_event_en = smap_get_bool(&nb->options, + "controller_event", false); + cleanup_macam(&macam); } diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml index cbaa9495f..c9d4acbe4 100644 --- a/ovn/ovn-nb.xml +++ b/ovn/ovn-nb.xml @@ -107,6 +107,11 @@ Configure a given OUI to be used as prefix when L2 address is dynamically assigned, e.g. 00:11:22 + + + Value used to enable/disable ovn-controller event reporting to the CMS. + Please see the table in SBDB. + diff --git a/tests/ovn.at b/tests/ovn.at index 1c54dd920..2df2833e9 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14031,3 +14031,69 @@ ovn-hv4-0 OVN_CLEANUP([hv1], [hv2], [hv3]) AT_CLEANUP + +AT_SETUP([ovn -- controller event]) +ovn_start + +# Create hypervisors hv[12]. +# Add vif1[12] to hv1, vif2[12] to hv2 +# Add all of the vifs to a single logical switch sw0. + +net_add n1 +ovn-nbctl ls-add sw0 +for i in 1 2; do + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovn_attach n1 br-phys 192.168.0.$i + + for j in 1 2; do + ovn-nbctl lsp-add sw0 sw0-p$i$j -- \ + lsp-set-addresses sw0-p$i$j "00:00:00:00:00:$i$j 192.168.1.$i$j" + + ovs-vsctl -- add-port br-int vif$i$j -- \ + set interface vif$i$j \ + external-ids:iface-id=sw0-p$i$j \ + options:tx_pcap=hv$i/vif$i$j-tx.pcap \ + options:rxq_pcap=hv$i/vif$i$j-rx.pcap \ + ofport-request=$i$j + done +done + +ovn-nbctl --wait=hv set NB_Global . options:controller_event=true +ovn-nbctl lb-add lb0 192.168.1.100:80 "" +ovn-nbctl ls-lb-add sw0 lb0 +uuid_lb=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0) + +OVN_POPULATE_ARP +ovn-nbctl --timeout=3 --wait=hv sync +ovn-sbctl lflow-list +as hv1 ovs-ofctl dump-flows br-int + +packet="inport==\"sw0-p11\" && eth.src==00:00:00:00:00:11 && eth.dst==00:00:00:00:00:21 && + ip4 && ip.ttl==64 && ip4.src==192.168.1.11 && ip4.dst==192.168.1.100 && + tcp && tcp.src==10000 && tcp.dst==80" +as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet" + +ovn-sbctl list controller_event +uuid=$(ovn-sbctl list controller_event | awk '/_uuid/{print $3}') +AT_CHECK([ovn-sbctl get controller_event $uuid event_type], [0], [dnl +empty_lb_backends +]) +AT_CHECK([ovn-sbctl get controller_event $uuid event_info:vip], [0], [dnl +"192.168.1.100:80" +]) +AT_CHECK([ovn-sbctl get controller_event $uuid event_info:protocol], [0], [dnl +tcp +]) +AT_CHECK_UNQUOTED([ovn-sbctl get controller_event $uuid event_info:load_balancer], [0], [dnl +"$uuid_lb" +]) +AT_CHECK([ovn-sbctl get controller_event $uuid handled], [0], [dnl +false +]) +ovn-sbctl set controller_event $uuid handled=true +AT_CHECK([ovn-sbctl list controller_event], [0], []) + +OVN_CLEANUP([hv1], [hv2]) +AT_CLEANUP