Linux – check the current backlog queue size

linuxnetworking

The sysctl netdev_max_backlog sets a limit to the maximum number of packets allowed in the kernel's backlog queue.

Is there a way to check the current queue size (i.e., how many packets are currently in the queue at a given time)?

Literally, the value of queue->input_pkt_queue.qlen from net/core/dev.c:netif_rx():

  queue = &__get_cpu_var(softnet_data);

  __get_cpu_var(netdev_rx_stat).total++;
  if (queue->input_pkt_queue.qlen <= netdev_max_backlog) {
    if (queue->input_pkt_queue.qlen) {
enqueue:
      __skb_queue_tail(&queue->input_pkt_queue, skb);
      local_irq_restore(flags);
      return NET_RX_SUCCESS;
    }

Best Answer

probe kernel.statement("enqueue_to_backlog@net/core/dev.c:3536") {
    printf("probe enqueue_to_backlog on cpu: %d qlen: %d\n", $sd->cpu, $qlen + 1)
}

systemtap probe. Line number(3536) depends on kernel version, look for this line

if (qlen <= netdev_max_backlog && !skb_flow_limit(skb, qlen)) {