* Insert @rt with nhop data from @rnd_new to @rnh. * Returns 0 on success and stores operation results in @rc. */
| 1051 | * Returns 0 on success and stores operation results in @rc. |
| 1052 | */ |
| 1053 | static int |
| 1054 | add_route_nhop(struct rib_head *rnh, struct rtentry *rt, |
| 1055 | struct rt_addrinfo *info, struct route_nhop_data *rnd, |
| 1056 | struct rib_cmd_info *rc) |
| 1057 | { |
| 1058 | struct sockaddr *ndst, *netmask; |
| 1059 | struct radix_node *rn; |
| 1060 | int error = 0; |
| 1061 | |
| 1062 | RIB_WLOCK_ASSERT(rnh); |
| 1063 | |
| 1064 | ndst = (struct sockaddr *)rt_key(rt); |
| 1065 | netmask = info->rti_info[RTAX_NETMASK]; |
| 1066 | |
| 1067 | rt->rt_nhop = rnd->rnd_nhop; |
| 1068 | rt->rt_weight = rnd->rnd_weight; |
| 1069 | rn = rnh->rnh_addaddr(ndst, netmask, &rnh->head, rt->rt_nodes); |
| 1070 | |
| 1071 | if (rn != NULL) { |
| 1072 | if (rt->rt_expire > 0) |
| 1073 | tmproutes_update(rnh, rt); |
| 1074 | |
| 1075 | /* Finalize notification */ |
| 1076 | rnh->rnh_gen++; |
| 1077 | rnh->rnh_prefixes++; |
| 1078 | |
| 1079 | rc->rc_cmd = RTM_ADD; |
| 1080 | rc->rc_rt = rt; |
| 1081 | rc->rc_nh_old = NULL; |
| 1082 | rc->rc_nh_new = rnd->rnd_nhop; |
| 1083 | rc->rc_nh_weight = rnd->rnd_weight; |
| 1084 | |
| 1085 | rib_notify(rnh, RIB_NOTIFY_IMMEDIATE, rc); |
| 1086 | } else { |
| 1087 | /* Existing route or memory allocation failure */ |
| 1088 | error = EEXIST; |
| 1089 | } |
| 1090 | |
| 1091 | return (error); |
| 1092 | } |
| 1093 | |
| 1094 | /* |
| 1095 | * Switch @rt nhop/weigh to the ones specified in @rnd. |
no test coverage detected