header cleaning: don't include smp_lock.h when not used
[linux-3.10.git] / net / ax25 / af_ax25.c
index e8753c7..429e13a 100644 (file)
@@ -13,7 +13,7 @@
  * Copyright (C) Hans Alblas PE1AYX (hans@esrac.ele.tue.nl)
  * Copyright (C) Frederic Rible F1OAT (frible@teaser.fr)
  */
-#include <linux/config.h>
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -23,7 +23,6 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
-#include <linux/smp_lock.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
 #include <net/ax25.h>
@@ -145,7 +144,7 @@ struct sock *ax25_find_listener(ax25_address *addr, int digi,
        ax25_cb *s;
        struct hlist_node *node;
 
-       spin_lock_bh(&ax25_list_lock);
+       spin_lock(&ax25_list_lock);
        ax25_for_each(s, node, &ax25_list) {
                if ((s->iamdigi && !digi) || (!s->iamdigi && digi))
                        continue;
@@ -154,12 +153,12 @@ struct sock *ax25_find_listener(ax25_address *addr, int digi,
                        /* If device is null we match any device */
                        if (s->ax25_dev == NULL || s->ax25_dev->dev == dev) {
                                sock_hold(s->sk);
-                               spin_unlock_bh(&ax25_list_lock);
+                               spin_unlock(&ax25_list_lock);
                                return s->sk;
                        }
                }
        }
-       spin_unlock_bh(&ax25_list_lock);
+       spin_unlock(&ax25_list_lock);
 
        return NULL;
 }
