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

Function siftr_chkreinject

freebsd/netinet/siftr.c:673–700  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

671 * Return value >0 means the caller should skip processing this mbuf.
672 */
673static inline int
674siftr_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

Callers 2

siftr_chkpktFunction · 0.85
siftr_chkpkt6Function · 0.85

Calls 3

m_tag_locateFunction · 0.85
m_tag_allocFunction · 0.85
m_tag_prependFunction · 0.50

Tested by

no test coverage detected