From patchwork Mon Jun 18 11:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 930814 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 418V294ddtz9s19 for ; Mon, 18 Jun 2018 21:57:05 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 190DDD6C; Mon, 18 Jun 2018 11:56:18 +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 041D8D63 for ; Mon, 18 Jun 2018 11:56:17 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4046A335 for ; Mon, 18 Jun 2018 11:56:16 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id x6-v6so13557094wmc.3 for ; Mon, 18 Jun 2018 04:56:16 -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=ty3vj8JKWgoz9vo0DU0I2f6UW8uS/1uOYXx2Vx8BnU4=; b=LCi5tH8ZXB6+8DBvUYR98V4EzKgilWl0LxlFCCJGr3grPTnELzYyNCz7UJzwGiBcwE imtf/99ox0dGndrLT9tMDM4Ro8Qqjf4eSsUJ+c7/9ABFzij+/34QuaQWBkYxL3ywvF7f M1DV+koAy5WH0vxNGllJUFJzw32oeOOdYKKzExVQOpEXmqLcFEEj6G84tT6u49jeoJHZ ud+fi9tZ/fr4Bc+/EkMT/BYUZz717ZMc88Q8w2ui4BjFQ4rKqWlRNkjMbl1SvE7DMauH bme4SBgYV+vyJqr8REuOXf4CWBXyh16D8e9UBQiup+9k2aA5oNZpD585j2S756J/o7Un i77g== X-Gm-Message-State: APt69E0CglHtgj1lRHhVKH4RmSo6UBawwhRG1QCuJxIt8cEs7QSh3wx3 kpb1TG7tXRcYgN4aWuHiYIM2I/Wpfc4= X-Google-Smtp-Source: ADUXVKI0oDqKKVmzSki0/zbztlEPCAVSOr1edgRrF0GyXaGOGNZoWoolden5mze0LxF8GBRrE67QTg== X-Received: by 2002:a1c:c342:: with SMTP id t63-v6mr8981056wmf.123.1529322974669; Mon, 18 Jun 2018 04:56:14 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id y30-v6sm17981450wrd.70.2018.06.18.04.56.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 04:56:14 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Mon, 18 Jun 2018 13:55:59 +0200 Message-Id: <75a3a4e16b50df6a036d13c81f39875c93c446cb.1529316047.git.lorenzo.bianconi@redhat.com> 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 v2 2/3] OVN: add TCP 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 TCP reset messages in reply to TCP datagrams directed to the router's IP address since the logical router doesn't accept any TCP traffic Signed-off-by: Lorenzo Bianconi --- ovn/northd/ovn-northd.8.xml | 4 ---- ovn/northd/ovn-northd.c | 29 ++++++++++++++++++++++++++++- tests/ovn.at | 31 +++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index a33de3d95..18a481b3d 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -1330,10 +1330,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 568d19b7d..27d7aab06 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -5147,7 +5147,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_cstr(&match), ds_cstr(&actions)); } - /* UDP port unreachable */ + /* UDP/TCP port unreachable */ for (int i = 0; i < op->lrp_networks.n_ipv4_addrs; i++) { const char *action; @@ -5164,6 +5164,17 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, "next; };"; ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 80, ds_cstr(&match), action); + + ds_clear(&match); + ds_put_format(&match, + "ip4 && ip4.dst == %s && !ip.later_frag && tcp", + op->lrp_networks.ipv4_addrs[i].addr_s); + action = "tcp_reset {" + "eth.dst <-> eth.src; " + "ip4.dst <-> ip4.src; " + "next; };"; + ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 80, + ds_cstr(&match), action); } ds_clear(&match); @@ -5285,6 +5296,22 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 90, ds_cstr(&match), ds_cstr(&actions)); } + + /* TCP port unreachable */ + for (int i = 0; i < op->lrp_networks.n_ipv6_addrs; i++) { + const char *action; + + ds_clear(&match); + ds_put_format(&match, + "ip6 && ip6.dst == %s && !ip.later_frag && tcp", + op->lrp_networks.ipv6_addrs[i].addr_s); + action = "tcp_reset {" + "eth.dst <-> eth.src; " + "ip6.dst <-> ip6.src; " + "next; };"; + ovn_lflow_add(lflows, op->od, S_ROUTER_IN_IP_INPUT, 80, + ds_cstr(&match), action); + } } /* NAT, Defrag and load balancing. */ diff --git a/tests/ovn.at b/tests/ovn.at index ee807f9c3..4648a303c 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -10379,6 +10379,34 @@ test_ip_packet() { as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet } +# test_tcp_syn_packet INPORT HV ETH_SRC ETH_DST IPV4_SRC IPV4_ROUTER 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 +# ETH_SRC, ETH_DST, IPV4_SRC, IPV4_ROUTER, IP_CHKSUM, TCP_SPORT, TCP_DPORT, TCP_CHKSUM as specified. +# EXP_IP_CHKSUM and EXP_TCP_RST_CHKSUM are the ip and tcp checksums of the tcp reset segment generated by OVN logical router +# +# INPORT is an lport number, e.g. 11 for vif11. +# HV is an hypervisor number +# ETH_SRC and ETH_DST are each 12 hex digits. +# IPV4_SRC and IPV4_ROUTER are each 8 hex digits. +# TCP_SPORT and TCP_DPORT are 4 hex digits. +# IP_CHKSUM, TCP_CHKSUM, EXP_IP_CHSUM and EXP_TCP_RST_CHKSUM are each 4 hex digits +test_tcp_syn_packet() { + local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 ipv4_src=$5 ip_router=$6 ip_chksum=$7 + local tcp_sport=$8 tcp_dport=$9 tcp_chksum=${10} + local exp_ip_chksum=${11} exp_tcp_rst_chksum=${12} + shift 12 + + local ip_ttl=ff + local packet=${eth_dst}${eth_src}08004500002800004000${ip_ttl}06${ip_chksum}${ipv4_src}${ip_router}${tcp_sport}${tcp_dport}000000010000000050027210${tcp_chksum}0000 + + local tcp_rst_ttl=fe + local reply=${eth_src}${eth_dst}08004500002800004000${tcp_rst_ttl}06${exp_ip_chksum}${ip_router}${ipv4_src}${tcp_dport}${tcp_sport}000000000000000150040000${exp_tcp_rst_chksum}0000 + echo $reply >> vif$inport.expected + + as hv$hv ovs-appctl netdev-dummy/receive vif$inport $packet +} + ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } @@ -10418,5 +10446,8 @@ 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]) +test_tcp_syn_packet 2 2 000000000002 00000000ff02 $(ip_to_hex 192 168 2 1) $(ip_to_hex 192 168 2 254) 0000 8b40 3039 0000 7bae 4486 +OVN_CHECK_PACKETS([hv2/vif2-tx.pcap], [vif2.expected]) + OVN_CLEANUP([hv1], [hv2]) AT_CLEANUP