Netdev List
 help / color / mirror / Atom feed
From: Lucian Adrian Grijincu <lgrijincu@ixiacom.com>
To: netdev@vger.kernel.org
Cc: opurdila@ixiacom.com
Subject: [PATCH 2/2] udp: cleanup __udp6_lib_mcast_deliver
Date: Thu, 5 Nov 2009 20:33:59 +0200	[thread overview]
Message-ID: <200911052033.59795.lgrijincu@ixiacom.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]


__udp6_lib_mcast_deliver always returned 0.
It's caller can return 0 explicitly to make things clearer.

Also, we don't need the spin_lock() on the hslot to free the skb.

kfree_skb() assumes that the frame is being dropped after a failure
and notes that. Replace it with consume_skb().

Signed-off-by: Lucian Adrian Grijincu <lgrijincu@ixiacom.com>
---
 net/ipv6/udp.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)


[-- Attachment #2: 0002-udp-cleanup-__udp6_lib_mcast_deliver.patch --]
[-- Type: text/plain, Size: 1494 bytes --]

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index d3b59d7..5f17fef 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -446,7 +446,7 @@ static struct sock *udp_v6_mcast_next(struct net *net, struct sock *sk,
  * Note: called only from the BH handler context,
  * so we don't need to lock the hashes.
  */
-static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
+static void __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 		struct in6_addr *saddr, struct in6_addr *daddr,
 		struct udp_table *udptable)
 {
@@ -460,8 +460,9 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 	dif = inet6_iif(skb);
 	sk = udp_v6_mcast_next(net, sk, uh->dest, daddr, uh->source, saddr, dif);
 	if (!sk) {
-		kfree_skb(skb);
-		goto out;
+		spin_unlock(&hslot->lock);
+		consume_skb(skb);
+		return;
 	}
 
 	sk2 = sk;
@@ -483,9 +484,8 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb,
 	else
 		sk_add_backlog(sk, skb);
 	bh_unlock_sock(sk);
-out:
+
 	spin_unlock(&hslot->lock);
-	return 0;
 }
 
 static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh,
@@ -568,9 +568,11 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	/*
 	 *	Multicast receive code
 	 */
-	if (ipv6_addr_is_multicast(daddr))
-		return __udp6_lib_mcast_deliver(net, skb,
+	if (ipv6_addr_is_multicast(daddr)) {
+		__udp6_lib_mcast_deliver(net, skb,
 				saddr, daddr, udptable);
+		return 0;
+	}
 
 	/* Unicast */
 

                 reply	other threads:[~2009-11-05 18:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200911052033.59795.lgrijincu@ixiacom.com \
    --to=lgrijincu@ixiacom.com \
    --cc=netdev@vger.kernel.org \
    --cc=opurdila@ixiacom.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