简体   繁体   中英

Linux skb alloc failed

When I keep connections with clients, I receive a report from each client. Some time later, the program crashes, and I get an error message:

skb allocation failed.

What can I do?

The information that you have provided is too incomplete to predict anything. But, still, majorly the problem with network sockets lies in buffer allocations. skbuffs are the buffers in which the Linux kernel handles network packets. When you keep connections with clients and receive packets, internally the packet is received by the network card, filled into a skbuff and passed over to the network stack.

See what alloc_skb() returned with. Read man pages to know that if alloc_skb() returns NULL, there is no memory to allocate the block you want. This can be one of the allocation failure situation.

By the way, hope you are driving the entire thing on interrupt basis. Man page of alloc_skb() says,

Buffers may only be allocated from interrupts using a gfp_mask of GFP_ATOMIC.

Your best bet to deliver the data regardless of the memory situation is the interrupt handler. One can create a skb list when the driver is loading. And, during the interrupt, do alloc_skb , if it fails, you can always one of the pre-allocated buffers (if you have any) to hold the data. For the next interrupt occurrence replenish the buffer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM