From patchwork Thu Jun 18 16:49:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1312319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=T/9mPcM7; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49nnxl13mPz9sRN for ; Fri, 19 Jun 2020 02:50:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6C2A9896DA; Thu, 18 Jun 2020 16:50:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pbQ+ROg7y-Gd; Thu, 18 Jun 2020 16:50:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id E3353896AB; Thu, 18 Jun 2020 16:50:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A90BBC07FF; Thu, 18 Jun 2020 16:50:46 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AA834C016E for ; Thu, 18 Jun 2020 16:50:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id A001787C60 for ; Thu, 18 Jun 2020 16:50:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id czMMgJuqGHw5 for ; Thu, 18 Jun 2020 16:50:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 21AB487C9D for ; Thu, 18 Jun 2020 16:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592499006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j1/lhL6PdgVKgsHjXxauMXf8loFto2Hs2gaVI0B05wg=; b=T/9mPcM7+/aIYmw/MLqfp9BVXPwK9Qmw96QPWftNQU9FFkHFT65Nemh8g3GBSTv4hvWSpg s31e/cMMyuuyZdf8YtfEUzMCvTWQg60Khp1xHhr5T1HYbk1KVCIsY30+JnaSe0FlVG6/KL sfRVHkzJ3WRbBwU9ONN8VIgkrtQxI3k= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-Y_7JEjWZMi-kO7HiGzdvmw-1; Thu, 18 Jun 2020 12:50:02 -0400 X-MC-Unique: Y_7JEjWZMi-kO7HiGzdvmw-1 Received: by mail-wm1-f70.google.com with SMTP id j128so2827008wmj.6 for ; Thu, 18 Jun 2020 09:50:02 -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:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j1/lhL6PdgVKgsHjXxauMXf8loFto2Hs2gaVI0B05wg=; b=Y3MtBLmjFr+h+ayOdUwqR5EQ5lmlKDdDEGwhzHscukwogGTwAk+tnZyQfRvZZCXZxz 9Z6IebrnV/DEooLpJWnNZOd0+Dq7bnDUjYnTIFkqvT/nNnMajT681qEKf26Rtg/SJHqi VePwDG15mAKsV53rsoKlV39MNMBX6I2dkHKn387K1hLjAZyIY/kQa3MVWjvD1GnnhzqN QNBrZg/25/PnwVdv3NkgVYyz42t3XbElLOq4LNpeEiQWaqNgdMjFzmZkIHt24c0M6dL/ 16fNk9U0+9hBS8AWldzko3ZHQOLEd66uBtvhS7PHvB7YXr6JLA8tjdv7a7VD0tkzO/sl XDSg== X-Gm-Message-State: AOAM531SuLybJm6od7JPMdzp/FEcQA1ROsRl4REjhuKDOb/9+HgA5vH1 HQZKwT4Zk413bnDSttEf7mZuP3pG1xYLMbCcRtGDKt+8jVt66ZnGaKT+95C3VqLYlcPKjNjTpOF MzOE/Nb2uLCU6NG/C2Q== X-Received: by 2002:adf:ed05:: with SMTP id a5mr2469406wro.176.1592499001218; Thu, 18 Jun 2020 09:50:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj7J4cwVxC8UTfCf8c3srKrlZZu432Iq6wKrHxBG7Krojzh1Oqwm1AB1ifdbFDxUz5aiZAxQ== X-Received: by 2002:adf:ed05:: with SMTP id a5mr2469378wro.176.1592499000811; Thu, 18 Jun 2020 09:50:00 -0700 (PDT) Received: from localhost.localdomain.com ([151.48.140.182]) by smtp.gmail.com with ESMTPSA id h13sm298097wrp.77.2020.06.18.09.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 09:50:00 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Thu, 18 Jun 2020 18:49:51 +0200 Message-Id: <97c8e3abe50f9c82ebfb6fbfddd60b1b65ed3aab.1592498902.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn] northd: set packet length in check_pkt_larger() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Set packet length in lr_in_chk_pkt_len router pipeline instead of gw interface MTU since ovs kernel datapath usually works on L2 frames Fixes: 7d42c146be ("ovn: Generate ICMPv4 packet in router pipeline for larger packets") Signed-off-by: Lorenzo Bianconi --- Changes since v1: - rely on macros for L2 header size - fix comment --- northd/ovn-northd.c | 7 +++---- tests/ovn.at | 33 ++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 6a9b097e5..40aeb0a58 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -10082,7 +10082,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_clear(&actions); ds_put_format(&actions, REGBIT_PKT_LARGER" = check_pkt_larger(%d);" - " next;", gw_mtu); + " next;", gw_mtu + VLAN_ETH_HEADER_LEN); ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_CHK_PKT_LEN, 50, ds_cstr(&match), ds_cstr(&actions), &od->l3dgw_port->nbrp->header_); @@ -10100,8 +10100,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, rp->json_key, od->l3dgw_port->json_key); ds_clear(&actions); - /* Set icmp4.frag_mtu to gw_mtu - 58. 58 is the Geneve tunnel - * overhead. */ + /* Set icmp4.frag_mtu to gw_mtu */ ds_put_format(&actions, "icmp4_error {" REGBIT_EGRESS_LOOPBACK" = 1; " @@ -10115,7 +10114,7 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, "next(pipeline=ingress, table=0); };", rp->lrp_networks.ea_s, rp->lrp_networks.ipv4_addrs[0].addr_s, - gw_mtu - 18); + gw_mtu); ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_LARGER_PKTS, 50, ds_cstr(&match), ds_cstr(&actions), &rp->nbrp->header_); diff --git a/tests/ovn.at b/tests/ovn.at index 7622b745b..8ee348397 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14873,14 +14873,16 @@ test_ip_packet_larger() { dst_mac="00000000ff01" # sw0-lr0 mac (internal router leg) src_ip=`ip_to_hex 10 0 0 3` dst_ip=`ip_to_hex 172 168 0 3` - # Set the packet length to 100. - pkt_len=0064 - packet=${dst_mac}${src_mac}08004500${pkt_len}0000000040010000 + # Set the packet length to 118. + pkt_len=0076 + packet=${dst_mac}${src_mac}08004500${pkt_len}000000004001c3d9 orig_packet_l3=${src_ip}${dst_ip}0304000000000000 orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 + orig_packet_l3=${orig_packet_l3}000000000000000000000000000000000000 + packet=${packet}${orig_packet_l3} gw_ip_garp=ffffffffffff00002020121308060001080006040001000020201213aca80064000000000000aca80064 @@ -14890,32 +14892,33 @@ test_ip_packet_larger() { # localnet port. # If icmp_pmtu_reply_expected is 1, it means the packet is larger than # the gateway mtu and ovn-controller should drop the packet and instead - # generate ICMPv4 Destination Unreachable message with pmtu set to 42. + # generate ICMPv4 Destination Unreachable message with pmtu set to 100. if test $icmp_pmtu_reply_expected = 0; then # Packet to expect at br-phys. src_mac="000020201213" dst_mac="00000012af11" src_ip=`ip_to_hex 10 0 0 3` dst_ip=`ip_to_hex 172 168 0 3` - expected=${dst_mac}${src_mac}08004500${pkt_len}000000003f010100 + expected=${dst_mac}${src_mac}08004500${pkt_len}000000003f01c4d9 expected=${expected}${src_ip}${dst_ip}0304000000000000 expected=${expected}000000000000000000000000000000000000 expected=${expected}000000000000000000000000000000000000 expected=${expected}000000000000000000000000000000000000 expected=${expected}000000000000000000000000000000000000 + expected=${expected}000000000000000000000000000000000000 echo $expected > br_phys_n1.expected echo $gw_ip_garp >> br_phys_n1.expected else - # MTU would be 100 - 18 = 82 (hex 0052) - mtu=0052 + # MTU would be 118 - 18 = 100 (hex 0064) + mtu=0064 src_ip=`ip_to_hex 10 0 0 1` dst_ip=`ip_to_hex 10 0 0 3` - # pkt len should be 128 (28 (icmp packet) + 100 (orig ip + payload)) - reply_pkt_len=0080 - ip_csum=bd91 - icmp_reply=${src_mac}${dst_mac}08004500${reply_pkt_len}00004000fe016879 + # pkt len should be 146 (28 (icmp packet) + 118 (orig ip + payload)) + reply_pkt_len=0092 + ip_csum=f993 + icmp_reply=${src_mac}${dst_mac}08004500${reply_pkt_len}00004000fe016867 icmp_reply=${icmp_reply}${src_ip}${dst_ip}0304${ip_csum}0000${mtu} - icmp_reply=${icmp_reply}4500${pkt_len}000000003f010100 + icmp_reply=${icmp_reply}4500${pkt_len}000000003f01c4d9 icmp_reply=${icmp_reply}${orig_packet_l3} echo $icmp_reply > hv1-vif1.expected fi @@ -14955,12 +14958,12 @@ awk '{print $3}') ovn-sbctl create MAC_Binding ip=172.168.0.3 datapath=$dp_uuid \ logical_port=lr0-public mac="00\:00\:00\:12\:af\:11" -# Set the gateway mtu to 100. If the packet length is > 100, ovn-controller +# Set the gateway mtu to 100. If the packet length is > 118, ovn-controller # should send icmp host not reachable with pmtu set to 100. ovn-nbctl --wait=hv set logical_router_port lr0-public options:gateway_mtu=100 as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply OVS_WAIT_UNTIL([ - test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(100)" | \ + test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(118)" | \ wc -l` -eq 1 ]) @@ -14971,7 +14974,7 @@ test_ip_packet_larger $icmp_reply_expected ovn-nbctl --wait=hv set logical_router_port lr0-public options:gateway_mtu=500 as hv3 ovs-appctl netdev-dummy/receive hv3-vif1 $arp_reply OVS_WAIT_UNTIL([ - test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(500)" | \ + test `as hv1 ovs-ofctl dump-flows br-int | grep "check_pkt_larger(518)" | \ wc -l` -eq 1 ])