From patchwork Fri Sep 4 13:44:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1357469 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bjf7R4Fcqz9sWV for ; Fri, 4 Sep 2020 23:45:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 75B672E1CD; Fri, 4 Sep 2020 13:45:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XrJzd+9hZORi; Fri, 4 Sep 2020 13:45:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 40230228A0; Fri, 4 Sep 2020 13:45:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 081E3C0052; Fri, 4 Sep 2020 13:45:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4E6E7C0051 for ; Fri, 4 Sep 2020 13:44:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 43CBD86CD2 for ; Fri, 4 Sep 2020 13:44:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XK4zpTXSTp1z for ; Fri, 4 Sep 2020 13:44:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by whitealder.osuosl.org (Postfix) with ESMTPS id 0674086BB9 for ; Fri, 4 Sep 2020 13:44:56 +0000 (UTC) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-mqqyge2gOuG13e69FefCfQ-1; Fri, 04 Sep 2020 09:44:54 -0400 X-MC-Unique: mqqyge2gOuG13e69FefCfQ-1 Received: by mail-ed1-f72.google.com with SMTP id y15so1225685edq.4 for ; Fri, 04 Sep 2020 06:44:54 -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:mime-version :content-transfer-encoding; bh=sb4UhSlJEzKg5eodjk0tUyrRFNJjiNNPL0uv45Vocvk=; b=ap+121pgpKXyTXV+iGscIga2fqJ2PN3jvDRMRa63TNhUxMVmuFxLOQCZPgeAg0/tGQ paluhQD2gHO+NT3UdbN7RzvNTFvOXCBsEJzax9whSAxwGeAwNInj4J2kFkaEKFxTgrLJ RzicyRY6OjbdUzSJAXaW/HBiL5Qr5zamXGHVoBfWzRdAUUxcmEGBgBNt3r1P5pQGI1lF ux4gqMRO5hjQ2l4z34iFlNorkjmZCMXAC6hegs0cdE9gUt0fR35cZ7ZvKjgFeuSPYq7F 5w82gz+Lz/Xq4tDcDIUgjAsRT+AAS8tgxIoMSHjZ91KGeN41XgbyqzT8uKXZTKOrTYMA IKyg== X-Gm-Message-State: AOAM5338DhXwy5lzfIL/IFZ4FbvXwFk0cvAAKvrt+8Mt8JKyMrgfeuZf urRc4Xxfr/8Y8VErndYXaQYZ/hOeEDI7PEUEkLY8/C4rdRT6xGXjt1Zdoc36oyH9qZ4HXw35ANr 5Evxpxl2iBaeO X-Received: by 2002:a05:6402:17ed:: with SMTP id t13mr8817960edy.163.1599227093333; Fri, 04 Sep 2020 06:44:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrGvdmmB7YMlEa4H9m60I4BnhY8hjcLyrumk3LbbdoTewVJxgDIU6KcZPs79ido93gMTuE0Q== X-Received: by 2002:a05:6402:17ed:: with SMTP id t13mr8817941edy.163.1599227093055; Fri, 04 Sep 2020 06:44:53 -0700 (PDT) Received: from lore-desk.redhat.com ([151.66.86.87]) by smtp.gmail.com with ESMTPSA id u15sm6049852edq.96.2020.09.04.06.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 06:44:52 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Fri, 4 Sep 2020 15:44:49 +0200 Message-Id: <311c2f8fe0f7f18aeab3c66036e1384cd43b06f3.1599226928.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn] northd: fix empty_lb_backends controller_event for IPv6 X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Introduce missing square brackets defining IPv6 empty_lb_backends controller_event logical flows in order to properly extract vip ip and port from the related string Fixes: bb9f2b9ce56c ("ovn-northd: Consider load balancer active backends in router pipeline") Fixes: 821e1e54abcb ("OVN: use trigger_event action to report 'empty_lb_rule' events") Acked-by: Dumitru Ceara Signed-off-by: Lorenzo Bianconi --- Changes since v1: - cosmetics --- northd/ovn-northd.c | 7 ++++--- tests/ovn.at | 30 +++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 7be0e85e6..3de71612b 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4996,6 +4996,7 @@ build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows, return; } + bool ipv4 = (lb_vip->addr_family == AF_INET); struct ds match = DS_EMPTY_INITIALIZER; char *meter = "", *action; @@ -5004,14 +5005,14 @@ build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows, } ds_put_format(&match, "ip%s.dst == %s && %s", - lb_vip->addr_family == AF_INET ? "4": "6", - lb_vip->vip, lb->protocol); + ipv4 ? "4": "6", lb_vip->vip, lb->protocol); char *vip = lb_vip->vip; if (lb_vip->vip_port) { ds_put_format(&match, " && %s.dst == %u", lb->protocol, lb_vip->vip_port); - vip = xasprintf("%s:%u", lb_vip->vip, lb_vip->vip_port); + vip = xasprintf("%s%s%s:%u", ipv4 ? "" : "[", lb_vip->vip, + ipv4 ? "" : "]", lb_vip->vip_port); } action = xasprintf("trigger_event(event = \"%s\", " diff --git a/tests/ovn.at b/tests/ovn.at index 5ad51c095..f659cdfa8 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -16411,7 +16411,7 @@ 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 lrp-add lr0 lrp$i 00:00:00:00:ff:0$idx 192.168.$idx.254/24 200$idx::a/64 ovn-nbctl \ -- lsp-add sw$i lrp$i-attachment \ -- set Logical_Switch_Port lrp$i-attachment type=router \ @@ -16427,7 +16427,7 @@ for i in 1 2; do 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" + lsp-set-addresses sw0-p$i$j "00:00:00:00:00:$i$j 192.168.1.$i$j 2001::$i$j" ovs-vsctl -- add-port br-int vif$i$j -- \ set interface vif$i$j \ @@ -16440,7 +16440,7 @@ 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" + -- lsp-set-addresses sw1-p0 "00:00:00:00:00:33 192.168.2.11 2002::1" ovs-vsctl -- add-port br-int vif33 -- \ set interface vif33 \ external-ids:iface-id=sw1-p0 \ @@ -16456,6 +16456,11 @@ 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 lb-add lb2 [[2001::10]]:50051 "" +ovn-nbctl ls-lb-add sw0 lb2 +uuid_lb2=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb2) + ovn-nbctl --wait=hv meter-add event-elb drop 100 pktps 10 OVN_POPULATE_ARP @@ -16500,6 +16505,25 @@ empty_lb_backends AT_CHECK([ovn-sbctl get controller_event $uuid event_info:vip], [0], [dnl "192.168.2.100:80" ]) +ovn-sbctl destroy controller_event $uuid + +packet2="inport==\"sw0-p11\" && eth.src==00:00:00:00:00:11 && eth.dst==00:00:00:00:00:21 && + ip6 && ip.ttl==64 && ip6.src==2001::11 && ip6.dst==2001::10 && + tcp && tcp.src==10000 && tcp.dst==50051" + +as hv1 ovs-appctl -t ovn-controller inject-pkt "$packet2" +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 +"[[2001::10]]:50051" +]) +AT_CHECK_UNQUOTED([ovn-sbctl get controller_event $uuid event_info:load_balancer], [0], [dnl +"$uuid_lb2" +]) OVN_CLEANUP([hv1], [hv2]) AT_CLEANUP