vxlan-udp-recv function lookup vxlan_sock struct on every packet recv by using udp-port number. we can use sk->sk_user_data to store vxlan_sock and avoid lookup. I have open coded rcu-api to store and read vxlan_sock from sk_user_data to avoid sparse warning as sk_user_data is not __rcu pointer.
backport of upstream commit 430eda6d6d56 (vxlan: Optimize vxlan rcv). Signed-off-by: Pravin B Shelar <pshe...@nicira.com> --- v2: Use ACCESS_ONCE() to read vs. --- datapath/linux/compat/vxlan.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/datapath/linux/compat/vxlan.c b/datapath/linux/compat/vxlan.c index db14f2f..0b6fd36 100644 --- a/datapath/linux/compat/vxlan.c +++ b/datapath/linux/compat/vxlan.c @@ -124,7 +124,8 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb) if (iptunnel_pull_header(skb, VXLAN_HLEN, htons(ETH_P_TEB))) goto drop; - vs = vxlan_find_sock(sock_net(sk), inet_sport(sk)); + vs = (struct vxlan_sock *)ACCESS_ONCE(sk->sk_user_data); + smp_read_barrier_depends(); if (!vs) goto drop; @@ -322,6 +323,8 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, } vs->rcv = rcv; vs->data = data; + smp_wmb(); + vs->sock->sk->sk_user_data = vs; /* Disable multicast loopback */ inet_sk(sk)->mc_loop = 0; @@ -359,6 +362,8 @@ void vxlan_sock_release(struct vxlan_sock *vs) spin_lock(&vn->sock_lock); hlist_del_rcu(&vs->hlist); + smp_wmb(); + vs->sock->sk->sk_user_data = NULL; spin_unlock(&vn->sock_lock); queue_work(&vs->del_work); -- 1.7.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev