* 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). */
| 586 | * queue). |
| 587 | */ |
| 588 | static int |
| 589 | ngp_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); |
nothing calls this directly
no test coverage detected