* Sets up algo @flm for table @rh and links it to the datapath. * */
| 969 | * |
| 970 | */ |
| 971 | static enum flm_op_result |
| 972 | setup_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; |
no test coverage detected