root/net/core/dev.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. min
  2. dev_add_pack
  3. dev_remove_pack
  4. dev_get
  5. dev_load
  6. dev_open
  7. dev_close
  8. register_netdevice_notifier
  9. unregister_netdevice_notifier
  10. dev_queue_xmit
  11. netif_rx
  12. dev_transmit
  13. net_bh
  14. dev_tint
  15. dev_ifconf
  16. sprintf_stats
  17. dev_get_info
  18. bad_mask
  19. dev_ifsioc
  20. dev_ioctl
  21. net_dev_init

   1 /*
   2  *      NET3    Protocol independent device support routines.
   3  *
   4  *              This program is free software; you can redistribute it and/or
   5  *              modify it under the terms of the GNU General Public License
   6  *              as published by the Free Software Foundation; either version
   7  *              2 of the License, or (at your option) any later version.
   8  *
   9  *      Derived from the non IP parts of dev.c 1.0.19
  10  *              Authors:        Ross Biro, <bir7@leland.Stanford.Edu>
  11  *                              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *                              Mark Evans, <evansmp@uhura.aston.ac.uk>
  13  *
  14  *      Additional Authors:
  15  *              Florian la Roche <rzsfl@rz.uni-sb.de>
  16  *              Alan Cox <gw4pts@gw4pts.ampr.org>
  17  *              David Hinds <dhinds@allegro.stanford.edu>
  18  *
  19  *      Changes:
  20  *              Alan Cox        :       device private ioctl copies fields back.
  21  *              Alan Cox        :       Transmit queue code does relevant stunts to
  22  *                                      keep the queue safe.
  23  *              Alan Cox        :       Fixed double lock.
  24  *              Alan Cox        :       Fixed promisc NULL pointer trap
  25  *              ????????        :       Support the full private ioctl range
  26  *              Alan Cox        :       Moved ioctl permission check into drivers
  27  *              Tim Kordas      :       SIOCADDMULTI/SIOCDELMULTI
  28  *              Alan Cox        :       100 backlog just doesn't cut it when
  29  *                                      you start doing multicast video 8)
  30  *              Alan Cox        :       Rewrote net_bh and list manager.
  31  *              Alan Cox        :       Fix ETH_P_ALL echoback lengths.
  32  *              Alan Cox        :       Took out transmit every packet pass
  33  *                                      Saved a few bytes in the ioctl handler
  34  *              Alan Cox        :       Network driver sets packet type before calling netif_rx. Saves
  35  *                                      a function call a packet.
  36  *              Alan Cox        :       Hashed net_bh()
  37  *              Richard Kooijman:       Timestamp fixes.
  38  *              Alan Cox        :       Wrong field in SIOCGIFDSTADDR
  39  *              Alan Cox        :       Device lock protection.
  40  *              Alan Cox        :       Fixed nasty side effect of device close changes.
  41  *              Rudi Cilibrasi  :       Pass the right thing to set_mac_address()
  42  *              Dave Miller     :       32bit quantity for the device lock to make it work out
  43  *                                      on a Sparc.
  44  *              Bjorn Ekwall    :       Added KERNELD hack.
  45  *              Alan Cox        :       Cleaned up the backlog initialise.
  46  *              Craig Metz      :       SIOCGIFCONF fix if space for under
  47  *                                      1 device.
  48  *
  49  */
  50 
  51 #include <asm/segment.h>
  52 #include <asm/system.h>
  53 #include <asm/bitops.h>
  54 #include <linux/config.h>
  55 #include <linux/types.h>
  56 #include <linux/kernel.h>
  57 #include <linux/sched.h>
  58 #include <linux/string.h>
  59 #include <linux/mm.h>
  60 #include <linux/socket.h>
  61 #include <linux/sockios.h>
  62 #include <linux/in.h>
  63 #include <linux/errno.h>
  64 #include <linux/interrupt.h>
  65 #include <linux/if_ether.h>
  66 #include <linux/inet.h>
  67 #include <linux/netdevice.h>
  68 #include <linux/etherdevice.h>
  69 #include <linux/notifier.h>
  70 #include <net/ip.h>
  71 #include <net/route.h>
  72 #include <linux/skbuff.h>
  73 #include <net/sock.h>
  74 #include <net/arp.h>
  75 #include <net/slhc.h>
  76 #include <linux/proc_fs.h>
  77 #include <linux/stat.h>
  78 #include <net/br.h>
  79 #ifdef CONFIG_NET_ALIAS
  80 #include <linux/net_alias.h>
  81 #endif
  82 #ifdef CONFIG_KERNELD
  83 #include <linux/kerneld.h>
  84 #endif
  85 
  86 /*
  87  *      The list of packet types we will receive (as opposed to discard)
  88  *      and the routines to invoke.
  89  */
  90 
  91 struct packet_type *ptype_base[16];
  92 struct packet_type *ptype_all = NULL;           /* Taps */
  93 
  94 /*
  95  *      Device list lock
  96  */
  97  
  98 int dev_lockct=0;
  99  
 100 /*
 101  *      Our notifier list
 102  */
 103  
 104 struct notifier_block *netdev_chain=NULL;
 105 
 106 /*
 107  *      Device drivers call our routines to queue packets here. We empty the
 108  *      queue in the bottom half handler.
 109  */
 110 
 111 static struct sk_buff_head backlog;
 112 
 113 /* 
 114  *      We don't overdo the queue or we will thrash memory badly.
 115  */
 116  
 117 static int backlog_size = 0;
 118 
 119 /*
 120  *      Return the lesser of the two values. 
 121  */
 122  
 123 static __inline__ unsigned long min(unsigned long a, unsigned long b)
     /* [previous][next][first][last][top][bottom][index][help] */
 124 {
 125         return (a < b)? a : b;
 126 }
 127 
 128 
 129 /******************************************************************************************
 130 
 131                 Protocol management and registration routines
 132 
 133 *******************************************************************************************/
 134 
 135 /*
 136  *      For efficiency
 137  */
 138 
 139 static int dev_nit=0;
 140 
 141 /*
 142  *      Add a protocol ID to the list. Now that the input handler is
 143  *      smarter we can dispense with all the messy stuff that used to be
 144  *      here.
 145  */
 146  
 147 void dev_add_pack(struct packet_type *pt)
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149         int hash;
 150         if(pt->type==htons(ETH_P_ALL))
 151         {
 152                 dev_nit++;
 153                 pt->next=ptype_all;
 154                 ptype_all=pt;
 155         }
 156         else
 157         {       
 158                 hash=ntohs(pt->type)&15;
 159                 pt->next = ptype_base[hash];
 160                 ptype_base[hash] = pt;
 161         }
 162 }
 163 
 164 
 165 /*
 166  *      Remove a protocol ID from the list.
 167  */
 168  
 169 void dev_remove_pack(struct packet_type *pt)
     /* [previous][next][first][last][top][bottom][index][help] */
 170 {
 171         struct packet_type **pt1;
 172         if(pt->type==htons(ETH_P_ALL))
 173         {
 174                 dev_nit--;
 175                 pt1=&ptype_all;
 176         }
 177         else
 178                 pt1=&ptype_base[ntohs(pt->type)&15];
 179         for(; (*pt1)!=NULL; pt1=&((*pt1)->next))
 180         {
 181                 if(pt==(*pt1))
 182                 {
 183                         *pt1=pt->next;
 184                         return;
 185                 }
 186         }
 187         printk("dev_remove_pack: %p not found.\n", pt);
 188 }
 189 
 190 /*****************************************************************************************
 191 
 192                             Device Interface Subroutines
 193 
 194 ******************************************************************************************/
 195 
 196 /* 
 197  *      Find an interface by name.
 198  */
 199  
 200 struct device *dev_get(const char *name)
     /* [previous][next][first][last][top][bottom][index][help] */
 201 {
 202         struct device *dev;
 203 
 204         for (dev = dev_base; dev != NULL; dev = dev->next) 
 205         {
 206                 if (strcmp(dev->name, name) == 0)
 207                         return(dev);
 208         }
 209         return NULL;
 210 }
 211         
 212 /*
 213  *      Find and possibly load an interface.
 214  */
 215  
 216 #ifdef CONFIG_KERNELD
 217 
 218 extern __inline__ void dev_load(const char *name)
     /* [previous][next][first][last][top][bottom][index][help] */
 219 {
 220         if(!dev_get(name)) {
 221 #ifdef CONFIG_NET_ALIAS
 222                 const char *sptr;
 223  
 224                 for (sptr=name ; *sptr ; sptr++) if(*sptr==':') break;
 225                 if (!(*sptr && *(sptr+1)))
 226 #endif
 227                 request_module(name);
 228         }
 229 }
 230 
 231 #endif
 232  
 233 /*
 234  *      Prepare an interface for use. 
 235  */
 236  
 237 int dev_open(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 238 {
 239         int ret = 0;
 240 
 241         /*
 242          *      Call device private open method
 243          */
 244         if (dev->open) 
 245                 ret = dev->open(dev);
 246 
 247         /*
 248          *      If it went open OK then set the flags
 249          */
 250          
 251         if (ret == 0) 
 252         {
 253                 dev->flags |= (IFF_UP | IFF_RUNNING);
 254                 /*
 255                  *      Initialise multicasting status 
 256                  */
 257                 dev_mc_upload(dev);
 258                 notifier_call_chain(&netdev_chain, NETDEV_UP, dev);
 259         }
 260         return(ret);
 261 }
 262 
 263 
 264 /*
 265  *      Completely shutdown an interface.
 266  */
 267  
 268 int dev_close(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 269 {
 270         int ct=0;
 271 
 272         /*
 273          *      Call the device specific close. This cannot fail.
 274          *      Only if device is UP
 275          */
 276          
 277         if ((dev->flags & IFF_UP) && dev->stop)
 278                 dev->stop(dev);
 279 
 280         /*
 281          *      Device is now down.
 282          */
 283          
 284         dev->flags&=~(IFF_UP|IFF_RUNNING);
 285 
 286         /*
 287          *      Tell people we are going down
 288          */
 289         notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev);
 290         /*
 291          *      Flush the multicast chain
 292          */
 293         dev_mc_discard(dev);
 294 
 295         /*
 296          *      Purge any queued packets when we down the link 
 297          */
 298         while(ct<DEV_NUMBUFFS)
 299         {
 300                 struct sk_buff *skb;
 301                 while((skb=skb_dequeue(&dev->buffs[ct]))!=NULL)
 302                         if(skb->free)
 303                                 kfree_skb(skb,FREE_WRITE);
 304                 ct++;
 305         }
 306         return(0);
 307 }
 308 
 309 
 310 /*
 311  *      Device change register/unregister. These are not inline or static
 312  *      as we export them to the world.
 313  */
 314 
 315 int register_netdevice_notifier(struct notifier_block *nb)
     /* [previous][next][first][last][top][bottom][index][help] */
 316 {
 317         return notifier_chain_register(&netdev_chain, nb);
 318 }
 319 
 320 int unregister_netdevice_notifier(struct notifier_block *nb)
     /* [previous][next][first][last][top][bottom][index][help] */
 321 {
 322         return notifier_chain_unregister(&netdev_chain,nb);
 323 }
 324 
 325 /*
 326  *      Send (or queue for sending) a packet. 
 327  *
 328  *      IMPORTANT: When this is called to resend frames. The caller MUST
 329  *      already have locked the sk_buff. Apart from that we do the
 330  *      rest of the magic.
 331  */
 332 
 333 void dev_queue_xmit(struct sk_buff *skb, struct device *dev, int pri)
     /* [previous][next][first][last][top][bottom][index][help] */
 334 {
 335         unsigned long flags;
 336         struct sk_buff_head *list;
 337         int retransmission = 0; /* used to say if the packet should go  */
 338                                 /* at the front or the back of the      */
 339                                 /* queue - front is a retransmit try    */
 340 
 341         if(pri>=0 && !skb_device_locked(skb))
 342                 skb_device_lock(skb);   /* Shove a lock on the frame */
 343 #if CONFIG_SKB_CHECK 
 344         IS_SKB(skb);
 345 #endif    
 346         skb->dev = dev;
 347 
 348         /*
 349          *      Negative priority is used to flag a frame that is being pulled from the
 350          *      queue front as a retransmit attempt. It therefore goes back on the queue
 351          *      start on a failure.
 352          */
 353          
 354         if (pri < 0) 
 355         {
 356                 pri = -pri-1;
 357                 retransmission = 1;
 358         }
 359 
 360 #ifdef CONFIG_NET_DEBUG
 361         if (pri >= DEV_NUMBUFFS) 
 362         {
 363                 printk("bad priority in dev_queue_xmit.\n");
 364                 pri = 1;
 365         }
 366 #endif
 367 
 368         /*
 369          *      If the address has not been resolved. Call the device header rebuilder.
 370          *      This can cover all protocols and technically not just ARP either.
 371          */
 372          
 373         if (!skb->arp && dev->rebuild_header(skb->data, dev, skb->raddr, skb)) {
 374                 return;
 375         }
 376 
 377         /*
 378          *
 379          *      If dev is an alias, switch to its main device.
 380          *      "arp" resolution has been made with alias device, so
 381          *      arp entries refer to alias, not main.
 382          *
 383          */
 384 
 385 #ifdef CONFIG_NET_ALIAS
 386         if (net_alias_is(dev))
 387                 skb->dev = dev = net_alias_main_dev(dev);
 388 #endif
 389 
 390         /*
 391          *      If we are bridging and this is directly generated output
 392          *      pass the frame via the bridge.
 393          */
 394 
 395 #ifdef CONFIG_BRIDGE
 396         if(skb->pkt_bridged!=IS_BRIDGED && br_stats.flags & BR_UP)
 397         {
 398                 if(br_tx_frame(skb))
 399                         return;
 400         }
 401 #endif
 402 
 403         list = dev->buffs + pri;
 404 
 405         save_flags(flags);
 406         /* if this isn't a retransmission, use the first packet instead... */
 407         if (!retransmission) {
 408                 if (skb_queue_len(list)) {
 409                         /* avoid overrunning the device queue.. */
 410                         if (skb_queue_len(list) > dev->tx_queue_len) {
 411                                 dev_kfree_skb(skb, FREE_WRITE);
 412                                 return;
 413                         }
 414                         cli();
 415                         skb_device_unlock(skb);         /* Buffer is on the device queue and can be freed safely */
 416                         __skb_queue_tail(list, skb);
 417                         skb = __skb_dequeue(list);
 418                         skb_device_lock(skb);           /* New buffer needs locking down */
 419                         restore_flags(flags);
 420                 }
 421                 
 422                 /* copy outgoing packets to any sniffer packet handlers */
 423                 if (dev_nit) {
 424                         struct packet_type *ptype;
 425                         skb->stamp=xtime;
 426                         for (ptype = ptype_all; ptype!=NULL; ptype = ptype->next) 
 427                         {
 428                                 /* Never send packets back to the socket
 429                                  * they originated from - MvS (miquels@drinkel.ow.org)
 430                                  */
 431                                 if ((ptype->dev == dev || !ptype->dev) &&
 432                                    ((struct sock *)ptype->data != skb->sk))
 433                                 {
 434                                         struct sk_buff *skb2;
 435                                         if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL)
 436                                                 break;
 437                                         skb2->h.raw = skb2->data + dev->hard_header_len;
 438                                         skb2->mac.raw = skb2->data;
 439                                         ptype->func(skb2, skb->dev, ptype);
 440                                 }
 441                         }
 442                 }
 443         }
 444         start_bh_atomic();
 445         if (dev->hard_start_xmit(skb, dev) == 0) {
 446                 /*
 447                  *      Packet is now solely the responsibility of the driver
 448                  */
 449                 end_bh_atomic();
 450                 return;
 451         }
 452         end_bh_atomic();
 453 
 454         /*
 455          *      Transmission failed, put skb back into a list. Once on the list it's safe and
 456          *      no longer device locked (it can be freed safely from the device queue)
 457          */
 458         cli();
 459         skb_device_unlock(skb);
 460         __skb_queue_head(list,skb);
 461         restore_flags(flags);
 462 }
 463 
 464 /*
 465  *      Receive a packet from a device driver and queue it for the upper
 466  *      (protocol) levels.  It always succeeds. This is the recommended 
 467  *      interface to use.
 468  */
 469 
 470 void netif_rx(struct sk_buff *skb)
     /* [previous][next][first][last][top][bottom][index][help] */
 471 {
 472         static int dropping = 0;
 473 
 474         /*
 475          *      Any received buffers are un-owned and should be discarded
 476          *      when freed. These will be updated later as the frames get
 477          *      owners.
 478          */
 479 
 480         skb->sk = NULL;
 481         skb->free = 1;
 482         if(skb->stamp.tv_sec==0)
 483                 skb->stamp = xtime;
 484 
 485         /*
 486          *      Check that we aren't overdoing things.
 487          */
 488 
 489         if (!backlog_size)
 490                 dropping = 0;
 491         else if (backlog_size > 300)
 492                 dropping = 1;
 493 
 494         if (dropping) 
 495         {
 496                 kfree_skb(skb, FREE_READ);
 497                 return;
 498         }
 499 
 500         /*
 501          *      Add it to the "backlog" queue. 
 502          */
 503 #if CONFIG_SKB_CHECK
 504         IS_SKB(skb);
 505 #endif  
 506         skb_queue_tail(&backlog,skb);
 507         backlog_size++;
 508   
 509         /*
 510          *      If any packet arrived, mark it for processing after the
 511          *      hardware interrupt returns.
 512          */
 513 
 514         mark_bh(NET_BH);
 515         return;
 516 }
 517 
 518 /*
 519  *      This routine causes all interfaces to try to send some data. 
 520  */
 521  
 522 void dev_transmit(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 523 {
 524         struct device *dev;
 525 
 526         for (dev = dev_base; dev != NULL; dev = dev->next)
 527         {
 528                 if (dev->flags != 0 && !dev->tbusy) {
 529                         /*
 530                          *      Kick the device
 531                          */
 532                         dev_tint(dev);
 533                 }
 534         }
 535 }
 536 
 537 
 538 /**********************************************************************************
 539 
 540                         Receive Queue Processor
 541                         
 542 ***********************************************************************************/
 543 
 544 /*
 545  *      When we are called the queue is ready to grab, the interrupts are
 546  *      on and hardware can interrupt and queue to the receive queue as we
 547  *      run with no problems.
 548  *      This is run as a bottom half after an interrupt handler that does
 549  *      mark_bh(NET_BH);
 550  */
 551  
 552 void net_bh(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 553 {
 554         struct packet_type *ptype;
 555         struct packet_type *pt_prev;
 556         unsigned short type;
 557 
 558         /*
 559          *      Can we send anything now? We want to clear the
 560          *      decks for any more sends that get done as we
 561          *      process the input. This also minimises the
 562          *      latency on a transmit interrupt bh.
 563          */
 564 
 565         dev_transmit();
 566   
 567         /*
 568          *      Any data left to process. This may occur because a
 569          *      mark_bh() is done after we empty the queue including
 570          *      that from the device which does a mark_bh() just after
 571          */
 572 
 573         /*
 574          *      While the queue is not empty..
 575          *
 576          *      Note that the queue never shrinks due to
 577          *      an interrupt, so we can do this test without
 578          *      disabling interrupts.
 579          */
 580 
 581         while (!skb_queue_empty(&backlog)) {
 582                 struct sk_buff * skb = backlog.next;
 583 
 584                 /*
 585                  *      We have a packet. Therefore the queue has shrunk
 586                  */
 587                 cli();
 588                 __skb_unlink(skb, &backlog);
 589                 backlog_size--;
 590                 sti();
 591                 
 592 
 593 #ifdef CONFIG_BRIDGE
 594 
 595                 /*
 596                  *      If we are bridging then pass the frame up to the
 597                  *      bridging code. If it is bridged then move on
 598                  */
 599                  
 600                 if (br_stats.flags & BR_UP)
 601                 {
 602                         /*
 603                          *      We pass the bridge a complete frame. This means
 604                          *      recovering the MAC header first.
 605                          */
 606                          
 607                         int offset=skb->data-skb->mac.raw;
 608                         cli();
 609                         skb_push(skb,offset);   /* Put header back on for bridge */
 610                         if(br_receive_frame(skb))
 611                                 continue;
 612                         /*
 613                          *      Pull the MAC header off for the copy going to
 614                          *      the upper layers.
 615                          */
 616                         skb_pull(skb,offset);
 617                         sti();
 618                 }
 619 #endif
 620                 
 621                 /*
 622                  *      Bump the pointer to the next structure.
 623                  * 
 624                  *      On entry to the protocol layer. skb->data and
 625                  *      skb->h.raw point to the MAC and encapsulated data
 626                  */
 627 
 628                 skb->h.raw = skb->data;
 629 
 630                 /*
 631                  *      Fetch the packet protocol ID. 
 632                  */
 633                 
 634                 type = skb->protocol;
 635 
 636                 /*
 637                  *      We got a packet ID.  Now loop over the "known protocols"
 638                  *      list. There are two lists. The ptype_all list of taps (normally empty)
 639                  *      and the main protocol list which is hashed perfectly for normal protocols.
 640                  */
 641                 
 642                 pt_prev = NULL;
 643                 for (ptype = ptype_all; ptype!=NULL; ptype=ptype->next)
 644                 {
 645                         if(pt_prev)
 646                         {
 647                                 struct sk_buff *skb2=skb_clone(skb, GFP_ATOMIC);
 648                                 if(skb2)
 649                                         pt_prev->func(skb2,skb->dev, pt_prev);
 650                         }
 651                         pt_prev=ptype;
 652                 }
 653                 
 654                 for (ptype = ptype_base[ntohs(type)&15]; ptype != NULL; ptype = ptype->next) 
 655                 {
 656                         if (ptype->type == type && (!ptype->dev || ptype->dev==skb->dev))
 657                         {
 658                                 /*
 659                                  *      We already have a match queued. Deliver
 660                                  *      to it and then remember the new match
 661                                  */
 662                                 if(pt_prev)
 663                                 {
 664                                         struct sk_buff *skb2;
 665 
 666                                         skb2=skb_clone(skb, GFP_ATOMIC);
 667 
 668                                         /*
 669                                          *      Kick the protocol handler. This should be fast
 670                                          *      and efficient code.
 671                                          */
 672 
 673                                         if(skb2)
 674                                                 pt_prev->func(skb2, skb->dev, pt_prev);
 675                                 }
 676                                 /* Remember the current last to do */
 677                                 pt_prev=ptype;
 678                         }
 679                 } /* End of protocol list loop */
 680                 
 681                 /*
 682                  *      Is there a last item to send to ?
 683                  */
 684 
 685                 if(pt_prev)
 686                         pt_prev->func(skb, skb->dev, pt_prev);
 687                 /*
 688                  *      Has an unknown packet has been received ?
 689                  */
 690          
 691                 else
 692                         kfree_skb(skb, FREE_WRITE);
 693                 /*
 694                  *      Again, see if we can transmit anything now. 
 695                  *      [Ought to take this out judging by tests it slows
 696                  *       us down not speeds us up]
 697                  */
 698 #ifdef XMIT_EVERY
 699                 dev_transmit();
 700 #endif          
 701         }       /* End of queue loop */
 702         
 703         /*
 704          *      We have emptied the queue
 705          */
 706         
 707         /*
 708          *      One last output flush.
 709          */
 710 
 711 #ifdef XMIT_AFTER        
 712         dev_transmit();
 713 #endif
 714 }
 715 
 716 
 717 /*
 718  *      This routine is called when an device driver (i.e. an
 719  *      interface) is ready to transmit a packet.
 720  */
 721  
 722 void dev_tint(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 723 {
 724         int i;
 725         unsigned long flags;
 726         struct sk_buff_head * head;
 727         
 728         /*
 729          * aliases do not transmit (for now :) )
 730          */
 731 
 732 #ifdef CONFIG_NET_ALIAS
 733         if (net_alias_is(dev)) return;
 734 #endif
 735         head = dev->buffs;
 736         save_flags(flags);
 737         cli();
 738 
 739         /*
 740          *      Work the queues in priority order
 741          */      
 742         for(i = 0;i < DEV_NUMBUFFS; i++,head++)
 743         {
 744 
 745                 while (!skb_queue_empty(head)) {
 746                         struct sk_buff *skb;
 747 
 748                         skb = head->next;
 749                         __skb_unlink(skb, head);
 750                         /*
 751                          *      Stop anyone freeing the buffer while we retransmit it
 752                          */
 753                         skb_device_lock(skb);
 754                         restore_flags(flags);
 755                         /*
 756                          *      Feed them to the output stage and if it fails
 757                          *      indicate they re-queue at the front.
 758                          */
 759                         dev_queue_xmit(skb,dev,-i - 1);
 760                         /*
 761                          *      If we can take no more then stop here.
 762                          */
 763                         if (dev->tbusy)
 764                                 return;
 765                         cli();
 766                 }
 767         }
 768         restore_flags(flags);
 769 }
 770 
 771 
 772 /*
 773  *      Perform a SIOCGIFCONF call. This structure will change
 774  *      size shortly, and there is nothing I can do about it.
 775  *      Thus we will need a 'compatibility mode'.
 776  */
 777 
 778 static int dev_ifconf(char *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 779 {
 780         struct ifconf ifc;
 781         struct ifreq ifr;
 782         struct device *dev;
 783         char *pos;
 784         int len;
 785         int err;
 786 
 787         /*
 788          *      Fetch the caller's info block. 
 789          */
 790          
 791         err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifconf));
 792         if(err)
 793                 return err;
 794         memcpy_fromfs(&ifc, arg, sizeof(struct ifconf));
 795         len = ifc.ifc_len;
 796         pos = ifc.ifc_buf;
 797 
 798         /*
 799          *      We now walk the device list filling each active device
 800          *      into the array.
 801          */
 802          
 803         err=verify_area(VERIFY_WRITE,pos,len);
 804         if(err)
 805                 return err;
 806         
 807         /*
 808          *      Loop over the interfaces, and write an info block for each. 
 809          */
 810 
 811         for (dev = dev_base; dev != NULL; dev = dev->next) 
 812         {
 813                 if(!(dev->flags & IFF_UP))      /* Downed devices don't count */
 814                         continue;
 815                 /*
 816                  *      Have we run out of space here ?
 817                  */
 818         
 819                 if (len < sizeof(struct ifreq)) 
 820                         break;
 821 
 822                 memset(&ifr, 0, sizeof(struct ifreq));
 823                 strcpy(ifr.ifr_name, dev->name);
 824                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_family = dev->family;
 825                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
 826 
 827 
 828                 /*
 829                  *      Write this block to the caller's space. 
 830                  */
 831                  
 832                 memcpy_tofs(pos, &ifr, sizeof(struct ifreq));
 833                 pos += sizeof(struct ifreq);
 834                 len -= sizeof(struct ifreq);            
 835         }
 836 
 837         /*
 838          *      All done.  Write the updated control block back to the caller. 
 839          */
 840          
 841         ifc.ifc_len = (pos - ifc.ifc_buf);
 842         ifc.ifc_req = (struct ifreq *) ifc.ifc_buf;
 843         memcpy_tofs(arg, &ifc, sizeof(struct ifconf));
 844         
 845         /*
 846          *      Report how much was filled in
 847          */
 848          
 849         return(pos - arg);
 850 }
 851 
 852 
 853 /*
 854  *      This is invoked by the /proc filesystem handler to display a device
 855  *      in detail.
 856  */
 857 
 858 #ifdef CONFIG_PROC_FS
 859 static int sprintf_stats(char *buffer, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 860 {
 861         struct enet_statistics *stats = (dev->get_stats ? dev->get_stats(dev): NULL);
 862         int size;
 863         
 864         if (stats)
 865                 size = sprintf(buffer, "%6s:%7d %4d %4d %4d %4d %8d %4d %4d %4d %5d %4d\n",
 866                    dev->name,
 867                    stats->rx_packets, stats->rx_errors,
 868                    stats->rx_dropped + stats->rx_missed_errors,
 869                    stats->rx_fifo_errors,
 870                    stats->rx_length_errors + stats->rx_over_errors
 871                    + stats->rx_crc_errors + stats->rx_frame_errors,
 872                    stats->tx_packets, stats->tx_errors, stats->tx_dropped,
 873                    stats->tx_fifo_errors, stats->collisions,
 874                    stats->tx_carrier_errors + stats->tx_aborted_errors
 875                    + stats->tx_window_errors + stats->tx_heartbeat_errors);
 876         else
 877                 size = sprintf(buffer, "%6s: No statistics available.\n", dev->name);
 878 
 879         return size;
 880 }
 881 
 882 /*
 883  *      Called from the PROCfs module. This now uses the new arbitrary sized /proc/net interface
 884  *      to create /proc/net/dev
 885  */
 886  
 887 int dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 888 {
 889         int len=0;
 890         off_t begin=0;
 891         off_t pos=0;
 892         int size;
 893         
 894         struct device *dev;
 895 
 896 
 897         size = sprintf(buffer, "Inter-|   Receive                  |  Transmit\n"
 898                             " face |packets errs drop fifo frame|packets errs drop fifo colls carrier\n");
 899         
 900         pos+=size;
 901         len+=size;
 902         
 903 
 904         for (dev = dev_base; dev != NULL; dev = dev->next) 
 905         {
 906                 size = sprintf_stats(buffer+len, dev);
 907                 len+=size;
 908                 pos=begin+len;
 909                                 
 910                 if(pos<offset)
 911                 {
 912                         len=0;
 913                         begin=pos;
 914                 }
 915                 if(pos>offset+length)
 916                         break;
 917         }
 918         
 919         *start=buffer+(offset-begin);   /* Start of wanted data */
 920         len-=(offset-begin);            /* Start slop */
 921         if(len>length)
 922                 len=length;             /* Ending slop */
 923         return len;
 924 }
 925 #endif  /* CONFIG_PROC_FS */
 926 
 927 
 928 /*
 929  *      This checks bitmasks for the ioctl calls for devices.
 930  */
 931  
 932 static inline int bad_mask(unsigned long mask, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 933 {
 934         if (addr & (mask = ~mask))
 935                 return 1;
 936         mask = ntohl(mask);
 937         if (mask & (mask+1))
 938                 return 1;
 939         return 0;
 940 }
 941 
 942 /*
 943  *      Perform the SIOCxIFxxx calls. 
 944  *
 945  *      The socket layer has seen an ioctl the address family thinks is
 946  *      for the device. At this point we get invoked to make a decision
 947  */
 948  
 949 static int dev_ifsioc(void *arg, unsigned int getset)
     /* [previous][next][first][last][top][bottom][index][help] */
 950 {
 951         struct ifreq ifr;
 952         struct device *dev;
 953         int ret;
 954 
 955         /*
 956          *      Fetch the caller's info block into kernel space
 957          */
 958 
 959         int err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifreq));
 960         if(err)
 961                 return err;
 962         
 963         memcpy_fromfs(&ifr, arg, sizeof(struct ifreq));
 964 
 965         /*
 966          *      See which interface the caller is talking about. 
 967          */
 968          
 969         /*
 970          *
 971          *      net_alias_dev_get(): dev_get() with added alias naming magic.
 972          *      only allow alias creation/deletion if (getset==SIOCSIFADDR)
 973          *
 974          */
 975          
 976 #ifdef CONFIG_KERNELD
 977         dev_load(ifr.ifr_name);
 978 #endif  
 979 
 980 #ifdef CONFIG_NET_ALIAS
 981         if ((dev = net_alias_dev_get(ifr.ifr_name, getset == SIOCSIFADDR, &err, NULL, NULL)) == NULL)
 982                 return(err);
 983 #else
 984         if ((dev = dev_get(ifr.ifr_name)) == NULL)      
 985                 return(-ENODEV);
 986 #endif
 987         switch(getset) 
 988         {
 989                 case SIOCGIFFLAGS:      /* Get interface flags */
 990                         ifr.ifr_flags = dev->flags;
 991                         goto rarok;
 992 
 993                 case SIOCSIFFLAGS:      /* Set interface flags */
 994                         {
 995                                 int old_flags = dev->flags;
 996                                 
 997                                 /*
 998                                  *      We are not allowed to potentially close/unload
 999                                  *      a device until we get this lock.
1000                                  */
1001                                 
1002                                 dev_lock_wait();
1003                                 
1004                                 /*
1005                                  *      Set the flags on our device.
1006                                  */
1007                                  
1008                                 dev->flags = (ifr.ifr_flags & (
1009                                         IFF_BROADCAST | IFF_DEBUG | IFF_LOOPBACK |
1010                                         IFF_POINTOPOINT | IFF_NOTRAILERS | IFF_RUNNING |
1011                                         IFF_NOARP | IFF_PROMISC | IFF_ALLMULTI | IFF_SLAVE | IFF_MASTER
1012                                         | IFF_MULTICAST)) | (dev->flags & IFF_UP);
1013                                 /*
1014                                  *      Load in the correct multicast list now the flags have changed.
1015                                  */                             
1016 
1017                                 dev_mc_upload(dev);
1018 
1019                                 /*
1020                                  *      Have we downed the interface. We handle IFF_UP ourselves
1021                                  *      according to user attempts to set it, rather than blindly
1022                                  *      setting it.
1023                                  */
1024                                  
1025                                 if ((old_flags^ifr.ifr_flags)&IFF_UP)   /* Bit is different  ? */
1026                                 {
1027                                         if(old_flags&IFF_UP)            /* Gone down */
1028                                                 ret=dev_close(dev);             
1029                                         else                            /* Come up */
1030                                         {
1031                                                 ret=dev_open(dev);
1032                                                 if(ret<0)
1033                                                         dev->flags&=~IFF_UP;    /* Open failed */
1034                                         }       
1035                                 }
1036                                 else
1037                                         ret=0;
1038                                 /*
1039                                  *      Load in the correct multicast list now the flags have changed.
1040                                  */                             
1041 
1042                                 dev_mc_upload(dev);
1043                         }
1044                         break;
1045                 
1046                 case SIOCGIFADDR:       /* Get interface address (and family) */
1047                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1048                         {
1049                                 memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1050                                 ifr.ifr_hwaddr.sa_family=dev->type;                     
1051                                 goto rarok;
1052                         }
1053                         else
1054                         {
1055                                 (*(struct sockaddr_in *)
1056                                           &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
1057                                 (*(struct sockaddr_in *)
1058                                           &ifr.ifr_addr).sin_family = dev->family;
1059                                 (*(struct sockaddr_in *)
1060                                           &ifr.ifr_addr).sin_port = 0;
1061                         }
1062                         goto rarok;
1063         
1064                 case SIOCSIFADDR:       /* Set interface address (and family) */
1065                 
1066                         /*
1067                          *      BSDism. SIOCSIFADDR family=AF_UNSPEC sets the
1068                          *      physical address. We can cope with this now.
1069                          */
1070                         
1071                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1072                         {
1073                                 if(dev->set_mac_address==NULL)
1074                                         return -EOPNOTSUPP;
1075                                 ret=dev->set_mac_address(dev,&ifr.ifr_addr);
1076                         }
1077                         else
1078                         {
1079                                 u32 new_pa_addr = (*(struct sockaddr_in *)
1080                                          &ifr.ifr_addr).sin_addr.s_addr;
1081                                 u16 new_family = ifr.ifr_addr.sa_family;
1082 
1083                                 if (new_family == dev->family &&
1084                                     new_pa_addr == dev->pa_addr) {
1085                                         ret =0;
1086                                         break;
1087                                 }
1088                                 if (dev->flags & IFF_UP)
1089                                         notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev);
1090 
1091                                 /*
1092                                  *      if dev is an alias, must rehash to update
1093                                  *      address change
1094                                  */
1095 
1096 #ifdef CONFIG_NET_ALIAS
1097                                 if (net_alias_is(dev))
1098                                 net_alias_dev_rehash(dev ,&ifr.ifr_addr);
1099 #endif
1100                                 dev->pa_addr = new_pa_addr;
1101                                 dev->family = new_family;
1102                         
1103 #ifdef CONFIG_INET      
1104                                 /* This is naughty. When net-032e comes out It wants moving into the net032
1105                                    code not the kernel. Till then it can sit here (SIGH) */             
1106                                 if (!dev->pa_mask)
1107                                         dev->pa_mask = ip_get_mask(dev->pa_addr);
1108 #endif                  
1109                                 if (!dev->pa_brdaddr)
1110                                         dev->pa_brdaddr = dev->pa_addr | ~dev->pa_mask;
1111                                 if (dev->flags & IFF_UP)
1112                                         notifier_call_chain(&netdev_chain, NETDEV_UP, dev);
1113                                 ret = 0;
1114                         }
1115                         break;
1116                         
1117                 case SIOCGIFBRDADDR:    /* Get the broadcast address */
1118                         (*(struct sockaddr_in *)
1119                                 &ifr.ifr_broadaddr).sin_addr.s_addr = dev->pa_brdaddr;
1120                         (*(struct sockaddr_in *)
1121                                 &ifr.ifr_broadaddr).sin_family = dev->family;
1122                         (*(struct sockaddr_in *)
1123                                 &ifr.ifr_broadaddr).sin_port = 0;
1124                         goto rarok;
1125 
1126                 case SIOCSIFBRDADDR:    /* Set the broadcast address */
1127                         dev->pa_brdaddr = (*(struct sockaddr_in *)
1128                                 &ifr.ifr_broadaddr).sin_addr.s_addr;
1129                         ret = 0;
1130                         break;
1131                         
1132                 case SIOCGIFDSTADDR:    /* Get the destination address (for point-to-point links) */
1133                         (*(struct sockaddr_in *)
1134                                 &ifr.ifr_dstaddr).sin_addr.s_addr = dev->pa_dstaddr;
1135                         (*(struct sockaddr_in *)
1136                                 &ifr.ifr_dstaddr).sin_family = dev->family;
1137                         (*(struct sockaddr_in *)
1138                                 &ifr.ifr_dstaddr).sin_port = 0;
1139                         goto rarok;
1140         
1141                 case SIOCSIFDSTADDR:    /* Set the destination address (for point-to-point links) */
1142                         dev->pa_dstaddr = (*(struct sockaddr_in *)
1143                                 &ifr.ifr_dstaddr).sin_addr.s_addr;
1144                         ret = 0;
1145                         break;
1146                         
1147                 case SIOCGIFNETMASK:    /* Get the netmask for the interface */
1148                         (*(struct sockaddr_in *)
1149                                 &ifr.ifr_netmask).sin_addr.s_addr = dev->pa_mask;
1150                         (*(struct sockaddr_in *)
1151                                 &ifr.ifr_netmask).sin_family = dev->family;
1152                         (*(struct sockaddr_in *)
1153                                 &ifr.ifr_netmask).sin_port = 0;
1154                         goto rarok;
1155 
1156                 case SIOCSIFNETMASK:    /* Set the netmask for the interface */
1157                         {
1158                                 unsigned long mask = (*(struct sockaddr_in *)
1159                                         &ifr.ifr_netmask).sin_addr.s_addr;
1160                                 ret = -EINVAL;
1161                                 /*
1162                                  *      The mask we set must be legal.
1163                                  */
1164                                 if (bad_mask(mask,0))
1165                                         break;
1166                                 dev->pa_mask = mask;
1167                                 ret = 0;
1168                         }
1169                         break;
1170                         
1171                 case SIOCGIFMETRIC:     /* Get the metric on the interface (currently unused) */
1172                         
1173                         ifr.ifr_metric = dev->metric;
1174                         goto  rarok;
1175                         
1176                 case SIOCSIFMETRIC:     /* Set the metric on the interface (currently unused) */
1177                         dev->metric = ifr.ifr_metric;
1178                         ret=0;
1179                         break;
1180         
1181                 case SIOCGIFMTU:        /* Get the MTU of a device */
1182                         ifr.ifr_mtu = dev->mtu;
1183                         goto rarok;
1184         
1185                 case SIOCSIFMTU:        /* Set the MTU of a device */
1186                 
1187                         /*
1188                          *      MTU must be positive.
1189                          */
1190                          
1191                         if(ifr.ifr_mtu<68)
1192                                 return -EINVAL;
1193 
1194                         if (dev->change_mtu)
1195                                 ret = (*dev->change_mtu)(dev, ifr.ifr_mtu);
1196                         else
1197                         {
1198                                 dev->mtu = ifr.ifr_mtu;
1199                                 ret = 0;
1200                         }
1201                         break;
1202         
1203                 case SIOCGIFMEM:        /* Get the per device memory space. We can add this but currently
1204                                            do not support it */
1205                         ret = -EINVAL;
1206                         break;
1207                 
1208                 case SIOCSIFMEM:        /* Set the per device memory buffer space. Not applicable in our case */
1209                         ret = -EINVAL;
1210                         break;
1211 
1212                 case SIOCGIFHWADDR:
1213                         memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1214                         ifr.ifr_hwaddr.sa_family=dev->type;                     
1215                         goto rarok;
1216                                 
1217                 case SIOCSIFHWADDR:
1218                         if(dev->set_mac_address==NULL)
1219                                 return -EOPNOTSUPP;
1220                         if(ifr.ifr_hwaddr.sa_family!=dev->type)
1221                                 return -EINVAL;
1222                         ret=dev->set_mac_address(dev,&ifr.ifr_hwaddr);
1223                         break;
1224                         
1225                 case SIOCGIFMAP:
1226                         ifr.ifr_map.mem_start=dev->mem_start;
1227                         ifr.ifr_map.mem_end=dev->mem_end;
1228                         ifr.ifr_map.base_addr=dev->base_addr;
1229                         ifr.ifr_map.irq=dev->irq;
1230                         ifr.ifr_map.dma=dev->dma;
1231                         ifr.ifr_map.port=dev->if_port;
1232                         goto rarok;
1233                         
1234                 case SIOCSIFMAP:
1235                         if(dev->set_config==NULL)
1236                                 return -EOPNOTSUPP;
1237                         return dev->set_config(dev,&ifr.ifr_map);
1238                         
1239                 case SIOCADDMULTI:
1240                         if(dev->set_multicast_list==NULL)
1241                                 return -EINVAL;
1242                         if(ifr.ifr_hwaddr.sa_family!=AF_UNSPEC)
1243                                 return -EINVAL;
1244                         dev_mc_add(dev,ifr.ifr_hwaddr.sa_data, dev->addr_len, 1);
1245                         return 0;
1246 
1247                 case SIOCDELMULTI:
1248                         if(dev->set_multicast_list==NULL)
1249                                 return -EINVAL;
1250                         if(ifr.ifr_hwaddr.sa_family!=AF_UNSPEC)
1251                                 return -EINVAL;
1252                         dev_mc_delete(dev,ifr.ifr_hwaddr.sa_data,dev->addr_len, 1);
1253                         return 0;
1254                 /*
1255                  *      Unknown or private ioctl
1256                  */
1257 
1258                 default:
1259                         if((getset >= SIOCDEVPRIVATE) &&
1260                            (getset <= (SIOCDEVPRIVATE + 15))) {
1261                                 if(dev->do_ioctl==NULL)
1262                                         return -EOPNOTSUPP;
1263                                 ret=dev->do_ioctl(dev, &ifr, getset);
1264                                 memcpy_tofs(arg,&ifr,sizeof(struct ifreq));
1265                                 break;
1266                         }
1267                         
1268                         ret = -EINVAL;
1269         }
1270         return(ret);
1271 /*
1272  *      The load of calls that return an ifreq and ok (saves memory).
1273  */
1274 rarok:
1275         memcpy_tofs(arg, &ifr, sizeof(struct ifreq));
1276         return 0;
1277 }
1278 
1279 
1280 /*
1281  *      This function handles all "interface"-type I/O control requests. The actual
1282  *      'doing' part of this is dev_ifsioc above.
1283  */
1284 
1285 int dev_ioctl(unsigned int cmd, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1286 {
1287         switch(cmd) 
1288         {
1289                 case SIOCGIFCONF:
1290                         (void) dev_ifconf((char *) arg);
1291                         return 0;
1292 
1293                 /*
1294                  *      Ioctl calls that can be done by all.
1295                  */
1296                  
1297                 case SIOCGIFFLAGS:
1298                 case SIOCGIFADDR:
1299                 case SIOCGIFDSTADDR:
1300                 case SIOCGIFBRDADDR:
1301                 case SIOCGIFNETMASK:
1302                 case SIOCGIFMETRIC:
1303                 case SIOCGIFMTU:
1304                 case SIOCGIFMEM:
1305                 case SIOCGIFHWADDR:
1306                 case SIOCSIFHWADDR:
1307                 case SIOCGIFSLAVE:
1308                 case SIOCGIFMAP:
1309                         return dev_ifsioc(arg, cmd);
1310 
1311                 /*
1312                  *      Ioctl calls requiring the power of a superuser
1313                  */
1314                  
1315                 case SIOCSIFFLAGS:
1316                 case SIOCSIFADDR:
1317                 case SIOCSIFDSTADDR:
1318                 case SIOCSIFBRDADDR:
1319                 case SIOCSIFNETMASK:
1320                 case SIOCSIFMETRIC:
1321                 case SIOCSIFMTU:
1322                 case SIOCSIFMEM:
1323                 case SIOCSIFMAP:
1324                 case SIOCSIFSLAVE:
1325                 case SIOCADDMULTI:
1326                 case SIOCDELMULTI:
1327                         if (!suser())
1328                                 return -EPERM;
1329                         return dev_ifsioc(arg, cmd);
1330         
1331                 case SIOCSIFLINK:
1332                         return -EINVAL;
1333 
1334                 /*
1335                  *      Unknown or private ioctl.
1336                  */     
1337                  
1338                 default:
1339                         if((cmd >= SIOCDEVPRIVATE) &&
1340                            (cmd <= (SIOCDEVPRIVATE + 15))) {
1341                                 return dev_ifsioc(arg, cmd);
1342                         }
1343                         return -EINVAL;
1344         }
1345 }
1346 
1347 
1348 /*
1349  *      Initialize the DEV module. At boot time this walks the device list and
1350  *      unhooks any devices that fail to initialise (normally hardware not 
1351  *      present) and leaves us with a valid list of present and active devices.
1352  *
1353  */
1354 extern int lance_init(void);
1355 extern int ni65_init(void);
1356 extern int pi_init(void);
1357 extern void sdla_setup(void);
1358 extern void dlci_setup(void);
1359 
1360 int net_dev_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1361 {
1362         struct device *dev, **dp;
1363 
1364         /*
1365          *      Initialise the packet receive queue.
1366          */
1367          
1368         skb_queue_head_init(&backlog);
1369         
1370         /*
1371          *      The bridge has to be up before the devices
1372          */
1373 
1374 #ifdef CONFIG_BRIDGE     
1375         br_init();
1376 #endif  
1377         
1378         /*
1379          * This is Very Ugly(tm).
1380          *
1381          * Some devices want to be initialized early..
1382          */
1383 #if defined(CONFIG_LANCE)
1384         lance_init();
1385 #endif
1386 #if defined(CONFIG_NI65)
1387         ni65_init();
1388 #endif
1389 #if defined(CONFIG_PI)
1390         pi_init();
1391 #endif  
1392 #if defined(CONFIG_PT)
1393         pt_init();
1394 #endif
1395 #if defined(CONFIG_DLCI)
1396         dlci_setup();
1397 #endif
1398 #if defined(CONFIG_SDLA)
1399         sdla_setup();
1400 #endif
1401         /*
1402          *      SLHC if present needs attaching so other people see it
1403          *      even if not opened.
1404          */
1405 #if (defined(CONFIG_SLIP) && defined(CONFIG_SLIP_COMPRESSED)) \
1406          || defined(CONFIG_PPP) \
1407     || (defined(CONFIG_ISDN) && defined(CONFIG_ISDN_PPP))
1408         slhc_install();
1409 #endif  
1410 
1411         /*
1412          *      Add the devices.
1413          *      If the call to dev->init fails, the dev is removed
1414          *      from the chain disconnecting the device until the
1415          *      next reboot.
1416          */
1417 
1418         dp = &dev_base;
1419         while ((dev = *dp) != NULL)
1420         {
1421                 int i;
1422                 for (i = 0; i < DEV_NUMBUFFS; i++)  {
1423                         skb_queue_head_init(dev->buffs + i);
1424                 }
1425 
1426                 if (dev->init && dev->init(dev)) 
1427                 {
1428                         /*
1429                          *      It failed to come up. Unhook it.
1430                          */
1431                         *dp = dev->next;
1432                 } 
1433                 else
1434                 {
1435                         dp = &dev->next;
1436                 }
1437         }
1438 
1439 #ifdef CONFIG_PROC_FS
1440         proc_net_register(&(struct proc_dir_entry) {
1441                 PROC_NET_DEV, 3, "dev",
1442                 S_IFREG | S_IRUGO, 1, 0, 0,
1443                 0, &proc_net_inode_operations,
1444                 dev_get_info
1445         });
1446 #endif
1447 
1448         /*      
1449          *      Initialise net_alias engine 
1450          *
1451          *              - register net_alias device notifier
1452          *              - register proc entries:        /proc/net/alias_types
1453          *                                                                      /proc/net/aliases
1454          */
1455 
1456 #ifdef CONFIG_NET_ALIAS
1457         net_alias_init();
1458 #endif
1459 
1460         init_bh(NET_BH, net_bh);
1461         return 0;
1462 }

/* [previous][next][first][last][top][bottom][index][help] */