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

Function defrouter_reset

freebsd/netinet6/nd6_rtr.c:828–866  ·  view source on GitHub ↗

* Remove all default routes from default router list. */

Source from the content-addressed store, hash-verified

826 * Remove all default routes from default router list.
827 */
828void
829defrouter_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

Callers 1

nd6_ioctlFunction · 0.85

Calls 5

mallocFunction · 0.85
defrouter_refFunction · 0.85
defrouter_delreqFunction · 0.85
defrouter_releFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected