Fix for the f8 build issue.
[linux-2.6.git] / linux-2.6-526-tun-tap.patch
index 16eb819..bcce6ac 100644 (file)
@@ -1,6 +1,6 @@
-diff -Nurb linux-2.6.22-525/drivers/net/Makefile linux-2.6.22-526/drivers/net/Makefile
---- linux-2.6.22-525/drivers/net/Makefile      2008-07-13 23:58:01.000000000 -0400
-+++ linux-2.6.22-526/drivers/net/Makefile      2008-07-13 23:58:45.000000000 -0400
+diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-522-523-524-525/drivers/net/Makefile linux-2.6.27.10-vs2.3.x-PS-522-523-524-525-526/drivers/net/Makefile
+--- linux-2.6.27.10-vs2.3.x-PS-522-523-524-525/drivers/net/Makefile    2008-10-13 14:52:02.000000000 +0200
++++ linux-2.6.27.10-vs2.3.x-PS-522-523-524-525-526/drivers/net/Makefile        2009-01-21 03:45:50.000000000 +0100
 @@ -1,7 +1,7 @@
  #
  # Makefile for the Linux network (ethercard) device drivers.
@@ -9,11 +9,11 @@ diff -Nurb linux-2.6.22-525/drivers/net/Makefile linux-2.6.22-526/drivers/net/Ma
 +obj-m += vnet_tun.o
  obj-$(CONFIG_E1000) += e1000/
  obj-$(CONFIG_E1000E) += e1000e/
