Lines Matching defs:rnh

77 static int add_route_byinfo(struct rib_head *rnh, struct rt_addrinfo *info,
79 static int change_route_byinfo(struct rib_head *rnh, struct rtentry *rt,
83 static int add_route_flags(struct rib_head *rnh, struct rtentry *rt,
86 static int add_route_flags_mpath(struct rib_head *rnh, struct rtentry *rt,
91 static int add_route(struct rib_head *rnh, struct rtentry *rt,
93 static int delete_route(struct rib_head *rnh, struct rtentry *rt,
95 static int rt_delete_conditional(struct rib_head *rnh, struct rtentry *rt,
150 struct rib_head *rnh;
156 rnh = rt_tables_get_rnh(fibnum, dst->sa_family);
158 return (rnh);
351 lookup_prefix_bysa(struct rib_head *rnh, const struct sockaddr *dst,
356 RIB_LOCK_ASSERT(rnh);
358 rt = (struct rtentry *)rnh->rnh_lookup(dst, netmask, &rnh->head);
371 lookup_prefix_rt(struct rib_head *rnh, const struct rtentry *rt,
374 return (lookup_prefix_bysa(rnh, rt_key_const(rt), rt_mask_const(rt), rnd));
384 lookup_prefix(struct rib_head *rnh, const struct rt_addrinfo *info,
389 rt = lookup_prefix_bysa(rnh, info->rti_info[RTAX_DST],
396 rib_lookup_prefix_plen(struct rib_head *rnh, struct sockaddr *dst, int plen,
403 return (lookup_prefix_bysa(rnh, dst, netmask, rnd));
492 struct rib_head *rnh = rt_tables_get_rnh(fibnum, dst->sa_family);
493 if (rnh == NULL)
497 FIB_RH_LOG(LOG_DEBUG, rnh, "error: invalid plen %d", plen);
502 if ((rt = rt_alloc(rnh, dst, netmask)) == NULL) {
503 FIB_RH_LOG(LOG_INFO, rnh, "rtentry allocation failed");
510 RIB_RLOCK(rnh);
511 rt = lookup_prefix_bysa(rnh, dst, netmask, &rnd_tmp);
512 RIB_RUNLOCK(rnh);
518 return (add_route_flags(rnh, rt, rnd, op_flags, rc));
571 struct rib_head *rnh = rt_tables_get_rnh(fibnum, dst->sa_family);
572 if (rnh == NULL)
576 FIB_RH_LOG(LOG_DEBUG, rnh, "error: dst->sa_len too big: %d", dst->sa_len);
581 FIB_RH_LOG(LOG_DEBUG, rnh, "error: invalid plen %d", plen);
587 RIB_WLOCK(rnh);
589 struct rtentry *rt = lookup_prefix_bysa(rnh, dst, netmask, &rnd);
591 error = rt_delete_conditional(rnh, rt, prio, filter_func,
595 RIB_WUNLOCK(rnh);
600 rib_notify(rnh, RIB_NOTIFY_DELAYED, rc);
695 struct rib_head *rnh;
700 rnh = get_rnh(fibnum, info);
701 if (rnh == NULL)
711 FIB_RH_LOG(LOG_DEBUG, rnh, "error: no RTF_HOST and empty netmask");
718 error = add_route_byinfo(rnh, info, rc);
720 rib_notify(rnh, RIB_NOTIFY_DELAYED, rc);
726 add_route_byinfo(struct rib_head *rnh, struct rt_addrinfo *info,
740 FIB_RH_LOG(LOG_DEBUG, rnh, "error: RTF_GATEWAY set with empty gw");
744 FIB_RH_LOG(LOG_DEBUG, rnh,
751 FIB_RH_LOG(LOG_DEBUG, rnh, "error: dst->sa_len too large: %d",
757 error = rt_getifa_fib(info, rnh->rib_fibnum);
762 if ((rt = rt_alloc(rnh, dst, netmask)) == NULL)
765 error = nhop_create_from_info(rnh, info, &nh);
783 return (add_route_flags(rnh, rt, &rnd_add, op_flags, rc));
787 add_route_flags(struct rib_head *rnh, struct rtentry *rt, struct route_nhop_data *rnd_add,
799 RIB_WLOCK(rnh);
801 rt_orig = lookup_prefix_rt(rnh, rt, &rnd_orig);
805 error = add_route(rnh, rt, rnd_add, rc);
808 RIB_WUNLOCK(rnh);
816 RIB_WUNLOCK(rnh);
825 RIB_WUNLOCK(rnh);
829 change_route(rnh, rt_orig, rnd_add, rc);
830 RIB_WUNLOCK(rnh);
835 RIB_WUNLOCK(rnh);
838 if ((op_flags & RTM_F_APPEND) && rib_can_multipath(rnh) &&
843 error = add_route_flags_mpath(rnh, rt_orig, rnd_add, &rnd_orig,
873 add_route_flags_mpath(struct rib_head *rnh, struct rtentry *rt,
881 error = nhgrp_get_addition_group(rnh, rnd_orig, rnd_add, &rnd_new);
889 RIB_RLOCK(rnh);
890 lookup_prefix_rt(rnh, rt, rnd_orig);
891 RIB_RUNLOCK(rnh);
899 error = change_route_conditional(rnh, rt, rnd_orig, &rnd_new, rc);
926 struct rib_head *rnh;
933 rnh = get_rnh(fibnum, info);
934 if (rnh == NULL)
946 FIB_RH_LOG(LOG_DEBUG, rnh, "error: dst->sa_len too large");
967 RIB_WLOCK(rnh);
969 struct rtentry *rt = lookup_prefix_bysa(rnh, dst, netmask, &rnd);
971 error = rt_delete_conditional(rnh, rt, prio, filter_func,
975 RIB_WUNLOCK(rnh);
980 rib_notify(rnh, RIB_NOTIFY_DELAYED, rc);
999 * Conditionally unlinks rtentry paths from @rnh matching @cb.
1006 rt_delete_conditional(struct rib_head *rnh, struct rtentry *rt,
1019 error = nhgrp_get_filtered_group(rnh, rt, nhg, cb, cbdata, &rnd);
1026 error = change_route(rnh, rt, &rnd, rc);
1037 return (delete_route(rnh, rt, rc));
1046 struct rib_head *rnh;
1052 rnh = get_rnh(fibnum, info);
1053 if (rnh == NULL)
1079 RIB_RLOCK(rnh);
1080 rt = (struct rtentry *)rnh->rnh_lookup(info->rti_info[RTAX_DST],
1081 info->rti_info[RTAX_NETMASK], &rnh->head);
1084 RIB_RUNLOCK(rnh);
1091 RIB_RUNLOCK(rnh);
1094 error = change_route_byinfo(rnh, rt, info, &rnd_orig, rc);
1103 change_nhop(struct rib_head *rnh, struct rt_addrinfo *info,
1118 error = rt_getifa_fib(info, rnh->rib_fibnum);
1126 error = nhop_create_from_nhop(rnh, nh_orig, info, nh_new);
1134 change_mpath_route(struct rib_head *rnh, struct rtentry *rt,
1157 error = change_nhop(rnh, info, nh_orig, &nh_new);
1172 error = nhgrp_get_group(rnh, wn_new, num_nhops, 0, &rnd_new.rnd_nhgrp);
1179 error = change_route_conditional(rnh, rt, rnd_orig, &rnd_new, rc);
1186 change_route_byinfo(struct rib_head *rnh, struct rtentry *rt,
1200 return (change_mpath_route(rnh, rt, info, rnd_orig, rc));
1204 error = change_nhop(rnh, info, nh_orig, &rnd_new.rnd_nhop);
1207 error = change_route_conditional(rnh, rt, rnd_orig, &rnd_new, rc);
1213 * Insert @rt with nhop data from @rnd_new to @rnh.
1217 add_route(struct rib_head *rnh, struct rtentry *rt,
1222 RIB_WLOCK_ASSERT(rnh);
1226 rn = rnh->rnh_addaddr(rt_key(rt), rt_mask_const(rt), &rnh->head, rt->rt_nodes);
1230 tmproutes_update(rnh, rt, rnd->rnd_nhop);
1233 rib_bump_gen(rnh);
1234 rnh->rnh_prefixes++;
1242 rib_notify(rnh, RIB_NOTIFY_IMMEDIATE, rc);
1251 * Unconditionally deletes @rt from @rnh.
1254 delete_route(struct rib_head *rnh, struct rtentry *rt, struct rib_cmd_info *rc)
1256 RIB_WLOCK_ASSERT(rnh);
1261 rn = rnh->rnh_deladdr(rt_key_const(rt), rt_mask_const(rt), &rnh->head);
1267 rib_bump_gen(rnh);
1268 rnh->rnh_prefixes--;
1276 rib_notify(rnh, RIB_NOTIFY_IMMEDIATE, rc);
1286 change_route(struct rib_head *rnh, struct rtentry *rt,
1291 RIB_WLOCK_ASSERT(rnh);
1296 return (delete_route(rnh, rt, rc));
1302 tmproutes_update(rnh, rt, rnd->rnd_nhop);
1305 rib_bump_gen(rnh);
1312 rib_notify(rnh, RIB_NOTIFY_IMMEDIATE, rc);
1323 change_route_conditional(struct rib_head *rnh, struct rtentry *rt,
1334 FIB_LOG(LOG_DEBUG2, rnh->rib_fibnum, rnh->rib_family,
1337 RIB_WLOCK(rnh);
1340 rt_new = lookup_prefix_rt(rnh, rt, &rnd);
1344 error = add_route(rnh, rt, rnd_new, rc);
1361 error = change_route(rnh, rt_new, rnd_new, rc);
1370 RIB_WUNLOCK(rnh);
1373 rib_notify(rnh, RIB_NOTIFY_DELAYED, rc);
1418 struct rib_head *rnh;
1436 if (rt_delete_conditional(di->rnh, rt, di->prio,
1477 struct rib_head *rnh;
1482 rnh = rt_tables_get_rnh(fibnum, family);
1483 if (rnh == NULL)
1487 .rnh = rnh,
1495 RIB_WLOCK(rnh);
1496 rnh->rnh_walktree(&rnh->head, rt_checkdelroute, &di);
1497 RIB_WUNLOCK(rnh);
1510 rib_notify(rnh, RIB_NOTIFY_DELAYED, &di.rc);
1536 struct rib_head *rnh = (struct rib_head *)arg;
1538 rn = rnh->rnh_deladdr(rt_key(rt), rt_mask(rt), &rnh->head);
1550 rib_flush_routes(struct rib_head *rnh)
1552 RIB_WLOCK(rnh);
1553 rnh->rnh_walktree(&rnh->head, rt_delete_unconditional, rnh);
1554 RIB_WUNLOCK(rnh);
1560 struct rib_head *rnh;
1563 if ((rnh = rt_tables_get_rnh(fibnum, family)) != NULL)
1564 rib_flush_routes(rnh);