The increase in the number of links to SKB

Is there any simple way to increase the number of references to the SKB buffer in the linux kernel so that the hardware does not release it.

I know that with skb_clone the link count is automatically incremented, but I would like to know, without creating a clone, how to increase the SKB link count.

My goal is to send the same packet several times, and I don't want to do skb_clone every time for this operation, since I want to reuse the same memory.

An example of the code that I use for the same SKB is shown below

for (i=0;i<=100;i++) { tmp_skb = skb_get(skb); if (tmp_skb == NULL) { printk ("Clone Failed"); continue; } if ( (err = dev_queue_xmit(tmp_skb)) != NETDEV_TX_OK) { if(unlikely(enable_error)) printk("ERROR - DEV QUEUE FAILED %d\n", err); err = -ENETDOWN; /* Probably we need a better error here */ continue; } if (i==100) { printk("Loop is done\n"); kfree_skb(skb); return(len); } } 
+4
source share
1 answer

Try get skb using the skb_get method:

 758 /** 759 * skb_get - reference buffer 760 * @skb: buffer to reference 761 * 762 * Makes another reference to a socket buffer and returns a pointer 763 * to the buffer. 764 */ 765 static inline struct sk_buff *skb_get(struct sk_buff *skb) 766 { 767 atomic_inc(&skb->users); 768 return skb; 769 } 
+3
source

Source: https://habr.com/ru/post/1441211/


All Articles