* Patch for Apani Nortel VPN Client to build against kernel 2.6.22 help/review
@ 2007-08-22 15:38 Fortier,Vincent [Montreal]
2007-08-22 16:18 ` Nick Bowler
0 siblings, 1 reply; 3+ messages in thread
From: Fortier,Vincent [Montreal] @ 2007-08-22 15:38 UTC (permalink / raw)
To: linux-kernel; +Cc: Gélineau,Samuel [Montreal]
Hi all,
Sadly I have to use the Apani/Nortel VPN linux client to connect to my office. The latest version (3.5) stopped being compatible with the latest stable 2.6.22 kernel (how suprising :().
Since
1) I'm stuck using that closed source/proprietary software
2) there will most probably not be a new release from apani until year 2013
3) support from apani is near zero
we got used with previous version (aka 3.3) to hack the linux_wrapper.c file to try to keep the module compatible (http://www.fedoraforum.org/forum/showpost.php?p=742619&postcount=26)
Based on the horrors that showed up while compiling against a 2.6.22 kernel (see below), I was wondering if somebody would be kind enough to review our not-yet-working patch that converts dev_base/skb calls to the new API. A collegue of mine made all the required changes but when the netlock service gets fired-up the machine hang.
Are there any ways to debug this black box?
Help very much appreciated.
----------------------
Here is the not-yet-working patch against the linux_wrapper.c file:
--- cvc_linux-rh-gcc3-3.5.orig/src/linux_wrapper.c 2007-02-07 19:10:41.000000000 +0000
+++ cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c 2007-08-21 17:42:30.000000000 +0000
@@ -136,6 +136,8 @@ int nl_open(struct inode *inode, struct
/* some necessary globals... */
#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
typedef struct device net_device_t;
+#elif (LINUX_VERSION_CODE >= 0x020616)
+typedef struct list_head net_device_t;
#else
typedef struct net_device net_device_t;
#endif
@@ -306,8 +308,11 @@ nl_copy_to_user(void *to, const void *fr
void init_misc(void)
{
-
+#if (LINUX_VERSION_CODE >= 0x020616)
+ nl_dev_base = &dev_base_head;
+#else
nl_dev_base = dev_base;
+#endif
}
#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
@@ -430,8 +435,13 @@ void nl_skb_put(struct sk_buff *skb, int
int nl_ip_rcv(struct sk_buff *skb, struct packet_type *pt)
{
#if (LINUX_VERSION_CODE > 0x02060c)
+#if (LINUX_VERSION_CODE >= 0x020616)
+ struct net_device *dev = skb->dev;
+ struct iphdr *iph = (struct iphdr*) skb->network_header;
+#else
struct net_device *dev = skb->dev;
struct iphdr *iph = skb->nh.iph;
+#endif
if (skb->dst == NULL)
{
@@ -469,28 +479,52 @@ int nl_unregister_netdevice_notifier(str
char *dev_name (net_device_t *dev)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (net_device_entry(dev)->name);
+#else
return (dev->name);
+#endif
}
int dev_name_len (net_device_t *dev)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (strlen(net_device_entry(dev)->name));
+#else
return (strlen(dev->name));
+#endif
}
unsigned *dev_mtu_ptr (net_device_t *dev)
{
- return (&dev->mtu);
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return &(net_device_entry(dev)->mtu);
+#else
+ return &(dev->mtu);
+#endif
}
unsigned dev_mtu (net_device_t *dev)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (net_device_entry(dev)->mtu);
+#else
return (dev->mtu);
+#endif
}
int dev_ifindex (net_device_t *dev)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (net_device_entry(dev)->ifindex);
+#else
return (dev->ifindex);
+#endif
}
void *dev_ip_ptr (net_device_t *dev)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (net_device_entry(dev)->ip_ptr);
+#else
return (dev->ip_ptr);
+#endif
}
net_device_t *dev_next (net_device_t *dev)
{
@@ -546,9 +580,15 @@ void nl_skb_dup (struct sk_buff *new_skb
head_offset = new_skb->head - skb->head;
new_skb->dev = skb->dev;
new_skb->dst = dst_clone(skb->dst);
+#if (LINUX_VERSION_CODE >= 0x020616)
+ new_skb->transport_header = skb->transport_header+head_offset;
+ new_skb->network_header = skb->network_header+head_offset;
+ new_skb->mac_header = skb->mac_header+head_offset;
+#else
new_skb->h.raw = skb->h.raw+head_offset;
new_skb->nh.raw = skb->nh.raw+head_offset;
new_skb->mac.raw = skb->mac.raw+head_offset;
+#endif
memcpy(new_skb->cb, skb->cb, sizeof(skb->cb));
new_skb->priority = skb->priority;
new_skb->protocol = skb->protocol;
@@ -573,9 +613,15 @@ void nl_skb_hdr_copy (struct sk_buff *sk
{
skb_to->dev = skb_from->dev;
skb_to->dst = skb_from->dst;
+#if (LINUX_VERSION_CODE >= 0x020616)
+ skb_to->transport_header = skb_from->transport_header;
+ skb_to->network_header = skb_from->network_header;
+ skb_to->mac_header = skb_from->mac_header;
+#else
skb_to->h.raw = skb_from->h.raw;
skb_to->nh.raw = skb_from->nh.raw;
skb_to->mac.raw = skb_from->mac.raw;
+#endif
memcpy(skb_to->cb, skb_from->cb, sizeof(skb_from->cb));
skb_to->priority = skb_from->priority;
skb_to->protocol = skb_from->protocol;
@@ -592,7 +638,11 @@ void nl_skb_hdr_copy (struct sk_buff *sk
struct iphdr * nl_skb_iph (struct sk_buff *skb)
{
+#if (LINUX_VERSION_CODE >= 0x020616)
+ return (struct iphdr*) skb->network_header;
+#else
return skb->nh.iph;
+#endif
}
net_device_t * nl_skb_dev (struct sk_buff *skb)
@@ -613,10 +663,14 @@ void nl_send_skb (struct sk_buff *skb, n
if (skb)
{
- skb->nh.iph = (struct iphdr *) skb->data;
skb->dev = dev;
-
- iph = skb->nh.iph;
+#if (LINUX_VERSION_CODE >= 0x020616)
+ skb->network_header = skb->data;
+ iph = (struct iphdr*) skb->network_header;
+#else
+ skb->nh.iph = (struct iphdr *) skb->data;
+ iph = skb->network_header.iph;
+#endif
rval = ip_route_output (&rt, iph->daddr, 0, RT_TOS(iph->tos), 0);
@@ -749,7 +803,11 @@ void do_checksum_offload( struct sk_buff
{
goto done_exit;
}
+#if (LINUX_VERSION_CODE >= 0x020616)
+ iph = (struct iphdr*) skb->network_header;
+#else
iph = skb->nh.iph;
+#endif
header_length = iph->ihl << 2; /* get the ip header length */
h_ptr = (char*)iph + header_length; /* get pointer to proto header */
frag_ptr = skb_shinfo( skb )->frag_list; /* at most, one frag */
@@ -765,11 +823,11 @@ void do_checksum_offload( struct sk_buff
csum = csum_partial( h_ptr, ntohs(iph->tot_len) - header_length, 0 );
check = csum_fold( csum_partial( frag_ptr->data, nl_data_len( frag_ptr ), csum ) );
}
- if ( skb->nh.iph->protocol == 17 ) /* if UDP, */
+ if ( iph->protocol == 17 ) /* if UDP, */
{
((struct udphdr*)h_ptr)->check = check;
}
- if ( skb->nh.iph->protocol == 6 ) /* if TCP, */
+ if ( iph->protocol == 6 ) /* if TCP, */
{
((struct tcphdr*)h_ptr)->check = check;
}
----------------------
Here are the "horrors" out of a make on the original linux_wrapper.c file against 2.6.22 kernel:
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'init_misc':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:310: error: 'dev_base' undeclared (first use in this function) /usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrap
per.c:310: error: (Each undeclared identifier is reported only once /usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrap
per.c:310: error: for each function it appears in.) /usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrap
per.c: In function 'nl_ip_rcv':/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrap
per.c:434: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'dev_next':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:497: error: 'net_device_t' has no member named 'next'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'nl_skb_dup':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:549: error: 'struct sk_buff' has no member named 'h'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:549: error: 'struct sk_buff' has no member named 'h'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:550: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:550: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:551: error: 'struct sk_buff' has no member named 'mac'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:551: error: 'struct sk_buff' has no member named 'mac'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'nl_skb_hdr_copy':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:576: error: 'struct sk_buff' has no member named 'h'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:576: error: 'struct sk_buff' has no member named 'h'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:577: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:577: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:578: error: 'struct sk_buff' has no member named 'mac'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:578: error: 'struct sk_buff' has no member named 'mac'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'nl_skb_iph':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:595: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'nl_send_skb':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:616: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:619: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c: In function 'nl_data_len':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:658: error: invalid operands to binary - /usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrap
per.c: In function 'do_checksum_offload':
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:752: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:768: error: 'struct sk_buff' has no member named 'nh'
/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.c:772: error: 'struct sk_buff' has no member named 'nh'
make[3]: ***
[/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6/linux_wrapper.o] Error 1
make[2]: ***
[_module_/usr/src/Nortel/Apani_VPN_v3.5/cvc_linux-rh-gcc3-3.5/src/k2.6]
Error 2
- vin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch for Apani Nortel VPN Client to build against kernel 2.6.22 help/review
2007-08-22 15:38 Patch for Apani Nortel VPN Client to build against kernel 2.6.22 help/review Fortier,Vincent [Montreal]
@ 2007-08-22 16:18 ` Nick Bowler
2007-09-11 16:57 ` Fortier,Vincent [Montreal]
0 siblings, 1 reply; 3+ messages in thread
From: Nick Bowler @ 2007-08-22 16:18 UTC (permalink / raw)
To: Fortier,Vincent [Montreal]; +Cc: linux-kernel, Gélineau,Samuel [Montreal]
I haven't read too much into the patch, but some quick comments. Most applies
throughout:
> +#if (LINUX_VERSION_CODE >= 0x020616)
KERNEL_VERSION(2,6,22) is much more readable than 0x020616.
> + return (struct iphdr*) skb->network_header;
Should be return ip_hdr(skb);
> + skb->network_header = skb->data;
Should be skb_reset_network_header(skb);
> + iph = skb->network_header.iph;
Probably meant skb->nh.iph.
> + if ( iph->protocol == 17 ) /* if UDP, */
(snip)
> + if ( iph->protocol == 6 ) /* if TCP, */
Could use IPPROTO_UDP and IPPROTO_TCP instead of 17 and 6, respectively.
Instead of littering the code with #if blah #else blah, you could also simply
provide implementations for the 2.6.22 functions #if LINUX_VERSION_CODE <
KERNEL_VERSION(2,6,22).
--
Nick Bowler, Elliptic Semiconductor (http://www.ellipticsemi.com/)
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Patch for Apani Nortel VPN Client to build against kernel 2.6.22 help/review
2007-08-22 16:18 ` Nick Bowler
@ 2007-09-11 16:57 ` Fortier,Vincent [Montreal]
0 siblings, 0 replies; 3+ messages in thread
From: Fortier,Vincent [Montreal] @ 2007-09-11 16:57 UTC (permalink / raw)
To: Nick Bowler; +Cc: linux-kernel, Gélineau,Samuel [Montreal]
[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]
> -----Message d'origine-----
> De : linux-kernel-owner@vger.kernel.org
> [mailto:linux-kernel-owner@vger.kernel.org] De la part de Nick Bowler
>
> I haven't read too much into the patch, but some quick
> comments. Most applies
> throughout:
>
> > +#if (LINUX_VERSION_CODE >= 0x020616)
> KERNEL_VERSION(2,6,22) is much more readable than 0x020616.
>
> > + return (struct iphdr*) skb->network_header;
> Should be return ip_hdr(skb);
>
> > + skb->network_header = skb->data;
> Should be skb_reset_network_header(skb);
>
> > + iph = skb->network_header.iph;
> Probably meant skb->nh.iph.
>
> > + if ( iph->protocol == 17 ) /* if UDP, */
> (snip)
> > + if ( iph->protocol == 6 ) /* if TCP, */
> Could use IPPROTO_UDP and IPPROTO_TCP instead of 17 and 6,
> respectively.
>
> Instead of littering the code with #if blah #else blah, you
> could also simply provide implementations for the 2.6.22
> functions #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22).
>
(Forwarding info by Samuel to lkml...)
Thanks for your comments, here is a new patch (bowler.patch) reflecting the changes you suggested. Unfortunately, and unsurprisingly for such cosmetic changes, the code still hangs.
I have added a great many debugging statements in order to pinpoint the problem (backtrace.patch); surprisingly, my custom backtraces didn't show up in the console, but a kernel call trace did (call_trace).
Here is the contents of the offending function. The {enter,exit}_func() calls are my debugging statements, and I have verified that only the else branch was compiled. As you can see, there are only function calls here, no memory manipulation nor dereferencing at all. What could possibly fail in this function? Shouldn`t the backtrace include one of the subcalls?
void nl_spin_lock_irqsave(spinlock_t *lockptr, DWORD *flagptr)
{
enter_func(__LINE__);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
assert(lockptr);
assert(flagptr);
spin_lock_irqsave((spinlock_t *)lockptr, (*flagptr));
#else
spin_lock_irq((spinlock_t *)lockptr);
#endif
exit_func(__LINE__);
}
- Samuel Gélineau
[-- Attachment #2: call_trace --]
[-- Type: application/octet-stream, Size: 1087 bytes --]
Call Trace:
[<f8e3....>] nl_spin_lock_irqsave+0x14/0x1f [mishim]
[<f8e3....>] mishim_packet_in+0x2f/0x170 [mishim]
[<c029....>] nf_iterate+0x4a/0x78
[<c029....>] ip_local_deliver_finish+0x0/0x1ba
[<c029....>] nf_hook_slow+0x57/0xbf
[<c029....>] ip_local_deliver_finish+0x0/0x1ba
[<c029....>] ip_local_deliver+0x7c/0x243
[<c029....>] ip_local_deliver_finish+0x0/0x1ba
[<c029....>] ip_rcv+0x496/0x4d4
[<c029....>] packet_rcv_spkt+0x14a/0x154
[<c029....>] ___netdec_alloc_skb+0x1a/0x33
[<c029....>] netif_receive_skb+0x2da/0x2fb
[<f8b5....>] e1000_clean_rx_irq+0x413/0x4d0 [e1000]
[<f8b5....>] e1000_clean+0x6f/0x10e [e1000]
[<c0b5....>] net_rx_action+0xa1/0x1bc
[<c012....>] __do_softirq+0x69/0xd3
[<c012....>] do_softirq+0x44/0x52
[<c012....>] irq_exit+0x38/0x6b
[<c010....>] do_IRQ+0x58/0x6b
[<c010....>] common_interrupt+0x23/0x28
[<c017....>] check_pad_bytes+0x17/0x82
[<c010....>] mwait_idle_with_hints+0x34/0x38
[<c010....>] mwait_idle+0x0/0x13
[<c010....>] cpu_idle+0xad/0xce
[<c03c....>] start_kernel+0x239/0x23d
[<c03c....>] unknown_bootoption+0x0/0x181
[-- Attachment #3: backtrace.patch --]
[-- Type: application/octet-stream, Size: 14295 bytes --]
--- cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c 2007-09-10 15:37:01.000000000 +0000
+++ cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c 2007-09-10 15:36:15.000000000 +0000
@@ -99,17 +99,45 @@
struct rtable;
#endif
+int backtrace_flag;
+int backtrace_debug[1024];
+void enter_func(int line) {
+ int i;
+ for(i=0; i<1024 && backtrace_debug[i]; ++i);
+ if (i == 1024) printk("overflow\n");
+ backtrace_debug[i] = line;
+ if (backtrace_flag) {printk("{ "); backtrace();}
+}
+void exit_func() {
+ int i;
+ for(i=1; i<1024 && backtrace_debug[i]; ++i);
+ --i;
+ if (backtrace_flag) {printk("} "); backtrace();}
+ backtrace_debug[i] = 0;
+}
+void backtrace() {
+ int i;
+ for(i=0; i<1024 && backtrace_debug[i]; ++i) {
+ printk("%d,", backtrace_debug[i]);
+ }
+ printk("\n");
+ backtrace_flag = 1;
+}
+
static inline int ip_route_output(struct rtable **rp,
u32 daddr, u32 saddr, u32 tos, int oif)
{
struct flowi flw;
+ enter_func(__LINE__);
flw.fl4_dst=daddr;
flw.fl4_src=saddr;
flw.oif=oif;
flw.fl4_tos=tos;
- return ip_route_output_key(rp, &flw);
+ int r = ip_route_output_key(rp, &flw);
+ exit_func();
+ return r;
}
#endif
@@ -197,6 +225,7 @@ int register_nl_netfilter (
{
int rval;
+ enter_func(__LINE__);
/* Register the netfilter hooks. */
input_filter.list.next = NULL;
input_filter.list.prev = NULL;
@@ -214,6 +243,7 @@ int register_nl_netfilter (
if (rval < 0)
{
printk(KERN_ERR "input netfilter hooks registration failed.\n");
+ exit_func();
return rval;
}
@@ -221,23 +251,31 @@ int register_nl_netfilter (
if (rval < 0)
{
printk(KERN_ERR "output netfilter hooks registration failed.\n");
+ exit_func();
return rval;
}
-
-
+
+
+ exit_func();
}
void unregister_netfilter()
{
+enter_func(__LINE__);
nf_unregister_hook(&input_filter);
nf_unregister_hook(&output_filter);
+exit_func();
}
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
struct iphdr ip_hdr(struct sk_buff *skb)
{
- return skb->nh.iph;
+ struct iphdr r;
+enter_func(__LINE__);
+ r = skb->nh.iph;
+exit_func();
+ return r;
}
net_device_t* net_device_entry(net_device_p *dev)
@@ -248,32 +286,41 @@ net_device_t* net_device_entry(net_devic
void mod_inc_use_count()
{
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
try_module_get(THIS_MODULE);
#else
MOD_INC_USE_COUNT;
#endif
+exit_func();
}
void mod_dec_use_count()
{
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
module_put(THIS_MODULE);
#else
MOD_DEC_USE_COUNT;
#endif
+exit_func();
}
void nldo_gettimeofday(struct timeval *tvdataptr)
{
+enter_func(__LINE__);
do_gettimeofday(tvdataptr);
+exit_func();
}
void nlpanic(const char *msg)
{
+enter_func(__LINE__);
panic(msg);
+exit_func();
}
int nlprintk(const char *fmt, ...)
{
+enter_func(__LINE__);
va_list args;
char buf[1024];
@@ -281,6 +328,7 @@ int nlprintk(const char *fmt, ...)
vsprintf(buf,fmt,args);
va_end(args);
+exit_func();
return printk(buf);
}
@@ -311,116 +359,184 @@ struct sk_buff *nl_skb_next (struct sk_b
unsigned long
nl_copy_from_user(void *to, const void *from, unsigned long n)
{
- return copy_from_user(to, from, n);
+ unsigned long r;
+enter_func(__LINE__);
+ r = copy_from_user(to, from, n);
+exit_func();
+ return r;
}
unsigned long
nl_copy_to_user(void *to, const void *from, unsigned long n)
{
- return copy_to_user(to, from, n);
+ unsigned long r;
+enter_func(__LINE__);
+ r = copy_to_user(to, from, n);
+exit_func();
+ return r;
}
void init_misc(void)
{
+ backtrace_flag = 0;
+ int i;
+ for(i=0; i<1024; ++i) {
+ backtrace_debug[i] = 0;
+ }
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
nl_dev_base = &dev_base_head;
#else
nl_dev_base = dev_base;
#endif
+exit_func();
}
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
int nl_register_firewall(int pf, struct firewall_ops *fw)
{
- return register_firewall(pf, fw);
+ int r;
+enter_func(__LINE__);
+ r = register_firewall(pf, fw);
+exit_func();
+ return r;
}
int nl_unregister_firewall(int pf, struct firewall_ops *fw)
{
- return unregister_firewall(pf, fw);
+ int r;
+enter_func(__LINE__);
+ r = unregister_firewall(pf, fw);
+exit_func();
+ return r;
}
void nl_poll_wait (struct file *file, struct wait_queue **sync, poll_table *pt)
{
+enter_func(__LINE__);
poll_wait(file, sync, pt);
+exit_func();
}
void nl_wake_up_interruptible (struct wait_queue **sync)
{
+enter_func(__LINE__);
wake_up_interruptible (sync);
+exit_func();
}
#else
int nl_nf_register_hook(struct nf_hook_ops *reg)
{
- return nf_register_hook(reg);
+ int r;
+enter_func(__LINE__);
+ r = nf_register_hook(reg);
+exit_func();
+ return r;
}
void nl_nf_unregister_hook(struct nf_hook_ops *reg)
{
+enter_func(__LINE__);
nf_unregister_hook(reg);
+exit_func();
}
void nl_poll_wait (struct file *file, wait_queue_head_t * wait_address, poll_table *pt)
{
+enter_func(__LINE__);
poll_wait(file, wait_address, pt);
+exit_func();
}
void nl_wake_up_interruptible (wait_queue_head_t * wait_address)
{
+enter_func(__LINE__);
wake_up_interruptible (wait_address);
+exit_func();
}
#endif
int nl_register_chrdev(unsigned int major, const char * name, struct file_operations *fops)
{
- return register_chrdev(major, name, fops);
+ int r;
+enter_func(__LINE__);
+ r = register_chrdev(major, name, fops);
+exit_func();
+ return r;
}
int nl_unregister_chrdev(unsigned int major, const char * name)
{
- return unregister_chrdev(major, name);
+ int r;
+enter_func(__LINE__);
+ r = unregister_chrdev(major, name);
+exit_func();
+ return r;
}
struct sk_buff *nl_alloc_skb(int size, int type)
{
- return alloc_skb(size, type);
+ struct sk_buff* r;
+enter_func(__LINE__);
+ r = alloc_skb(size, type);
+exit_func();
+ return r;
}
void nl_kfree_skb(struct sk_buff *skb)
{
+enter_func(__LINE__);
kfree_skb(skb);
+exit_func();
}
void nl_kfree(const void *ptr)
{
+enter_func(__LINE__);
kfree(ptr);
+exit_func();
}
void *nl_kmalloc (size_t size, int priority)
{
- return kmalloc(size, priority);
+ void* r;
+enter_func(__LINE__);
+ r = kmalloc(size, priority);
+exit_func();
+ return r;
}
struct sk_buff *nl_skb_clone(struct sk_buff *skb, int priority)
{
- return skb_clone(skb, priority);
+ struct sk_buff* r;
+enter_func(__LINE__);
+ r = skb_clone(skb, priority);
+exit_func();
+ return r;
}
struct sk_buff *nl_skb_copy(struct sk_buff *skb, int priority)
{
- return skb_copy(skb, priority);
+ struct sk_buff* r;
+enter_func(__LINE__);
+ r = skb_copy(skb, priority);
+exit_func();
+ return r;
}
void nl_spin_lock_init(spinlock_t *lockptr)
{
+enter_func(__LINE__);
assert(lockptr);
spin_lock_init(lockptr);
+exit_func();
}
void nl_spin_lock_irqsave(spinlock_t *lockptr, DWORD *flagptr)
{
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
assert(lockptr);
assert(flagptr);
@@ -428,10 +544,12 @@ void nl_spin_lock_irqsave(spinlock_t *lo
#else
spin_lock_irq((spinlock_t *)lockptr);
#endif
+exit_func();
}
void nl_spin_unlock_irqrestore(spinlock_t *lockptr, DWORD *flagptr)
{
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
assert(lockptr);
assert(flagptr);
@@ -439,15 +557,20 @@ void nl_spin_unlock_irqrestore(spinlock_
#else
spin_unlock_irq((spinlock_t *)lockptr);
#endif
+exit_func();
}
void nl_skb_put(struct sk_buff *skb, int length)
{
+enter_func(__LINE__);
skb_put(skb, length);
+exit_func();
}
int nl_ip_rcv(struct sk_buff *skb, struct packet_type *pt)
{
+int r;
+enter_func(__LINE__);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12))
struct net_device *dev = skb->dev;
struct iphdr *iph = ip_hdr(skb);
@@ -457,67 +580,118 @@ int nl_ip_rcv(struct sk_buff *skb, struc
if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))
goto drop;
}
- return dst_input (skb);
+ r = dst_input (skb);
+exit_func();
+ return r;
drop:
kfree_skb(skb);
+exit_func();
return 0;
#else
- return ip_rcv(skb, skb->dev, pt);
+ r = ip_rcv(skb, skb->dev, pt);
+exit_func();
+ return r;
#endif
}
void nl_ip_send_check(struct iphdr *iph)
{
+enter_func(__LINE__);
ip_send_check(iph);
+exit_func();
}
int nl_ip_route_output(struct rtable **rp, u32 daddr, u32 saddr, u32 tos, int oif)
{
- return ip_route_output(rp, daddr, saddr, tos, oif);
+ int r;
+enter_func(__LINE__);
+ r = ip_route_output(rp, daddr, saddr, tos, oif);
+exit_func();
+ return r;
}
int nl_register_netdevice_notifier(struct notifier_block *nb)
{
- return register_netdevice_notifier (nb);
+ int r;
+enter_func(__LINE__);
+ r = register_netdevice_notifier (nb);
+exit_func();
+ return r;
}
int nl_unregister_netdevice_notifier(struct notifier_block *nb)
{
- return unregister_netdevice_notifier (nb);
+ int r;
+enter_func(__LINE__);
+ r = unregister_netdevice_notifier (nb);
+exit_func();
+ return r;
}
char *dev_name (net_device_p *dev)
{
- return (net_device_entry(dev)->name);
+ char* r;
+enter_func(__LINE__);
+ r = (net_device_entry(dev)->name);
+exit_func();
+ return r;
}
int dev_name_len (net_device_p *dev)
{
- return (strlen(net_device_entry(dev)->name));
+ int r;
+enter_func(__LINE__);
+ r = (strlen(net_device_entry(dev)->name));
+exit_func();
+ return r;
}
unsigned *dev_mtu_ptr (net_device_p *dev)
{
- return &(net_device_entry(dev)->mtu);
+ unsigned *r;
+enter_func(__LINE__);
+ r = &(net_device_entry(dev)->mtu);
+exit_func();
+ return r;
}
unsigned dev_mtu (net_device_p *dev)
{
- return (net_device_entry(dev)->mtu);
+ unsigned r;
+enter_func(__LINE__);
+ r = (net_device_entry(dev)->mtu);
+exit_func();
+ return r;
}
int dev_ifindex (net_device_p *dev)
{
- return (net_device_entry(dev)->ifindex);
+ int r;
+enter_func(__LINE__);
+ r = (net_device_entry(dev)->ifindex);
+exit_func();
+ return r;
}
void *dev_ip_ptr (net_device_p *dev)
{
- return (net_device_entry(dev)->ip_ptr);
+ void* r;
+enter_func(__LINE__);
+ r = (net_device_entry(dev)->ip_ptr);
+exit_func();
+ return r;
}
net_device_t *dev_next (net_device_p *dev)
{
- return (dev->next);
+ net_device_t* r;
+enter_func(__LINE__);
+ r = (dev->next);
+exit_func();
+ return r;
}
int ip_summed(struct sk_buff *skb)
{
- return (skb->ip_summed);
+ int r;
+enter_func(__LINE__);
+ r = (skb->ip_summed);
+exit_func();
+ return r;
}
/* This structure will hold the functions to be called
* when a process does something to the device we
@@ -538,12 +712,18 @@ struct file_operations kmsp_fops = {
int max_skb_headroom (int type, struct sk_buff *skb)
{
- return (type == PACKET_HOST)?skb_headroom(skb):MAX_HEADER;
+ int r;
+enter_func(__LINE__);
+ r = (type == PACKET_HOST)?skb_headroom(skb):MAX_HEADER;
+exit_func();
+ return r;
}
void nl_skb_reserve (struct sk_buff *skb, int len)
{
+enter_func(__LINE__);
skb_reserve(skb, len);
+exit_func();
}
unsigned char * nl_skb_dataptr (struct sk_buff *skb)
@@ -559,6 +739,7 @@ int nl_skb_len(struct sk_buff *skb)
void nl_skb_dup (struct sk_buff *new_skb, struct sk_buff *skb, int type)
{
int head_offset;
+enter_func(__LINE__);
if (type == PACKET_HOST)
{
@@ -592,10 +773,12 @@ void nl_skb_dup (struct sk_buff *new_skb
#endif
new_skb->pkt_type = type;
new_skb->destructor = NULL;
+exit_func();
}
void nl_skb_hdr_copy (struct sk_buff *skb_to, struct sk_buff *skb_from)
{
+enter_func(__LINE__);
skb_to->dev = skb_from->dev;
skb_to->dst = skb_from->dst;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
@@ -619,11 +802,16 @@ void nl_skb_hdr_copy (struct sk_buff *sk
skb_to->data = skb_from->data;
skb_to->head = skb_from->head;
+exit_func();
}
struct iphdr * nl_skb_iph (struct sk_buff *skb)
{
- return ip_hdr(skb);
+ struct iphdr* r;
+enter_func(__LINE__);
+ r = ip_hdr(skb);
+exit_func();
+ return r;
}
net_device_t * nl_skb_dev (struct sk_buff *skb)
@@ -641,6 +829,7 @@ void nl_send_skb (struct sk_buff *skb, n
struct iphdr *iph;
int rval;
struct rtable *rt;
+enter_func(__LINE__);
if (skb)
{
@@ -676,6 +865,7 @@ void nl_send_skb (struct sk_buff *skb, n
}
}
+exit_func();
}
int size_of_skb ()
@@ -685,7 +875,11 @@ int size_of_skb ()
int nl_skb_cloned (struct sk_buff *skb)
{
- return skb_cloned(skb);
+ int r;
+enter_func(__LINE__);
+ r = skb_cloned(skb);
+exit_func();
+ return r;
}
int nl_data_len (struct sk_buff *skb)
@@ -695,9 +889,11 @@ int nl_data_len (struct sk_buff *skb)
void update_inner_route (struct sk_buff *skb, net_device_t *dev)
{
+enter_func(__LINE__);
skb->dev = dev;
dst_release(skb->dst);
skb->dst = NULL;
+exit_func();
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
@@ -705,30 +901,40 @@ extern char kernel_version [];
int init_module(void)
{
+enter_func(__LINE__);
#if DEBUG
printk("init_module (%x).\n", init_module);
#endif
if (mishim_init() != 0)
return -EIO;
+exit_func();
return 0;
}
void cleanup_module(void)
{
+enter_func(__LINE__);
if (mishim_uninit() != 0)
printk("mishim module: module can't be removed.");
+exit_func();
}
#else
static int __init nlshim_init (void)
{
- return mishim_init();
+ int r;
+enter_func(__LINE__);
+ r = mishim_init();
+exit_func();
+ return r;
}
static void __exit nlshim_exit(void)
{
+enter_func(__LINE__);
mishim_uninit();
+exit_func();
}
module_init(nlshim_init);
@@ -776,8 +982,10 @@ void do_checksum_offload( struct sk_buff
struct sk_buff *frag_ptr;
struct iphdr *iph;
+ enter_func(__LINE__);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
ip_send_check (skb->nh.iph);
+ exit_func();
return;
#else
if ( !skb->ip_summed ) /* if offload not enabled, */
@@ -811,9 +1019,11 @@ void do_checksum_offload( struct sk_buff
skb->ip_summed = 0; /* don't csum in hardware */
done_exit:
+ exit_func();
return;
#endif
-
+
+ exit_func();
}
#if 0
/************************************************************************
[-- Attachment #4: bowler.patch --]
[-- Type: application/octet-stream, Size: 11041 bytes --]
--- cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c 2007-02-07 19:10:41.000000000 +0000
+++ cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c 2007-09-10 14:16:04.000000000 +0000
@@ -48,7 +48,7 @@
#include <linux/utsrelease.h>
#endif
/* Version 2.2.x */
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
#include <linux/autoconf.h>
@@ -77,7 +77,7 @@
#include <net/ip.h>
#include <linux/udp.h>
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
#include <linux/firewall.h>
#include <asm/spinlock.h>
#include <net/route.h>
@@ -88,12 +88,12 @@
int nl_nf_register_hook(struct nf_hook_ops *reg);
int mishim_init();
int mishim_uninit();
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
#include <asm/checksum.h>
#include <net/flow.h>
-#if (LINUX_VERSION_CODE > 0x02060c)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,c))
#include <net/route.h>
#else
struct rtable;
@@ -134,13 +134,18 @@ int nl_open(struct inode *inode, struct
/* some necessary globals... */
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
typedef struct device net_device_t;
#else
typedef struct net_device net_device_t;
#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+typedef struct list_head net_device_p;
+#else
+typedef net_device_t net_device_p;
+#endif
-net_device_t *nl_dev_base;
+net_device_p *nl_dev_base;
int kmalloc_pri = GFP_ATOMIC;
/* assert macro definition */
@@ -168,12 +173,12 @@ typedef unsigned long DWORD;
unsigned long volatile *nljiffies = &jiffies;
char kernel_version [] = UTS_RELEASE;
-#if (LINUX_VERSION_CODE > 0x020400)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0))
static struct nf_hook_ops input_filter;
static struct nf_hook_ops output_filter;
#endif
-#if (LINUX_VERSION_CODE > 0x020400)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0))
unsigned int mishim_packet_in (unsigned int hooknum,
struct sk_buff **skbp,
const net_device_t *in,
@@ -229,9 +234,21 @@ void unregister_netfilter()
}
#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
+struct iphdr ip_hdr(struct sk_buff *skb)
+{
+ return skb->nh.iph;
+}
+
+net_device_t* net_device_entry(net_device_p *dev)
+{
+ return dev;
+}
+#endif
+
void mod_inc_use_count()
{
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
try_module_get(THIS_MODULE);
#else
MOD_INC_USE_COUNT;
@@ -239,12 +256,11 @@ void mod_inc_use_count()
}
void mod_dec_use_count()
{
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
module_put(THIS_MODULE);
#else
MOD_DEC_USE_COUNT;
#endif
-
}
void nldo_gettimeofday(struct timeval *tvdataptr)
{
@@ -280,7 +296,7 @@ unsigned long ticks_to_ms (unsigned long
struct sk_buff *nl_frag_list (struct sk_buff *skb)
{
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
return NULL;
#else
return skb_shinfo(skb)->frag_list;
@@ -306,11 +322,14 @@ nl_copy_to_user(void *to, const void *fr
void init_misc(void)
{
-
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+ nl_dev_base = &dev_base_head;
+#else
nl_dev_base = dev_base;
+#endif
}
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
int nl_register_firewall(int pf, struct firewall_ops *fw)
{
@@ -402,7 +421,7 @@ void nl_spin_lock_init(spinlock_t *lockp
}
void nl_spin_lock_irqsave(spinlock_t *lockptr, DWORD *flagptr)
{
-#if (LINUX_VERSION_CODE < 0x020607)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
assert(lockptr);
assert(flagptr);
spin_lock_irqsave((spinlock_t *)lockptr, (*flagptr));
@@ -413,7 +432,7 @@ void nl_spin_lock_irqsave(spinlock_t *lo
void nl_spin_unlock_irqrestore(spinlock_t *lockptr, DWORD *flagptr)
{
-#if (LINUX_VERSION_CODE < 0x020607)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
assert(lockptr);
assert(flagptr);
spin_unlock_irqrestore((spinlock_t *)lockptr, (*flagptr));
@@ -429,9 +448,9 @@ void nl_skb_put(struct sk_buff *skb, int
int nl_ip_rcv(struct sk_buff *skb, struct packet_type *pt)
{
-#if (LINUX_VERSION_CODE > 0x02060c)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12))
struct net_device *dev = skb->dev;
- struct iphdr *iph = skb->nh.iph;
+ struct iphdr *iph = ip_hdr(skb);
if (skb->dst == NULL)
{
@@ -467,32 +486,32 @@ int nl_unregister_netdevice_notifier(str
return unregister_netdevice_notifier (nb);
}
-char *dev_name (net_device_t *dev)
+char *dev_name (net_device_p *dev)
{
- return (dev->name);
+ return (net_device_entry(dev)->name);
}
-int dev_name_len (net_device_t *dev)
+int dev_name_len (net_device_p *dev)
{
- return (strlen(dev->name));
+ return (strlen(net_device_entry(dev)->name));
}
-unsigned *dev_mtu_ptr (net_device_t *dev)
+unsigned *dev_mtu_ptr (net_device_p *dev)
{
- return (&dev->mtu);
+ return &(net_device_entry(dev)->mtu);
}
-unsigned dev_mtu (net_device_t *dev)
+unsigned dev_mtu (net_device_p *dev)
{
- return (dev->mtu);
+ return (net_device_entry(dev)->mtu);
}
-int dev_ifindex (net_device_t *dev)
+int dev_ifindex (net_device_p *dev)
{
- return (dev->ifindex);
+ return (net_device_entry(dev)->ifindex);
}
-void *dev_ip_ptr (net_device_t *dev)
+void *dev_ip_ptr (net_device_p *dev)
{
- return (dev->ip_ptr);
+ return (net_device_entry(dev)->ip_ptr);
}
-net_device_t *dev_next (net_device_t *dev)
+net_device_t *dev_next (net_device_p *dev)
{
return (dev->next);
}
@@ -546,20 +565,26 @@ void nl_skb_dup (struct sk_buff *new_skb
head_offset = new_skb->head - skb->head;
new_skb->dev = skb->dev;
new_skb->dst = dst_clone(skb->dst);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+ new_skb->transport_header = skb->transport_header+head_offset;
+ new_skb->network_header = skb->network_header+head_offset;
+ new_skb->mac_header = skb->mac_header+head_offset;
+#else
new_skb->h.raw = skb->h.raw+head_offset;
new_skb->nh.raw = skb->nh.raw+head_offset;
new_skb->mac.raw = skb->mac.raw+head_offset;
+#endif
memcpy(new_skb->cb, skb->cb, sizeof(skb->cb));
new_skb->priority = skb->priority;
new_skb->protocol = skb->protocol;
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
new_skb->security = skb->security;
new_skb->stamp = skb->stamp;
new_skb->used = skb->used;
#endif
}
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
new_skb->is_clone = 0;
#else
new_skb->ip_summed = skb->ip_summed;
@@ -573,13 +598,19 @@ void nl_skb_hdr_copy (struct sk_buff *sk
{
skb_to->dev = skb_from->dev;
skb_to->dst = skb_from->dst;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+ skb_to->transport_header = skb_from->transport_header;
+ skb_to->network_header = skb_from->network_header;
+ skb_to->mac_header = skb_from->mac_header;
+#else
skb_to->h.raw = skb_from->h.raw;
skb_to->nh.raw = skb_from->nh.raw;
skb_to->mac.raw = skb_from->mac.raw;
+#endif
memcpy(skb_to->cb, skb_from->cb, sizeof(skb_from->cb));
skb_to->priority = skb_from->priority;
skb_to->protocol = skb_from->protocol;
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
skb_to->stamp = skb_from->stamp;
skb_to->used = skb_from->used;
#else
@@ -592,7 +623,7 @@ void nl_skb_hdr_copy (struct sk_buff *sk
struct iphdr * nl_skb_iph (struct sk_buff *skb)
{
- return skb->nh.iph;
+ return ip_hdr(skb);
}
net_device_t * nl_skb_dev (struct sk_buff *skb)
@@ -613,13 +644,17 @@ void nl_send_skb (struct sk_buff *skb, n
if (skb)
{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+ skb_reset_network_header(skb);
+#else
skb->nh.iph = (struct iphdr *) skb->data;
+#endif
skb->dev = dev;
-
- iph = skb->nh.iph;
-
+
+ iph = ip_hdr(skb);
+
rval = ip_route_output (&rt, iph->daddr, 0, RT_TOS(iph->tos), 0);
-
+
if (rval < 0)
{
printk("NL_SEND_SKB: ip_route_output failed.");
@@ -633,7 +668,7 @@ void nl_send_skb (struct sk_buff *skb, n
if (skb->dst)
{
-#if ((LINUX_VERSION_CODE < 0x020607) || (LINUX_VERSION_CODE > 0x020609))
+#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)))
skb->dst->output(skb);
#else
skb->dst->output(&skb);
@@ -664,7 +699,7 @@ void update_inner_route (struct sk_buff
dst_release(skb->dst);
skb->dst = NULL;
}
-#if (LINUX_VERSION_CODE < 0x020500)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
extern char kernel_version [];
@@ -741,7 +776,7 @@ void do_checksum_offload( struct sk_buff
struct sk_buff *frag_ptr;
struct iphdr *iph;
-#if (LINUX_VERSION_CODE < 0x020500)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
ip_send_check (skb->nh.iph);
return;
#else
@@ -749,7 +784,7 @@ void do_checksum_offload( struct sk_buff
{
goto done_exit;
}
- iph = skb->nh.iph;
+ iph = ip_hdr(skb);
header_length = iph->ihl << 2; /* get the ip header length */
h_ptr = (char*)iph + header_length; /* get pointer to proto header */
frag_ptr = skb_shinfo( skb )->frag_list; /* at most, one frag */
@@ -765,11 +800,11 @@ void do_checksum_offload( struct sk_buff
csum = csum_partial( h_ptr, ntohs(iph->tot_len) - header_length, 0 );
check = csum_fold( csum_partial( frag_ptr->data, nl_data_len( frag_ptr ), csum ) );
}
- if ( skb->nh.iph->protocol == 17 ) /* if UDP, */
+ if ( iph->protocol == IPPROTO_UDP )
{
((struct udphdr*)h_ptr)->check = check;
}
- if ( skb->nh.iph->protocol == 6 ) /* if TCP, */
+ if ( iph->protocol == IPPROTO_TCP )
{
((struct tcphdr*)h_ptr)->check = check;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-11 16:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-22 15:38 Patch for Apani Nortel VPN Client to build against kernel 2.6.22 help/review Fortier,Vincent [Montreal]
2007-08-22 16:18 ` Nick Bowler
2007-09-11 16:57 ` Fortier,Vincent [Montreal]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®