* Remove all default routes from default router list. */
| 826 | * Remove all default routes from default router list. |
| 827 | */ |
| 828 | void |
| 829 | defrouter_reset(void) |
| 830 | { |
| 831 | struct nd_defrouter *dr, **dra; |
| 832 | int count, i; |
| 833 | |
| 834 | count = i = 0; |
| 835 | |
| 836 | /* |
| 837 | * We can't delete routes with the ND lock held, so make a copy of the |
| 838 | * current default router list and use that when deleting routes. |
| 839 | */ |
| 840 | ND6_RLOCK(); |
| 841 | TAILQ_FOREACH(dr, &V_nd6_defrouter, dr_entry) |
| 842 | count++; |
| 843 | ND6_RUNLOCK(); |
| 844 | |
| 845 | dra = malloc(count * sizeof(*dra), M_TEMP, M_WAITOK | M_ZERO); |
| 846 | |
| 847 | ND6_RLOCK(); |
| 848 | TAILQ_FOREACH(dr, &V_nd6_defrouter, dr_entry) { |
| 849 | if (i == count) |
| 850 | break; |
| 851 | defrouter_ref(dr); |
| 852 | dra[i++] = dr; |
| 853 | } |
| 854 | ND6_RUNLOCK(); |
| 855 | |
| 856 | for (i = 0; i < count && dra[i] != NULL; i++) { |
| 857 | defrouter_delreq(dra[i]); |
| 858 | defrouter_rele(dra[i]); |
| 859 | } |
| 860 | free(dra, M_TEMP); |
| 861 | |
| 862 | /* |
| 863 | * XXX should we also nuke any default routers in the kernel, by |
| 864 | * going through them by rtalloc1()? |
| 865 | */ |
| 866 | } |
| 867 | |
| 868 | /* |
| 869 | * Look up a matching default router list entry and remove it. Returns true if a |
no test coverage detected