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

Function ngp_rcvdata

freebsd/netgraph/ng_pipe.c:588–716  ·  view source on GitHub ↗

* Receive data on a hook - both in upstream and downstream direction. * We put the frame on the inbound queue, and try to initiate dequeuing * sequence immediately. If inbound queue is full, discard one frame * depending on dropping policy (from the head or from the tail of the * queue). */

Source from the content-addressed store, hash-verified

586 * queue).
587 */
588static int
589ngp_rcvdata(hook_p hook, item_p item)
590{
591 struct hookinfo *const hinfo = NG_HOOK_PRIVATE(hook);
592 const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
593 struct timeval uuptime;
594 struct timeval *now = &uuptime;
595 struct ngp_fifo *ngp_f = NULL, *ngp_f1;
596 struct ngp_hdr *ngp_h = NULL;
597 struct mbuf *m;
598 int hash, plen;
599 int error = 0;
600
601 /*
602 * Shortcut from inbound to outbound hook when neither of
603 * bandwidth, delay, BER or duplication probability is
604 * configured, nor we have queued frames to drain.
605 */
606 if (hinfo->run.qin_frames == 0 && hinfo->run.qout_frames == 0 &&
607 hinfo->noqueue) {
608 struct hookinfo *dest;
609 if (hinfo == &priv->lower)
610 dest = &priv->upper;
611 else
612 dest = &priv->lower;
613
614 /* Send the frame. */
615 plen = NGI_M(item)->m_pkthdr.len;
616 NG_FWD_ITEM_HOOK(error, item, dest->hook);
617
618 /* Update stats. */
619 if (error) {
620 hinfo->stats.out_disc_frames++;
621 hinfo->stats.out_disc_octets += plen;
622 } else {
623 hinfo->stats.fwd_frames++;
624 hinfo->stats.fwd_octets += plen;
625 }
626
627 return (error);
628 }
629
630 microuptime(now);
631
632 /*
633 * If this was an empty queue, update service deadline time.
634 */
635 if (hinfo->run.qin_frames == 0) {
636 struct timeval *when = &hinfo->qin_utime;
637 if (when->tv_sec < now->tv_sec || (when->tv_sec == now->tv_sec
638 && when->tv_usec < now->tv_usec)) {
639 when->tv_sec = now->tv_sec;
640 when->tv_usec = now->tv_usec;
641 }
642 }
643
644 /* Populate the packet header */
645 ngp_h = uma_zalloc(ngp_zone, M_NOWAIT);

Callers

nothing calls this directly

Calls 6

microuptimeFunction · 0.85
pipe_dequeueFunction · 0.85
ip_hashFunction · 0.70
uma_zallocFunction · 0.50
uma_zfreeFunction · 0.50
m_freemFunction · 0.50

Tested by

no test coverage detected