]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netgraph/ng_eiface.c
param.h: Bump __FreeBSD_version to 1302509 for commit 7aaf39f6b3b0
[FreeBSD/FreeBSD.git] / sys / netgraph / ng_eiface.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  *
5  * Copyright (c) 1999-2001, Vitaly V Belekhov
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice unmodified, this list of conditions, and the following
13  *    disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30
31 #include <sys/param.h>
32 #include <sys/eventhandler.h>
33 #include <sys/systm.h>
34 #include <sys/errno.h>
35 #include <sys/kernel.h>
36 #include <sys/malloc.h>
37 #include <sys/mbuf.h>
38 #include <sys/errno.h>
39 #include <sys/proc.h>
40 #include <sys/sockio.h>
41 #include <sys/socket.h>
42 #include <sys/syslog.h>
43
44 #include <net/if.h>
45 #include <net/if_var.h>
46 #include <net/if_media.h>
47 #include <net/if_types.h>
48 #include <net/netisr.h>
49 #include <net/route.h>
50 #include <net/vnet.h>
51
52 #include <netgraph/ng_message.h>
53 #include <netgraph/netgraph.h>
54 #include <netgraph/ng_parse.h>
55 #include <netgraph/ng_eiface.h>
56
57 #include <net/bpf.h>
58 #include <net/ethernet.h>
59 #include <net/if_arp.h>
60
61 static const struct ng_cmdlist ng_eiface_cmdlist[] = {
62         {
63           NGM_EIFACE_COOKIE,
64           NGM_EIFACE_GET_IFNAME,
65           "getifname",
66           NULL,
67           &ng_parse_string_type
68         },
69         {
70           NGM_EIFACE_COOKIE,
71           NGM_EIFACE_SET,
72           "set",
73           &ng_parse_enaddr_type,
74           NULL
75         },
76         { 0 }
77 };
78
79 /* Node private data */
80 struct ng_eiface_private {
81         struct ifnet    *ifp;           /* per-interface network data */
82         struct ifmedia  media;          /* (fake) media information */
83         int             link_status;    /* fake */
84         int             unit;           /* Interface unit number */
85         node_p          node;           /* Our netgraph node */
86         hook_p          ether;          /* Hook for ethernet stream */
87 };
88 typedef struct ng_eiface_private *priv_p;
89
90 /* Interface methods */
91 static void     ng_eiface_init(void *xsc);
92 static void     ng_eiface_start(struct ifnet *ifp);
93 static int      ng_eiface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
94 #ifdef DEBUG
95 static void     ng_eiface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data);
96 #endif
97
98 /* Netgraph methods */
99 static int              ng_eiface_mod_event(module_t, int, void *);
100 static ng_constructor_t ng_eiface_constructor;
101 static ng_rcvmsg_t      ng_eiface_rcvmsg;
102 static ng_shutdown_t    ng_eiface_rmnode;
103 static ng_newhook_t     ng_eiface_newhook;
104 static ng_rcvdata_t     ng_eiface_rcvdata;
105 static ng_disconnect_t  ng_eiface_disconnect;
106
107 /* Node type descriptor */
108 static struct ng_type typestruct = {
109         .version =      NG_ABI_VERSION,
110         .name =         NG_EIFACE_NODE_TYPE,
111         .mod_event =    ng_eiface_mod_event,
112         .constructor =  ng_eiface_constructor,
113         .rcvmsg =       ng_eiface_rcvmsg,
114         .shutdown =     ng_eiface_rmnode,
115         .newhook =      ng_eiface_newhook,
116         .rcvdata =      ng_eiface_rcvdata,
117         .disconnect =   ng_eiface_disconnect,
118         .cmdlist =      ng_eiface_cmdlist
119 };
120 NETGRAPH_INIT(eiface, &typestruct);
121
122 VNET_DEFINE_STATIC(struct unrhdr *, ng_eiface_unit);
123 #define V_ng_eiface_unit                VNET(ng_eiface_unit)
124
125 /************************************************************************
126                         INTERFACE STUFF
127  ************************************************************************/
128
129 /*
130  * Process an ioctl for the virtual interface
131  */
132 static int
133 ng_eiface_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
134 {
135         const priv_p priv = (priv_p)ifp->if_softc;
136         struct ifreq *const ifr = (struct ifreq *)data;
137         int error = 0;
138
139 #ifdef DEBUG
140         ng_eiface_print_ioctl(ifp, command, data);
141 #endif
142         switch (command) {
143         /* These two are mostly handled at a higher layer */
144         case SIOCSIFADDR:
145                 error = ether_ioctl(ifp, command, data);
146                 break;
147         case SIOCGIFADDR:
148                 break;
149
150         /* Set flags */
151         case SIOCSIFFLAGS:
152                 /*
153                  * If the interface is marked up and stopped, then start it.
154                  * If it is marked down and running, then stop it.
155                  */
156                 if (ifp->if_flags & IFF_UP) {
157                         if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
158                                 ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE);
159                                 ifp->if_drv_flags |= IFF_DRV_RUNNING;
160                         }
161                 } else {
162                         if (ifp->if_drv_flags & IFF_DRV_RUNNING)
163                                 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING |
164                                     IFF_DRV_OACTIVE);
165                 }
166                 break;
167
168         /* Set the interface MTU */
169         case SIOCSIFMTU:
170                 if (ifr->ifr_mtu > NG_EIFACE_MTU_MAX ||
171                     ifr->ifr_mtu < NG_EIFACE_MTU_MIN)
172                         error = EINVAL;
173                 else
174                         ifp->if_mtu = ifr->ifr_mtu;
175                 break;
176
177         /* (Fake) media type manipulation */
178         case SIOCSIFMEDIA:
179         case SIOCGIFMEDIA:
180                 error = ifmedia_ioctl(ifp, ifr, &priv->media, command);
181                 break;
182
183         /* Stuff that's not supported */
184         case SIOCADDMULTI:
185         case SIOCDELMULTI:
186                 error = 0;
187                 break;
188         case SIOCSIFPHYS:
189                 error = EOPNOTSUPP;
190                 break;
191
192         default:
193                 error = EINVAL;
194                 break;
195         }
196         return (error);
197 }
198
199 static void
200 ng_eiface_init(void *xsc)
201 {
202         priv_p sc = xsc;
203         struct ifnet *ifp = sc->ifp;
204
205         ifp->if_drv_flags |= IFF_DRV_RUNNING;
206         ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
207 }
208
209 /*
210  * We simply relay the packet to the "ether" hook, if it is connected.
211  * We have been through the netgraph locking and are guaranteed to
212  * be the only code running in this node at this time.
213  */
214 static void
215 ng_eiface_start2(node_p node, hook_p hook, void *arg1, int arg2)
216 {
217         struct ifnet *ifp = arg1;
218         const priv_p priv = (priv_p)ifp->if_softc;
219         int error = 0;
220         struct mbuf *m;
221
222         /* Check interface flags */
223
224         if (!((ifp->if_flags & IFF_UP) &&
225             (ifp->if_drv_flags & IFF_DRV_RUNNING)))
226                 return;
227
228         for (;;) {
229                 /*
230                  * Grab a packet to transmit.
231                  */
232                 IF_DEQUEUE(&ifp->if_snd, m);
233
234                 /* If there's nothing to send, break. */
235                 if (m == NULL)
236                         break;
237
238                 /* Peel the mbuf off any stale tags */
239                 m_tag_delete_chain(m, NULL);
240
241                 /*
242                  * Berkeley packet filter.
243                  * Pass packet to bpf if there is a listener.
244                  * XXX is this safe? locking?
245                  */
246                 BPF_MTAP(ifp, m);
247
248                 if (ifp->if_flags & IFF_MONITOR) {
249                         if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
250                         m_freem(m);
251                         continue;
252                 }
253
254                 /*
255                  * Send packet; if hook is not connected, mbuf will get
256                  * freed.
257                  */
258                 NG_OUTBOUND_THREAD_REF();
259                 NG_SEND_DATA_ONLY(error, priv->ether, m);
260                 NG_OUTBOUND_THREAD_UNREF();
261
262                 /* Update stats */
263                 if (error == 0)
264                         if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
265                 else
266                         if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
267         }
268
269         ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
270
271         return;
272 }
273
274 /*
275  * This routine is called to deliver a packet out the interface.
276  * We simply queue the netgraph version to be called when netgraph locking
277  * allows it to happen.
278  * Until we know what the rest of the networking code is doing for
279  * locking, we don't know how we will interact with it.
280  * Take comfort from the fact that the ifnet struct is part of our
281  * private info and can't go away while we are queued.
282  * [Though we don't know it is still there now....]
283  * it is possible we don't gain anything from this because
284  * we would like to get the mbuf and queue it as data
285  * somehow, but we can't and if we did would we solve anything?
286  */
287 static void
288 ng_eiface_start(struct ifnet *ifp)
289 {
290         const priv_p priv = (priv_p)ifp->if_softc;
291
292         /* Don't do anything if output is active */
293         if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
294                 return;
295
296         ifp->if_drv_flags |= IFF_DRV_OACTIVE;
297
298         if (ng_send_fn(priv->node, NULL, &ng_eiface_start2, ifp, 0) != 0)
299                 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
300 }
301
302 #ifdef DEBUG
303 /*
304  * Display an ioctl to the virtual interface
305  */
306
307 static void
308 ng_eiface_print_ioctl(struct ifnet *ifp, int command, caddr_t data)
309 {
310         char *str;
311
312         switch (command & IOC_DIRMASK) {
313         case IOC_VOID:
314                 str = "IO";
315                 break;
316         case IOC_OUT:
317                 str = "IOR";
318                 break;
319         case IOC_IN:
320                 str = "IOW";
321                 break;
322         case IOC_INOUT:
323                 str = "IORW";
324                 break;
325         default:
326                 str = "IO??";
327         }
328         log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n",
329             ifp->if_xname,
330             str,
331             IOCGROUP(command),
332             command & 0xff,
333             IOCPARM_LEN(command));
334 }
335 #endif /* DEBUG */
336
337 /*
338  * ifmedia stuff
339  */
340 static int
341 ng_eiface_mediachange(struct ifnet *ifp)
342 {
343         const priv_p priv = (priv_p)ifp->if_softc;
344         struct ifmedia *ifm = &priv->media;
345
346         if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
347                 return (EINVAL);
348         if (IFM_SUBTYPE(ifm->ifm_media) == IFM_AUTO)
349                 ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T);
350         else
351                 ifp->if_baudrate = ifmedia_baudrate(ifm->ifm_media);
352
353         return (0);
354 }
355
356 static void
357 ng_eiface_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
358 {
359         const priv_p priv = (priv_p)ifp->if_softc;
360         struct ifmedia *ifm = &priv->media;
361
362         if (ifm->ifm_cur->ifm_media == (IFM_ETHER | IFM_AUTO) &&
363             (priv->link_status & IFM_ACTIVE))
364                 ifmr->ifm_active = IFM_ETHER | IFM_1000_T | IFM_FDX;
365         else
366                 ifmr->ifm_active = ifm->ifm_cur->ifm_media;
367         ifmr->ifm_status = priv->link_status;
368
369         return;
370 }
371
372 /************************************************************************
373                         NETGRAPH NODE STUFF
374  ************************************************************************/
375
376 /*
377  * Constructor for a node
378  */
379 static int
380 ng_eiface_constructor(node_p node)
381 {
382         struct ifnet *ifp;
383         priv_p priv;
384         struct ether_addr eaddr;
385
386         /* Allocate node and interface private structures */
387         priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO);
388
389         ifp = priv->ifp = if_alloc(IFT_ETHER);
390         if (ifp == NULL) {
391                 free(priv, M_NETGRAPH);
392                 return (ENOSPC);
393         }
394
395         /* Link them together */
396         ifp->if_softc = priv;
397
398         /* Get an interface unit number */
399         priv->unit = alloc_unr(V_ng_eiface_unit);
400
401         /* Link together node and private info */
402         NG_NODE_SET_PRIVATE(node, priv);
403         priv->node = node;
404
405         /* Initialize interface structure */
406         if_initname(ifp, NG_EIFACE_EIFACE_NAME, priv->unit);
407         ifp->if_init = ng_eiface_init;
408         ifp->if_output = ether_output;
409         ifp->if_start = ng_eiface_start;
410         ifp->if_ioctl = ng_eiface_ioctl;
411         ifp->if_snd.ifq_maxlen = ifqmaxlen;
412         ifp->if_flags = (IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST);
413         ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
414         ifp->if_capenable = IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
415         ifmedia_init(&priv->media, 0, ng_eiface_mediachange,
416             ng_eiface_mediastatus);
417         ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T, 0, NULL);
418         ifmedia_add(&priv->media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
419         ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX, 0, NULL);
420         ifmedia_add(&priv->media, IFM_ETHER | IFM_100_TX | IFM_FDX, 0, NULL);
421         ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T, 0, NULL);
422         ifmedia_add(&priv->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
423         ifmedia_add(&priv->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL);
424         ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL);
425         ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO);
426         priv->link_status = IFM_AVALID;
427
428         /* Give this node the same name as the interface (if possible) */
429         if (ng_name_node(node, ifp->if_xname) != 0)
430                 log(LOG_WARNING, "%s: can't acquire netgraph name\n",
431                     ifp->if_xname);
432
433         /* Attach the interface */
434         ether_gen_addr(ifp, &eaddr);
435         ether_ifattach(ifp, eaddr.octet);
436         ifp->if_baudrate = ifmedia_baudrate(IFM_ETHER | IFM_1000_T);
437
438         /* Done */
439         return (0);
440 }
441
442 /*
443  * Give our ok for a hook to be added
444  */
445 static int
446 ng_eiface_newhook(node_p node, hook_p hook, const char *name)
447 {
448         priv_p priv = NG_NODE_PRIVATE(node);
449         struct ifnet *ifp = priv->ifp;
450
451         if (strcmp(name, NG_EIFACE_HOOK_ETHER))
452                 return (EPFNOSUPPORT);
453         if (priv->ether != NULL)
454                 return (EISCONN);
455         priv->ether = hook;
456         NG_HOOK_SET_PRIVATE(hook, &priv->ether);
457         NG_HOOK_SET_TO_INBOUND(hook);
458
459         priv->link_status |= IFM_ACTIVE;
460         CURVNET_SET_QUIET(ifp->if_vnet);
461         if_link_state_change(ifp, LINK_STATE_UP);
462         CURVNET_RESTORE();
463
464         return (0);
465 }
466
467 /*
468  * Receive a control message
469  */
470 static int
471 ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook)
472 {
473         const priv_p priv = NG_NODE_PRIVATE(node);
474         struct ifnet *const ifp = priv->ifp;
475         struct ng_mesg *resp = NULL;
476         int error = 0;
477         struct ng_mesg *msg;
478
479         NGI_GET_MSG(item, msg);
480         switch (msg->header.typecookie) {
481         case NGM_EIFACE_COOKIE:
482                 switch (msg->header.cmd) {
483                 case NGM_EIFACE_SET:
484                     {
485                         if (msg->header.arglen != ETHER_ADDR_LEN) {
486                                 error = EINVAL;
487                                 break;
488                         }
489                         error = if_setlladdr(priv->ifp,
490                             (u_char *)msg->data, ETHER_ADDR_LEN);
491                         break;
492                     }
493
494                 case NGM_EIFACE_GET_IFNAME:
495                         NG_MKRESPONSE(resp, msg, IFNAMSIZ, M_NOWAIT);
496                         if (resp == NULL) {
497                                 error = ENOMEM;
498                                 break;
499                         }
500                         strlcpy(resp->data, ifp->if_xname, IFNAMSIZ);
501                         break;
502
503                 case NGM_EIFACE_GET_IFADDRS:
504                     {
505                         struct epoch_tracker et;
506                         struct ifaddr *ifa;
507                         caddr_t ptr;
508                         int buflen;
509
510                         /* Determine size of response and allocate it */
511                         buflen = 0;
512                         NET_EPOCH_ENTER(et);
513                         CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
514                                 buflen += SA_SIZE(ifa->ifa_addr);
515                         NG_MKRESPONSE(resp, msg, buflen, M_NOWAIT);
516                         if (resp == NULL) {
517                                 NET_EPOCH_EXIT(et);
518                                 error = ENOMEM;
519                                 break;
520                         }
521
522                         /* Add addresses */
523                         ptr = resp->data;
524                         CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
525                                 const int len = SA_SIZE(ifa->ifa_addr);
526
527                                 if (buflen < len) {
528                                         log(LOG_ERR, "%s: len changed?\n",
529                                             ifp->if_xname);
530                                         break;
531                                 }
532                                 bcopy(ifa->ifa_addr, ptr, len);
533                                 ptr += len;
534                                 buflen -= len;
535                         }
536                         NET_EPOCH_EXIT(et);
537                         break;
538                     }
539
540                 default:
541                         error = EINVAL;
542                         break;
543                 } /* end of inner switch() */
544                 break;
545         case NGM_FLOW_COOKIE:
546                 CURVNET_SET_QUIET(ifp->if_vnet);
547                 switch (msg->header.cmd) {
548                 case NGM_LINK_IS_UP:
549                         priv->link_status |= IFM_ACTIVE;
550                         if_link_state_change(ifp, LINK_STATE_UP);
551                         break;
552                 case NGM_LINK_IS_DOWN:
553                         priv->link_status &= ~IFM_ACTIVE;
554                         if_link_state_change(ifp, LINK_STATE_DOWN);
555                         break;
556                 default:
557                         break;
558                 }
559                 CURVNET_RESTORE();
560                 break;
561         default:
562                 error = EINVAL;
563                 break;
564         }
565         NG_RESPOND_MSG(error, node, item, resp);
566         NG_FREE_MSG(msg);
567         return (error);
568 }
569
570 /*
571  * Receive data from a hook. Pass the packet to the ether_input routine.
572  */
573 static int
574 ng_eiface_rcvdata(hook_p hook, item_p item)
575 {
576         const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
577         struct ifnet *const ifp = priv->ifp;
578         struct mbuf *m;
579
580         NGI_GET_M(item, m);
581         NG_FREE_ITEM(item);
582
583         if (!((ifp->if_flags & IFF_UP) &&
584             (ifp->if_drv_flags & IFF_DRV_RUNNING))) {
585                 NG_FREE_M(m);
586                 return (ENETDOWN);
587         }
588
589         if (m->m_len < ETHER_HDR_LEN) {
590                 m = m_pullup(m, ETHER_HDR_LEN);
591                 if (m == NULL)
592                         return (EINVAL);
593         }
594
595         /* Note receiving interface */
596         m->m_pkthdr.rcvif = ifp;
597
598         /* Update interface stats */
599         if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
600
601         (*ifp->if_input)(ifp, m);
602
603         /* Done */
604         return (0);
605 }
606
607 /*
608  * Shutdown processing.
609  */
610 static int
611 ng_eiface_rmnode(node_p node)
612 {
613         const priv_p priv = NG_NODE_PRIVATE(node);
614         struct ifnet *const ifp = priv->ifp;
615
616         /*
617          * the ifnet may be in a different vnet than the netgraph node, 
618          * hence we have to change the current vnet context here.
619          */
620         CURVNET_SET_QUIET(ifp->if_vnet);
621         ether_ifdetach(ifp);
622         ifmedia_removeall(&priv->media);
623         if_free(ifp);
624         CURVNET_RESTORE();
625         free_unr(V_ng_eiface_unit, priv->unit);
626         free(priv, M_NETGRAPH);
627         NG_NODE_SET_PRIVATE(node, NULL);
628         NG_NODE_UNREF(node);
629         return (0);
630 }
631
632 /*
633  * Hook disconnection
634  */
635 static int
636 ng_eiface_disconnect(hook_p hook)
637 {
638         const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
639
640         priv->ether = NULL;
641         priv->link_status &= ~IFM_ACTIVE;
642         CURVNET_SET_QUIET(priv->ifp->if_vnet);
643         if_link_state_change(priv->ifp, LINK_STATE_DOWN);
644         CURVNET_RESTORE();
645         return (0);
646 }
647
648 /*
649  * Handle loading and unloading for this node type.
650  */
651 static int
652 ng_eiface_mod_event(module_t mod, int event, void *data)
653 {
654         int error = 0;
655
656         switch (event) {
657         case MOD_LOAD:
658         case MOD_UNLOAD:
659                 break;
660         default:
661                 error = EOPNOTSUPP;
662                 break;
663         }
664         return (error);
665 }
666
667 static void
668 vnet_ng_eiface_init(const void *unused)
669 {
670
671         V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
672 }
673 VNET_SYSINIT(vnet_ng_eiface_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
674     vnet_ng_eiface_init, NULL);
675
676 static void
677 vnet_ng_eiface_uninit(const void *unused)
678 {
679
680         delete_unrhdr(V_ng_eiface_unit);
681 }
682 VNET_SYSUNINIT(vnet_ng_eiface_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY,
683    vnet_ng_eiface_uninit, NULL);