Netdev List
 help / color / mirror / Atom feed
From: Adrian Moreno <amorenoz@redhat.com>
To: netdev@vger.kernel.org, dev@openvswitch.org
Cc: Adrian Moreno <amorenoz@redhat.com>,
	cmi@nvidia.com, yotam.gi@gmail.com, i.maximets@ovn.org,
	aconole@redhat.com, echaudro@redhat.com, horms@kernel.org
Subject: [RFC PATCH 3/4] net:openvswitch: Avoid extra copy if no listeners.
Date: Thu,  7 Mar 2024 16:18:47 +0100	[thread overview]
Message-ID: <20240307151849.394962-4-amorenoz@redhat.com> (raw)
In-Reply-To: <20240307151849.394962-1-amorenoz@redhat.com>

If there are no listeneres in the multicast group, there is no need for
building the upcall packet. Exit early in that case.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 net/openvswitch/datapath.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 5a2c0b3b4112..5171aefa6a7c 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -455,6 +455,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 	if (!dp_ifindex)
 		return -ENODEV;
 
+	if (upcall_info->portid == MCAST_PID &&
+	    !genl_has_listeners(&dp_packet_genl_family, ovs_dp_get_net(dp), 0))
+		return 0;
+
 	if (skb_vlan_tag_present(skb)) {
 		nskb = skb_clone(skb, GFP_ATOMIC);
 		if (!nskb)
-- 
2.44.0


  parent reply	other threads:[~2024-03-07 15:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 15:18 [RFC PATCH 0/4] net: openvswitch: Add sample multicasting Adrian Moreno
2024-03-07 15:18 ` [RFC PATCH 1/4] net:openvswitch: Support multicasting userspace Adrian Moreno
2024-03-07 15:18 ` [RFC PATCH 2/4] openvswitch:trace: Add ovs_dp_monitor tracepoint Adrian Moreno
2024-03-07 15:18 ` Adrian Moreno [this message]
2024-03-07 15:18 ` [RFC PATCH 4/4] net:openvswitch: Add multicasted packets to stats Adrian Moreno
2024-03-07 16:54 ` [RFC PATCH 0/4] net: openvswitch: Add sample multicasting Ilya Maximets
2024-03-07 20:59   ` Adrian Moreno
2024-03-07 21:29     ` Ilya Maximets
2024-03-08 14:24       ` Ilya Maximets
2024-03-13  8:28         ` Adrian Moreno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240307151849.394962-4-amorenoz@redhat.com \
    --to=amorenoz@redhat.com \
    --cc=aconole@redhat.com \
    --cc=cmi@nvidia.com \
    --cc=dev@openvswitch.org \
    --cc=echaudro@redhat.com \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=netdev@vger.kernel.org \
    --cc=yotam.gi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox