Lines Matching defs:rt

321 	struct rtentry *rt;
323 if ((rt = ro->ro_rt) != NULL) {
324 if (rt->rt_ifp != NULL && rt->rt_flags & RTF_UP)
326 RTFREE(rt);
337 struct rtentry *rt;
339 if ((rt = ro->ro_rt) != NULL) {
340 if (rt->rt_ifp != NULL && rt->rt_flags & RTF_UP)
342 RTFREE(rt);
440 rtfree(struct rtentry *rt)
444 KASSERT(rt != NULL,("%s: NULL rt", __func__));
445 rnh = rt_tables_get_rnh(rt->rt_fibnum, rt_key(rt)->sa_family);
448 RT_LOCK_ASSERT(rt);
454 RT_REMREF(rt);
455 if (rt->rt_refcnt > 0) {
456 log(LOG_DEBUG, "%s: %p has %d refs\n", __func__, rt, rt->rt_refcnt);
469 if (rt->rt_refcnt == 0 && rnh->rnh_close)
470 rnh->rnh_close((struct radix_node *)rt, rnh);
477 if ((rt->rt_flags & RTF_UP) == 0) {
478 if (rt->rt_nodes->rn_flags & (RNF_ACTIVE | RNF_ROOT))
486 if (rt->rt_refcnt < 0) {
487 printf("rtfree: %p not freed (neg refs)\n", rt);
495 if (rt->rt_ifa)
496 ifa_free(rt->rt_ifa);
502 Free(rt_key(rt));
507 RT_LOCK_DESTROY(rt);
508 uma_zfree(V_rtzone, rt);
512 RT_UNLOCK(rt);
541 struct rtentry *rt, *rt0 = NULL;
560 rt = rtalloc1_fib(dst, 0, 0UL, fibnum); /* NB: rt is locked */
567 if (!(flags & RTF_DONE) && rt &&
568 (!sa_equal(src, rt->rt_gateway) || rt->rt_ifa != ifa))
580 if (rt == NULL || (rt_mask(rt) && rt_mask(rt)->sa_len < 2))
586 if (rt->rt_flags & RTF_GATEWAY) {
587 if (((rt->rt_flags & RTF_HOST) == 0) && (flags & RTF_HOST)) {
593 rt0 = rt;
594 rt = NULL;
605 error = rtrequest1_fib(RTM_ADD, &info, &rt, fibnum);
606 if (rt != NULL) {
607 RT_LOCK(rt);
609 EVENTHANDLER_INVOKE(route_redirect_event, rt0, rt, dst);
610 flags = rt->rt_flags;
623 rt->rt_flags |= RTF_MODIFIED;
629 RT_UNLOCK(rt);
631 RT_LOCK(rt);
632 rt_setgate(rt, rt_key(rt), gateway);
635 EVENTHANDLER_INVOKE(route_redirect_event, rt, gwrt, dst);
641 if (rt)
642 RTFREE_LOCKED(rt);
727 struct rtentry *rt = rtalloc1_fib(gateway, 0, RTF_RNH_LOCKED, fibnum);
728 if (rt == NULL)
736 if (satosin(rt_key(rt))->sin_addr.s_addr == INADDR_ANY)
740 if (IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(rt))->sin6_addr))
746 if (!not_found && rt->rt_ifa != NULL) {
747 ifa = rt->rt_ifa;
750 RT_REMREF(rt);
751 RT_UNLOCK(rt);
872 rtexpunge(struct rtentry *rt)
888 rnh = rt_tables_get_rnh(rt->rt_fibnum, rt_key(rt)->sa_family);
889 RT_LOCK_ASSERT(rt);
895 fib = rt->rt_fibnum;
897 info.rti_ifp = rt->rt_ifp;
899 info.rti_info[RTAX_DST] = rt_key(rt);
900 info.rti_info[RTAX_GATEWAY] = rt->rt_ifa->ifa_addr;
902 RT_UNLOCK(rt);
906 rt = rt0;
907 RT_LOCK(rt);
909 RT_LOCK(rt);
917 rn = rnh->rnh_deladdr(rt_key(rt), rt_mask(rt), rnh);
924 KASSERT(rt == RNTORT(rn),
925 ("lookup mismatch, rt %p rn %p", rt, rn));
928 rt->rt_flags &= ~RTF_UP;
933 if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest) {
937 info.rti_flags = rt->rt_flags;
938 info.rti_info[RTAX_DST] = rt_key(rt);
939 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
940 info.rti_info[RTAX_NETMASK] = rt_mask(rt);
941 ifa->ifa_rtrequest(RTM_DELETE, rt, &info);
957 int rt_print(char *buf, int buflen, struct rtentry *rt);
983 rt_print(char *buf, int buflen, struct rtentry *rt)
988 addr = rt_key(rt);
989 mask = rt_mask(rt);
992 if (!(rt->rt_flags & RTF_HOST)) {
997 if (rt->rt_flags & RTF_GATEWAY) {
999 i += p_sockaddr(buf + i, buflen - i, rt->rt_gateway);
1015 struct rtentry *rt, *rto = NULL;
1022 rto = rt = RNTORT(rn);
1024 rt = rt_mpath_matchgate(rt, gateway);
1025 if (rt == NULL)
1030 if (rto == rt) {
1031 rn = rn_mpath_next((struct radix_node *)rt);
1040 } else if (rt->rt_flags & RTF_GATEWAY) {
1050 (rt->rt_gateway->sa_len != gateway->sa_len ||
1051 memcmp(rt->rt_gateway, gateway, gateway->sa_len)))
1059 KASSERT(rt == RNTORT(rn), ("radix node disappeared"));
1078 if ((req == RTM_DELETE) && !rt_mpath_deldup(rto, rt))
1081 RT_LOCK(rt);
1082 RT_ADDREF(rt);
1084 rt->rt_flags &= ~RTF_UP;
1088 * when RTFREE(rt) is eventually called.
1104 *ret_nrt = rt;
1105 RT_UNLOCK(rt);
1107 RTFREE_LOCKED(rt);
1118 register struct rtentry *rt;
1179 rt = (struct rtentry *)rnh->rnh_lookup(dst,
1181 if ((rt != NULL) && (rt->rt_flags & RTF_PINNED))
1194 rt = RNTORT(rn);
1195 RT_LOCK(rt);
1196 RT_ADDREF(rt);
1197 rt->rt_flags &= ~RTF_UP;
1202 if ((ifa = rt->rt_ifa) && ifa->ifa_rtrequest)
1203 ifa->ifa_rtrequest(RTM_DELETE, rt, info);
1208 * when RTFREE(rt) is eventually called.
1218 *ret_nrt = rt;
1219 RT_UNLOCK(rt);
1221 RTFREE_LOCKED(rt);
1243 rt = uma_zalloc(V_rtzone, M_NOWAIT | M_ZERO);
1244 if (rt == NULL) {
1249 RT_LOCK_INIT(rt);
1250 rt->rt_flags = RTF_UP | flags;
1251 rt->rt_fibnum = fibnum;
1255 RT_LOCK(rt);
1256 if ((error = rt_setgate(rt, dst, gateway)) != 0) {
1257 RT_LOCK_DESTROY(rt);
1260 uma_zfree(V_rtzone, rt);
1267 ndst = (struct sockaddr *)rt_key(rt);
1282 rt->rt_ifa = ifa;
1283 rt->rt_ifp = ifa->ifa_ifp;
1284 rt->rt_rmx.rmx_weight = 1;
1289 rt_mpath_conflict(rnh, rt, netmask)) {
1290 if (rt->rt_ifa) {
1291 ifa_free(rt->rt_ifa);
1293 Free(rt_key(rt));
1294 RT_LOCK_DESTROY(rt);
1295 uma_zfree(V_rtzone, rt);
1354 rn = rnh->rnh_addaddr(ndst, netmask, rnh, rt->rt_nodes);
1360 if (rt->rt_ifa)
1361 ifa_free(rt->rt_ifa);
1362 Free(rt_key(rt));
1363 RT_LOCK_DESTROY(rt);
1364 uma_zfree(V_rtzone, rt);
1394 ifa->ifa_rtrequest(req, rt, info);
1401 *ret_nrt = rt;
1402 RT_ADDREF(rt);
1404 RT_UNLOCK(rt);
1424 rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
1431 rnh = rt_tables_get_rnh(rt->rt_fibnum, dst->sa_family);
1434 RT_LOCK_ASSERT(rt);
1438 * Prepare to store the gateway in rt->rt_gateway.
1444 if (rt->rt_gateway == NULL || glen > SA_SIZE(rt->rt_gateway)) {
1451 * XXX note, we copy from *dst and not *rt_key(rt) because
1453 * allocated route entry, in which case rt_key(rt) == NULL
1454 * (and also rt->rt_gateway == NULL).
1458 Free(rt_key(rt)); /* free old block, if any */
1459 rt_key(rt) = (struct sockaddr *)new;
1460 rt->rt_gateway = (struct sockaddr *)(new + dlen);
1466 bcopy(gate, rt->rt_gateway, glen);
1500 struct rtentry *rt = NULL;
1584 rt = RNTORT(rn);
1587 * rt->rt_gateway is sockaddr_intf
1592 rt = rt_mpath_matchgate(rt,
1594 if (rt == NULL)
1625 error = rtrequest1_fib(cmd, &info, &rt, fibnum);
1641 error = rtrequest1_fib(RTM_DELETE, &info, &rt, fibnum);
1646 error = rtrequest1_fib(cmd, &info, &rt, fibnum);
1653 if (error == 0 && rt != NULL) {
1657 RT_LOCK(rt);
1666 if (memcmp(rt->rt_ifa->ifa_addr,
1668 ifa_free(rt->rt_ifa);
1670 rt->rt_ifp = ifa->ifa_ifp;
1671 rt->rt_ifa = ifa;
1678 ((struct sockaddr_dl *)rt->rt_gateway)->sdl_type =
1679 rt->rt_ifp->if_type;
1680 ((struct sockaddr_dl *)rt->rt_gateway)->sdl_index =
1681 rt->rt_ifp->if_index;
1683 RT_ADDREF(rt);
1684 RT_UNLOCK(rt);
1685 rt_newaddrmsg_fib(cmd, ifa, error, rt, fibnum);
1686 RT_LOCK(rt);
1687 RT_REMREF(rt);
1694 RTFREE_LOCKED(rt);
1701 RT_REMREF(rt);
1703 RT_UNLOCK(rt);
1800 rt_routemsg(int cmd, struct ifnet *ifp, int error, struct rtentry *rt,
1810 KASSERT(rt_key(rt) != NULL, (":%s: rt_key must be supplied", __func__));
1812 return (rtsock_routemsg(cmd, ifp, error, rt, fibnum));
1816 rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt)
1819 rt_newaddrmsg_fib(cmd, ifa, error, rt, RT_ALL_FIBS);
1827 rt_newaddrmsg_fib(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt,
1838 if (rt != NULL)
1839 rt_routemsg(cmd, ifa->ifa_ifp, error, rt, fibnum);
1841 if (rt != NULL)
1842 rt_routemsg(cmd, ifa->ifa_ifp, error, rt, fibnum);