]> git.saurik.com Git - apple/xnu.git/blob - bsd/net/ether_if_module.c
35acf10648f3c8ac2b89e3d6f7db564146d6465d
[apple/xnu.git] / bsd / net / ether_if_module.c
1 /*
2 * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (c) 1982, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 */
61
62 #include <sys/param.h>
63 #include <sys/systm.h>
64 #include <sys/kernel.h>
65 #include <sys/malloc.h>
66 #include <sys/mbuf.h>
67 #include <sys/socket.h>
68 #include <sys/sockio.h>
69 #include <sys/sysctl.h>
70
71 #include <pexpert/pexpert.h>
72
73 #define etherbroadcastaddr fugly
74 #include <net/if.h>
75 #include <net/route.h>
76 #include <net/if_llc.h>
77 #include <net/if_dl.h>
78 #include <net/if_types.h>
79 #include <net/if_ether.h>
80 #include <net/if_gif.h>
81 #include <netinet/if_ether.h>
82 #include <netinet/in.h> /* For M_LOOP */
83 #include <net/kpi_interface.h>
84 #include <net/kpi_protocol.h>
85 #undef etherbroadcastaddr
86
87 /*
88 #if INET
89 #include <netinet/in.h>
90 #include <netinet/in_var.h>
91 *
92 #include <netinet/in_systm.h>
93 #include <netinet/ip.h>
94 #endif
95 */
96 #include <net/ether_if_module.h>
97 #include <sys/socketvar.h>
98 #include <net/if_vlan_var.h>
99 #if BOND
100 #include <net/if_bond_internal.h>
101 #endif /* BOND */
102 #if IF_BRIDGE
103 #include <net/if_bridgevar.h>
104 #endif /* IF_BRIDGE */
105 #if IF_FAKE
106 #include <net/if_fake_var.h>
107 #endif /* IF_FAKE */
108
109 #include <net/dlil.h>
110
111 SYSCTL_DECL(_net_link);
112 SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW | CTLFLAG_LOCKED, 0,
113 "Ethernet");
114
115 struct en_desc {
116 u_int16_t type; /* Type of protocol stored in data */
117 u_int32_t protocol_family; /* Protocol family */
118 u_int32_t data[2]; /* Protocol data */
119 };
120
121 /* descriptors are allocated in blocks of ETHER_DESC_BLK_SIZE */
122 #if CONFIG_EMBEDDED
123 #define ETHER_DESC_BLK_SIZE (2) /* IP, ARP */
124 #else
125 #define ETHER_DESC_BLK_SIZE (10)
126 #endif
127
128 /*
129 * Header for the demux list, hangs off of IFP at if_family_cookie
130 */
131 struct ether_desc_blk_str {
132 u_int32_t n_max_used;
133 u_int32_t n_count;
134 u_int32_t n_used;
135 struct en_desc block_ptr[1];
136 };
137
138 /* Size of the above struct before the array of struct en_desc */
139 #define ETHER_DESC_HEADER_SIZE \
140 ((size_t) offsetof(struct ether_desc_blk_str, block_ptr))
141
142 __private_extern__ u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
143 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
144
145 /*
146 * Release all descriptor entries owned by this protocol (there may be several).
147 * Setting the type to 0 releases the entry. Eventually we should compact-out
148 * the unused entries.
149 */
150 int
151 ether_del_proto(ifnet_t ifp, protocol_family_t protocol_family)
152 {
153 struct ether_desc_blk_str *desc_blk =
154 (struct ether_desc_blk_str *)ifp->if_family_cookie;
155 u_int32_t current = 0;
156 int found = 0;
157
158 if (desc_blk == NULL) {
159 return 0;
160 }
161
162 for (current = desc_blk->n_max_used; current > 0; current--) {
163 if (desc_blk->block_ptr[current - 1].protocol_family ==
164 protocol_family) {
165 found = 1;
166 desc_blk->block_ptr[current - 1].type = 0;
167 desc_blk->n_used--;
168 }
169 }
170
171 if (desc_blk->n_used == 0) {
172 FREE(ifp->if_family_cookie, M_IFADDR);
173 ifp->if_family_cookie = 0;
174 } else {
175 /* Decrement n_max_used */
176 for (; desc_blk->n_max_used > 0 &&
177 desc_blk->block_ptr[desc_blk->n_max_used - 1].type == 0;
178 desc_blk->n_max_used--) {
179 ;
180 }
181 }
182
183 return 0;
184 }
185
186 static int
187 ether_add_proto_internal(struct ifnet *ifp, protocol_family_t protocol,
188 const struct ifnet_demux_desc *demux)
189 {
190 struct en_desc *ed;
191 struct ether_desc_blk_str *desc_blk =
192 (struct ether_desc_blk_str *)ifp->if_family_cookie;
193 u_int32_t i;
194
195 switch (demux->type) {
196 /* These types are supported */
197 /* Top three are preferred */
198 case DLIL_DESC_ETYPE2:
199 if (demux->datalen != 2) {
200 return EINVAL;
201 }
202 break;
203
204 case DLIL_DESC_SAP:
205 if (demux->datalen != 3) {
206 return EINVAL;
207 }
208 break;
209
210 case DLIL_DESC_SNAP:
211 if (demux->datalen != 5) {
212 return EINVAL;
213 }
214 break;
215
216 default:
217 return ENOTSUP;
218 }
219
220 /* Verify a matching descriptor does not exist */
221 if (desc_blk != NULL) {
222 switch (demux->type) {
223 case DLIL_DESC_ETYPE2:
224 for (i = 0; i < desc_blk->n_max_used; i++) {
225 if (desc_blk->block_ptr[i].type ==
226 DLIL_DESC_ETYPE2 &&
227 desc_blk->block_ptr[i].data[0] ==
228 *(u_int16_t*)demux->data) {
229 return EADDRINUSE;
230 }
231 }
232 break;
233 case DLIL_DESC_SAP:
234 case DLIL_DESC_SNAP:
235 for (i = 0; i < desc_blk->n_max_used; i++) {
236 if (desc_blk->block_ptr[i].type ==
237 demux->type &&
238 bcmp(desc_blk->block_ptr[i].data,
239 demux->data, demux->datalen) == 0) {
240 return EADDRINUSE;
241 }
242 }
243 break;
244 }
245 }
246
247 /* Check for case where all of the descriptor blocks are in use */
248 if (desc_blk == NULL || desc_blk->n_used == desc_blk->n_count) {
249 struct ether_desc_blk_str *tmp;
250 u_int32_t new_count = ETHER_DESC_BLK_SIZE;
251 u_int32_t new_size;
252 u_int32_t old_size = 0;
253
254 i = 0;
255
256 if (desc_blk) {
257 new_count += desc_blk->n_count;
258 old_size = desc_blk->n_count * sizeof(struct en_desc) +
259 ETHER_DESC_HEADER_SIZE;
260 i = desc_blk->n_used;
261 }
262
263 new_size = new_count * sizeof(struct en_desc) +
264 ETHER_DESC_HEADER_SIZE;
265
266 tmp = _MALLOC(new_size, M_IFADDR, M_WAITOK);
267 if (tmp == NULL) {
268 /*
269 * Remove any previous descriptors set in the call.
270 */
271 return ENOMEM;
272 }
273
274 bzero(((char *)tmp) + old_size, new_size - old_size);
275 if (desc_blk) {
276 bcopy(desc_blk, tmp, old_size);
277 FREE(desc_blk, M_IFADDR);
278 }
279 desc_blk = tmp;
280 ifp->if_family_cookie = (uintptr_t)desc_blk;
281 desc_blk->n_count = new_count;
282 } else {
283 /* Find a free entry */
284 for (i = 0; i < desc_blk->n_count; i++) {
285 if (desc_blk->block_ptr[i].type == 0) {
286 break;
287 }
288 }
289 }
290
291 /* Bump n_max_used if appropriate */
292 if (i + 1 > desc_blk->n_max_used) {
293 desc_blk->n_max_used = i + 1;
294 }
295
296 ed = &desc_blk->block_ptr[i];
297 ed->protocol_family = protocol;
298 ed->data[0] = 0;
299 ed->data[1] = 0;
300
301 switch (demux->type) {
302 case DLIL_DESC_ETYPE2:
303 /* 2 byte ethernet raw protocol type is at native_type */
304 /* prtocol must be in network byte order */
305 ed->type = DLIL_DESC_ETYPE2;
306 ed->data[0] = *(u_int16_t*)demux->data;
307 break;
308
309 case DLIL_DESC_SAP:
310 ed->type = DLIL_DESC_SAP;
311 bcopy(demux->data, &ed->data[0], 3);
312 break;
313
314 case DLIL_DESC_SNAP: {
315 u_int8_t* pDest = ((u_int8_t*)&ed->data[0]) + 3;
316 ed->type = DLIL_DESC_SNAP;
317 bcopy(demux->data, pDest, 5);
318 break;
319 }
320 }
321
322 desc_blk->n_used++;
323
324 return 0;
325 }
326
327 int
328 ether_add_proto(ifnet_t ifp, protocol_family_t protocol,
329 const struct ifnet_demux_desc *demux_list, u_int32_t demux_count)
330 {
331 int error = 0;
332 u_int32_t i;
333
334 for (i = 0; i < demux_count; i++) {
335 error = ether_add_proto_internal(ifp, protocol, &demux_list[i]);
336 if (error) {
337 ether_del_proto(ifp, protocol);
338 break;
339 }
340 }
341
342 return error;
343 }
344
345 int
346 ether_demux(ifnet_t ifp, mbuf_t m, char *frame_header,
347 protocol_family_t *protocol_family)
348 {
349 struct ether_header *eh = (struct ether_header *)(void *)frame_header;
350 u_short ether_type = eh->ether_type;
351 u_int16_t type;
352 u_int8_t *data;
353 u_int32_t i = 0;
354 struct ether_desc_blk_str *desc_blk =
355 (struct ether_desc_blk_str *)ifp->if_family_cookie;
356 u_int32_t maxd = desc_blk ? desc_blk->n_max_used : 0;
357 struct en_desc *ed = desc_blk ? desc_blk->block_ptr : NULL;
358 u_int32_t extProto1 = 0;
359 u_int32_t extProto2 = 0;
360
361 if (eh->ether_dhost[0] & 1) {
362 /* Check for broadcast */
363 if (_ether_cmp(etherbroadcastaddr, eh->ether_dhost) == 0) {
364 m->m_flags |= M_BCAST;
365 } else {
366 m->m_flags |= M_MCAST;
367 }
368 }
369
370 if (m->m_flags & M_HASFCS) {
371 /*
372 * If the M_HASFCS is set by the driver we want to make sure
373 * that we strip off the trailing FCS data before handing it
374 * up the stack.
375 */
376 m_adj(m, -ETHER_CRC_LEN);
377 m->m_flags &= ~M_HASFCS;
378 }
379
380 if (ifp->if_eflags & IFEF_BOND) {
381 /* if we're bonded, bond "protocol" gets all the packets */
382 *protocol_family = PF_BOND;
383 return 0;
384 }
385
386 if ((eh->ether_dhost[0] & 1) == 0) {
387 /*
388 * When the driver is put into promiscuous mode we may receive
389 * unicast frames that are not intended for our interfaces.
390 * They are marked here as being promiscuous so the caller may
391 * dispose of them after passing the packets to any interface
392 * filters.
393 */
394 if (_ether_cmp(eh->ether_dhost, IF_LLADDR(ifp))) {
395 m->m_flags |= M_PROMISC;
396 }
397 }
398
399 /* check for VLAN */
400 if ((m->m_pkthdr.csum_flags & CSUM_VLAN_TAG_VALID) != 0) {
401 if (EVL_VLANOFTAG(m->m_pkthdr.vlan_tag) != 0) {
402 *protocol_family = PF_VLAN;
403 return 0;
404 }
405 /* the packet is just priority-tagged, clear the bit */
406 m->m_pkthdr.csum_flags &= ~CSUM_VLAN_TAG_VALID;
407 } else if (ether_type == htons(ETHERTYPE_VLAN)) {
408 struct ether_vlan_header * evl;
409
410 evl = (struct ether_vlan_header *)(void *)frame_header;
411 if (m->m_len < ETHER_VLAN_ENCAP_LEN ||
412 ntohs(evl->evl_proto) == ETHERTYPE_VLAN ||
413 EVL_VLANOFTAG(ntohs(evl->evl_tag)) != 0) {
414 *protocol_family = PF_VLAN;
415 return 0;
416 }
417 /* the packet is just priority-tagged */
418
419 /* make the encapsulated ethertype the actual ethertype */
420 ether_type = evl->evl_encap_proto = evl->evl_proto;
421
422 /* remove the encapsulation header */
423 m->m_len -= ETHER_VLAN_ENCAP_LEN;
424 m->m_data += ETHER_VLAN_ENCAP_LEN;
425 m->m_pkthdr.len -= ETHER_VLAN_ENCAP_LEN;
426 m->m_pkthdr.csum_flags = 0; /* can't trust hardware checksum */
427 } else if (ether_type == htons(ETHERTYPE_ARP)) {
428 m->m_pkthdr.pkt_flags |= PKTF_INET_RESOLVE; /* ARP packet */
429 }
430 data = mtod(m, u_int8_t*);
431
432 /*
433 * Determine the packet's protocol type and stuff the protocol into
434 * longs for quick compares.
435 */
436 if (ntohs(ether_type) <= 1500) {
437 bcopy(data, &extProto1, sizeof(u_int32_t));
438
439 /* SAP or SNAP */
440 if ((extProto1 & htonl(0xFFFFFF00)) == htonl(0xAAAA0300)) {
441 /* SNAP */
442 type = DLIL_DESC_SNAP;
443 bcopy(data + sizeof(u_int32_t), &extProto2,
444 sizeof(u_int32_t));
445 extProto1 &= htonl(0x000000FF);
446 } else {
447 type = DLIL_DESC_SAP;
448 extProto1 &= htonl(0xFFFFFF00);
449 }
450 } else {
451 type = DLIL_DESC_ETYPE2;
452 }
453
454 /*
455 * Search through the connected protocols for a match.
456 */
457 switch (type) {
458 case DLIL_DESC_ETYPE2:
459 for (i = 0; i < maxd; i++) {
460 if ((ed[i].type == type) &&
461 (ed[i].data[0] == ether_type)) {
462 *protocol_family = ed[i].protocol_family;
463 return 0;
464 }
465 }
466 break;
467
468 case DLIL_DESC_SAP:
469 for (i = 0; i < maxd; i++) {
470 if ((ed[i].type == type) &&
471 (ed[i].data[0] == extProto1)) {
472 *protocol_family = ed[i].protocol_family;
473 return 0;
474 }
475 }
476 break;
477
478 case DLIL_DESC_SNAP:
479 for (i = 0; i < maxd; i++) {
480 if ((ed[i].type == type) &&
481 (ed[i].data[0] == extProto1) &&
482 (ed[i].data[1] == extProto2)) {
483 *protocol_family = ed[i].protocol_family;
484 return 0;
485 }
486 }
487 break;
488 }
489
490 return ENOENT;
491 }
492
493 /*
494 * On embedded, ether_frameout is practicaly ether_frameout_extended.
495 * On non-embedded, ether_frameout has long been exposed as a public KPI,
496 * and therefore its signature must remain the same (without the pre- and
497 * postpend length parameters.)
498 */
499 #if KPI_INTERFACE_EMBEDDED
500 int
501 ether_frameout(struct ifnet *ifp, struct mbuf **m,
502 const struct sockaddr *ndest, const char *edst,
503 const char *ether_type, u_int32_t *prepend_len, u_int32_t *postpend_len)
504 #else /* !KPI_INTERFACE_EMBEDDED */
505 int
506 ether_frameout(struct ifnet *ifp, struct mbuf **m,
507 const struct sockaddr *ndest, const char *edst,
508 const char *ether_type)
509 #endif /* KPI_INTERFACE_EMBEDDED */
510 {
511 #if KPI_INTERFACE_EMBEDDED
512 return ether_frameout_extended(ifp, m, ndest, edst, ether_type,
513 prepend_len, postpend_len);
514 #else /* !KPI_INTERFACE_EMBEDDED */
515 return ether_frameout_extended(ifp, m, ndest, edst, ether_type,
516 NULL, NULL);
517 #endif /* !KPI_INTERFACE_EMBEDDED */
518 }
519
520 /*
521 * Ethernet output routine.
522 * Encapsulate a packet of type family for the local net.
523 * Use trailer local net encapsulation if enough data in first
524 * packet leaves a multiple of 512 bytes of data in remainder.
525 */
526 int
527 ether_frameout_extended(struct ifnet *ifp, struct mbuf **m,
528 const struct sockaddr *ndest, const char *edst,
529 const char *ether_type, u_int32_t *prepend_len, u_int32_t *postpend_len)
530 {
531 struct ether_header *eh;
532 int hlen; /* link layer header length */
533
534 hlen = ETHER_HDR_LEN;
535
536 /*
537 * If a simplex interface, and the packet is being sent to our
538 * Ethernet address or a broadcast address, loopback a copy.
539 * XXX To make a simplex device behave exactly like a duplex
540 * device, we should copy in the case of sending to our own
541 * ethernet address (thus letting the original actually appear
542 * on the wire). However, we don't do that here for security
543 * reasons and compatibility with the original behavior.
544 */
545 if ((ifp->if_flags & IFF_SIMPLEX) &&
546 ((*m)->m_flags & M_LOOP) && lo_ifp != NULL) {
547 if ((*m)->m_flags & M_BCAST) {
548 struct mbuf *n = m_copy(*m, 0, (int)M_COPYALL);
549 if (n != NULL) {
550 dlil_output(lo_ifp, ndest->sa_family,
551 n, NULL, ndest, 0, NULL);
552 }
553 } else if (_ether_cmp(edst, IF_LLADDR(ifp)) == 0) {
554 dlil_output(lo_ifp, ndest->sa_family, *m,
555 NULL, ndest, 0, NULL);
556 return EJUSTRETURN;
557 }
558 }
559
560 /*
561 * Add local net header. If no space in first mbuf,
562 * allocate another.
563 */
564 M_PREPEND(*m, sizeof(struct ether_header), M_DONTWAIT, 0);
565 if (*m == NULL) {
566 return EJUSTRETURN;
567 }
568
569 if (prepend_len != NULL) {
570 *prepend_len = sizeof(struct ether_header);
571 }
572 if (postpend_len != NULL) {
573 *postpend_len = 0;
574 }
575
576 eh = mtod(*m, struct ether_header *);
577 (void) memcpy(&eh->ether_type, ether_type, sizeof(eh->ether_type));
578 (void) memcpy(eh->ether_dhost, edst, ETHER_ADDR_LEN);
579 ifnet_lladdr_copy_bytes(ifp, eh->ether_shost, ETHER_ADDR_LEN);
580
581 return 0;
582 }
583
584 errno_t
585 ether_check_multi(ifnet_t ifp, const struct sockaddr *proto_addr)
586 {
587 #pragma unused(ifp)
588 errno_t result = EAFNOSUPPORT;
589 const u_char *e_addr;
590
591 /*
592 * AF_SPEC and AF_LINK don't require translation. We do
593 * want to verify that they specify a valid multicast.
594 */
595 switch (proto_addr->sa_family) {
596 case AF_UNSPEC:
597 e_addr = (const u_char*)&proto_addr->sa_data[0];
598 if ((e_addr[0] & 0x01) != 0x01) {
599 result = EADDRNOTAVAIL;
600 } else {
601 result = 0;
602 }
603 break;
604
605 case AF_LINK:
606 e_addr = CONST_LLADDR((const struct sockaddr_dl*)
607 (uintptr_t)(size_t)proto_addr);
608 if ((e_addr[0] & 0x01) != 0x01) {
609 result = EADDRNOTAVAIL;
610 } else {
611 result = 0;
612 }
613 break;
614 }
615
616 return result;
617 }
618
619 int
620 ether_ioctl(ifnet_t ifp, u_int32_t command, void *data)
621 {
622 #pragma unused(ifp, command, data)
623 return EOPNOTSUPP;
624 }
625
626 __private_extern__ int
627 ether_family_init(void)
628 {
629 errno_t error = 0;
630
631 /* Register protocol registration functions */
632 if ((error = proto_register_plumber(PF_INET, APPLE_IF_FAM_ETHERNET,
633 ether_attach_inet, ether_detach_inet)) != 0) {
634 printf("proto_register_plumber failed for PF_INET error=%d\n",
635 error);
636 goto done;
637 }
638 #if INET6
639 if ((error = proto_register_plumber(PF_INET6, APPLE_IF_FAM_ETHERNET,
640 ether_attach_inet6, ether_detach_inet6)) != 0) {
641 printf("proto_register_plumber failed for PF_INET6 error=%d\n",
642 error);
643 goto done;
644 }
645 #endif /* INET6 */
646 #if VLAN
647 vlan_family_init();
648 #endif /* VLAN */
649 #if BOND
650 bond_family_init();
651 #endif /* BOND */
652 #if IF_BRIDGE
653 bridgeattach(0);
654 #endif /* IF_BRIDGE */
655 #if IF_FAKE
656 if_fake_init();
657 #endif /* IF_FAKE */
658
659 done:
660
661 return error;
662 }