]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tun.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / drivers / net / tun.c
index f8b8c71187a076f426b40833f5631d9445c9fdf0..038c1ef94d2e72e7332a4e28a86cbd82be14788a 100644 (file)
@@ -292,17 +292,6 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv,
        return count;
 }
 
-static inline size_t iov_total(const struct iovec *iv, unsigned long count)
-{
-       unsigned long i;
-       size_t len;
-
-       for (i = 0, len = 0; i < count; i++)
-               len += iv[i].iov_len;
-
-       return len;
-}
-
 static ssize_t tun_chr_aio_write(struct kiocb *iocb, const struct iovec *iv,
                              unsigned long count, loff_t pos)
 {
@@ -313,7 +302,7 @@ static ssize_t tun_chr_aio_write(struct kiocb *iocb, const struct iovec *iv,
 
        DBG(KERN_INFO "%s: tun_chr_write %ld\n", tun->dev->name, count);
 
-       return tun_get_user(tun, (struct iovec *) iv, iov_total(iv, count));
+       return tun_get_user(tun, (struct iovec *) iv, iov_length(iv, count));
 }
 
 /* Put packet to the user space buffer */
@@ -364,7 +353,7 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
 
        DBG(KERN_INFO "%s: tun_chr_read\n", tun->dev->name);
 
-       len = iov_total(iv, count);
+       len = iov_length(iv, count);
        if (len < 0)
                return -EINVAL;
 
@@ -517,7 +506,7 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
                /* Be promiscuous by default to maintain previous behaviour. */
                tun->if_flags = IFF_PROMISC;
                /* Generate random Ethernet address. */
-               *(u16 *)tun->dev_addr = htons(0x00FF);
+               *(__be16 *)tun->dev_addr = htons(0x00FF);
                get_random_bytes(tun->dev_addr + sizeof(u16), 4);
                memset(tun->chr_filter, 0, sizeof tun->chr_filter);
 
@@ -540,9 +529,13 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
 
        if (ifr->ifr_flags & IFF_NO_PI)
                tun->flags |= TUN_NO_PI;
+       else
+               tun->flags &= ~TUN_NO_PI;
 
        if (ifr->ifr_flags & IFF_ONE_QUEUE)
                tun->flags |= TUN_ONE_QUEUE;
+       else
+               tun->flags &= ~TUN_ONE_QUEUE;
 
        file->private_data = tun;
        tun->attached = 1;