Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1159224lqj; Mon, 3 Jun 2024 11:58:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWa0hxgHeZDrdHUehSPxumZuZH0O1nVnxibuA4vUqZQrWxIlSReaUZlnOV8pRuNFn4ptu/IJkKEx+ninekvhlyxpGGZ2CBTUfvH/UhZtQ== X-Google-Smtp-Source: AGHT+IEa9kt0O9E67tqqbit2tK+0NX3EE5fWFbjxBZJQBTG74miqjS603HAbCFM+gs8hZLU8UE45 X-Received: by 2002:a17:907:9712:b0:a69:1219:2e2d with SMTP id a640c23a62f3a-a6912192f18mr272765166b.35.1717441128710; Mon, 03 Jun 2024 11:58:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717441128; cv=pass; d=google.com; s=arc-20160816; b=S6hEzckTz4BMrhF+r7U1akYoQWVmwlrBW/KfR0d2bk6nPVmhX/g/QwTibn6ZuKqeGa sUTImH2wKpkBZt5U7TiOB+oobNnx3pi4wA+yfGcu/6srtQQ3honCcJ+lZ1COSm2PmD81 R3ZOU2uri775K6+dMiG0f7ERpjIp0HCATPf2+rF1SsR4UGHtjivuzhn9earOID2cZTyW +wflKecwJDO1Js6vvyUpZJhPqJ6YA/vPjFsRzyLP1CjFcLEY6PIKhEb3if+mFU37Vdqa dk1G5lFgOHkKh2QKwXz2P6q5ONALJ8BUjYaITEmoWjf0LbVEyyfI9q3bk8ao56TU6JQ7 mCqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=D+C3Lxc1H/BkHmxaLgkIrAXsMU+NbPCnsT3EFyhByuc=; fh=WVVfreXWJVLS+3cUArQ7+LP5dwTkSDjx9JOOooK0PyM=; b=fUliKtLwM8rO25ySFnArx5/7XkBwHT6CaH1aYZy6AxU606fpoxunXEbUO3aITqC9W6 UlnfGUYKjk8MdeCOpiDGCoaqqoADNX7rbnwmDUE/a0Z8cpvIidTXmoff9HFJ/rlWH8lz ogyGfIVHrydA3YFDIViW/Uhx8c/P0kAg4KkjGwy3m6fnZemYi1Im4cGa8+BCkxW+ZcKl p/Hhmq6FDAcviWZXdMn9ksft+d21FkS6RtL4TNxx04pLkiheuXFNUSrZKb/Q/tarjw9v knpWGqkxS84qGVIon1I/dx1JthJAaeQKni8+LpCfGMIweq1FdQ9bb6AQ5G71QWBcWRmU Mj6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GOnNiq6R; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a685645f39esi369913466b.128.2024.06.03.11.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GOnNiq6R; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199585-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199585-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 980E01F242A9 for ; Mon, 3 Jun 2024 18:57:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC99E13B2B0; Mon, 3 Jun 2024 18:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GOnNiq6R" 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 BFC1F13A884 for ; Mon, 3 Jun 2024 18:57:25 +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=1717441047; cv=none; b=VMuKmmzjYF3MHFbuDkvhGeV9zfhz0CjYrVjTf5ABy1V9wVh/urYXBRjldvyg8oa+6sGhyRPxheXUhSELndZxsm+CdSfG56t6nlSOwxTVhzSM1WVedYa+2QVBO7rKRLE8LRRXGLCpPh9q0s7Qs+d+011JmzTuIKRAHbf311H3zQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717441047; c=relaxed/simple; bh=9iZFbFIqgMdQvgciGYpaXFrrxvOTwy3YOFeAKytklLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cszq8J6RL5bmAkRE22wKwlDkdl71fHWpZiV6T+FjiebsKeKrUeBE70kWzX86HnBoavmBo9M5di5q0H81B4Y1qQ1XQAmpVVrcNAUNsnJIjkc2hCh5BAa1RoPhY+K6len0qtAd+Axaf7Ca0RLyO2vwSaT6ikdSJ6t8zv7uyEagjl8= 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=GOnNiq6R; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717441044; 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=D+C3Lxc1H/BkHmxaLgkIrAXsMU+NbPCnsT3EFyhByuc=; b=GOnNiq6RwfVYre3A1dp1BIfyAQdyG4BCQdg2BiPRNngeSiB1U+Jcvrv5BPzXuEzM4V6cbf qQEFJjXGOcupclxszJdANcMwI5cQ8h9TYuTqcrZYk/8XUZCtGbwbaCv78rSaDV+Vy32jrb BagTlp9d1WCJ47rSGfYx3Rd9tO5/j64= Received: from mx-prod-mc-02.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-130-yJC5n1d4MP23gZgdSGrKzQ-1; Mon, 03 Jun 2024 14:57:20 -0400 X-MC-Unique: yJC5n1d4MP23gZgdSGrKzQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5DD5318BF6C6; Mon, 3 Jun 2024 18:57:18 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6521D1955F6E; Mon, 3 Jun 2024 18:57:14 +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 , Yotam Gigi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 3/9] net: psample: skip packet copy if no listeners Date: Mon, 3 Jun 2024 20:56:37 +0200 Message-ID: <20240603185647.2310748-4-amorenoz@redhat.com> In-Reply-To: <20240603185647.2310748-1-amorenoz@redhat.com> References: <20240603185647.2310748-1-amorenoz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 If nobody is listening on the multicast group, generating the sample, which involves copying packet data, seems completely unnecessary. Return fast in this case. 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) + -- 2.45.1