Replacing data in skbuff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello People,
I'm trying to write a target for netfilter which replace packet payload, but I'm having some troubles, cause I don't really know what is the best way to do it.
I tried this way: 

/* payload points to the old payload in skb */
memcpy(payload,newpayload,newpayload_size*sizeof(char));
skb->len = skb->len-payload_size+newpayload_size;
/*new checksum and ip total length*/
(skbuff is big enough to contain the new payload)

and this way, using some skbuff api:

/*Get ip+tcp/udp header*/
int header_len = payload - (char *) skb->data;
char *header = kmalloc(sizeof(char)*header_len,GFP_KERNEL);
memcpy(header,skb->data,header_len);
/*Remove all data from skb */
skb_pull(skb,skb->len);
/*Reserve new data space*/
skb_put(skb,newpayload_size+header_len);
/*Copy old header and new payload*/
memcpy(skb->data,header,header_len);
memcpy(skb->data+header_len,newpayload,newpayload_size);

Both seems to work somehow (most of the time) but system takes a while to handle the packet and looking in kernel log there is this message more than once: BUG: schedule while atomic

any idea?!--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux