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

Function rip_append

freebsd/netinet/raw_ip.c:233–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232#ifdef INET
233static int
234rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
235 struct sockaddr_in *ripsrc)
236{
237 int policyfail = 0;
238
239 INP_LOCK_ASSERT(last);
240
241#if defined(IPSEC) || defined(IPSEC_SUPPORT)
242 /* check AH/ESP integrity. */
243 if (IPSEC_ENABLED(ipv4)) {
244 if (IPSEC_CHECK_POLICY(ipv4, n, last) != 0)
245 policyfail = 1;
246 }
247#endif /* IPSEC */
248#ifdef MAC
249 if (!policyfail && mac_inpcb_check_deliver(last, n) != 0)
250 policyfail = 1;
251#endif
252 /* Check the minimum TTL for socket. */
253 if (last->inp_ip_minttl && last->inp_ip_minttl > ip->ip_ttl)
254 policyfail = 1;
255 if (!policyfail) {
256 struct mbuf *opts = NULL;
257 struct socket *so;
258
259 so = last->inp_socket;
260 if ((last->inp_flags & INP_CONTROLOPTS) ||
261 (so->so_options & (SO_TIMESTAMP | SO_BINTIME)))
262 ip_savecontrol(last, &opts, ip, n);
263 SOCKBUF_LOCK(&so->so_rcv);
264 if (sbappendaddr_locked(&so->so_rcv,
265 (struct sockaddr *)ripsrc, n, opts) == 0) {
266 /* should notify about lost packet */
267 m_freem(n);
268 if (opts)
269 m_freem(opts);
270 SOCKBUF_UNLOCK(&so->so_rcv);
271 } else
272 sorwakeup_locked(so);
273 } else
274 m_freem(n);
275 return (policyfail);
276}
277
278/*
279 * Setup generic address and protocol structures for raw_input routine, then

Callers 1

rip_inputFunction · 0.85

Calls 4

mac_inpcb_check_deliverFunction · 0.85
ip_savecontrolFunction · 0.85
sbappendaddr_lockedFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected