netdev
[Top] [All Lists]

sk_buff resizing

To: netdev@xxxxxxxxxxx
Subject: sk_buff resizing
From: Sumit Garg <sumitg@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Apr 2000 10:44:48 -0400
Organization: Lucent Bell Labs
Sender: owner-netdev@xxxxxxxxxxx
Hello,
       I am trying to modify the contents of a well formed sk_buff in a
function called from
dev_queue_xmit() with properly filled in sk_buff.
I may need to add or delete or simply overwrite certain portions of the
data in skbuff buffer.
Now .. If I plainly overwrite a chunk of data in buffer , and update the
checksums of TCP, IP headers.. things work fine.
However if I try to ADD new data or DELETE... the same sk_buff keeps
transmitting.. though it gets acks

By the way, I am trying to modify sk_buffs generated by a specific
telnet session. and once I do the modifications.. that telnet session
hangs up. (though I can start new telnet connections)

Any insight?

The code:  diff the the amount by which I need to change the size.  I
need to replace the data at
(o_buf)  of length (o_len) in sk_buff (skb) by  new data in a buffer
pointed to by n_buf  of length n_len.

o_offset=o_buf - (char*) skb->data;
skb_len=skb->len;

     if (skb_tailroom(skb)>=diff) {
      if (diff>0) { // grow
        skb_put(skb,diff);
        memmove(o_buf + n_len, o_buf + o_len,
               skb_len - (o_offset + o_len) );
        memmove(o_buf, n_buf, n_len);
      } else { // shrink
        memmove(o_buf+n_len, o_buf+o_len, skb->len - (o_offset +
o_len));
        skb_trim(skb,skb->len+diff);
        memmove(o_buf,n_buf,n_len);
      }




Thanks
Sumit



<Prev in Thread] Current Thread [Next in Thread>