Use an tempory struct ifnet *ifp instead of sc->sc_if to access the

ifnet in stf_clone_create.  Also use if_printf() instead of printf().
This commit is contained in:
Brooks Davis 2004-04-19 05:06:27 +00:00
parent f663ded69d
commit 1861b71020
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128417

View file

@ -185,25 +185,27 @@ stf_clone_create(ifc, unit)
int unit;
{
struct stf_softc *sc;
struct ifnet *ifp;
sc = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK | M_ZERO);
if_initname(&sc->sc_if, ifc->ifc_name, unit);
ifp = &sc->sc_if;
if_initname(ifp, ifc->ifc_name, unit);
sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
stf_encapcheck, &in_stf_protosw, sc);
if (sc->encap_cookie == NULL) {
printf("%s: attach failed\n", if_name(&sc->sc_if));
if_printf(ifp, "attach failed\n");
free(sc, M_STF);
return (ENOMEM);
}
sc->sc_if.if_mtu = IPV6_MMTU;
sc->sc_if.if_ioctl = stf_ioctl;
sc->sc_if.if_output = stf_output;
sc->sc_if.if_type = IFT_STF;
sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
if_attach(&sc->sc_if);
bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
ifp->if_mtu = IPV6_MMTU;
ifp->if_ioctl = stf_ioctl;
ifp->if_output = stf_output;
ifp->if_type = IFT_STF;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
if_attach(ifp);
bpfattach(ifp, DLT_NULL, sizeof(u_int));
mtx_lock(&stf_mtx);
LIST_INSERT_HEAD(&stf_softc_list, sc, sc_list);
mtx_unlock(&stf_mtx);