]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/x25/af_x25.c
[NET]: Make device event notification network namespace safe
[linux-2.6-omap-h63xx.git] / net / x25 / af_x25.c
index e62ba41b05c59b06e8889440f079ccbd9f19344b..fc416f9606a9e259e22f2e641c602107e06b9200 100644 (file)
@@ -191,6 +191,9 @@ static int x25_device_event(struct notifier_block *this, unsigned long event,
        struct net_device *dev = ptr;
        struct x25_neigh *nb;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        if (dev->type == ARPHRD_X25
 #if defined(CONFIG_LLC) || defined(CONFIG_LLC_MODULE)
         || dev->type == ARPHRD_ETHER
@@ -466,10 +469,10 @@ static struct proto x25_proto = {
        .obj_size = sizeof(struct x25_sock),
 };
 
-static struct sock *x25_alloc_socket(void)
+static struct sock *x25_alloc_socket(struct net *net)
 {
        struct x25_sock *x25;
-       struct sock *sk = sk_alloc(AF_X25, GFP_ATOMIC, &x25_proto, 1);
+       struct sock *sk = sk_alloc(net, AF_X25, GFP_ATOMIC, &x25_proto, 1);
 
        if (!sk)
                goto out;
@@ -485,17 +488,20 @@ out:
        return sk;
 }
 
-static int x25_create(struct socket *sock, int protocol)
+static int x25_create(struct net *net, struct socket *sock, int protocol)
 {
        struct sock *sk;
        struct x25_sock *x25;
        int rc = -ESOCKTNOSUPPORT;
 
+       if (net != &init_net)
+               return -EAFNOSUPPORT;
+
        if (sock->type != SOCK_SEQPACKET || protocol)
                goto out;
 
        rc = -ENOMEM;
-       if ((sk = x25_alloc_socket()) == NULL)
+       if ((sk = x25_alloc_socket(net)) == NULL)
                goto out;
 
        x25 = x25_sk(sk);
@@ -543,7 +549,7 @@ static struct sock *x25_make_new(struct sock *osk)
        if (osk->sk_type != SOCK_SEQPACKET)
                goto out;
 
-       if ((sk = x25_alloc_socket()) == NULL)
+       if ((sk = x25_alloc_socket(osk->sk_net)) == NULL)
                goto out;
 
        x25 = x25_sk(sk);
@@ -951,7 +957,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
         *      Incoming Call User Data.
         */
        if (skb->len >= 0) {
-               memcpy(makex25->calluserdata.cuddata, skb->data, skb->len);
+               skb_copy_from_linear_data(skb, makex25->calluserdata.cuddata, skb->len);
                makex25->calluserdata.cudlength = skb->len;
        }
 
@@ -1058,9 +1064,10 @@ static int x25_sendmsg(struct kiocb *iocb, struct socket *sock,
         */
        SOCK_DEBUG(sk, "x25_sendmsg: Copying user data\n");
 
-       asmptr = skb->h.raw = skb_put(skb, len);
+       skb_reset_transport_header(skb);
+       skb_put(skb, len);
 
-       rc = memcpy_fromiovec(asmptr, msg->msg_iov, len);
+       rc = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len);
        if (rc)
                goto out_kfree_skb;
 
@@ -1210,8 +1217,7 @@ static int x25_recvmsg(struct kiocb *iocb, struct socket *sock,
                }
        }
 
-       skb->h.raw = skb->data;
-
+       skb_reset_transport_header(skb);
        copied = skb->len;
 
        if (copied > size) {
@@ -1280,6 +1286,12 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                                rc = sock_get_timestamp(sk,
                                                (struct timeval __user *)argp);
                        break;
+               case SIOCGSTAMPNS:
+                       rc = -EINVAL;
+                       if (sk)
+                               rc = sock_get_timestampns(sk,
+                                               (struct timespec __user *)argp);
+                       break;
                case SIOCGIFADDR:
                case SIOCSIFADDR:
                case SIOCGIFDSTADDR:
@@ -1521,6 +1533,12 @@ static int compat_x25_ioctl(struct socket *sock, unsigned int cmd,
                        rc = compat_sock_get_timestamp(sk,
                                        (struct timeval __user*)argp);
                break;
+       case SIOCGSTAMPNS:
+               rc = -EINVAL;
+               if (sk)
+                       rc = compat_sock_get_timestampns(sk,
+                                       (struct timespec __user*)argp);
+               break;
        case SIOCGIFADDR:
        case SIOCSIFADDR:
        case SIOCGIFDSTADDR:
@@ -1593,7 +1611,6 @@ static const struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = {
        .sendpage =     sock_no_sendpage,
 };
 
-#include <linux/smp_lock.h>
 SOCKOPS_WRAP(x25_proto, AF_X25);
 
 static struct packet_type x25_packet_type = {