@@ -174,7 +173,7 @@ struct sock *ax25_get_socket(ax25_address *my_addr, ax25_address *dest_addr,
        ax25_cb *s;
        struct hlist_node *node;
 
-       spin_lock_bh(&ax25_list_lock);
+       spin_lock(&ax25_list_lock);
        ax25_for_each(s, node, &ax25_list) {
                if (s->sk && !ax25cmp(&s->source_addr, my_addr) &&
                    !ax25cmp(&s->dest_addr, dest_addr) &&
@@ -185,7 +184,7 @@ struct sock *ax25_get_socket(ax25_address *my_addr, ax25_address *dest_addr,
                }
        }
 
-       spin_unlock_bh(&ax25_list_lock);
+       spin_unlock(&ax25_list_lock);
 
        return sk;
 }
@@ -227,13 +226,15 @@ ax25_cb *ax25_find_cb(ax25_address *src_addr, ax25_address *dest_addr,
        return NULL;
 }
 
+EXPORT_SYMBOL(ax25_find_cb);
+
 void ax25_send_to_raw(ax25_address *addr, struct sk_buff *skb, int proto)
 {
        ax25_cb *s;
        struct sk_buff *copy;
        struct hlist_node *node;
 
-       spin_lock_bh(&ax25_list_lock);
+       spin_lock(&ax25_list_lock);
        ax25_for_each(s, node, &ax25_list) {
                if (s->sk != NULL && ax25cmp(&s->source_addr, addr) == 0 &&
                    s->sk->sk_type == SOCK_RAW &&
@@ -246,7 +247,7 @@ void ax25_send_to_raw(ax25_address *addr, struct sk_buff *skb, int proto)
                                kfree_skb(copy);
                }
        }
-       spin_unlock_bh(&ax25_list_lock);
+       spin_unlock(&ax25_list_lock);
 }
 
 /*
@@ -261,9 +262,9 @@ static void ax25_destroy_timer(unsigned long data)
 {
        ax25_cb *ax25=(ax25_cb *)data;
        struct sock *sk;
-       
+
        sk=ax25->sk;
-       
+
        bh_lock_sock(sk);
        sock_hold(sk);
        ax25_destroy_socket(ax25);
@@ -367,62 +368,82 @@ static int ax25_ctl_ioctl(const unsigned int cmd, void __user *arg)
                ax25_disconnect(ax25, ENETRESET);
                break;
 
-       case AX25_WINDOW:
-               if (ax25->modulus == AX25_MODULUS) {
-                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7)
-                               return -EINVAL;
-               } else {
-                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63)
-                               return -EINVAL;
-               }
-               ax25->window = ax25_ctl.arg;
-               break;
-
-       case AX25_T1:
+       case AX25_WINDOW:
+               if (ax25->modulus == AX25_MODULUS) {
+                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7)
+                               return -EINVAL;
+               } else {
+                       if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63)
+                               return -EINVAL;
+               }
+               ax25->window = ax25_ctl.arg;
+               break;
+
+       case AX25_T1:
                if (ax25_ctl.arg < 1)
-                       return -EINVAL;
-               ax25->rtt = (ax25_ctl.arg * HZ) / 2;
-               ax25->t1  = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_T2:
-               if (ax25_ctl.arg < 1)
-                       return -EINVAL;
-               ax25->t2 = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_N2:
-               if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31)
                        return -EINVAL;
-               ax25->n2count = 0;
-               ax25->n2 = ax25_ctl.arg;
-               break;
-
-       case AX25_T3:
-               if (ax25_ctl.arg < 0)
-                       return -EINVAL;
-               ax25->t3 = ax25_ctl.arg * HZ;
-               break;
-
-       case AX25_IDLE:
-               if (ax25_ctl.arg < 0)
-                       return -EINVAL;
-               ax25->idle = ax25_ctl.arg * 60 * HZ;
-               break;
-
-       case AX25_PACLEN:
-               if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535)
-                       return -EINVAL;
-               ax25->paclen = ax25_ctl.arg;
-               break;
-
-       default:
-               return -EINVAL;
+               ax25->rtt = (ax25_ctl.arg * HZ) / 2;
+               ax25->t1  = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_T2:
+               if (ax25_ctl.arg < 1)
+                       return -EINVAL;
+               ax25->t2 = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_N2:
+               if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31)
+                       return -EINVAL;
+               ax25->n2count = 0;
+               ax25->n2 = ax25_ctl.arg;
+               break;
+
+       case AX25_T3:
+               if (ax25_ctl.arg < 0)
+                       return -EINVAL;
+               ax25->t3 = ax25_ctl.arg * HZ;
+               break;
+
+       case AX25_IDLE:
+               if (ax25_ctl.arg < 0)
+                       return -EINVAL;
+               ax25->idle = ax25_ctl.arg * 60 * HZ;
+               break;
+
+       case AX25_PACLEN:
+               if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535)
+                       return -EINVAL;
+               ax25->paclen = ax25_ctl.arg;
+               break;
+
+       default:
+               return -EINVAL;
          }
 
        return 0;
 }
 
+static void ax25_fillin_cb_from_dev(ax25_cb *ax25, ax25_dev *ax25_dev)
+{
+       ax25->rtt     = msecs_to_jiffies(ax25_dev->values[AX25_VALUES_T1]) / 2;
+       ax25->t1      = msecs_to_jiffies(ax25_dev->values[AX25_VALUES_T1]);
+       ax25->t2      = msecs_to_jiffies(ax25_dev->values[AX25_VALUES_T2]);
+       ax25->t3      = msecs_to_jiffies(ax25_dev->values[AX25_VALUES_T3]);
+       ax25->n2      = ax25_dev->values[AX25_VALUES_N2];
+       ax25->paclen  = ax25_dev->values[AX25_VALUES_PACLEN];
+       ax25->idle    = msecs_to_jiffies(ax25_dev->values[AX25_VALUES_IDLE]);
+       ax25->backoff = ax25_dev->values[AX25_VALUES_BACKOFF];
+
+       if (ax25_dev->values[AX25_VALUES_AXDEFMODE]) {
+               ax25->modulus = AX25_EMODULUS;
+               ax25->window  = ax25_dev->values[AX25_VALUES_EWINDOW];
+       } else {
+               ax25->modulus = AX25_MODULUS;
+               ax25->window  = ax25_dev->values[AX25_VALUES_WINDOW];
+       }
+}
+
 /*
  *     Fill in a created AX.25 created control block with the default
  *     values for a particular device.
@@ -432,39 +453,28 @@ void ax25_fillin_cb(ax25_cb *ax25, ax25_dev *ax25_dev)
        ax25->ax25_dev = ax25_dev;
 
        if (ax25->ax25_dev != NULL) {
-               ax25->rtt     = ax25_dev->values[AX25_VALUES_T1] / 2;
-               ax25->t1      = ax25_dev->values[AX25_VALUES_T1];
-               ax25->t2      = ax25_dev->values[AX25_VALUES_T2];
-               ax25->t3      = ax25_dev->values[AX25_VALUES_T3];
-               ax25->n2      = ax25_dev->values[AX25_VALUES_N2];
-               ax25->paclen  = ax25_dev->values[AX25_VALUES_PACLEN];
-               ax25->idle    = ax25_dev->values[AX25_VALUES_IDLE];
-               ax25->backoff = ax25_dev->values[AX25_VALUES_BACKOFF];
-
-               if (ax25_dev->values[AX25_VALUES_AXDEFMODE]) {
-                       ax25->modulus = AX25_EMODULUS;
-                       ax25->window  = ax25_dev->values[AX25_VALUES_EWINDOW];
-               } else {
-                       ax25->modulus = AX25_MODULUS;
-                       ax25->window  = ax25_dev->values[AX25_VALUES_WINDOW];
-               }
+               ax25_fillin_cb_from_dev(ax25, ax25_dev);
+               return;
+       }
+
+       /*
+        * No device, use kernel / AX.25 spec default values
+        */
+       ax25->rtt     = msecs_to_jiffies(AX25_DEF_T1) / 2;
+       ax25->t1      = msecs_to_jiffies(AX25_DEF_T1);
+       ax25->t2      = msecs_to_jiffies(AX25_DEF_T2);
+       ax25->t3      = msecs_to_jiffies(AX25_DEF_T3);
+       ax25->n2      = AX25_DEF_N2;
+       ax25->paclen  = AX25_DEF_PACLEN;
+       ax25->idle    = msecs_to_jiffies(AX25_DEF_IDLE);
+       ax25->backoff = AX25_DEF_BACKOFF;
+
+       if (AX25_DEF_AXDEFMODE) {
+               ax25->modulus = AX25_EMODULUS;
+               ax25->window  = AX25_DEF_EWINDOW;
        } else {
-               ax25->rtt     = AX25_DEF_T1 / 2;
-               ax25->t1      = AX25_DEF_T1;
-               ax25->t2      = AX25_DEF_T2;
-               ax25->t3      = AX25_DEF_T3;
-               ax25->n2      = AX25_DEF_N2;
-               ax25->paclen  = AX25_DEF_PACLEN;
-               ax25->idle    = AX25_DEF_IDLE;
-               ax25->backoff = AX25_DEF_BACKOFF;
-
-               if (AX25_DEF_AXDEFMODE) {
-                       ax25->modulus = AX25_EMODULUS;
-                       ax25->window  = AX25_DEF_EWINDOW;
-               } else {
-                       ax25->modulus = AX25_MODULUS;
-                       ax25->window  = AX25_DEF_WINDOW;
-               }
+               ax25->modulus = AX25_MODULUS;
+               ax25->window  = AX25_DEF_WINDOW;
        }
 }
 
