Skip to content

Commit

Permalink
Set the kernel as an extra user of SKBs that are sent out.
Browse files Browse the repository at this point in the history
This should be used in conjunction with the kernel patch. The patch makes sure
that SKBs in socket's TX path are freed with kfree_skb() and not __kfree_skb().
kfree_skb() pays attention to the number of users SKB currently has, whereas
__kfree_skb() frees SKBs unconditionally. With these two patches together SKBs
can be freed safely at any time.
  • Loading branch information
keshonok committed Aug 4, 2015
1 parent 1d82c49 commit 6ea9bfb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tempesta_fw/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ ss_send(struct sock *sk, const SsSkbList *skb_list)
SS_DBG("%s:%d entail skb=%p data_len=%u len=%u\n",
__FUNCTION__, __LINE__, skb, skb->data_len, skb->len);

/*
* When SKBs are removed from socket's receive queue and
* passed to Tempesta, control over these SKBs is passed
* from kernel to Tempesta as well. Tempesta becomes the
* sole owner of these SKBs. When these SKBs are sent out
* to a client or a backend by Tempesta, the kernel becomes
* an extra owner of the SKBs in addition to Tempesta.
* To account for that it's necessary to increment SKB's
* count of users so that SKBs are not freed from under
* Tempesta or from under the kernel.
*/
skb_get(skb);

skb_entail(sk, skb);

tcb->end_seq += skb->len;
Expand Down

0 comments on commit 6ea9bfb

Please sign in to comment.