From patchwork Thu Sep 3 16:04:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1356736 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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bIRecie5; dkim-atps=neutral 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 4Bj5Gm5Gy0z9sR4 for ; Fri, 4 Sep 2020 02:04:32 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id AC5032E110; Thu, 3 Sep 2020 16:04:30 +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 RGiR1P3XTpK2; Thu, 3 Sep 2020 16:04:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id CF20F2E0F6; Thu, 3 Sep 2020 16:04:28 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B7EE1C0052; Thu, 3 Sep 2020 16:04:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id C8BD9C0051 for ; Thu, 3 Sep 2020 16:04:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BF74E2E0F8 for ; Thu, 3 Sep 2020 16:04:26 +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 ARz6sxUCSNws for ; Thu, 3 Sep 2020 16:04:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by silver.osuosl.org (Postfix) with ESMTPS id 365832E0F6 for ; Thu, 3 Sep 2020 16:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599149063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OoYcCAjKULD9mNlkjOhBDIk7SOPiV2qVtWFevMYEtas=; b=bIRecie5Gwe3zC5MbsqHXwEwTv//HYePmB5yyaBxyexLY0mS3gdfcLwrze8chvR9Py2ZTn B66xsJ8Yx3do+JA1PKyiWjV/FISK3AVM/EQvM/uQh1SYUz7A2VeWlFvosDwfl6YEPSU4AS kHZwsVR9+YQX3GdRnjCChnFAogdbInY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-o4CZ8aEzPKucM9ldozF3pQ-1; Thu, 03 Sep 2020 12:04:09 -0400 X-MC-Unique: o4CZ8aEzPKucM9ldozF3pQ-1 Received: by mail-wr1-f70.google.com with SMTP id a12so1246340wrg.13 for ; Thu, 03 Sep 2020 09:04:08 -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=OoYcCAjKULD9mNlkjOhBDIk7SOPiV2qVtWFevMYEtas=; b=GzblCgOyGuP6oPrIHS+7XRFO2BBrccYfSTaj69BHyVx54BJuvy/gXCQW2Hl8//p/8N BNHDdBXuk6saRxbXUhdTrRSperQSJUz7RkTWMXshtpXH4+5PKvINmH5rE1fnL8rvnrZS AFh45ZbM16MKzrykJdnMFTVFGOs3H+XA+qqAFUTq4P9C41jaBKZdQ+Hgl8piVoenaeb7 JLU4ns1WrA/JWu9e54lbw4k6tnEH5HU7/PjAblQN50KTtelLvvJkmeuP2VTj7KoJgJwn 4zMwscPA8XLjdEnykPeTkom+JVQ3KYyQPEHGHnWU8SmZG5ULDLbDECbqxY9Kvdk4uPVl QVXg== X-Gm-Message-State: AOAM530AIWMsZqnhCxiEahzeQpAtue+B2ePDvm6Mmg4+RN1mWmbB4jxw 0KwHRoJabzcI1HClbougHUrrXanFYcK428YXMr3WRvkUYfBtNyi05C9x5tSShCKqBhZ/ljCFwei KQDbKa8R9QC21 X-Received: by 2002:a5d:46cd:: with SMTP id g13mr3498637wrs.153.1599149047366; Thu, 03 Sep 2020 09:04:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe3S7CUtaLjzrbpyIIrm4p2GQN8dblrr33Lgs169bgLmQPhfYxmvLhJmDxXMvcStLnuCJzRg== X-Received: by 2002:a5d:46cd:: with SMTP id g13mr3498604wrs.153.1599149047069; Thu, 03 Sep 2020 09:04:07 -0700 (PDT) Received: from lore-desk.redhat.com ([151.66.86.87]) by smtp.gmail.com with ESMTPSA id b84sm6232041wmd.0.2020.09.03.09.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 09:04:06 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Thu, 3 Sep 2020 18:04:00 +0200 Message-Id: <32746328541e298b339620e73867583b14d4652a.1599148681.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 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") Suggested-by: Dumitru Ceara Signed-off-by: Lorenzo Bianconi Acked-by: Dumitru Ceara --- 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..f05e8ae6f 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