@@ -475,10 +485,9 @@ ax25_cb *ax25_create_cb(void)
 {
        ax25_cb *ax25;
 
-       if ((ax25 = kmalloc(sizeof(*ax25), GFP_ATOMIC)) == NULL)
+       if ((ax25 = kzalloc(sizeof(*ax25), GFP_ATOMIC)) == NULL)
                return NULL;
 
-       memset(ax25, 0x00, sizeof(*ax25));
        atomic_set(&ax25->refcount, 1);
 
        skb_queue_head_init(&ax25->write_queue);
@@ -896,13 +905,13 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
        ax25->source_addr = oax25->source_addr;
 
        if (oax25->digipeat != NULL) {
-               if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
+               ax25->digipeat = kmemdup(oax25->digipeat, sizeof(ax25_digi),
+                                        GFP_ATOMIC);
+               if (ax25->digipeat == NULL) {
                        sk_free(sk);
                        ax25_cb_put(ax25);
                        return NULL;
                }
-
-               memcpy(ax25->digipeat, oax25->digipeat, sizeof(ax25_digi));
        }
 
        sk->sk_protinfo = ax25;
@@ -1078,8 +1087,8 @@ out:
 /*
  *     FIXME: nonblock behaviour looks like it may have a bug.
  */
-static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
-       int addr_len, int flags)
+static int __must_check ax25_connect(struct socket *sock,
+       struct sockaddr *uaddr, int addr_len, int flags)
 {
        struct sock *sk = sock->sk;
        ax25_cb *ax25 = ax25_sk(sk), *ax25t;
@@ -1117,22 +1126,22 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
                switch (sk->sk_state) {
                case TCP_SYN_SENT: /* still trying */
                        err = -EINPROGRESS;
-                       goto out;
+                       goto out_release;
 
                case TCP_ESTABLISHED: /* connection established */
                        sock->state = SS_CONNECTED;
-                       goto out;
+                       goto out_release;
 
                case TCP_CLOSE: /* connection refused */
                        sock->state = SS_UNCONNECTED;
                        err = -ECONNREFUSED;
-                       goto out;
+                       goto out_release;
                }
        }
 
        if (sk->sk_state == TCP_ESTABLISHED && sk->sk_type == SOCK_SEQPACKET) {
                err = -EISCONN; /* No reconnect on a seqpacket socket */
-               goto out;
+               goto out_release;
        }
 
        sk->sk_state   = TCP_CLOSE;
