2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* $FreeBSD: src/sys/net/if_gif.c,v 1.4.2.6 2001/07/24 19:10:18 brooks Exp $ */
29 /* $KAME: if_gif.c,v 1.47 2001/05/01 05:28:42 itojun Exp $ */
32 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
33 * All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. Neither the name of the project nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * NOTICE: This file was modified by SPARTA, Inc. in 2006 to introduce
61 * support for mandatory and extensible security protections. This notice
62 * is included in support of clause 2.2 (b) of the Apple Public License,
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/kernel.h>
69 #include <sys/malloc.h>
71 #include <sys/socket.h>
72 #include <sys/sockio.h>
73 #include <sys/errno.h>
75 #include <sys/syslog.h>
76 #include <sys/protosw.h>
77 #include <kern/cpu_number.h>
80 #include <net/if_types.h>
81 #include <net/route.h>
83 #include <net/kpi_protocol.h>
84 #include <net/kpi_interface.h>
86 #include <netinet/in.h>
87 #include <netinet/in_systm.h>
88 #include <netinet/ip.h>
90 #include <netinet/in_var.h>
91 #include <netinet/in_gif.h>
92 #include <netinet/ip_var.h>
96 #include <netinet6/in6_var.h>
97 #include <netinet/ip6.h>
98 #include <netinet6/ip6_var.h>
99 #include <netinet6/in6_gif.h>
100 #include <netinet6/ip6protosw.h>
103 #include <netinet/ip_encap.h>
104 #include <net/dlil.h>
105 #include <net/if_gif.h>
107 #include <net/net_osdep.h>
110 #include <security/mac_framework.h>
113 #define GIFNAME "gif"
114 #define GIFDEV "if_gif"
115 #define GIF_MAXUNIT 0x7fff /* ifp->if_unit is only 15 bits */
118 static MALLOC_DEFINE(M_GIF
, "gif", "Generic Tunnel Interface");
121 TAILQ_HEAD(gifhead
, gif_softc
) gifs
= TAILQ_HEAD_INITIALIZER(gifs
);
124 void gifattach(void);
125 static int gif_encapcheck(const struct mbuf
*, int, int, void*);
126 static errno_t
gif_output(ifnet_t ifp
, mbuf_t m
);
127 static errno_t
gif_input(ifnet_t ifp
, protocol_family_t protocol_family
,
128 mbuf_t m
, char *frame_header
);
129 static errno_t
gif_ioctl(ifnet_t ifp
, u_long cmd
, void *data
);
131 int ngif
= 0; /* number of interfaces */
135 struct protosw in_gif_protosw
=
136 { SOCK_RAW
, 0, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC
|PR_ADDR
,
137 in_gif_input
, 0, 0, 0,
142 0, rip_unlock
, 0, {0, 0}, 0, {0}
146 struct ip6protosw in6_gif_protosw
=
147 { SOCK_RAW
, 0, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC
|PR_ADDR
,
148 in6_gif_input
, 0, 0, 0,
153 0, rip_unlock
, 0, {0, 0}, 0, {0}
158 static if_clone_t gif_cloner
= NULL
;
159 static int gif_clone_create(struct if_clone
*, uint32_t, void *);
160 static int gif_clone_destroy(struct ifnet
*);
161 static void gif_delete_tunnel(struct gif_softc
*);
165 * Theory of operation: initially, one gif interface is created.
166 * Any time a gif interface is configured, if there are no other
167 * unconfigured gif interfaces, a new gif interface is created.
168 * BSD uses the clone mechanism to dynamically create more
171 * We have some extra glue to support DLIL.
174 /* GIF interface module support */
175 static int gif_demux(
178 __unused
char *frame_header
,
179 protocol_family_t
*protocol_family
)
181 /* Only one protocol may be attached to a gif interface. */
182 *protocol_family
= ((struct gif_softc
*)ifnet_softc(ifp
))->gif_proto
;
190 protocol_family_t protocol_family
,
191 __unused
const struct ifnet_demux_desc
*demux_array
,
192 __unused u_int32_t demux_count
)
194 /* Only one protocol may be attached at a time */
195 struct gif_softc
* gif
= ifnet_softc(ifp
);
197 if (gif
->gif_proto
!= 0)
198 printf("gif_add_proto: request add_proto for gif%d\n", ifnet_unit(ifp
));
200 gif
->gif_proto
= protocol_family
;
208 protocol_family_t protocol_family
)
210 if (((struct gif_softc
*)ifnet_softc(ifp
))->gif_proto
== protocol_family
)
211 ((struct gif_softc
*)ifnet_softc(ifp
))->gif_proto
= 0;
216 /* Glue code to attach inet to a gif interface through DLIL */
218 gif_attach_proto_family(
220 protocol_family_t protocol_family
)
222 struct ifnet_attach_proto_param reg
;
225 bzero(®
, sizeof(reg
));
226 reg
.input
= gif_input
;
228 stat
= ifnet_attach_protocol(ifp
, protocol_family
, ®
);
229 if (stat
&& stat
!= EEXIST
) {
230 printf("gif_attach_proto_family can't attach interface fam=%d\n",
239 /* Function to setup the first gif interface */
240 __private_extern__
void
244 struct ifnet_clone_params ifnet_clone_params
;
245 struct if_clone
*ifc
= NULL
;
247 /* Init the list of interfaces */
250 /* Register protocol registration functions */
251 result
= proto_register_plumber(PF_INET
, APPLE_IF_FAM_GIF
,
252 gif_attach_proto_family
, NULL
);
254 printf("proto_register_plumber failed for AF_INET error=%d\n", result
);
256 result
= proto_register_plumber(PF_INET6
, APPLE_IF_FAM_GIF
,
257 gif_attach_proto_family
, NULL
);
259 printf("proto_register_plumber failed for AF_INET6 error=%d\n", result
);
261 ifnet_clone_params
.ifc_name
= "gif";
262 ifnet_clone_params
.ifc_create
= gif_clone_create
;
263 ifnet_clone_params
.ifc_destroy
= gif_clone_destroy
;
265 result
= ifnet_clone_attach(&ifnet_clone_params
, &gif_cloner
);
267 printf("gifattach: ifnet_clone_attach failed %d\n", result
);
269 /* Create first device */
270 ifc
= if_clone_lookup("gif", NULL
);
271 gif_clone_create(ifc
, 0, NULL
);
278 bpf_packet_func callback
)
280 struct gif_softc
*sc
= ifnet_softc(ifp
);
283 sc
->tap_callback
= callback
;
290 gif_clone_create(struct if_clone
*ifc
, uint32_t unit
, __unused
void *params
)
292 struct gif_softc
*sc
= NULL
;
293 struct ifnet_init_params gif_init
;
296 /* Can't create more than GIF_MAXUNIT */
297 if (ngif
>= GIF_MAXUNIT
)
300 sc
= _MALLOC(sizeof(struct gif_softc
), M_DEVBUF
, M_WAITOK
);
302 log(LOG_ERR
, "gif_clone_create: failed to allocate gif%d\n", unit
);
305 bzero(sc
, sizeof(struct gif_softc
));
307 /* use the interface name as the unique id for ifp recycle */
308 snprintf(sc
->gif_ifname
, sizeof(sc
->gif_ifname
), "%s%d",
309 ifc
->ifc_name
, unit
);
311 bzero(&gif_init
, sizeof(gif_init
));
312 gif_init
.uniqueid
= sc
->gif_ifname
;
313 gif_init
.uniqueid_len
= strlen(sc
->gif_ifname
);
314 gif_init
.name
= GIFNAME
;
315 gif_init
.unit
= unit
;
316 gif_init
.type
= IFT_GIF
;
317 gif_init
.family
= IFNET_FAMILY_GIF
;
318 gif_init
.output
= gif_output
;
319 gif_init
.demux
= gif_demux
;
320 gif_init
.add_proto
= gif_add_proto
;
321 gif_init
.del_proto
= gif_del_proto
;
323 gif_init
.ioctl
= gif_ioctl
;
324 gif_init
.set_bpf_tap
= gif_set_bpf_tap
;
326 result
= ifnet_allocate(&gif_init
, &sc
->gif_if
);
328 printf("gif_clone_create, ifnet_allocate failed - %d\n", result
);
333 sc
->encap_cookie4
= sc
->encap_cookie6
= NULL
;
335 sc
->encap_cookie4
= encap_attach_func(AF_INET
, -1,
336 gif_encapcheck
, &in_gif_protosw
, sc
);
337 if (sc
->encap_cookie4
== NULL
) {
338 printf("%s: unable to attach encap4\n", if_name(sc
->gif_if
));
339 ifnet_release(sc
->gif_if
);
345 sc
->encap_cookie6
= encap_attach_func(AF_INET6
, -1,
346 gif_encapcheck
, (struct protosw
*)&in6_gif_protosw
, sc
);
347 if (sc
->encap_cookie6
== NULL
) {
348 if (sc
->encap_cookie4
) {
349 encap_detach(sc
->encap_cookie4
);
350 sc
->encap_cookie4
= NULL
;
352 printf("%s: unable to attach encap6\n", if_name(sc
->gif_if
));
353 ifnet_release(sc
->gif_if
);
359 ifnet_set_mtu(sc
->gif_if
, GIF_MTU
);
360 ifnet_set_flags(sc
->gif_if
, IFF_POINTOPOINT
| IFF_MULTICAST
, 0xffff);
362 /* turn off ingress filter */
363 sc
->gif_if
.if_flags
|= IFF_LINK2
;
365 result
= ifnet_attach(sc
->gif_if
, NULL
);
367 printf("gif_clone_create - ifnet_attach failed - %d\n", result
);
368 ifnet_release(sc
->gif_if
);
369 if (sc
->encap_cookie4
) {
370 encap_detach(sc
->encap_cookie4
);
371 sc
->encap_cookie4
= NULL
;
373 if (sc
->encap_cookie6
) {
374 encap_detach(sc
->encap_cookie6
);
375 sc
->encap_cookie6
= NULL
;
381 mac_ifnet_label_init(&sc
->gif_if
);
383 bpfattach(sc
->gif_if
, DLT_NULL
, sizeof(u_int
));
384 TAILQ_INSERT_TAIL(&gifs
, sc
, gif_link
);
390 gif_clone_destroy(struct ifnet
*ifp
)
392 #if defined(INET) || defined(INET6)
395 struct gif_softc
*sc
= ifp
->if_softc
;
397 TAILQ_REMOVE(&gifs
, sc
, gif_link
);
399 gif_delete_tunnel(sc
);
401 if (sc
->encap_cookie6
!= NULL
) {
402 err
= encap_detach(sc
->encap_cookie6
);
403 KASSERT(err
== 0, ("gif_clone_destroy: Unexpected error detaching encap_cookie6"));
407 if (sc
->encap_cookie4
!= NULL
) {
408 err
= encap_detach(sc
->encap_cookie4
);
409 KASSERT(err
== 0, ("gif_clone_destroy: Unexpected error detaching encap_cookie4"));
412 err
= ifnet_set_flags(ifp
, 0, IFF_UP
);
414 printf("gif_clone_destroy: ifnet_set_flags failed %d\n", err
);
417 err
= ifnet_detach(ifp
);
419 panic("gif_clone_destroy: ifnet_detach(%p) failed %d\n", ifp
, err
);
427 const struct mbuf
*m
,
433 struct gif_softc
*sc
;
435 sc
= (struct gif_softc
*)arg
;
439 if ((ifnet_flags(sc
->gif_if
) & IFF_UP
) == 0)
442 /* no physical address */
443 if (!sc
->gif_psrc
|| !sc
->gif_pdst
)
459 mbuf_copydata((struct mbuf
*)(size_t)m
, 0, sizeof(ip
), &ip
);
464 if (sc
->gif_psrc
->sa_family
!= AF_INET
||
465 sc
->gif_pdst
->sa_family
!= AF_INET
)
467 return gif_encapcheck4(m
, off
, proto
, arg
);
471 if (sc
->gif_psrc
->sa_family
!= AF_INET6
||
472 sc
->gif_pdst
->sa_family
!= AF_INET6
)
474 return gif_encapcheck6(m
, off
, proto
, arg
);
486 struct gif_softc
*sc
= ifnet_softc(ifp
);
490 max_gif_nesting check used to live here. It doesn't anymore
491 because there is no guaruntee that we won't be called
492 concurrently from more than one thread.
495 m
->m_flags
&= ~(M_BCAST
|M_MCAST
);
496 if (!(ifnet_flags(ifp
) & IFF_UP
) ||
497 sc
->gif_psrc
== NULL
|| sc
->gif_pdst
== NULL
) {
498 ifnet_touch_lastchange(ifp
);
499 m_freem(m
); /* free it here not in dlil_output */
504 bpf_tap_out(ifp
, 0, m
, &sc
->gif_proto
, sizeof(sc
->gif_proto
));
506 /* inner AF-specific encapsulation */
508 /* XXX should we check if our outer source is legal? */
510 /* dispatch to output logic based on outer AF */
511 switch (sc
->gif_psrc
->sa_family
) {
514 error
= in_gif_output(ifp
, sc
->gif_proto
, m
, NULL
);
519 error
= in6_gif_output(ifp
, sc
->gif_proto
, m
, NULL
);
529 /* the mbuf was freed either by in_gif_output or in here */
530 ifnet_stat_increment_out(ifp
, 0, 0, 1);
533 ifnet_stat_increment_out(ifp
, 1, m
->m_pkthdr
.len
, 0);
536 error
= EJUSTRETURN
; /* if no error, packet got sent already */
541 * gif_input is the input handler for IP and IPv6 attached to gif
546 protocol_family_t protocol_family
,
548 __unused
char *frame_header
)
550 struct gif_softc
*sc
= ifnet_softc(ifp
);
552 bpf_tap_in(ifp
, 0, m
, &sc
->gif_proto
, sizeof(sc
->gif_proto
));
555 * Put the packet to the network layer input queue according to the
556 * specified address family.
557 * Note: older versions of gif_input directly called network layer
558 * input functions, e.g. ip6_input, here. We changed the policy to
559 * prevent too many recursive calls of such input functions, which
560 * might cause kernel panic. But the change may introduce another
561 * problem; if the input queue is full, packets are discarded.
562 * We believed it rarely occurs and changed the policy. If we find
563 * it occurs more times than we thought, we may change the policy
566 if (proto_input(protocol_family
, m
) != 0) {
567 ifnet_stat_increment_in(ifp
, 0, 0, 1);
570 ifnet_stat_increment_in(ifp
, 1, m
->m_pkthdr
.len
, 0);
575 /* XXX how should we handle IPv6 scope on SIOC[GS]IFPHYADDR? */
582 struct gif_softc
*sc
= ifnet_softc(ifp
);
583 struct ifreq
*ifr
= (struct ifreq
*)data
;
585 struct sockaddr
*dst
= NULL
, *src
= NULL
;
588 struct gif_softc
*sc2
;
601 #ifdef SIOCSIFMTU /* xxx */
609 if (mtu
< GIF_MTU_MIN
|| mtu
> GIF_MTU_MAX
) {
612 ifnet_set_mtu(ifp
, mtu
);
615 #endif /* SIOCSIFMTU */
619 case SIOCSIFPHYADDR_IN6_32
:
620 case SIOCSIFPHYADDR_IN6_64
:
622 case SIOCSLIFPHYADDR
:
626 src
= (struct sockaddr
*)
627 &(((struct in_aliasreq
*)data
)->ifra_addr
);
628 dst
= (struct sockaddr
*)
629 &(((struct in_aliasreq
*)data
)->ifra_dstaddr
);
633 case SIOCSIFPHYADDR_IN6_32
: {
634 struct in6_aliasreq_32
*ifra_32
=
635 (struct in6_aliasreq_32
*)data
;
637 src
= (struct sockaddr
*)&ifra_32
->ifra_addr
;
638 dst
= (struct sockaddr
*)&ifra_32
->ifra_dstaddr
;
642 case SIOCSIFPHYADDR_IN6_64
: {
643 struct in6_aliasreq_64
*ifra_64
=
644 (struct in6_aliasreq_64
*)data
;
646 src
= (struct sockaddr
*)&ifra_64
->ifra_addr
;
647 dst
= (struct sockaddr
*)&ifra_64
->ifra_dstaddr
;
651 case SIOCSLIFPHYADDR
:
652 src
= (struct sockaddr
*)
653 &(((struct if_laddrreq
*)data
)->addr
);
654 dst
= (struct sockaddr
*)
655 &(((struct if_laddrreq
*)data
)->dstaddr
);
658 /* sa_family must be equal */
659 if (src
->sa_family
!= dst
->sa_family
)
662 /* validate sa_len */
663 switch (src
->sa_family
) {
666 if (src
->sa_len
!= sizeof(struct sockaddr_in
))
672 if (src
->sa_len
!= sizeof(struct sockaddr_in6
))
679 switch (dst
->sa_family
) {
682 if (dst
->sa_len
!= sizeof(struct sockaddr_in
))
688 if (dst
->sa_len
!= sizeof(struct sockaddr_in6
))
696 /* check sa_family looks sane for the cmd */
699 if (src
->sa_family
== AF_INET
)
703 case SIOCSIFPHYADDR_IN6_32
:
704 case SIOCSIFPHYADDR_IN6_64
:
705 if (src
->sa_family
== AF_INET6
)
709 case SIOCSLIFPHYADDR
:
710 /* checks done in the above */
714 ifnet_head_lock_shared();
715 TAILQ_FOREACH(ifp2
, &ifnet_head
, if_link
) {
716 if (strcmp(ifnet_name(ifp2
), GIFNAME
) != 0)
718 sc2
= ifnet_softc(ifp2
);
721 if (!sc2
->gif_pdst
|| !sc2
->gif_psrc
)
723 if (sc2
->gif_pdst
->sa_family
!= dst
->sa_family
||
724 sc2
->gif_pdst
->sa_len
!= dst
->sa_len
||
725 sc2
->gif_psrc
->sa_family
!= src
->sa_family
||
726 sc2
->gif_psrc
->sa_len
!= src
->sa_len
)
729 /* can't configure same pair of address onto two gifs */
730 if (bcmp(sc2
->gif_pdst
, dst
, dst
->sa_len
) == 0 &&
731 bcmp(sc2
->gif_psrc
, src
, src
->sa_len
) == 0) {
732 error
= EADDRNOTAVAIL
;
738 /* can't configure multiple multi-dest interfaces */
739 #define multidest(x) \
740 (((struct sockaddr_in *)(void *)(x))->sin_addr.s_addr == INADDR_ANY)
742 #define multidest6(x) \
743 (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)(void *)(x))->sin6_addr))
745 if (dst
->sa_family
== AF_INET
&&
746 multidest(dst
) && multidest(sc2
->gif_pdst
)) {
747 error
= EADDRNOTAVAIL
;
752 if (dst
->sa_family
== AF_INET6
&&
753 multidest6(dst
) && multidest6(sc2
->gif_pdst
)) {
754 error
= EADDRNOTAVAIL
;
763 FREE((caddr_t
)sc
->gif_psrc
, M_IFADDR
);
764 sa
= (struct sockaddr
*)_MALLOC(src
->sa_len
, M_IFADDR
, M_WAITOK
);
767 bcopy((caddr_t
)src
, (caddr_t
)sa
, src
->sa_len
);
771 FREE((caddr_t
)sc
->gif_pdst
, M_IFADDR
);
772 sa
= (struct sockaddr
*)_MALLOC(dst
->sa_len
, M_IFADDR
, M_WAITOK
);
775 bcopy((caddr_t
)dst
, (caddr_t
)sa
, dst
->sa_len
);
778 ifnet_set_flags(ifp
, IFF_RUNNING
| IFF_UP
, IFF_RUNNING
| IFF_UP
);
783 #ifdef SIOCDIFPHYADDR
786 FREE((caddr_t
)sc
->gif_psrc
, M_IFADDR
);
790 FREE((caddr_t
)sc
->gif_pdst
, M_IFADDR
);
793 /* change the IFF_{UP, RUNNING} flag as well? */
797 case SIOCGIFPSRCADDR
:
799 case SIOCGIFPSRCADDR_IN6
:
801 if (sc
->gif_psrc
== NULL
) {
802 error
= EADDRNOTAVAIL
;
808 case SIOCGIFPSRCADDR
:
809 dst
= &ifr
->ifr_addr
;
810 size
= sizeof(ifr
->ifr_addr
);
814 case SIOCGIFPSRCADDR_IN6
:
815 dst
= (struct sockaddr
*)
816 &(((struct in6_ifreq
*)data
)->ifr_addr
);
817 size
= sizeof(((struct in6_ifreq
*)data
)->ifr_addr
);
821 error
= EADDRNOTAVAIL
;
824 if (src
->sa_len
> size
)
826 bcopy((caddr_t
)src
, (caddr_t
)dst
, src
->sa_len
);
829 case SIOCGIFPDSTADDR
:
831 case SIOCGIFPDSTADDR_IN6
:
833 if (sc
->gif_pdst
== NULL
) {
834 error
= EADDRNOTAVAIL
;
840 case SIOCGIFPDSTADDR
:
841 dst
= &ifr
->ifr_addr
;
842 size
= sizeof(ifr
->ifr_addr
);
846 case SIOCGIFPDSTADDR_IN6
:
847 dst
= (struct sockaddr
*)
848 &(((struct in6_ifreq
*)data
)->ifr_addr
);
849 size
= sizeof(((struct in6_ifreq
*)data
)->ifr_addr
);
853 error
= EADDRNOTAVAIL
;
856 if (src
->sa_len
> size
)
858 bcopy((caddr_t
)src
, (caddr_t
)dst
, src
->sa_len
);
861 case SIOCGLIFPHYADDR
:
862 if (sc
->gif_psrc
== NULL
|| sc
->gif_pdst
== NULL
) {
863 error
= EADDRNOTAVAIL
;
869 dst
= (struct sockaddr
*)
870 &(((struct if_laddrreq
*)data
)->addr
);
871 size
= sizeof(((struct if_laddrreq
*)data
)->addr
);
872 if (src
->sa_len
> size
)
874 bcopy((caddr_t
)src
, (caddr_t
)dst
, src
->sa_len
);
878 dst
= (struct sockaddr
*)
879 &(((struct if_laddrreq
*)data
)->dstaddr
);
880 size
= sizeof(((struct if_laddrreq
*)data
)->dstaddr
);
881 if (src
->sa_len
> size
)
883 bcopy((caddr_t
)src
, (caddr_t
)dst
, src
->sa_len
);
887 /* if_ioctl() takes care of it */
898 /* This function is not used in our stack */
900 gif_delete_tunnel(sc
)
901 struct gif_softc
*sc
;
903 /* XXX: NetBSD protects this function with splsoftnet() */
906 FREE((caddr_t
)sc
->gif_psrc
, M_IFADDR
);
910 FREE((caddr_t
)sc
->gif_pdst
, M_IFADDR
);
913 /* change the IFF_UP flag as well? */