From patchwork Wed Nov 4 07:02:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1393680 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CQyL906Bpz9sTK for ; Wed, 4 Nov 2020 18:03:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 673488644F; Wed, 4 Nov 2020 07:03:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7u3XjA8s3k_L; Wed, 4 Nov 2020 07:03:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 80BC786440; Wed, 4 Nov 2020 07:03:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 68829C088B; Wed, 4 Nov 2020 07:03:38 +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 DFE59C1AD7 for ; Wed, 4 Nov 2020 07:03:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B7C15228A7 for ; Wed, 4 Nov 2020 07:03:36 +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 DuDTl3P1WOKR for ; Wed, 4 Nov 2020 07:03:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by silver.osuosl.org (Postfix) with ESMTPS id 0819D229D4 for ; Wed, 4 Nov 2020 07:03:06 +0000 (UTC) X-Originating-IP: 75.54.222.30 Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id B37DE2000A; Wed, 4 Nov 2020 07:03:04 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 3 Nov 2020 23:02:42 -0800 Message-Id: <20201104070246.2847579-9-blp@ovn.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201104070246.2847579-1-blp@ovn.org> References: <20201104070246.2847579-1-blp@ovn.org> MIME-Version: 1.0 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH ovn 08/12] ovn-l7: Move ipv6_addr_is_routable_multicast() into new .c file. 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" This makes it possible for the upcoming ovn-northd-ddlog program to call into it from Rust. Signed-off-by: Ben Pfaff Acked-by: Numan Siddique --- lib/automake.mk | 1 + lib/ovn-l7.c | 39 +++++++++++++++++++++++++++++++++++++++ lib/ovn-l7.h | 19 +------------------ 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 lib/ovn-l7.c diff --git a/lib/automake.mk b/lib/automake.mk index f3e9c8818b2b..d38d5c50c768 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -19,6 +19,7 @@ lib_libovn_la_SOURCES = \ lib/mcast-group-index.h \ lib/lex.c \ lib/ovn-l7.h \ + lib/ovn-l7.c \ lib/ovn-util.c \ lib/ovn-util.h \ lib/logical-fields.c \ diff --git a/lib/ovn-l7.c b/lib/ovn-l7.c new file mode 100644 index 000000000000..3a5f3f3ec02e --- /dev/null +++ b/lib/ovn-l7.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Red Hat. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "ovn-l7.h" + +bool +ipv6_addr_is_routable_multicast(const struct in6_addr *ip) +{ + if (!ipv6_addr_is_multicast(ip)) { + return false; + } + + /* Check multicast group scope, RFC 4291, 2.7. */ + switch (ip->s6_addr[1] & 0x0F) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x0F: + return false; + default: + return true; + } +} diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index c3e8fd660983..a3bfd4e539e3 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -420,24 +420,7 @@ controller_event_opts_destroy(struct controller_event_options *opts) } } -static inline bool -ipv6_addr_is_routable_multicast(const struct in6_addr *ip) { - if (!ipv6_addr_is_multicast(ip)) { - return false; - } - - /* Check multicast group scope, RFC 4291, 2.7. */ - switch (ip->s6_addr[1] & 0x0F) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x0F: - return false; - default: - return true; - } -} +bool ipv6_addr_is_routable_multicast(const struct in6_addr *); static inline bool ipv6_addr_is_host_zero(const struct in6_addr *prefix,