* Calculates IPv6 path MTU for @dst based on transmit @ifp, * and cached data in @ro_pmtu. * MTU from (successful) route lookup is saved (along with dst) * inside @ro_pmtu to avoid subsequent route lookups after packet * filter processing. * * Stores mtu and always-frag value into @mtup and @alwaysfragp. * Returns 0 on success. */
| 1490 | * Returns 0 on success. |
| 1491 | */ |
| 1492 | static int |
| 1493 | ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup, |
| 1494 | struct ifnet *ifp, const struct in6_addr *dst, u_long *mtup, |
| 1495 | int *alwaysfragp, u_int fibnum, u_int proto) |
| 1496 | { |
| 1497 | struct nhop_object *nh; |
| 1498 | struct in6_addr kdst; |
| 1499 | uint32_t scopeid; |
| 1500 | struct sockaddr_in6 *sa6_dst, sin6; |
| 1501 | u_long mtu; |
| 1502 | |
| 1503 | NET_EPOCH_ASSERT(); |
| 1504 | |
| 1505 | mtu = 0; |
| 1506 | if (ro_pmtu == NULL || do_lookup) { |
| 1507 | /* |
| 1508 | * Here ro_pmtu has final destination address, while |
| 1509 | * ro might represent immediate destination. |
| 1510 | * Use ro_pmtu destination since mtu might differ. |
| 1511 | */ |
| 1512 | if (ro_pmtu != NULL) { |
| 1513 | sa6_dst = (struct sockaddr_in6 *)&ro_pmtu->ro_dst; |
| 1514 | if (!IN6_ARE_ADDR_EQUAL(&sa6_dst->sin6_addr, dst)) |
| 1515 | ro_pmtu->ro_mtu = 0; |
| 1516 | } else |
| 1517 | sa6_dst = &sin6; |
| 1518 | |
| 1519 | if (ro_pmtu == NULL || ro_pmtu->ro_mtu == 0) { |
| 1520 | bzero(sa6_dst, sizeof(*sa6_dst)); |
| 1521 | sa6_dst->sin6_family = AF_INET6; |
| 1522 | sa6_dst->sin6_len = sizeof(struct sockaddr_in6); |
| 1523 | sa6_dst->sin6_addr = *dst; |
| 1524 | |
| 1525 | in6_splitscope(dst, &kdst, &scopeid); |
| 1526 | nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0); |
| 1527 | if (nh != NULL) { |
| 1528 | mtu = nh->nh_mtu; |
| 1529 | if (ro_pmtu != NULL) |
| 1530 | ro_pmtu->ro_mtu = mtu; |
| 1531 | } |
| 1532 | } else |
| 1533 | mtu = ro_pmtu->ro_mtu; |
| 1534 | } |
| 1535 | |
| 1536 | if (ro_pmtu != NULL && ro_pmtu->ro_nh != NULL) |
| 1537 | mtu = ro_pmtu->ro_nh->nh_mtu; |
| 1538 | |
| 1539 | return (ip6_calcmtu(ifp, dst, mtu, mtup, alwaysfragp, proto)); |
| 1540 | } |
| 1541 | |
| 1542 | /* |
| 1543 | * Calculate MTU based on transmit @ifp, route mtu @rt_mtu and |
no test coverage detected