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

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