From patchwork Mon Oct 28 14:37:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1185464 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.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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="QXlEItL3"; dkim-atps=neutral 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 471y5q6PHqz9sCJ for ; Tue, 29 Oct 2019 01:39:11 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 289CC117A; Mon, 28 Oct 2019 14:38:16 +0000 (UTC) X-Original-To: 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 1939610CF for ; Mon, 28 Oct 2019 14:38:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 22ECC87B for ; Mon, 28 Oct 2019 14:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572273493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F0bDZIk4KCB3cKnWaG4njeZc+kGS9/8neoUgbvt9qjM=; b=QXlEItL3XgFQd5GRu9lhk/JqgcahRs1UWYeDcSuRou6AHxEu65jFdceVsi09t/T0hslDT+ KaeCpJk8Vy8ZYTtFjbE5+EOMRnPcuXiL8K3aO+mbtGYqSWV9Shqn4U7o80nk8x0LP/tS+e g7/AyA54KWbVLiJ4AlxuI99ao3MHCyE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-gnx21JuCMnKpBVQexqjT-g-1; Mon, 28 Oct 2019 10:38:11 -0400 Received: by mail-wr1-f72.google.com with SMTP id h4so6476303wrx.15 for ; Mon, 28 Oct 2019 07:38:11 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gp6KHYFPSHff0dDYXIbJd41Spt+oeyIur2gj8j3nAGo=; b=Ee4M6qg3wZLiM/ojpROFG41BX4BNNvWMktMUx6kT8y83j9/3x8Rpq8KxQ4BevOgo/r H71hP1LJvmt44eT7q80xdJ2GKVvIltmIwY45A62uJySW16pc4XNqfChtMAco7czwKz48 7CaB8VRD+eeRlXCxSnT87L12ORdlGwvJv1EfRmtsF3bac/k5xTsgNidKQ49WAbiKGGtQ JEIfJ3ZMVf0t9Xm8aHFnV9olL0iG9u6GeC014S9mN0V94mPOK+5H9gheUbuZoTJV/qRA GgJmKDazJXj8yZ35TgQrxg8+v+oxQ01yRGSNRqkrrtdceo6w866Ul6/CKFR8SQ3y4Lr+ 0adw== X-Gm-Message-State: APjAAAV+QiYoQcUuGX3VmsA+jM0h2kLDDe5BdSrY3HBJGBDmJU0OU66H pYVsy4BUz9iaTbd0sMv9lLunsskWVkmZHF5yxprlB1JziAQ/fjhrjdTPQCqt4QMe+bHU7NpSCeH 8vjrGeyn7Yglk X-Received: by 2002:a1c:9a43:: with SMTP id c64mr302823wme.20.1572273489929; Mon, 28 Oct 2019 07:38:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdWxdUJErWMr6LR3Hl6FH/Trljc0M5sun8IANPPolf8/llYnlTgYa3geTVHpOQ6cqpIFpqyw== X-Received: by 2002:a1c:9a43:: with SMTP id c64mr302798wme.20.1572273489587; Mon, 28 Oct 2019 07:38:09 -0700 (PDT) Received: from localhost.localdomain.com ([176.229.194.15]) by smtp.gmail.com with ESMTPSA id y1sm11982267wrw.6.2019.10.28.07.38.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 07:38:09 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Mon, 28 Oct 2019 15:37:39 +0100 Message-Id: <1bf15e9b91dff1c81039476ac5f065b473975374.1572273087.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: gnx21JuCMnKpBVQexqjT-g-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 v4 ovn 1/2] Add RDNSS support to OVN 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 Introduce the possibility to specify a RDNSS option to Router Advertisement packets. DNS IPv6 address can be specified using 'rdnss' tag in the ipv6_ra_configs column of logical router port table Acked-by: Mark Michelson Signed-off-by: Lorenzo Bianconi --- controller/pinctrl.c | 39 +++++++++++++++++++++++++++++++++++++++ lib/ovn-l7.h | 11 +++++++++++ northd/ovn-northd.c | 5 +++++ ovn-nb.xml | 5 +++++ tests/ovn.at | 27 +++++++++++++++++++-------- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index d826da186..f105ebb5c 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2192,6 +2192,8 @@ struct ipv6_ra_config { uint8_t mo_flags; /* Managed/Other flags for RAs */ uint8_t la_flags; /* On-link/autonomous flags for address prefixes */ struct lport_addresses prefixes; + struct in6_addr rdnss; + bool has_rdnss; }; struct ipv6_ra_state { @@ -2289,6 +2291,12 @@ ipv6_ra_update_config(const struct sbrec_port_binding *pb) VLOG_WARN("Invalid IP source %s", ip_addr); goto fail; } + const char *rdnss = smap_get(&pb->options, "ipv6_ra_rdnss"); + if (rdnss && !ipv6_parse(rdnss, &config->rdnss)) { + VLOG_WARN("Invalid RDNSS source %s", rdnss); + goto fail; + } + config->has_rdnss = !!rdnss; return config; @@ -2319,6 +2327,33 @@ put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits, bitwise_one(ofpact_set_field_mask(sf), sf->field->n_bytes, ofs, n_bits); } +static void +packet_put_ra_rdnss_opt(struct dp_packet *b, uint8_t num, + ovs_be32 lifetime, const struct in6_addr *dns) +{ + size_t prev_l4_size = dp_packet_l4_size(b); + struct ip6_hdr *nh = dp_packet_l3(b); + size_t len = 2 * num + 1; + + nh->ip6_plen = htons(prev_l4_size + len * 8); + + struct nd_rdnss_opt *nd_rdnss = dp_packet_put_uninit(b, sizeof *nd_rdnss); + nd_rdnss->type = ND_OPT_RDNSS; + nd_rdnss->len = len; + nd_rdnss->reserved = 0; + put_16aligned_be32(&nd_rdnss->lifetime, lifetime); + + for (int i = 0; i < num; i++) { + dp_packet_put(b, &dns[i], sizeof(ovs_be32[4])); + } + + struct ovs_ra_msg *ra = dp_packet_l4(b); + ra->icmph.icmp6_cksum = 0; + uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b)); + ra->icmph.icmp6_cksum = csum_finish(csum_continue(icmp_csum, ra, + prev_l4_size + len * 8)); +} + /* Called with in the pinctrl_handler thread context. */ static long long int ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) @@ -2343,6 +2378,10 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) ra->config->la_flags, htonl(IPV6_ND_RA_OPT_PREFIX_VALID_LIFETIME), htonl(IPV6_ND_RA_OPT_PREFIX_PREFERRED_LIFETIME), addr); } + if (ra->config->has_rdnss) { + packet_put_ra_rdnss_opt(&packet, 1, htonl(0xffffffff), + &ra->config->rdnss); + } uint64_t ofpacts_stub[4096 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index c93def450..12cee6329 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -220,6 +220,17 @@ struct dhcpv6_opt_ia_na { ovs_be32 t2; }); +/* RDNSS option RFC 6106 */ +#define ND_RDNSS_OPT_LEN 8 +#define ND_OPT_RDNSS 25 +struct nd_rdnss_opt { + uint8_t type; /* ND_OPT_RDNSS. */ + uint8_t len; /* >= 3. */ + ovs_be16 reserved; /* Always 0. */ + ovs_16aligned_be32 lifetime; +}; +BUILD_ASSERT_DECL(ND_RDNSS_OPT_LEN == sizeof(struct nd_rdnss_opt)); + #define DHCPV6_DUID_LL 3 #define DHCPV6_HW_TYPE_ETH 1 diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index ea8ad7c2d..d1de36e08 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6485,6 +6485,11 @@ copy_ra_to_sb(struct ovn_port *op, const char *address_mode) smap_add(&options, "ipv6_ra_prefixes", ds_cstr(&s)); ds_destroy(&s); + const char *rdnss = smap_get(&op->nbrp->ipv6_ra_configs, "rdnss"); + if (rdnss) { + smap_add(&options, "ipv6_ra_rdnss", rdnss); + } + smap_add(&options, "ipv6_ra_src_eth", op->lrp_networks.ea_s); sbrec_port_binding_set_options(op->sb, &options); diff --git a/ovn-nb.xml b/ovn-nb.xml index 1504f8fca..2faf9390b 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1885,6 +1885,11 @@ is one-third of , i.e. 200 seconds if that key is unset. + + + IPv6 address of RDNSS server announced in RA packets. At the moment + OVN supports just one RDNSS server. + diff --git a/tests/ovn.at b/tests/ovn.at index 22b272a60..3e7692895 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -12537,14 +12537,15 @@ construct_expected_ra() { local mtu=$1 local ra_mo=$2 - local ra_prefix_la=$3 + local rdnss=$3 + local ra_prefix_la=$4 local slla=0101${src_mac} local mtu_opt="" if test $mtu != 0; then mtu_opt=05010000${mtu} fi - shift 3 + shift 4 local prefix="" while [[ $# -gt 0 ]] ; do @@ -12554,7 +12555,12 @@ construct_expected_ra() { shift 2 done - local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix} + local rdnss_opt="" + if test $rdnss != 0; then + rdnss_opt=19030000ffffffff${rdnss} + fi + + local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix}${rdnss_opt} local icmp=8600XXXX${ra} local ip_len=$(expr ${#icmp} / 2) @@ -12589,23 +12595,28 @@ ra_test() { } # Baseline test with no MTU -ra_test 0 00 c0 40 aef00000000000000000000000000000 +ra_test 0 00 0 c0 40 aef00000000000000000000000000000 # Now make sure an MTU option makes it ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:mtu=1500 -ra_test 000005dc 00 c0 40 aef00000000000000000000000000000 +ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000 # Now test for multiple network prefixes ovn-nbctl --wait=hv set Logical_Router_port ro-sw networks='aef0\:\:1/64 fd0f\:\:1/48' -ra_test 000005dc 00 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 + +# Now test for RDNSS +ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:rdnss='aef0::11' +dns_addr=aef00000000000000000000000000011 +ra_test 000005dc 00 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # Test a different address mode now ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateful -ra_test 000005dc 80 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 80 $dns_addr 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # And the other address mode ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateless -ra_test 000005dc 40 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 40 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP From patchwork Mon Oct 28 14:37:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1185465 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.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 Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="A/A46nBJ"; dkim-atps=neutral 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 471y6V5Swzz9sCJ for ; Tue, 29 Oct 2019 01:39:46 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id CEF30117C; Mon, 28 Oct 2019 14:38:23 +0000 (UTC) X-Original-To: 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 4D5AB1176 for ; Mon, 28 Oct 2019 14:38:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 667ED876 for ; Mon, 28 Oct 2019 14:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572273499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gsgyew2WecpRY+shPkOTNEiO24MAKS5y6i6N7lShgt4=; b=A/A46nBJ8qARiTyuLJss26Tf6mw5fcYj7vkbDQE5pS+84ygfEwR0PU9L+BzfHfVovlMiA+ xzDNX0dtYVJwUwjNvPVjPHoSDPKIPfOcwGmz2xS5CDCVeUo2XeRZvIGJgFatL35fwlFq88 vQunJQ7zPwH/jITCB3ELPoLlUhlI3zU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-76-5FIhkincOd2KVQ7SH5huug-1; Mon, 28 Oct 2019 10:38:15 -0400 Received: by mail-wm1-f71.google.com with SMTP id g21so1024503wmh.8 for ; Mon, 28 Oct 2019 07:38:15 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wffmmY30s1p3+9rmisWPMn7wISDLo0vHovzR4hztyVw=; b=nZxeIfnuAXHTCfPoAGTsY6vl0l1k/4+ff20s3es6uworYGo4HeRnveUodUcVCEbq/s YZ7FE3WTolReTIHD2M6i53bQghJAG3X7JC5yzKRn9mCP5GGiXijLef58+45WiSNehQgR Ash6eK8r7Bv3586oJS5kq1VrPCmBC1d+NmTZnv5TP0SA8wbk93TmWy0Mf8UDEW1sfYEH j2lOB3rAjacIorj1iQHIbrtreBTupg1zgTlT2KcXawcN4LCQLv8Br/K4XQ9S9orkx8Kn 4cr7qMN4qJD1aQeWjHOJUASyib6rYtuCX52N07ADH5OKV6zu+iut90g8pchQ+9csiMYW Cm+Q== X-Gm-Message-State: APjAAAUZuA8jgR3pETsPc6lKZw3no/Kp2ZCL9saFXovrL1WTUMz4KIk/ ItYpQ2y+lUAzI++ws7n0+09OZ1P++h+2wZcadVCMFN1ZqBFR1uCPVHfs1opbNCGQIltkGx1WlRH a0VUGx6wFdljT X-Received: by 2002:a1c:2008:: with SMTP id g8mr294723wmg.34.1572273494077; Mon, 28 Oct 2019 07:38:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwobwqSuf0deEqX2ki99sUQGyVJ0KA0Y/9nFv/nzEc+DMUoS1Ant4p4fltHwwv3+oZafWakA== X-Received: by 2002:a1c:2008:: with SMTP id g8mr294696wmg.34.1572273493751; Mon, 28 Oct 2019 07:38:13 -0700 (PDT) Received: from localhost.localdomain.com ([176.229.194.15]) by smtp.gmail.com with ESMTPSA id y1sm11982267wrw.6.2019.10.28.07.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 07:38:13 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Mon, 28 Oct 2019 15:37:40 +0100 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: 5FIhkincOd2KVQ7SH5huug-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 v4 ovn 2/2] Add DNSSL support to OVN 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 Introduce the possibility to specify a DNSSL option to Router Advertisement packets. DNS Search list can be specified using 'dnssl' tag in the ipv6_ra_configs column of logical router port table Signed-off-by: Lorenzo Bianconi --- controller/pinctrl.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ lib/ovn-l7.h | 11 ++++++++++ northd/ovn-northd.c | 4 ++++ ovn-nb.xml | 5 +++++ tests/ovn.at | 30 +++++++++++++++++--------- 5 files changed, 91 insertions(+), 10 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index f105ebb5c..0bd1ef3ef 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2194,6 +2194,7 @@ struct ipv6_ra_config { struct lport_addresses prefixes; struct in6_addr rdnss; bool has_rdnss; + struct ds dnssl; }; struct ipv6_ra_state { @@ -2215,6 +2216,7 @@ ipv6_ra_config_delete(struct ipv6_ra_config *config) { if (config) { destroy_lport_addresses(&config->prefixes); + ds_destroy(&config->dnssl); free(config); } } @@ -2253,6 +2255,7 @@ ipv6_ra_update_config(const struct sbrec_port_binding *pb) nd_ra_min_interval_default(config->max_interval)); config->mtu = smap_get_int(&pb->options, "ipv6_ra_mtu", ND_MTU_DEFAULT); config->la_flags = IPV6_ND_RA_OPT_PREFIX_ON_LINK; + ds_init(&config->dnssl); const char *address_mode = smap_get(&pb->options, "ipv6_ra_address_mode"); if (!address_mode) { @@ -2298,6 +2301,11 @@ ipv6_ra_update_config(const struct sbrec_port_binding *pb) } config->has_rdnss = !!rdnss; + const char *dnssl = smap_get(&pb->options, "ipv6_ra_dnssl"); + if (dnssl) { + ds_put_buffer(&config->dnssl, dnssl, strlen(dnssl)); + } + return config; fail: @@ -2354,6 +2362,45 @@ packet_put_ra_rdnss_opt(struct dp_packet *b, uint8_t num, prev_l4_size + len * 8)); } +static void +packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime, + char *dnssl_list) +{ + char *t0, *r0 = dnssl_list, dnssl[255] = {}; + size_t prev_l4_size = dp_packet_l4_size(b); + size_t size = sizeof(struct ovs_nd_dnssl); + struct ip6_hdr *nh = dp_packet_l3(b); + int i = 0; + + while ((t0 = strtok_r(r0, ",", &r0))) { + char *t1, *r1 = t0; + + size += strlen(t0) + 2; + while ((t1 = strtok_r(r1, ".", &r1))) { + dnssl[i++] = strlen(t1); + memcpy(&dnssl[i], t1, strlen(t1)); + i += strlen(t1); + } + dnssl[i++] = 0; + } + size = ROUND_UP(size, 8); + nh->ip6_plen = htons(prev_l4_size + size); + + struct ovs_nd_dnssl *nd_dnssl = dp_packet_put_uninit(b, sizeof *nd_dnssl); + nd_dnssl->type = ND_OPT_DNSSL; + nd_dnssl->len = size / 8; + nd_dnssl->reserved = 0; + put_16aligned_be32(&nd_dnssl->lifetime, lifetime); + + dp_packet_put(b, dnssl, size - sizeof *nd_dnssl); + + struct ovs_ra_msg *ra = dp_packet_l4(b); + ra->icmph.icmp6_cksum = 0; + uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b)); + ra->icmph.icmp6_cksum = csum_finish(csum_continue(icmp_csum, ra, + prev_l4_size + size)); +} + /* Called with in the pinctrl_handler thread context. */ static long long int ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) @@ -2382,6 +2429,10 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) packet_put_ra_rdnss_opt(&packet, 1, htonl(0xffffffff), &ra->config->rdnss); } + if (ra->config->dnssl.length) { + packet_put_ra_dnssl_opt(&packet, htonl(0xffffffff), + ra->config->dnssl.string); + } uint64_t ofpacts_stub[4096 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index 12cee6329..5fc370bf5 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -231,6 +231,17 @@ struct nd_rdnss_opt { }; BUILD_ASSERT_DECL(ND_RDNSS_OPT_LEN == sizeof(struct nd_rdnss_opt)); +/* DNSSL option RFC 6106 */ +#define ND_OPT_DNSSL 31 +#define ND_DNSSL_OPT_LEN 8 +struct ovs_nd_dnssl { + u_int8_t type; /* ND_OPT_DNSSL */ + u_int8_t len; /* >= 2 */ + ovs_be16 reserved; + ovs_16aligned_be32 lifetime; +}; +BUILD_ASSERT_DECL(ND_DNSSL_OPT_LEN == sizeof(struct ovs_nd_dnssl)); + #define DHCPV6_DUID_LL 3 #define DHCPV6_HW_TYPE_ETH 1 diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index d1de36e08..dbb279052 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6489,6 +6489,10 @@ copy_ra_to_sb(struct ovn_port *op, const char *address_mode) if (rdnss) { smap_add(&options, "ipv6_ra_rdnss", rdnss); } + const char *dnssl = smap_get(&op->nbrp->ipv6_ra_configs, "dnssl"); + if (dnssl) { + smap_add(&options, "ipv6_ra_dnssl", dnssl); + } smap_add(&options, "ipv6_ra_src_eth", op->lrp_networks.ea_s); diff --git a/ovn-nb.xml b/ovn-nb.xml index 2faf9390b..c49144848 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1890,6 +1890,11 @@ IPv6 address of RDNSS server announced in RA packets. At the moment OVN supports just one RDNSS server. + + + DNS Search List announced in RA packets. At the moment OVN supports + just one DNS Search entry + diff --git a/tests/ovn.at b/tests/ovn.at index 3e7692895..f4f5ddd5a 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -12538,14 +12538,15 @@ construct_expected_ra() { local mtu=$1 local ra_mo=$2 local rdnss=$3 - local ra_prefix_la=$4 + local dnssl=$4 + local ra_prefix_la=$5 local slla=0101${src_mac} local mtu_opt="" if test $mtu != 0; then mtu_opt=05010000${mtu} fi - shift 4 + shift 5 local prefix="" while [[ $# -gt 0 ]] ; do @@ -12559,8 +12560,12 @@ construct_expected_ra() { if test $rdnss != 0; then rdnss_opt=19030000ffffffff${rdnss} fi + local dnssl_opt="" + if test $dnssl != 0; then + dnssl_opt=1f030000ffffffff${dnssl} + fi - local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix}${rdnss_opt} + local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix}${rdnss_opt}${dnssl_opt} local icmp=8600XXXX${ra} local ip_len=$(expr ${#icmp} / 2) @@ -12595,28 +12600,33 @@ ra_test() { } # Baseline test with no MTU -ra_test 0 00 0 c0 40 aef00000000000000000000000000000 +ra_test 0 00 0 0 c0 40 aef00000000000000000000000000000 # Now make sure an MTU option makes it ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:mtu=1500 -ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000 +ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000 # Now test for multiple network prefixes ovn-nbctl --wait=hv set Logical_Router_port ro-sw networks='aef0\:\:1/64 fd0f\:\:1/48' -ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # Now test for RDNSS ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:rdnss='aef0::11' dns_addr=aef00000000000000000000000000011 -ra_test 000005dc 00 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 00 $dns_addr 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 + +# Now test for DNSSL +ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:dnssl="aa.bb.cc" +dnssl=02616102626202636300000000000000 +ra_test 000005dc 00 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 -# Test a different address mode now +## Test a different address mode now ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateful -ra_test 000005dc 80 $dns_addr 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 80 $dns_addr $dnssl 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # And the other address mode ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateless -ra_test 000005dc 40 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 40 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP