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

Function nd6_ra_input

freebsd/netinet6/nd6_rtr.c:352–607  ·  view source on GitHub ↗

* Receive Router Advertisement Message. * * Based on RFC 2461 * TODO: on-link bit on prefix information * TODO: ND_RA_FLAG_{OTHER,MANAGED} processing */

Source from the content-addressed store, hash-verified

350 * TODO: ND_RA_FLAG_{OTHER,MANAGED} processing
351 */
352void
353nd6_ra_input(struct mbuf *m, int off, int icmp6len)
354{
355 struct ifnet *ifp;
356 struct nd_ifinfo *ndi;
357 struct ip6_hdr *ip6;
358 struct nd_router_advert *nd_ra;
359 struct in6_addr saddr6;
360 struct nd_defrouter *dr;
361 union nd_opts ndopts;
362 char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
363 int mcast;
364
365 /*
366 * We only accept RAs only when the per-interface flag
367 * ND6_IFF_ACCEPT_RTADV is on the receiving interface.
368 */
369 ifp = m->m_pkthdr.rcvif;
370 ndi = ND_IFINFO(ifp);
371 if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV))
372 goto freeit;
373
374 /* RFC 6980: Nodes MUST silently ignore fragments */
375 if(m->m_flags & M_FRAGMENTED)
376 goto freeit;
377
378 ip6 = mtod(m, struct ip6_hdr *);
379 if (__predict_false(ip6->ip6_hlim != 255)) {
380 ICMP6STAT_INC(icp6s_invlhlim);
381 nd6log((LOG_ERR,
382 "%s: invalid hlim (%d) from %s to %s on %s\n", __func__,
383 ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
384 ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
385 goto bad;
386 }
387
388 saddr6 = ip6->ip6_src;
389 if (!IN6_IS_ADDR_LINKLOCAL(&saddr6)) {
390 nd6log((LOG_ERR,
391 "%s: src %s is not link-local\n", __func__,
392 ip6_sprintf(ip6bufs, &saddr6)));
393 goto bad;
394 }
395
396 if (m->m_len < off + icmp6len) {
397 m = m_pullup(m, off + icmp6len);
398 if (m == NULL) {
399 IP6STAT_INC(ip6s_exthdrtoolong);
400 return;
401 }
402 }
403 ip6 = mtod(m, struct ip6_hdr *);
404 nd_ra = (struct nd_router_advert *)((caddr_t)ip6 + off);
405
406 icmp6len -= sizeof(*nd_ra);
407 nd6_option_init(nd_ra + 1, icmp6len, &ndopts);
408 if (nd6_options(&ndopts) < 0) {
409 nd6log((LOG_INFO,

Callers 2

send_outputFunction · 0.85
icmp6_inputFunction · 0.85

Calls 15

ip6_sprintfFunction · 0.85
m_pullupFunction · 0.85
nd6_option_initFunction · 0.85
nd6_optionsFunction · 0.85
bzeroFunction · 0.85
defrtrlist_updateFunction · 0.85
defrtr_ipv6_only_ifpFunction · 0.85
prelist_updateFunction · 0.85
defrouter_releFunction · 0.85
in6_setmaxmtuFunction · 0.85
rt_updatemtuFunction · 0.85
nd6_cache_lladdrFunction · 0.85

Tested by

no test coverage detected