From patchwork Fri Aug 12 06:34:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurucharan Shetty X-Patchwork-Id: 658717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3s9r9C6kM2z9sxR for ; Sat, 13 Aug 2016 02:35:43 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BA57310D50; Fri, 12 Aug 2016 09:35:42 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 6B09410D42 for ; Fri, 12 Aug 2016 09:35:41 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 025E216248E for ; Fri, 12 Aug 2016 10:35:41 -0600 (MDT) X-ASG-Debug-ID: 1471019740-0b32375f6ee45e0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id BHiBnpnqQlBMmfuD (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 12 Aug 2016 10:35:40 -0600 (MDT) X-Barracuda-Envelope-From: guru.ovn@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f68.google.com) (209.85.220.68) by mx1-pf2.cudamail.com with ESMTPS (AES128-SHA encrypted); 12 Aug 2016 16:35:40 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.68 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.85.220.68 X-Barracuda-RBL-IP: 209.85.220.68 Received: by mail-pa0-f68.google.com with SMTP id hh10so1715665pac.1 for ; Fri, 12 Aug 2016 09:35:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=MXmTv6olEFc6ha2mWsQWWu7M6jHKX8u0qo1UkBSskA0=; b=kNeqy7GldL7GbLd9ukDZgsKHncxaotmbl28b92pDtrRYld0F2jrYAOhdcoMhQsI4CR BWSdtdm5MYwYan5He8QDub6GSk3UUlDu7y7zPDbApRSBci+Qx9vRBlW+ZZnzuUA9kvJU wRRggcs1HrFqOK6iu/f3JAJ7YmXEXK4NpMf/3WXl2NKqx/KEL2bHxfdHtyXhk6DHUSAQ g4CnMvMPknYuaQDxg3MmbO0TXc9DK2ZcZZq8uZzTI/VVyggkZOyVflZnyA3+OWynujXN Af9K/4vx1991Lk2/Co8vaymQV6UV5CFLMD6HC7Uz0STRB0VlIuDa3Wr98eDWI63lR2/w Z9Qw== X-Gm-Message-State: AEkoouuzD8QmGWU4GOg16QawZ5ZxrP4SDG59ZkUXZKGCe9aPz9kFjgyhMb4EbBL6GCe9AQ== X-Received: by 10.66.155.7 with SMTP id vs7mr28371144pab.154.1471019739016; Fri, 12 Aug 2016 09:35:39 -0700 (PDT) Received: from ubuntu.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id yv9sm14314069pab.0.2016.08.12.09.35.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 09:35:38 -0700 (PDT) X-CudaMail-Envelope-Sender: guru.ovn@gmail.com From: Gurucharan Shetty To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-811035024 X-CudaMail-DTE: 081216 X-CudaMail-Originating-IP: 209.85.220.68 Date: Thu, 11 Aug 2016 23:34:36 -0700 X-ASG-Orig-Subj: [##CM-E2-811035024##][PATCH 1/2] ovn: Ability to set multiple load balancers. Message-Id: <1470983677-7638-1-git-send-email-guru@ovn.org> X-Mailer: git-send-email 1.9.1 X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1471019740 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 1/2] ovn: Ability to set multiple load balancers. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" The schema prevented one from setting more than one load balancer to a switch. This removes that anamoly. Signed-off-by: Gurucharan Shetty --- ovn/northd/ovn-northd.c | 38 +++++++++++++++++++------------------- ovn/ovn-nb.ovsschema | 6 +++--- tests/system-ovn.at | 19 ++++++++++++++++++- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 861f872..97d71ea 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -1938,11 +1938,11 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) ovn_lflow_add(lflows, od, S_SWITCH_OUT_PRE_LB, 0, "1", "next;"); struct sset all_ips = SSET_INITIALIZER(&all_ips); - if (od->nbs->load_balancer) { - struct nbrec_load_balancer *lb = od->nbs->load_balancer; + bool vip_configured = false; + for (int i = 0; i < od->nbs->n_load_balancer; i++) { + struct nbrec_load_balancer *lb = od->nbs->load_balancer[i]; struct smap *vips = &lb->vips; struct smap_node *node; - bool vip_configured = false; SMAP_FOR_EACH (node, vips) { vip_configured = true; @@ -1966,23 +1966,23 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) * the packet through ct() action to de-fragment. In stateful * table, we will eventually look at L4 information. */ } + } - /* 'REGBIT_CONNTRACK_DEFRAG' is set to let the pre-stateful table send - * packet to conntrack for defragmentation. */ - const char *ip_address; - SSET_FOR_EACH(ip_address, &all_ips) { - char *match = xasprintf("ip && ip4.dst == %s", ip_address); - ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, - 100, match, REGBIT_CONNTRACK_DEFRAG" = 1; next;"); - free(match); - } + /* 'REGBIT_CONNTRACK_DEFRAG' is set to let the pre-stateful table send + * packet to conntrack for defragmentation. */ + const char *ip_address; + SSET_FOR_EACH(ip_address, &all_ips) { + char *match = xasprintf("ip && ip4.dst == %s", ip_address); + ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, + 100, match, REGBIT_CONNTRACK_DEFRAG" = 1; next;"); + free(match); + } - sset_destroy(&all_ips); + sset_destroy(&all_ips); - if (vip_configured) { - ovn_lflow_add(lflows, od, S_SWITCH_OUT_PRE_LB, - 100, "ip", REGBIT_CONNTRACK_DEFRAG" = 1; next;"); - } + if (vip_configured) { + ovn_lflow_add(lflows, od, S_SWITCH_OUT_PRE_LB, + 100, "ip", REGBIT_CONNTRACK_DEFRAG" = 1; next;"); } } @@ -2297,8 +2297,8 @@ build_stateful(struct ovn_datapath *od, struct hmap *lflows) * a higher priority rule for load balancing below also commits the * connection, so it is okay if we do not hit the above match on * REGBIT_CONNTRACK_COMMIT. */ - if (od->nbs->load_balancer) { - struct nbrec_load_balancer *lb = od->nbs->load_balancer; + for (int i = 0; i < od->nbs->n_load_balancer; i++) { + struct nbrec_load_balancer *lb = od->nbs->load_balancer[i]; struct smap *vips = &lb->vips; struct smap_node *node; diff --git a/ovn/ovn-nb.ovsschema b/ovn/ovn-nb.ovsschema index 660db76..6bf1291 100644 --- a/ovn/ovn-nb.ovsschema +++ b/ovn/ovn-nb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Northbound", - "version": "5.3.0", - "cksum": "1305504870 9051", + "version": "5.3.1", + "cksum": "106203516 9061", "tables": { "NB_Global": { "columns": { @@ -30,7 +30,7 @@ "refTable": "Load_Balancer", "refType": "strong"}, "min": 0, - "max": 1}}, + "max": "unlimited"}}, "other_config": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, diff --git a/tests/system-ovn.at b/tests/system-ovn.at index b96b260..d9ee371 100755 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -347,6 +347,10 @@ ovn-nbctl lsp-add bar bar3 \ uuid=`ovn-nbctl create load_balancer vips:30.0.0.1="172.16.1.2,172.16.1.3,172.16.1.4"` ovn-nbctl set logical_switch foo load_balancer=$uuid +# Create another load-balancer with another VIP. +uuid=`ovn-nbctl create load_balancer vips:30.0.0.3="172.16.1.2,172.16.1.3,172.16.1.4"` +ovn-nbctl add logical_switch foo load_balancer $uuid + # Config OVN load-balancer with another VIP (this time with ports). ovn-nbctl set load_balancer $uuid vips:'"30.0.0.2:8000"'='"172.16.1.2:80,172.16.1.3:80,172.16.1.4:80"' @@ -358,7 +362,7 @@ NETNS_DAEMONIZE([bar1], [[$PYTHON $srcdir/test-l7.py]], [http1.pid]) NETNS_DAEMONIZE([bar2], [[$PYTHON $srcdir/test-l7.py]], [http2.pid]) NETNS_DAEMONIZE([bar3], [[$PYTHON $srcdir/test-l7.py]], [http3.pid]) -dnl Should work with the virtual IP address through NAT +dnl Should work with the virtual IP 30.0.0.1 address through NAT for i in 1 2 3 4 5 6 7 8 9 10 11 12; do echo Request $i NS_CHECK_EXEC([foo1], [wget 30.0.0.1 -t 5 -T 1 --retry-connrefused -v -o wget$i.log]) @@ -371,6 +375,19 @@ tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=,dport=),reply=(s tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=,dport=),reply=(src=172.16.1.4,dst=192.168.1.2,sport=,dport=),protoinfo=(state=) ]) +dnl Should work with the virtual IP 30.0.0.3 address through NAT +for i in 1 2 3 4 5 6 7 8 9 10 11 12; do + echo Request $i + NS_CHECK_EXEC([foo1], [wget 30.0.0.3 -t 5 -T 1 --retry-connrefused -v -o wget$i.log]) +done + +dnl Each server should have at least one connection. +AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(30.0.0.3)], [0], [dnl +tcp,orig=(src=192.168.1.2,dst=30.0.0.3,sport=,dport=),reply=(src=172.16.1.2,dst=192.168.1.2,sport=,dport=),protoinfo=(state=) +tcp,orig=(src=192.168.1.2,dst=30.0.0.3,sport=,dport=),reply=(src=172.16.1.3,dst=192.168.1.2,sport=,dport=),protoinfo=(state=) +tcp,orig=(src=192.168.1.2,dst=30.0.0.3,sport=,dport=),reply=(src=172.16.1.4,dst=192.168.1.2,sport=,dport=),protoinfo=(state=) +]) + dnl Test load-balancing that includes L4 ports in NAT. for i in 1 2 3 4 5 6 7 8 9 10 11 12; do echo Request $i