The schema prevented one from setting more than one load balancer to a switch. This removes that anamoly.
Signed-off-by: Gurucharan Shetty <g...@ovn.org> --- 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=<cleared>,dport=<cleared>),reply=(s tcp,orig=(src=192.168.1.2,dst=30.0.0.1,sport=<cleared>,dport=<cleared>),reply=(src=172.16.1.4,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) ]) +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=<cleared>,dport=<cleared>),reply=(src=172.16.1.2,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) +tcp,orig=(src=192.168.1.2,dst=30.0.0.3,sport=<cleared>,dport=<cleared>),reply=(src=172.16.1.3,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) +tcp,orig=(src=192.168.1.2,dst=30.0.0.3,sport=<cleared>,dport=<cleared>),reply=(src=172.16.1.4,dst=192.168.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) +]) + 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 -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev