This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / net / packet / af_packet.c
index 7ebb64d..429cb4b 100644 (file)
@@ -70,6 +70,9 @@
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/vs_base.h>
+#include <linux/vs_context.h>
+#include <linux/vs_network.h>
 
 #ifdef CONFIG_INET
 #include <net/inet_common.h>
@@ -217,6 +220,8 @@ void packet_sock_destruct(struct sock *sk)
 {
        BUG_TRAP(!atomic_read(&sk->sk_rmem_alloc));
        BUG_TRAP(!atomic_read(&sk->sk_wmem_alloc));
+       BUG_ON(sk->sk_nx_info);
+       BUG_ON(sk->sk_vx_info);
 
        if (!sock_flag(sk, SOCK_DEAD)) {
                printk("Attempt to release alive packet socket: %p\n", sk);
@@ -449,6 +454,9 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,  struct packe
        sk = pt->af_packet_priv;
        po = pkt_sk(sk);
 
+       if (sk->sk_xid && sk->sk_xid != skb->xid)
+               goto drop;
+
        skb->dev = dev;
 
        if (dev->hard_header) {
@@ -819,6 +827,9 @@ static int packet_release(struct socket *sock)
        }
 #endif
 
+       clr_vx_info(&sk->sk_vx_info);
+       clr_nx_info(&sk->sk_nx_info);
+
        /*
         *      Now the socket is dead. No more input will appear.
         */
@@ -994,6 +1005,11 @@ static int packet_create(struct socket *sock, int protocol)
        sk->sk_destruct = packet_sock_destruct;
        atomic_inc(&packet_socks_nr);
 
+       set_vx_info(&sk->sk_vx_info, current->vx_info);
+       sk->sk_xid = vx_current_xid();
+       set_nx_info(&sk->sk_nx_info, current->nx_info);
+       sk->sk_nid = nx_current_nid();
+
        /*
         *      Attach a protocol block
         */
@@ -1037,7 +1053,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
        int copied, err;
 
        err = -EINVAL;
-       if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC))
+       if (flags & ~(MSG_PEEK|MSG_DONTWAIT|MSG_TRUNC|MSG_CMSG_COMPAT))
                goto out;
 
 #if 0
@@ -1292,7 +1308,7 @@ static void packet_flush_mclist(struct sock *sk)
 #endif
 
 static int
-packet_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen)
+packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
 {
        struct sock *sk = sock->sk;
        int ret;
@@ -1347,7 +1363,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char *optval, int
 }
 
 int packet_getsockopt(struct socket *sock, int level, int optname,
-                     char *optval, int *optlen)
+                     char __user *optval, int __user *optlen)
 {
        int len;
        struct sock *sk = sock->sk;
@@ -1450,7 +1466,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
                case SIOCOUTQ:
                {
                        int amount = atomic_read(&sk->sk_wmem_alloc);
-                       return put_user(amount, (int *)arg);
+                       return put_user(amount, (int __user *)arg);
                }
                case SIOCINQ:
                {
@@ -1462,10 +1478,10 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
                        if (skb)
                                amount = skb->len;
                        spin_unlock_bh(&sk->sk_receive_queue.lock);
-                       return put_user(amount, (int *)arg);
+                       return put_user(amount, (int __user *)arg);
                }
                case SIOCGSTAMP:
-                       return sock_get_timestamp(sk, (struct timeval *)arg);
+                       return sock_get_timestamp(sk, (struct timeval __user *)arg);
                        
 #ifdef CONFIG_INET
                case SIOCADDRT:
@@ -1486,7 +1502,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
 #endif
 
                default:
-                       return dev_ioctl(cmd, (void *)arg);
+                       return dev_ioctl(cmd, (void __user *)arg);
        }
        return 0;
 }
@@ -1779,12 +1795,14 @@ struct proto_ops packet_ops = {
        .mmap =         packet_mmap,
        .sendpage =     sock_no_sendpage,
 };
+EXPORT_SYMBOL(packet_ops);
 
-static struct net_proto_family packet_family_ops = {
+struct net_proto_family packet_family_ops = {
        .family =       PF_PACKET,
        .create =       packet_create,
        .owner  =       THIS_MODULE,
 };
+EXPORT_SYMBOL(packet_family_ops);
 
 static struct notifier_block packet_netdev_notifier = {
        .notifier_call =packet_notifier,