Read the explanation of skb_reserve

According to the source, http://lxr.linux.no/#linux+v2.6.31/include/linux/skbuff.h#L1204

1197 *      skb_reserve - adjust headroom
1198 *      @skb: buffer to alter
1199 *      @len: bytes to move
1200 *
1201 *      Increase the headroom of an empty &sk_buff by reducing the tail
1202 *      room. This is only allowed for an empty buffer.
1203 */
1204static inline void skb_reserve(struct sk_buff *skb, int len)
1205{
1206        skb->data += len;
1207        skb->tail += len;
1208}

But the room room is only enlarged and not "reduced" correctly?

+3
source share
1 answer

If you look at the function right before this:

1185 /**
1186  *      skb_tailroom - bytes at buffer end
1187  *      @skb: buffer to check
1188  *
1189  *      Return the number of bytes of free space at the tail of an sk_buff
1190  */
1191 static inline int skb_tailroom(const struct sk_buff *skb)
1192 {
1193         return skb_is_nonlinear(skb) ? 0 : skb->end - skb->tail;
1194 }

It becomes clear that the โ€œtailโ€ is the difference between endand tail, therefore, the function in question really reduces the tail space in the buffer.

+4
source

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


All Articles