rx-race-condition-cleanup-by-adding-busy-status-20010605
[openafs.git] / src / rx / rx_user.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
11
12 # include <afs/param.h>
13 # include <sys/types.h>
14 # include <errno.h>
15 # include <signal.h>
16 #ifdef AFS_NT40_ENV
17 # include <WINNT/syscfg.h>
18 #else
19 # include <sys/socket.h>
20 # include <sys/file.h>
21 # include <netdb.h>
22 # include <sys/stat.h>
23 # include <netinet/in.h>
24 # include <sys/time.h>
25 # include <net/if.h>
26 # include <sys/ioctl.h>
27 #endif
28 # include <fcntl.h>
29 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
30 # include <sys/syscall.h>
31 #endif
32 #include <afs/afs_args.h>
33 #include <afs/afsutil.h>
34
35 #ifndef IPPORT_USERRESERVED
36 /* If in.h doesn't define this, define it anyway.  Unfortunately, defining
37    this doesn't put the code into the kernel to restrict kernel assigned
38    port numbers to numbers below IPPORT_USERRESERVED...  */
39 #define IPPORT_USERRESERVED 5000
40 # endif
41
42 #ifndef AFS_NT40_ENV
43 # include <sys/time.h>
44 #endif
45 # include "rx.h"
46 # include "rx_globals.h"
47
48
49 extern void rxi_Delay();
50
51 #ifdef AFS_PTHREAD_ENV
52 #include <assert.h>
53
54 /*
55  * The rx_if_init_mutex mutex protects the following global variables:
56  * Inited
57  */
58
59 pthread_mutex_t rx_if_init_mutex;
60 #define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0);
61 #define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0);
62
63 /*
64  * The rx_if_mutex mutex protects the following global variables:
65  * myNetFlags
66  * myNetMTUs
67  * myNetMasks
68  */
69
70 pthread_mutex_t rx_if_mutex;
71 #define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0);
72 #define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0);
73 #else
74 #define LOCK_IF_INIT
75 #define UNLOCK_IF_INIT
76 #define LOCK_IF
77 #define UNLOCK_IF
78 #endif /* AFS_PTHREAD_ENV */
79
80
81 /*
82  * Make a socket for receiving/sending IP packets.  Set it into non-blocking
83  * and large buffering modes.  If port isn't specified, the kernel will pick
84  * one.  Returns the socket (>= 0) on success.  Returns OSI_NULLSOCKET on
85  * failure. Port must be in network byte order. 
86  */
87 osi_socket rxi_GetUDPSocket(u_short port)
88 {
89     int binds, code;
90     osi_socket socketFd = OSI_NULLSOCKET;
91     struct sockaddr_in taddr;
92     char *name = "rxi_GetUDPSocket: ";
93     extern int rxi_Listen(osi_socket sock);
94     int greedy;
95
96 #if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
97     if (ntohs(port) >= IPPORT_RESERVED && ntohs(port) < IPPORT_USERRESERVED) {
98 /*      (osi_Msg "%s*WARNING* port number %d is not a reserved port number.  Use port numbers above %d\n", name, port, IPPORT_USERRESERVED);
99 */ ;
100     }
101     if (ntohs(port) > 0 && ntohs(port) < IPPORT_RESERVED && geteuid() != 0) {
102         (osi_Msg "%sport number %d is a reserved port number which may only be used by root.  Use port numbers above %d\n", name, ntohs(port), IPPORT_USERRESERVED);
103         goto error;
104     }
105 #endif
106     socketFd = socket(AF_INET, SOCK_DGRAM, 0);
107
108     if (socketFd < 0) {
109         perror("socket");
110         goto error;
111     }
112
113     taddr.sin_addr.s_addr = 0;
114     taddr.sin_family = AF_INET;
115     taddr.sin_port = (u_short)port;
116 #define MAX_RX_BINDS 10
117     for (binds=0; binds<MAX_RX_BINDS; binds++) {
118       if (binds) rxi_Delay (10);
119       code = bind(socketFd, (struct sockaddr *) &taddr, sizeof(taddr));
120       if (!code) break;
121     }
122     if (code) {
123       perror("bind");
124       (osi_Msg "%sbind failed\n", name);
125       goto error;
126     }
127
128 #if !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
129     /*
130      * Set close-on-exec on rx socket 
131      */
132     fcntl(socketFd, F_SETFD, 1);
133 #endif
134
135     /* Use one of three different ways of getting a socket buffer expanded to
136      * a reasonable size.
137      */
138     {
139         int len1, len2;
140
141         len1 = 32766;
142         len2 = rx_UdpBufSize;
143 #ifndef AFS_DJGPP_ENV
144         greedy = 
145           (setsockopt(socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
146                       sizeof(len2)) >= 0);
147         if (!greedy) {
148           len2=32766;  /* fall back to old size... uh-oh! */
149         }
150
151         greedy =
152           (setsockopt(socketFd, SOL_SOCKET, SO_SNDBUF, (char *)&len1,
153                       sizeof(len1)) >= 0) &&
154           (setsockopt(socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2,
155                       sizeof(len2)) >= 0);
156 #endif /* AFS_DJGPP_ENV */
157     }
158
159 #ifndef AFS_DJGPP_ENV
160     if (!greedy)
161         (osi_Msg "%s*WARNING* Unable to increase buffering on socket\n", name);
162 #endif /* AFS_DJGPP_ENV */
163     if (rxi_Listen(socketFd) < 0) {
164         goto error;
165     }
166
167     return socketFd;
168
169 error:
170 #ifdef AFS_NT40_ENV
171     if (socketFd >= 0) closesocket(socketFd);
172 #else
173     if (socketFd >= 0) close(socketFd);
174 #endif
175
176     MUTEX_ENTER(&rx_stats_mutex);
177     rx_stats.socketGreedy = greedy;
178     MUTEX_EXIT(&rx_stats_mutex);
179     return OSI_NULLSOCKET;
180 }
181
182 void osi_Panic(msg, a1, a2, a3)
183     char *msg;
184 {
185     (osi_Msg "Fatal Rx error: ");
186     (osi_Msg msg, a1, a2, a3);
187     fflush(stderr);
188     fflush(stdout);
189     afs_abort();
190 }
191
192 /*
193  * osi_AssertFailU() -- used by the osi_Assert() macro.
194  */
195
196 void osi_AssertFailU(const char *expr, const char *file, int line)
197 {
198     osi_Panic("assertion failed: %s, file: %s, line: %d\n", expr, file, line);
199 }
200
201 #ifdef  AFS_AIX32_ENV
202 #ifndef osi_Alloc
203 static const char memZero;
204 char * osi_Alloc(x)
205     afs_int32 x; 
206 {
207     /* 
208      * 0-length allocs may return NULL ptr from osi_kalloc, so we special-case
209      * things so that NULL returned iff an error occurred 
210      */
211     if (x == 0) return &memZero;
212     return ((char *) malloc(x));
213 }
214
215 osi_Free(x, size)
216     char *x;
217     afs_int32 size; 
218 {
219     if (x == &memZero) return;
220     free((char *)x);
221 }
222 #endif
223 #endif /* AFS_AIX32_ENV */
224
225 #define ADDRSPERSITE    16
226
227
228 afs_uint32 rxi_NetAddrs[ADDRSPERSITE]; /* host order */
229 static int myNetMTUs[ADDRSPERSITE];
230 static int myNetMasks[ADDRSPERSITE];
231 static int myNetFlags[ADDRSPERSITE];
232 u_int rxi_numNetAddrs;
233 static int Inited = 0;
234
235 #if defined(AFS_NT40_ENV) || defined(AFS_DJGPP_ENV)
236 int rxi_getaddr(void)
237 {
238     if (rxi_numNetAddrs > 0)
239         return htonl(rxi_NetAddrs[0]);
240     else
241         return 0;
242 }
243
244 /* 
245 ** return number of addresses 
246 ** and the addresses themselves in the buffer
247 ** maxSize - max number of interfaces to return.
248 */
249 int rx_getAllAddr (afs_int32 *buffer, int maxSize)
250 {
251     int count = 0;
252     for (count = 0; count < rxi_numNetAddrs && maxSize > 0; count++, maxSize--)
253         buffer[count] = htonl(rxi_NetAddrs[count]);
254
255     return count;
256 }
257
258 #endif
259
260 #ifdef AFS_NT40_ENV
261
262 void rx_GetIFInfo(void)
263 {
264     LOCK_IF_INIT
265     if (Inited) {
266         UNLOCK_IF_INIT
267         return;
268     }
269     else {
270         u_int maxsize;
271         u_int rxsize;
272         int npackets, ncbufs;
273         afs_uint32 i;
274
275         Inited = 1;
276         UNLOCK_IF_INIT
277         rxi_numNetAddrs = ADDRSPERSITE;
278
279         LOCK_IF
280         (void) syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs,
281                                 myNetMasks, myNetMTUs, myNetFlags);
282
283         for (i=0; i<rxi_numNetAddrs; i++) {
284             rxsize = rxi_AdjustIfMTU(myNetMTUs[i] - RX_IPUDP_SIZE);
285             maxsize = rxi_nRecvFrags*rxsize + (rxi_nRecvFrags-1)*UDP_HDR_SIZE;
286             maxsize = rxi_AdjustMaxMTU(rxsize, maxsize);
287             if (rx_maxReceiveSize < maxsize)  {
288                 rx_maxReceiveSize = MIN( RX_MAX_PACKET_SIZE, maxsize);
289                 rx_maxReceiveSize = MIN( rx_maxReceiveSize,
290                                          rx_maxReceiveSizeUser);
291             }
292
293         }
294         UNLOCK_IF
295         ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
296         if (ncbufs > 0) {
297             ncbufs = ncbufs / RX_CBUFFERSIZE;
298             npackets = rx_initSendWindow -1;
299             rxi_MorePackets(npackets*(ncbufs+1));
300         }
301     }
302 }
303     
304 #endif
305
306 static afs_uint32 fudge_netmask(addr) 
307 afs_uint32 addr;
308 {
309 afs_uint32 msk;
310
311     if (IN_CLASSA(addr)) msk = IN_CLASSA_NET;
312     else if (IN_CLASSB(addr)) msk = IN_CLASSB_NET;
313     else if (IN_CLASSC(addr)) msk = IN_CLASSC_NET;
314     else msk = 0;
315
316 return msk;
317 }
318
319
320
321 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DJGPP_ENV)
322 int rxi_syscall(a3, a4, a5)
323 afs_uint32 a3, a4;
324 void * a5;
325 {
326   afs_uint32 rcode;
327   void (*old)();
328         
329   old = (void (*)())signal(SIGSYS, SIG_IGN);    
330
331 #if defined(AFS_SGI_ENV)
332   rcode = afs_syscall(a3, a4, a5);
333 #else
334   rcode = syscall (AFS_SYSCALL, 28 /* AFSCALL_CALL */, a3, a4, a5);
335 #endif /* AFS_SGI_ENV */
336
337   signal(SIGSYS, old);  
338
339 return rcode;
340 }
341 #endif /* AFS_AIX_ENV */
342
343 #ifndef AFS_NT40_ENV
344 void rx_GetIFInfo()
345 {
346     int     s;
347     int     i, j, len, res;
348 #ifndef AFS_DJGPP_ENV
349     struct ifconf   ifc;
350     struct ifreq    ifs[ADDRSPERSITE];
351     struct ifreq ifreq, *ifr;
352 #ifdef  AFS_AIX41_ENV
353     char buf[BUFSIZ], *cp, *cplim;
354 #endif
355     struct sockaddr_in *a;
356 #endif /* AFS_DJGPP_ENV */
357
358     LOCK_IF_INIT
359     if (Inited) {
360       UNLOCK_IF_INIT
361       return;
362     }
363     Inited = 1;
364     UNLOCK_IF_INIT
365
366     LOCK_IF
367     rxi_numNetAddrs = 0;
368     bzero(rxi_NetAddrs, sizeof(rxi_NetAddrs));
369     bzero(myNetFlags, sizeof(myNetFlags));
370     bzero(myNetMTUs, sizeof(myNetMTUs));
371     bzero(myNetMasks, sizeof(myNetMasks));
372     UNLOCK_IF
373
374     s = socket(AF_INET, SOCK_DGRAM, 0);
375     if (s < 0) return;
376
377 #ifndef AFS_DJGPP_ENV
378 #ifdef  AFS_AIX41_ENV
379     ifc.ifc_len = sizeof (buf);
380     ifc.ifc_buf = buf;
381     ifr = ifc.ifc_req;
382 #else
383     ifc.ifc_len = sizeof(ifs);
384     ifc.ifc_buf = (caddr_t) &ifs[0];
385     bzero(&ifs[0], sizeof(ifs));
386 #endif 
387     res = ioctl(s, SIOCGIFCONF, &ifc);
388     if (res < 0) {
389       /* fputs(stderr, "ioctl error IFCONF\n"); */
390       close(s);
391       return;
392     }
393
394     LOCK_IF
395
396 #ifdef  AFS_AIX41_ENV
397 #define size(p) MAX((p).sa_len, sizeof(p))
398     cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
399     for (cp = buf; cp < cplim ;
400          cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))) {
401         if (rxi_numNetAddrs >= ADDRSPERSITE)
402             break;
403
404         ifr = (struct ifreq *)cp;
405 #else
406     len = ifc.ifc_len / sizeof(struct ifreq);
407     if (len > ADDRSPERSITE)
408       len = ADDRSPERSITE;
409
410     for (i = 0; i < len; ++i) {
411         ifr = &ifs[i];
412         res = ioctl(s, SIOCGIFADDR, ifr);
413 #endif
414         if (res < 0) {
415           /* fputs(stderr, "ioctl error IFADDR\n");
416             perror(ifr->ifr_name);   */
417           continue;
418         }
419         a = (struct sockaddr_in *) &ifr->ifr_addr;
420         if (a->sin_family != AF_INET) continue;
421         rxi_NetAddrs[rxi_numNetAddrs] = ntohl(a->sin_addr.s_addr);
422         if (rxi_NetAddrs[rxi_numNetAddrs] == 0x7f000001) {
423           /* we don't really care about "localhost" */
424           continue;
425         }
426         for (j=0; j < rxi_numNetAddrs; j++) {
427            if (rxi_NetAddrs[j] == rxi_NetAddrs[rxi_numNetAddrs])
428               break;
429         }
430         if (j < rxi_numNetAddrs) continue;
431
432         /* fprintf(stderr, "if %s addr=%x\n", ifr->ifr_name,
433                 rxi_NetAddrs[rxi_numNetAddrs]); */
434
435 #ifdef SIOCGIFFLAGS
436         res = ioctl(s, SIOCGIFFLAGS, ifr);
437         if (res == 0) {
438             myNetFlags[rxi_numNetAddrs] = ifr->ifr_flags;
439 #ifdef IFF_LOOPBACK
440             /* Handle aliased loopbacks as well. */
441             if (ifr->ifr_flags & IFF_LOOPBACK)
442                 continue;
443 #endif
444             /* fprintf(stderr, "if %s flags=%x\n", 
445                     ifr->ifr_name, ifr->ifr_flags); */
446         }
447         else { /*
448           fputs(stderr, "ioctl error IFFLAGS\n");
449           perror(ifr->ifr_name); */
450         }
451 #endif /* SIOCGIFFLAGS */
452
453 #if !defined(AFS_AIX_ENV)  && !defined(AFS_LINUX20_ENV)
454         /* this won't run on an AIX system w/o a cache manager */
455         rxi_syscallp = rxi_syscall;
456 #endif
457
458         /* If I refer to kernel extensions that aren't loaded on AIX, the 
459          * program refuses to load and run, so I simply can't include the 
460          * following code.  Fortunately, AIX is the one operating system in
461          * which the subsequent ioctl works reliably. */
462         if (rxi_syscallp) {
463           if ((*rxi_syscallp)( 20 /*AFSOP_GETMTU*/,  
464                               htonl(rxi_NetAddrs[rxi_numNetAddrs]),
465                               &(myNetMTUs[rxi_numNetAddrs]))) {
466             /* fputs(stderr, "syscall error GETMTU\n");
467                perror(ifr->ifr_name); */
468             myNetMTUs[rxi_numNetAddrs] = 0;
469           }
470           if ((*rxi_syscallp)(42 /*AFSOP_GETMASK*/,  
471                               htonl(rxi_NetAddrs[rxi_numNetAddrs]),
472                               &(myNetMasks[rxi_numNetAddrs]))) {
473             /* fputs(stderr, "syscall error GETMASK\n");
474                perror(ifr->ifr_name); */
475             myNetMasks[rxi_numNetAddrs] = 0;
476           }
477           else myNetMasks[rxi_numNetAddrs] = ntohl( myNetMasks[rxi_numNetAddrs]);
478            /* fprintf(stderr, "if %s mask=0x%x\n", 
479              ifr->ifr_name, myNetMasks[rxi_numNetAddrs]);*/
480         }
481
482         if (myNetMTUs[rxi_numNetAddrs] == 0) {
483           myNetMTUs[rxi_numNetAddrs] = OLD_MAX_PACKET_SIZE + RX_IPUDP_SIZE;
484 #ifdef SIOCGIFMTU
485           res = ioctl(s, SIOCGIFMTU, ifr);
486           if ((res == 0) && (ifr->ifr_metric > 128))  { /* sanity check */
487             myNetMTUs[rxi_numNetAddrs] = ifr->ifr_metric;
488             /* fprintf(stderr, "if %s mtu=%d\n", 
489                     ifr->ifr_name, ifr->ifr_metric); */
490           }
491           else {
492             /* fputs(stderr, "ioctl error IFMTU\n");
493                perror(ifr->ifr_name); */
494           }
495 #endif
496         }
497
498         if (myNetMasks[rxi_numNetAddrs] == 0) {
499           myNetMasks[rxi_numNetAddrs] = fudge_netmask(rxi_NetAddrs[rxi_numNetAddrs]);
500 #ifdef SIOCGIFNETMASK
501           res = ioctl(s, SIOCGIFNETMASK, ifr);
502           if ((res == 0)) {
503             a = (struct sockaddr_in *) &ifr->ifr_addr;
504             myNetMasks[rxi_numNetAddrs] = ntohl(a->sin_addr.s_addr);
505             /* fprintf(stderr, "if %s subnetmask=0x%x\n", 
506                     ifr->ifr_name, myNetMasks[rxi_numNetAddrs]); */
507           }
508           else {
509             /* fputs(stderr, "ioctl error IFMASK\n");
510                perror(ifr->ifr_name); */
511           }
512 #endif
513         }
514
515         if (rxi_NetAddrs[rxi_numNetAddrs] != 0x7f000001) { /* ignore lo0 */
516            int maxsize;
517            maxsize = rxi_nRecvFrags*(myNetMTUs[rxi_numNetAddrs] - RX_IP_SIZE);
518            maxsize -= UDP_HDR_SIZE; /* only the first frag has a UDP hdr */
519            if (rx_maxReceiveSize < maxsize) 
520                 rx_maxReceiveSize = MIN( RX_MAX_PACKET_SIZE, maxsize);
521            ++rxi_numNetAddrs;
522         }
523     }
524     UNLOCK_IF
525     close(s);
526
527     /* have to allocate at least enough to allow a single packet to reach its
528      * maximum size, so ReadPacket will work.  Allocate enough for a couple
529      * of packets to do so, for good measure */
530     {
531       int npackets, ncbufs;
532
533       rx_maxJumboRecvSize = RX_HEADER_SIZE
534                             + rxi_nDgramPackets * RX_JUMBOBUFFERSIZE
535                             + (rxi_nDgramPackets-1) * RX_JUMBOHEADERSIZE;
536       rx_maxJumboRecvSize = MAX(rx_maxJumboRecvSize, rx_maxReceiveSize);
537       ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
538       if (ncbufs > 0) {
539         ncbufs = ncbufs / RX_CBUFFERSIZE;
540         npackets = rx_initSendWindow -1;
541         rxi_MorePackets(npackets*(ncbufs+1));
542       }
543     }
544 #else /* AFS_DJGPP_ENV */
545     close(s);
546     return;
547 #endif /* AFS_DJGPP_ENV */
548 }
549 #endif /* AFS_NT40_ENV */
550
551 /* Called from rxi_FindPeer, when initializing a clear rx_peer structure,
552  * to get interesting information.
553  * Curiously enough, the rx_peerHashTable_lock currently protects the
554  * Inited variable (and hence rx_GetIFInfo). When the fs suite uses
555  * pthreads, this issue will need to be revisited.
556  */
557
558 void rxi_InitPeerParams(struct rx_peer *pp)
559 {
560     afs_uint32 ppaddr;
561     u_short rxmtu;
562     int ix;
563
564
565
566     LOCK_IF_INIT
567     if (!Inited) {
568         UNLOCK_IF_INIT
569         /*
570          * there's a race here since more than one thread could call
571          * rx_GetIFInfo.  The race stops in rx_GetIFInfo.
572          */
573         rx_GetIFInfo();
574     } else {
575         UNLOCK_IF_INIT
576     }
577
578 #ifdef ADAPT_MTU
579     /* try to second-guess IP, and identify which link is most likely to
580      * be used for traffic to/from this host. */
581     ppaddr = ntohl(pp->host);
582
583     pp->ifMTU = 0;
584     pp->timeout.sec = 2;
585     pp->rateFlag = 2;   /* start timing after two full packets */
586     /* I don't initialize these, because I presume they are bzero'd... 
587      * pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec
588      * pp->timeout.usec */
589   
590     LOCK_IF
591     for (ix = 0; ix < rxi_numNetAddrs; ++ix) {
592       if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) {
593 #ifdef IFF_POINTOPOINT
594         if (myNetFlags[ix] & IFF_POINTOPOINT) 
595            pp->timeout.sec = 4;
596 #endif /* IFF_POINTOPOINT */
597         rxmtu = myNetMTUs[ix] - RX_IPUDP_SIZE;
598         if ( rxmtu < RX_MIN_PACKET_SIZE ) 
599           rxmtu = RX_MIN_PACKET_SIZE ;
600         if (pp->ifMTU < rxmtu) 
601           pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu);
602       }
603     }
604     UNLOCK_IF
605
606     if (!pp->ifMTU) { /* not local */
607         pp->timeout.sec = 3;
608         pp->ifMTU = RX_REMOTE_PACKET_SIZE;
609     }
610 #else /* ADAPT_MTU */
611     pp->rateFlag = 2;   /* start timing after two full packets */
612     pp->timeout.sec = 2;
613     pp->ifMTU = OLD_MAX_PACKET_SIZE;
614 #endif /* ADAPT_MTU */
615     pp->ifMTU = rxi_AdjustIfMTU(pp->ifMTU);
616     pp->maxMTU = OLD_MAX_PACKET_SIZE;  /* for compatibility with old guys */
617     pp->natMTU = MIN((int)pp->ifMTU, OLD_MAX_PACKET_SIZE); 
618     pp->maxDgramPackets = MIN(rxi_nDgramPackets,
619                               rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
620     pp->ifDgramPackets = MIN(rxi_nDgramPackets,
621                              rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
622     pp->maxDgramPackets = 1;
623     /* Initialize slow start parameters */
624     pp->MTU = MIN(pp->natMTU, pp->maxMTU);
625     pp->cwind = 1;
626     pp->nDgramPackets = 1;
627     pp->congestSeq = 0;
628 }
629
630 /* Don't expose jumobgram internals. */
631 void rx_SetNoJumbo(void)
632 {
633     rx_maxReceiveSize = OLD_MAX_PACKET_SIZE;
634     rxi_nSendFrags = rxi_nRecvFrags = 1;
635 }