From patchwork Wed Feb 19 15:50:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Bryant X-Patchwork-Id: 1240762 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.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48N2RS3G98z9sRN for ; Thu, 20 Feb 2020 02:57:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D2B82869EA; Wed, 19 Feb 2020 15:57:22 +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 3AXzD++k99z0; Wed, 19 Feb 2020 15:57:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id D2BFF869C4; Wed, 19 Feb 2020 15:57:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B26B5C1D81; Wed, 19 Feb 2020 15:57:21 +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 A7AF3C013E for ; Wed, 19 Feb 2020 15:57:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 916C7869C4 for ; Wed, 19 Feb 2020 15:57:19 +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 2nkxXXFC5sFY for ; Wed, 19 Feb 2020 15:57:18 +0000 (UTC) X-Greylist: delayed 00:06:16 by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id A13078695F for ; Wed, 19 Feb 2020 15:57:17 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-233-JymBraTUNZmdqJaZNBXKzg-1; Wed, 19 Feb 2020 10:50:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AAC1801FAF; Wed, 19 Feb 2020 15:50:52 +0000 (UTC) Received: from t480s.redhat.com (ovpn-122-50.rdu2.redhat.com [10.10.122.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id B387A48; Wed, 19 Feb 2020 15:50:51 +0000 (UTC) From: Russell Bryant To: dev@openvswitch.org Date: Wed, 19 Feb 2020 10:50:50 -0500 Message-Id: <20200219155050.615473-1-russell@ovn.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: JymBraTUNZmdqJaZNBXKzg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: ovn.org Subject: [ovs-dev] [PATCH ovn v1] northd: Allow /64 after ipv6_prefix 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" We recently hit a bug in ovn-kubernetes, where I accidentally added /64 at the end of ipv6_prefix, to match the format we used for the subnet option for IPv4. This was not allowed. This patch update ovn-northd to take the ipv6_prefix either with or without a trailing "/64". It still enforces a /64 CIDR prefix length. A test case was updated to ensure that a prefix with "/64" is now accepted. Signed-off-by: Russell Bryant Acked-by: Numan Siddique --- northd/ovn-northd.c | 31 +++++++++++++++++++++++++++++-- tests/ovn.at | 4 +++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 2580b4ec9..59d085aa9 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -664,8 +664,35 @@ init_ipam_info_for_datapath(struct ovn_datapath *od) const char *ipv6_prefix = smap_get(&od->nbs->other_config, "ipv6_prefix"); if (ipv6_prefix) { - od->ipam_info.ipv6_prefix_set = ipv6_parse( - ipv6_prefix, &od->ipam_info.ipv6_prefix); + if (strstr(ipv6_prefix, "/")) { + /* If a prefix length was specified, it must be 64. */ + struct in6_addr mask; + char *error + = ipv6_parse_masked(ipv6_prefix, + &od->ipam_info.ipv6_prefix, &mask); + if (error) { + static struct vlog_rate_limit rl + = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL(&rl, "bad 'ipv6_prefix' %s: %s", ipv6_prefix, error); + free(error); + } else { + if (ipv6_count_cidr_bits(&mask) == 64) { + od->ipam_info.ipv6_prefix_set = true; + } else { + static struct vlog_rate_limit rl + = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL(&rl, "bad 'ipv6_prefix' %s: must be /64", ipv6_prefix); + } + } + } else { + od->ipam_info.ipv6_prefix_set = ipv6_parse( + ipv6_prefix, &od->ipam_info.ipv6_prefix); + if (!od->ipam_info.ipv6_prefix_set) { + static struct vlog_rate_limit rl + = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL(&rl, "bad 'ipv6_prefix' %s", ipv6_prefix); + } + } } if (!subnet_str) { diff --git a/tests/ovn.at b/tests/ovn.at index 254645a3a..cbaa6d4a2 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -12289,8 +12289,10 @@ ovn-nbctl set Logical_Switch ls1 \ other_config:subnet=10.1.0.0/24 other_config:ipv6_prefix="2001:db8:1::" ovn-nbctl set Logical_Switch ls2 \ other_config:subnet=10.2.0.0/24 other_config:ipv6_prefix="2001:db8:2::" + +# A prefix length may be specified, but only if it is /64. ovn-nbctl set Logical_Switch ls3 \ - other_config:subnet=10.3.0.0/24 other_config:ipv6_prefix="2001:db8:3::" + other_config:subnet=10.3.0.0/24 other_config:ipv6_prefix="2001:db8:3::/64" ovn-nbctl lsp-add ls1 lp1 ovn-nbctl lsp-add ls2 lp2