Hi Patrick,
Patrick McHardy wrote:
Pablo Neira wrote:
skb_queue_tail(&sk->sk_receive_queue, skb);
- sk->sk_data_ready(sk, len);
- sock_put(sk);
+ if (!nlk->pid) {
+ struct netlink_work *nlwork = + kmalloc(sizeof(struct netlink_work), GFP_KERNEL);
+
+ if (!nlwork) {
+ sock_put(sk);
+ return -EAGAIN;
What happens if we queue the packet, fail here and no further packets are sent ? The socket will never get waken up and the packet will be stuck forever, right ?
No, there's no problem ;-), for example, in ip_queue:
--- snipped from ip_queue.c -------
static void ipq_rcv_sk(struct sock *sk, int len) { do { struct sk_buff *skb;
if (down_trylock(&ipqnl_sem)) return;
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { ^^^^
ipq_rcv_skb(skb); kfree_skb(skb); }
up(&ipqnl_sem);
} while (ipqnl && ipqnl->sk_receive_queue.qlen); }
------ end of snip -----
Here we are dequeueing until we get empty the buffer, so if that allocation fails, next callback will handle that packet with a delay. That's the way it is in rtnetlink.c and folks. I prefer delaying the packet than dropping it, this makes netlink sockets more reliable.
regards, Pablo - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html