MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_car_q_event

Function ng_car_q_event

freebsd/netgraph/ng_car.c:663–704  ·  view source on GitHub ↗

* Queue processing callout handler. */

Source from the content-addressed store, hash-verified

661 * Queue processing callout handler.
662 */
663void
664ng_car_q_event(node_p node, hook_p hook, void *arg, int arg2)
665{
666 struct hookinfo *hinfo = NG_HOOK_PRIVATE(hook);
667 struct mbuf *m;
668 int error;
669
670 /* Refill tokens for time we have slept. */
671 ng_car_refillhook(hinfo);
672
673 /* If we have some tokens */
674 while (hinfo->tc >= 0) {
675 /* Send packet. */
676 m = hinfo->q[hinfo->q_first];
677 NG_SEND_DATA_ONLY(error, hinfo->dest, m);
678 if (error != 0)
679 ++hinfo->stats.errors;
680 ++hinfo->stats.passed_pkts;
681
682 /* Get next one. */
683 hinfo->q_first++;
684 if (hinfo->q_first >= NG_CAR_QUEUE_SIZE)
685 hinfo->q_first = 0;
686
687 /* Stop if none left. */
688 if (hinfo->q_first == hinfo->q_last)
689 break;
690
691 /* If we have more packet, try it. */
692 m = hinfo->q[hinfo->q_first];
693 if (hinfo->conf.opt & NG_CAR_COUNT_PACKETS) {
694 hinfo->tc -= 128;
695 } else {
696 hinfo->tc -= m->m_pkthdr.len;
697 }
698 }
699
700 /* If something left */
701 if (hinfo->q_first != hinfo->q_last)
702 /* Schedule queue processing. */
703 ng_car_schedule(hinfo);
704}
705
706/*
707 * Enqueue packet.

Callers

nothing calls this directly

Calls 2

ng_car_refillhookFunction · 0.85
ng_car_scheduleFunction · 0.85

Tested by

no test coverage detected