Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/if_gif.c
Show First 20 Lines • Show All 917 Lines • ▼ Show 20 Lines | default: | ||||
break; | break; | ||||
} | } | ||||
bad: | bad: | ||||
sx_xunlock(&gif_ioctl_sx); | sx_xunlock(&gif_ioctl_sx); | ||||
return (error); | return (error); | ||||
} | } | ||||
static void | static void | ||||
gif_detach(struct gif_softc *sc) | gif_detach(struct gif_softc *sc, int family) | ||||
{ | { | ||||
sx_assert(&gif_ioctl_sx, SA_XLOCKED); | sx_assert(&gif_ioctl_sx, SA_XLOCKED); | ||||
if (sc->gif_ecookie != NULL) | if (sc->gif_ecookie != NULL) { | ||||
encap_detach(sc->gif_ecookie); | switch (family) { | ||||
#ifdef INET | |||||
case AF_INET: | |||||
ip_encap_detach(sc->gif_ecookie); | |||||
break; | |||||
#endif | |||||
#ifdef INET6 | |||||
case AF_INET6: | |||||
ip6_encap_detach(sc->gif_ecookie); | |||||
break; | |||||
#endif | |||||
} | |||||
} | |||||
sc->gif_ecookie = NULL; | sc->gif_ecookie = NULL; | ||||
} | } | ||||
static int | static int | ||||
gif_attach(struct gif_softc *sc, int af) | gif_attach(struct gif_softc *sc, int af) | ||||
{ | { | ||||
sx_assert(&gif_ioctl_sx, SA_XLOCKED); | sx_assert(&gif_ioctl_sx, SA_XLOCKED); | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | case AF_INET6: | ||||
ip6->ip6_vfc = IPV6_VERSION; | ip6->ip6_vfc = IPV6_VERSION; | ||||
break; | break; | ||||
#endif | #endif | ||||
default: | default: | ||||
return (EAFNOSUPPORT); | return (EAFNOSUPPORT); | ||||
} | } | ||||
if (sc->gif_family != src->sa_family) | if (sc->gif_family != src->sa_family) | ||||
gif_detach(sc); | gif_detach(sc, sc->gif_family); | ||||
if (sc->gif_family == 0 || | if (sc->gif_family == 0 || | ||||
sc->gif_family != src->sa_family) | sc->gif_family != src->sa_family) | ||||
error = gif_attach(sc, src->sa_family); | error = gif_attach(sc, src->sa_family); | ||||
GIF_WLOCK(sc); | GIF_WLOCK(sc); | ||||
if (sc->gif_family != 0) | if (sc->gif_family != 0) | ||||
free(sc->gif_hdr, M_GIF); | free(sc->gif_hdr, M_GIF); | ||||
sc->gif_family = src->sa_family; | sc->gif_family = src->sa_family; | ||||
Show All 21 Lines | gif_delete_tunnel(struct ifnet *ifp) | ||||
if (sc == NULL) | if (sc == NULL) | ||||
return; | return; | ||||
GIF_WLOCK(sc); | GIF_WLOCK(sc); | ||||
family = sc->gif_family; | family = sc->gif_family; | ||||
sc->gif_family = 0; | sc->gif_family = 0; | ||||
GIF_WUNLOCK(sc); | GIF_WUNLOCK(sc); | ||||
if (family != 0) { | if (family != 0) { | ||||
gif_detach(sc); | gif_detach(sc, family); | ||||
free(sc->gif_hdr, M_GIF); | free(sc->gif_hdr, M_GIF); | ||||
} | } | ||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING; | ifp->if_drv_flags &= ~IFF_DRV_RUNNING; | ||||
if_link_state_change(ifp, LINK_STATE_DOWN); | if_link_state_change(ifp, LINK_STATE_DOWN); | ||||
} | } |