From patchwork Fri Jun 28 11:05:39 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: 13715964 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 B747F157467 for ; Fri, 28 Jun 2024 11:06:30 +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=1719572793; cv=none; b=eSpxl2htJ07obDWh78P3i0gO4Za9GfSi6JFj44K5YZ2ZJ3HDDntO5Nkvsn5PpwRUuWgKDjrmGksMZlKbd+SV95lbF1X0ZVr7v3ECWZauZWrgBtHaOTZNQBefQcBPMlqtcCEdnHFghtg40A5l3i8dmhhDTpT1z7IStvmMuOutNak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719572793; c=relaxed/simple; bh=OwDvHl+s4ECjeytw/0sjArzf4oaD21GZ98U6MT4B8E4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JLFgC/wXZPjm9qPUnjd2ZHIDX5UsvWdhhYCA6K0Tb9YPLRSbncNrimRAXUi6bvrK0x6jcBqCmEm1cvLA4gBa0+R2upRLtN2Mg1PCoULqJYojQpk55HcOpQgCuwp6UfBE+jREt6KeL7554E+J/flIoYNlhC5BRqfZJx3DMvj+cS8= 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=NQllYwFO; 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="NQllYwFO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719572790; 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=n2D874c+YhsRMRneo/991mnvInFwFQ/UmgHZ/hmjeug=; b=NQllYwFOI9vpnrojbDFaCR+9drHUg2dzPT4LpK+Fip3kS1Y+ByIJOuUmVogASJzTV4rj+h TAzUVW5KFgxgMl2rmxnwaNCjn9TbyLQjzmJccpD2BtJn19EPAfimk4pPyK5QlFgJC3V+dg ncQv3YEH/cfUMwEnL0TEN4FC3Q7ziZ0= Received: from mx-prod-mc-01.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-240-WI1MxPmyNBKoe2SYk0rONw-1; Fri, 28 Jun 2024 07:06:23 -0400 X-MC-Unique: WI1MxPmyNBKoe2SYk0rONw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 00E511944D36; Fri, 28 Jun 2024 11:06:22 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.194.173]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDFFC1955D89; Fri, 28 Jun 2024 11:06:17 +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 v6 03/10] net: psample: skip packet copy if no listeners Date: Fri, 28 Jun 2024 13:05:39 +0200 Message-ID: <20240628110559.3893562-4-amorenoz@redhat.com> In-Reply-To: <20240628110559.3893562-1-amorenoz@redhat.com> References: <20240628110559.3893562-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.12 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. 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) +