@@ -1149,12 +1158,12 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
                /* Valid number of digipeaters ? */
                if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) {
                        err = -EINVAL;
-                       goto out;
+                       goto out_release;
                }
 
                if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) {
                        err = -ENOBUFS;
-                       goto out;
+                       goto out_release;
                }
 
                digi->ndigi      = fsa->fsa_ax25.sax25_ndigis;
@@ -1184,7 +1193,7 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
                        current->comm);
                if ((err = ax25_rt_autobind(ax25, &fsa->fsa_ax25.sax25_call)) < 0) {
                        kfree(digi);
-                       goto out;
+                       goto out_release;
                }
 
                ax25_fillin_cb(ax25, ax25->ax25_dev);
@@ -1193,17 +1202,17 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
                if (ax25->ax25_dev == NULL) {
                        kfree(digi);
                        err = -EHOSTUNREACH;
-                       goto out;
+                       goto out_release;
                }
        }
 
        if (sk->sk_type == SOCK_SEQPACKET &&
            (ax25t=ax25_find_cb(&ax25->source_addr, &fsa->fsa_ax25.sax25_call, digi,
-                        ax25->ax25_dev->dev))) {
+                        ax25->ax25_dev->dev))) {
                kfree(digi);
                err = -EADDRINUSE;              /* Already such a connection */
                ax25_cb_put(ax25t);
-               goto out;
+               goto out_release;
        }
 
        ax25->dest_addr = fsa->fsa_ax25.sax25_call;
@@ -1213,7 +1222,7 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
        if (sk->sk_type != SOCK_SEQPACKET) {
                sock->state = SS_CONNECTED;
                sk->sk_state   = TCP_ESTABLISHED;
-               goto out;
+               goto out_release;
        }
 
        /* Move to connecting socket, ax.25 lapb WAIT_UA.. */
@@ -1245,55 +1254,53 @@ static int ax25_connect(struct socket *sock, struct sockaddr *uaddr,
        /* Now the loop */
        if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) {
                err = -EINPROGRESS;
-               goto out;
+               goto out_release;
        }
 
        if (sk->sk_state == TCP_SYN_SENT) {
-               struct task_struct *tsk = current;
-               DECLARE_WAITQUEUE(wait, tsk);
+               DEFINE_WAIT(wait);
 
-               add_wait_queue(sk->sk_sleep, &wait);
                for (;;) {
+                       prepare_to_wait(sk->sk_sleep, &wait,
+                                       TASK_INTERRUPTIBLE);
                        if (sk->sk_state != TCP_SYN_SENT)
                                break;
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       release_sock(sk);
-                       if (!signal_pending(tsk)) {
+                       if (!signal_pending(current)) {
+                               release_sock(sk);
                                schedule();
                                lock_sock(sk);
                                continue;
                        }
-                       current->state = TASK_RUNNING;
-                       remove_wait_queue(sk->sk_sleep, &wait);
-                       return -ERESTARTSYS;
+                       err = -ERESTARTSYS;
+                       break;
                }
-               current->state = TASK_RUNNING;
-               remove_wait_queue(sk->sk_sleep, &wait);
+               finish_wait(sk->sk_sleep, &wait);
+
+               if (err)
+                       goto out_release;
        }
 
        if (sk->sk_state != TCP_ESTABLISHED) {
                /* Not in ABM, not in WAIT_UA -> failed */
                sock->state = SS_UNCONNECTED;
                err = sock_error(sk);   /* Always set at this point */
-               goto out;
+               goto out_release;
        }
 
        sock->state = SS_CONNECTED;
 
-       err=0;
-out:
+       err = 0;
+out_release:
        release_sock(sk);
 
        return err;
 }
 
