From patchwork Fri Dec 23 05:58:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Benli Ye X-Patchwork-Id: 708379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3tlHl30tqzz9srY for ; Fri, 23 Dec 2016 16:58:55 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D2B80B43; Fri, 23 Dec 2016 05:58:51 +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 22969360 for ; Fri, 23 Dec 2016 05:58:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EX13-EDG-OU-001.vmware.com (ex13-edg-ou-001.vmware.com [208.91.0.189]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AB8DED5 for ; Fri, 23 Dec 2016 05:58:49 +0000 (UTC) Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Thu, 22 Dec 2016 21:57:30 -0800 Received: from EX13-CAS-006.vmware.com (smtp-inbound.vmware.com [10.113.191.56]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 0047518428; Thu, 22 Dec 2016 21:58:48 -0800 (PST) Received: from ubuntu.eng.vmware.com (10.113.170.11) by EX13-MBX-005.vmware.com (10.113.191.25) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Thu, 22 Dec 2016 21:58:45 -0800 From: Benli Ye To: , , , Date: Thu, 22 Dec 2016 21:58:00 -0800 Message-ID: <1482472681-69569-1-git-send-email-daniely@vmware.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.113.170.11] X-ClientProxiedBy: EX13-CAS-005.vmware.com (10.113.191.55) To EX13-MBX-005.vmware.com (10.113.191.25) Received-SPF: None (EX13-EDG-OU-001.vmware.com: daniely@vmware.com does not designate permitted sender hosts) X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD 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 1/2] sflow: restrict sampling from 1 to UINT32_MAX 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When sampling field is 0, no need to generate sample or the inner action. Signed-off-by: Benli Ye --- ofproto/ofproto-dpif-xlate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 08a72a7..3eb94ac 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -2506,6 +2506,11 @@ compose_sample_action(struct xlate_ctx *ctx, const odp_port_t tunnel_out_port, bool include_actions) { + if (probability == 0) { + /* No need to generate sampling or the inner action. */ + return 0; + } + size_t sample_offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_SAMPLE);