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