]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/ppp/ether.c
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / usr.sbin / ppp / ether.c
1 /*-
2  * Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #include <sys/param.h>
30 #include <sys/socket.h>
31 #include <sys/un.h>
32 #include <netinet/in.h>
33 #include <arpa/inet.h>
34 #include <netdb.h>
35 #include <netgraph.h>
36 #include <net/ethernet.h>
37 #include <netinet/in_systm.h>
38 #include <netinet/ip.h>
39 #include <netgraph/ng_ether.h>
40 #include <netgraph/ng_message.h>
41 #include <netgraph/ng_pppoe.h>
42 #include <netgraph/ng_socket.h>
43
44 #include <errno.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <sysexits.h>
49 #include <sys/fcntl.h>
50 #if defined(__FreeBSD__) && !defined(NOKLDLOAD)
51 #include <sys/linker.h>
52 #include <sys/module.h>
53 #endif
54 #include <sys/uio.h>
55 #include <termios.h>
56 #include <sys/time.h>
57 #include <unistd.h>
58
59 #include "layer.h"
60 #include "defs.h"
61 #include "mbuf.h"
62 #include "log.h"
63 #include "timer.h"
64 #include "lqr.h"
65 #include "hdlc.h"
66 #include "throughput.h"
67 #include "fsm.h"
68 #include "lcp.h"
69 #include "ccp.h"
70 #include "link.h"
71 #include "async.h"
72 #include "descriptor.h"
73 #include "physical.h"
74 #include "main.h"
75 #include "mp.h"
76 #include "chat.h"
77 #include "auth.h"
78 #include "chap.h"
79 #include "cbcp.h"
80 #include "datalink.h"
81 #include "slcompress.h"
82 #include "iplist.h"
83 #include "ipcp.h"
84 #include "filter.h"
85 #ifndef NORADIUS
86 #include "radius.h"
87 #endif
88 #include "bundle.h"
89 #include "id.h"
90 #include "ether.h"
91
92
93 #define PPPOE_NODE_TYPE_LEN (sizeof NG_PPPOE_NODE_TYPE - 1) /* "PPPoE" */
94
95 struct etherdevice {
96   struct device dev;                    /* What struct physical knows about */
97   int cs;                               /* Control socket */
98   int connected;                        /* Are we connected yet ? */
99   int timeout;                          /* Seconds attempting to connect */
100   char hook[sizeof TUN_NAME + 11];      /* Our socket node hook */
101 };
102
103 #define device2ether(d) \
104   ((d)->type == ETHER_DEVICE ? (struct etherdevice *)d : NULL)
105
106 int
107 ether_DeviceSize(void)
108 {
109   return sizeof(struct etherdevice);
110 }
111
112 static ssize_t
113 ether_Write(struct physical *p, const void *v, size_t n)
114 {
115   struct etherdevice *dev = device2ether(p->handler);
116
117   return NgSendData(p->fd, dev->hook, v, n) == -1 ? -1 : n;
118 }
119
120 static ssize_t
121 ether_Read(struct physical *p, void *v, size_t n)
122 {
123   char hook[sizeof TUN_NAME + 11];
124
125   return NgRecvData(p->fd, v, n, hook);
126 }
127
128 static int
129 ether_RemoveFromSet(struct physical *p, fd_set *r, fd_set *w, fd_set *e)
130 {
131   struct etherdevice *dev = device2ether(p->handler);
132   int result;
133
134   if (r && dev->cs >= 0 && FD_ISSET(dev->cs, r)) {
135     FD_CLR(dev->cs, r);
136     log_Printf(LogTIMER, "%s: fdunset(ctrl) %d\n", p->link.name, dev->cs);
137     result = 1;
138   } else
139     result = 0;
140
141   /* Careful... physical_RemoveFromSet() called us ! */
142
143   p->handler->removefromset = NULL;
144   result += physical_RemoveFromSet(p, r, w, e);
145   p->handler->removefromset = ether_RemoveFromSet;
146
147   return result;
148 }
149
150 static void
151 ether_Free(struct physical *p)
152 {
153   struct etherdevice *dev = device2ether(p->handler);
154
155   physical_SetDescriptor(p);
156   if (dev->cs != -1)
157     close(dev->cs);
158   free(dev);
159 }
160
161 static const char *
162 ether_OpenInfo(struct physical *p)
163 {
164   struct etherdevice *dev = device2ether(p->handler);
165
166   switch (dev->connected) {
167     case CARRIER_PENDING:
168       return "negotiating";
169     case CARRIER_OK:
170       return "established";
171   }
172
173   return "disconnected";
174 }
175
176 static void
177 ether_device2iov(struct device *d, struct iovec *iov, int *niov,
178                  int maxiov, int *auxfd, int *nauxfd)
179 {
180   struct etherdevice *dev = device2ether(d);
181   int sz = physical_MaxDeviceSize();
182
183   iov[*niov].iov_base = realloc(d, sz);
184   if (iov[*niov].iov_base == NULL) {
185     log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
186     AbortProgram(EX_OSERR);
187   }
188   iov[*niov].iov_len = sz;
189   (*niov)++;
190
191   if (dev->cs >= 0) {
192     *auxfd = dev->cs;
193     (*nauxfd)++;
194   }
195 }
196
197 static void
198 ether_MessageIn(struct etherdevice *dev)
199 {
200   char msgbuf[sizeof(struct ng_mesg) + sizeof(struct ngpppoe_sts)];
201   struct ng_mesg *rep = (struct ng_mesg *)msgbuf;
202   struct ngpppoe_sts *sts = (struct ngpppoe_sts *)(msgbuf + sizeof *rep);
203   char unknown[14];
204   const char *msg;
205   struct timeval t;
206   fd_set r;
207
208   if (dev->cs < 0)
209     return;
210
211   FD_ZERO(&r);
212   FD_SET(dev->cs, &r);
213   t.tv_sec = t.tv_usec = 0;
214   if (select(dev->cs + 1, &r, NULL, NULL, &t) <= 0)
215     return;
216
217   if (NgRecvMsg(dev->cs, rep, sizeof msgbuf, NULL) < 0)
218     return;
219
220   if (rep->header.version != NG_VERSION) {
221     log_Printf(LogWARN, "%ld: Unexpected netgraph version, expected %ld\n",
222                (long)rep->header.version, (long)NG_VERSION);
223     return;
224   }
225
226   if (rep->header.typecookie != NGM_PPPOE_COOKIE) {
227     log_Printf(LogWARN, "%ld: Unexpected netgraph cookie, expected %ld\n",
228                (long)rep->header.typecookie, (long)NGM_PPPOE_COOKIE);
229     return;
230   }
231
232   switch (rep->header.cmd) {
233     case NGM_PPPOE_SET_FLAG:    msg = "SET_FLAG";       break;
234     case NGM_PPPOE_CONNECT:     msg = "CONNECT";        break;
235     case NGM_PPPOE_LISTEN:      msg = "LISTEN";         break;
236     case NGM_PPPOE_OFFER:       msg = "OFFER";          break;
237     case NGM_PPPOE_SUCCESS:     msg = "SUCCESS";        break;
238     case NGM_PPPOE_FAIL:        msg = "FAIL";           break;
239     case NGM_PPPOE_CLOSE:       msg = "CLOSE";          break;
240     case NGM_PPPOE_GET_STATUS:  msg = "GET_STATUS";     break;
241     default:
242       snprintf(unknown, sizeof unknown, "<%d>", (int)rep->header.cmd);
243       msg = unknown;
244       break;
245   }
246
247   log_Printf(LogPHASE, "Received NGM_PPPOE_%s (hook \"%s\")\n", msg, sts->hook);
248
249   switch (rep->header.cmd) {
250     case NGM_PPPOE_SUCCESS:
251       dev->connected = CARRIER_OK;
252       break;
253     case NGM_PPPOE_FAIL:
254     case NGM_PPPOE_CLOSE:
255       dev->connected = CARRIER_LOST;
256       break;
257   }
258 }
259
260 static int
261 ether_AwaitCarrier(struct physical *p)
262 {
263   struct etherdevice *dev = device2ether(p->handler);
264
265   if (dev->connected != CARRIER_OK && !dev->timeout--)
266     dev->connected = CARRIER_LOST;
267   else if (dev->connected == CARRIER_PENDING)
268     ether_MessageIn(dev);
269
270   return dev->connected;
271 }
272
273 static const struct device baseetherdevice = {
274   ETHER_DEVICE,
275   "ether",
276   { CD_REQUIRED, DEF_ETHERCDDELAY },
277   ether_AwaitCarrier,
278   ether_RemoveFromSet,
279   NULL,
280   NULL,
281   NULL,
282   NULL,
283   ether_Free,
284   ether_Read,
285   ether_Write,
286   ether_device2iov,
287   NULL,
288   ether_OpenInfo
289 };
290
291 struct device *
292 ether_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
293                  int maxiov, int *auxfd, int *nauxfd)
294 {
295   if (type == ETHER_DEVICE) {
296     struct etherdevice *dev = (struct etherdevice *)iov[(*niov)++].iov_base;
297
298     dev = realloc(dev, sizeof *dev);    /* Reduce to the correct size */
299     if (dev == NULL) {
300       log_Printf(LogALERT, "Failed to allocate memory: %d\n",
301                  (int)(sizeof *dev));
302       AbortProgram(EX_OSERR);
303     }
304
305     if (*nauxfd) {
306       dev->cs = *auxfd;
307       (*nauxfd)--;
308     } else
309       dev->cs = -1;
310
311     /* Refresh function pointers etc */
312     memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
313
314     physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
315     return &dev->dev;
316   }
317
318   return NULL;
319 }
320
321 static int
322 ether_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
323 {
324   struct physical *p = descriptor2physical(d);
325   struct etherdevice *dev = device2ether(p->handler);
326   int result;
327
328   if (r && dev->cs >= 0) {
329     FD_SET(dev->cs, r);
330     log_Printf(LogTIMER, "%s(ctrl): fdset(r) %d\n", p->link.name, dev->cs);
331     result = 1;
332   } else
333     result = 0;
334
335   result += physical_doUpdateSet(d, r, w, e, n, 0);
336
337   return result;
338 }
339
340 static int
341 ether_IsSet(struct fdescriptor *d, const fd_set *fdset)
342 {
343   struct physical *p = descriptor2physical(d);
344   struct etherdevice *dev = device2ether(p->handler);
345   int result;
346
347   result = dev->cs >= 0 && FD_ISSET(dev->cs, fdset);
348   result += physical_IsSet(d, fdset);
349
350   return result;
351 }
352
353 static void
354 ether_DescriptorRead(struct fdescriptor *d, struct bundle *bundle,
355                      const fd_set *fdset)
356 {
357   struct physical *p = descriptor2physical(d);
358   struct etherdevice *dev = device2ether(p->handler);
359
360   if (dev->cs >= 0 && FD_ISSET(dev->cs, fdset)) {
361     ether_MessageIn(dev);
362     if (dev->connected == CARRIER_LOST) {
363       log_Printf(LogPHASE, "%s: Device disconnected\n", p->link.name);
364       datalink_Down(p->dl, CLOSE_NORMAL);
365       return;
366     }
367   }
368
369   if (physical_IsSet(d, fdset))
370     physical_DescriptorRead(d, bundle, fdset);
371 }
372
373 static struct device *
374 ether_Abandon(struct etherdevice *dev, struct physical *p)
375 {
376   /* Abandon our node construction */
377   close(dev->cs);
378   close(p->fd);
379   p->fd = -2;   /* Nobody else need try.. */
380   free(dev);
381
382   return NULL;
383 }
384
385 struct device *
386 ether_Create(struct physical *p)
387 {
388   u_char rbuf[2048];
389   struct etherdevice *dev;
390   struct ng_mesg *resp;
391   const struct hooklist *hlist;
392   const struct nodeinfo *ninfo;
393   int f;
394
395   dev = NULL;
396   if (p->fd < 0 && !strncasecmp(p->name.full, NG_PPPOE_NODE_TYPE,
397                                 PPPOE_NODE_TYPE_LEN) &&
398       p->name.full[PPPOE_NODE_TYPE_LEN] == ':') {
399     const struct linkinfo *nlink;
400     struct ngpppoe_init_data *data;
401     struct ngm_mkpeer mkp;
402     struct ngm_connect ngc;
403     const char *iface, *provider;
404     char *path, etherid[12];
405     int ifacelen, providerlen;
406     char connectpath[sizeof dev->hook + 2];     /* .:<hook> */
407
408     p->fd--;                            /* We own the device - change fd */
409
410 #if defined(__FreeBSD__) && !defined(NOKLDLOAD)
411     if (modfind("netgraph") == -1) {
412       log_Printf(LogWARN, "Netgraph is not built into the kernel\n");
413       return NULL;
414     }
415
416     if (modfind("ng_socket") == -1 &&
417         ID0kldload("ng_socket") == -1) {
418       log_Printf(LogWARN, "kldload: ng_socket: %s\n", strerror(errno));
419       return NULL;
420     }
421 #endif
422
423     if ((dev = malloc(sizeof *dev)) == NULL)
424       return NULL;
425
426     iface = p->name.full + PPPOE_NODE_TYPE_LEN + 1;
427
428     provider = strchr(iface, ':');
429     if (provider) {
430       ifacelen = provider - iface;
431       provider++;
432       providerlen = strlen(provider);
433     } else {
434       ifacelen = strlen(iface);
435       provider = "";
436       providerlen = 0;
437     }
438
439     /*
440      * We're going to do this (where tunN is our tunnel device):
441      *
442      * .---------.
443      * |  ether  |
444      * | <iface> |                         dev->cs
445      * `---------'                           |
446      *  (orphan)                     p->fd   |
447      *     |                           |     |
448      *     |                           |     |
449      * (ethernet)                      |     |
450      * .---------.                  .-----------.
451      * |  pppoe  |                  |  socket   |
452      * | <iface> |(tunN)<---->(tunN)| <unnamed> |
453      * `---------                   `-----------'
454      *   (tunX)
455      *     ^
456      *     |
457      *     `--->(tunX)
458      */
459
460     /* Create a socket node */
461     if (ID0NgMkSockNode(NULL, &dev->cs, &p->fd) == -1) {
462       log_Printf(LogWARN, "Cannot create netgraph socket node: %s\n",
463                  strerror(errno));
464       free(dev);
465       return NULL;
466     }
467
468     /*
469      * Ask for a list of hooks attached to the "ether" node.  This node should
470      * magically exist as a way of hooking stuff onto an ethernet device
471      */
472     path = (char *)alloca(ifacelen + 2);
473     sprintf(path, "%.*s:", ifacelen, iface);
474     if (NgSendMsg(dev->cs, path, NGM_GENERIC_COOKIE, NGM_LISTHOOKS,
475                   NULL, 0) < 0) {
476       log_Printf(LogWARN, "%s Cannot send a netgraph message: %s\n",
477                  path, strerror(errno));
478       return ether_Abandon(dev, p);
479     }
480
481     /* Get our list back */
482     resp = (struct ng_mesg *)rbuf;
483     if (NgRecvMsg(dev->cs, resp, sizeof rbuf, NULL) < 0) {
484       log_Printf(LogWARN, "Cannot get netgraph response: %s\n",
485                  strerror(errno));
486       return ether_Abandon(dev, p);
487     }
488
489     hlist = (const struct hooklist *)resp->data;
490     ninfo = &hlist->nodeinfo;
491
492     /* Make sure we've got the right type of node */
493     if (strncmp(ninfo->type, NG_ETHER_NODE_TYPE,
494                 sizeof NG_ETHER_NODE_TYPE - 1)) {
495       log_Printf(LogWARN, "%s Unexpected node type ``%s'' (wanted ``"
496                  NG_ETHER_NODE_TYPE "'')\n", path, ninfo->type);
497       return ether_Abandon(dev, p);
498     }
499
500     log_Printf(LogDEBUG, "List of netgraph node ``%s'' (id %x) hooks:\n",
501                path, ninfo->id);
502
503     /* look for a hook already attached.  */
504     for (f = 0; f < ninfo->hooks; f++) {
505       nlink = &hlist->link[f];
506
507       log_Printf(LogDEBUG, "  Found %s -> %s\n", nlink->ourhook,
508                  nlink->peerhook);
509
510       if (!strcmp(nlink->ourhook, NG_ETHER_HOOK_ORPHAN) ||
511           !strcmp(nlink->ourhook, NG_ETHER_HOOK_DIVERT)) {
512         /*
513          * Something is using the data coming out of this ``ether'' node.
514          * If it's a PPPoE node, we use that node, otherwise we complain that
515          * someone else is using the node.
516          */
517         if (!strcmp(nlink->nodeinfo.type, NG_PPPOE_NODE_TYPE))
518           /* Use this PPPoE node ! */
519           snprintf(ngc.path, sizeof ngc.path, "[%x]:", nlink->nodeinfo.id);
520         else {
521           log_Printf(LogWARN, "%s Node type ``%s'' is currently active\n",
522                      path, nlink->nodeinfo.type);
523           return ether_Abandon(dev, p);
524         }
525         break;
526       }
527     }
528
529     if (f == ninfo->hooks) {
530       /*
531        * Create a new ``PPPoE'' node connected to the ``ether'' node using
532        * the magic ``orphan'' and ``ethernet'' hooks
533        */
534       snprintf(mkp.type, sizeof mkp.type, "%s", NG_PPPOE_NODE_TYPE);
535       snprintf(mkp.ourhook, sizeof mkp.ourhook, "%s", NG_ETHER_HOOK_ORPHAN);
536       snprintf(mkp.peerhook, sizeof mkp.peerhook, "%s", NG_PPPOE_HOOK_ETHERNET);
537       snprintf(etherid, sizeof etherid, "[%x]:", ninfo->id);
538
539       log_Printf(LogDEBUG, "Creating PPPoE netgraph node %s%s -> %s\n",
540                  etherid, mkp.ourhook, mkp.peerhook);
541
542       if (NgSendMsg(dev->cs, etherid, NGM_GENERIC_COOKIE,
543                     NGM_MKPEER, &mkp, sizeof mkp) < 0) {
544         log_Printf(LogWARN, "%s Cannot create PPPoE netgraph node: %s\n",
545                    etherid, strerror(errno));
546         return ether_Abandon(dev, p);
547       }
548
549       snprintf(ngc.path, sizeof ngc.path, "%s%s", path, NG_ETHER_HOOK_ORPHAN);
550     }
551
552     snprintf(dev->hook, sizeof dev->hook, "%s%d",
553              TUN_NAME, p->dl->bundle->unit);
554
555     /*
556      * Connect the PPPoE node to our socket node.
557      * ngc.path has already been set up
558      */
559     snprintf(ngc.ourhook, sizeof ngc.ourhook, "%s", dev->hook);
560     memcpy(ngc.peerhook, ngc.ourhook, sizeof ngc.peerhook);
561
562     log_Printf(LogDEBUG, "Connecting netgraph socket .:%s -> %s:%s\n",
563                ngc.ourhook, ngc.path, ngc.peerhook);
564     if (NgSendMsg(dev->cs, ".:", NGM_GENERIC_COOKIE,
565                   NGM_CONNECT, &ngc, sizeof ngc) < 0) {
566       log_Printf(LogWARN, "Cannot connect PPPoE and socket netgraph "
567                  "nodes: %s\n", strerror(errno));
568       return ether_Abandon(dev, p);
569     }
570
571     /* And finally, request a connection to the given provider */
572
573     data = (struct ngpppoe_init_data *)alloca(sizeof *data + providerlen + 1);
574
575     snprintf(data->hook, sizeof data->hook, "%s", dev->hook);
576     strcpy(data->data, provider);
577     data->data_len = providerlen;
578
579     snprintf(connectpath, sizeof connectpath, ".:%s", dev->hook);
580     log_Printf(LogDEBUG, "Sending PPPOE_CONNECT to %s\n", connectpath);
581     if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE,
582                   NGM_PPPOE_CONNECT, data, sizeof *data + providerlen) == -1) {
583       log_Printf(LogWARN, "``%s'': Cannot start netgraph node: %s\n",
584                  connectpath, strerror(errno));
585       return ether_Abandon(dev, p);
586     }
587
588     /* Hook things up so that we monitor dev->cs */
589     p->desc.UpdateSet = ether_UpdateSet;
590     p->desc.IsSet = ether_IsSet;
591     p->desc.Read = ether_DescriptorRead;
592
593     memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
594     switch (p->cfg.cd.necessity) {
595       case CD_VARIABLE:
596         dev->dev.cd.delay = p->cfg.cd.delay;
597         break;
598       case CD_REQUIRED:
599         dev->dev.cd = p->cfg.cd;
600         break;
601       case CD_NOTREQUIRED:
602         log_Printf(LogWARN, "%s: Carrier must be set, using ``set cd %d!''\n",
603                    p->link.name, dev->dev.cd.delay);
604       case CD_DEFAULT:
605         break;
606     }
607
608     dev->timeout = dev->dev.cd.delay;
609     dev->connected = CARRIER_PENDING;
610
611   } else {
612     /* See if we're a netgraph socket */
613     struct sockaddr_ng ngsock;
614     struct sockaddr *sock = (struct sockaddr *)&ngsock;
615     int sz;
616
617     sz = sizeof ngsock;
618     if (getsockname(p->fd, sock, &sz) != -1 && sock->sa_family == AF_NETGRAPH) {
619       /*
620        * It's a netgraph node... We can't determine hook names etc, so we
621        * stay pretty impartial....
622        */
623       log_Printf(LogPHASE, "%s: Link is a netgraph node\n", p->link.name);
624
625       if ((dev = malloc(sizeof *dev)) == NULL) {
626         log_Printf(LogWARN, "%s: Cannot allocate an ether device: %s\n",
627                    p->link.name, strerror(errno));
628         return NULL;
629       }
630
631       memcpy(&dev->dev, &baseetherdevice, sizeof dev->dev);
632       dev->cs = -1;
633       dev->timeout = 0;
634       dev->connected = CARRIER_OK;
635       *dev->hook = '\0';
636     }
637   }
638
639   if (dev) {
640     physical_SetupStack(p, dev->dev.name, PHYSICAL_FORCE_SYNCNOACF);
641
642     /* Moan about (and fix) invalid LCP configurations */
643     if (p->link.lcp.cfg.mru > 1492) {
644       log_Printf(LogWARN, "%s: Reducing MRU to 1492\n", p->link.name);
645       p->link.lcp.cfg.mru = 1492;
646     }
647     if (p->dl->bundle->cfg.mtu > 1492) {
648       log_Printf(LogWARN, "%s: Reducing MTU to 1492\n", p->link.name);
649       p->dl->bundle->cfg.mtu = 1492;
650     }
651
652     return &dev->dev;
653   }
654
655   return NULL;
656 }