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          *      Blank the IP addresses
 296          */
 297         dev->pa_addr = 0;
 298         dev->pa_dstaddr = 0;
 299         dev->pa_brdaddr = 0;
 300         dev->pa_mask = 0;
 301         /*
 302          *      Purge any queued packets when we down the link 
 303          */
 304         while(ct<DEV_NUMBUFFS)
 305         {
 306                 struct sk_buff *skb;
 307                 while((skb=skb_dequeue(&dev->buffs[ct]))!=NULL)
 308                         if(skb->free)
 309                                 kfree_skb(skb,FREE_WRITE);
 310                 ct++;
 311         }
 312         return(0);
 313 }
 314 
 315 
 316 /*
 317  *      Device change register/unregister. These are not inline or static
 318  *      as we export them to the world.
 319  */
 320 
 321 int register_netdevice_notifier(struct notifier_block *nb)
     /* [previous][next][first][last][top][bottom][index][help] */
 322 {
 323         return notifier_chain_register(&netdev_chain, nb);
 324 }
 325 
 326 int unregister_netdevice_notifier(struct notifier_block *nb)
     /* [previous][next][first][last][top][bottom][index][help] */
 327 {
 328         return notifier_chain_unregister(&netdev_chain,nb);
 329 }
 330 
 331 /*
 332  *      Send (or queue for sending) a packet. 
 333  *
 334  *      IMPORTANT: When this is called to resend frames. The caller MUST
 335  *      already have locked the sk_buff. Apart from that we do the
 336  *      rest of the magic.
 337  */
 338 
 339 void dev_queue_xmit(struct sk_buff *skb, struct device *dev, int pri)
     /* [previous][next][first][last][top][bottom][index][help] */
 340 {
 341         unsigned long flags;
 342         struct sk_buff_head *list;
 343         int retransmission = 0; /* used to say if the packet should go  */
 344                                 /* at the front or the back of the      */
 345                                 /* queue - front is a retransmit try    */
 346 
 347         if(pri>=0 && !skb_device_locked(skb))
 348                 skb_device_lock(skb);   /* Shove a lock on the frame */
 349 #if CONFIG_SKB_CHECK 
 350         IS_SKB(skb);
 351 #endif    
 352         skb->dev = dev;
 353 
 354         /*
 355          *      Negative priority is used to flag a frame that is being pulled from the
 356          *      queue front as a retransmit attempt. It therefore goes back on the queue
 357          *      start on a failure.
 358          */
 359          
 360         if (pri < 0) 
 361         {
 362                 pri = -pri-1;
 363                 retransmission = 1;
 364         }
 365 
 366 #ifdef CONFIG_NET_DEBUG
 367         if (pri >= DEV_NUMBUFFS) 
 368         {
 369                 printk("bad priority in dev_queue_xmit.\n");
 370                 pri = 1;
 371         }
 372 #endif
 373 
 374         /*
 375          *      If the address has not been resolved. Call the device header rebuilder.
 376          *      This can cover all protocols and technically not just ARP either.
 377          */
 378          
 379         if (!skb->arp && dev->rebuild_header(skb->data, dev, skb->raddr, skb)) {
 380                 return;
 381         }
 382 
 383         /*
 384          *
 385          *      If dev is an alias, switch to its main device.
 386          *      "arp" resolution has been made with alias device, so
 387          *      arp entries refer to alias, not main.
 388          *
 389          */
 390 
 391 #ifdef CONFIG_NET_ALIAS
 392         if (net_alias_is(dev))
 393                 skb->dev = dev = net_alias_main_dev(dev);
 394 #endif
 395 
 396         /*
 397          *      If we are bridging and this is directly generated output
 398          *      pass the frame via the bridge.
 399          */
 400 
 401 #ifdef CONFIG_BRIDGE
 402         if(skb->pkt_bridged!=IS_BRIDGED && br_stats.flags & BR_UP)
 403         {
 404                 if(br_tx_frame(skb))
 405                         return;
 406         }
 407 #endif
 408 
 409         list = dev->buffs + pri;
 410 
 411         save_flags(flags);
 412         /* if this isn't a retransmission, use the first packet instead... */
 413         if (!retransmission) {
 414                 if (skb_queue_len(list)) {
 415                         /* avoid overrunning the device queue.. */
 416                         if (skb_queue_len(list) > dev->tx_queue_len) {
 417                                 dev_kfree_skb(skb, FREE_WRITE);
 418                                 return;
 419                         }
 420                         cli();
 421                         skb_device_unlock(skb);         /* Buffer is on the device queue and can be freed safely */
 422                         __skb_queue_tail(list, skb);
 423                         skb = __skb_dequeue(list);
 424                         skb_device_lock(skb);           /* New buffer needs locking down */
 425                         restore_flags(flags);
 426                 }
 427                 
 428                 /* copy outgoing packets to any sniffer packet handlers */
 429                 if (dev_nit) {
 430                         struct packet_type *ptype;
 431                         skb->stamp=xtime;
 432                         for (ptype = ptype_all; ptype!=NULL; ptype = ptype->next) 
 433                         {
 434                                 /* Never send packets back to the socket
 435                                  * they originated from - MvS (miquels@drinkel.ow.org)
 436                                  */
 437                                 if ((ptype->dev == dev || !ptype->dev) &&
 438                                    ((struct sock *)ptype->data != skb->sk))
 439                                 {
 440                                         struct sk_buff *skb2;
 441                                         if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL)
 442                                                 break;
 443                                         skb2->h.raw = skb2->data + dev->hard_header_len;
 444                                         skb2->mac.raw = skb2->data;
 445                                         ptype->func(skb2, skb->dev, ptype);
 446                                 }
 447                         }
 448                 }
 449         }
 450         start_bh_atomic();
 451         if (dev->hard_start_xmit(skb, dev) == 0) {
 452                 /*
 453                  *      Packet is now solely the responsibility of the driver
 454                  */
 455                 end_bh_atomic();
 456                 return;
 457         }
 458         end_bh_atomic();
 459 
 460         /*
 461          *      Transmission failed, put skb back into a list. Once on the list it's safe and
 462          *      no longer device locked (it can be freed safely from the device queue)
 463          */
 464         cli();
 465         skb_device_unlock(skb);
 466         __skb_queue_head(list,skb);
 467         restore_flags(flags);
 468 }
 469 
 470 /*
 471  *      Receive a packet from a device driver and queue it for the upper
 472  *      (protocol) levels.  It always succeeds. This is the recommended 
 473  *      interface to use.
 474  */
 475 
 476 void netif_rx(struct sk_buff *skb)
     /* [previous][next][first][last][top][bottom][index][help] */
 477 {
 478         static int dropping = 0;
 479 
 480         /*
 481          *      Any received buffers are un-owned and should be discarded
 482          *      when freed. These will be updated later as the frames get
 483          *      owners.
 484          */
 485 
 486         skb->sk = NULL;
 487         skb->free = 1;
 488         if(skb->stamp.tv_sec==0)
 489                 skb->stamp = xtime;
 490 
 491         /*
 492          *      Check that we aren't overdoing things.
 493          */
 494 
 495         if (!backlog_size)
 496                 dropping = 0;
 497         else if (backlog_size > 300)
 498                 dropping = 1;
 499 
 500         if (dropping) 
 501         {
 502                 kfree_skb(skb, FREE_READ);
 503                 return;
 504         }
 505 
 506         /*
 507          *      Add it to the "backlog" queue. 
 508          */
 509 #if CONFIG_SKB_CHECK
 510         IS_SKB(skb);
 511 #endif  
 512         skb_queue_tail(&backlog,skb);
 513         backlog_size++;
 514   
 515         /*
 516          *      If any packet arrived, mark it for processing after the
 517          *      hardware interrupt returns.
 518          */
 519 
 520         mark_bh(NET_BH);
 521         return;
 522 }
 523 
 524 /*
 525  *      This routine causes all interfaces to try to send some data. 
 526  */
 527  
 528 void dev_transmit(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 529 {
 530         struct device *dev;
 531 
 532         for (dev = dev_base; dev != NULL; dev = dev->next)
 533         {
 534                 if (dev->flags != 0 && !dev->tbusy) {
 535                         /*
 536                          *      Kick the device
 537                          */
 538                         dev_tint(dev);
 539                 }
 540         }
 541 }
 542 
 543 
 544 /**********************************************************************************
 545 
 546                         Receive Queue Processor
 547                         
 548 ***********************************************************************************/
 549 
 550 /*
 551  *      When we are called the queue is ready to grab, the interrupts are
 552  *      on and hardware can interrupt and queue to the receive queue a we
 553  *      run with no problems.
 554  *      This is run as a bottom half after an interrupt handler that does
 555  *      mark_bh(NET_BH);
 556  */
 557  
 558 void net_bh(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 559 {
 560         struct packet_type *ptype;
 561         struct packet_type *pt_prev;
 562         unsigned short type;
 563 
 564         /*
 565          *      Can we send anything now? We want to clear the
 566          *      decks for any more sends that get done as we
 567          *      process the input. This also minimises the
 568          *      latency on a transmit interrupt bh.
 569          */
 570 
 571         dev_transmit();
 572   
 573         /*
 574          *      Any data left to process. This may occur because a
 575          *      mark_bh() is done after we empty the queue including
 576          *      that from the device which does a mark_bh() just after
 577          */
 578 
 579         /*
 580          *      While the queue is not empty..
 581          *
 582          *      Note that the queue never shrinks due to
 583          *      an interrupt, so we can do this test without
 584          *      disabling interrupts.
 585          */
 586 
 587         while (!skb_queue_empty(&backlog)) {
 588                 struct sk_buff * skb = backlog.next;
 589 
 590                 /*
 591                  *      We have a packet. Therefore the queue has shrunk
 592                  */
 593                 cli();
 594                 __skb_unlink(skb, &backlog);
 595                 backlog_size--;
 596                 sti();
 597                 
 598 
 599 #ifdef CONFIG_BRIDGE
 600 
 601                 /*
 602                  *      If we are bridging then pass the frame up to the
 603                  *      bridging code. If it is bridged then move on
 604                  */
 605                  
 606                 if (br_stats.flags & BR_UP)
 607                 {
 608                         /*
 609                          *      We pass the bridge a complete frame. This means
 610                          *      recovering the MAC header first.
 611                          */
 612                          
 613                         int offset=skb->data-skb->mac.raw;
 614                         cli();
 615                         skb_push(skb,offset);   /* Put header back on for bridge */
 616                         if(br_receive_frame(skb))
 617                                 continue;
 618                         /*
 619                          *      Pull the MAC header off for the copy going to
 620                          *      the upper layers.
 621                          */
 622                         skb_pull(skb,offset);
 623                         sti();
 624                 }
 625 #endif
 626                 
 627                 /*
 628                  *      Bump the pointer to the next structure.
 629                  * 
 630                  *      On entry to the protocol layer. skb->data and
 631                  *      skb->h.raw point to the MAC and encapsulated data
 632                  */
 633 
 634                 skb->h.raw = skb->data;
 635 
 636                 /*
 637                  *      Fetch the packet protocol ID. 
 638                  */
 639                 
 640                 type = skb->protocol;
 641 
 642                 /*
 643                  *      We got a packet ID.  Now loop over the "known protocols"
 644                  *      list. There are two lists. The ptype_all list of taps (normally empty)
 645                  *      and the main protocol list which is hashed perfectly for normal protocols.
 646                  */
 647                 
 648                 pt_prev = NULL;
 649                 for (ptype = ptype_all; ptype!=NULL; ptype=ptype->next)
 650                 {
 651                         if(pt_prev)
 652                         {
 653                                 struct sk_buff *skb2=skb_clone(skb, GFP_ATOMIC);
 654                                 if(skb2)
 655                                         pt_prev->func(skb2,skb->dev, pt_prev);
 656                         }
 657                         pt_prev=ptype;
 658                 }
 659                 
 660                 for (ptype = ptype_base[ntohs(type)&15]; ptype != NULL; ptype = ptype->next) 
 661                 {
 662                         if (ptype->type == type && (!ptype->dev || ptype->dev==skb->dev))
 663                         {
 664                                 /*
 665                                  *      We already have a match queued. Deliver
 666                                  *      to it and then remember the new match
 667                                  */
 668                                 if(pt_prev)
 669                                 {
 670                                         struct sk_buff *skb2;
 671 
 672                                         skb2=skb_clone(skb, GFP_ATOMIC);
 673 
 674                                         /*
 675                                          *      Kick the protocol handler. This should be fast
 676                                          *      and efficient code.
 677                                          */
 678 
 679                                         if(skb2)
 680                                                 pt_prev->func(skb2, skb->dev, pt_prev);
 681                                 }
 682                                 /* Remember the current last to do */
 683                                 pt_prev=ptype;
 684                         }
 685                 } /* End of protocol list loop */
 686                 
 687                 /*
 688                  *      Is there a last item to send to ?
 689                  */
 690 
 691                 if(pt_prev)
 692                         pt_prev->func(skb, skb->dev, pt_prev);
 693                 /*
 694                  *      Has an unknown packet has been received ?
 695                  */
 696          
 697                 else
 698                         kfree_skb(skb, FREE_WRITE);
 699                 /*
 700                  *      Again, see if we can transmit anything now. 
 701                  *      [Ought to take this out judging by tests it slows
 702                  *       us down not speeds us up]
 703                  */
 704 #ifdef XMIT_EVERY
 705                 dev_transmit();
 706 #endif          
 707         }       /* End of queue loop */
 708         
 709         /*
 710          *      We have emptied the queue
 711          */
 712         
 713         /*
 714          *      One last output flush.
 715          */
 716 
 717 #ifdef XMIT_AFTER        
 718         dev_transmit();
 719 #endif
 720 }
 721 
 722 
 723 /*
 724  *      This routine is called when an device driver (i.e. an
 725  *      interface) is ready to transmit a packet.
 726  */
 727  
 728 void dev_tint(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 729 {
 730         int i;
 731         unsigned long flags;
 732         struct sk_buff_head * head;
 733         
 734         /*
 735          * aliases do not transmit (for now :) )
 736          */
 737 
 738 #ifdef CONFIG_NET_ALIAS
 739         if (net_alias_is(dev)) return;
 740 #endif
 741         head = dev->buffs;
 742         save_flags(flags);
 743         cli();
 744 
 745         /*
 746          *      Work the queues in priority order
 747          */      
 748         for(i = 0;i < DEV_NUMBUFFS; i++,head++)
 749         {
 750 
 751                 while (!skb_queue_empty(head)) {
 752                         struct sk_buff *skb;
 753 
 754                         skb = head->next;
 755                         __skb_unlink(skb, head);
 756                         /*
 757                          *      Stop anyone freeing the buffer while we retransmit it
 758                          */
 759                         skb_device_lock(skb);
 760                         restore_flags(flags);
 761                         /*
 762                          *      Feed them to the output stage and if it fails
 763                          *      indicate they re-queue at the front.
 764                          */
 765                         dev_queue_xmit(skb,dev,-i - 1);
 766                         /*
 767                          *      If we can take no more then stop here.
 768                          */
 769                         if (dev->tbusy)
 770                                 return;
 771                         cli();
 772                 }
 773         }
 774         restore_flags(flags);
 775 }
 776 
 777 
 778 /*
 779  *      Perform a SIOCGIFCONF call. This structure will change
 780  *      size shortly, and there is nothing I can do about it.
 781  *      Thus we will need a 'compatibility mode'.
 782  */
 783 
 784 static int dev_ifconf(char *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 785 {
 786         struct ifconf ifc;
 787         struct ifreq ifr;
 788         struct device *dev;
 789         char *pos;
 790         int len;
 791         int err;
 792 
 793         /*
 794          *      Fetch the caller's info block. 
 795          */
 796          
 797         err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifconf));
 798         if(err)
 799                 return err;
 800         memcpy_fromfs(&ifc, arg, sizeof(struct ifconf));
 801         len = ifc.ifc_len;
 802         pos = ifc.ifc_buf;
 803 
 804         /*
 805          *      We now walk the device list filling each active device
 806          *      into the array.
 807          */
 808          
 809         err=verify_area(VERIFY_WRITE,pos,len);
 810         if(err)
 811                 return err;
 812         
 813         /*
 814          *      Loop over the interfaces, and write an info block for each. 
 815          */
 816 
 817         for (dev = dev_base; dev != NULL; dev = dev->next) 
 818         {
 819                 if(!(dev->flags & IFF_UP))      /* Downed devices don't count */
 820                         continue;
 821                 /*
 822                  *      Have we run out of space here ?
 823                  */
 824         
 825                 if (len < sizeof(struct ifreq)) 
 826                         break;
 827 
 828                 memset(&ifr, 0, sizeof(struct ifreq));
 829                 strcpy(ifr.ifr_name, dev->name);
 830                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_family = dev->family;
 831                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
 832 
 833 
 834                 /*
 835                  *      Write this block to the caller's space. 
 836                  */
 837                  
 838                 memcpy_tofs(pos, &ifr, sizeof(struct ifreq));
 839                 pos += sizeof(struct ifreq);
 840                 len -= sizeof(struct ifreq);            
 841         }
 842 
 843         /*
 844          *      All done.  Write the updated control block back to the caller. 
 845          */
 846          
 847         ifc.ifc_len = (pos - ifc.ifc_buf);
 848         ifc.ifc_req = (struct ifreq *) ifc.ifc_buf;
 849         memcpy_tofs(arg, &ifc, sizeof(struct ifconf));
 850         
 851         /*
 852          *      Report how much was filled in
 853          */
 854          
 855         return(pos - arg);
 856 }
 857 
 858 
 859 /*
 860  *      This is invoked by the /proc filesystem handler to display a device
 861  *      in detail.
 862  */
 863 
 864 #ifdef CONFIG_PROC_FS
 865 static int sprintf_stats(char *buffer, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 866 {
 867         struct enet_statistics *stats = (dev->get_stats ? dev->get_stats(dev): NULL);
 868         int size;
 869         
 870         if (stats)
 871                 size = sprintf(buffer, "%6s:%7d %4d %4d %4d %4d %8d %4d %4d %4d %5d %4d\n",
 872                    dev->name,
 873                    stats->rx_packets, stats->rx_errors,
 874                    stats->rx_dropped + stats->rx_missed_errors,
 875                    stats->rx_fifo_errors,
 876                    stats->rx_length_errors + stats->rx_over_errors
 877                    + stats->rx_crc_errors + stats->rx_frame_errors,
 878                    stats->tx_packets, stats->tx_errors, stats->tx_dropped,
 879                    stats->tx_fifo_errors, stats->collisions,
 880                    stats->tx_carrier_errors + stats->tx_aborted_errors
 881                    + stats->tx_window_errors + stats->tx_heartbeat_errors);
 882         else
 883                 size = sprintf(buffer, "%6s: No statistics available.\n", dev->name);
 884 
 885         return size;
 886 }
 887 
 888 /*
 889  *      Called from the PROCfs module. This now uses the new arbitrary sized /proc/net interface
 890  *      to create /proc/net/dev
 891  */
 892  
 893 int dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 894 {
 895         int len=0;
 896         off_t begin=0;
 897         off_t pos=0;
 898         int size;
 899         
 900         struct device *dev;
 901 
 902 
 903         size = sprintf(buffer, "Inter-|   Receive                  |  Transmit\n"
 904                             " face |packets errs drop fifo frame|packets errs drop fifo colls carrier\n");
 905         
 906         pos+=size;
 907         len+=size;
 908         
 909 
 910         for (dev = dev_base; dev != NULL; dev = dev->next) 
 911         {
 912                 size = sprintf_stats(buffer+len, dev);
 913                 len+=size;
 914                 pos=begin+len;
 915                                 
 916                 if(pos<offset)
 917                 {
 918                         len=0;
 919                         begin=pos;
 920                 }
 921                 if(pos>offset+length)
 922                         break;
 923         }
 924         
 925         *start=buffer+(offset-begin);   /* Start of wanted data */
 926         len-=(offset-begin);            /* Start slop */
 927         if(len>length)
 928                 len=length;             /* Ending slop */
 929         return len;
 930 }
 931 #endif  /* CONFIG_PROC_FS */
 932 
 933 
 934 /*
 935  *      This checks bitmasks for the ioctl calls for devices.
 936  */
 937  
 938 static inline int bad_mask(unsigned long mask, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 939 {
 940         if (addr & (mask = ~mask))
 941                 return 1;
 942         mask = ntohl(mask);
 943         if (mask & (mask+1))
 944                 return 1;
 945         return 0;
 946 }
 947 
 948 /*
 949  *      Perform the SIOCxIFxxx calls. 
 950  *
 951  *      The socket layer has seen an ioctl the address family thinks is
 952  *      for the device. At this point we get invoked to make a decision
 953  */
 954  
 955 static int dev_ifsioc(void *arg, unsigned int getset)
     /* [previous][next][first][last][top][bottom][index][help] */
 956 {
 957         struct ifreq ifr;
 958         struct device *dev;
 959         int ret;
 960 
 961         /*
 962          *      Fetch the caller's info block into kernel space
 963          */
 964 
 965         int err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifreq));
 966         if(err)
 967                 return err;
 968         
 969         memcpy_fromfs(&ifr, arg, sizeof(struct ifreq));
 970 
 971         /*
 972          *      See which interface the caller is talking about. 
 973          */
 974          
 975         /*
 976          *
 977          *      net_alias_dev_get(): dev_get() with added alias naming magic.
 978          *      only allow alias creation/deletion if (getset==SIOCSIFADDR)
 979          *
 980          */
 981          
 982 #ifdef CONFIG_KERNELD
 983         dev_load(ifr.ifr_name);
 984 #endif  
 985 
 986 #ifdef CONFIG_NET_ALIAS
 987         if ((dev = net_alias_dev_get(ifr.ifr_name, getset == SIOCSIFADDR, &err, NULL, NULL)) == NULL)
 988                 return(err);
 989 #else
 990         if ((dev = dev_get(ifr.ifr_name)) == NULL)      
 991                 return(-ENODEV);
 992 #endif
 993         switch(getset) 
 994         {
 995                 case SIOCGIFFLAGS:      /* Get interface flags */
 996                         ifr.ifr_flags = dev->flags;
 997                         goto rarok;
 998 
 999                 case SIOCSIFFLAGS:      /* Set interface flags */
1000                         {
1001                                 int old_flags = dev->flags;
1002                                 
1003                                 /*
1004                                  *      We are not allowed to potentially close/unload
1005                                  *      a device until we get this lock.
1006                                  */
1007                                 
1008                                 dev_lock_wait();
1009                                 
1010                                 /*
1011                                  *      Set the flags on our device.
1012                                  */
1013                                  
1014                                 dev->flags = (ifr.ifr_flags & (
1015                                         IFF_BROADCAST | IFF_DEBUG | IFF_LOOPBACK |
1016                                         IFF_POINTOPOINT | IFF_NOTRAILERS | IFF_RUNNING |
1017                                         IFF_NOARP | IFF_PROMISC | IFF_ALLMULTI | IFF_SLAVE | IFF_MASTER
1018                                         | IFF_MULTICAST)) | (dev->flags & IFF_UP);
1019                                 /*
1020                                  *      Load in the correct multicast list now the flags have changed.
1021                                  */                             
1022 
1023                                 dev_mc_upload(dev);
1024 
1025                                 /*
1026                                  *      Have we downed the interface. We handle IFF_UP ourselves
1027                                  *      according to user attempts to set it, rather than blindly
1028                                  *      setting it.
1029                                  */
1030                                  
1031                                 if ((old_flags^ifr.ifr_flags)&IFF_UP)   /* Bit is different  ? */
1032                                 {
1033                                         if(old_flags&IFF_UP)            /* Gone down */
1034                                                 ret=dev_close(dev);             
1035                                         else                            /* Come up */
1036                                         {
1037                                                 ret=dev_open(dev);
1038                                                 if(ret<0)
1039                                                         dev->flags&=~IFF_UP;    /* Open failed */
1040                                         }       
1041                                 }
1042                                 else
1043                                         ret=0;
1044                                 /*
1045                                  *      Load in the correct multicast list now the flags have changed.
1046                                  */                             
1047 
1048                                 dev_mc_upload(dev);
1049                         }
1050                         break;
1051                 
1052                 case SIOCGIFADDR:       /* Get interface address (and family) */
1053                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1054                         {
1055                                 memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1056                                 ifr.ifr_hwaddr.sa_family=dev->type;                     
1057                                 goto rarok;
1058                         }
1059                         else
1060                         {
1061                                 (*(struct sockaddr_in *)
1062                                           &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
1063                                 (*(struct sockaddr_in *)
1064                                           &ifr.ifr_addr).sin_family = dev->family;
1065                                 (*(struct sockaddr_in *)
1066                                           &ifr.ifr_addr).sin_port = 0;
1067                         }
1068                         goto rarok;
1069         
1070                 case SIOCSIFADDR:       /* Set interface address (and family) */
1071                 
1072                         /*
1073                          *      BSDism. SIOCSIFADDR family=AF_UNSPEC sets the
1074                          *      physical address. We can cope with this now.
1075                          */
1076                         
1077                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1078                         {
1079                                 if(dev->set_mac_address==NULL)
1080                                         return -EOPNOTSUPP;
1081                                 ret=dev->set_mac_address(dev,&ifr.ifr_addr);
1082                         }
1083                         else
1084                         {
1085 
1086                                 /*
1087                                  *      if dev is an alias, must rehash to update
1088                                  *      address change
1089                                  */
1090 
1091 #ifdef CONFIG_NET_ALIAS
1092                                 if (net_alias_is(dev))
1093                                 net_alias_dev_rehash(dev ,&ifr.ifr_addr);
1094 #endif
1095                                 dev->pa_addr = (*(struct sockaddr_in *)
1096                                          &ifr.ifr_addr).sin_addr.s_addr;
1097                                 dev->family = ifr.ifr_addr.sa_family;
1098                         
1099 #ifdef CONFIG_INET      
1100                                 /* This is naughty. When net-032e comes out It wants moving into the net032
1101                                    code not the kernel. Till then it can sit here (SIGH) */             
1102                                 dev->pa_mask = ip_get_mask(dev->pa_addr);
1103 #endif                  
1104                                 dev->pa_brdaddr = dev->pa_addr | ~dev->pa_mask;
1105                                 ret = 0;
1106                         }
1107                         break;
1108                         
1109                 case SIOCGIFBRDADDR:    /* Get the broadcast address */
1110                         (*(struct sockaddr_in *)
1111                                 &ifr.ifr_broadaddr).sin_addr.s_addr = dev->pa_brdaddr;
1112                         (*(struct sockaddr_in *)
1113                                 &ifr.ifr_broadaddr).sin_family = dev->family;
1114                         (*(struct sockaddr_in *)
1115                                 &ifr.ifr_broadaddr).sin_port = 0;
1116                         goto rarok;
1117 
1118                 case SIOCSIFBRDADDR:    /* Set the broadcast address */
1119                         dev->pa_brdaddr = (*(struct sockaddr_in *)
1120                                 &ifr.ifr_broadaddr).sin_addr.s_addr;
1121                         ret = 0;
1122                         break;
1123                         
1124                 case SIOCGIFDSTADDR:    /* Get the destination address (for point-to-point links) */
1125                         (*(struct sockaddr_in *)
1126                                 &ifr.ifr_dstaddr).sin_addr.s_addr = dev->pa_dstaddr;
1127                         (*(struct sockaddr_in *)
1128                                 &ifr.ifr_dstaddr).sin_family = dev->family;
1129                         (*(struct sockaddr_in *)
1130                                 &ifr.ifr_dstaddr).sin_port = 0;
1131                         goto rarok;
1132         
1133                 case SIOCSIFDSTADDR:    /* Set the destination address (for point-to-point links) */
1134                         dev->pa_dstaddr = (*(struct sockaddr_in *)
1135                                 &ifr.ifr_dstaddr).sin_addr.s_addr;
1136                         ret = 0;
1137                         break;
1138                         
1139                 case SIOCGIFNETMASK:    /* Get the netmask for the interface */
1140                         (*(struct sockaddr_in *)
1141                                 &ifr.ifr_netmask).sin_addr.s_addr = dev->pa_mask;
1142                         (*(struct sockaddr_in *)
1143                                 &ifr.ifr_netmask).sin_family = dev->family;
1144                         (*(struct sockaddr_in *)
1145                                 &ifr.ifr_netmask).sin_port = 0;
1146                         goto rarok;
1147 
1148                 case SIOCSIFNETMASK:    /* Set the netmask for the interface */
1149                         {
1150                                 unsigned long mask = (*(struct sockaddr_in *)
1151                                         &ifr.ifr_netmask).sin_addr.s_addr;
1152                                 ret = -EINVAL;
1153                                 /*
1154                                  *      The mask we set must be legal.
1155                                  */
1156                                 if (bad_mask(mask,0))
1157                                         break;
1158                                 dev->pa_mask = mask;
1159                                 ret = 0;
1160                         }
1161                         break;
1162                         
1163                 case SIOCGIFMETRIC:     /* Get the metric on the interface (currently unused) */
1164                         
1165                         ifr.ifr_metric = dev->metric;
1166                         goto  rarok;
1167                         
1168                 case SIOCSIFMETRIC:     /* Set the metric on the interface (currently unused) */
1169                         dev->metric = ifr.ifr_metric;
1170                         ret=0;
1171                         break;
1172         
1173                 case SIOCGIFMTU:        /* Get the MTU of a device */
1174                         ifr.ifr_mtu = dev->mtu;
1175                         goto rarok;
1176         
1177                 case SIOCSIFMTU:        /* Set the MTU of a device */
1178                 
1179                         /*
1180                          *      MTU must be positive.
1181                          */
1182                          
1183                         if(ifr.ifr_mtu<68)
1184                                 return -EINVAL;
1185 
1186                         if (dev->change_mtu)
1187                                 ret = (*dev->change_mtu)(dev, ifr.ifr_mtu);
1188                         else
1189                         {
1190                                 dev->mtu = ifr.ifr_mtu;
1191                                 ret = 0;
1192                         }
1193                         break;
1194         
1195                 case SIOCGIFMEM:        /* Get the per device memory space. We can add this but currently
1196                                            do not support it */
1197                         ret = -EINVAL;
1198                         break;
1199                 
1200                 case SIOCSIFMEM:        /* Set the per device memory buffer space. Not applicable in our case */
1201                         ret = -EINVAL;
1202                         break;
1203 
1204                 case SIOCGIFHWADDR:
1205                         memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1206                         ifr.ifr_hwaddr.sa_family=dev->type;                     
1207                         goto rarok;
1208                                 
1209                 case SIOCSIFHWADDR:
1210                         if(dev->set_mac_address==NULL)
1211                                 return -EOPNOTSUPP;
1212                         if(ifr.ifr_hwaddr.sa_family!=dev->type)
1213                                 return -EINVAL;
1214                         ret=dev->set_mac_address(dev,&ifr.ifr_hwaddr);
1215                         break;
1216                         
1217                 case SIOCGIFMAP:
1218                         ifr.ifr_map.mem_start=dev->mem_start;
1219                         ifr.ifr_map.mem_end=dev->mem_end;
1220                         ifr.ifr_map.base_addr=dev->base_addr;
1221                         ifr.ifr_map.irq=dev->irq;
1222                         ifr.ifr_map.dma=dev->dma;
1223                         ifr.ifr_map.port=dev->if_port;
1224                         goto rarok;
1225                         
1226                 case SIOCSIFMAP:
1227                         if(dev->set_config==NULL)
1228                                 return -EOPNOTSUPP;
1229                         return dev->set_config(dev,&ifr.ifr_map);
1230                         
1231                 case SIOCADDMULTI:
1232                         if(dev->set_multicast_list==NULL)
1233                                 return -EINVAL;
1234                         if(ifr.ifr_hwaddr.sa_family!=AF_UNSPEC)
1235                                 return -EINVAL;
1236                         dev_mc_add(dev,ifr.ifr_hwaddr.sa_data, dev->addr_len, 1);
1237                         return 0;
1238 
1239                 case SIOCDELMULTI:
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_delete(dev,ifr.ifr_hwaddr.sa_data,dev->addr_len, 1);
1245                         return 0;
1246                 /*
1247                  *      Unknown or private ioctl
1248                  */
1249 
1250                 default:
1251                         if((getset >= SIOCDEVPRIVATE) &&
1252                            (getset <= (SIOCDEVPRIVATE + 15))) {
1253                                 if(dev->do_ioctl==NULL)
1254                                         return -EOPNOTSUPP;
1255                                 ret=dev->do_ioctl(dev, &ifr, getset);
1256                                 memcpy_tofs(arg,&ifr,sizeof(struct ifreq));
1257                                 break;
1258                         }
1259                         
1260                         ret = -EINVAL;
1261         }
1262         return(ret);
1263 /*
1264  *      The load of calls that return an ifreq and ok (saves memory).
1265  */
1266 rarok:
1267         memcpy_tofs(arg, &ifr, sizeof(struct ifreq));
1268         return 0;
1269 }
1270 
1271 
1272 /*
1273  *      This function handles all "interface"-type I/O control requests. The actual
1274  *      'doing' part of this is dev_ifsioc above.
1275  */
1276 
1277 int dev_ioctl(unsigned int cmd, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1278 {
1279         switch(cmd) 
1280         {
1281                 case SIOCGIFCONF:
1282                         (void) dev_ifconf((char *) arg);
1283                         return 0;
1284 
1285                 /*
1286                  *      Ioctl calls that can be done by all.
1287                  */
1288                  
1289                 case SIOCGIFFLAGS:
1290                 case SIOCGIFADDR:
1291                 case SIOCGIFDSTADDR:
1292                 case SIOCGIFBRDADDR:
1293                 case SIOCGIFNETMASK:
1294                 case SIOCGIFMETRIC:
1295                 case SIOCGIFMTU:
1296                 case SIOCGIFMEM:
1297                 case SIOCGIFHWADDR:
1298                 case SIOCSIFHWADDR:
1299                 case SIOCGIFSLAVE:
1300                 case SIOCGIFMAP:
1301                         return dev_ifsioc(arg, cmd);
1302 
1303                 /*
1304                  *      Ioctl calls requiring the power of a superuser
1305                  */
1306                  
1307                 case SIOCSIFFLAGS:
1308                 case SIOCSIFADDR:
1309                 case SIOCSIFDSTADDR:
1310                 case SIOCSIFBRDADDR:
1311                 case SIOCSIFNETMASK:
1312                 case SIOCSIFMETRIC:
1313                 case SIOCSIFMTU:
1314                 case SIOCSIFMEM:
1315                 case SIOCSIFMAP:
1316                 case SIOCSIFSLAVE:
1317                 case SIOCADDMULTI:
1318                 case SIOCDELMULTI:
1319                         if (!suser())
1320                                 return -EPERM;
1321                         return dev_ifsioc(arg, cmd);
1322         
1323                 case SIOCSIFLINK:
1324                         return -EINVAL;
1325 
1326                 /*
1327                  *      Unknown or private ioctl.
1328                  */     
1329                  
1330                 default:
1331                         if((cmd >= SIOCDEVPRIVATE) &&
1332                            (cmd <= (SIOCDEVPRIVATE + 15))) {
1333                                 return dev_ifsioc(arg, cmd);
1334                         }
1335                         return -EINVAL;
1336         }
1337 }
1338 
1339 
1340 /*
1341  *      Initialize the DEV module. At boot time this walks the device list and
1342  *      unhooks any devices that fail to initialise (normally hardware not 
1343  *      present) and leaves us with a valid list of present and active devices.
1344  *
1345  */
1346 extern int lance_init(void);
1347 extern int ni65_init(void);
1348 extern int pi_init(void);
1349 extern void sdla_setup(void);
1350 extern void dlci_setup(void);
1351 
1352 int net_dev_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1353 {
1354         struct device *dev, **dp;
1355 
1356         /*
1357          *      Initialise the packet receive queue.
1358          */
1359          
1360         skb_queue_head_init(&backlog);
1361         
1362         /*
1363          *      The bridge has to be up before the devices
1364          */
1365 
1366 #ifdef CONFIG_BRIDGE     
1367         br_init();
1368 #endif  
1369         
1370         /*
1371          * This is Very Ugly(tm).
1372          *
1373          * Some devices want to be initialized early..
1374          */
1375 #if defined(CONFIG_LANCE)
1376         lance_init();
1377 #endif
1378 #if defined(CONFIG_NI65)
1379         ni65_init();
1380 #endif
1381 #if defined(CONFIG_PI)
1382         pi_init();
1383 #endif  
1384 #if defined(CONFIG_PT)
1385         pt_init();
1386 #endif
1387 #if defined(CONFIG_DLCI)
1388         dlci_setup();
1389 #endif
1390 #if defined(CONFIG_SDLA)
1391         sdla_setup();
1392 #endif
1393         /*
1394          *      SLHC if present needs attaching so other people see it
1395          *      even if not opened.
1396          */
1397 #if (defined(CONFIG_SLIP) && defined(CONFIG_SLIP_COMPRESSED)) \
1398          || defined(CONFIG_PPP) \
1399     || (defined(CONFIG_ISDN) && defined(CONFIG_ISDN_PPP))
1400         slhc_install();
1401 #endif  
1402 
1403         /*
1404          *      Add the devices.
1405          *      If the call to dev->init fails, the dev is removed
1406          *      from the chain disconnecting the device until the
1407          *      next reboot.
1408          */
1409 
1410         dp = &dev_base;
1411         while ((dev = *dp) != NULL)
1412         {
1413                 int i;
1414                 for (i = 0; i < DEV_NUMBUFFS; i++)  {
1415                         skb_queue_head_init(dev->buffs + i);
1416                 }
1417 
1418                 if (dev->init && dev->init(dev)) 
1419                 {
1420                         /*
1421                          *      It failed to come up. Unhook it.
1422                          */
1423                         *dp = dev->next;
1424                 } 
1425                 else
1426                 {
1427                         dp = &dev->next;
1428                 }
1429         }
1430 
1431 #ifdef CONFIG_PROC_FS
1432         proc_net_register(&(struct proc_dir_entry) {
1433                 PROC_NET_DEV, 3, "dev",
1434                 S_IFREG | S_IRUGO, 1, 0, 0,
1435                 0, &proc_net_inode_operations,
1436                 dev_get_info
1437         });
1438 #endif
1439 
1440         /*      
1441          *      Initialise net_alias engine 
1442          *
1443          *              - register net_alias device notifier
1444          *              - register proc entries:        /proc/net/alias_types
1445          *                                                                      /proc/net/aliases
1446          */
1447 
1448 #ifdef CONFIG_NET_ALIAS
1449         net_alias_init();
1450 #endif
1451 
1452         init_bh(NET_BH, net_bh);
1453         return 0;
1454 }

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