From patchwork Fri Apr 6 17:05:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 895768 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 40HmLz59Tgz9s0x for ; Sat, 7 Apr 2018 03:06:35 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 78DC4F49; Fri, 6 Apr 2018 17:05:54 +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 BBC6BF45 for ; Fri, 6 Apr 2018 17:05:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 493FB66F for ; Fri, 6 Apr 2018 17:05:52 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id g20-v6so993177plo.9 for ; Fri, 06 Apr 2018 10:05:52 -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=cwAqu5beb+T2kNhlofCNaUaZ7Oy0AxPCKAgt4mIjzTQ=; b=kKzljuprPLTaUGU3gyagiQwH+21Nso9J/CmVV+5Fkr4Ss00mfcWPH8bWZqmkSh/QBK Ey+jLczc1UkR2EYiIrgvCYLi6k26Yr4Lyj4mnr03+akN34vIOIcVp9MgPgLqFsrhI1Jt hFyh18H2U909XX+KCxdUX0663SDaXGf4VcJv3CPjazrG/WEWEGT89FQT597m0B1YDVk/ hM8vsUfmOGyOrxUhU/gXVDQk/5S0cqpAGOkdp87OXk2FU5zhsaxHVM3jGYv4N2aCwQCJ vhHxHVpNleOPL2+Lse01ShpBYju0LxDX5aXN2KNJSiye/Ffx4NWdaXWaZqlbmBXo1MNb 8bPQ== X-Gm-Message-State: AElRT7GLR/Fzbc/ciwRUuZmyhpjddSlS7TNPygi8xbqTje94zTmJy6Sr ZCPyHRguET7HHJ1oBqXrBirIlWwPSzU= X-Google-Smtp-Source: AIpwx4+7sPMVXQHMFgkHBm1INglCv8oiLP4IgPEKfKUBWNTQG0XFiIqeo2KpeyiJyf3Yiq4jwo5Qvg== X-Received: by 2002:a17:902:d205:: with SMTP id t5-v6mr26766158ply.381.1523034351770; Fri, 06 Apr 2018 10:05:51 -0700 (PDT) Received: from wlan-180-84.mxp.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id m11sm19763349pgc.30.2018.04.06.10.05.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Apr 2018 10:05:51 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Fri, 6 Apr 2018 19:05:33 +0200 Message-Id: <3071dbab24b800637904911c3c47668ef074d905.1523033721.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.14.3 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 2/2] OVN: add icmp6 action to ovn acl reject support 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 Whenever the acl reject rule is hit by an IPv6 packet send back an ICMPv6 destination unreachable packet using the icmp6 action Signed-off-by: Lorenzo Bianconi --- ovn/northd/ovn-northd.c | 25 ++++++++++++++++++++++--- tests/ovn.at | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 9ca15bc2f..845faba86 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -2912,10 +2912,12 @@ build_pre_acls(struct ovn_datapath *od, struct hmap *lflows) * unreachable packets. */ ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_ACL, 110, "nd || nd_rs || nd_ra || icmp4.type == 3 || " - "(tcp && tcp.flags == 4)", "next;"); + "icmp6.type == 1 || (tcp && tcp.flags == 4)", + "next;"); ovn_lflow_add(lflows, od, S_SWITCH_OUT_PRE_ACL, 110, "nd || nd_rs || nd_ra || icmp4.type == 3 || " - "(tcp && tcp.flags == 4)", "next;"); + "icmp6.type == 1 || (tcp && tcp.flags == 4)", + "next;"); /* Ingress and Egress Pre-ACL Table (Priority 100). * @@ -3131,7 +3133,7 @@ build_reject_acl_rules(struct ovn_datapath *od, struct hmap *lflows, ovn_lflow_add(lflows, od, stage, acl->priority + OVN_ACL_PRI_OFFSET + 10, ds_cstr(&match), ds_cstr(&actions)); - /* IPv4 traffic */ + /* IP traffic */ ds_clear(&match); ds_clear(&actions); build_acl_log(&actions, acl); @@ -3148,6 +3150,23 @@ build_reject_acl_rules(struct ovn_datapath *od, struct hmap *lflows, ingress ? "output;" : "next(pipeline=ingress,table=0);"); ovn_lflow_add(lflows, od, stage, acl->priority + OVN_ACL_PRI_OFFSET, ds_cstr(&match), ds_cstr(&actions)); + ds_clear(&match); + ds_clear(&actions); + build_acl_log(&actions, acl); + if (extra_match->length > 0) { + ds_put_format(&match, "(%s) && ", extra_match->string); + } + ds_put_format(&match, "ip6 && (%s)", acl->match); + if (extra_actions->length > 0) { + ds_put_format(&actions, "%s ", extra_actions->string); + } + ds_put_format(&actions, "reg0 = 0; icmp6 { " + "eth.dst <-> eth.src; ip6.dst <-> ip6.src; " + "outport <-> inport; %s };", + ingress ? "output;" : "next(pipeline=ingress,table=0);"); + ovn_lflow_add(lflows, od, stage, acl->priority + OVN_ACL_PRI_OFFSET, + ds_cstr(&match), ds_cstr(&actions)); + ds_destroy(&match); ds_destroy(&actions); } diff --git a/tests/ovn.at b/tests/ovn.at index 0b23e3bcc..a37e6f140 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -9412,6 +9412,24 @@ test_ip_packet() { as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet } +# test_ipv6_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST EXP_ICMP_CHKSUM +# +# Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv6 packet with +# ETH_SRC, ETH_DST, IPV6_SRC, IPV6_DST as specified. +# EXP_ICMP_CHKSUM is the icmp6 checksums of the icmp6 destination unreachable frame generated from ACL rule hit +test_ipv6_packet() { + local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv6_src=$5 ipv6_dst=$6 exp_icmp_chksum=$7 + shift 7 + + local ip6_hdr=6000000000083aff${ipv6_src}${ipv6_dst} + local packet=${eth_dst}${eth_src}86dd${ip6_hdr}0000000000000000 + + local reply=${eth_src}${eth_dst}86dd6000000000303aff${ipv6_dst}${ipv6_src}0101${exp_icmp_chksum}00000000${ip6_hdr} + echo $reply >> vif$inport.expected + + as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet +} + # test_tcp_syn_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_DST IP_CHKSUM TCP_SPORT TCP_DPORT TCP_CHKSUM EXP_IP_CHKSUM EXP_TCP_RST_CHKSUM # # Causes a packet to be received on INPORT of the hypervisor HV. The packet is an TCP syn segment with @@ -9486,6 +9504,8 @@ test_ip_packet 11 1 000000000011 000000000021 $(ip_to_hex 192 168 1 11) $(ip_to_ test_ip_packet 21 2 000000000021 000000000011 $(ip_to_hex 192 168 1 21) $(ip_to_hex 192 168 1 11) 0000 7d8d fcfe test_ip_packet 31 3 000000000031 000000000012 $(ip_to_hex 192 168 1 31) $(ip_to_hex 192 168 1 12) 0000 7d82 fcfe +test_ipv6_packet 11 1 000000000011 000000000021 fe80000000000000020001fffe000001 fe80000000000000020001fffe000002 6183 + test_tcp_syn_packet 11 1 000000000011 000000000021 $(ip_to_hex 192 168 1 11) $(ip_to_hex 192 168 1 21) 0000 8b40 3039 0000 7d8d 4486 test_tcp_syn_packet 21 2 000000000021 000000000011 $(ip_to_hex 192 168 1 21) $(ip_to_hex 192 168 1 11) 0000 8b40 3039 0000 7d8d 4486 test_tcp_syn_packet 31 3 000000000031 000000000012 $(ip_to_hex 192 168 1 31) $(ip_to_hex 192 168 1 12) 0000 8b40 3039 0000 7d82 4486