title: The correct way to copy data from a sk_buff to a kernel buffer
body: <p>Can someone give me a full example for copying an entire packet from a sk_buff?  I'm doing something along the lines of:</p>
  
  <pre><code>char *pkt = skb_header_pointer(sbuf, 0, sbuf-&gt;len, mybuf);
  if (mybuf != pkt) {
      memcpy(mybuf, pkt, sbuf-&gt;len);
  }
  </code></pre>
  
  <p>where <code>sbuf</code> is a <code>struct sk_buff *</code> and <code>mybuf</code> is my own buffer.  For reasons that I don't understand, this function occasionally returns a NULL pointer, indicating something has failed.  What could be the cause?  And what exactly is the best way to copy an entire buffer?</p>