[ovs-dev] [PATCH v2 ovn 1/2] DNSSL: copy dnssl string in order to avoid truncated value
Lorenzo Bianconi
lorenzo.bianconi at redhat.com
Tue Jan 7 16:50:05 UTC 2020
ipv6_ra_send can run 2 times in a row before prepare_ipv6_ras updates
the dnss list. Copy the dnss dynamic string in packet_put_ra_dnssl_opt
in order to avoid sending truncated dnssl list on the wire.
Moreover move ip6_hdr definition just before accessing it because the
packet can be reallocated if the data area is not big enough for packet
content
Fixes: 5a12a940f ("Add DNSSL support to OVN")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
---
controller/pinctrl.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/controller/pinctrl.c b/controller/pinctrl.c
index c886b21d9..1a577f62a 100644
--- a/controller/pinctrl.c
+++ b/controller/pinctrl.c
@@ -2413,14 +2413,15 @@ packet_put_ra_rdnss_opt(struct dp_packet *b, uint8_t num,
static void
packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
- char *dnssl_list)
+ char *dnssl_data)
{
+ char *dnssl_list, *t0, *r0 = NULL, 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);
- char *t0, *r0 = NULL, dnssl[255] = {};
int i = 0;
+ dnssl_list = xstrdup(dnssl_data);
+
/* Multiple DNS Search List must be 'comma' separated
* (e.g. "a.b.c, d.e.f"). Domain names must be encoded
* as described in Section 3.1 of RFC1035.
@@ -2433,7 +2434,7 @@ packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
size += strlen(t0) + 2;
if (size > sizeof(dnssl)) {
- return;
+ goto out;
}
for (t1 = strtok_r(t0, ".", &r1); t1;
@@ -2445,6 +2446,8 @@ packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
dnssl[i++] = 0;
}
size = ROUND_UP(size, 8);
+
+ struct ip6_hdr *nh = dp_packet_l3(b);
nh->ip6_plen = htons(prev_l4_size + size);
struct ovs_nd_dnssl *nd_dnssl = dp_packet_put_uninit(b, sizeof *nd_dnssl);
@@ -2460,6 +2463,8 @@ packet_put_ra_dnssl_opt(struct dp_packet *b, ovs_be32 lifetime,
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));
+out:
+ free(dnssl_list);
}
static void
@@ -2567,7 +2572,7 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra)
}
if (ra->config->dnssl.length) {
packet_put_ra_dnssl_opt(&packet, htonl(0xffffffff),
- ra->config->dnssl.string);
+ ds_cstr(&ra->config->dnssl));
}
if (ra->config->route_info.length) {
packet_put_ra_route_info_opt(&packet, htonl(0xffffffff),
--
2.21.1
More information about the dev
mailing list