net: Nastily set the max number of convs to 4096
[akaros.git] / kern / src / net / udp.c
1 /* Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
2  * Portions Copyright © 1997-1999 Vita Nuova Limited
3  * Portions Copyright © 2000-2007 Vita Nuova Holdings Limited
4  *                                (www.vitanuova.com)
5  * Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
6  *
7  * Modified for the Akaros operating system:
8  * Copyright (c) 2013-2014 The Regents of the University of California
9  * Copyright (c) 2013-2015 Google Inc.
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  * SOFTWARE. */
28
29 #define DEBUG
30 #include <vfs.h>
31 #include <kfs.h>
32 #include <slab.h>
33 #include <kmalloc.h>
34 #include <kref.h>
35 #include <string.h>
36 #include <stdio.h>
37 #include <assert.h>
38 #include <error.h>
39 #include <cpio.h>
40 #include <pmap.h>
41 #include <smp.h>
42 #include <ip.h>
43
44 #include <vfs.h>
45 #include <kfs.h>
46 #include <slab.h>
47 #include <kmalloc.h>
48 #include <kref.h>
49 #include <string.h>
50 #include <stdio.h>
51 #include <assert.h>
52 #include <error.h>
53 #include <cpio.h>
54 #include <pmap.h>
55 #include <smp.h>
56 #include <ip.h>
57
58 #define DPRINT if(0)print
59
60 enum {
61         UDP_UDPHDR_SZ = 8,
62
63         UDP4_PHDR_OFF = 8,
64         UDP4_PHDR_SZ = 12,
65         UDP4_IPHDR_SZ = 20,
66         UDP6_IPHDR_SZ = 40,
67         UDP6_PHDR_SZ = 40,
68         UDP6_PHDR_OFF = 0,
69
70         IP_UDPPROTO = 17,
71         UDP_USEAD7 = 52,
72         UDP_USEAD6 = 36,
73
74         Udprxms = 200,
75         Udptickms = 100,
76         Udpmaxxmit = 10,
77 };
78
79 typedef struct Udp4hdr Udp4hdr;
80 struct Udp4hdr {
81         /* ip header */
82         uint8_t vihl;                           /* Version and header length */
83         uint8_t tos;                            /* Type of service */
84         uint8_t length[2];                      /* packet length */
85         uint8_t id[2];                          /* Identification */
86         uint8_t frag[2];                        /* Fragment information */
87         uint8_t Unused;
88         uint8_t udpproto;                       /* Protocol */
89         uint8_t udpplen[2];                     /* Header plus data length */
90         uint8_t udpsrc[IPv4addrlen];    /* Ip source */
91         uint8_t udpdst[IPv4addrlen];    /* Ip destination */
92
93         /* udp header */
94         uint8_t udpsport[2];            /* Source port */
95         uint8_t udpdport[2];            /* Destination port */
96         uint8_t udplen[2];                      /* data length */
97         uint8_t udpcksum[2];            /* Checksum */
98 };
99
100 typedef struct Udp6hdr Udp6hdr;
101 struct Udp6hdr {
102         uint8_t viclfl[4];
103         uint8_t len[2];
104         uint8_t nextheader;
105         uint8_t hoplimit;
106         uint8_t udpsrc[IPaddrlen];
107         uint8_t udpdst[IPaddrlen];
108
109         /* udp header */
110         uint8_t udpsport[2];            /* Source port */
111         uint8_t udpdport[2];            /* Destination port */
112         uint8_t udplen[2];                      /* data length */
113         uint8_t udpcksum[2];            /* Checksum */
114 };
115
116 /* MIB II counters */
117 typedef struct Udpstats Udpstats;
118 struct Udpstats {
119         uint32_t udpInDatagrams;
120         uint32_t udpNoPorts;
121         uint32_t udpInErrors;
122         uint32_t udpOutDatagrams;
123 };
124
125 typedef struct Udppriv Udppriv;
126 struct Udppriv {
127         struct Ipht ht;
128
129         /* MIB counters */
130         Udpstats ustats;
131
132         /* non-MIB stats */
133         uint32_t csumerr;                       /* checksum errors */
134         uint32_t lenerr;                        /* short packet */
135 };
136
137 void (*etherprofiler) (char *name, int qlen);
138 void udpkick(void *x, struct block *bp);
139
140 /*
141  *  protocol specific part of Conv
142  */
143 typedef struct Udpcb Udpcb;
144 struct Udpcb {
145         uint8_t headers;
146 };
147
148 static void udpconnect(struct conv *c, char **argv, int argc)
149 {
150         Udppriv *upriv;
151
152         upriv = c->p->priv;
153         Fsstdconnect(c, argv, argc);
154         Fsconnected(c, 0);
155
156         iphtadd(&upriv->ht, c);
157 }
158
159 static int udpstate(struct conv *c, char *state, int n)
160 {
161         return snprintf(state, n, "%s qin %d qout %d\n",
162                                         c->inuse ? "Open" : "Closed",
163                                         c->rq ? qlen(c->rq) : 0, c->wq ? qlen(c->wq) : 0);
164 }
165
166 static void udpannounce(struct conv *c, char **argv, int argc)
167 {
168         Udppriv *upriv;
169
170         upriv = c->p->priv;
171         Fsstdannounce(c, argv, argc);
172         Fsconnected(c, NULL);
173         iphtadd(&upriv->ht, c);
174 }
175
176 static void udpbypass(struct conv *cv, char **argv, int argc)
177 {
178         Udppriv *upriv = cv->p->priv;
179
180         Fsstdbypass(cv, argv, argc);
181         iphtadd(&upriv->ht, cv);
182 }
183
184 static void udpcreate(struct conv *c)
185 {
186         c->rq = qopen(128 * 1024, Qmsg, 0, 0);
187         c->wq = qbypass(udpkick, c);
188 }
189
190 static void udpclose(struct conv *c)
191 {
192         Udpcb *ucb;
193         Udppriv *upriv;
194
195         upriv = c->p->priv;
196         iphtrem(&upriv->ht, c);
197
198         c->state = 0;
199         qclose(c->rq);
200         qclose(c->wq);
201         qclose(c->eq);
202         ipmove(c->laddr, IPnoaddr);
203         ipmove(c->raddr, IPnoaddr);
204         c->lport = 0;
205         c->rport = 0;
206
207         ucb = (Udpcb *) c->ptcl;
208         ucb->headers = 0;
209
210         qunlock(&c->qlock);
211 }
212
213 void udpkick(void *x, struct block *bp)
214 {
215         struct conv *c = x;
216         Udp4hdr *uh4;
217         Udp6hdr *uh6;
218         uint16_t rport;
219         uint8_t laddr[IPaddrlen], raddr[IPaddrlen];
220         Udpcb *ucb;
221         int dlen, ptcllen;
222         Udppriv *upriv;
223         struct Fs *f;
224         int version;
225         struct conv *rc;
226
227         upriv = c->p->priv;
228         assert(upriv);
229         f = c->p->f;
230
231         netlog(c->p->f, Logudp, "udp: kick\n");
232         if (bp == NULL)
233                 return;
234
235         ucb = (Udpcb *) c->ptcl;
236         switch (ucb->headers) {
237                 case 7:
238                         /* get user specified addresses */
239                         bp = pullupblock(bp, UDP_USEAD7);
240                         if (bp == NULL)
241                                 return;
242                         ipmove(raddr, bp->rp);
243                         bp->rp += IPaddrlen;
244                         ipmove(laddr, bp->rp);
245                         bp->rp += IPaddrlen;
246                         /* pick interface closest to dest */
247                         if (ipforme(f, laddr) != Runi)
248                                 findlocalip(f, laddr, raddr);
249                         bp->rp += IPaddrlen;    /* Ignore ifc address */
250                         rport = nhgets(bp->rp);
251                         bp->rp += 2 + 2;        /* Ignore local port */
252                         break;
253                 case 6:
254                         /* get user specified addresses */
255                         bp = pullupblock(bp, UDP_USEAD6);
256                         if (bp == NULL)
257                                 return;
258                         ipmove(raddr, bp->rp);
259                         bp->rp += IPaddrlen;
260                         ipmove(laddr, bp->rp);
261                         bp->rp += IPaddrlen;
262                         /* pick interface closest to dest */
263                         if (ipforme(f, laddr) != Runi)
264                                 findlocalip(f, laddr, raddr);
265                         rport = nhgets(bp->rp);
266                         bp->rp += 2 + 2;        /* Ignore local port */
267                         break;
268                 default:
269                         rport = 0;
270                         break;
271         }
272
273         if (ucb->headers) {
274                 if (memcmp(laddr, v4prefix, IPv4off) == 0 ||
275                         ipcmp(laddr, IPnoaddr) == 0)
276                         version = V4;
277                 else
278                         version = V6;
279         } else {
280                 if ((memcmp(c->raddr, v4prefix, IPv4off) == 0 &&
281                          memcmp(c->laddr, v4prefix, IPv4off) == 0)
282                         || ipcmp(c->raddr, IPnoaddr) == 0)
283                         version = V4;
284                 else
285                         version = V6;
286         }
287
288         dlen = blocklen(bp);
289
290         /* fill in pseudo header and compute checksum */
291         switch (version) {
292                 case V4:
293                         bp = padblock(bp, UDP4_IPHDR_SZ + UDP_UDPHDR_SZ);
294                         if (bp == NULL)
295                                 return;
296
297                         uh4 = (Udp4hdr *) (bp->rp);
298                         ptcllen = dlen + UDP_UDPHDR_SZ;
299                         uh4->Unused = 0;
300                         uh4->udpproto = IP_UDPPROTO;
301                         uh4->frag[0] = 0;
302                         uh4->frag[1] = 0;
303                         hnputs(uh4->udpplen, ptcllen);
304                         if (ucb->headers) {
305                                 v6tov4(uh4->udpdst, raddr);
306                                 hnputs(uh4->udpdport, rport);
307                                 v6tov4(uh4->udpsrc, laddr);
308                                 rc = NULL;
309                         } else {
310                                 v6tov4(uh4->udpdst, c->raddr);
311                                 hnputs(uh4->udpdport, c->rport);
312                                 if (ipcmp(c->laddr, IPnoaddr) == 0)
313                                         findlocalip(f, c->laddr, c->raddr);
314                                 v6tov4(uh4->udpsrc, c->laddr);
315                                 rc = c;
316                         }
317                         hnputs(uh4->udpsport, c->lport);
318                         hnputs(uh4->udplen, ptcllen);
319                         uh4->udpcksum[0] = 0;
320                         uh4->udpcksum[1] = 0;
321                         hnputs(uh4->udpcksum,
322                                    ~ptclcsum(bp, UDP4_PHDR_OFF, UDP4_PHDR_SZ));
323                         bp->checksum_start = UDP4_IPHDR_SZ;
324                         bp->checksum_offset = uh4->udpcksum - uh4->udpsport;
325                         bp->flag |= Budpck;
326                         uh4->vihl = IP_VER4;
327                         ipoput4(f, bp, 0, c->ttl, c->tos, rc);
328                         break;
329
330                 case V6:
331                         bp = padblock(bp, UDP6_IPHDR_SZ + UDP_UDPHDR_SZ);
332                         if (bp == NULL)
333                                 return;
334
335                         // using the v6 ip header to create pseudo header
336                         // first then reset it to the normal ip header
337                         uh6 = (Udp6hdr *) (bp->rp);
338                         memset(uh6, 0, 8);
339                         ptcllen = dlen + UDP_UDPHDR_SZ;
340                         hnputl(uh6->viclfl, ptcllen);
341                         uh6->hoplimit = IP_UDPPROTO;
342                         if (ucb->headers) {
343                                 ipmove(uh6->udpdst, raddr);
344                                 hnputs(uh6->udpdport, rport);
345                                 ipmove(uh6->udpsrc, laddr);
346                                 rc = NULL;
347                         } else {
348                                 ipmove(uh6->udpdst, c->raddr);
349                                 hnputs(uh6->udpdport, c->rport);
350                                 if (ipcmp(c->laddr, IPnoaddr) == 0)
351                                         findlocalip(f, c->laddr, c->raddr);
352                                 ipmove(uh6->udpsrc, c->laddr);
353                                 rc = c;
354                         }
355                         hnputs(uh6->udpsport, c->lport);
356                         hnputs(uh6->udplen, ptcllen);
357                         uh6->udpcksum[0] = 0;
358                         uh6->udpcksum[1] = 0;
359                         hnputs(uh6->udpcksum,
360                                    ptclcsum(bp, UDP6_PHDR_OFF,
361                                                         dlen + UDP_UDPHDR_SZ + UDP6_PHDR_SZ));
362                         memset(uh6, 0, 8);
363                         uh6->viclfl[0] = IP_VER6;
364                         hnputs(uh6->len, ptcllen);
365                         uh6->nextheader = IP_UDPPROTO;
366                         ipoput6(f, bp, 0, c->ttl, c->tos, rc);
367                         break;
368
369                 default:
370                         panic("udpkick: version %d", version);
371         }
372         upriv->ustats.udpOutDatagrams++;
373 }
374
375 void udpiput(struct Proto *udp, struct Ipifc *ifc, struct block *bp)
376 {
377         int len;
378         Udp4hdr *uh4;
379         Udp6hdr *uh6;
380         struct conv *c;
381         Udpcb *ucb;
382         uint8_t raddr[IPaddrlen], laddr[IPaddrlen];
383         uint16_t rport, lport;
384         Udppriv *upriv;
385         struct Fs *f;
386         int version;
387         int ottl, oviclfl, olen;
388         uint8_t *p;
389
390         upriv = udp->priv;
391         f = udp->f;
392         upriv->ustats.udpInDatagrams++;
393
394         uh4 = (Udp4hdr *) (bp->rp);
395         version = ((uh4->vihl & 0xF0) == IP_VER6) ? V6 : V4;
396
397         /*
398          * Put back pseudo header for checksum
399          * (remember old values for icmpnoconv())
400          */
401         switch (version) {
402                 case V4:
403                         ottl = uh4->Unused;
404                         uh4->Unused = 0;
405                         len = nhgets(uh4->udplen);
406                         olen = nhgets(uh4->udpplen);
407                         hnputs(uh4->udpplen, len);
408
409                         v4tov6(raddr, uh4->udpsrc);
410                         v4tov6(laddr, uh4->udpdst);
411                         lport = nhgets(uh4->udpdport);
412                         rport = nhgets(uh4->udpsport);
413
414                         if (!(bp->flag & Budpck) &&
415                             (uh4->udpcksum[0] || uh4->udpcksum[1]) &&
416                             ptclcsum(bp, UDP4_PHDR_OFF, len + UDP4_PHDR_SZ)) {
417                                 upriv->ustats.udpInErrors++;
418                                 netlog(f, Logudp, "udp: checksum error %I\n",
419                                        raddr);
420                                 printd("udp: checksum error %I\n", raddr);
421                                 freeblist(bp);
422                                 return;
423                         }
424                         uh4->Unused = ottl;
425                         hnputs(uh4->udpplen, olen);
426                         break;
427                 case V6:
428                         uh6 = (Udp6hdr *) (bp->rp);
429                         len = nhgets(uh6->udplen);
430                         oviclfl = nhgetl(uh6->viclfl);
431                         olen = nhgets(uh6->len);
432                         ottl = uh6->hoplimit;
433                         ipmove(raddr, uh6->udpsrc);
434                         ipmove(laddr, uh6->udpdst);
435                         lport = nhgets(uh6->udpdport);
436                         rport = nhgets(uh6->udpsport);
437                         memset(uh6, 0, 8);
438                         hnputl(uh6->viclfl, len);
439                         uh6->hoplimit = IP_UDPPROTO;
440                         if (ptclcsum(bp, UDP6_PHDR_OFF, len + UDP6_PHDR_SZ)) {
441                                 upriv->ustats.udpInErrors++;
442                                 netlog(f, Logudp, "udp: checksum error %I\n", raddr);
443                                 printd("udp: checksum error %I\n", raddr);
444                                 freeblist(bp);
445                                 return;
446                         }
447                         hnputl(uh6->viclfl, oviclfl);
448                         hnputs(uh6->len, olen);
449                         uh6->nextheader = IP_UDPPROTO;
450                         uh6->hoplimit = ottl;
451                         break;
452                 default:
453                         panic("udpiput: version %d", version);
454                         return; /* to avoid a warning */
455         }
456
457         c = iphtlook(&upriv->ht, raddr, rport, laddr, lport);
458         if (c == NULL) {
459                 /* no converstation found */
460                 upriv->ustats.udpNoPorts++;
461                 netlog(f, Logudp, "udp: no conv %I!%d -> %I!%d\n", raddr, rport,
462                            laddr, lport);
463
464                 switch (version) {
465                         case V4:
466                                 icmpnoconv(f, bp);
467                                 break;
468                         case V6:
469                                 icmphostunr(f, ifc, bp, icmp6_port_unreach, 0);
470                                 break;
471                         default:
472                                 panic("udpiput2: version %d", version);
473                 }
474
475                 freeblist(bp);
476                 return;
477         }
478
479         if (c->state == Bypass) {
480                 bypass_or_drop(c, bp);
481                 return;
482         }
483
484         ucb = (Udpcb *) c->ptcl;
485
486         if (c->state == Announced) {
487                 if (ucb->headers == 0) {
488                         /* create a new conversation */
489                         if (ipforme(f, laddr) != Runi) {
490                                 switch (version) {
491                                         case V4:
492                                                 v4tov6(laddr, ifc->lifc->local);
493                                                 break;
494                                         case V6:
495                                                 ipmove(laddr, ifc->lifc->local);
496                                                 break;
497                                         default:
498                                                 panic("udpiput3: version %d", version);
499                                 }
500                         }
501                         qlock(&udp->qlock);
502                         c = Fsnewcall(c, raddr, rport, laddr, lport, version);
503                         qunlock(&udp->qlock);
504                         if (c == NULL) {
505                                 freeblist(bp);
506                                 return;
507                         }
508                         iphtadd(&upriv->ht, c);
509                         ucb = (Udpcb *) c->ptcl;
510                 }
511         }
512
513         qlock(&c->qlock);
514
515         /*
516          * Trim the packet down to data size
517          */
518         len -= UDP_UDPHDR_SZ;
519         switch (version) {
520                 case V4:
521                         bp = trimblock(bp, UDP4_IPHDR_SZ + UDP_UDPHDR_SZ, len);
522                         break;
523                 case V6:
524                         bp = trimblock(bp, UDP6_IPHDR_SZ + UDP_UDPHDR_SZ, len);
525                         break;
526                 default:
527                         bp = NULL;
528                         panic("udpiput4: version %d", version);
529         }
530         if (bp == NULL) {
531                 qunlock(&c->qlock);
532                 netlog(f, Logudp, "udp: len err %I.%d -> %I.%d\n", raddr, rport,
533                            laddr, lport);
534                 upriv->lenerr++;
535                 return;
536         }
537
538         netlog(f, Logudpmsg, "udp: %I.%d -> %I.%d l %d\n", raddr, rport,
539                    laddr, lport, len);
540
541         switch (ucb->headers) {
542                 case 7:
543                         /* pass the src address */
544                         bp = padblock(bp, UDP_USEAD7);
545                         p = bp->rp;
546                         ipmove(p, raddr);
547                         p += IPaddrlen;
548                         ipmove(p, laddr);
549                         p += IPaddrlen;
550                         ipmove(p, ifc->lifc->local);
551                         p += IPaddrlen;
552                         hnputs(p, rport);
553                         p += 2;
554                         hnputs(p, lport);
555                         break;
556                 case 6:
557                         /* pass the src address */
558                         bp = padblock(bp, UDP_USEAD6);
559                         p = bp->rp;
560                         ipmove(p, raddr);
561                         p += IPaddrlen;
562                         ipmove(p, ipforme(f, laddr) == Runi ? laddr : ifc->lifc->local);
563                         p += IPaddrlen;
564                         hnputs(p, rport);
565                         p += 2;
566                         hnputs(p, lport);
567                         break;
568         }
569
570         if (bp->next)
571                 bp = concatblock(bp);
572
573         if (qfull(c->rq)) {
574                 qunlock(&c->qlock);
575                 netlog(f, Logudp, "udp: qfull %I.%d -> %I.%d\n", raddr, rport,
576                            laddr, lport);
577                 freeblist(bp);
578                 return;
579         }
580
581         qpass(c->rq, bp);
582         qunlock(&c->qlock);
583
584 }
585
586 static void udpctl(struct conv *c, char **f, int n)
587 {
588         Udpcb *ucb = (Udpcb*)c->ptcl;
589
590         if ((n == 1) && strcmp(f[0], "oldheaders") == 0)
591                 ucb->headers = 6;
592         else if ((n == 1) && strcmp(f[0], "headers") == 0)
593                 ucb->headers = 7;
594         else
595                 error(EINVAL, "unknown command to %s", __func__);
596 }
597
598 void udpadvise(struct Proto *udp, struct block *bp, char *msg)
599 {
600         Udp4hdr *h4;
601         Udp6hdr *h6;
602         uint8_t source[IPaddrlen], dest[IPaddrlen];
603         uint16_t psource, pdest;
604         struct conv *s, **p;
605         int version;
606
607         h4 = (Udp4hdr *) (bp->rp);
608         version = ((h4->vihl & 0xF0) == IP_VER6) ? V6 : V4;
609
610         switch (version) {
611                 case V4:
612                         v4tov6(dest, h4->udpdst);
613                         v4tov6(source, h4->udpsrc);
614                         psource = nhgets(h4->udpsport);
615                         pdest = nhgets(h4->udpdport);
616                         break;
617                 case V6:
618                         h6 = (Udp6hdr *) (bp->rp);
619                         ipmove(dest, h6->udpdst);
620                         ipmove(source, h6->udpsrc);
621                         psource = nhgets(h6->udpsport);
622                         pdest = nhgets(h6->udpdport);
623                         break;
624                 default:
625                         panic("udpadvise: version %d", version);
626                         return; /* to avoid a warning */
627         }
628
629         /* Look for a connection */
630         for (p = udp->conv; *p; p++) {
631                 s = *p;
632                 if (s->rport == pdest)
633                         if (s->lport == psource)
634                                 if (ipcmp(s->raddr, dest) == 0)
635                                         if (ipcmp(s->laddr, source) == 0) {
636                                                 if (s->ignoreadvice)
637                                                         break;
638                                                 qlock(&s->qlock);
639                                                 qhangup(s->rq, msg);
640                                                 qhangup(s->wq, msg);
641                                                 qunlock(&s->qlock);
642                                                 freeblist(bp);
643                                                 return;
644                                         }
645         }
646         freeblist(bp);
647 }
648
649 int udpstats(struct Proto *udp, char *buf, int len)
650 {
651         Udppriv *upriv;
652         char *p, *e;
653
654         upriv = udp->priv;
655         p = buf;
656         e = p + len;
657         p = seprintf(p, e, "InDatagrams: %u\n", upriv->ustats.udpInDatagrams);
658         p = seprintf(p, e, "NoPorts: %u\n", upriv->ustats.udpNoPorts);
659         p = seprintf(p, e, "InErrors: %u\n", upriv->ustats.udpInErrors);
660         p = seprintf(p, e, "OutDatagrams: %u\n", upriv->ustats.udpOutDatagrams);
661         return p - buf;
662 }
663
664 void udpinit(struct Fs *fs)
665 {
666         struct Proto *udp;
667
668         udp = kzmalloc(sizeof(struct Proto), 0);
669         udp->priv = kzmalloc(sizeof(Udppriv), 0);
670         udp->name = "udp";
671         udp->connect = udpconnect;
672         udp->announce = udpannounce;
673         udp->bypass = udpbypass;
674         udp->ctl = udpctl;
675         udp->state = udpstate;
676         udp->create = udpcreate;
677         udp->close = udpclose;
678         udp->rcv = udpiput;
679         udp->advise = udpadvise;
680         udp->stats = udpstats;
681         udp->ipproto = IP_UDPPROTO;
682         udp->nc = 4096;
683         udp->ptclsize = sizeof(Udpcb);
684
685         Fsproto(fs, udp);
686 }