Add empty load balancer controller_event support to logical router pipeline. Update northd documentation even for logical switch pipeline
Signed-off-by: Lorenzo Bianconi <lorenzo.bianc...@redhat.com> --- northd/ovn-northd.8.xml | 12 +++++++++ northd/ovn-northd.c | 19 +++++++++----- tests/ovn.at | 57 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index d45bb15dc..f58338880 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -301,6 +301,10 @@ <code>Pre-stateful</code> to send IP packets to the connection tracker for packet de-fragmentation before eventually advancing to ingress table <code>LB</code>. + If controller_event has been enabled and load balancing rules with + empty backends have been added in <code>OVN_Northbound</code>, a 130 flow + is added to trigger ovn-controller events whenever the chassis receives a + packet for that particular VIP </p> <h3>Ingress Table 5: Pre-stateful</h3> @@ -1757,6 +1761,14 @@ icmp6 { </p> <ul> + <li> + If controller_event has been enabled for all the configured load + balancing rules for a Gateway router or Router with gateway port + in <code>OVN_Northbound</code> database that does not have configured + backends, a priority-130 flow is added to trigger ovn-controller events + whenever the chassis receives a packet for that particular VIP + </li> + <li> For all the configured load balancing rules for a Gateway router or Router with gateway port in <code>OVN_Northbound</code> database that diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 9db8b43e2..d6ac8159e 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6127,9 +6127,13 @@ get_force_snat_ip(struct ovn_datapath *od, const char *key_type, ovs_be32 *ip) static void add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od, struct ds *match, struct ds *actions, int priority, - const char *lb_force_snat_ip, char *backend_ips, - bool is_udp, int addr_family) + const char *lb_force_snat_ip, struct smap_node *node, + bool is_udp, int addr_family, char *ip_addr, + uint16_t l4_port, struct nbrec_load_balancer *lb) { + build_empty_lb_event_flow(od, lflows, node, ip_addr, lb, + l4_port, addr_family, S_ROUTER_IN_DNAT); + /* A match and actions for new connections. */ char *new_match = xasprintf("ct.new && %s", ds_cstr(match)); if (lb_force_snat_ip) { @@ -6156,7 +6160,7 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od, free(new_match); free(est_match); - if (!od->l3dgw_port || !od->l3redirect_port || !backend_ips) { + if (!od->l3dgw_port || !od->l3redirect_port || !node->value) { return; } @@ -6171,7 +6175,7 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od, ds_put_cstr(&undnat_match, "ip6 && ("); } char *start, *next, *ip_str; - start = next = xstrdup(backend_ips); + start = next = xstrdup(node->value); ip_str = strsep(&next, ","); bool backend_ips_found = false; while (ip_str && ip_str[0]) { @@ -7469,7 +7473,6 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_put_format(&match, "ip && ip6.dst == %s", ip_address); } - free(ip_address); int prio = 110; bool is_udp = lb->protocol && !strcmp(lb->protocol, "udp") ? @@ -7490,8 +7493,10 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, od->l3redirect_port->json_key); } add_router_lb_flow(lflows, od, &match, &actions, prio, - lb_force_snat_ip, node->value, is_udp, - addr_family); + lb_force_snat_ip, node, is_udp, + addr_family, ip_address, port, lb); + + free(ip_address); } } sset_destroy(&all_ips); diff --git a/tests/ovn.at b/tests/ovn.at index c5281a09d..86078c400 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14679,9 +14679,22 @@ 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. +# Create logical router lr0 net_add n1 -ovn-nbctl ls-add sw0 + +ovn-nbctl create Logical_Router name=lr0 options:chassis=hv1 +for i in 0 1; do + idx=$((i+1)) + ovn-nbctl ls-add sw$i + ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$idx 192.168.$idx.254/24 + ovn-nbctl \ + -- lsp-add sw$i lrp$i-attachment \ + -- set Logical_Switch_Port lrp$i-attachment type=router \ + options:router-port=lrp$i \ + addresses='"00:00:00:00:ff:'0$idx'"' +done + for i in 1 2; do sim_add hv$i as hv$i @@ -14701,20 +14714,35 @@ for i in 1 2; do done done +as hv1 +ovn-nbctl lsp-add sw1 sw1-p0 \ + -- lsp-set-addresses sw1-p0 "00:00:00:00:00:33 192.168.2.11" +ovs-vsctl -- add-port br-int vif33 -- \ + set interface vif33 \ + external-ids:iface-id=sw1-p0 \ + options:tx_pcap=hv$i/vif33-tx.pcap \ + options:rxq_pcap=hv$i/vif33-rx.pcap \ + ofport-request=33 + + 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) +uuid_lb0=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0) + +ovn-nbctl lb-add lb1 192.168.2.100:80 "" +ovn-nbctl lr-lb-add lr0 lb1 +uuid_lb1=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb1) 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" +packet0="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 "$packet0" ovn-sbctl list controller_event uuid=$(ovn-sbctl list controller_event | awk '/_uuid/{print $3}') @@ -14728,12 +14756,27 @@ 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" +"$uuid_lb0" ]) AT_CHECK([ovn-sbctl get controller_event $uuid seq_num], [0], [dnl 1 ]) +ovn-sbctl destroy controller_event $uuid +packet1="inport==\"sw1-p0\" && eth.src==00:00:00:00:00:33 && eth.dst==00:00:00:00:ff:02 && + ip4 && ip.ttl==64 && ip4.src==192.168.2.11 && ip4.dst==192.168.2.100 && + tcp && tcp.src==10000 && tcp.dst==80" + +as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet1" +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.2.100:80" +]) + OVN_CLEANUP([hv1], [hv2]) AT_CLEANUP -- 2.21.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev