geneve: Remove socket and offload handlers at destruction.
authorJesse Gross <jesse@nicira.com>
Wed, 17 Dec 2014 02:25:31 +0000 (18:25 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Dec 2014 17:38:13 +0000 (12:38 -0500)
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>
net/ipv4/geneve.c

index a457232f0131c49d1a9fd574c683df8604f48e99..5a47188b01e94f524bedbf0d20f85bab513332eb 100644 (file)
@@ -159,6 +159,15 @@ static void geneve_notify_add_rx_port(struct geneve_sock *gs)
        }
 }
 
+static void geneve_notify_del_rx_port(struct geneve_sock *gs)
+{
+       struct sock *sk = gs->sock->sk;
+       sa_family_t sa_family = sk->sk_family;
+
+       if (sa_family == AF_INET)
+               udp_del_offload(&gs->udp_offloads);
+}
+
 /* Callback from net/ipv4/udp.c to receive packets */
 static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
 {
@@ -312,9 +321,17 @@ EXPORT_SYMBOL_GPL(geneve_sock_add);
 
 void geneve_sock_release(struct geneve_sock *gs)
 {
+       struct net *net = sock_net(gs->sock->sk);
+       struct geneve_net *gn = net_generic(net, geneve_net_id);
+
        if (!atomic_dec_and_test(&gs->refcnt))
                return;
 
+       spin_lock(&gn->sock_lock);
+       hlist_del_rcu(&gs->hlist);
+       geneve_notify_del_rx_port(gs);
+       spin_unlock(&gn->sock_lock);
+
        queue_work(geneve_wq, &gs->del_work);
 }
 EXPORT_SYMBOL_GPL(geneve_sock_release);