Lines Matching +full:common +full:- +full:rules
6 * June 1991 as shown in the file COPYING in the top-level directory of this
42 struct nsim_fib_entry rules; member
82 struct nsim_fib_rt common; member
89 struct nsim_fib_rt common; member
143 entry = &fib_data->ipv4.fib; in nsim_fib_get_val()
146 entry = &fib_data->ipv4.rules; in nsim_fib_get_val()
149 entry = &fib_data->ipv6.fib; in nsim_fib_get_val()
152 entry = &fib_data->ipv6.rules; in nsim_fib_get_val()
155 entry = &fib_data->nexthops; in nsim_fib_get_val()
161 return max ? entry->max : atomic64_read(&entry->num); in nsim_fib_get_val()
171 entry = &fib_data->ipv4.fib; in nsim_fib_set_max()
174 entry = &fib_data->ipv4.rules; in nsim_fib_set_max()
177 entry = &fib_data->ipv6.fib; in nsim_fib_set_max()
180 entry = &fib_data->ipv6.rules; in nsim_fib_set_max()
183 entry = &fib_data->nexthops; in nsim_fib_set_max()
189 entry->max = val; in nsim_fib_set_max()
198 if (!atomic64_add_unless(&entry->num, 1, entry->max)) { in nsim_fib_rule_account()
199 err = -ENOSPC; in nsim_fib_rule_account()
203 atomic64_dec_if_positive(&entry->num); in nsim_fib_rule_account()
212 struct netlink_ext_ack *extack = info->extack; in nsim_fib_rule_event()
215 switch (info->family) { in nsim_fib_rule_event()
217 err = nsim_fib_rule_account(&data->ipv4.rules, add, extack); in nsim_fib_rule_event()
220 err = nsim_fib_rule_account(&data->ipv6.rules, add, extack); in nsim_fib_rule_event()
232 if (!atomic64_add_unless(&entry->num, 1, entry->max)) in nsim_fib_account()
233 err = -ENOSPC; in nsim_fib_account()
235 atomic64_dec_if_positive(&entry->num); in nsim_fib_account()
246 memcpy(fib_rt->key.addr, addr, addr_len); in nsim_fib_rt_init()
247 fib_rt->key.prefix_len = prefix_len; in nsim_fib_rt_init()
248 fib_rt->key.family = family; in nsim_fib_rt_init()
249 fib_rt->key.tb_id = tb_id; in nsim_fib_rt_init()
250 list_add(&fib_rt->list, &data->fib_rt_list); in nsim_fib_rt_init()
255 list_del(&fib_rt->list); in nsim_fib_rt_fini()
284 nsim_fib_rt_init(data, &fib4_rt->common, &fen_info->dst, sizeof(u32), in nsim_fib4_rt_create()
285 fen_info->dst_len, AF_INET, fen_info->tb_id); in nsim_fib4_rt_create()
287 fib4_rt->fi = fen_info->fi; in nsim_fib4_rt_create()
288 fib_info_hold(fib4_rt->fi); in nsim_fib4_rt_create()
289 fib4_rt->dscp = fen_info->dscp; in nsim_fib4_rt_create()
290 fib4_rt->type = fen_info->type; in nsim_fib4_rt_create()
297 fib_info_put(fib4_rt->fi); in nsim_fib4_rt_destroy()
298 nsim_fib_rt_fini(&fib4_rt->common); in nsim_fib4_rt_destroy()
308 fib_rt = nsim_fib_rt_lookup(fib_rt_ht, &fen_info->dst, sizeof(u32), in nsim_fib4_rt_lookup()
309 fen_info->dst_len, AF_INET, in nsim_fib4_rt_lookup()
310 fen_info->tb_id); in nsim_fib4_rt_lookup()
314 return container_of(fib_rt, struct nsim_fib4_rt, common); in nsim_fib4_rt_lookup()
321 u32 *p_dst = (u32 *)&fen_info->dst; in nsim_fib4_rt_offload_failed_flag_set()
324 fri.fi = fen_info->fi; in nsim_fib4_rt_offload_failed_flag_set()
325 fri.tb_id = fen_info->tb_id; in nsim_fib4_rt_offload_failed_flag_set()
327 fri.dst_len = fen_info->dst_len; in nsim_fib4_rt_offload_failed_flag_set()
328 fri.dscp = fen_info->dscp; in nsim_fib4_rt_offload_failed_flag_set()
329 fri.type = fen_info->type; in nsim_fib4_rt_offload_failed_flag_set()
340 u32 *p_dst = (u32 *) fib4_rt->common.key.addr; in nsim_fib4_rt_hw_flags_set()
341 int dst_len = fib4_rt->common.key.prefix_len; in nsim_fib4_rt_hw_flags_set()
344 fri.fi = fib4_rt->fi; in nsim_fib4_rt_hw_flags_set()
345 fri.tb_id = fib4_rt->common.key.tb_id; in nsim_fib4_rt_hw_flags_set()
348 fri.dscp = fib4_rt->dscp; in nsim_fib4_rt_hw_flags_set()
349 fri.type = fib4_rt->type; in nsim_fib4_rt_hw_flags_set()
359 struct net *net = devlink_net(data->devlink); in nsim_fib4_rt_add()
362 err = rhashtable_insert_fast(&data->fib_rt_ht, in nsim_fib4_rt_add()
363 &fib4_rt->common.ht_node, in nsim_fib4_rt_add()
378 nsim_fib_account(&data->ipv4.fib, false); in nsim_fib4_rt_add()
386 struct net *net = devlink_net(data->devlink); in nsim_fib4_rt_replace()
392 err = nsim_fib_account(&data->ipv4.fib, false); in nsim_fib4_rt_replace()
395 err = rhashtable_replace_fast(&data->fib_rt_ht, in nsim_fib4_rt_replace()
396 &fib4_rt_old->common.ht_node, in nsim_fib4_rt_replace()
397 &fib4_rt->common.ht_node, in nsim_fib4_rt_replace()
417 if (data->fail_route_offload) { in nsim_fib4_rt_insert()
423 return -EINVAL; in nsim_fib4_rt_insert()
428 return -ENOMEM; in nsim_fib4_rt_insert()
430 fib4_rt_old = nsim_fib4_rt_lookup(&data->fib_rt_ht, fen_info); in nsim_fib4_rt_insert()
447 fib4_rt = nsim_fib4_rt_lookup(&data->fib_rt_ht, fen_info); in nsim_fib4_rt_remove()
451 rhashtable_remove_fast(&data->fib_rt_ht, &fib4_rt->common.ht_node, in nsim_fib4_rt_remove()
466 struct net *net = devlink_net(data->devlink); in nsim_fib4_event()
487 list_for_each_entry(fib6_rt_nh, &fib6_rt->nh_list, list) { in nsim_fib6_rt_nh_find()
488 if (fib6_rt_nh->rt == rt) in nsim_fib6_rt_nh_find()
502 return -ENOMEM; in nsim_fib6_rt_nh_add()
505 fib6_rt_nh->rt = rt; in nsim_fib6_rt_nh_add()
506 list_add_tail(&fib6_rt_nh->list, &fib6_rt->nh_list); in nsim_fib6_rt_nh_add()
507 fib6_rt->nhs++; in nsim_fib6_rt_nh_add()
532 fib6_rt->nhs--; in nsim_fib6_rt_nh_del()
533 list_del(&fib6_rt_nh->list); in nsim_fib6_rt_nh_del()
534 nsim_rt6_release(fib6_rt_nh->rt); in nsim_fib6_rt_nh_del()
549 return ERR_PTR(-ENOMEM); in nsim_fib6_rt_create()
551 nsim_fib_rt_init(data, &fib6_rt->common, &rt->fib6_dst.addr, in nsim_fib6_rt_create()
552 sizeof(rt->fib6_dst.addr), rt->fib6_dst.plen, AF_INET6, in nsim_fib6_rt_create()
553 rt->fib6_table->tb6_id); in nsim_fib6_rt_create()
559 INIT_LIST_HEAD(&fib6_rt->nh_list); in nsim_fib6_rt_create()
570 for (i--; i >= 0; i--) { in nsim_fib6_rt_create()
573 nsim_fib_rt_fini(&fib6_rt->common); in nsim_fib6_rt_create()
582 list_for_each_entry_safe(iter, tmp, &fib6_rt->nh_list, list) in nsim_fib6_rt_destroy()
583 nsim_fib6_rt_nh_del(fib6_rt, iter->rt); in nsim_fib6_rt_destroy()
584 WARN_ON_ONCE(!list_empty(&fib6_rt->nh_list)); in nsim_fib6_rt_destroy()
585 nsim_fib_rt_fini(&fib6_rt->common); in nsim_fib6_rt_destroy()
594 fib_rt = nsim_fib_rt_lookup(fib_rt_ht, &rt->fib6_dst.addr, in nsim_fib6_rt_lookup()
595 sizeof(rt->fib6_dst.addr), in nsim_fib6_rt_lookup()
596 rt->fib6_dst.plen, AF_INET6, in nsim_fib6_rt_lookup()
597 rt->fib6_table->tb6_id); in nsim_fib6_rt_lookup()
601 return container_of(fib_rt, struct nsim_fib6_rt, common); in nsim_fib6_rt_lookup()
607 struct fib6_info *rt = fib6_event->rt_arr[0]; in nsim_fib6_rt_append()
611 if (data->fail_route_offload) { in nsim_fib6_rt_append()
617 return -EINVAL; in nsim_fib6_rt_append()
620 fib6_rt = nsim_fib6_rt_lookup(&data->fib_rt_ht, rt); in nsim_fib6_rt_append()
622 return -EINVAL; in nsim_fib6_rt_append()
624 for (i = 0; i < fib6_event->nrt6; i++) { in nsim_fib6_rt_append()
625 err = nsim_fib6_rt_nh_add(fib6_rt, fib6_event->rt_arr[i]); in nsim_fib6_rt_append()
629 WRITE_ONCE(fib6_event->rt_arr[i]->trap, true); in nsim_fib6_rt_append()
635 for (i--; i >= 0; i--) { in nsim_fib6_rt_append()
636 WRITE_ONCE(fib6_event->rt_arr[i]->trap, false); in nsim_fib6_rt_append()
637 nsim_fib6_rt_nh_del(fib6_rt, fib6_event->rt_arr[i]); in nsim_fib6_rt_append()
648 struct net *net = devlink_net(data->devlink); in nsim_fib6_rt_offload_failed_flag_set()
667 struct net *net = devlink_net(data->devlink); in nsim_fib6_rt_hw_flags_set()
670 list_for_each_entry(fib6_rt_nh, &fib6_rt->nh_list, list) in nsim_fib6_rt_hw_flags_set()
671 fib6_info_hw_flags_set(net, fib6_rt_nh->rt, false, trap, false); in nsim_fib6_rt_hw_flags_set()
686 err = rhashtable_insert_fast(&data->fib_rt_ht, in nsim_fib6_rt_add()
687 &fib6_rt->common.ht_node, in nsim_fib6_rt_add()
702 nsim_fib_account(&data->ipv6.fib, false); in nsim_fib6_rt_add()
715 err = nsim_fib_account(&data->ipv6.fib, false); in nsim_fib6_rt_replace()
719 err = rhashtable_replace_fast(&data->fib_rt_ht, in nsim_fib6_rt_replace()
720 &fib6_rt_old->common.ht_node, in nsim_fib6_rt_replace()
721 &fib6_rt->common.ht_node, in nsim_fib6_rt_replace()
739 struct fib6_info *rt = fib6_event->rt_arr[0]; in nsim_fib6_rt_insert()
743 if (data->fail_route_offload) { in nsim_fib6_rt_insert()
749 return -EINVAL; in nsim_fib6_rt_insert()
752 fib6_rt = nsim_fib6_rt_create(data, fib6_event->rt_arr, in nsim_fib6_rt_insert()
753 fib6_event->nrt6); in nsim_fib6_rt_insert()
757 fib6_rt_old = nsim_fib6_rt_lookup(&data->fib_rt_ht, rt); in nsim_fib6_rt_insert()
772 struct fib6_info *rt = fib6_event->rt_arr[0]; in nsim_fib6_rt_remove()
781 fib6_rt = nsim_fib6_rt_lookup(&data->fib_rt_ht, rt); in nsim_fib6_rt_remove()
788 if (fib6_event->nrt6 != fib6_rt->nhs) { in nsim_fib6_rt_remove()
789 for (i = 0; i < fib6_event->nrt6; i++) in nsim_fib6_rt_remove()
790 nsim_fib6_rt_nh_del(fib6_rt, fib6_event->rt_arr[i]); in nsim_fib6_rt_remove()
794 rhashtable_remove_fast(&data->fib_rt_ht, &fib6_rt->common.ht_node, in nsim_fib6_rt_remove()
802 struct fib6_info *rt = fen6_info->rt; in nsim_fib6_event_init()
808 nrt6 = fen6_info->nsiblings + 1; in nsim_fib6_event_init()
812 return -ENOMEM; in nsim_fib6_event_init()
814 fib6_event->rt_arr = rt_arr; in nsim_fib6_event_init()
815 fib6_event->nrt6 = nrt6; in nsim_fib6_event_init()
820 if (!fen6_info->nsiblings) in nsim_fib6_event_init()
823 list_for_each_entry(iter, &rt->fib6_siblings, fib6_siblings) { in nsim_fib6_event_init()
824 if (i == fen6_info->nsiblings) in nsim_fib6_event_init()
831 WARN_ON_ONCE(i != fen6_info->nsiblings); in nsim_fib6_event_init()
840 for (i = 0; i < fib6_event->nrt6; i++) in nsim_fib6_event_fini()
841 nsim_rt6_release(fib6_event->rt_arr[i]); in nsim_fib6_event_fini()
842 kfree(fib6_event->rt_arr); in nsim_fib6_event_fini()
851 if (fib6_event->rt_arr[0]->fib6_src.plen) in nsim_fib6_event()
875 nsim_fib6_rt_offload_failed_flag_set(data, fib6_event->rt_arr, in nsim_fib6_event()
876 fib6_event->nrt6); in nsim_fib6_event()
882 switch (fib_event->family) { in nsim_fib_event()
884 nsim_fib4_event(fib_event->data, &fib_event->fen_info, in nsim_fib_event()
885 fib_event->event); in nsim_fib_event()
886 fib_info_put(fib_event->fen_info.fi); in nsim_fib_event()
889 nsim_fib6_event(fib_event->data, &fib_event->fib6_event, in nsim_fib_event()
890 fib_event->event); in nsim_fib_event()
891 nsim_fib6_event_fini(&fib_event->fib6_event); in nsim_fib_event()
900 struct nsim_fib_data *data = fib_event->data; in nsim_fib4_prepare_event()
907 fib_event->fen_info = *fen_info; in nsim_fib4_prepare_event()
908 extack = info->extack; in nsim_fib4_prepare_event()
912 err = nsim_fib_account(&data->ipv4.fib, true); in nsim_fib4_prepare_event()
919 if (data->fail_route_delete) { in nsim_fib4_prepare_event()
921 return -EINVAL; in nsim_fib4_prepare_event()
923 nsim_fib_account(&data->ipv4.fib, false); in nsim_fib4_prepare_event()
930 fib_info_hold(fib_event->fen_info.fi); in nsim_fib4_prepare_event()
939 struct nsim_fib_data *data = fib_event->data; in nsim_fib6_prepare_event()
947 err = nsim_fib6_event_init(&fib_event->fib6_event, fen6_info); in nsim_fib6_prepare_event()
951 extack = info->extack; in nsim_fib6_prepare_event()
954 err = nsim_fib_account(&data->ipv6.fib, true); in nsim_fib6_prepare_event()
961 if (data->fail_route_delete) { in nsim_fib6_prepare_event()
962 err = -EINVAL; in nsim_fib6_prepare_event()
966 nsim_fib_account(&data->ipv6.fib, false); in nsim_fib6_prepare_event()
973 nsim_fib6_event_fini(&fib_event->fib6_event); in nsim_fib6_prepare_event()
984 if (info->family != AF_INET && info->family != AF_INET6) in nsim_fib_event_schedule_work()
994 fib_event->data = data; in nsim_fib_event_schedule_work()
995 fib_event->event = event; in nsim_fib_event_schedule_work()
996 fib_event->family = info->family; in nsim_fib_event_schedule_work()
998 switch (info->family) { in nsim_fib_event_schedule_work()
1011 spin_lock_bh(&data->fib_event_queue_lock); in nsim_fib_event_schedule_work()
1012 list_add_tail(&fib_event->list, &data->fib_event_queue); in nsim_fib_event_schedule_work()
1013 spin_unlock_bh(&data->fib_event_queue_lock); in nsim_fib_event_schedule_work()
1014 schedule_work(&data->fib_event_work); in nsim_fib_event_schedule_work()
1022 schedule_work(&data->fib_flush_work); in nsim_fib_event_schedule_work()
1052 struct devlink *devlink = data->devlink; in nsim_fib4_rt_free()
1055 fib4_rt = container_of(fib_rt, struct nsim_fib4_rt, common); in nsim_fib4_rt_free()
1057 nsim_fib_account(&data->ipv4.fib, false); in nsim_fib4_rt_free()
1066 fib6_rt = container_of(fib_rt, struct nsim_fib6_rt, common); in nsim_fib6_rt_free()
1068 nsim_fib_account(&data->ipv6.fib, false); in nsim_fib6_rt_free()
1077 switch (fib_rt->key.family) { in nsim_fib_rt_free()
1097 flush_work(&data->fib_event_work); in nsim_fib_dump_inconsistent()
1102 list_for_each_entry_safe(fib_rt, fib_rt_tmp, &data->fib_rt_list, list) { in nsim_fib_dump_inconsistent()
1103 rhashtable_remove_fast(&data->fib_rt_ht, &fib_rt->ht_node, in nsim_fib_dump_inconsistent()
1108 atomic64_set(&data->ipv4.rules.num, 0ULL); in nsim_fib_dump_inconsistent()
1109 atomic64_set(&data->ipv6.rules.num, 0ULL); in nsim_fib_dump_inconsistent()
1121 return ERR_PTR(-ENOMEM); in nsim_nexthop_create()
1123 nexthop->id = info->id; in nsim_nexthop_create()
1129 switch (info->type) { in nsim_nexthop_create()
1134 for (i = 0; i < info->nh_grp->num_nh; i++) in nsim_nexthop_create()
1135 occ += info->nh_grp->nh_entries[i].weight; in nsim_nexthop_create()
1138 occ = info->nh_res_table->num_nh_buckets; in nsim_nexthop_create()
1139 nexthop->is_resilient = true; in nsim_nexthop_create()
1142 NL_SET_ERR_MSG_MOD(info->extack, "Unsupported nexthop type"); in nsim_nexthop_create()
1144 return ERR_PTR(-EOPNOTSUPP); in nsim_nexthop_create()
1147 nexthop->occ = occ; in nsim_nexthop_create()
1163 if (!atomic64_add_unless(&data->nexthops.num, 1, in nsim_nexthop_account()
1164 data->nexthops.max)) { in nsim_nexthop_account()
1165 err = -ENOSPC; in nsim_nexthop_account()
1170 if (WARN_ON(occ > atomic64_read(&data->nexthops.num))) in nsim_nexthop_account()
1171 return -EINVAL; in nsim_nexthop_account()
1172 atomic64_sub(occ, &data->nexthops.num); in nsim_nexthop_account()
1178 atomic64_sub(i, &data->nexthops.num); in nsim_nexthop_account()
1189 nexthop_set_hw_flags(net, nexthop->id, false, trap); in nsim_nexthop_hw_flags_set()
1191 if (!nexthop->is_resilient) in nsim_nexthop_hw_flags_set()
1194 for (i = 0; i < nexthop->occ; i++) in nsim_nexthop_hw_flags_set()
1195 nexthop_bucket_set_hw_flags(net, nexthop->id, i, false, trap); in nsim_nexthop_hw_flags_set()
1202 struct net *net = devlink_net(data->devlink); in nsim_nexthop_add()
1205 err = nsim_nexthop_account(data, nexthop->occ, true, extack); in nsim_nexthop_add()
1209 err = rhashtable_insert_fast(&data->nexthop_ht, &nexthop->ht_node, in nsim_nexthop_add()
1221 nsim_nexthop_account(data, nexthop->occ, false, extack); in nsim_nexthop_add()
1230 struct net *net = devlink_net(data->devlink); in nsim_nexthop_replace()
1233 err = nsim_nexthop_account(data, nexthop->occ, true, extack); in nsim_nexthop_replace()
1237 err = rhashtable_replace_fast(&data->nexthop_ht, in nsim_nexthop_replace()
1238 &nexthop_old->ht_node, &nexthop->ht_node, in nsim_nexthop_replace()
1246 nsim_nexthop_account(data, nexthop_old->occ, false, extack); in nsim_nexthop_replace()
1252 nsim_nexthop_account(data, nexthop->occ, false, extack); in nsim_nexthop_replace()
1266 nexthop_old = rhashtable_lookup_fast(&data->nexthop_ht, &info->id, in nsim_nexthop_insert()
1269 err = nsim_nexthop_add(data, nexthop, info->extack); in nsim_nexthop_insert()
1272 info->extack); in nsim_nexthop_insert()
1285 nexthop = rhashtable_lookup_fast(&data->nexthop_ht, &info->id, in nsim_nexthop_remove()
1290 rhashtable_remove_fast(&data->nexthop_ht, &nexthop->ht_node, in nsim_nexthop_remove()
1292 nsim_nexthop_account(data, nexthop->occ, false, info->extack); in nsim_nexthop_remove()
1299 if (data->fail_res_nexthop_group_replace) { in nsim_nexthop_res_table_pre_replace()
1300 NL_SET_ERR_MSG_MOD(info->extack, "Failed to replace a resilient nexthop group"); in nsim_nexthop_res_table_pre_replace()
1301 return -EINVAL; in nsim_nexthop_res_table_pre_replace()
1310 if (data->fail_nexthop_bucket_replace) { in nsim_nexthop_bucket_replace()
1311 NL_SET_ERR_MSG_MOD(info->extack, "Failed to replace nexthop bucket"); in nsim_nexthop_bucket_replace()
1312 return -EINVAL; in nsim_nexthop_bucket_replace()
1315 nexthop_bucket_set_hw_flags(info->net, info->id, in nsim_nexthop_bucket_replace()
1316 info->nh_res_bucket->bucket_index, in nsim_nexthop_bucket_replace()
1330 mutex_lock(&data->nh_lock); in nsim_nexthop_event_nb()
1348 mutex_unlock(&data->nh_lock); in nsim_nexthop_event_nb()
1358 net = devlink_net(data->devlink); in nsim_nexthop_free()
1360 nsim_nexthop_account(data, nexthop->occ, false, NULL); in nsim_nexthop_free()
1368 struct nsim_fib_data *data = file->private_data; in nsim_nexthop_bucket_activity_write()
1369 struct net *net = devlink_net(data->devlink); in nsim_nexthop_bucket_activity_write()
1379 return -EINVAL; in nsim_nexthop_bucket_activity_write()
1380 if (size > sizeof(buf) - 1) in nsim_nexthop_bucket_activity_write()
1381 return -EINVAL; in nsim_nexthop_bucket_activity_write()
1383 return -EFAULT; in nsim_nexthop_bucket_activity_write()
1387 return -EINVAL; in nsim_nexthop_bucket_activity_write()
1391 nexthop = rhashtable_lookup_fast(&data->nexthop_ht, &nhid, in nsim_nexthop_bucket_activity_write()
1393 if (!nexthop || !nexthop->is_resilient || in nsim_nexthop_bucket_activity_write()
1394 bucket_index >= nexthop->occ) { in nsim_nexthop_bucket_activity_write()
1395 err = -EINVAL; in nsim_nexthop_bucket_activity_write()
1399 activity = bitmap_zalloc(nexthop->occ, GFP_KERNEL); in nsim_nexthop_bucket_activity_write()
1401 err = -ENOMEM; in nsim_nexthop_bucket_activity_write()
1406 nexthop_res_grp_activity_update(net, nhid, nexthop->occ, activity); in nsim_nexthop_bucket_activity_write()
1473 val = (u64) -1; in nsim_fib_set_max_all()
1486 spin_lock_bh(&data->fib_event_queue_lock); in nsim_fib_event_work()
1487 list_splice_init(&data->fib_event_queue, &fib_event_queue); in nsim_fib_event_work()
1488 spin_unlock_bh(&data->fib_event_queue_lock); in nsim_fib_event_work()
1490 mutex_lock(&data->fib_lock); in nsim_fib_event_work()
1494 list_del(&fib_event->list); in nsim_fib_event_work()
1498 mutex_unlock(&data->fib_lock); in nsim_fib_event_work()
1508 flush_work(&data->fib_event_work); in nsim_fib_flush_work()
1510 mutex_lock(&data->fib_lock); in nsim_fib_flush_work()
1511 list_for_each_entry_safe(fib_rt, fib_rt_tmp, &data->fib_rt_list, list) { in nsim_fib_flush_work()
1512 rhashtable_remove_fast(&data->fib_rt_ht, &fib_rt->ht_node, in nsim_fib_flush_work()
1516 mutex_unlock(&data->fib_lock); in nsim_fib_flush_work()
1522 data->ddir = debugfs_create_dir("fib", nsim_dev->ddir); in nsim_fib_debugfs_init()
1523 if (IS_ERR(data->ddir)) in nsim_fib_debugfs_init()
1524 return PTR_ERR(data->ddir); in nsim_fib_debugfs_init()
1526 data->fail_route_offload = false; in nsim_fib_debugfs_init()
1527 debugfs_create_bool("fail_route_offload", 0600, data->ddir, in nsim_fib_debugfs_init()
1528 &data->fail_route_offload); in nsim_fib_debugfs_init()
1530 data->fail_res_nexthop_group_replace = false; in nsim_fib_debugfs_init()
1531 debugfs_create_bool("fail_res_nexthop_group_replace", 0600, data->ddir, in nsim_fib_debugfs_init()
1532 &data->fail_res_nexthop_group_replace); in nsim_fib_debugfs_init()
1534 data->fail_nexthop_bucket_replace = false; in nsim_fib_debugfs_init()
1535 debugfs_create_bool("fail_nexthop_bucket_replace", 0600, data->ddir, in nsim_fib_debugfs_init()
1536 &data->fail_nexthop_bucket_replace); in nsim_fib_debugfs_init()
1538 debugfs_create_file("nexthop_bucket_activity", 0200, data->ddir, in nsim_fib_debugfs_init()
1541 data->fail_route_delete = false; in nsim_fib_debugfs_init()
1542 debugfs_create_bool("fail_route_delete", 0600, data->ddir, in nsim_fib_debugfs_init()
1543 &data->fail_route_delete); in nsim_fib_debugfs_init()
1549 debugfs_remove_recursive(data->ddir); in nsim_fib_debugfs_exit()
1561 return ERR_PTR(-ENOMEM); in nsim_fib_create()
1562 data->devlink = devlink; in nsim_fib_create()
1569 mutex_init(&data->nh_lock); in nsim_fib_create()
1570 err = rhashtable_init(&data->nexthop_ht, &nsim_nexthop_ht_params); in nsim_fib_create()
1574 mutex_init(&data->fib_lock); in nsim_fib_create()
1575 INIT_LIST_HEAD(&data->fib_rt_list); in nsim_fib_create()
1576 err = rhashtable_init(&data->fib_rt_ht, &nsim_fib_rt_ht_params); in nsim_fib_create()
1580 INIT_WORK(&data->fib_event_work, nsim_fib_event_work); in nsim_fib_create()
1581 INIT_WORK(&data->fib_flush_work, nsim_fib_flush_work); in nsim_fib_create()
1582 INIT_LIST_HEAD(&data->fib_event_queue); in nsim_fib_create()
1583 spin_lock_init(&data->fib_event_queue_lock); in nsim_fib_create()
1587 data->nexthop_nb.notifier_call = nsim_nexthop_event_nb; in nsim_fib_create()
1588 err = register_nexthop_notifier(devlink_net(devlink), &data->nexthop_nb, in nsim_fib_create()
1595 data->fib_nb.notifier_call = nsim_fib_event_nb; in nsim_fib_create()
1596 err = register_fib_notifier(devlink_net(devlink), &data->fib_nb, in nsim_fib_create()
1626 unregister_nexthop_notifier(devlink_net(devlink), &data->nexthop_nb); in nsim_fib_create()
1628 cancel_work_sync(&data->fib_flush_work); in nsim_fib_create()
1629 flush_work(&data->fib_event_work); in nsim_fib_create()
1630 rhashtable_free_and_destroy(&data->fib_rt_ht, nsim_fib_rt_free, in nsim_fib_create()
1633 rhashtable_free_and_destroy(&data->nexthop_ht, nsim_nexthop_free, in nsim_fib_create()
1635 mutex_destroy(&data->fib_lock); in nsim_fib_create()
1637 mutex_destroy(&data->nh_lock); in nsim_fib_create()
1656 unregister_fib_notifier(devlink_net(devlink), &data->fib_nb); in nsim_fib_destroy()
1657 unregister_nexthop_notifier(devlink_net(devlink), &data->nexthop_nb); in nsim_fib_destroy()
1658 cancel_work_sync(&data->fib_flush_work); in nsim_fib_destroy()
1659 flush_work(&data->fib_event_work); in nsim_fib_destroy()
1660 rhashtable_free_and_destroy(&data->fib_rt_ht, nsim_fib_rt_free, in nsim_fib_destroy()
1662 rhashtable_free_and_destroy(&data->nexthop_ht, nsim_nexthop_free, in nsim_fib_destroy()
1664 WARN_ON_ONCE(!list_empty(&data->fib_event_queue)); in nsim_fib_destroy()
1665 WARN_ON_ONCE(!list_empty(&data->fib_rt_list)); in nsim_fib_destroy()
1666 mutex_destroy(&data->fib_lock); in nsim_fib_destroy()
1667 mutex_destroy(&data->nh_lock); in nsim_fib_destroy()