From patchwork Tue Jan 7 16:50:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1218911 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.136; helo=silver.osuosl.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="LQp5Iwgc"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47sdgG71w1z9sRG for ; Wed, 8 Jan 2020 03:51:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4C2FE20420; Tue, 7 Jan 2020 16:51:05 +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 agmblSpI2Qgq; Tue, 7 Jan 2020 16:51:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 4D310203C4; Tue, 7 Jan 2020 16:51:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3B474C1D84; Tue, 7 Jan 2020 16:51:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id F16FFC1D82 for ; Tue, 7 Jan 2020 16:51:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id DFFED85487 for ; Tue, 7 Jan 2020 16:51:01 +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 QjxPqmZvWqss for ; Tue, 7 Jan 2020 16:50:59 +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 [207.211.31.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DC8B381A25 for ; Tue, 7 Jan 2020 16:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578415820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sh76yMFA7J6eVf0buySwbhD2watDM0ycIJPziOuz/tQ=; b=LQp5Iwgc/Eo7ukfi+PMOoZ6RZh2IXgMB9gGxsbfodfE9cqVrj7h5HPerlzjtTXQ8I7rF0n e3ajRDakr2w4nIRTaeF92A0jY/O22ML+SiU+domuyJ7iBF9GruxSbGxzDxbsd8x+yNCLPf 83SNQqsv/ppC/KiSDFIVo/+LlDNA8hQ= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-x4vy_HchOmSSd3NK7zag_g-1; Tue, 07 Jan 2020 11:50:19 -0500 Received: by mail-wm1-f72.google.com with SMTP id g26so37028wmk.6 for ; Tue, 07 Jan 2020 08:50:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sFVN5kYY1Nob8wA1+W9RnMxU2l8NqEUuGiyz4M/OXOg=; b=ljfY2iQatY6mNzbjdjUTYVJtmJXXx5BNeDw4AO78+HXeY4hKI/UzfUt5V75UhLTOxL o2hYaHTPhxlS8QPxTSnUWVq5yIOph0QjKeqnN5O/ipW3DGkApnmxjeBhJHnncq4FQY4X G01F2sWGB7WIGjcStHf+CllPAGhbtlW21FWyouXTUmzqqx1QYdDMTBt366Ak3T24XMYV bpPS1EfDMb0bY9iV9122Prx8h0bf+Li7N0OHuTzmz9yqOsZSDJm/Q54kBQGDNgP5N747 z4Vd9QYE/mZUpC2yEBZZfCXyeA2Kn5F1i0+fvQnLpUPOR8K0K9Y8BXiVPRPmQB4AzGwy hYJg== X-Gm-Message-State: APjAAAXHQdBK9MDJzNAssvleF0zf1EdI4TQWtGeHRSUClXt7bnMcZiUn D873Jb0NxI0a6pF/7436YpW8u2hTtvCvWeZwmDeEWa0LdMZ4HwtuLSf/QWMcc1U1fBOr9pLJIUg q7fjH8cypFgpx X-Received: by 2002:adf:9104:: with SMTP id j4mr111436941wrj.221.1578415817849; Tue, 07 Jan 2020 08:50:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwbI1nFd97wYT9AbFP/FiC+XUQrF2p7nggGriTWFrnFArAYwXySCP4YGBfP4mZuhh1wSqQdTw== X-Received: by 2002:adf:9104:: with SMTP id j4mr111436927wrj.221.1578415817632; Tue, 07 Jan 2020 08:50:17 -0800 (PST) Received: from new-host-3.redhat.com (net-2-42-61-77.cust.vodafonedsl.it. [2.42.61.77]) by smtp.gmail.com with ESMTPSA id n1sm487436wrw.52.2020.01.07.08.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:50:17 -0800 (PST) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Tue, 7 Jan 2020 17:50:05 +0100 Message-Id: <3082041e3162d3882bfb946dead94bd1b75d072e.1578414443.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: x4vy_HchOmSSd3NK7zag_g-1 X-Mimecast-Spam-Score: 0 Subject: [ovs-dev] [PATCH v2 ovn 1/2] DNSSL: copy dnssl string in order to avoid truncated value 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" 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 --- 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), From patchwork Tue Jan 7 16:50:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1218910 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.138; helo=whitealder.osuosl.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="alNfw3bP"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47sdgD5LQbz9sRf for ; Wed, 8 Jan 2020 03:51:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5CBCA86005; Tue, 7 Jan 2020 16:51:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RNZYtb53ZCch; Tue, 7 Jan 2020 16:51:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 9C9EA85FC4; Tue, 7 Jan 2020 16:51:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9361DC1D82; Tue, 7 Jan 2020 16:51:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id C219BC0881 for ; Tue, 7 Jan 2020 16:50:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id AE25985569 for ; Tue, 7 Jan 2020 16:50:59 +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 sXvKwLCzDKDm for ; Tue, 7 Jan 2020 16:50:58 +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 [207.211.31.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 377C585495 for ; Tue, 7 Jan 2020 16:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578415826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+6Rw2S6Jn4dYXXaxmGIoyXHtzSVsLQE29QO0XF3P7OY=; b=alNfw3bPWywzM5gkXZIa66SauU30QHEcgYTqVAnNIDG5FasrKHewKWJHLWVFVymiiFVrf/ HBaYC4sRHpmHvEnZsVQWkduP5ql+BqZXQcM3YH3445Jl/HUTJkz36WOQjPJsyZoAuB/X5d zP6SBw9MRCCdqTfRomY4cTx7bL81jWM= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-mmCyQV-7PFSRXb2zraUepw-1; Tue, 07 Jan 2020 11:50:20 -0500 Received: by mail-wr1-f70.google.com with SMTP id l20so183883wrc.13 for ; Tue, 07 Jan 2020 08:50:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qFwmHvL5JD5CbR17BpsK+vcM39ls4LvO2Q9VzS0VKYY=; b=hLIF4UCe6QrhlAYdiEJm6WBeIfbkvq+dtK+l1KLaXBfNkOgDa+B6K36j33xTZdukwt 5jeouExV++ie7cfZbT+l6/EO8F7KhWKJS11hLFZbTzz8SNGQoeivDusorHVyTmIHpc4G u8gKfPGzqllGR2yMqVSackQtaYXrLbvp/SlA6sbriAwVu1VsgUB++JebqFi++OujJZEQ vJBdlJpZhINY7u1bI7TUOvyo3dhMyCdlt3ynklLzEeIEOAd6mPlo0vgAgD8ldKkrSOLv vWBMq0M3hpsKn9PBPiDbjMD3w9uU6osLvswWFw+9B36gU57FmQeeUVkjj40pfflKkdo0 aifg== X-Gm-Message-State: APjAAAXd8vd69XM2pjmSfW5lo+JXR2+mLLaSHXskyzfrCAz8ACFyP0x2 AqomfgEqYnUltobqiU3onwnwF3ybc7uIV5/4giEDMElTvcguwYVYgeK8gwbnqchZPPpc6VjBEUg y1Sr9yv7b0lpw X-Received: by 2002:adf:bc87:: with SMTP id g7mr1990572wrh.121.1578415819529; Tue, 07 Jan 2020 08:50:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz8M4WWY4dAEry6mzVqxzT8723WPPFBhfB4alCUevtLxhhTs4TaEpa11rp58FKASpD1fJeGMA== X-Received: by 2002:adf:bc87:: with SMTP id g7mr1990553wrh.121.1578415819252; Tue, 07 Jan 2020 08:50:19 -0800 (PST) Received: from new-host-3.redhat.com (net-2-42-61-77.cust.vodafonedsl.it. [2.42.61.77]) by smtp.gmail.com with ESMTPSA id n1sm487436wrw.52.2020.01.07.08.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 08:50:18 -0800 (PST) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Tue, 7 Jan 2020 17:50:06 +0100 Message-Id: <8bc6b374e3a80fcac7a8a92951ae629ad6879d49.1578414443.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: mmCyQV-7PFSRXb2zraUepw-1 X-Mimecast-Spam-Score: 0 Subject: [ovs-dev] [PATCH v2 ovn 2/2] RA Route Info Option: copy route info string in order to avoid truncated value 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" ipv6_ra_send can run 2 times in a row before prepare_ipv6_ras updates the route info. Copy route info string in packet_put_ra_route_info_opt in order to avoid sending truncated route info 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: 9f7f466af ("Add support for Route Info Option in RA - RFC 4191") Signed-off-by: Lorenzo Bianconi --- controller/pinctrl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 1a577f62a..c4752c673 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2469,13 +2469,14 @@ out: static void packet_put_ra_route_info_opt(struct dp_packet *b, ovs_be32 lifetime, - char *route_list) + char *route_data) { size_t prev_l4_size = dp_packet_l4_size(b); - struct ip6_hdr *nh = dp_packet_l3(b); - char *t0, *r0 = NULL; + char *route_list, *t0, *r0 = NULL; size_t size = 0; + route_list = xstrdup(route_data); + for (t0 = strtok_r(route_list, ",", &r0); t0; t0 = strtok_r(NULL, ",", &r0)) { struct ovs_nd_route_info nd_rinfo; @@ -2503,11 +2504,11 @@ packet_put_ra_route_info_opt(struct dp_packet *b, ovs_be32 lifetime, uint8_t plen; if (!extract_ip_addresses(t1, &route)) { - return; + goto out; } if (!route.n_ipv6_addrs) { destroy_lport_addresses(&route); - return; + goto out; } nd_rinfo.prefix_len = route.ipv6_addrs->plen; @@ -2522,17 +2523,20 @@ packet_put_ra_route_info_opt(struct dp_packet *b, ovs_be32 lifetime, break; } default: - return; + goto out; } } } + struct ip6_hdr *nh = dp_packet_l3(b); nh->ip6_plen = htons(prev_l4_size + 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)); +out: + free(route_list); } /* Called with in the pinctrl_handler thread context. */ @@ -2576,7 +2580,7 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) } if (ra->config->route_info.length) { packet_put_ra_route_info_opt(&packet, htonl(0xffffffff), - ra->config->route_info.string); + ds_cstr(&ra->config->route_info)); } uint64_t ofpacts_stub[4096 / 8];