From patchwork Mon Jul 2 15:19:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 937988 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 41K9sT1pZ4z9s4Z for ; Tue, 3 Jul 2018 01:19:39 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2D5BFEEE; Mon, 2 Jul 2018 15:19:37 +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 AF5BBEE5 for ; Mon, 2 Jul 2018 15:19:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 2B2A8A3 for ; Mon, 2 Jul 2018 15:19:35 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id p1-v6so15958677wrs.9 for ; Mon, 02 Jul 2018 08:19:35 -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=V6oZlyIUDsU/9FbVIVp9/rcyes+RKE7rfJnvxbz4tso=; b=iDZmPH/xRu2KfGeEc/H+aoO3CWh8COeNgQTTbJMoB2Y6ESco8PFYMxJxA/9PVog89B r6s/L6D5lxoOqQuaDx1fRZwFnbMdMTpqaj+jcM61Fo61LovNMZpCCi5Sf8reTYdF4B73 EavKJM/RTPE2M5FMDyRYsTP4d6qlk+HCu1b9zMyLBUeGHZKMXXYgJDtih+BCs/bmdG91 QoqBo19+mLt69gYVKZ1CbMd/URFFqoOuXnFMVhPZCImJoQlz4y0v8zY16iYVyFJz1joU nX0+ax7Fxtkl+32HHc9w2MTMUIlvJdWEszRxP+tkguB+VPhhtJ4zdCDT5xSA+p/3ZV2B xlKA== X-Gm-Message-State: APt69E3Zg7XIOmm5HoLJ+ju9Kj1dpuDiKAprZ1dru0rWqZZn1yxQVAWY d6d60G46xBwHmaWDQKJa7d5wAUBp07U= X-Google-Smtp-Source: AAOMgpeH1W8WwuhVI9s6LJo9u5tPZ06LgBGgeBUxpHFevQaq9mKwq7GPMgW6ysmvujRvxzfK0ADwTA== X-Received: by 2002:adf:9883:: with SMTP id w3-v6mr21418094wrb.9.1530544773460; Mon, 02 Jul 2018 08:19:33 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id q8-v6sm3851237wmb.3.2018.07.02.08.19.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Jul 2018 08:19:32 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Mon, 2 Jul 2018 17:19:22 +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, RCVD_IN_DNSWL_NONE 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] OVN: add ICMPv6 time exceeded support to OVN logical router 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 Using icmp6 action, send an ICMPv6 time exceeded frame whenever an OVN logical router receives an IPv6 packets whose TTL has expired (ip.ttl == {0, 1}) Signed-off-by: Lorenzo Bianconi --- ovn/northd/ovn-northd.8.xml | 12 +++++++++++- ovn/northd/ovn-northd.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index 4d0bab476..08e0325a0 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -1383,7 +1383,8 @@ nd_na { address is A, a priority-40 flow with match inport == P && ip.ttl == {0, 1} && !ip.later_frag matches packets whose TTL has expired, with the - following actions to send an ICMP time exceeded reply: + following actions to send an ICMP time exceeded reply for IPv4 and + IPv6 respectively:

@@ -1395,6 +1396,15 @@ icmp4 {
     ip.ttl = 255;
     next;
 };
+
+icmp6 {
+    icmp6.type = 3; /* Time exceeded. */
+    icmp6.code = 0;  /* TTL exceeded in transit. */
+    ip6.dst = ip6.src;
+    ip6.src = A;
+    ip.ttl = 255;
+    next;
+};
         
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 2febf7b8e..8ed0c4987 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -5328,6 +5328,37 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_cstr(&match), action); } } + + /* ICMPv6 time exceeded */ + for (int i = 0; i < op->lrp_networks.n_ipv6_addrs; i++) { + /* skip link-local address */ + if (in6_is_lla(&op->lrp_networks.ipv6_addrs[i].network)) { + continue; + } + + ds_clear(&match); + ds_clear(&actions); + + ds_put_format(&match, + "inport == %s && ip6 && " + "ip6.src == %s/%d && " + "ip.ttl == {0, 1} && !ip.later_frag", + op->json_key, + op->lrp_networks.ipv6_addrs[i].network_s, + op->lrp_networks.ipv6_addrs[i].plen); + ds_put_format(&actions, + "icmp6 {" + "eth.dst <-> eth.src; " + "ip6.dst = ip6.src; " + "ip6.src = %s; " + "ip.ttl = 255; " + "icmp6.type = 3; /* Time exceeded */ " + "icmp6.code = 0; /* TTL exceeded in transit */ " + "next; };", + op->lrp_networks.ipv6_addrs[i].addr_s); + ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 40, + ds_cstr(&match), ds_cstr(&actions)); + } } /* NAT, Defrag and load balancing. */