netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
To: dsa@cumulusnetworks.com
Cc: David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, rshearma@brocade.com
Subject: Re: ipv6 udp early demux breaks udp_l3mdev_accept=0
Date: Sat, 15 Apr 2017 20:23:31 -0600	[thread overview]
Message-ID: <2b582c01f3d2e265cf94bc89d0346a5b@codeaurora.org> (raw)
In-Reply-To: <20170415.094810.1393827754237126920.davem@davemloft.net>

>> It should be fixed for 4.12. Basically, __udp6_lib_demux_lookup needs 
>> to
>> be more like __udp4_lib_demux_lookup

Hi David

Would it be possible for you to test this with udp_l3mdev_accept=0

diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index b793ed1..0e307e5 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -46,6 +46,7 @@
  #include <net/tcp_states.h>
  #include <net/ip6_checksum.h>
  #include <net/xfrm.h>
+#include <net/inet_hashtables.h>
  #include <net/inet6_hashtables.h>
  #include <net/busy_poll.h>
  #include <net/sock_reuseport.h>
@@ -864,21 +865,25 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct 
udp_table *udptable,
         return 0;
  }

+
  static struct sock *__udp6_lib_demux_lookup(struct net *net,
                         __be16 loc_port, const struct in6_addr 
*loc_addr,
                         __be16 rmt_port, const struct in6_addr 
*rmt_addr,
                         int dif)
  {
+       unsigned short hnum = ntohs(loc_port);
+       unsigned int hash2 = udp6_portaddr_hash(net, loc_addr, hnum);
+       unsigned int slot2 = hash2 & udp_table.mask;
+       struct udp_hslot *hslot2 = &udp_table.hash2[slot2];
+       const __portpair ports = INET_COMBINED_PORTS(rmt_port, hnum);
         struct sock *sk;

-       rcu_read_lock();
-       sk = __udp6_lib_lookup(net, rmt_addr, rmt_port, loc_addr, 
loc_port,
-                              dif, &udp_table, NULL);
-       if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
-               sk = NULL;
-       rcu_read_unlock();
-
-       return sk;
+       udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
+               if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, 
dif))
+                       return sk;
+               break;
+       }
+       return NULL;
  }

  static void udp_v6_early_demux(struct sk_buff *skb)

  reply	other threads:[~2017-04-16  2:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14 22:23 ipv6 udp early demux breaks udp_l3mdev_accept=0 David Ahern
2017-04-15  0:38 ` Subash Abhinov Kasiviswanathan
2017-04-15  0:42   ` David Ahern
2017-04-15 13:48     ` David Miller
2017-04-16  2:23       ` Subash Abhinov Kasiviswanathan [this message]
2017-04-16 23:26         ` David Ahern
2017-04-17  0:44           ` Subash Abhinov Kasiviswanathan
2017-04-17  2:59             ` David Ahern

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=2b582c01f3d2e265cf94bc89d0346a5b@codeaurora.org \
    --to=subashab@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=rshearma@brocade.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;
as well as URLs for NNTP newsgroup(s).