From patchwork Fri Sep 14 15:19:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 969920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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 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 42BfNK4l4Sz9s3l for ; Sat, 15 Sep 2018 01:20:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 6748CD3D; Fri, 14 Sep 2018 15:19:41 +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 D5BE7CD7 for ; Fri, 14 Sep 2018 15:19:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 40E937E5 for ; Fri, 14 Sep 2018 15:19:40 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id b19-v6so2326380wme.3 for ; Fri, 14 Sep 2018 08:19:40 -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; bh=aMWa0uq5jtTN94A2wZLD8siLqCbLFeGznOnobuBtvM8=; b=NuACua5PmChEgs3AX8vytq5ts584oQRdxmcT6YHhrJJoLzwul+gS2BD10c0JN8cZl9 Tn+ynJqSghqfyYVlXA3NLcPNrXgnzawzMrUI5sdu0HoMfxHN0u7qONu+7QnjAw8jAB0h o0/E7R/tRrdKY92F4nKDMxfk/ldvnIPwyqNU4s0TmMrqY+nstucAUzIkZoXBkl1DVHB4 opxyVUQtaXm/dgElehdKDrOHCmDrSWXyYS7qXta4dFPVhG14MBU762quRra8ETyOlNkm FJyJe5VtvZn1imw70yVv0hpzyJp5r9P8tdaxS7GR9IRdLSCmumsuV/agNkpJXxCjnu9J ELhA== X-Gm-Message-State: APzg51CZczZSOy9DCNyoPJ73qpCW2FBePheqee5gaznsC7kzVQ6ZWcyL gfyZ6nUQwqPDLUnNtb74XqmMwAhhlb0= X-Google-Smtp-Source: ANB0VdaTyhkfBKzopZXb6JSDhdaClnXnByuts+6mbyIzTgQI1u4wHcsNgKxOHUkVVkDB0eG7rKyrKw== X-Received: by 2002:a1c:1bca:: with SMTP id b193-v6mr2915602wmb.6.1536938378566; Fri, 14 Sep 2018 08:19:38 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id k63-v6sm4116584wmd.46.2018.09.14.08.19.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Sep 2018 08:19:38 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Fri, 14 Sep 2018 17:19:25 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 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 2/2] OVN: add buffering support for ipv6 packets 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Add buffering support for IPv6 packets that will be processed by nd_ns {} action when L2 address is not discovered yet since otherwise the packet will be substituted with a Neighbor Solicitation frame and this will result in the lost of the first packet of the connection Signed-off-by: Lorenzo Bianconi --- ovn/controller/pinctrl.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 3f8c0ac4e..6436be428 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -99,6 +99,7 @@ static void pinctrl_handle_put_nd_ra_opts( struct ofputil_packet_in *pin, struct ofpbuf *userdata, struct ofpbuf *continuation); static void pinctrl_handle_nd_ns(const struct flow *ip_flow, + struct dp_packet *pkt_in, const struct match *md, struct ofpbuf *userdata); static void init_ipv6_ras(void); @@ -1358,7 +1359,8 @@ process_packet_in(const struct ofp_header *msg, break; case ACTION_OPCODE_ND_NS: - pinctrl_handle_nd_ns(&headers, &pin.flow_metadata, &userdata); + pinctrl_handle_nd_ns(&headers, &packet, &pin.flow_metadata, + &userdata); break; case ACTION_OPCODE_ICMP: @@ -2569,9 +2571,13 @@ pinctrl_handle_nd_na(const struct flow *ip_flow, const struct match *md, } static void -pinctrl_handle_nd_ns(const struct flow *ip_flow, const struct match *md, - struct ofpbuf *userdata) +pinctrl_handle_nd_ns(const struct flow *ip_flow, struct dp_packet *pkt_in, + const struct match *md, struct ofpbuf *userdata) { + struct dp_packet *clone, packet; + uint64_t packet_stub[128 / 8]; + char ip[INET6_ADDRSTRLEN]; + /* This action only works for IPv6 packets. */ if (get_dl_type(ip_flow) != htons(ETH_TYPE_IPV6)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); @@ -2579,8 +2585,27 @@ pinctrl_handle_nd_ns(const struct flow *ip_flow, const struct match *md, return; } - uint64_t packet_stub[128 / 8]; - struct dp_packet packet; + inet_ntop(AF_INET6, &ip_flow->ipv6_dst, ip, sizeof(ip)); + uint32_t hash = hash_string(ip, 0); + struct buffered_packets *bp = pinctrl_find_buffered_packets(ip, hash); + if (!bp) { + if (hmap_count(&buffered_packets_map) >= 1000) { + COVERAGE_INC(pinctrl_drop_buffered_packets_map); + goto send_ns; + } + + bp = xmalloc(sizeof *bp); + hmap_insert(&buffered_packets_map, &bp->hmap_node, hash); + ovs_strlcpy_arrays(bp->ip, ip); + bp->head = bp->tail = 0; + } + bp->timestamp = time_msec(); + /* clone the packet to send it later with correct L2 address */ + clone = dp_packet_clone_data(dp_packet_data(pkt_in), + dp_packet_size(pkt_in)); + buffered_push_packet(bp, clone, md); + +send_ns: dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub); compose_nd_ns(&packet, ip_flow->dl_src, &ip_flow->ipv6_src,