Skip to content

Commit

Permalink
vxlan: Optimize vxlan rcv
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pravin B Shelar authored and David S. Miller committed Sep 4, 2013
1 parent f8de310 commit 430eda6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,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(vxlan_wq, &vs->del_work);
Expand Down Expand Up @@ -1009,7 +1011,8 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)

port = inet_sk(sk)->inet_sport;

vs = vxlan_find_sock(sock_net(sk), port);
smp_read_barrier_depends();
vs = (struct vxlan_sock *)sk->sk_user_data;
if (!vs)
goto drop;

Expand Down Expand Up @@ -2236,6 +2239,8 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
atomic_set(&vs->refcnt, 1);
vs->rcv = rcv;
vs->data = data;
smp_wmb();
vs->sock->sk->sk_user_data = vs;

spin_lock(&vn->sock_lock);
hlist_add_head_rcu(&vs->hlist, vs_head(net, port));
Expand Down

0 comments on commit 430eda6

Please sign in to comment.