From patchwork Fri Sep 6 15:00:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1159057 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 46Q12c1W78z9s3Z for ; Sat, 7 Sep 2019 01:00:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A4F73245B; Fri, 6 Sep 2019 15:00:36 +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 1C12A23D8 for ; Fri, 6 Sep 2019 15:00:35 +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 56CA9831 for ; Fri, 6 Sep 2019 15:00:34 +0000 (UTC) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (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 5D19D4D2E6 for ; Fri, 6 Sep 2019 15:00:33 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id o11so2656646wrq.22 for ; Fri, 06 Sep 2019 08:00:33 -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:mime-version :content-transfer-encoding; bh=uVUPWqMcopCshEfpvkajfh++OOZoUc0GipU28tl1Fso=; b=cZOX9TRp+T7tucwzo4I32DG6XBmJFmSN0xLoJFDfEZ2H432JHBLjOBN/1CXd93S723 BZd+MfxV0XYqwBjYoF2VvyzRmJ9AFh6rR+aV/elz4O8bM2k5Bvxn2OdscbmJKSegvBst ZZeDo0ZLxc7QoHfQGOIOUgaWkOSzjDfocc+pKsUer65wzh4g5cv5cLgqwOj5DCd0Tp4u 9Q9etSHHfPcbYhyuMV2ZPRBZiYaLeJENc5mOPPBr81WhP9xuOUBuNfvuLygobINCDRov C6d++7ThBEq3P7oMw6qnGQUcqbWBhn1JTjsRsYLpiBoZEnihWAAKlSPlAGFuE7uFRVQ+ t7MQ== X-Gm-Message-State: APjAAAWLHuKT2jG8JIZ6GPRUjuqmfGS+x+2wTsbbwcnrKu965TsJezT6 /UH02Tgi/TcrEYvJg/XLztOfmYbgk0UJ6NRR1qdwifw1FZ6k/lJjSlHLFchg61T6tqbFj/hW8ze U6stASucSDHeMBjOKmw== X-Received: by 2002:a1c:cf8c:: with SMTP id f134mr7879477wmg.174.1567782031701; Fri, 06 Sep 2019 08:00:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUbEO7FZ3F7xk2gN47cuhNB9O/Cmh4D7EXL1WqaX8hLCCO3uEbpfK07bWGg3YZZhUFPhr9+Q== X-Received: by 2002:a1c:cf8c:: with SMTP id f134mr7879448wmg.174.1567782031402; Fri, 06 Sep 2019 08:00:31 -0700 (PDT) Received: from localhost.localdomain.com ([151.66.4.139]) by smtp.gmail.com with ESMTPSA id r1sm5862847wro.13.2019.09.06.08.00.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 08:00:30 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Fri, 6 Sep 2019 17:00:19 +0200 Message-Id: <4253115f5e5a055158cc1f7b44980bc7127a8f5a.1567781778.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.0 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 v2 ovn] northd: add empty_lb controller_event for logical router 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 empty load balancer controller_event support to logical router pipeline. Update northd documentation even for logical switch pipeline Signed-off-by: Lorenzo Bianconi --- Changes since v1: - rebase on-top of current ovn master branch --- northd/ovn-northd.8.xml | 10 ++++++++ northd/ovn-northd.c | 26 ++++++++++++------- tests/ovn.at | 56 +++++++++++++++++++++++++++++++++++------ 3 files changed, 76 insertions(+), 16 deletions(-) diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index b34ef687a..0f4f1c112 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -1785,6 +1785,16 @@ icmp6 {

    +
  • + If controller_event has been enabled for all the configured load + balancing rules for a Gateway router or Router with gateway port + in OVN_Northbound 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. + If event-elb meter has been previously created, it will be + associated to the empty_lb logical flow +
  • +
  • For all the configured load balancing rules for a Gateway router or Router with gateway port in OVN_Northbound database that diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index c24e4d864..9bb1e7dd5 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6148,9 +6148,15 @@ 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, + struct shash *meter_groups) { + build_empty_lb_event_flow(od, lflows, node, ip_addr, lb, + l4_port, addr_family, S_ROUTER_IN_DNAT, + meter_groups); + /* A match and actions for new connections. */ char *new_match = xasprintf("ct.new && %s", ds_cstr(match)); if (lb_force_snat_ip) { @@ -6177,7 +6183,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; } @@ -6192,7 +6198,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]) { @@ -6308,7 +6314,7 @@ copy_ra_to_sb(struct ovn_port *op, const char *address_mode) static void build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, - struct hmap *lflows) + struct hmap *lflows, struct shash *meter_groups) { /* This flow table structure is documented in ovn-northd(8), so please * update ovn-northd.8.xml if you change anything. */ @@ -7525,7 +7531,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") ? @@ -7546,8 +7551,11 @@ 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, + meter_groups); + + free(ip_address); } } sset_destroy(&all_ips); @@ -8328,7 +8336,7 @@ build_lflows(struct northd_context *ctx, struct hmap *datapaths, build_lswitch_flows(datapaths, ports, port_groups, &lflows, mcgroups, igmp_groups, meter_groups); - build_lrouter_flows(datapaths, ports, &lflows); + build_lrouter_flows(datapaths, ports, &lflows, meter_groups); /* Push changes to the Logical_Flow table to database. */ const struct sbrec_logical_flow *sbflow, *next_sbflow; diff --git a/tests/ovn.at b/tests/ovn.at index de1b3b3ba..2749184eb 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14683,9 +14683,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 @@ -14705,10 +14718,24 @@ 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-nbctl --wait=hv meter-add event-elb drop 100 pktps 10 OVN_POPULATE_ARP @@ -14716,10 +14743,10 @@ 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}') @@ -14733,12 +14760,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