title: How to get sk_buff_head in kernel driver?
body: <p>I currently write a network driver, and in the transmit function I want to modify the socket buffer queue. Therefore I need to get the lock of <code>sk_buff_head</code>, but the link to the head from a socket buffer was removed years ago.</p>
  
  <p>How can I access <code>sk_buff_head</code> from <code>ndo_start_xmit(struct sk_buff *skb, net_device *dev)</code>?</p>
  
  <p>I am using current linux kernel 4.15.3.</p>
  
  <h2>Background</h2>
  
  <p>I modify an existing driver for a virtual network device to implement fragmentation which relies on the order of frames, so the second fragment must be sent directly after the first fragment. It works on layer 2 frames.</p>
  
  <p>Therefore I hook up in the <code>start_xmit</code>function, simplified it looks like this:</p>
  
  <pre><code>static spinlock_t xmit_lock;
  start_xmit(struct sk_buff *skb, struct net_device *dev)
  {
  
      [...]
  
      if(skb-&gt;len &gt; TRESHHOLD) {
          second_skb = do_fragmentation(skb);
      }
  
      [...]
  
      spin_lock_bh(&amp;xmit_lock);
  
      if(second_skb) {
           second_skb-&gt;next = skb-&gt;next;
           second_skb-&gt;prev = skb;
           skb-&gt;next = second_skb;
      }
  
      ret = dev_queue_xmit(skb);
  
      spin_lock_bh(&amp;xmit_lock);
  }
  </code></pre>
  
  <p>So I want to reach that both skbs are sent in exactly this order, there should not be a frame sent in between which passes this driver. This works, when using ping flood mode oder iperf with UDP but sometimes it messes up with iperf using a TCP connection. Then, there are some cases where the order is messed up.</p>
  
  <p>To solve this, I thought I need the "real" queue lock for the skb and so I need <code>sk_buff_head</code> for this.</p>