- obj-$(CONFIG_IBM_EMAC) += ibm_emac/
-diff -Nurb linux-2.6.22-525/drivers/net/vnet_tun.c linux-2.6.22-526/drivers/net/vnet_tun.c
---- linux-2.6.22-525/drivers/net/vnet_tun.c    1969-12-31 19:00:00.000000000 -0500
-+++ linux-2.6.22-526/drivers/net/vnet_tun.c    2008-07-14 12:07:47.000000000 -0400
-@@ -0,0 +1,714 @@
+ obj-$(CONFIG_IBM_NEW_EMAC) += ibm_newemac/
+diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-522-523-524-525/drivers/net/vnet_tun.c linux-2.6.27.10-vs2.3.x-PS-522-523-524-525-526/drivers/net/vnet_tun.c
+--- linux-2.6.27.10-vs2.3.x-PS-522-523-524-525/drivers/net/vnet_tun.c  1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.27.10-vs2.3.x-PS-522-523-524-525-526/drivers/net/vnet_tun.c      2009-01-21 03:45:50.000000000 +0100
+@@ -0,0 +1,725 @@
 +/*
 + *  TUN - Universal TUN/TAP device driver.
 + *  Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com>
@@ -103,7 +103,7 @@ diff -Nurb linux-2.6.22-525/drivers/net/vnet_tun.c linux-2.6.22-526/drivers/net/
 +      else {
 +              if (in_interrupt() && print_once) {
 +                      print_once=0;
-+                      printk(KERN_EMERG "vnet_tun: get-sk_xid called in interrupt context!\n");
++                      printk(KERN_EMERG "vnet_tun: get-sk_xid called in interrupt context! Stephen: Don't Panic.\n");
 +              }
 +              return current->xid;
 +      }
@@ -111,6 +111,7 @@ diff -Nurb linux-2.6.22-525/drivers/net/vnet_tun.c linux-2.6.22-526/drivers/net/
 +
 +#define set_sk_xid(sk,xid) sk->sk_nid=xid
 +#define set_skb_xid(skb,xid) skb->skb_tag=xid
++#define get_skb_xid(skb) skb->skb_tag
 +
 +/* Extended fields */
 +struct tun_pi_ext {
@@ -195,9 +196,15 @@ diff -Nurb linux-2.6.22-525/drivers/net/vnet_tun.c linux-2.6.22-526/drivers/net/
 +/* Net device start xmit */
 +static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 +{
-+      xid_t xid = get_sk_xid(skb->sk);
-+      struct tun_struct *tun = tun_get_by_xid(xid);
++      xid_t xid, skb_xid; 
++      struct tun_struct *tun;
++      skb_xid=get_skb_xid(skb);
++      if (skb_xid<1) 
++              xid=get_sk_xid(skb->sk);
++      else
++              xid=skb_xid;
 +
++      tun = tun_get_by_xid(xid);
 +      /* Mark packet */
 +      set_skb_xid(skb, xid);
 +
@@ -728,3 +735,187 @@ diff -Nurb linux-2.6.22-525/drivers/net/vnet_tun.c linux-2.6.22-526/drivers/net/
 +
 +      unregister_netdev(&tun_netdev);
 +}
++
++module_init(tun_init);
++module_cleanup(tun_cleanup);
++MODULE_LICENSE("GPL");
+
+; fixup
+diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-02.0/drivers/net/tun.c linux-2.6.27.10-vs2.3.x-PS-02.1/drivers/net/tun.c
+--- linux-2.6.27.10-vs2.3.x-PS-02.0/drivers/net/tun.c  2008-10-13 14:54:20.000000000 +0200
++++ linux-2.6.27.10-vs2.3.x-PS-02.1/drivers/net/tun.c  2009-01-24 20:23:36.000000000 +0100
+@@ -81,33 +81,6 @@ static int debug;
+ #define DBG1( a... )
+ #endif
+-#define FLT_EXACT_COUNT 8
+-struct tap_filter {
+-      unsigned int    count;    /* Number of addrs. Zero means disabled */
+-      u32             mask[2];  /* Mask of the hashed addrs */
+-      unsigned char   addr[FLT_EXACT_COUNT][ETH_ALEN];
+-};
+-
+-struct tun_struct {
+-      struct list_head        list;
+-      unsigned int            flags;
+-      int                     attached;
+-      uid_t                   owner;
+-      gid_t                   group;
+-      nid_t                   nid;
+-
+-      wait_queue_head_t       read_wait;
+-      struct sk_buff_head     readq;
+-
+-      struct net_device       *dev;
+-      struct fasync_struct    *fasync;
+-
+-      struct tap_filter       txflt;
+-
+-#ifdef TUN_DEBUG
+-      int debug;
+-#endif
+-};
+ /* TAP filterting */
+ static void addr_hash_set(u32 *mask, const u8 *addr)
+diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-02.0/include/linux/if_tun.h linux-2.6.27.10-vs2.3.x-PS-02.1/include/linux/if_tun.h
+--- linux-2.6.27.10-vs2.3.x-PS-02.0/include/linux/if_tun.h     2008-10-13 14:54:20.000000000 +0200
++++ linux-2.6.27.10-vs2.3.x-PS-02.1/include/linux/if_tun.h     2009-01-24 20:23:47.000000000 +0100
+@@ -83,4 +83,32 @@ struct tun_filter {
+       __u8   addr[0][ETH_ALEN];
+ };
++#define FLT_EXACT_COUNT 8
++struct tap_filter {
++      unsigned int    count;    /* Number of addrs. Zero means disabled */
++      u32             mask[2];  /* Mask of the hashed addrs */
++      unsigned char   addr[FLT_EXACT_COUNT][ETH_ALEN];
++};
++
++struct tun_struct {
++      struct list_head        list;
++      unsigned int            flags;
++      int                     attached;
++      uid_t                   owner;
++      gid_t                   group;
++      nid_t                   nid;
++
++      wait_queue_head_t       read_wait;
++      struct sk_buff_head     readq;
++
++      struct net_device       *dev;
++      struct fasync_struct    *fasync;
++
++      struct tap_filter       txflt;
++
++#ifdef TUN_DEBUG
++      int debug;
++#endif
++};
++
+ #endif /* __IF_TUN_H */
+diff -NurpP --exclude '*.orig' --exclude '*.rej' linux-2.6.27.10-vs2.3.x-PS-02.0/drivers/net/vnet_tun.c linux-2.6.27.10-vs2.3.x-PS-02.1/drivers/net/vnet_tun.c
+--- linux-2.6.27.10-vs2.3.x-PS-02.0/drivers/net/vnet_tun.c     2009-01-25 02:29:32.000000000 +0100
++++ linux-2.6.27.10-vs2.3.x-PS-02.1/drivers/net/vnet_tun.c     2009-01-24 23:17:50.000000000 +0100
+@@ -133,14 +133,12 @@ static struct tun_struct *tun_get_by_xid
+       struct tun_struct *tun;
+       read_lock_bh(&tun_dev_hash_lock);
+-
+       list_for_each_entry(tun, &tun_dev_hash[__xidhashfn(xid)], list) {
+               if (tun->owner == xid) {
+                       read_unlock_bh(&tun_dev_hash_lock);
+                       return tun;
+               }
+       }
+-
+       read_unlock_bh(&tun_dev_hash_lock);
+       return NULL;
+@@ -173,7 +171,7 @@ static void tun_xmit(struct sk_buff *skb
+  drop:
+       if (tun)
+-              tun->stats.tx_dropped++;
++              tun->dev->stats.tx_dropped++;
+       tun_stats.tx_dropped++;
+ }
+@@ -182,11 +180,12 @@ static int tun_net_xmit(struct sk_buff *
+ {
+       xid_t xid, skb_xid; 
+       struct tun_struct *tun;
+-      skb_xid=get_skb_xid(skb);
+-      if (skb_xid<1) 
+-              xid=get_sk_xid(skb->sk);
++
++      skb_xid = get_skb_xid(skb);
++      if (skb_xid < 1) 
++              xid = get_sk_xid(skb->sk);
+       else
+-              xid=skb_xid;
++              xid = skb_xid;
+       tun = tun_get_by_xid(xid);
+       /* Mark packet */
+@@ -214,7 +213,7 @@ static void tun_net_mclist(struct net_de
+ static struct net_device_stats *tun_net_stats(struct net_device *dev)
+ {
+       struct tun_struct *tun = tun_get_by_xid(current->xid);
+-      return tun ? &tun->stats : &tun_stats;
++      return tun ? &tun->dev->stats : &tun_stats;
+ }
+ /* Character device part */
+@@ -263,7 +262,7 @@ static __inline__ ssize_t tun_get_user(s
+       }
+  
+       if (!(skb = alloc_skb(len + 2, GFP_KERNEL))) {
+-              tun->stats.rx_dropped++;
++              tun->dev->stats.rx_dropped++;
+               tun_stats.rx_dropped++;
+               return -ENOMEM;
+       }
+@@ -291,8 +290,8 @@ static __inline__ ssize_t tun_get_user(s
+       netif_rx_ni(skb);
+    
+-      tun->stats.rx_packets++;
+-      tun->stats.rx_bytes += len;
++      tun->dev->stats.rx_packets++;
++      tun->dev->stats.rx_bytes += len;
+       tun_stats.rx_packets++;
+       tun_stats.rx_bytes += len;
+@@ -417,8 +416,8 @@ static __inline__ ssize_t tun_put_user(s
+       skb_copy_datagram_iovec(skb, 0, iv, len);
+       total += len;
+-      tun->stats.tx_packets++;
+-      tun->stats.tx_bytes += len;
++      tun->dev->stats.tx_packets++;
++      tun->dev->stats.tx_bytes += len;
+       tun_stats.tx_packets++;
+       tun_stats.tx_bytes += len;
+@@ -688,7 +687,7 @@ int __init tun_init(void)
+       dev->flags |= IFF_NOARP | IFF_POINTOPOINT;
+       dev->flags &= ~IFF_MULTICAST;
+-      SET_MODULE_OWNER(dev);
++      // SET_MODULE_OWNER(dev);
+       dev->hard_start_xmit = tun_net_xmit;
+       dev->get_stats = tun_net_stats;
+@@ -721,5 +720,8 @@ void __exit tun_cleanup(void)
+ }
+ module_init(tun_init);
+-module_cleanup(tun_cleanup);
++module_exit(tun_cleanup);
++// MODULE_DESCRIPTION(DRV_DESCRIPTION);
++// MODULE_AUTHOR(DRV_COPYRIGHT);
++// MODULE_ALIAS_MISCDEV(TUN_MINOR);
+ MODULE_LICENSE("GPL");
+
+