[PATCH] ieee80211_crypt_tkip depends on NET_RADIO
[safe/jmp/linux-2.6] / net / decnet / af_decnet.c
index 34d4128..d402e90 100644 (file)
@@ -153,6 +153,7 @@ static struct proto_ops dn_proto_ops;
 static DEFINE_RWLOCK(dn_hash_lock);
 static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE];
 static struct hlist_head dn_wild_sk;
+static atomic_t decnet_memory_allocated;
 
 static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen, int flags);
 static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags);
@@ -446,14 +447,29 @@ static void dn_destruct(struct sock *sk)
        dst_release(xchg(&sk->sk_dst_cache, NULL));
 }
 
+static int dn_memory_pressure;
+
+static void dn_enter_memory_pressure(void)
+{
+       if (!dn_memory_pressure) {
+               dn_memory_pressure = 1;
+       }
+}
+
 static struct proto dn_proto = {
-       .name     = "DECNET",
-       .owner    = THIS_MODULE,
-       .obj_size = sizeof(struct dn_sock),
+       .name                   = "NSP",
+       .owner                  = THIS_MODULE,
+       .enter_memory_pressure  = dn_enter_memory_pressure,
+       .memory_pressure        = &dn_memory_pressure,
+       .memory_allocated       = &decnet_memory_allocated,
+       .sysctl_mem             = sysctl_decnet_mem,
+       .sysctl_wmem            = sysctl_decnet_wmem,
+       .sysctl_rmem            = sysctl_decnet_rmem,
+       .max_header             = DN_MAX_NSP_DATA_HEADER + 64,
+       .obj_size               = sizeof(struct dn_sock),
 };
 
-static struct sock *dn_alloc_sock(struct socket *sock,
-                                 unsigned int __nocast gfp)
+static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp)
 {
        struct dn_scp *scp;
        struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1);
@@ -471,6 +487,8 @@ static struct sock *dn_alloc_sock(struct socket *sock,
        sk->sk_family      = PF_DECnet;
        sk->sk_protocol    = 0;
        sk->sk_allocation  = gfp;
+       sk->sk_sndbuf      = sysctl_decnet_wmem[1];
+       sk->sk_rcvbuf      = sysctl_decnet_rmem[1];
 
        /* Initialization of DECnet Session Control Port                */
        scp = DN_SK(sk);
@@ -720,22 +738,9 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        if (saddr->sdn_flags & ~SDF_WILD)
                return -EINVAL;
 
-#if 1
        if (!capable(CAP_NET_BIND_SERVICE) && (saddr->sdn_objnum ||
            (saddr->sdn_flags & SDF_WILD)))
                return -EACCES;
-#else
-       /*
-        * Maybe put the default actions in the default security ops for
-        * dn_prot_sock ? Would be nice if the capable call would go there
-        * too.
-        */
-       if (security_dn_prot_sock(saddr) &&
-           !capable(CAP_NET_BIND_SERVICE) || 
-           saddr->sdn_objnum || (saddr->sdn_flags & SDF_WILD))
-               return -EACCES;
-#endif
-
 
        if (!(saddr->sdn_flags & SDF_WILD)) {
                if (dn_ntohs(saddr->sdn_nodeaddrl)) {
@@ -805,8 +810,7 @@ static int dn_auto_bind(struct socket *sock)
        return rv;
 }
 
-static int dn_confirm_accept(struct sock *sk, long *timeo,
-                               unsigned int __nocast allocation)
+static int dn_confirm_accept(struct sock *sk, long *timeo, gfp_t allocation)
 {
        struct dn_scp *scp = DN_SK(sk);
        DEFINE_WAIT(wait);
@@ -1679,17 +1683,15 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
                goto out;
        }
 
-       rv = dn_check_state(sk, NULL, 0, &timeo, flags);
-       if (rv)
-               goto out;
-
        if (sk->sk_shutdown & RCV_SHUTDOWN) {
-               if (!(flags & MSG_NOSIGNAL))
-                       send_sig(SIGPIPE, current, 0);
-               rv = -EPIPE;
+               rv = 0;
                goto out;
        }
 
+       rv = dn_check_state(sk, NULL, 0, &timeo, flags);
+       if (rv)
+               goto out;
+
        if (flags & ~(MSG_PEEK|MSG_OOB|MSG_WAITALL|MSG_DONTWAIT|MSG_NOSIGNAL)) {
                rv = -EOPNOTSUPP;
                goto out;
@@ -1943,6 +1945,8 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
 
        if (sk->sk_shutdown & SEND_SHUTDOWN) {
                err = -EPIPE;
+               if (!(flags & MSG_NOSIGNAL))
+                       send_sig(SIGPIPE, current, 0);
                goto out_err;
        }