All of lore.kernel.org
 help / color / mirror / Atom feed
* Replacing data in skbuff
@ 2011-08-04 23:15 Daniele Rossetti
  0 siblings, 0 replies; only message in thread
From: Daniele Rossetti @ 2011-08-04 23:15 UTC (permalink / raw)
  To: netfilter

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?!

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-04 23:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04 23:15 Replacing data in skbuff Daniele Rossetti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.