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

Function ip6_tryforward

freebsd/netinet6/ip6_fastfwd.c:91–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91struct mbuf*
92ip6_tryforward(struct mbuf *m)
93{
94 struct sockaddr_in6 dst;
95 struct nhop_object *nh;
96 struct m_tag *fwd_tag;
97 struct ip6_hdr *ip6;
98 struct ifnet *rcvif;
99 uint32_t plen;
100 int error;
101
102 /*
103 * Fallback conditions to ip6_input for slow path processing.
104 */
105 ip6 = mtod(m, struct ip6_hdr *);
106 if ((m->m_flags & (M_BCAST | M_MCAST)) != 0 ||
107 ip6->ip6_nxt == IPPROTO_HOPOPTS ||
108 IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
109 IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst) ||
110 IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_src) ||
111 IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) ||
112 in6_localip(&ip6->ip6_dst))
113 return (m);
114 /*
115 * Check that the amount of data in the buffers
116 * is as at least much as the IPv6 header would have us expect.
117 * Trim mbufs if longer than we expect.
118 * Drop packet if shorter than we expect.
119 */
120 rcvif = m->m_pkthdr.rcvif;
121 plen = ntohs(ip6->ip6_plen);
122 if (plen == 0) {
123 /*
124 * Jumbograms must have hop-by-hop header and go via
125 * slow path.
126 */
127 IP6STAT_INC(ip6s_badoptions);
128 goto dropin;
129 }
130 if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) {
131 IP6STAT_INC(ip6s_tooshort);
132 in6_ifstat_inc(rcvif, ifs6_in_truncated);
133 goto dropin;
134 }
135 if (m->m_pkthdr.len > sizeof(struct ip6_hdr) + plen) {
136 if (m->m_len == m->m_pkthdr.len) {
137 m->m_len = sizeof(struct ip6_hdr) + plen;
138 m->m_pkthdr.len = sizeof(struct ip6_hdr) + plen;
139 } else
140 m_adj(m, sizeof(struct ip6_hdr) + plen -
141 m->m_pkthdr.len);
142 }
143
144 /*
145 * Hop limit.
146 */
147#ifdef IPSTEALTH
148 if (!V_ip6stealth)

Callers 1

ip6_inputFunction · 0.85

Calls 10

in6_localipFunction · 0.85
m_adjFunction · 0.85
icmp6_errorFunction · 0.85
bzeroFunction · 0.85
pfil_run_hooksFunction · 0.85
m_tag_deleteFunction · 0.85
ip6_findrouteFunction · 0.85
m_tag_findFunction · 0.50
m_clrprotoflagsFunction · 0.50
m_freemFunction · 0.50

Tested by

no test coverage detected