|
From: Wang R. <wan...@ue...> - 2008-12-11 13:33:22
|
Hi,
I am trying to port aodv-uu 0.9.5 to Linux kernel 2.6.26. The
netfilter implementation has changed since 2.6.24 :
[NETFILTER]: Replace sk_buff ** with sk_buff *
With all the users of the double pointers removed, this patch mops up by
finally replacing all occurances of sk_buff ** in the netfilter API by
sk_buff *.
So the original 0.9.5 implementation of struct sk_buff
*ip_pkt_encapsulate(struct sk_buff *skb, __u32 dest) no longer works. I
tried to modify ip_pkt_encapsulate by using pskb_expand_head instead of
skb_copy_expand:
struct sk_buff *ip_pkt_encapsulate(struct sk_buff *skb, __u32 dest)
{
int oldlen;
struct min_ipenc_hdr *ipe;
struct iphdr *iph;
/* Allocate new data space at head */
if( pskb_expand_head(skb,0,
sizeof(struct min_ipenc_hdr),GFP_ATOMIC) < 0) {
printk("Could not expand skb header\n");
kfree_skb(skb);
return NULL;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
iph = skb->nh.iph;
#else
iph = (struct iphdr *)skb->network_header;
#endif
oldlen = skb->len;
skb_put(skb, sizeof(struct min_ipenc_hdr));
/* Move the data */
memmove(skb->data + (iph->ihl << 2) + sizeof(struct min_ipenc_hdr),
skb->data + (iph->ihl << 2), oldlen - (iph->ihl << 2));
/* Update pointers */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
iph = skb->nh.iph = (struct iphdr *)skb->data;
#else
iph = (struct iphdr *)skb->data;
skb->network_header = skb->data;
#endif
ipe = (struct min_ipenc_hdr *)(skb->data + (iph->ihl << 2));
.
}
But the kaodv module crashes when sending paged packages, saying that the
skb is not linear, so I added:
If(!skb_make_writable(skb,skb->len)) {
printk("Could not make skb writable\n");
return NULL;
}
just before calling pskb_expand_head. The module stops crashing this time,
but the package still cannot deliver correctly.
Can anybody tell me how to modify ip_pkt_encapsulate to correctly add the
additional header to the paged skb?
Wang Rui
wan...@ue..., wan...@gm...
|