* Create neighbor cache entry and cache link-layer address, * on reception of inbound ND6 packets. (RS/RA/NS/redirect) * * type - ICMP6 type * code - type dependent information * */
| 1921 | * |
| 1922 | */ |
| 1923 | void |
| 1924 | nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, |
| 1925 | int lladdrlen, int type, int code) |
| 1926 | { |
| 1927 | struct llentry *ln = NULL, *ln_tmp; |
| 1928 | int is_newentry; |
| 1929 | int do_update; |
| 1930 | int olladdr; |
| 1931 | int llchange; |
| 1932 | int flags; |
| 1933 | uint16_t router = 0; |
| 1934 | struct sockaddr_in6 sin6; |
| 1935 | struct mbuf *chain = NULL; |
| 1936 | u_char linkhdr[LLE_MAX_LINKHDR]; |
| 1937 | size_t linkhdrsize; |
| 1938 | int lladdr_off; |
| 1939 | |
| 1940 | NET_EPOCH_ASSERT(); |
| 1941 | IF_AFDATA_UNLOCK_ASSERT(ifp); |
| 1942 | |
| 1943 | KASSERT(ifp != NULL, ("%s: ifp == NULL", __func__)); |
| 1944 | KASSERT(from != NULL, ("%s: from == NULL", __func__)); |
| 1945 | |
| 1946 | /* nothing must be updated for unspecified address */ |
| 1947 | if (IN6_IS_ADDR_UNSPECIFIED(from)) |
| 1948 | return; |
| 1949 | |
| 1950 | /* |
| 1951 | * Validation about ifp->if_addrlen and lladdrlen must be done in |
| 1952 | * the caller. |
| 1953 | * |
| 1954 | * XXX If the link does not have link-layer adderss, what should |
| 1955 | * we do? (ifp->if_addrlen == 0) |
| 1956 | * Spec says nothing in sections for RA, RS and NA. There's small |
| 1957 | * description on it in NS section (RFC 2461 7.2.3). |
| 1958 | */ |
| 1959 | flags = lladdr ? LLE_EXCLUSIVE : 0; |
| 1960 | ln = nd6_lookup(from, flags, ifp); |
| 1961 | is_newentry = 0; |
| 1962 | if (ln == NULL) { |
| 1963 | flags |= LLE_EXCLUSIVE; |
| 1964 | ln = nd6_alloc(from, 0, ifp); |
| 1965 | if (ln == NULL) |
| 1966 | return; |
| 1967 | |
| 1968 | /* |
| 1969 | * Since we already know all the data for the new entry, |
| 1970 | * fill it before insertion. |
| 1971 | */ |
| 1972 | if (lladdr != NULL) { |
| 1973 | linkhdrsize = sizeof(linkhdr); |
| 1974 | if (lltable_calc_llheader(ifp, AF_INET6, lladdr, |
| 1975 | linkhdr, &linkhdrsize, &lladdr_off) != 0) |
| 1976 | return; |
| 1977 | lltable_set_entry_addr(ifp, ln, linkhdr, linkhdrsize, |
| 1978 | lladdr_off); |
| 1979 | } |
| 1980 |
no test coverage detected