1 /* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */
4 * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
5 * Nottingham University 1987.
7 * This source may be freely distributed, however I would be interested
8 * in any changes that are made.
10 * This driver takes packets off the IP i/f and hands them up to a
11 * user process to have its wicked way with. This driver has it's
12 * roots in a similar driver written by Phil Cockcroft (formerly) at
13 * UCL. This driver is based much more on read/write/poll mode of
19 #include "opt_atalk.h"
21 #include "opt_inet6.h"
25 #include <sys/param.h>
27 #include <sys/systm.h>
30 #include <sys/module.h>
31 #include <sys/socket.h>
32 #include <sys/fcntl.h>
33 #include <sys/filio.h>
34 #include <sys/sockio.h>
35 #include <sys/ttycom.h>
37 #include <sys/selinfo.h>
38 #include <sys/signalvar.h>
39 #include <sys/filedesc.h>
40 #include <sys/kernel.h>
41 #include <sys/sysctl.h>
44 #include <sys/malloc.h>
45 #include <sys/random.h>
48 #include <net/if_types.h>
49 #include <net/netisr.h>
50 #include <net/route.h>
52 #include <netinet/in.h>
55 #include <net/if_tun.h>
57 #include <sys/queue.h>
60 * tun_list is protected by global tunmtx. Other mutable fields are
61 * protected by tun->tun_mtx, or by their owning subsystem. tun_dev is
62 * static for the duration of a tunnel interface.
65 TAILQ_ENTRY(tun_softc) tun_list;
67 u_short tun_flags; /* misc flags */
68 #define TUN_OPEN 0x0001
69 #define TUN_INITED 0x0002
70 #define TUN_RCOLL 0x0004
71 #define TUN_IASET 0x0008
72 #define TUN_DSTADDR 0x0010
73 #define TUN_LMODE 0x0020
74 #define TUN_RWAIT 0x0040
75 #define TUN_ASYNC 0x0080
76 #define TUN_IFHEAD 0x0100
78 #define TUN_READY (TUN_OPEN | TUN_INITED)
81 * XXXRW: tun_pid is used to exclusively lock /dev/tun. Is this
82 * actually needed? Can we just return EBUSY if already open?
83 * Problem is that this involved inherent races when a tun device
84 * is handed off from one process to another, as opposed to just
85 * being slightly stale informationally.
87 pid_t tun_pid; /* owning pid */
88 struct ifnet *tun_ifp; /* the interface */
89 struct sigio *tun_sigio; /* information for async I/O */
90 struct selinfo tun_rsel; /* read select */
91 struct mtx tun_mtx; /* protect mutable softc fields */
93 #define TUN2IFP(sc) ((sc)->tun_ifp)
95 #define TUNDEBUG if (tundebug) if_printf
99 * All mutable global variables in if_tun are locked using tunmtx, with
100 * the exception of tundebug, which is used unlocked, and tunclones,
101 * which is static after setup.
103 static struct mtx tunmtx;
104 static MALLOC_DEFINE(M_TUN, TUNNAME, "Tunnel Interface");
105 static int tundebug = 0;
106 static struct clonedevs *tunclones;
107 static TAILQ_HEAD(,tun_softc) tunhead = TAILQ_HEAD_INITIALIZER(tunhead);
108 SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, "");
110 static void tunclone(void *arg, struct ucred *cred, char *name,
111 int namelen, struct cdev **dev);
112 static void tuncreate(struct cdev *dev);
113 static int tunifioctl(struct ifnet *, u_long, caddr_t);
114 static int tuninit(struct ifnet *);
115 static int tunmodevent(module_t, int, void *);
116 static int tunoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
118 static void tunstart(struct ifnet *);
120 static d_open_t tunopen;
121 static d_close_t tunclose;
122 static d_read_t tunread;
123 static d_write_t tunwrite;
124 static d_ioctl_t tunioctl;
125 static d_poll_t tunpoll;
126 static d_kqfilter_t tunkqfilter;
128 static int tunkqread(struct knote *, long);
129 static int tunkqwrite(struct knote *, long);
130 static void tunkqdetach(struct knote *);
132 static struct filterops tun_read_filterops = {
135 .f_detach = tunkqdetach,
136 .f_event = tunkqread,
139 static struct filterops tun_write_filterops = {
142 .f_detach = tunkqdetach,
143 .f_event = tunkqwrite,
146 static struct cdevsw tun_cdevsw = {
147 .d_version = D_VERSION,
148 .d_flags = D_PSEUDO | D_NEEDGIANT,
155 .d_kqfilter = tunkqfilter,
160 tunclone(void *arg, struct ucred *cred, char *name, int namelen,
168 if (strcmp(name, TUNNAME) == 0) {
170 } else if (dev_stdclone(name, NULL, TUNNAME, &u) != 1)
171 return; /* Don't recognise the name */
172 if (u != -1 && u > IF_MAXUNIT)
173 return; /* Unit number too high */
175 /* find any existing device, or allocate new unit number */
176 i = clone_create(&tunclones, &tun_cdevsw, &u, dev, 0);
178 /* No preexisting struct cdev *, create one */
179 *dev = make_dev(&tun_cdevsw, unit2minor(u),
180 UID_UUCP, GID_DIALER, 0600, "tun%d", u);
183 (*dev)->si_flags |= SI_CHEAPCLONE;
189 tun_destroy(struct tun_softc *tp)
194 KASSERT((tp->tun_flags & TUN_OPEN) == 0,
195 ("tununits is out of sync - unit %d", TUN2IFP(tp)->if_dunit));
198 bpfdetach(TUN2IFP(tp));
199 if_detach(TUN2IFP(tp));
200 if_free(TUN2IFP(tp));
202 knlist_destroy(&tp->tun_rsel.si_note);
203 mtx_destroy(&tp->tun_mtx);
208 tunmodevent(module_t mod, int type, void *data)
210 static eventhandler_tag tag;
211 struct tun_softc *tp;
215 mtx_init(&tunmtx, "tunmtx", NULL, MTX_DEF);
216 clone_setup(&tunclones);
217 tag = EVENTHANDLER_REGISTER(dev_clone, tunclone, 0, 1000);
222 EVENTHANDLER_DEREGISTER(dev_clone, tag);
225 while ((tp = TAILQ_FIRST(&tunhead)) != NULL) {
226 TAILQ_REMOVE(&tunhead, tp, tun_list);
232 clone_cleanup(&tunclones);
233 mtx_destroy(&tunmtx);
241 static moduledata_t tun_mod = {
247 DECLARE_MODULE(if_tun, tun_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
250 tunstart(struct ifnet *ifp)
252 struct tun_softc *tp = ifp->if_softc;
255 TUNDEBUG(ifp,"%s starting\n", ifp->if_xname);
256 if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
257 IFQ_LOCK(&ifp->if_snd);
258 IFQ_POLL_NOLOCK(&ifp->if_snd, m);
260 IFQ_UNLOCK(&ifp->if_snd);
263 IFQ_UNLOCK(&ifp->if_snd);
266 mtx_lock(&tp->tun_mtx);
267 if (tp->tun_flags & TUN_RWAIT) {
268 tp->tun_flags &= ~TUN_RWAIT;
271 if (tp->tun_flags & TUN_ASYNC && tp->tun_sigio) {
272 mtx_unlock(&tp->tun_mtx);
273 pgsigio(&tp->tun_sigio, SIGIO, 0);
275 mtx_unlock(&tp->tun_mtx);
276 selwakeuppri(&tp->tun_rsel, PZERO + 1);
277 KNOTE_UNLOCKED(&tp->tun_rsel.si_note, 0);
280 /* XXX: should return an error code so it can fail. */
282 tuncreate(struct cdev *dev)
284 struct tun_softc *sc;
287 dev->si_flags &= ~SI_CHEAPCLONE;
289 MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK | M_ZERO);
290 mtx_init(&sc->tun_mtx, "tun_mtx", NULL, MTX_DEF);
291 sc->tun_flags = TUN_INITED;
294 TAILQ_INSERT_TAIL(&tunhead, sc, tun_list);
297 ifp = sc->tun_ifp = if_alloc(IFT_PPP);
299 panic("%s%d: failed to if_alloc() interface.\n",
300 TUNNAME, dev2unit(dev));
301 if_initname(ifp, TUNNAME, dev2unit(dev));
302 ifp->if_mtu = TUNMTU;
303 ifp->if_ioctl = tunifioctl;
304 ifp->if_output = tunoutput;
305 ifp->if_start = tunstart;
306 ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
308 IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
309 ifp->if_snd.ifq_drv_maxlen = 0;
310 IFQ_SET_READY(&ifp->if_snd);
311 knlist_init(&sc->tun_rsel.si_note, NULL, NULL, NULL, NULL);
314 bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
316 TUNDEBUG(ifp, "interface %s is created, minor = %#x\n",
317 ifp->if_xname, minor(dev));
321 tunopen(struct cdev *dev, int flag, int mode, struct thread *td)
324 struct tun_softc *tp;
327 * XXXRW: Non-atomic test and set of dev->si_drv1 requires
337 * XXXRW: This use of tun_pid is subject to error due to the
338 * fact that a reference to the tunnel can live beyond the
339 * death of the process that created it. Can we replace this
340 * with a simple busy flag?
342 mtx_lock(&tp->tun_mtx);
343 if (tp->tun_pid != 0 && tp->tun_pid != td->td_proc->p_pid) {
344 mtx_unlock(&tp->tun_mtx);
347 tp->tun_pid = td->td_proc->p_pid;
349 tp->tun_flags |= TUN_OPEN;
350 mtx_unlock(&tp->tun_mtx);
352 TUNDEBUG(ifp, "open\n");
358 * tunclose - close the device - mark i/f down & delete
362 tunclose(struct cdev *dev, int foo, int bar, struct thread *td)
364 struct tun_softc *tp;
371 mtx_lock(&tp->tun_mtx);
372 tp->tun_flags &= ~TUN_OPEN;
376 * junk all pending output
379 IFQ_PURGE(&ifp->if_snd);
381 mtx_unlock(&tp->tun_mtx);
383 if (ifp->if_flags & IFF_UP) {
389 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
393 /* find internet addresses and delete routes */
394 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
395 if (ifa->ifa_addr->sa_family == AF_INET)
397 rtinit(ifa, (int)RTM_DELETE,
398 tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
399 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
403 funsetown(&tp->tun_sigio);
404 selwakeuppri(&tp->tun_rsel, PZERO + 1);
405 KNOTE_UNLOCKED(&tp->tun_rsel.si_note, 0);
406 TUNDEBUG (ifp, "closed\n");
411 tuninit(struct ifnet *ifp)
413 struct tun_softc *tp = ifp->if_softc;
417 TUNDEBUG(ifp, "tuninit\n");
419 ifp->if_flags |= IFF_UP;
420 ifp->if_drv_flags |= IFF_DRV_RUNNING;
421 getmicrotime(&ifp->if_lastchange);
424 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
425 if (ifa->ifa_addr->sa_family == AF_INET) {
426 struct sockaddr_in *si;
428 si = (struct sockaddr_in *)ifa->ifa_addr;
429 mtx_lock(&tp->tun_mtx);
430 if (si->sin_addr.s_addr)
431 tp->tun_flags |= TUN_IASET;
433 si = (struct sockaddr_in *)ifa->ifa_dstaddr;
434 if (si && si->sin_addr.s_addr)
435 tp->tun_flags |= TUN_DSTADDR;
436 mtx_unlock(&tp->tun_mtx);
444 * Process an ioctl request.
447 tunifioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
449 struct ifreq *ifr = (struct ifreq *)data;
450 struct tun_softc *tp = ifp->if_softc;
457 ifs = (struct ifstat *)data;
458 mtx_lock(&tp->tun_mtx);
460 sprintf(ifs->ascii + strlen(ifs->ascii),
461 "\tOpened by PID %d\n", tp->tun_pid);
462 mtx_unlock(&tp->tun_mtx);
465 error = tuninit(ifp);
466 TUNDEBUG(ifp, "address set, error=%d\n", error);
469 error = tuninit(ifp);
470 TUNDEBUG(ifp, "destination address set, error=%d\n", error);
473 ifp->if_mtu = ifr->ifr_mtu;
474 TUNDEBUG(ifp, "mtu set\n");
488 * tunoutput - queue packets from higher level ready to put out.
494 struct sockaddr *dst,
497 struct tun_softc *tp = ifp->if_softc;
498 u_short cached_tun_flags;
502 TUNDEBUG (ifp, "tunoutput\n");
505 error = mac_check_ifnet_transmit(ifp, m0);
512 /* Could be unlocked read? */
513 mtx_lock(&tp->tun_mtx);
514 cached_tun_flags = tp->tun_flags;
515 mtx_unlock(&tp->tun_mtx);
516 if ((cached_tun_flags & TUN_READY) != TUN_READY) {
517 TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags);
522 if ((ifp->if_flags & IFF_UP) != IFF_UP) {
527 /* BPF writes need to be handled specially. */
528 if (dst->sa_family == AF_UNSPEC) {
529 bcopy(dst->sa_data, &af, sizeof(af));
533 if (bpf_peers_present(ifp->if_bpf)) {
535 bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m0);
538 /* prepend sockaddr? this may abort if the mbuf allocation fails */
539 if (cached_tun_flags & TUN_LMODE) {
540 /* allocate space for sockaddr */
541 M_PREPEND(m0, dst->sa_len, M_DONTWAIT);
543 /* if allocation failed drop packet */
549 bcopy(dst, m0->m_data, dst->sa_len);
553 if (cached_tun_flags & TUN_IFHEAD) {
554 /* Prepend the address family */
555 M_PREPEND(m0, 4, M_DONTWAIT);
557 /* if allocation failed drop packet */
563 *(u_int32_t *)m0->m_data = htonl(dst->sa_family);
566 if (dst->sa_family != AF_INET)
570 return (EAFNOSUPPORT);
574 IFQ_HANDOFF(ifp, m0, error);
576 ifp->if_collisions++;
584 * the cdevsw interface is now pretty minimal.
587 tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
591 struct tun_softc *tp = dev->si_drv1;
592 struct tuninfo *tunp;
596 tunp = (struct tuninfo *)data;
597 if (tunp->mtu < IF_MINMTU)
599 if (TUN2IFP(tp)->if_mtu != tunp->mtu
600 && (error = suser(td)) != 0)
602 TUN2IFP(tp)->if_mtu = tunp->mtu;
603 TUN2IFP(tp)->if_type = tunp->type;
604 TUN2IFP(tp)->if_baudrate = tunp->baudrate;
607 tunp = (struct tuninfo *)data;
608 tunp->mtu = TUN2IFP(tp)->if_mtu;
609 tunp->type = TUN2IFP(tp)->if_type;
610 tunp->baudrate = TUN2IFP(tp)->if_baudrate;
613 tundebug = *(int *)data;
616 *(int *)data = tundebug;
619 mtx_lock(&tp->tun_mtx);
621 tp->tun_flags |= TUN_LMODE;
622 tp->tun_flags &= ~TUN_IFHEAD;
624 tp->tun_flags &= ~TUN_LMODE;
625 mtx_unlock(&tp->tun_mtx);
628 mtx_lock(&tp->tun_mtx);
630 tp->tun_flags |= TUN_IFHEAD;
631 tp->tun_flags &= ~TUN_LMODE;
633 tp->tun_flags &= ~TUN_IFHEAD;
634 mtx_unlock(&tp->tun_mtx);
637 /* Could be unlocked read? */
638 mtx_lock(&tp->tun_mtx);
639 *(int *)data = (tp->tun_flags & TUN_IFHEAD) ? 1 : 0;
640 mtx_unlock(&tp->tun_mtx);
643 /* deny this if UP */
644 if (TUN2IFP(tp)->if_flags & IFF_UP)
647 switch (*(int *)data & ~IFF_MULTICAST) {
648 case IFF_POINTOPOINT:
650 TUN2IFP(tp)->if_flags &=
651 ~(IFF_BROADCAST|IFF_POINTOPOINT|IFF_MULTICAST);
652 TUN2IFP(tp)->if_flags |= *(int *)data;
659 mtx_lock(&tp->tun_mtx);
660 tp->tun_pid = curthread->td_proc->p_pid;
661 mtx_unlock(&tp->tun_mtx);
666 mtx_lock(&tp->tun_mtx);
668 tp->tun_flags |= TUN_ASYNC;
670 tp->tun_flags &= ~TUN_ASYNC;
671 mtx_unlock(&tp->tun_mtx);
675 if (!IFQ_IS_EMPTY(&TUN2IFP(tp)->if_snd)) {
677 IFQ_LOCK(&TUN2IFP(tp)->if_snd);
678 IFQ_POLL_NOLOCK(&TUN2IFP(tp)->if_snd, mb);
679 for( *(int *)data = 0; mb != 0; mb = mb->m_next)
680 *(int *)data += mb->m_len;
681 IFQ_UNLOCK(&TUN2IFP(tp)->if_snd);
687 return (fsetown(*(int *)data, &tp->tun_sigio));
690 *(int *)data = fgetown(&tp->tun_sigio);
693 /* This is deprecated, FIOSETOWN should be used instead. */
695 return (fsetown(-(*(int *)data), &tp->tun_sigio));
697 /* This is deprecated, FIOGETOWN should be used instead. */
699 *(int *)data = -fgetown(&tp->tun_sigio);
709 * The cdevsw read interface - reads a packet at a time, or at
710 * least as much of a packet as can be read.
713 tunread(struct cdev *dev, struct uio *uio, int flag)
715 struct tun_softc *tp = dev->si_drv1;
716 struct ifnet *ifp = TUN2IFP(tp);
720 TUNDEBUG (ifp, "read\n");
721 mtx_lock(&tp->tun_mtx);
722 if ((tp->tun_flags & TUN_READY) != TUN_READY) {
723 mtx_unlock(&tp->tun_mtx);
724 TUNDEBUG (ifp, "not ready 0%o\n", tp->tun_flags);
728 tp->tun_flags &= ~TUN_RWAIT;
729 mtx_unlock(&tp->tun_mtx);
733 IFQ_DEQUEUE(&ifp->if_snd, m);
735 if (flag & O_NONBLOCK) {
737 return (EWOULDBLOCK);
739 mtx_lock(&tp->tun_mtx);
740 tp->tun_flags |= TUN_RWAIT;
741 mtx_unlock(&tp->tun_mtx);
742 if ((error = tsleep(tp, PCATCH | (PZERO + 1),
743 "tunread", 0)) != 0) {
751 while (m && uio->uio_resid > 0 && error == 0) {
752 len = min(uio->uio_resid, m->m_len);
754 error = uiomove(mtod(m, void *), len, uio);
759 TUNDEBUG(ifp, "Dropping mbuf\n");
766 * the cdevsw write interface - an atomic write is a packet - or else!
769 tunwrite(struct cdev *dev, struct uio *uio, int flag)
771 struct tun_softc *tp = dev->si_drv1;
772 struct ifnet *ifp = TUN2IFP(tp);
778 TUNDEBUG(ifp, "tunwrite\n");
780 if ((ifp->if_flags & IFF_UP) != IFF_UP)
781 /* ignore silently */
784 if (uio->uio_resid == 0)
787 if (uio->uio_resid < 0 || uio->uio_resid > TUNMRU) {
788 TUNDEBUG(ifp, "len=%d!\n", uio->uio_resid);
792 if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0)) == NULL) {
797 m->m_pkthdr.rcvif = ifp;
799 mac_create_mbuf_from_ifnet(ifp, m);
802 /* Could be unlocked read? */
803 mtx_lock(&tp->tun_mtx);
804 if (tp->tun_flags & TUN_IFHEAD) {
805 mtx_unlock(&tp->tun_mtx);
806 if (m->m_len < sizeof(family) &&
807 (m = m_pullup(m, sizeof(family))) == NULL)
809 family = ntohl(*mtod(m, u_int32_t *));
810 m_adj(m, sizeof(family));
812 mtx_unlock(&tp->tun_mtx);
816 BPF_MTAP2(ifp, &family, sizeof(family), m);
841 return (EAFNOSUPPORT);
843 /* First chunk of an mbuf contains good junk */
844 if (harvest.point_to_point)
845 random_harvest(m, 16, 3, 0, RANDOM_NET);
846 ifp->if_ibytes += m->m_pkthdr.len;
848 netisr_dispatch(isr, m);
853 * tunpoll - the poll interface, this is only useful on reads
854 * really. The write detect always returns true, write never blocks
855 * anyway, it either accepts the packet or drops it.
858 tunpoll(struct cdev *dev, int events, struct thread *td)
861 struct tun_softc *tp = dev->si_drv1;
862 struct ifnet *ifp = TUN2IFP(tp);
867 TUNDEBUG(ifp, "tunpoll\n");
869 if (events & (POLLIN | POLLRDNORM)) {
870 IFQ_LOCK(&ifp->if_snd);
871 IFQ_POLL_NOLOCK(&ifp->if_snd, m);
873 TUNDEBUG(ifp, "tunpoll q=%d\n", ifp->if_snd.ifq_len);
874 revents |= events & (POLLIN | POLLRDNORM);
876 TUNDEBUG(ifp, "tunpoll waiting\n");
877 selrecord(td, &tp->tun_rsel);
879 IFQ_UNLOCK(&ifp->if_snd);
881 if (events & (POLLOUT | POLLWRNORM))
882 revents |= events & (POLLOUT | POLLWRNORM);
889 * tunkqfilter - support for the kevent() system call.
892 tunkqfilter(struct cdev *dev, struct knote *kn)
895 struct tun_softc *tp = dev->si_drv1;
896 struct ifnet *ifp = TUN2IFP(tp);
899 switch(kn->kn_filter) {
901 TUNDEBUG(ifp, "%s kqfilter: EVFILT_READ, minor = %#x\n",
902 ifp->if_xname, minor(dev));
903 kn->kn_fop = &tun_read_filterops;
907 TUNDEBUG(ifp, "%s kqfilter: EVFILT_WRITE, minor = %#x\n",
908 ifp->if_xname, minor(dev));
909 kn->kn_fop = &tun_write_filterops;
913 TUNDEBUG(ifp, "%s kqfilter: invalid filter, minor = %#x\n",
914 ifp->if_xname, minor(dev));
920 kn->kn_hook = (caddr_t) dev;
921 knlist_add(&tp->tun_rsel.si_note, kn, 0);
927 * Return true of there is data in the interface queue.
930 tunkqread(struct knote *kn, long hint)
933 struct cdev *dev = (struct cdev *)(kn->kn_hook);
934 struct tun_softc *tp = dev->si_drv1;
935 struct ifnet *ifp = TUN2IFP(tp);
938 if ((kn->kn_data = ifp->if_snd.ifq_len) > 0) {
940 "%s have data in the queue. Len = %d, minor = %#x\n",
941 ifp->if_xname, ifp->if_snd.ifq_len, minor(dev));
945 "%s waiting for data, minor = %#x\n", ifp->if_xname,
955 * Always can write, always return MTU in kn->data.
958 tunkqwrite(struct knote *kn, long hint)
961 struct tun_softc *tp = ((struct cdev *)kn->kn_hook)->si_drv1;
962 struct ifnet *ifp = TUN2IFP(tp);
965 kn->kn_data = ifp->if_mtu;
972 tunkqdetach(struct knote *kn)
974 struct tun_softc *tp = ((struct cdev *)kn->kn_hook)->si_drv1;
976 knlist_remove(&tp->tun_rsel.si_note, kn, 0);