From patchwork Tue Jul 2 09:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 13719368 X-Patchwork-Delegate: kuba@kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7F8E155C90 for ; Tue, 2 Jul 2024 09:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719914051; cv=none; b=UwpxxHPEvpZw+iuDGqQvlq3QnGbx1Nfl4B/wfHZTQC0IepZIlCv1riq2N42vEUrYm1QQYa3NAD+uTG0v7MK8NlOym029kZOyftfPoWy3c4ZoHl741qbxbOkfaBG4tkuPUQyad4m1kIt2+f9Oaq5IJLT34u8F6IBEtnEvaeRU/6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719914051; c=relaxed/simple; bh=tEMt8uF4hWy9k1ZIQOKRPv/vvsgheompOMTSikfwhVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rz7T8d3HdryoHUzPvjkkQp14xpeBvLezHUxLnKcbPIXCuSPevv/YG7VCKQH0+3gvVwTwJ6wsSIHu/Y+BnIz5CUyPJHP9DVU2iwC/RyQD8Lh3jQ0p2ur+qp/ShPMQqgGJWsbxy5zapnZhsqATrREl+bG+QRwTxnmjPkpkQCdI9qY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RwiVkxY4; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RwiVkxY4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719914048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=818RCWMsmwDVM2bQEv4PthGvmSOhVSaUgggsNvr7KIY=; b=RwiVkxY4I4D0IsH34TYjp2SEYFDGGppej/eYwFhY7zT1tsbVaopMBSD3zJUJxWDRpz3jDS cuPJGc6e8UD/5eQrr6GSCQ1XWW4E1U1wBxdSRJUbdu1KvKy0OEGVeBjSBvr+hij0Pgf5Tc /w164jQL6uEjxySlpvpZpTJZUvD3HG0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-316-K06NSaG3Omu5p2sT6qq9-g-1; Tue, 02 Jul 2024 05:54:03 -0400 X-MC-Unique: K06NSaG3Omu5p2sT6qq9-g-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 398A31944D31; Tue, 2 Jul 2024 09:54:02 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.194.50]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 528E719560A3; Tue, 2 Jul 2024 09:53:55 +0000 (UTC) From: Adrian Moreno To: netdev@vger.kernel.org Cc: aconole@redhat.com, echaudro@redhat.com, horms@kernel.org, i.maximets@ovn.org, dev@openvswitch.org, Adrian Moreno , Ido Schimmel , Yotam Gigi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v8 03/10] net: psample: skip packet copy if no listeners Date: Tue, 2 Jul 2024 11:53:20 +0200 Message-ID: <20240702095336.596506-4-amorenoz@redhat.com> In-Reply-To: <20240702095336.596506-1-amorenoz@redhat.com> References: <20240702095336.596506-1-amorenoz@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Patchwork-Delegate: kuba@kernel.org If nobody is listening on the multicast group, generating the sample, which involves copying packet data, seems completely unnecessary. Return fast in this case. Reviewed-by: Aaron Conole Acked-by: Eelco Chaudron Reviewed-by: Ido Schimmel Reviewed-by: Simon Horman Signed-off-by: Adrian Moreno --- net/psample/psample.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/psample/psample.c b/net/psample/psample.c index b37488f426bc..1c76f3e48dcd 100644 --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -376,6 +376,10 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, void *data; int ret; + if (!genl_has_listeners(&psample_nl_family, group->net, + PSAMPLE_NL_MCGRP_SAMPLE)) + return; + meta_len = (in_ifindex ? nla_total_size(sizeof(u16)) : 0) + (out_ifindex ? nla_total_size(sizeof(u16)) : 0) + (md->out_tc_valid ? nla_total_size(sizeof(u16)) : 0) +