* Check if a given mbuf has the SIFTR mbuf tag. If it does, log the fact that * it's a reinjected packet and return. If it doesn't, tag the mbuf and return. * Return value >0 means the caller should skip processing this mbuf. */
| 671 | * Return value >0 means the caller should skip processing this mbuf. |
| 672 | */ |
| 673 | static inline int |
| 674 | siftr_chkreinject(struct mbuf *m, int dir, struct siftr_stats *ss) |
| 675 | { |
| 676 | if (m_tag_locate(m, PACKET_COOKIE_SIFTR, PACKET_TAG_SIFTR, NULL) |
| 677 | != NULL) { |
| 678 | if (dir == PFIL_IN) |
| 679 | ss->nskip_in_dejavu++; |
| 680 | else |
| 681 | ss->nskip_out_dejavu++; |
| 682 | |
| 683 | return (1); |
| 684 | } else { |
| 685 | struct m_tag *tag = m_tag_alloc(PACKET_COOKIE_SIFTR, |
| 686 | PACKET_TAG_SIFTR, 0, M_NOWAIT); |
| 687 | if (tag == NULL) { |
| 688 | if (dir == PFIL_IN) |
| 689 | ss->nskip_in_malloc++; |
| 690 | else |
| 691 | ss->nskip_out_malloc++; |
| 692 | |
| 693 | return (1); |
| 694 | } |
| 695 | |
| 696 | m_tag_prepend(m, tag); |
| 697 | } |
| 698 | |
| 699 | return (0); |
| 700 | } |
| 701 | |
| 702 | /* |
| 703 | * Look up an inpcb for a packet. Return the inpcb pointer if found, or NULL |
no test coverage detected