@@ -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:
@@ -2356,6 +2364,44 @@ packet_put_ra_rdnss_opt(struct dp_packet *b, uint8_t num,
prev_l4_size + size));
}
+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);
+ struct ip6_hdr *nh = dp_packet_l3(b);
+ size_t size = 8;
+ 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, size);
+ nd_dnssl->type = ND_OPT_DNSSL;
+ nd_dnssl->len = size / 8;
+ nd_dnssl->reserved = 0;
+ put_16aligned_be32(&nd_dnssl->lifetime, lifetime);
+ memcpy(&nd_dnssl->dnssl[0], dnssl, size);
+
+ 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)
@@ -2364,7 +2410,7 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra)
return ra->next_announce;
}
- uint64_t packet_stub[128 / 8];
+ uint64_t packet_stub[512 / 8];
struct dp_packet packet;
dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub);
compose_nd_ra(&packet, ra->config->eth_src, ra->config->eth_dst,
@@ -2384,6 +2430,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);
@@ -232,6 +232,18 @@ 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;
+ char dnssl[0];
+};
+BUILD_ASSERT_DECL(ND_DNSSL_OPT_LEN == sizeof(struct ovs_nd_dnssl));
+
#define DHCPV6_DUID_LL 3
#define DHCPV6_HW_TYPE_ETH 1
@@ -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);
@@ -1890,6 +1890,11 @@
IPv6 address of RDNSS server announced in RA packets. At the moment
OVN supports just one RDNSS server.
</column>
+
+ <column name="ipv6_ra_configs" key="dnssl">
+ DNS Search List announced in RA packets. At the moment OVN supports
+ just one DNS Search entry
+ </column>
</group>
<group title="Options">
@@ -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
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 <lorenzo.bianconi@redhat.com> --- controller/pinctrl.c | 52 +++++++++++++++++++++++++++++++++++++++++++- lib/ovn-l7.h | 12 ++++++++++ northd/ovn-northd.c | 4 ++++ ovn-nb.xml | 5 +++++ tests/ovn.at | 30 ++++++++++++++++--------- 5 files changed, 92 insertions(+), 11 deletions(-)