2 /* $KAME: if_gif.c,v 1.87 2001/10/19 08:50:27 itojun Exp $ */
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "opt_inet6.h"
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/malloc.h>
41 #include <sys/module.h>
42 #include <sys/socket.h>
43 #include <sys/sockio.h>
44 #include <sys/errno.h>
46 #include <sys/sysctl.h>
47 #include <sys/syslog.h>
50 #include <sys/protosw.h>
52 #include <machine/cpu.h>
55 #include <net/if_clone.h>
56 #include <net/if_types.h>
57 #include <net/netisr.h>
58 #include <net/route.h>
62 #include <netinet/in.h>
63 #include <netinet/in_systm.h>
64 #include <netinet/ip.h>
66 #include <netinet/in_var.h>
67 #include <netinet/in_gif.h>
68 #include <netinet/ip_var.h>
73 #include <netinet/in.h>
75 #include <netinet6/in6_var.h>
76 #include <netinet/ip6.h>
77 #include <netinet6/ip6_var.h>
78 #include <netinet6/scope6_var.h>
79 #include <netinet6/in6_gif.h>
80 #include <netinet6/ip6protosw.h>
83 #include <netinet/ip_encap.h>
84 #include <net/ethernet.h>
85 #include <net/if_bridgevar.h>
86 #include <net/if_gif.h>
88 #include <security/mac/mac_framework.h>
93 * gif_mtx protects the global gif_softc_list.
95 static struct mtx gif_mtx;
96 static MALLOC_DEFINE(M_GIF, "gif", "Generic Tunnel Interface");
98 static VNET_DEFINE(LIST_HEAD(, gif_softc), gif_softc_list);
100 #define V_gif_softc_list VNET(gif_softc_list)
103 VNET_DEFINE(int, ip_gif_ttl) = GIF_TTL;
104 #define V_ip_gif_ttl VNET(ip_gif_ttl)
107 VNET_DEFINE(int, ip6_gif_hlim) = GIF_HLIM;
108 #define V_ip6_gif_hlim VNET(ip6_gif_hlim)
111 void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, int af);
112 void (*ng_gif_input_orphan_p)(struct ifnet *ifp, struct mbuf *m, int af);
113 void (*ng_gif_attach_p)(struct ifnet *ifp);
114 void (*ng_gif_detach_p)(struct ifnet *ifp);
116 static void gif_start(struct ifnet *);
117 static int gif_clone_create(struct if_clone *, int, caddr_t);
118 static void gif_clone_destroy(struct ifnet *);
120 IFC_SIMPLE_DECLARE(gif, 0);
122 static int gifmodevent(module_t, int, void *);
124 SYSCTL_DECL(_net_link);
125 SYSCTL_NODE(_net_link, IFT_GIF, gif, CTLFLAG_RW, 0,
126 "Generic Tunnel Interface");
129 * This macro controls the default upper limitation on nesting of gif tunnels.
130 * Since, setting a large value to this macro with a careless configuration
131 * may introduce system crash, we don't allow any nestings by default.
132 * If you need to configure nested gif tunnels, you can define this macro
133 * in your kernel configuration file. However, if you do so, please be
134 * careful to configure the tunnels so that it won't make a loop.
136 #define MAX_GIF_NEST 1
139 static VNET_DEFINE(int, max_gif_nesting) = MAX_GIF_NEST;
140 #define V_max_gif_nesting VNET(max_gif_nesting)
142 SYSCTL_VNET_INT(_net_link_gif, OID_AUTO, max_nesting, CTLFLAG_RW,
143 &VNET_NAME(max_gif_nesting), 0, "Max nested tunnels");
146 SYSCTL_DECL(_net_inet6_ip6);
147 SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, gifhlim, CTLFLAG_RW,
148 &VNET_NAME(ip6_gif_hlim), 0, "");
152 * By default, we disallow creation of multiple tunnels between the same
153 * pair of addresses. Some applications require this functionality so
154 * we allow control over this check here.
157 static VNET_DEFINE(int, parallel_tunnels) = 1;
159 static VNET_DEFINE(int, parallel_tunnels) = 0;
161 #define V_parallel_tunnels VNET(parallel_tunnels)
163 SYSCTL_VNET_INT(_net_link_gif, OID_AUTO, parallel_tunnels, CTLFLAG_RW,
164 &VNET_NAME(parallel_tunnels), 0, "Allow parallel tunnels?");
166 /* copy from src/sys/net/if_ethersubr.c */
167 static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
168 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
169 #ifndef ETHER_IS_BROADCAST
170 #define ETHER_IS_BROADCAST(addr) \
171 (bcmp(etherbroadcastaddr, (addr), ETHER_ADDR_LEN) == 0)
175 gif_clone_create(ifc, unit, params)
176 struct if_clone *ifc;
180 struct gif_softc *sc;
182 sc = malloc(sizeof(struct gif_softc), M_GIF, M_WAITOK | M_ZERO);
183 sc->gif_fibnum = curthread->td_proc->p_fibnum;
184 GIF2IFP(sc) = if_alloc(IFT_GIF);
185 if (GIF2IFP(sc) == NULL) {
192 GIF2IFP(sc)->if_softc = sc;
193 if_initname(GIF2IFP(sc), ifc->ifc_name, unit);
195 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
196 sc->gif_options = GIF_ACCEPT_REVETHIP;
198 GIF2IFP(sc)->if_addrlen = 0;
199 GIF2IFP(sc)->if_mtu = GIF_MTU;
200 GIF2IFP(sc)->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
202 /* turn off ingress filter */
203 GIF2IFP(sc)->if_flags |= IFF_LINK2;
205 GIF2IFP(sc)->if_ioctl = gif_ioctl;
206 GIF2IFP(sc)->if_start = gif_start;
207 GIF2IFP(sc)->if_output = gif_output;
208 GIF2IFP(sc)->if_snd.ifq_maxlen = IFQ_MAXLEN;
209 if_attach(GIF2IFP(sc));
210 bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t));
211 if (ng_gif_attach_p != NULL)
212 (*ng_gif_attach_p)(GIF2IFP(sc));
215 LIST_INSERT_HEAD(&V_gif_softc_list, sc, gif_list);
216 mtx_unlock(&gif_mtx);
222 gif_clone_destroy(ifp)
225 #if defined(INET) || defined(INET6)
228 struct gif_softc *sc = ifp->if_softc;
231 LIST_REMOVE(sc, gif_list);
232 mtx_unlock(&gif_mtx);
234 gif_delete_tunnel(ifp);
236 if (sc->encap_cookie6 != NULL) {
237 err = encap_detach(sc->encap_cookie6);
238 KASSERT(err == 0, ("Unexpected error detaching encap_cookie6"));
242 if (sc->encap_cookie4 != NULL) {
243 err = encap_detach(sc->encap_cookie4);
244 KASSERT(err == 0, ("Unexpected error detaching encap_cookie4"));
248 if (ng_gif_detach_p != NULL)
249 (*ng_gif_detach_p)(ifp);
254 GIF_LOCK_DESTROY(sc);
260 vnet_gif_init(const void *unused __unused)
263 LIST_INIT(&V_gif_softc_list);
265 VNET_SYSINIT(vnet_gif_init, SI_SUB_PSEUDO, SI_ORDER_MIDDLE, vnet_gif_init,
269 gifmodevent(mod, type, data)
277 mtx_init(&gif_mtx, "gif_mtx", NULL, MTX_DEF);
278 if_clone_attach(&gif_cloner);
282 if_clone_detach(&gif_cloner);
283 mtx_destroy(&gif_mtx);
291 static moduledata_t gif_mod = {
297 DECLARE_MODULE(if_gif, gif_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
298 MODULE_VERSION(if_gif, 1);
301 gif_encapcheck(m, off, proto, arg)
302 const struct mbuf *m;
308 struct gif_softc *sc;
310 sc = (struct gif_softc *)arg;
314 if ((GIF2IFP(sc)->if_flags & IFF_UP) == 0)
317 /* no physical address */
318 if (!sc->gif_psrc || !sc->gif_pdst)
330 case IPPROTO_ETHERIP:
337 /* Bail on short packets */
338 if (m->m_pkthdr.len < sizeof(ip))
341 m_copydata(m, 0, sizeof(ip), (caddr_t)&ip);
346 if (sc->gif_psrc->sa_family != AF_INET ||
347 sc->gif_pdst->sa_family != AF_INET)
349 return gif_encapcheck4(m, off, proto, arg);
353 if (m->m_pkthdr.len < sizeof(struct ip6_hdr))
355 if (sc->gif_psrc->sa_family != AF_INET6 ||
356 sc->gif_pdst->sa_family != AF_INET6)
358 return gif_encapcheck6(m, off, proto, arg);
366 gif_start(struct ifnet *ifp)
368 struct gif_softc *sc;
373 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
375 IFQ_DEQUEUE(&ifp->if_snd, m);
379 gif_output(ifp, m, sc->gif_pdst, NULL);
382 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
388 gif_output(ifp, m, dst, ro)
391 struct sockaddr *dst;
394 struct gif_softc *sc = ifp->if_softc;
401 error = mac_ifnet_check_transmit(ifp, m);
409 * gif may cause infinite recursion calls when misconfigured.
410 * We'll prevent this by detecting loops.
412 * High nesting level may cause stack exhaustion.
413 * We'll prevent this by introducing upper limit.
416 mtag = m_tag_locate(m, MTAG_GIF, MTAG_GIF_CALLED, NULL);
417 while (mtag != NULL) {
418 if (*(struct ifnet **)(mtag + 1) == ifp) {
420 "gif_output: loop detected on %s\n",
421 (*(struct ifnet **)(mtag + 1))->if_xname);
423 error = EIO; /* is there better errno? */
426 mtag = m_tag_locate(m, MTAG_GIF, MTAG_GIF_CALLED, mtag);
429 if (gif_called > V_max_gif_nesting) {
431 "gif_output: recursively called too many times(%d)\n",
434 error = EIO; /* is there better errno? */
437 mtag = m_tag_alloc(MTAG_GIF, MTAG_GIF_CALLED, sizeof(struct ifnet *),
444 *(struct ifnet **)(mtag + 1) = ifp;
445 m_tag_prepend(m, mtag);
447 m->m_flags &= ~(M_BCAST|M_MCAST);
451 if (!(ifp->if_flags & IFF_UP) ||
452 sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
459 /* BPF writes need to be handled specially. */
460 if (dst->sa_family == AF_UNSPEC) {
461 bcopy(dst->sa_data, &af, sizeof(af));
466 BPF_MTAP2(ifp, &af, sizeof(af), m);
468 ifp->if_obytes += m->m_pkthdr.len;
470 /* override to IPPROTO_ETHERIP for bridged traffic */
474 M_SETFIB(m, sc->gif_fibnum);
475 /* inner AF-specific encapsulation */
477 /* XXX should we check if our outer source is legal? */
479 /* dispatch to output logic based on outer AF */
480 switch (sc->gif_psrc->sa_family) {
483 error = in_gif_output(ifp, af, m);
488 error = in6_gif_output(ifp, af, m);
504 gif_input(m, af, ifp)
510 struct gif_softc *sc = ifp->if_softc;
511 struct etherip_header *eip;
512 struct ether_header *eh;
513 struct ifnet *oldifp;
521 m->m_pkthdr.rcvif = ifp;
524 mac_ifnet_create_mbuf(ifp, m);
527 if (bpf_peers_present(ifp->if_bpf)) {
529 bpf_mtap2(ifp->if_bpf, &af1, sizeof(af1), m);
532 if (ng_gif_input_p != NULL) {
533 (*ng_gif_input_p)(ifp, &m, af);
539 * Put the packet to the network layer input queue according to the
540 * specified address family.
541 * Note: older versions of gif_input directly called network layer
542 * input functions, e.g. ip6_input, here. We changed the policy to
543 * prevent too many recursive calls of such input functions, which
544 * might cause kernel panic. But the change may introduce another
545 * problem; if the input queue is full, packets are discarded.
546 * The kernel stack overflow really happened, and we believed
547 * queue-full rarely occurs, so we changed the policy.
561 n = sizeof(struct etherip_header) + sizeof(struct ether_header);
570 eip = mtod(m, struct etherip_header *);
572 * GIF_ACCEPT_REVETHIP (enabled by default) intentionally
573 * accepts an EtherIP packet with revered version field in
574 * the header. This is a knob for backward compatibility
575 * with FreeBSD 7.2R or prior.
577 if (sc->gif_options & GIF_ACCEPT_REVETHIP) {
578 if (eip->eip_resvl != ETHERIP_VERSION
579 && eip->eip_ver != ETHERIP_VERSION) {
580 /* discard unknown versions */
585 if (eip->eip_ver != ETHERIP_VERSION) {
586 /* discard unknown versions */
591 m_adj(m, sizeof(struct etherip_header));
593 m->m_flags &= ~(M_BCAST|M_MCAST);
594 m->m_pkthdr.rcvif = ifp;
596 if (ifp->if_bridge) {
598 eh = mtod(m, struct ether_header *);
599 if (ETHER_IS_MULTICAST(eh->ether_dhost)) {
600 if (ETHER_IS_BROADCAST(eh->ether_dhost))
601 m->m_flags |= M_BCAST;
603 m->m_flags |= M_MCAST;
606 BRIDGE_INPUT(ifp, m);
608 if (m != NULL && ifp != oldifp) {
610 * The bridge gave us back itself or one of the
611 * members for which the frame is addressed.
622 if (ng_gif_input_orphan_p != NULL)
623 (*ng_gif_input_orphan_p)(ifp, m, af);
630 ifp->if_ibytes += m->m_pkthdr.len;
631 netisr_dispatch(isr, m);
634 /* XXX how should we handle IPv6 scope on SIOC[GS]IFPHYADDR? */
636 gif_ioctl(ifp, cmd, data)
641 struct gif_softc *sc = ifp->if_softc;
642 struct ifreq *ifr = (struct ifreq*)data;
645 struct sockaddr *dst, *src;
646 #ifdef SIOCSIFMTU /* xxx */
652 ifp->if_flags |= IFF_UP;
662 #ifdef SIOCSIFMTU /* xxx */
668 if (mtu < GIF_MTU_MIN || mtu > GIF_MTU_MAX)
672 #endif /* SIOCSIFMTU */
678 case SIOCSIFPHYADDR_IN6:
680 case SIOCSLIFPHYADDR:
684 src = (struct sockaddr *)
685 &(((struct in_aliasreq *)data)->ifra_addr);
686 dst = (struct sockaddr *)
687 &(((struct in_aliasreq *)data)->ifra_dstaddr);
691 case SIOCSIFPHYADDR_IN6:
692 src = (struct sockaddr *)
693 &(((struct in6_aliasreq *)data)->ifra_addr);
694 dst = (struct sockaddr *)
695 &(((struct in6_aliasreq *)data)->ifra_dstaddr);
698 case SIOCSLIFPHYADDR:
699 src = (struct sockaddr *)
700 &(((struct if_laddrreq *)data)->addr);
701 dst = (struct sockaddr *)
702 &(((struct if_laddrreq *)data)->dstaddr);
708 /* sa_family must be equal */
709 if (src->sa_family != dst->sa_family)
712 /* validate sa_len */
713 switch (src->sa_family) {
716 if (src->sa_len != sizeof(struct sockaddr_in))
722 if (src->sa_len != sizeof(struct sockaddr_in6))
729 switch (dst->sa_family) {
732 if (dst->sa_len != sizeof(struct sockaddr_in))
738 if (dst->sa_len != sizeof(struct sockaddr_in6))
746 /* check sa_family looks sane for the cmd */
749 if (src->sa_family == AF_INET)
753 case SIOCSIFPHYADDR_IN6:
754 if (src->sa_family == AF_INET6)
758 case SIOCSLIFPHYADDR:
759 /* checks done in the above */
763 error = gif_set_tunnel(GIF2IFP(sc), src, dst);
766 #ifdef SIOCDIFPHYADDR
768 gif_delete_tunnel(GIF2IFP(sc));
772 case SIOCGIFPSRCADDR:
774 case SIOCGIFPSRCADDR_IN6:
776 if (sc->gif_psrc == NULL) {
777 error = EADDRNOTAVAIL;
783 case SIOCGIFPSRCADDR:
784 dst = &ifr->ifr_addr;
785 size = sizeof(ifr->ifr_addr);
789 case SIOCGIFPSRCADDR_IN6:
790 dst = (struct sockaddr *)
791 &(((struct in6_ifreq *)data)->ifr_addr);
792 size = sizeof(((struct in6_ifreq *)data)->ifr_addr);
796 error = EADDRNOTAVAIL;
799 if (src->sa_len > size)
801 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
803 if (dst->sa_family == AF_INET6) {
804 error = sa6_recoverscope((struct sockaddr_in6 *)dst);
811 case SIOCGIFPDSTADDR:
813 case SIOCGIFPDSTADDR_IN6:
815 if (sc->gif_pdst == NULL) {
816 error = EADDRNOTAVAIL;
822 case SIOCGIFPDSTADDR:
823 dst = &ifr->ifr_addr;
824 size = sizeof(ifr->ifr_addr);
828 case SIOCGIFPDSTADDR_IN6:
829 dst = (struct sockaddr *)
830 &(((struct in6_ifreq *)data)->ifr_addr);
831 size = sizeof(((struct in6_ifreq *)data)->ifr_addr);
835 error = EADDRNOTAVAIL;
838 if (src->sa_len > size)
840 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
842 if (dst->sa_family == AF_INET6) {
843 error = sa6_recoverscope((struct sockaddr_in6 *)dst);
850 case SIOCGLIFPHYADDR:
851 if (sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
852 error = EADDRNOTAVAIL;
858 dst = (struct sockaddr *)
859 &(((struct if_laddrreq *)data)->addr);
860 size = sizeof(((struct if_laddrreq *)data)->addr);
861 if (src->sa_len > size)
863 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
867 dst = (struct sockaddr *)
868 &(((struct if_laddrreq *)data)->dstaddr);
869 size = sizeof(((struct if_laddrreq *)data)->dstaddr);
870 if (src->sa_len > size)
872 bcopy((caddr_t)src, (caddr_t)dst, src->sa_len);
876 /* if_ioctl() takes care of it */
880 options = sc->gif_options;
881 error = copyout(&options, ifr->ifr_data,
886 if ((error = priv_check(curthread, PRIV_NET_GIF)) != 0)
888 error = copyin(ifr->ifr_data, &options, sizeof(options));
891 if (options & ~GIF_OPTMASK)
894 sc->gif_options = options;
906 * XXXRW: There's a general event-ordering issue here: the code to check
907 * if a given tunnel is already present happens before we perform a
908 * potentially blocking setup of the tunnel. This code needs to be
909 * re-ordered so that the check and replacement can be atomic using
913 gif_set_tunnel(ifp, src, dst)
915 struct sockaddr *src;
916 struct sockaddr *dst;
918 struct gif_softc *sc = ifp->if_softc;
919 struct gif_softc *sc2;
920 struct sockaddr *osrc, *odst, *sa;
924 LIST_FOREACH(sc2, &V_gif_softc_list, gif_list) {
927 if (!sc2->gif_pdst || !sc2->gif_psrc)
929 if (sc2->gif_pdst->sa_family != dst->sa_family ||
930 sc2->gif_pdst->sa_len != dst->sa_len ||
931 sc2->gif_psrc->sa_family != src->sa_family ||
932 sc2->gif_psrc->sa_len != src->sa_len)
936 * Disallow parallel tunnels unless instructed
939 if (!V_parallel_tunnels &&
940 bcmp(sc2->gif_pdst, dst, dst->sa_len) == 0 &&
941 bcmp(sc2->gif_psrc, src, src->sa_len) == 0) {
942 error = EADDRNOTAVAIL;
943 mtx_unlock(&gif_mtx);
947 /* XXX both end must be valid? (I mean, not 0.0.0.0) */
949 mtx_unlock(&gif_mtx);
951 /* XXX we can detach from both, but be polite just in case */
953 switch (sc->gif_psrc->sa_family) {
956 (void)in_gif_detach(sc);
961 (void)in6_gif_detach(sc);
967 sa = (struct sockaddr *)malloc(src->sa_len, M_IFADDR, M_WAITOK);
968 bcopy((caddr_t)src, (caddr_t)sa, src->sa_len);
972 sa = (struct sockaddr *)malloc(dst->sa_len, M_IFADDR, M_WAITOK);
973 bcopy((caddr_t)dst, (caddr_t)sa, dst->sa_len);
976 switch (sc->gif_psrc->sa_family) {
979 error = in_gif_attach(sc);
985 * Check validity of the scope zone ID of the addresses, and
986 * convert it into the kernel internal form if necessary.
988 error = sa6_embedscope((struct sockaddr_in6 *)sc->gif_psrc, 0);
991 error = sa6_embedscope((struct sockaddr_in6 *)sc->gif_pdst, 0);
994 error = in6_gif_attach(sc);
1000 free((caddr_t)sc->gif_psrc, M_IFADDR);
1001 free((caddr_t)sc->gif_pdst, M_IFADDR);
1002 sc->gif_psrc = osrc;
1003 sc->gif_pdst = odst;
1008 free((caddr_t)osrc, M_IFADDR);
1010 free((caddr_t)odst, M_IFADDR);
1013 if (sc->gif_psrc && sc->gif_pdst)
1014 ifp->if_drv_flags |= IFF_DRV_RUNNING;
1016 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1022 gif_delete_tunnel(ifp)
1025 struct gif_softc *sc = ifp->if_softc;
1028 free((caddr_t)sc->gif_psrc, M_IFADDR);
1029 sc->gif_psrc = NULL;
1032 free((caddr_t)sc->gif_pdst, M_IFADDR);
1033 sc->gif_pdst = NULL;
1035 /* it is safe to detach from both */
1037 (void)in_gif_detach(sc);
1040 (void)in6_gif_detach(sc);
1042 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;