MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setup_fd_instance

Function setup_fd_instance

freebsd/net/route/fib_algo.c:971–1030  ·  view source on GitHub ↗

* Sets up algo @flm for table @rh and links it to the datapath. * */

Source from the content-addressed store, hash-verified

969 *
970 */
971static enum flm_op_result
972setup_fd_instance(struct fib_lookup_module *flm, struct rib_head *rh,
973 struct fib_data *orig_fd, struct fib_data **pfd, bool attach)
974{
975 struct fib_data *prev_fd, *new_fd;
976 enum flm_op_result result;
977
978 NET_EPOCH_ASSERT();
979 RIB_WLOCK_ASSERT(rh);
980
981 prev_fd = orig_fd;
982 new_fd = NULL;
983 for (int i = 0; i < FIB_MAX_TRIES; i++) {
984 result = try_setup_fd_instance(flm, rh, prev_fd, &new_fd);
985
986 if ((result == FLM_SUCCESS) && attach)
987 result = attach_datapath(new_fd);
988
989 if ((prev_fd != NULL) && (prev_fd != orig_fd)) {
990 schedule_destroy_fd_instance(prev_fd, false);
991 prev_fd = NULL;
992 }
993
994 RH_PRINTF(LOG_INFO, rh, "try %d: fib algo result: %s", i,
995 print_op_result(result));
996
997 if (result == FLM_REBUILD) {
998 prev_fd = new_fd;
999 new_fd = NULL;
1000 continue;
1001 }
1002
1003 break;
1004 }
1005
1006 if (result != FLM_SUCCESS) {
1007 RH_PRINTF(LOG_WARNING, rh,
1008 "%s algo instance setup failed, failures=%d", flm->flm_name,
1009 orig_fd ? orig_fd->fd_failed_rebuilds + 1 : 0);
1010 /* update failure count */
1011 FIB_MOD_LOCK();
1012 if (orig_fd != NULL)
1013 orig_fd->fd_failed_rebuilds++;
1014 FIB_MOD_UNLOCK();
1015
1016 /* Ban algo on non-recoverable error */
1017 if (result == FLM_ERROR)
1018 flm_error_add(flm, rh->rib_fibnum);
1019
1020 if ((prev_fd != NULL) && (prev_fd != orig_fd))
1021 schedule_destroy_fd_instance(prev_fd, false);
1022 if (new_fd != NULL) {
1023 schedule_destroy_fd_instance(new_fd, false);
1024 new_fd = NULL;
1025 }
1026 }
1027
1028 *pfd = new_fd;

Callers 3

rebuild_fdFunction · 0.85
set_fib_algoFunction · 0.85
fib_select_algo_initialFunction · 0.85

Calls 5

try_setup_fd_instanceFunction · 0.85
attach_datapathFunction · 0.85
print_op_resultFunction · 0.85
flm_error_addFunction · 0.85

Tested by

no test coverage detected