|
|
bbaaef |
From 5a12a940f63a5909baee6d00ce9e1696a2e7c96c Mon Sep 17 00:00:00 2001
|
|
|
bbaaef |
Message-Id: <5a12a940f63a5909baee6d00ce9e1696a2e7c96c.1572427188.git.lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
Date: Tue, 29 Oct 2019 13:18:34 +0100
|
|
|
bbaaef |
Subject: [PATCH ovn] Add DNSSL support to OVN
|
|
|
bbaaef |
|
|
|
bbaaef |
Introduce the possibility to specify a DNSSL option to Router
|
|
|
bbaaef |
Advertisement packets. DNS Search list can be specified using
|
|
|
bbaaef |
'dnssl' tag in the ipv6_ra_configs column of logical router
|
|
|
bbaaef |
port table
|
|
|
bbaaef |
|
|
|
bbaaef |
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
bbaaef |
---
|
|
|
bbaaef |
ovn/controller/pinctrl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
bbaaef |
ovn/lib/ovn-l7.h | 11 ++++++++
|
|
|
bbaaef |
ovn/northd/ovn-northd.c | 4 +++
|
|
|
bbaaef |
ovn/ovn-nb.xml | 5 ++++
|
|
|
bbaaef |
tests/ovn.at | 30 ++++++++++++++-------
|
|
|
bbaaef |
5 files changed, 103 insertions(+), 10 deletions(-)
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/ovn/controller/pinctrl.c
|
|
|
bbaaef |
+++ b/ovn/controller/pinctrl.c
|
|
|
bbaaef |
@@ -2198,6 +2198,7 @@ struct ipv6_ra_config {
|
|
|
bbaaef |
struct lport_addresses prefixes;
|
|
|
bbaaef |
struct in6_addr rdnss;
|
|
|
bbaaef |
bool has_rdnss;
|
|
|
bbaaef |
+ struct ds dnssl;
|
|
|
bbaaef |
};
|
|
|
bbaaef |
|
|
|
bbaaef |
struct ipv6_ra_state {
|
|
|
bbaaef |
@@ -2219,6 +2220,7 @@ ipv6_ra_config_delete(struct ipv6_ra_con
|
|
|
bbaaef |
{
|
|
|
bbaaef |
if (config) {
|
|
|
bbaaef |
destroy_lport_addresses(&config->prefixes);
|
|
|
bbaaef |
+ ds_destroy(&config->dnssl);
|
|
|
bbaaef |
free(config);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
}
|
|
|
bbaaef |
@@ -2257,6 +2259,7 @@ ipv6_ra_update_config(const struct sbrec
|
|
|
bbaaef |
nd_ra_min_interval_default(config->max_interval));
|
|
|
bbaaef |
config->mtu = smap_get_int(&pb->options, "ipv6_ra_mtu", ND_MTU_DEFAULT);
|
|
|
bbaaef |
config->la_flags = IPV6_ND_RA_OPT_PREFIX_ON_LINK;
|
|
|
bbaaef |
+ ds_init(&config->dnssl);
|
|
|
bbaaef |
|
|
|
bbaaef |
const char *address_mode = smap_get(&pb->options, "ipv6_ra_address_mode");
|
|
|
bbaaef |
if (!address_mode) {
|
|
|
bbaaef |
@@ -2302,6 +2305,11 @@ ipv6_ra_update_config(const struct sbrec
|
|
|
bbaaef |
}
|
|
|
bbaaef |
config->has_rdnss = !!rdnss;
|
|
|
bbaaef |
|
|
|
bbaaef |
+ const char *dnssl = smap_get(&pb->options, "ipv6_ra_dnssl");
|
|
|
bbaaef |
+ if (dnssl) {
|
|
|
bbaaef |
+ ds_put_buffer(&config->dnssl, dnssl, strlen(dnssl));
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+
|
|
|
bbaaef |
return config;
|
|
|
bbaaef |
|
|
|
bbaaef |
fail:
|
|
|
bbaaef |
@@ -2358,6 +2366,57 @@ packet_put_ra_rdnss_opt(struct dp_packet
|
|
|
bbaaef |
prev_l4_size + len * 8));
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
+static void
|
|
|
bbaaef |
+packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
|
|
|
bbaaef |
+ char *dnssl_list)
|
|
|
bbaaef |
+{
|
|
|
bbaaef |
+ size_t prev_l4_size = dp_packet_l4_size(b);
|
|
|
bbaaef |
+ size_t size = sizeof(struct ovs_nd_dnssl);
|
|
|
bbaaef |
+ struct ip6_hdr *nh = dp_packet_l3(b);
|
|
|
bbaaef |
+ char *t0, *r0, dnssl[255] = {};
|
|
|
bbaaef |
+ int i = 0;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ /* Multiple DNS Search List must be 'comma' separated
|
|
|
bbaaef |
+ * (e.g. "a.b.c, d.e.f"). Domain names must be encoded
|
|
|
bbaaef |
+ * as described in Section 3.1 of RFC1035.
|
|
|
bbaaef |
+ * (e.g if dns list is a.b.c,www.ovn.org, it will be encoded as:
|
|
|
bbaaef |
+ * 01 61 01 62 01 63 00 03 77 77 77 03 6f 76 63 03 6f 72 67 00
|
|
|
bbaaef |
+ */
|
|
|
bbaaef |
+ for (t0 = strtok_r(dnssl_list, ",", &r0;; t0;
|
|
|
bbaaef |
+ t0 = strtok_r(NULL, ",", &r0)) {
|
|
|
bbaaef |
+ char *t1, *r1;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ size += strlen(t0) + 2;
|
|
|
bbaaef |
+ if (size > sizeof(dnssl)) {
|
|
|
bbaaef |
+ return;
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ for (t1 = strtok_r(t0, ".", &r1;; t1;
|
|
|
bbaaef |
+ t1 = strtok_r(NULL, ".", &r1)) {
|
|
|
bbaaef |
+ dnssl[i++] = strlen(t1);
|
|
|
bbaaef |
+ memcpy(&dnssl[i], t1, strlen(t1));
|
|
|
bbaaef |
+ i += strlen(t1);
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ dnssl[i++] = 0;
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ size = ROUND_UP(size, 8);
|
|
|
bbaaef |
+ nh->ip6_plen = htons(prev_l4_size + size);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ struct ovs_nd_dnssl *nd_dnssl = dp_packet_put_uninit(b, sizeof *nd_dnssl);
|
|
|
bbaaef |
+ nd_dnssl->type = ND_OPT_DNSSL;
|
|
|
bbaaef |
+ nd_dnssl->len = size / 8;
|
|
|
bbaaef |
+ nd_dnssl->reserved = 0;
|
|
|
bbaaef |
+ put_16aligned_be32(&nd_dnssl->lifetime, lifetime);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ dp_packet_put(b, dnssl, size - sizeof *nd_dnssl);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ struct ovs_ra_msg *ra = dp_packet_l4(b);
|
|
|
bbaaef |
+ ra->icmph.icmp6_cksum = 0;
|
|
|
bbaaef |
+ uint32_t icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
|
|
|
bbaaef |
+ ra->icmph.icmp6_cksum = csum_finish(csum_continue(icmp_csum, ra,
|
|
|
bbaaef |
+ prev_l4_size + size));
|
|
|
bbaaef |
+}
|
|
|
bbaaef |
+
|
|
|
bbaaef |
/* Called with in the pinctrl_handler thread context. */
|
|
|
bbaaef |
static long long int
|
|
|
bbaaef |
ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra)
|
|
|
bbaaef |
@@ -2386,6 +2445,10 @@ ipv6_ra_send(struct rconn *swconn, struc
|
|
|
bbaaef |
packet_put_ra_rdnss_opt(&packet, 1, htonl(0xffffffff),
|
|
|
bbaaef |
&ra->config->rdnss);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
+ if (ra->config->dnssl.length) {
|
|
|
bbaaef |
+ packet_put_ra_dnssl_opt(&packet, htonl(0xffffffff),
|
|
|
bbaaef |
+ ra->config->dnssl.string);
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
|
|
|
bbaaef |
uint64_t ofpacts_stub[4096 / 8];
|
|
|
bbaaef |
struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub);
|
|
|
bbaaef |
--- a/ovn/lib/ovn-l7.h
|
|
|
bbaaef |
+++ b/ovn/lib/ovn-l7.h
|
|
|
bbaaef |
@@ -231,6 +231,17 @@ struct nd_rdnss_opt {
|
|
|
bbaaef |
};
|
|
|
bbaaef |
BUILD_ASSERT_DECL(ND_RDNSS_OPT_LEN == sizeof(struct nd_rdnss_opt));
|
|
|
bbaaef |
|
|
|
bbaaef |
+/* DNSSL option RFC 6106 */
|
|
|
bbaaef |
+#define ND_OPT_DNSSL 31
|
|
|
bbaaef |
+#define ND_DNSSL_OPT_LEN 8
|
|
|
bbaaef |
+struct ovs_nd_dnssl {
|
|
|
bbaaef |
+ u_int8_t type; /* ND_OPT_DNSSL */
|
|
|
bbaaef |
+ u_int8_t len; /* >= 2 */
|
|
|
bbaaef |
+ ovs_be16 reserved;
|
|
|
bbaaef |
+ ovs_16aligned_be32 lifetime;
|
|
|
bbaaef |
+};
|
|
|
bbaaef |
+BUILD_ASSERT_DECL(ND_DNSSL_OPT_LEN == sizeof(struct ovs_nd_dnssl));
|
|
|
bbaaef |
+
|
|
|
bbaaef |
#define DHCPV6_DUID_LL 3
|
|
|
bbaaef |
#define DHCPV6_HW_TYPE_ETH 1
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
+++ b/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
@@ -6477,6 +6477,10 @@ copy_ra_to_sb(struct ovn_port *op, const
|
|
|
bbaaef |
if (rdnss) {
|
|
|
bbaaef |
smap_add(&options, "ipv6_ra_rdnss", rdnss);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
+ const char *dnssl = smap_get(&op->nbrp->ipv6_ra_configs, "dnssl");
|
|
|
bbaaef |
+ if (dnssl) {
|
|
|
bbaaef |
+ smap_add(&options, "ipv6_ra_dnssl", dnssl);
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
|
|
|
bbaaef |
smap_add(&options, "ipv6_ra_src_eth", op->lrp_networks.ea_s);
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/ovn/ovn-nb.xml
|
|
|
bbaaef |
+++ b/ovn/ovn-nb.xml
|
|
|
bbaaef |
@@ -1890,6 +1890,11 @@
|
|
|
bbaaef |
IPv6 address of RDNSS server announced in RA packets. At the moment
|
|
|
bbaaef |
OVN supports just one RDNSS server.
|
|
|
bbaaef |
</column>
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ <column name="ipv6_ra_configs" key="dnssl">
|
|
|
bbaaef |
+ DNS Search List announced in RA packets. Multiple DNS Search List
|
|
|
bbaaef |
+ must be 'comma' separated (e.g. "a.b.c, d.e.f")
|
|
|
bbaaef |
+ </column>
|
|
|
bbaaef |
</group>
|
|
|
bbaaef |
|
|
|
bbaaef |
<group title="Options">
|
|
|
bbaaef |
--- a/tests/ovn.at
|
|
|
bbaaef |
+++ b/tests/ovn.at
|
|
|
bbaaef |
@@ -12522,14 +12522,15 @@ construct_expected_ra() {
|
|
|
bbaaef |
local mtu=$1
|
|
|
bbaaef |
local ra_mo=$2
|
|
|
bbaaef |
local rdnss=$3
|
|
|
bbaaef |
- local ra_prefix_la=$4
|
|
|
bbaaef |
+ local dnssl=$4
|
|
|
bbaaef |
+ local ra_prefix_la=$5
|
|
|
bbaaef |
|
|
|
bbaaef |
local slla=0101${src_mac}
|
|
|
bbaaef |
local mtu_opt=""
|
|
|
bbaaef |
if test $mtu != 0; then
|
|
|
bbaaef |
mtu_opt=05010000${mtu}
|
|
|
bbaaef |
fi
|
|
|
bbaaef |
- shift 4
|
|
|
bbaaef |
+ shift 5
|
|
|
bbaaef |
|
|
|
bbaaef |
local prefix=""
|
|
|
bbaaef |
while [[ $# -gt 0 ]] ; do
|
|
|
bbaaef |
@@ -12543,8 +12544,12 @@ construct_expected_ra() {
|
|
|
bbaaef |
if test $rdnss != 0; then
|
|
|
bbaaef |
rdnss_opt=19030000ffffffff${rdnss}
|
|
|
bbaaef |
fi
|
|
|
bbaaef |
+ local dnssl_opt=""
|
|
|
bbaaef |
+ if test $dnssl != 0; then
|
|
|
bbaaef |
+ dnssl_opt=1f030000ffffffff${dnssl}
|
|
|
bbaaef |
+ fi
|
|
|
bbaaef |
|
|
|
bbaaef |
- local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix}${rdnss_opt}
|
|
|
bbaaef |
+ local ra=ff${ra_mo}ffff0000000000000000${slla}${mtu_opt}${prefix}${rdnss_opt}${dnssl_opt}
|
|
|
bbaaef |
local icmp=8600XXXX${ra}
|
|
|
bbaaef |
|
|
|
bbaaef |
local ip_len=$(expr ${#icmp} / 2)
|
|
|
bbaaef |
@@ -12579,28 +12584,33 @@ ra_test() {
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
# Baseline test with no MTU
|
|
|
bbaaef |
-ra_test 0 00 0 c0 40 aef00000000000000000000000000000
|
|
|
bbaaef |
+ra_test 0 00 0 0 c0 40 aef00000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
# Now make sure an MTU option makes it
|
|
|
bbaaef |
ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:mtu=1500
|
|
|
bbaaef |
-ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000
|
|
|
bbaaef |
+ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
# Now test for multiple network prefixes
|
|
|
bbaaef |
ovn-nbctl --wait=hv set Logical_Router_port ro-sw networks='aef0\:\:1/64 fd0f\:\:1/48'
|
|
|
bbaaef |
-ra_test 000005dc 00 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
+ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
# Now test for RDNSS
|
|
|
bbaaef |
ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:rdnss='aef0::11'
|
|
|
bbaaef |
dns_addr=aef00000000000000000000000000011
|
|
|
bbaaef |
-ra_test 000005dc 00 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
+ra_test 000005dc 00 $dns_addr 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+# Now test for DNSSL
|
|
|
bbaaef |
+ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:dnssl="aa.bb.cc"
|
|
|
bbaaef |
+dnssl=02616102626202636300000000000000
|
|
|
bbaaef |
+ra_test 000005dc 00 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
-# Test a different address mode now
|
|
|
bbaaef |
+## Test a different address mode now
|
|
|
bbaaef |
ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateful
|
|
|
bbaaef |
-ra_test 000005dc 80 $dns_addr 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
+ra_test 000005dc 80 $dns_addr $dnssl 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
# And the other address mode
|
|
|
bbaaef |
ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateless
|
|
|
bbaaef |
-ra_test 000005dc 40 $dns_addr c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
+ra_test 000005dc 40 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000
|
|
|
bbaaef |
|
|
|
bbaaef |
OVN_CLEANUP([hv1],[hv2])
|
|
|
bbaaef |
AT_CLEANUP
|