]> err.no Git - linux-2.6/blobdiff - net/core/sock.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[linux-2.6] / net / core / sock.c
index 3d7757ee2fc878f809c6eac0fc49f431b07e70d1..b1a6ed4d33c19ec7a9d58f9f0249445708473e81 100644 (file)
@@ -667,6 +667,13 @@ set_rcvbuf:
                else
                        clear_bit(SOCK_PASSSEC, &sock->flags);
                break;
+       case SO_MARK:
+               if (!capable(CAP_NET_ADMIN))
+                       ret = -EPERM;
+               else {
+                       sk->sk_mark = val;
+               }
+               break;
 
                /* We implement the SO_SNDLOWAT etc to
                   not be settable (1003.1g 5.3) */
@@ -836,6 +843,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
        case SO_PEERSEC:
                return security_socket_getpeersec_stream(sock, optval, optlen, len);
 
+       case SO_MARK:
+               v.val = sk->sk_mark;
+               break;
+
        default:
                return -ENOPROTOOPT;
        }
@@ -970,12 +981,31 @@ void sk_free(struct sock *sk)
 
        if (atomic_read(&sk->sk_omem_alloc))
                printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
-                      __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
+                      __func__, atomic_read(&sk->sk_omem_alloc));
 
        put_net(sk->sk_net);
        sk_prot_free(sk->sk_prot_creator, sk);
 }
 
+/*
+ * Last sock_put should drop referrence to sk->sk_net. It has already
+ * been dropped in sk_change_net. Taking referrence to stopping namespace
+ * is not an option.
+ * Take referrence to a socket to remove it from hash _alive_ and after that
+ * destroy it in the context of init_net.
+ */
+void sk_release_kernel(struct sock *sk)
+{
+       if (sk == NULL || sk->sk_socket == NULL)
+               return;
+
+       sock_hold(sk);
+       sock_release(sk->sk_socket);
+       sk->sk_net = get_net(&init_net);
+       sock_put(sk);
+}
+EXPORT_SYMBOL(sk_release_kernel);
+
 struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
 {
        struct sock *newsk;
@@ -1065,10 +1095,12 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
        if (sk->sk_route_caps & NETIF_F_GSO)
                sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
        if (sk_can_gso(sk)) {
-               if (dst->header_len)
+               if (dst->header_len) {
                        sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
-               else
+               } else {
                        sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
+                       sk->sk_gso_max_size = dst->dev->gso_max_size;
+               }
        }
 }
 EXPORT_SYMBOL_GPL(sk_setup_caps);
@@ -1720,7 +1752,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
        atomic_set(&sk->sk_drops, 0);
 }
 
-void fastcall lock_sock_nested(struct sock *sk, int subclass)
+void lock_sock_nested(struct sock *sk, int subclass)
 {
        might_sleep();
        spin_lock_bh(&sk->sk_lock.slock);
@@ -1737,7 +1769,7 @@ void fastcall lock_sock_nested(struct sock *sk, int subclass)
 
 EXPORT_SYMBOL(lock_sock_nested);
 
-void fastcall release_sock(struct sock *sk)
+void release_sock(struct sock *sk)
 {
        /*
         * The sk_lock has mutex_unlock() semantics:
@@ -1913,7 +1945,7 @@ int proto_register(struct proto *prot, int alloc_slab)
        char *request_sock_slab_name = NULL;
        char *timewait_sock_slab_name;
 
-       if (pcounter_alloc(&prot->inuse) != 0) {
+       if (sock_prot_inuse_init(prot) != 0) {
                printk(KERN_CRIT "%s: Can't alloc inuse counters!\n", prot->name);
                goto out;
        }
@@ -1984,7 +2016,7 @@ out_free_sock_slab:
        kmem_cache_destroy(prot->slab);
        prot->slab = NULL;
 out_free_inuse:
-       pcounter_free(&prot->inuse);
+       sock_prot_inuse_free(prot);
 out:
        return -ENOBUFS;
 }
@@ -1997,7 +2029,7 @@ void proto_unregister(struct proto *prot)
        list_del(&prot->node);
        write_unlock(&proto_list_lock);
 
-       pcounter_free(&prot->inuse);
+       sock_prot_inuse_free(prot);
 
        if (prot->slab != NULL) {
                kmem_cache_destroy(prot->slab);