]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netrom/af_netrom.c
[NETROM]: Use socket helpers instead of direct fiddling with struct sock
[linux-2.6-omap-h63xx.git] / net / netrom / af_netrom.c
index e5d82d711cae2ea36e1e36e652fdeebd0b5db591..389a4119e1b405a9cebbf11f4a9076ff4b2d95c4 100644 (file)
@@ -8,9 +8,9 @@
  * Copyright Alan Cox GW4PTS (alan@lxorguk.ukuu.org.uk)
  * Copyright Darryl Miles G7LED (dlm@g7led.demon.co.uk)
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
@@ -63,7 +63,7 @@ static unsigned short circuit = 0x101;
 static HLIST_HEAD(nr_list);
 static DEFINE_SPINLOCK(nr_list_lock);
 
-static struct proto_ops nr_proto_ops;
+static const struct proto_ops nr_proto_ops;
 
 /*
  *     Socket removal during an interrupt is now safe.
@@ -424,11 +424,16 @@ static int nr_create(struct socket *sock, int protocol)
 
        nr_init_timers(sk);
 
-       nr->t1     = sysctl_netrom_transport_timeout;
-       nr->t2     = sysctl_netrom_transport_acknowledge_delay;
-       nr->n2     = sysctl_netrom_transport_maximum_tries;
-       nr->t4     = sysctl_netrom_transport_busy_delay;
-       nr->idle   = sysctl_netrom_transport_no_activity_timeout;
+       nr->t1     =
+               msecs_to_jiffies(sysctl_netrom_transport_timeout);
+       nr->t2     =
+               msecs_to_jiffies(sysctl_netrom_transport_acknowledge_delay);
+       nr->n2     =
+               msecs_to_jiffies(sysctl_netrom_transport_maximum_tries);
+       nr->t4     =
+               msecs_to_jiffies(sysctl_netrom_transport_busy_delay);
+       nr->idle   =
+               msecs_to_jiffies(sysctl_netrom_transport_no_activity_timeout);
        nr->window = sysctl_netrom_transport_requested_window_size;
 
        nr->bpqext = 1;
@@ -795,7 +800,7 @@ static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
 
        /* Now attach up the new socket */
        kfree_skb(skb);
-       sk->sk_ack_backlog--;
+       sk_acceptq_removed(sk);
        newsock->sk = newsk;
 
 out:
@@ -980,7 +985,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
        nr_make->vr        = 0;
        nr_make->vl        = 0;
        nr_make->state     = NR_STATE_3;
-       sk->sk_ack_backlog++;
+       sk_acceptq_added(sk);
 
        nr_insert_socket(make);
 
@@ -1166,10 +1171,11 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        void __user *argp = (void __user *)arg;
        int ret;
 
-       lock_sock(sk);
        switch (cmd) {
        case TIOCOUTQ: {
                long amount;
+
+               lock_sock(sk);
                amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
                if (amount < 0)
                        amount = 0;
@@ -1180,6 +1186,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        case TIOCINQ: {
                struct sk_buff *skb;
                long amount = 0L;
+
+               lock_sock(sk);
                /* These two are safe on a single CPU system as only user tasks fiddle here */
                if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
                        amount = skb->len;
@@ -1188,6 +1196,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        }
 
        case SIOCGSTAMP:
+               lock_sock(sk);
                ret = sock_get_timestamp(sk, argp);
                release_sock(sk);
                return ret;
@@ -1202,21 +1211,17 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
        case SIOCSIFNETMASK:
        case SIOCGIFMETRIC:
        case SIOCSIFMETRIC:
-               release_sock(sk);
                return -EINVAL;
 
        case SIOCADDRT:
        case SIOCDELRT:
        case SIOCNRDECOBS:
-               release_sock(sk);
                if (!capable(CAP_NET_ADMIN)) return -EPERM;
                return nr_rt_ioctl(cmd, argp);
 
        default:
-               release_sock(sk);
-               return dev_ioctl(cmd, argp);
+               return -ENOIOCTLCMD;
        }
-       release_sock(sk);
 
        return 0;
 }
@@ -1337,7 +1342,7 @@ static struct net_proto_family nr_family_ops = {
        .owner          =       THIS_MODULE,
 };
 
-static struct proto_ops nr_proto_ops = {
+static const struct proto_ops nr_proto_ops = {
        .family         =       PF_NETROM,
        .owner          =       THIS_MODULE,
        .release        =       nr_release,
@@ -1364,8 +1369,6 @@ static struct notifier_block nr_dev_notifier = {
 
 static struct net_device **dev_nr;
 
-static char banner[] __initdata = KERN_INFO "G4KLX NET/ROM for Linux. Version 0.7 for AX25.037 Linux 2.4\n";
-
 static int __init nr_proto_init(void)
 {
        int i;
@@ -1413,7 +1416,6 @@ static int __init nr_proto_init(void)
        }
                
        register_netdevice_notifier(&nr_dev_notifier);
-       printk(banner);
 
        ax25_protocol_register(AX25_P_NETROM, nr_route_frame);
        ax25_linkfail_register(nr_link_failed);