Commit 4378fe7d7973624d7b9a8d814651c82e428c241b

Authored by Jesse Gross
Committed by Greg Kroah-Hartman
1 parent 3c030f1946

geneve: Remove socket and offload handlers at destruction.

[ Upstream commit 7ed767f73192d6daf673c6d885cd02d5f280ac1f ]

Sockets aren't currently removed from the the global list when
they are destroyed. In addition, offload handlers need to be cleaned
up as well.

Fixes: 0b5e8b8e ("net: Add Geneve tunneling protocol driver")
CC: Andy Zhou <azhou@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 17 additions and 0 deletions Side-by-side Diff

... ... @@ -165,6 +165,15 @@
165 165 }
166 166 }
167 167  
  168 +static void geneve_notify_del_rx_port(struct geneve_sock *gs)
  169 +{
  170 + struct sock *sk = gs->sock->sk;
  171 + sa_family_t sa_family = sk->sk_family;
  172 +
  173 + if (sa_family == AF_INET)
  174 + udp_del_offload(&gs->udp_offloads);
  175 +}
  176 +
168 177 /* Callback from net/ipv4/udp.c to receive packets */
169 178 static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
170 179 {
171 180  
... ... @@ -318,8 +327,16 @@
318 327  
319 328 void geneve_sock_release(struct geneve_sock *gs)
320 329 {
  330 + struct net *net = sock_net(gs->sock->sk);
  331 + struct geneve_net *gn = net_generic(net, geneve_net_id);
  332 +
321 333 if (!atomic_dec_and_test(&gs->refcnt))
322 334 return;
  335 +
  336 + spin_lock(&gn->sock_lock);
  337 + hlist_del_rcu(&gs->hlist);
  338 + geneve_notify_del_rx_port(gs);
  339 + spin_unlock(&gn->sock_lock);
323 340  
324 341 queue_work(geneve_wq, &gs->del_work);
325 342 }