* Finalises fd destruction by freeing all fd resources. */
| 822 | * Finalises fd destruction by freeing all fd resources. |
| 823 | */ |
| 824 | static void |
| 825 | destroy_fd_instance(struct fib_data *fd) |
| 826 | { |
| 827 | |
| 828 | FD_PRINTF(LOG_INFO, fd, "destroy fd %p", fd); |
| 829 | |
| 830 | /* Call destroy callback first */ |
| 831 | if (fd->fd_algo_data != NULL) |
| 832 | fd->fd_flm->flm_destroy_cb(fd->fd_algo_data); |
| 833 | |
| 834 | /* Nhop table */ |
| 835 | if ((fd->nh_idx != NULL) && (fd->nh_ref_table != NULL)) { |
| 836 | for (int i = 0; i < fd->number_nhops; i++) { |
| 837 | if (!is_idx_free(fd, i)) { |
| 838 | FD_PRINTF(LOG_DEBUG2, fd, " FREE nhop %d %p", |
| 839 | i, fd->nh_idx[i]); |
| 840 | nhop_free_any(fd->nh_idx[i]); |
| 841 | } |
| 842 | } |
| 843 | free(fd->nh_idx, M_RTABLE); |
| 844 | } |
| 845 | if (fd->nh_ref_table != NULL) |
| 846 | free(fd->nh_ref_table, M_RTABLE); |
| 847 | |
| 848 | fib_unref_algo(fd->fd_flm); |
| 849 | |
| 850 | free(fd, M_RTABLE); |
| 851 | } |
| 852 | |
| 853 | /* |
| 854 | * Epoch callback indicating fd is safe to destroy |
no test coverage detected