From patchwork Mon May 27 11:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eelco Chaudron X-Patchwork-Id: 1939854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=NkizHYJe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vnt5M3tgTz20KL for ; Mon, 27 May 2024 21:02:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C3BA140BF5; Mon, 27 May 2024 11:02:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id TpzA6v6cVV1J; Mon, 27 May 2024 11:02:11 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A153B41467 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NkizHYJe Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id A153B41467; Mon, 27 May 2024 11:02:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 63EB5C0DD0; Mon, 27 May 2024 11:02:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0C383C0DD9 for ; Mon, 27 May 2024 11:02:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A2F3A60808 for ; Mon, 27 May 2024 11:02:06 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 1sWShwjyG08b for ; Mon, 27 May 2024 11:02:06 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=echaudro@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org E3235605D4 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E3235605D4 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NkizHYJe Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id E3235605D4 for ; Mon, 27 May 2024 11:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716807724; 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: in-reply-to:in-reply-to:references:references; bh=QDzE4fisUQLKUdT89C7qUckgAecHR2RvKUXlbInS9XQ=; b=NkizHYJeta+GL5s14aL0uPa7L8S8YfkU9ynKo3asbhuYlVAvON1kRdG+/UgeaEtIIYzV2x iFVvHyd/f4T0BWlcTg9hILl3/FChfGNpZFOCn/QAA0qnJtpkibEOQXxdKW9BU70AaC5+zR dImbaj+2XZxd06t/AeY9Y6QJEeXKok4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-FuC-Uz3QMnG7Y3x5LJAUdQ-1; Mon, 27 May 2024 07:02:03 -0400 X-MC-Unique: FuC-Uz3QMnG7Y3x5LJAUdQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CCA9D8058D8 for ; Mon, 27 May 2024 11:02:02 +0000 (UTC) Received: from ebuild.redhat.com (unknown [10.39.192.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FA88492BC6; Mon, 27 May 2024 11:02:02 +0000 (UTC) From: Eelco Chaudron To: dev@openvswitch.org Date: Mon, 27 May 2024 13:01:49 +0200 Message-ID: In-Reply-To: <8832a7af843af7fe0a821e0ba9874ca6a2232ab6.1716807712.git.echaudro@redhat.com> References: <8832a7af843af7fe0a821e0ba9874ca6a2232ab6.1716807712.git.echaudro@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH 4/7] sflow: Fix check for disabled receive time. 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" Instead of casting time_t to uint32_t for the 0xffffffff comparison, define a TIME_T_MAX and use it for both setting and comparison. Fixes: c72e245a0e2c ("Add InMon's sFlow Agent library to the build system.") Signed-off-by: Eelco Chaudron --- Note that this checkpatch reports an 'Improper whitespace around control block' error on this patch. But I did not want to change the code style in this entire file. --- include/openvswitch/types.h | 3 +++ lib/sflow_receiver.c | 3 ++- ofproto/ofproto-dpif-sflow.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h index 8c5ec94a6..bfeed752c 100644 --- a/include/openvswitch/types.h +++ b/include/openvswitch/types.h @@ -33,6 +33,9 @@ extern "C" { #define OVS_FORCE #endif +/* Maximum time_t value. */ +#define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) + /* The ovs_be types indicate that an object is in big-endian, not * native-endian, byte order. They are otherwise equivalent to uint_t. */ typedef uint16_t OVS_BITWISE ovs_be16; diff --git a/lib/sflow_receiver.c b/lib/sflow_receiver.c index 4162518e3..b5b02c060 100644 --- a/lib/sflow_receiver.c +++ b/lib/sflow_receiver.c @@ -146,7 +146,8 @@ void sfl_receiver_tick(SFLReceiver *receiver) // if there are any samples to send, flush them now if(receiver->sampleCollector.numSamples > 0) sendSample(receiver); // check the timeout - if(receiver->sFlowRcvrTimeout && (u_int32_t)receiver->sFlowRcvrTimeout != 0xFFFFFFFF) { + if(receiver->sFlowRcvrTimeout + && receiver->sFlowRcvrTimeout != TIME_T_MAX) { // count down one tick and reset if we reach 0 if(--receiver->sFlowRcvrTimeout == 0) reset(receiver); } diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c index 4a68e9b94..08c16f6f8 100644 --- a/ofproto/ofproto-dpif-sflow.c +++ b/ofproto/ofproto-dpif-sflow.c @@ -808,7 +808,7 @@ dpif_sflow_set_options(struct dpif_sflow *ds, receiver = sfl_agent_addReceiver(ds->sflow_agent); sfl_receiver_set_sFlowRcvrOwner(receiver, "Open vSwitch sFlow"); - sfl_receiver_set_sFlowRcvrTimeout(receiver, 0xffffffff); + sfl_receiver_set_sFlowRcvrTimeout(receiver, TIME_T_MAX); /* Set the sampling_rate down in the datapath. */ ds->probability = MAX(1, UINT32_MAX / ds->options->sampling_rate);