-
 static int ax25_accept(struct socket *sock, struct socket *newsock, int flags)
 {
-       struct task_struct *tsk = current;
-       DECLARE_WAITQUEUE(wait, tsk);
        struct sk_buff *skb;
        struct sock *newsk;
+       DEFINE_WAIT(wait);
        struct sock *sk;
        int err = 0;
 
@@ -1318,30 +1325,29 @@ static int ax25_accept(struct socket *sock, struct socket *newsock, int flags)
         *      The read queue this time is holding sockets ready to use
         *      hooked into the SABM we saved
         */
-       add_wait_queue(sk->sk_sleep, &wait);
        for (;;) {
+               prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
                skb = skb_dequeue(&sk->sk_receive_queue);
                if (skb)
                        break;
 
-               release_sock(sk);
-               current->state = TASK_INTERRUPTIBLE;
                if (flags & O_NONBLOCK) {
-                       current->state = TASK_RUNNING;
-                       remove_wait_queue(sk->sk_sleep, &wait);
-                       return -EWOULDBLOCK;
+                       err = -EWOULDBLOCK;
+                       break;
                }
-               if (!signal_pending(tsk)) {
+               if (!signal_pending(current)) {
+                       release_sock(sk);
                        schedule();
                        lock_sock(sk);
                        continue;
                }
-               current->state = TASK_RUNNING;
-               remove_wait_queue(sk->sk_sleep, &wait);
-               return -ERESTARTSYS;
+               err = -ERESTARTSYS;
+               break;
        }
-       current->state = TASK_RUNNING;
-       remove_wait_queue(sk->sk_sleep, &wait);
+       finish_wait(sk->sk_sleep, &wait);
+
+       if (err)
+               goto out;
 
        newsk            = skb->sk;
        newsk->sk_socket = newsock;
@@ -1415,7 +1421,6 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
        struct sockaddr_ax25 sax;
        struct sk_buff *skb;
        ax25_digi dtmp, *dp;
-       unsigned char *asmptr;
        ax25_cb *ax25;
        size_t size;
        int lv, err, addr_len = msg->msg_namelen;
@@ -1446,7 +1451,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                err = -EMSGSIZE;
                goto out;
        }
-               
+
        if (usax != NULL) {
                if (usax->sax25_family != AF_AX25) {
                        err = -EINVAL;
@@ -1460,8 +1465,8 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                else if (addr_len != sizeof(struct full_sockaddr_ax25)) {
                        /* support for old structure may go away some time */
                        if ((addr_len < sizeof(struct sockaddr_ax25) + sizeof(ax25_address) * 6) ||
-                           (addr_len > sizeof(struct full_sockaddr_ax25))) {
-                               err = -EINVAL;
+                           (addr_len > sizeof(struct full_sockaddr_ax25))) {
+                               err = -EINVAL;
                                goto out;
                        }
 
@@ -1538,13 +1543,11 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                goto out;
        }
 
-       skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
 
        /* Add the PID if one is not supplied by the user in the skb */
-       if (!ax25->pidincl) {
-               asmptr  = skb_push(skb, 1);
-               *asmptr = sk->sk_protocol;
-       }
+       if (!ax25->pidincl)
+               *skb_push(skb, 1) = sk->sk_protocol;
 
        SOCK_DEBUG(sk, "AX.25: Transmitting buffer\n");
 
@@ -1563,7 +1566,7 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                goto out;
        }
 
-       asmptr = skb_push(skb, 1 + ax25_addr_size(dp));
+       skb_push(skb, 1 + ax25_addr_size(dp));
 
        SOCK_DEBUG(sk, "Building AX.25 Header (dp=%p).\n", dp);
 
@@ -1571,17 +1574,17 @@ static int ax25_sendmsg(struct kiocb *iocb, struct socket *sock,
                SOCK_DEBUG(sk, "Num digipeaters=%d\n", dp->ndigi);
 
        /* Build an AX.25 header */
-       asmptr += (lv = ax25_addr_build(asmptr, &ax25->source_addr,
-                                       &sax.sax25_call, dp,
-                                       AX25_COMMAND, AX25_MODULUS));
+       lv = ax25_addr_build(skb->data, &ax25->source_addr, &sax.sax25_call,
+                            dp, AX25_COMMAND, AX25_MODULUS);
 
        SOCK_DEBUG(sk, "Built header (%d bytes)\n",lv);
 
-       skb->h.raw = asmptr;
+       skb_set_transport_header(skb, lv);
 
-       SOCK_DEBUG(sk, "base=%p pos=%p\n", skb->data, asmptr);
+       SOCK_DEBUG(sk, "base=%p pos=%p\n",
+                  skb->data, skb_transport_header(skb));
 
-       *asmptr = AX25_UI;
+       *skb_transport_header(skb) = AX25_UI;
 
        /* Datagram frames go straight out of the door as UI */
        ax25_queue_xmit(skb, ax25->ax25_dev->dev);
@@ -1614,15 +1617,15 @@ static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,
 
        /* Now we can treat all alike */
        skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
-                               flags & MSG_DONTWAIT, &err);
+                               flags & MSG_DONTWAIT, &err);
        if (skb == NULL)
                goto out;
 
        if (!ax25_sk(sk)->pidincl)
                skb_pull(skb, 1);               /* Remove PID */
 
-       skb->h.raw = skb->data;
-       copied     = skb->len;
+       skb_reset_transport_header(skb);
+       copied = skb->len;
 
        if (copied > size) {
                copied = size;
@@ -1635,9 +1638,10 @@ static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,
                struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;
                ax25_digi digi;
                ax25_address src;
+               const unsigned char *mac = skb_mac_header(skb);
 
-               ax25_addr_parse(skb->mac.raw+1, skb->data-skb->mac.raw-1, &src, NULL, &digi, NULL, NULL);
-
+               ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL,
+                               &digi, NULL, NULL);
                sax->sax25_family = AF_AX25;
                /* We set this correctly, even though we may not let the
                   application know the digi calls further down (because it
@@ -1701,6 +1705,10 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                res = sock_get_timestamp(sk, argp);
                break;
 
+       case SIOCGSTAMPNS:
+               res = sock_get_timestampns(sk, argp);
+               break;
+
        case SIOCAX25ADDUID:    /* Add a uid to the uid/call map table */
        case SIOCAX25DELUID:    /* Delete a uid from the uid/call map table */
        case SIOCAX25GETUID: {
@@ -1859,7 +1867,7 @@ static void *ax25_info_next(struct seq_file *seq, void *v, loff_t *pos)
        return hlist_entry( ((struct ax25_cb *)v)->ax25_node.next,
                            struct ax25_cb, ax25_node);
 }
-       
+
 static void ax25_info_stop(struct seq_file *seq, void *v)
 {
        spin_unlock_bh(&ax25_list_lock);
@@ -1928,7 +1936,7 @@ static int ax25_info_open(struct inode *inode, struct file *file)
        return seq_open(file, &ax25_info_seqops);
 }
 
-static struct file_operations ax25_info_fops = {
+static const struct file_operations ax25_info_fops = {
        .owner = THIS_MODULE,
        .open = ax25_info_open,
        .read = seq_read,
@@ -1978,24 +1986,6 @@ static struct notifier_block ax25_dev_notifier = {
        .notifier_call =ax25_device_event,
 };
 
-EXPORT_SYMBOL(ax25_hard_header);
-EXPORT_SYMBOL(ax25_rebuild_header);
-EXPORT_SYMBOL(ax25_findbyuid);
-EXPORT_SYMBOL(ax25_find_cb);
-EXPORT_SYMBOL(ax25_linkfail_register);
-EXPORT_SYMBOL(ax25_linkfail_release);
-EXPORT_SYMBOL(ax25_listen_register);
-EXPORT_SYMBOL(ax25_listen_release);
-EXPORT_SYMBOL(ax25_protocol_register);
-EXPORT_SYMBOL(ax25_protocol_release);
-EXPORT_SYMBOL(ax25_send_frame);
-EXPORT_SYMBOL(ax25_uid_policy);
-EXPORT_SYMBOL(ax25cmp);
-EXPORT_SYMBOL(ax2asc);
-EXPORT_SYMBOL(asc2ax);
-EXPORT_SYMBOL(null_ax25_address);
-EXPORT_SYMBOL(ax25_display_timer);
-
 static int __init ax25_init(void)
 {
        int rc = proto_register(&ax25_proto, 0);