From patchwork Fri Jun 15 09:49:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 929836 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 416bLw4Mc3z9s19 for ; Fri, 15 Jun 2018 19:50:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 67C47E7E; Fri, 15 Jun 2018 09:49:22 +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 E4563E3F for ; Fri, 15 Jun 2018 09:49:21 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 168A65A5 for ; Fri, 15 Jun 2018 09:49:21 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id v131-v6so2782839wma.1 for ; Fri, 15 Jun 2018 02:49:20 -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=p6hXRUNH918WGy/wXT4FnYyGGwZmH2ZB1fHDH8N9/E4=; b=kWIwJYYOOcju7j/yZM+SKjZy2uXhJJ89UIuFywNtPgDS1S9rvUPgkc1vtwwOklnkfW abwQx1lWheKCfyWNTct44/xstK+U9c8e30Sl48rHZH8NpShTRr21NWe9zJLQhVqW1nUM DuuE0i3/AXMpFWF7En9S+pngSwx80QbRFlPPzQDK//p34EkvxOi3IaT1PGFoc0NGmNik X6AhkNpLS6b/Q/jjwSe2BDardIfS3OgAii3rB/RGV7sVMqQogmwDUxM/9oP16HdeooAE ylGAhmBsnkD1rIcqdRBiz/KykYkBTOxArqyqHhbrUvJoAfKfEQhY4/956SM3Dd5WeUrl 6R8A== X-Gm-Message-State: APt69E3WMZeukKgV8uLqkpnnFHUUktbjChgVPgKfc/vPRvtksQtFP2Aa e75vm9sqgqCnUaWn0sIaehednB7xZ+4= X-Google-Smtp-Source: ADUXVKJH5RaEC+hkrQRZMQTXECCdvj6YPC6Q+IX6dZfKNCu9kyIh8ceWKc2XmyKbhieGHSDUk2zosw== X-Received: by 2002:a1c:1808:: with SMTP id 8-v6mr738257wmy.113.1529056159402; Fri, 15 Jun 2018 02:49:19 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id c53-v6sm17646770wrg.12.2018.06.15.02.49.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 02:49:18 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Fri, 15 Jun 2018 11:49:07 +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 1/3] OVN: add UDP port unreachable 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 Add priority-80 flows to generate ICMP port unreachable messages in reply to UDP datagrams directed to the router's IP address since the logical router doesn't accept any UDP traffic Signed-off-by: Lorenzo Bianconi --- ovn/northd/ovn-northd.8.xml | 4 -- ovn/northd/ovn-northd.c | 20 ++++++++++ tests/ovn.at | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index 759d3dace..a33de3d95 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -1317,10 +1317,6 @@ nd_na {

These flows should not match IP fragments with nonzero offset.

- -

- Details TBD. Not yet implemented. -

  • diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 74eefc6ca..0e137efde 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -5147,6 +5147,26 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_cstr(&match), ds_cstr(&actions)); } + /* UDP port unreachable */ + for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) { + ds_clear(&match); + ds_clear(&actions); + + ds_put_format(&match, + "ip4 && ip4.dst == %s && !ip.later_frag && udp", + op->lrp_networks.ipv4_addrs[i].addr_s); + ds_put_format(&actions, + "icmp4 {" + "eth.dst <-> eth.src; " + "ip4.dst <-> ip4.src; " + "ip.ttl = 255; " + "icmp4.type = 3; " + "icmp4.code = 3; " + "next; };"); + ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 80, + ds_cstr(&match), ds_cstr(&actions)); + } + ds_clear(&match); ds_put_cstr(&match, "ip4.dst == {"); bool has_drop_ips = false; diff --git a/tests/ovn.at b/tests/ovn.at index b586afb4e..ee807f9c3 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -10344,3 +10344,79 @@ OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [vif1.expected]) OVN_CLEANUP([hv1], [hv2]) AT_CLEANUP + +AT_SETUP([ovn -- router port unreachable]) +AT_KEYWORDS([router-port-unreachable]) +AT_SKIP_IF([test $HAVE_PYTHON = no]) +ovn_start + +# test_ip_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_ROUTER L4_PROTCOL IP_CHKSUM EXP_IP_CHKSUM EXP_ICMP_CHKSUM EXP_ICMP_CODE +# +# Causes a packet to be received on INPORT of the hypervisor HV. The packet is an IPv4 packet with +# ETH_SRC, ETH_DST, IPV4_SRC, IPV4_ROUTER, L4_PROTCOL, IP_CHKSUM as specified. +# EXP_IP_CHKSUM and EXP_ICMP_CHKSUM are the ip and icmp checksums of the icmp frame generated by OVN logical router +# EXP_ICMP_CODE are code and type of the icmp frame generated by OVN logical router +# +# INPORT is a lport number, e.g. 11 for vif11. +# HV is a hypervisor number +# ETH_SRC and ETH_DST are each 12 hex digits. +# IPV4_SRC and IPV4_ROUTER are each 8 hex digits. +# IP_CHKSUM, EXP_IP_CHSUM and EXP_ICMP_CHKSUM are each 4 hex digits +test_ip_packet() { + local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ip_router=$6 l4_proto=$7 ip_chksum=$8 + local exp_ip_chksum=$9 exp_icmp_chksum=${10} exp_icmp_code=${11} + shift 11 + + local ip_ttl=ff + local packet=${eth_dst}${eth_src}08004500001400004000${ip_ttl}${l4_proto}${ip_chksum}${ipv4_src}${ip_router} + + local reply_icmp_ttl=fe + local icmp_data=00000000 + local reply_icmp_payload=${exp_icmp_code}${exp_icmp_chksum}${icmp_data} + local reply=${eth_src}${eth_dst}08004500001c00004000${reply_icmp_ttl}01${exp_ip_chksum}${ip_router}${ipv4_src}${reply_icmp_payload} + echo $reply >> vif$inport.expected + + as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet +} + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + +for i in 1 2; do + net_add n$i + ovn-nbctl ls-add sw$i + + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovn_attach n$i br-phys 192.168.$i.1 + + ovn-nbctl lsp-add sw$i sw$i-p${i}0 -- \ + lsp-set-addresses sw$i-p${i}0 "00:00:00:00:00:0$i 192.168.$i.1" + + ovs-vsctl -- add-port br-int vif$i -- \ + set interface vif$i \ + external-ids:iface-id=sw$i-p${i}0 \ + options:tx_pcap=hv$i/vif$i-tx.pcap \ + options:rxq_pcap=hv$i/vif$i-rx.pcap \ + ofport-request=$i +done + +ovn-nbctl lr-add lr0 +for i in 1 2; do + ovn-nbctl lrp-add lr0 lrp$i 00:00:00:00:ff:0$i 192.168.$i.254/24 + ovn-nbctl -- lsp-add sw$i lrp$i-attachment \ + -- set Logical_Switch_Port lrp$i-attachment type=router \ + options:router-port=lrp$i addresses='"00:00:00:00:ff:'0$i'"' +done + +OVN_POPULATE_ARP +# allow some time for ovn-northd and ovn-controller to catch up. +ovn-nbctl --wait=hv sync + +test_ip_packet 1 1 000000000001 00000000ff01 $(ip_to_hex 192 168 1 1) $(ip_to_hex 192 168 1 254) 11 0000 7dae fcfc 0303 +OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [vif1.expected]) + +OVN_CLEANUP([hv1], [hv2]) +AT_CLEANUP