* Default hop limit selection. The precedence is as follows: * 1. Hoplimit value specified via ioctl. * 2. (If the outgoing interface is detected) the current * hop limit of the interface specified by router advertisement. * 3. The system default hoplimit. */
| 905 | * 3. The system default hoplimit. |
| 906 | */ |
| 907 | int |
| 908 | in6_selecthlim(struct inpcb *inp, struct ifnet *ifp) |
| 909 | { |
| 910 | |
| 911 | if (inp && inp->in6p_hops >= 0) |
| 912 | return (inp->in6p_hops); |
| 913 | else if (ifp) |
| 914 | return (ND_IFINFO(ifp)->chlim); |
| 915 | else if (inp && !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { |
| 916 | struct nhop_object *nh; |
| 917 | struct in6_addr dst; |
| 918 | uint32_t fibnum, scopeid; |
| 919 | int hlim; |
| 920 | |
| 921 | fibnum = inp->inp_inc.inc_fibnum; |
| 922 | in6_splitscope(&inp->in6p_faddr, &dst, &scopeid); |
| 923 | nh = fib6_lookup(fibnum, &dst, scopeid, 0, 0); |
| 924 | if (nh != NULL) { |
| 925 | hlim = ND_IFINFO(nh->nh_ifp)->chlim; |
| 926 | return (hlim); |
| 927 | } |
| 928 | } |
| 929 | return (V_ip6_defhlim); |
| 930 | } |
| 931 | |
| 932 | /* |
| 933 | * XXX: this is borrowed from in6_pcbbind(). If possible, we should |
no test coverage detected