From patchwork Wed Mar 3 03:49:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1446489 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.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cuzpPsYO; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dr18V0XZLz9sSC for ; Wed, 3 Mar 2021 15:23:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3D7FD6F610; Wed, 3 Mar 2021 04:23:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p7CPlC5oszrc; Wed, 3 Mar 2021 04:23:32 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 293DC605AA; Wed, 3 Mar 2021 04:23:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ED793C000A; Wed, 3 Mar 2021 04:23:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id E1A4CC0001 for ; Wed, 3 Mar 2021 04:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BB4714E3C5 for ; Wed, 3 Mar 2021 04:23:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m0Nqmo5-dc1l for ; Wed, 3 Mar 2021 04:23:28 +0000 (UTC) X-Greylist: delayed 00:23:20 by SQLgrey-1.8.0 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by smtp4.osuosl.org (Postfix) with ESMTPS id 556804CA27 for ; Wed, 3 Mar 2021 04:23:28 +0000 (UTC) Received: by mail-qk1-x731.google.com with SMTP id f124so4610723qkj.5 for ; Tue, 02 Mar 2021 20:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n+FdfMpdQbcQDliIw/LbktABwFZN+LpsfogCv570Ijk=; b=cuzpPsYOojPfU67AO6QUED3AFio51ztWwNav6tT77LcVlfiRCVYtRcGiJHxMlK2lwp Y6u5hJtW5tf5L4Eu/soDAId0wKa2ItVwHxjU9BTCdjLuhETZbbP22XoB82QJf/UF2/Rk /4Og+ssd0y9ry/R7/JakoinDEeH/MOaOgP7jY/Y/LLRh4sbaR4E8C0EeTHIBYAzG8uJU VjwLN9WNTdV9aq4TAzQCweeeMWPZyg/Uit/vQsmrkimBCD0WnLjQF6wotcFIv3YvWGNx DPbxkXjcLmoL9z9h/LmIPkhCsOA+kSh5hcYeZ6+VqebKWV5eSU6ooCOZgzqiCkF1J16I lTew== 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:in-reply-to :references; bh=n+FdfMpdQbcQDliIw/LbktABwFZN+LpsfogCv570Ijk=; b=JlQmWWsvH0VG6hJAyogNkxELu5flU7M+0q4VSRYZLLYfAyKy3jkF3HDSRGxEEc7DWG elPAXQQIS+ErbYHife5JO0QzxVhivB04X38YVQJ4boGAfnXLramJf9oF5QDsmyTxuZrs lOhvw0XEgl1FdUkleDfI4GckVUYr0xEIV8zEf6oe3GxNIYJ74UbSj8x/qPMwiI9L1ZPy MkGt9xyH/6XAGhEgWvacDsXTCK9SeGLsyrEW1MCKruKsWkpk0crv1GXJMPWvMmu2pBKa Rxcwo63ICQDUakr2OoJIAMAR+QD+CCBnSl7YsqHsy6Ikr409foPgyBu8aZViSyYdcvgW W+Gw== X-Gm-Message-State: AOAM531otHva0btYoTceMjpTQ9ns0NFxlRvRd8Bw+sDAlvjBoWHr+OqA 1x3QALCV4pLFMe7YVUrmlaoafr9YpGY= X-Google-Smtp-Source: ABdhPJx0sbvbw41qWWks0uT2k09Z2OZA6HKj22345BZGpWQwRiCMTFdbxeHO4T1tFCY7ekXlH7+P+g== X-Received: by 2002:a05:622a:3cf:: with SMTP id k15mr21432553qtx.368.1614743521902; Tue, 02 Mar 2021 19:52:01 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id c7sm14388828qtc.82.2021.03.02.19.51.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Mar 2021 19:52:01 -0800 (PST) From: xiangxia.m.yue@gmail.com To: i.maximets@ovn.org, blp@ovn.org, u9012063@gmail.com, horms@ovn.org Date: Wed, 3 Mar 2021 11:49:03 +0800 Message-Id: <20210303034904.13223-4-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20210303034904.13223-1-xiangxia.m.yue@gmail.com> References: <20210303034904.13223-1-xiangxia.m.yue@gmail.com> Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ovs v3 3/4] dpif-netdev: Add the burst size to buckets. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang For now, the meter of the userspace datapath, don't include the bucket burst size to total buckets. This patch includes it now. $ ovs-ofctl -O OpenFlow13 add-meter br0 \ 'meter=1 pktps burst stats bands=type=drop rate=10000 burst_size=2000' Signed-off-by: Tonghao Zhang --- lib/dpif-netdev.c | 5 ++-- tests/dpif-netdev.at | 63 ++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 77df376a26bc..e53ed31b906c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -6207,7 +6207,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, uint64_t max_bucket_size; band = &meter->bands[m]; - max_bucket_size = band->rate * 1000ULL; + max_bucket_size = (band->rate + band->burst_size) * 1000ULL; /* Update band's bucket. */ band->bucket += (uint64_t) delta_t * band->rate; if (band->bucket > max_bucket_size) { @@ -6335,7 +6335,8 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id meter_id, meter->bands[i].rate = config->bands[i].rate; meter->bands[i].burst_size = config->bands[i].burst_size; /* Start with a full bucket. */ - meter->bands[i].bucket = meter->bands[i].rate * 1000ULL; + meter->bands[i].bucket = + (meter->bands[i].burst_size + meter->bands[i].rate) * 1000ULL; /* Figure out max delta_t that is enough to fill any bucket. */ band_max_delta_t diff --git a/tests/dpif-netdev.at b/tests/dpif-netdev.at index a30d026cabe1..b2ff69a01ee6 100644 --- a/tests/dpif-netdev.at +++ b/tests/dpif-netdev.at @@ -299,60 +299,59 @@ type=drop rate=1 burst_size=2 ]) ovs-appctl time/warp 5000 -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) +for i in `seq 1 7`; do + AT_CHECK([ovs-appctl netdev-dummy/receive p7 \ + 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) +done + +for i in `seq 1 5`; do + AT_CHECK([ovs-appctl netdev-dummy/receive p8 \ + 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) +done + sleep 1 # wait for forwarders process packets # Meter 1 is measuring packets, allowing one packet per second with -# bursts of one packet, so 4 out of 5 packets should hit the drop +# bursts of one packet, so 3 out of 5 packets should hit the drop # band. -# Meter 2 is measuring kbps, with burst size 2 (== 1000 bits). 2 packets -# (120 bytes == 960 bits) pass, but the last packet should hit the drop band. +# Meter 2 is measuring kbps, with burst size 2 (== 3000 bits). 6 packets +# (360 bytes == 2880 bits) pass, but the last packet should hit the drop band. AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl OFPST_METER reply (OF1.3) (xid=0x2): meter:1 flow_count:1 packet_in_count:5 byte_in_count:300 duration:0.0s bands: -0: packet_count:4 byte_count:240 - -meter:2 flow_count:1 packet_in_count:5 byte_in_count:300 duration:0.0s bands: 0: packet_count:3 byte_count:180 + +meter:2 flow_count:1 packet_in_count:7 byte_in_count:420 duration:0.0s bands: +0: packet_count:1 byte_count:60 ]) # Advance time by 1/2 second ovs-appctl time/warp 500 -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p7 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) -AT_CHECK([ovs-appctl netdev-dummy/receive p8 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) +for i in `seq 1 5`; do + AT_CHECK([ovs-appctl netdev-dummy/receive p7 \ + 'in_port(7),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) + + AT_CHECK([ovs-appctl netdev-dummy/receive p8 \ + 'in_port(8),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.3,dst=10.0.0.4,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' --len 60]) + +done + sleep 1 # wait for forwarders process packets # Meter 1 is measuring packets, allowing one packet per second with # bursts of one packet, so all 5 of the new packets should hit the drop # band. -# Meter 2 is measuring kbps, with burst size 2 (== 1000 bits). After 500ms -# there should be space for 40 + 500 bits, so one new 60 byte (480 bit) packet +# Meter 2 is measuring kbps, with burst size 2 (== 3000 bits). After 500ms +# there should be space for 120 + 500 bits, so one new 60 byte (480 bit) packet # should pass, remaining 4 should hit the drop band. AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0 | strip_timers], [0], [dnl OFPST_METER reply (OF1.3) (xid=0x2): meter:1 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands: -0: packet_count:9 byte_count:540 +0: packet_count:8 byte_count:480 -meter:2 flow_count:1 packet_in_count:10 byte_in_count:600 duration:0.0s bands: -0: packet_count:7 byte_count:420 +meter:2 flow_count:1 packet_in_count:12 byte_in_count:720 duration:0.0s bands: +0: packet_count:5 byte_count:300 ]) ovs-appctl time/warp 5000 @@ -360,7 +359,7 @@ ovs-appctl time/warp 5000 AT_CHECK([ ovs-appctl coverage/read-counter datapath_drop_meter ], [0], [dnl -16 +13 ]) AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout_keep_actions], [0], [dnl