Patch to make Click work with Linux-2.6.27.10/Vserver/NetNS
[linux-2.6.git] / support / patch-click-1.6.0-linux-2.6.27.10
1 --- click-1.6.0-27/lib/ino.cc.orig      2007-09-11 15:39:22.000000000 -0400
2 +++ click-1.6.0-27/lib/ino.cc   2009-01-20 22:34:50.000000000 -0500
3 @@ -34,6 +34,16 @@
4      _generation = 0;
5  }
6  
7 +#define DT_UNKNOWN      0
8 +#define DT_FIFO         1
9 +#define DT_CHR          2
10 +#define DT_DIR          4
11 +#define DT_BLK          6
12 +#define DT_REG          8
13 +#define DT_LNK          10
14 +#define DT_SOCK         12
15 +#define DT_WHT          14
16 +
17  void
18  ClickIno::cleanup()
19  {
20 --- click-1.6.0-27/include/clicknet/ip.h.orig   2007-07-16 19:47:50.000000000 -0400
21 +++ click-1.6.0-27/include/clicknet/ip.h        2009-01-19 16:01:43.000000000 -0500
22 @@ -5,6 +5,7 @@
23  #include <click/cxxprotect.h>
24  CLICK_CXX_PROTECT
25  #if CLICK_LINUXMODULE
26 +#include <linux/autoconf.h>
27  # include <net/checksum.h>
28  # include <linux/in.h>
29  #else
30 --- click-1.6.0-27/include/click/glue.hh.orig   2007-09-12 18:24:50.000000000 -0400
31 +++ click-1.6.0-27/include/click/glue.hh        2009-01-27 10:12:52.000000000 -0500
32 @@ -15,6 +15,7 @@
33  # endif
34  # include <click/cxxprotect.h>
35  CLICK_CXX_PROTECT
36 +#include <linux/autoconf.h>
37  # ifdef WANT_MOD_USE_COUNT
38  #  define __NO_VERSION__
39  #  include <linux/module.h>
40 --- click-1.6.0-27/include/click/packet.hh.orig 2007-09-07 16:11:26.000000000 -0400
41 +++ click-1.6.0-27/include/click/packet.hh      2009-01-27 10:13:43.000000000 -0500
42 @@ -452,7 +452,7 @@
43  Packet::mac_header() const
44  {
45  #if CLICK_LINUXMODULE
46 -    return skb()->mac.raw;
47 +    return skb_mac_header(skb());
48  #else
49      return _mac;
50  #endif
51 @@ -462,7 +462,7 @@
52  Packet::network_header() const
53  {
54  #if CLICK_LINUXMODULE
55 -    return skb()->nh.raw;
56 +    return skb_network_header(skb());
57  #else
58      return _nh;
59  #endif
60 @@ -472,7 +472,7 @@
61  Packet::transport_header() const
62  {
63  #if CLICK_LINUXMODULE
64 -    return skb()->h.raw;
65 +    return skb_transport_header(skb());
66  #else
67      return _h;
68  #endif
69 @@ -567,7 +567,7 @@
70  # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 13)
71      memcpy(&skb()->stamp, &timestamp, 8);
72  # else
73 -    skb_set_timestamp(skb(), &timestamp.timeval());
74 +    memcpy(&skb()->tstamp, &timestamp, 8);
75  # endif
76  #else
77      _timestamp = timestamp;
78 @@ -904,7 +904,7 @@
79  Packet::set_mac_header(const unsigned char *h)
80  {
81  #if CLICK_LINUXMODULE  /* Linux kernel module */
82 -    skb()->mac.raw = const_cast<unsigned char *>(h);
83 +    skb()->mac_header = const_cast<unsigned char *>(h);
84  #else                          /* User-space and BSD kernel module */
85      _mac = const_cast<unsigned char *>(h);
86  #endif
87 @@ -914,8 +914,8 @@
88  Packet::set_mac_header(const unsigned char *h, uint32_t len)
89  {
90  #if CLICK_LINUXMODULE  /* Linux kernel module */
91 -    skb()->mac.raw = const_cast<unsigned char *>(h);
92 -    skb()->nh.raw = const_cast<unsigned char *>(h) + len;
93 +    skb()->mac_header = const_cast<unsigned char *>(h);
94 +    skb()->network_header = const_cast<unsigned char *>(h) + len;
95  #else                          /* User-space and BSD kernel module */
96      _mac = const_cast<unsigned char *>(h);
97      _nh = const_cast<unsigned char *>(h) + len;
98 @@ -956,8 +956,8 @@
99  Packet::set_network_header(const unsigned char *h, uint32_t len)
100  {
101  #if CLICK_LINUXMODULE  /* Linux kernel module */
102 -    skb()->nh.raw = const_cast<unsigned char *>(h);
103 -    skb()->h.raw = const_cast<unsigned char *>(h) + len;
104 +    skb()->network_header = const_cast<unsigned char *>(h);
105 +    skb()->transport_header = const_cast<unsigned char *>(h) + len;
106  #else                          /* User-space and BSD kernel module */
107      _nh = const_cast<unsigned char *>(h);
108      _h = const_cast<unsigned char *>(h) + len;
109 @@ -968,7 +968,7 @@
110  Packet::set_network_header_length(uint32_t len)
111  {
112  #if CLICK_LINUXMODULE  /* Linux kernel module */
113 -    skb()->h.raw = skb()->nh.raw + len;
114 +    skb()->transport_header = skb()->network_header + len;
115  #else                          /* User-space and BSD kernel module */
116      _h = _nh + len;
117  #endif
118 @@ -1076,9 +1076,9 @@
119    _h += (_h ? shift : 0);
120  #else
121    struct sk_buff *mskb = skb();
122 -  mskb->mac.raw += (mskb->mac.raw ? shift : 0);
123 -  mskb->nh.raw += (mskb->nh.raw ? shift : 0);
124 -  mskb->h.raw += (mskb->h.raw ? shift : 0);
125 +  mskb->mac_header += (mskb->mac_header ? shift : 0);
126 +  mskb->network_header += (mskb->network_header ? shift : 0);
127 +  mskb->transport_header += (mskb->transport_header ? shift : 0);
128  #endif
129  }
130  
131 --- click-1.6.0-27/include/click/config-linuxmodule.h.orig      2009-01-19 15:07:24.000000000 -0500
132 +++ click-1.6.0-27/include/click/config-linuxmodule.h   2009-01-20 22:30:23.000000000 -0500
133 @@ -87,12 +87,13 @@
134  #endif
135  
136  /* Include integer type definitions. */
137 +# include <linux/autoconf.h>
138  #if !HAVE_LINUXMODULE_2_6
139  # include <linux/autoconf.h>
140  #endif
141  #include <linux/types.h>
142  typedef ptrdiff_t intptr_t;
143 -typedef unsigned long uintptr_t; /* XXX? */
144 +//typedef unsigned long uintptr_t; /* XXX? */
145  
146  /* Define HAVE_INT64_IS_LONG based on HAVE_INT64_IS_LONG_LINUXMODULE. */
147  #ifdef HAVE_INT64_IS_LONG_LINUXMODULE
148 @@ -114,11 +115,11 @@
149  #ifdef __cplusplus
150  
151  /* Declare operator new. */
152 -void *operator new(size_t) throw ();
153 -void *operator new[](size_t) throw ();
154 +void *operator new(unsigned int) throw ();
155 +void *operator new[](unsigned int) throw ();
156  
157  /* Provide placement new. */
158 -inline void *operator new(size_t, void *v) { return v; }
159 +inline void *operator new(unsigned int, void *v) { return v; }
160  #define HAVE_PLACEMENT_NEW 1
161  
162  /* Define macros that surround Click declarations. */
163 --- click-1.6.0-27/linuxmodule/Makefile.orig    2009-01-19 15:15:55.000000000 -0500
164 +++ click-1.6.0-27/linuxmodule/Makefile 2009-01-20 10:22:39.000000000 -0500
165 @@ -95,7 +95,7 @@
166  
167  CLICKDEFS = -DHAVE_CONFIG_H 
168  CLICKINCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
169 -       -I$(srcdir) -I$(top_srcdir) -I$(linuxdir)/include
170 +       -I$(srcdir) -I$(top_srcdir) -I$(linuxdir)/include -I$(linuxdir)/include/asm/mach-default
171  
172  CXXCOMPILE = $(CLICKCXX) $(LINUXCFLAGS) $(CLICKCPPFLAGS) $(CLICKCFLAGS) \
173         $(CLICKCXXFLAGS) $(CLICKDEFS) $(CLICKINCLUDES) $(CLICKDEPCFLAGS)
174 @@ -177,7 +177,7 @@
175  
176  CC = gcc -w -W -Wall
177  CPP = gcc -W -Wall -E
178 -CXX = g++ -w -W -Wall -fno-exceptions -fno-rtti  -D__SMP__
179 +CXX = g++ -w -W -fno-exceptions -fno-rtti  -D__SMP__
180  CXXCPP = g++ -W -Wall  -E
181  LD = ld
182  STRIP = strip
183 --- click-1.6.0-27/linuxmodule/sched.cc.orig    2007-08-28 19:01:58.000000000 -0400
184 +++ click-1.6.0-27/linuxmodule/sched.cc 2009-01-26 16:55:57.000000000 -0500
185 @@ -228,7 +228,7 @@
186    click_thread_priority = priority;
187    if (click_thread_pids)
188      for (int i = 0; i < click_thread_pids->size(); i++) {
189 -      struct task_struct *task = find_task_by_pid((*click_thread_pids)[i]);
190 +      struct task_struct *task = find_task_by_vpid((*click_thread_pids)[i]);
191        if (task)
192         TASK_PRIO(task) = priority;
193      }
194 @@ -429,7 +429,7 @@
195      SOFT_SPIN_LOCK(&click_thread_lock);
196      for (int i = 0; i < click_thread_pids->size(); i++) {
197        printk("<1>click:   router thread pid %d\n", (*click_thread_pids)[i]);
198 -      struct task_struct *ct = find_task_by_pid((*click_thread_pids)[i]);
199 +      struct task_struct *ct = find_task_by_vpid((*click_thread_pids)[i]);
200        if (ct)
201           printk("<1>click:   state %d, EIP %08x\n", (int) ct->state, KSTK_EIP(ct));
202      }
203 --- click-1.6.0-27/linuxmodule/proclikefs.c.orig        2007-07-16 19:47:50.000000000 -0400
204 +++ click-1.6.0-27/linuxmodule/proclikefs.c     2009-01-26 17:17:09.000000000 -0500
205 @@ -20,6 +20,7 @@
206  #undef CLICK_LINUXMODULE
207  #include <linux/version.h>
208  #include <linux/autoconf.h>
209 +#include <linux/list.h>
210  #ifndef EXPORT_SYMTAB
211  # define EXPORT_SYMTAB
212  #endif
213 @@ -73,7 +74,7 @@
214      char name[1];
215  };
216  
217 -static LIST_HEAD(fs_list);
218 +static struct list_head fs_list;
219  static spinlock_t fslist_lock;
220  extern spinlock_t inode_lock;
221  extern spinlock_t sb_lock;
222 @@ -357,7 +358,7 @@
223         fo->unlocked_ioctl = (void *) return_EIO;
224         fo->compat_ioctl = (void *) return_EIO;
225         fo->aio_fsync = (void *) return_EIO;
226 -       fo->sendfile = (void *) return_EIO;
227 +       //fo->sendfile = (void *) return_EIO;
228         fo->check_flags = (void *) return_EIO;
229         fo->flock = (void *) return_EIO;
230  #endif
231 @@ -533,10 +534,12 @@
232  int
233  init_module(void)
234  {
235 -    proclikefs_null_super_operations.read_inode = proclikefs_read_inode;
236 +    //proclikefs_null_super_operations.read_inode = proclikefs_read_inode;
237      proclikefs_null_super_operations.put_super = proclikefs_put_super;
238      proclikefs_null_root_inode_operations.lookup = proclikefs_null_root_lookup;
239      spin_lock_init(&fslist_lock);
240 +    INIT_LIST_HEAD(&fs_list);
241 +    printk (KERN_CRIT "Initializing module\n");
242      return 0;
243  }
244  
245 --- click-1.6.0-27/elements/linuxmodule/tohost.cc.orig  2007-08-31 11:21:55.000000000 -0400
246 +++ click-1.6.0-27/elements/linuxmodule/tohost.cc       2009-01-26 16:52:00.000000000 -0500
247 @@ -143,7 +143,7 @@
248  
249      // do not call eth_type_trans; it changes pkt_type! Instead, do its work
250      // directly.
251 -    skb->mac.raw = skb->data;
252 +    skb->mac_header = skb->data;
253      skb_pull(skb, 14);
254  
255  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
256 --- click-1.6.0-27/elements/linuxmodule/fromdevice.cc.orig      2007-08-29 04:01:48.000000000 -0400
257 +++ click-1.6.0-27/elements/linuxmodule/fromdevice.cc   2009-01-26 14:38:07.000000000 -0500
258 @@ -258,7 +258,7 @@
259         assert(skb_shared(skb) == 0); /* else skb = skb_clone(skb, GFP_ATOMIC); */
260  
261         /* Retrieve the MAC header. */
262 -       skb_push(skb, skb->data - skb->mac.raw);
263 +       skb_push(skb, skb->data - skb_mac_header(skb));
264  
265         Packet *p = Packet::make(skb);
266         _queue[_tail] = p; /* hand it to run_task */
267 --- click-1.6.0-27/elements/linuxmodule/fromhost.cc.orig        2007-07-16 19:47:50.000000000 -0400
268 +++ click-1.6.0-27/elements/linuxmodule/fromhost.cc     2009-01-26 15:16:05.000000000 -0500
269 @@ -121,7 +121,7 @@
270      used = this;
271      
272      // check for existing device
273 -    _dev = dev_get_by_name(_devname.c_str());
274 +    _dev = dev_get_by_name(&init_net, _devname.c_str());
275      if (_dev) {
276         if (_dev->open != fl_open) {
277             dev_put(_dev);
278 @@ -175,16 +175,16 @@
279  
280      ifr.ifr_hwaddr.sa_family = _dev->type;
281      memcpy(ifr.ifr_hwaddr.sa_data, _macaddr.data(), 6);
282 -    if ((res = dev_ioctl(SIOCSIFHWADDR, &ifr)) < 0)
283 +    if ((res = dev_ioctl(&init_net, SIOCSIFHWADDR, &ifr)) < 0)
284         errh->error("error %d setting hardware address for device '%s'", res, _devname.c_str());
285  
286      sin->sin_family = AF_INET;
287      sin->sin_addr = _destaddr;
288 -    if (res >= 0 && (res = devinet_ioctl(SIOCSIFADDR, &ifr)) < 0)
289 +    if (res >= 0 && (res = devinet_ioctl(&init_net,SIOCSIFADDR, &ifr)) < 0)
290         errh->error("error %d setting address for device '%s'", res, _devname.c_str());
291  
292      sin->sin_addr = _destmask;
293 -    if (res >= 0 && (res = devinet_ioctl(SIOCSIFNETMASK, &ifr)) < 0)
294 +    if (res >= 0 && (res = devinet_ioctl(&init_net,SIOCSIFNETMASK, &ifr)) < 0)
295         errh->error("error %d setting netmask for device '%s'", res, _devname.c_str());
296  
297      set_fs(oldfs);
298 @@ -202,9 +202,9 @@
299      mm_segment_t oldfs = get_fs();
300      set_fs(get_ds());
301  
302 -    (void) dev_ioctl(SIOCGIFFLAGS, &ifr);
303 +    (void) dev_ioctl(&init_net, SIOCGIFFLAGS, &ifr);
304      ifr.ifr_flags = (up > 0 ? ifr.ifr_flags | flags : ifr.ifr_flags & ~flags);
305 -    if ((res = dev_ioctl(SIOCSIFFLAGS, &ifr)) < 0 && errh)
306 +    if ((res = dev_ioctl(&init_net, SIOCSIFFLAGS, &ifr)) < 0 && errh)
307         errh->error("error %d bringing %s device '%s'", res, (up > 0 ? "up" : "down"), dev->name);
308  
309      set_fs(oldfs);
310 --- click-1.6.0-27/elements/linuxmodule/anydevice.cc.orig       2007-08-29 04:03:55.000000000 -0400
311 +++ click-1.6.0-27/elements/linuxmodule/anydevice.cc    2009-01-21 14:44:39.000000000 -0500
312 @@ -49,7 +49,7 @@
313  int
314  AnyDevice::find_device(AnyDeviceMap *adm, ErrorHandler *errh)
315  {
316 -    _dev = dev_get_by_name(_devname.c_str());
317 +    _dev = dev_get_by_name(&init_net,_devname.c_str());
318      _devname_exists = (bool) _dev;
319      if (!_dev)
320         _dev = dev_get_by_ether_address(_devname, this);
321 @@ -233,7 +233,7 @@
322         return 0;
323      read_lock(&dev_base_lock);
324      net_device *dev;
325 -    for (dev = dev_base; dev; dev = dev->next)
326 +    for_each_netdev(&init_net, dev)//for (dev = dev_base; dev; dev = dev->next)
327         if ((dev->type == ARPHRD_ETHER || dev->type == ARPHRD_80211)
328             && memcmp(en, dev->dev_addr, 6) == 0) {
329             dev_hold(dev);      // dev_get_by_name does dev_hold; so
330 --- click-1.6.0-27/elements/linuxmodule/todevice.cc.orig        2007-09-14 12:19:28.000000000 -0400
331 +++ click-1.6.0-27/elements/linuxmodule/todevice.cc     2009-01-26 16:50:39.000000000 -0500
332 @@ -21,6 +21,8 @@
333   * legally binding.
334   */
335  
336 +#include <linux/autoconf.h>
337 +#include <linux/version.h>
338  #include <click/config.h>
339  #include <click/glue.hh>
340  #include "polldevice.hh"
341 @@ -243,12 +245,12 @@
342      }
343  # else
344      local_bh_disable();
345 -    if (!spin_trylock(&_dev->xmit_lock)) {
346 +    if (!spin_trylock(&_dev->_tx[0]._xmit_lock)) {
347         local_bh_enable();
348         _task.fast_reschedule();
349         return false;
350      }
351 -    _dev->xmit_lock_owner = smp_processor_id();
352 +    _dev->_tx[0].xmit_lock_owner = smp_processor_id();
353  # endif
354  #endif
355  
356 @@ -316,7 +318,7 @@
357      // (or until Linux sends another packet) unless we poke
358      // net_bh(), which calls qdisc_restart(). We are not allowed
359      // to call qdisc_restart() ourselves, outside of net_bh().
360 -    if (is_polling && !busy && _dev->qdisc->q.qlen) {
361 +    if (is_polling && !busy && _dev->_tx[0].qdisc->q.qlen) {
362         _dev->tx_eob(_dev);
363         netif_wake_queue(_dev);
364      }
365 @@ -349,8 +351,8 @@
366  # if HAVE_NETIF_TX_LOCK
367      netif_tx_unlock_bh(_dev);
368  # else
369 -    _dev->xmit_lock_owner = -1;
370 -    spin_unlock(&_dev->xmit_lock);
371 +    _dev->_tx[0].xmit_lock_owner = -1;
372 +    spin_unlock(&_dev->_tx[0]._xmit_lock);
373      local_bh_enable();
374  # endif
375  #endif
376 --- click-1.6.0-27/elements/standard/addressinfo.cc.orig        2007-09-12 02:14:04.000000000 -0400
377 +++ click-1.6.0-27/elements/standard/addressinfo.cc     2009-01-21 13:08:40.000000000 -0500
378 @@ -272,7 +272,7 @@
379      // if it's a device name, return a primary IP address
380  #if CLICK_LINUXMODULE
381  # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
382 -    net_device *dev = dev_get_by_name(s.c_str());
383 +    net_device *dev = dev_get_by_name(&init_net,s.c_str());
384      if (dev) {
385         bool found = false;
386         in_device *in_dev = in_dev_get(dev);
387 @@ -383,7 +383,7 @@
388  # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
389  #  define dev_put(dev) /* nada */
390  # endif
391 -    net_device *dev = dev_get_by_name(s.c_str());
392 +    net_device *dev = dev_get_by_name(&init_net,s.c_str());
393      if (dev && (dev->type == ARPHRD_ETHER || dev->type == ARPHRD_80211)) {
394         memcpy(store, dev->dev_addr, 6);
395         dev_put(dev);