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                         cli();
 609                         if(br_receive_frame(skb))
 610                                 continue;
 611                         sti();
 612                 }
 613 #endif
 614                 
 615                 /*
 616                  *      Bump the pointer to the next structure.
 617                  * 
 618                  *      On entry to the protocol layer. skb->data and
 619                  *      skb->h.raw point to the MAC and encapsulated data
 620                  */
 621 
 622                 skb->h.raw = skb->data;
 623 
 624                /*
 625                 *       Fetch the packet protocol ID. 
 626                 */
 627                 
 628                 type = skb->protocol;
 629 
 630                 /*
 631                  *      We got a packet ID.  Now loop over the "known protocols"
 632                  *      list. There are two lists. The ptype_all list of taps (normally empty)
 633                  *      and the main protocol list which is hashed perfectly for normal protocols.
 634                  */
 635                 
 636                 pt_prev = NULL;
 637                 for (ptype = ptype_all; ptype!=NULL; ptype=ptype->next)
 638                 {
 639                         if(pt_prev)
 640                         {
 641                                 struct sk_buff *skb2=skb_clone(skb, GFP_ATOMIC);
 642                                 if(skb2)
 643                                         pt_prev->func(skb2,skb->dev, pt_prev);
 644                         }
 645                         pt_prev=ptype;
 646                 }
 647                 
 648                 for (ptype = ptype_base[ntohs(type)&15]; ptype != NULL; ptype = ptype->next) 
 649                 {
 650                         if (ptype->type == type && (!ptype->dev || ptype->dev==skb->dev))
 651                         {
 652                                 /*
 653                                  *      We already have a match queued. Deliver
 654                                  *      to it and then remember the new match
 655                                  */
 656                                 if(pt_prev)
 657                                 {
 658                                         struct sk_buff *skb2;
 659 
 660                                         skb2=skb_clone(skb, GFP_ATOMIC);
 661 
 662                                         /*
 663                                          *      Kick the protocol handler. This should be fast
 664                                          *      and efficient code.
 665                                          */
 666 
 667                                         if(skb2)
 668                                                 pt_prev->func(skb2, skb->dev, pt_prev);
 669                                 }
 670                                 /* Remember the current last to do */
 671                                 pt_prev=ptype;
 672                         }
 673                 } /* End of protocol list loop */
 674                 
 675                 /*
 676                  *      Is there a last item to send to ?
 677                  */
 678 
 679                 if(pt_prev)
 680                         pt_prev->func(skb, skb->dev, pt_prev);
 681                 /*
 682                  *      Has an unknown packet has been received ?
 683                  */
 684          
 685                 else
 686                         kfree_skb(skb, FREE_WRITE);
 687                 /*
 688                  *      Again, see if we can transmit anything now. 
 689                  *      [Ought to take this out judging by tests it slows
 690                  *       us down not speeds us up]
 691                  */
 692 #ifdef XMIT_EVERY
 693                 dev_transmit();
 694 #endif          
 695         }       /* End of queue loop */
 696         
 697         /*
 698          *      We have emptied the queue
 699          */
 700         
 701         /*
 702          *      One last output flush.
 703          */
 704 
 705 #ifdef XMIT_AFTER        
 706         dev_transmit();
 707 #endif
 708 }
 709 
 710 
 711 /*
 712  *      This routine is called when an device driver (i.e. an
 713  *      interface) is ready to transmit a packet.
 714  */
 715  
 716 void dev_tint(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 717 {
 718         int i;
 719         unsigned long flags;
 720         struct sk_buff_head * head;
 721         
 722         /*
 723          * aliases do not transmit (for now :) )
 724          */
 725 
 726 #ifdef CONFIG_NET_ALIAS
 727         if (net_alias_is(dev)) return;
 728 #endif
 729         head = dev->buffs;
 730         save_flags(flags);
 731         cli();
 732 
 733         /*
 734          *      Work the queues in priority order
 735          */      
 736         for(i = 0;i < DEV_NUMBUFFS; i++,head++)
 737         {
 738 
 739                 while (!skb_queue_empty(head)) {
 740                         struct sk_buff *skb;
 741 
 742                         skb = head->next;
 743                         __skb_unlink(skb, head);
 744                         /*
 745                          *      Stop anyone freeing the buffer while we retransmit it
 746                          */
 747                         skb_device_lock(skb);
 748                         restore_flags(flags);
 749                         /*
 750                          *      Feed them to the output stage and if it fails
 751                          *      indicate they re-queue at the front.
 752                          */
 753                         dev_queue_xmit(skb,dev,-i - 1);
 754                         /*
 755                          *      If we can take no more then stop here.
 756                          */
 757                         if (dev->tbusy)
 758                                 return;
 759                         cli();
 760                 }
 761         }
 762         restore_flags(flags);
 763 }
 764 
 765 
 766 /*
 767  *      Perform a SIOCGIFCONF call. This structure will change
 768  *      size shortly, and there is nothing I can do about it.
 769  *      Thus we will need a 'compatibility mode'.
 770  */
 771 
 772 static int dev_ifconf(char *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 773 {
 774         struct ifconf ifc;
 775         struct ifreq ifr;
 776         struct device *dev;
 777         char *pos;
 778         int len;
 779         int err;
 780 
 781         /*
 782          *      Fetch the caller's info block. 
 783          */
 784          
 785         err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifconf));
 786         if(err)
 787                 return err;
 788         memcpy_fromfs(&ifc, arg, sizeof(struct ifconf));
 789         len = ifc.ifc_len;
 790         pos = ifc.ifc_buf;
 791 
 792         /*
 793          *      We now walk the device list filling each active device
 794          *      into the array.
 795          */
 796          
 797         err=verify_area(VERIFY_WRITE,pos,len);
 798         if(err)
 799                 return err;
 800         
 801         /*
 802          *      Loop over the interfaces, and write an info block for each. 
 803          */
 804 
 805         for (dev = dev_base; dev != NULL; dev = dev->next) 
 806         {
 807                 if(!(dev->flags & IFF_UP))      /* Downed devices don't count */
 808                         continue;
 809                 /*
 810                  *      Have we run out of space here ?
 811                  */
 812         
 813                 if (len < sizeof(struct ifreq)) 
 814                         break;
 815 
 816                 memset(&ifr, 0, sizeof(struct ifreq));
 817                 strcpy(ifr.ifr_name, dev->name);
 818                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_family = dev->family;
 819                 (*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
 820 
 821 
 822                 /*
 823                  *      Write this block to the caller's space. 
 824                  */
 825                  
 826                 memcpy_tofs(pos, &ifr, sizeof(struct ifreq));
 827                 pos += sizeof(struct ifreq);
 828                 len -= sizeof(struct ifreq);            
 829         }
 830 
 831         /*
 832          *      All done.  Write the updated control block back to the caller. 
 833          */
 834          
 835         ifc.ifc_len = (pos - ifc.ifc_buf);
 836         ifc.ifc_req = (struct ifreq *) ifc.ifc_buf;
 837         memcpy_tofs(arg, &ifc, sizeof(struct ifconf));
 838         
 839         /*
 840          *      Report how much was filled in
 841          */
 842          
 843         return(pos - arg);
 844 }
 845 
 846 
 847 /*
 848  *      This is invoked by the /proc filesystem handler to display a device
 849  *      in detail.
 850  */
 851 
 852 #ifdef CONFIG_PROC_FS
 853 static int sprintf_stats(char *buffer, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 854 {
 855         struct enet_statistics *stats = (dev->get_stats ? dev->get_stats(dev): NULL);
 856         int size;
 857         
 858         if (stats)
 859                 size = sprintf(buffer, "%6s:%7d %4d %4d %4d %4d %8d %4d %4d %4d %5d %4d\n",
 860                    dev->name,
 861                    stats->rx_packets, stats->rx_errors,
 862                    stats->rx_dropped + stats->rx_missed_errors,
 863                    stats->rx_fifo_errors,
 864                    stats->rx_length_errors + stats->rx_over_errors
 865                    + stats->rx_crc_errors + stats->rx_frame_errors,
 866                    stats->tx_packets, stats->tx_errors, stats->tx_dropped,
 867                    stats->tx_fifo_errors, stats->collisions,
 868                    stats->tx_carrier_errors + stats->tx_aborted_errors
 869                    + stats->tx_window_errors + stats->tx_heartbeat_errors);
 870         else
 871                 size = sprintf(buffer, "%6s: No statistics available.\n", dev->name);
 872 
 873         return size;
 874 }
 875 
 876 /*
 877  *      Called from the PROCfs module. This now uses the new arbitrary sized /proc/net interface
 878  *      to create /proc/net/dev
 879  */
 880  
 881 int dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
 882 {
 883         int len=0;
 884         off_t begin=0;
 885         off_t pos=0;
 886         int size;
 887         
 888         struct device *dev;
 889 
 890 
 891         size = sprintf(buffer, "Inter-|   Receive                  |  Transmit\n"
 892                             " face |packets errs drop fifo frame|packets errs drop fifo colls carrier\n");
 893         
 894         pos+=size;
 895         len+=size;
 896         
 897 
 898         for (dev = dev_base; dev != NULL; dev = dev->next) 
 899         {
 900                 size = sprintf_stats(buffer+len, dev);
 901                 len+=size;
 902                 pos=begin+len;
 903                                 
 904                 if(pos<offset)
 905                 {
 906                         len=0;
 907                         begin=pos;
 908                 }
 909                 if(pos>offset+length)
 910                         break;
 911         }
 912         
 913         *start=buffer+(offset-begin);   /* Start of wanted data */
 914         len-=(offset-begin);            /* Start slop */
 915         if(len>length)
 916                 len=length;             /* Ending slop */
 917         return len;
 918 }
 919 #endif  /* CONFIG_PROC_FS */
 920 
 921 
 922 /*
 923  *      This checks bitmasks for the ioctl calls for devices.
 924  */
 925  
 926 static inline int bad_mask(unsigned long mask, unsigned long addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 927 {
 928         if (addr & (mask = ~mask))
 929                 return 1;
 930         mask = ntohl(mask);
 931         if (mask & (mask+1))
 932                 return 1;
 933         return 0;
 934 }
 935 
 936 /*
 937  *      Perform the SIOCxIFxxx calls. 
 938  *
 939  *      The socket layer has seen an ioctl the address family thinks is
 940  *      for the device. At this point we get invoked to make a decision
 941  */
 942  
 943 static int dev_ifsioc(void *arg, unsigned int getset)
     /* [previous][next][first][last][top][bottom][index][help] */
 944 {
 945         struct ifreq ifr;
 946         struct device *dev;
 947         int ret;
 948 
 949         /*
 950          *      Fetch the caller's info block into kernel space
 951          */
 952 
 953         int err=verify_area(VERIFY_WRITE, arg, sizeof(struct ifreq));
 954         if(err)
 955                 return err;
 956         
 957         memcpy_fromfs(&ifr, arg, sizeof(struct ifreq));
 958 
 959         /*
 960          *      See which interface the caller is talking about. 
 961          */
 962          
 963         /*
 964          *
 965          *      net_alias_dev_get(): dev_get() with added alias naming magic.
 966          *      only allow alias creation/deletion if (getset==SIOCSIFADDR)
 967          *
 968          */
 969          
 970 #ifdef CONFIG_KERNELD
 971         dev_load(ifr.ifr_name);
 972 #endif  
 973 
 974 #ifdef CONFIG_NET_ALIAS
 975         if ((dev = net_alias_dev_get(ifr.ifr_name, getset == SIOCSIFADDR, &err, NULL, NULL)) == NULL)
 976                 return(err);
 977 #else
 978         if ((dev = dev_get(ifr.ifr_name)) == NULL)      
 979                 return(-ENODEV);
 980 #endif
 981         switch(getset) 
 982         {
 983                 case SIOCGIFFLAGS:      /* Get interface flags */
 984                         ifr.ifr_flags = dev->flags;
 985                         goto rarok;
 986 
 987                 case SIOCSIFFLAGS:      /* Set interface flags */
 988                         {
 989                                 int old_flags = dev->flags;
 990                                 
 991                                 /*
 992                                  *      We are not allowed to potentially close/unload
 993                                  *      a device until we get this lock.
 994                                  */
 995                                 
 996                                 dev_lock_wait();
 997                                 
 998                                 /*
 999                                  *      Set the flags on our device.
1000                                  */
1001                                  
1002                                 dev->flags = (ifr.ifr_flags & (
1003                                         IFF_BROADCAST | IFF_DEBUG | IFF_LOOPBACK |
1004                                         IFF_POINTOPOINT | IFF_NOTRAILERS | IFF_RUNNING |
1005                                         IFF_NOARP | IFF_PROMISC | IFF_ALLMULTI | IFF_SLAVE | IFF_MASTER
1006                                         | IFF_MULTICAST)) | (dev->flags & IFF_UP);
1007                                 /*
1008                                  *      Load in the correct multicast list now the flags have changed.
1009                                  */                             
1010 
1011                                 dev_mc_upload(dev);
1012 
1013                                 /*
1014                                  *      Have we downed the interface. We handle IFF_UP ourselves
1015                                  *      according to user attempts to set it, rather than blindly
1016                                  *      setting it.
1017                                  */
1018                                  
1019                                 if ((old_flags^ifr.ifr_flags)&IFF_UP)   /* Bit is different  ? */
1020                                 {
1021                                         if(old_flags&IFF_UP)            /* Gone down */
1022                                                 ret=dev_close(dev);             
1023                                         else                            /* Come up */
1024                                         {
1025                                                 ret=dev_open(dev);
1026                                                 if(ret<0)
1027                                                         dev->flags&=~IFF_UP;    /* Open failed */
1028                                         }       
1029                                 }
1030                                 else
1031                                         ret=0;
1032                                 /*
1033                                  *      Load in the correct multicast list now the flags have changed.
1034                                  */                             
1035 
1036                                 dev_mc_upload(dev);
1037                         }
1038                         break;
1039                 
1040                 case SIOCGIFADDR:       /* Get interface address (and family) */
1041                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1042                         {
1043                                 memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1044                                 ifr.ifr_hwaddr.sa_family=dev->type;                     
1045                                 goto rarok;
1046                         }
1047                         else
1048                         {
1049                                 (*(struct sockaddr_in *)
1050                                           &ifr.ifr_addr).sin_addr.s_addr = dev->pa_addr;
1051                                 (*(struct sockaddr_in *)
1052                                           &ifr.ifr_addr).sin_family = dev->family;
1053                                 (*(struct sockaddr_in *)
1054                                           &ifr.ifr_addr).sin_port = 0;
1055                         }
1056                         goto rarok;
1057         
1058                 case SIOCSIFADDR:       /* Set interface address (and family) */
1059                 
1060                         /*
1061                          *      BSDism. SIOCSIFADDR family=AF_UNSPEC sets the
1062                          *      physical address. We can cope with this now.
1063                          */
1064                         
1065                         if(ifr.ifr_addr.sa_family==AF_UNSPEC)
1066                         {
1067                                 if(dev->set_mac_address==NULL)
1068                                         return -EOPNOTSUPP;
1069                                 ret=dev->set_mac_address(dev,&ifr.ifr_addr);
1070                         }
1071                         else
1072                         {
1073 
1074                                 /*
1075                                  *      if dev is an alias, must rehash to update
1076                                  *      address change
1077                                  */
1078 
1079 #ifdef CONFIG_NET_ALIAS
1080                                 if (net_alias_is(dev))
1081                                 net_alias_dev_rehash(dev ,&ifr.ifr_addr);
1082 #endif
1083                                 dev->pa_addr = (*(struct sockaddr_in *)
1084                                          &ifr.ifr_addr).sin_addr.s_addr;
1085                                 dev->family = ifr.ifr_addr.sa_family;
1086                         
1087 #ifdef CONFIG_INET      
1088                                 /* This is naughty. When net-032e comes out It wants moving into the net032
1089                                    code not the kernel. Till then it can sit here (SIGH) */             
1090                                 dev->pa_mask = ip_get_mask(dev->pa_addr);
1091 #endif                  
1092                                 dev->pa_brdaddr = dev->pa_addr | ~dev->pa_mask;
1093                                 ret = 0;
1094                         }
1095                         break;
1096                         
1097                 case SIOCGIFBRDADDR:    /* Get the broadcast address */
1098                         (*(struct sockaddr_in *)
1099                                 &ifr.ifr_broadaddr).sin_addr.s_addr = dev->pa_brdaddr;
1100                         (*(struct sockaddr_in *)
1101                                 &ifr.ifr_broadaddr).sin_family = dev->family;
1102                         (*(struct sockaddr_in *)
1103                                 &ifr.ifr_broadaddr).sin_port = 0;
1104                         goto rarok;
1105 
1106                 case SIOCSIFBRDADDR:    /* Set the broadcast address */
1107                         dev->pa_brdaddr = (*(struct sockaddr_in *)
1108                                 &ifr.ifr_broadaddr).sin_addr.s_addr;
1109                         ret = 0;
1110                         break;
1111                         
1112                 case SIOCGIFDSTADDR:    /* Get the destination address (for point-to-point links) */
1113                         (*(struct sockaddr_in *)
1114                                 &ifr.ifr_dstaddr).sin_addr.s_addr = dev->pa_dstaddr;
1115                         (*(struct sockaddr_in *)
1116                                 &ifr.ifr_dstaddr).sin_family = dev->family;
1117                         (*(struct sockaddr_in *)
1118                                 &ifr.ifr_dstaddr).sin_port = 0;
1119                         goto rarok;
1120         
1121                 case SIOCSIFDSTADDR:    /* Set the destination address (for point-to-point links) */
1122                         dev->pa_dstaddr = (*(struct sockaddr_in *)
1123                                 &ifr.ifr_dstaddr).sin_addr.s_addr;
1124                         ret = 0;
1125                         break;
1126                         
1127                 case SIOCGIFNETMASK:    /* Get the netmask for the interface */
1128                         (*(struct sockaddr_in *)
1129                                 &ifr.ifr_netmask).sin_addr.s_addr = dev->pa_mask;
1130                         (*(struct sockaddr_in *)
1131                                 &ifr.ifr_netmask).sin_family = dev->family;
1132                         (*(struct sockaddr_in *)
1133                                 &ifr.ifr_netmask).sin_port = 0;
1134                         goto rarok;
1135 
1136                 case SIOCSIFNETMASK:    /* Set the netmask for the interface */
1137                         {
1138                                 unsigned long mask = (*(struct sockaddr_in *)
1139                                         &ifr.ifr_netmask).sin_addr.s_addr;
1140                                 ret = -EINVAL;
1141                                 /*
1142                                  *      The mask we set must be legal.
1143                                  */
1144                                 if (bad_mask(mask,0))
1145                                         break;
1146                                 dev->pa_mask = mask;
1147                                 ret = 0;
1148                         }
1149                         break;
1150                         
1151                 case SIOCGIFMETRIC:     /* Get the metric on the interface (currently unused) */
1152                         
1153                         ifr.ifr_metric = dev->metric;
1154                         goto  rarok;
1155                         
1156                 case SIOCSIFMETRIC:     /* Set the metric on the interface (currently unused) */
1157                         dev->metric = ifr.ifr_metric;
1158                         ret=0;
1159                         break;
1160         
1161                 case SIOCGIFMTU:        /* Get the MTU of a device */
1162                         ifr.ifr_mtu = dev->mtu;
1163                         goto rarok;
1164         
1165                 case SIOCSIFMTU:        /* Set the MTU of a device */
1166                 
1167                         /*
1168                          *      MTU must be positive.
1169                          */
1170                          
1171                         if(ifr.ifr_mtu<68)
1172                                 return -EINVAL;
1173 
1174                         if (dev->change_mtu)
1175                                 ret = (*dev->change_mtu)(dev, ifr.ifr_mtu);
1176                         else
1177                         {
1178                                 dev->mtu = ifr.ifr_mtu;
1179                                 ret = 0;
1180                         }
1181                         break;
1182         
1183                 case SIOCGIFMEM:        /* Get the per device memory space. We can add this but currently
1184                                            do not support it */
1185                         ret = -EINVAL;
1186                         break;
1187                 
1188                 case SIOCSIFMEM:        /* Set the per device memory buffer space. Not applicable in our case */
1189                         ret = -EINVAL;
1190                         break;
1191 
1192                 case SIOCGIFHWADDR:
1193                         memcpy(ifr.ifr_hwaddr.sa_data,dev->dev_addr, MAX_ADDR_LEN);
1194                         ifr.ifr_hwaddr.sa_family=dev->type;                     
1195                         goto rarok;
1196                                 
1197                 case SIOCSIFHWADDR:
1198                         if(dev->set_mac_address==NULL)
1199                                 return -EOPNOTSUPP;
1200                         if(ifr.ifr_hwaddr.sa_family!=dev->type)
1201                                 return -EINVAL;
1202                         ret=dev->set_mac_address(dev,&ifr.ifr_hwaddr);
1203                         break;
1204                         
1205                 case SIOCGIFMAP:
1206                         ifr.ifr_map.mem_start=dev->mem_start;
1207                         ifr.ifr_map.mem_end=dev->mem_end;
1208                         ifr.ifr_map.base_addr=dev->base_addr;
1209                         ifr.ifr_map.irq=dev->irq;
1210                         ifr.ifr_map.dma=dev->dma;
1211                         ifr.ifr_map.port=dev->if_port;
1212                         goto rarok;
1213                         
1214                 case SIOCSIFMAP:
1215                         if(dev->set_config==NULL)
1216                                 return -EOPNOTSUPP;
1217                         return dev->set_config(dev,&ifr.ifr_map);
1218                         
1219                 case SIOCADDMULTI:
1220                         if(dev->set_multicast_list==NULL)
1221                                 return -EINVAL;
1222                         if(ifr.ifr_hwaddr.sa_family!=AF_UNSPEC)
1223                                 return -EINVAL;
1224                         dev_mc_add(dev,ifr.ifr_hwaddr.sa_data, dev->addr_len, 1);
1225                         return 0;
1226 
1227                 case SIOCDELMULTI:
1228                         if(dev->set_multicast_list==NULL)
1229                                 return -EINVAL;
1230                         if(ifr.ifr_hwaddr.sa_family!=AF_UNSPEC)
1231                                 return -EINVAL;
1232                         dev_mc_delete(dev,ifr.ifr_hwaddr.sa_data,dev->addr_len, 1);
1233                         return 0;
1234                 /*
1235                  *      Unknown or private ioctl
1236                  */
1237 
1238                 default:
1239                         if((getset >= SIOCDEVPRIVATE) &&
1240                            (getset <= (SIOCDEVPRIVATE + 15))) {
1241                                 if(dev->do_ioctl==NULL)
1242                                         return -EOPNOTSUPP;
1243                                 ret=dev->do_ioctl(dev, &ifr, getset);
1244                                 memcpy_tofs(arg,&ifr,sizeof(struct ifreq));
1245                                 break;
1246                         }
1247                         
1248                         ret = -EINVAL;
1249         }
1250         return(ret);
1251 /*
1252  *      The load of calls that return an ifreq and ok (saves memory).
1253  */
1254 rarok:
1255         memcpy_tofs(arg, &ifr, sizeof(struct ifreq));
1256         return 0;
1257 }
1258 
1259 
1260 /*
1261  *      This function handles all "interface"-type I/O control requests. The actual
1262  *      'doing' part of this is dev_ifsioc above.
1263  */
1264 
1265 int dev_ioctl(unsigned int cmd, void *arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1266 {
1267         switch(cmd) 
1268         {
1269                 case SIOCGIFCONF:
1270                         (void) dev_ifconf((char *) arg);
1271                         return 0;
1272 
1273                 /*
1274                  *      Ioctl calls that can be done by all.
1275                  */
1276                  
1277                 case SIOCGIFFLAGS:
1278                 case SIOCGIFADDR:
1279                 case SIOCGIFDSTADDR:
1280                 case SIOCGIFBRDADDR:
1281                 case SIOCGIFNETMASK:
1282                 case SIOCGIFMETRIC:
1283                 case SIOCGIFMTU:
1284                 case SIOCGIFMEM:
1285                 case SIOCGIFHWADDR:
1286                 case SIOCSIFHWADDR:
1287                 case SIOCGIFSLAVE:
1288                 case SIOCGIFMAP:
1289                         return dev_ifsioc(arg, cmd);
1290 
1291                 /*
1292                  *      Ioctl calls requiring the power of a superuser
1293                  */
1294                  
1295                 case SIOCSIFFLAGS:
1296                 case SIOCSIFADDR:
1297                 case SIOCSIFDSTADDR:
1298                 case SIOCSIFBRDADDR:
1299                 case SIOCSIFNETMASK:
1300                 case SIOCSIFMETRIC:
1301                 case SIOCSIFMTU:
1302                 case SIOCSIFMEM:
1303                 case SIOCSIFMAP:
1304                 case SIOCSIFSLAVE:
1305                 case SIOCADDMULTI:
1306                 case SIOCDELMULTI:
1307                         if (!suser())
1308                                 return -EPERM;
1309                         return dev_ifsioc(arg, cmd);
1310         
1311                 case SIOCSIFLINK:
1312                         return -EINVAL;
1313 
1314                 /*
1315                  *      Unknown or private ioctl.
1316                  */     
1317                  
1318                 default:
1319                         if((cmd >= SIOCDEVPRIVATE) &&
1320                            (cmd <= (SIOCDEVPRIVATE + 15))) {
1321                                 return dev_ifsioc(arg, cmd);
1322                         }
1323                         return -EINVAL;
1324         }
1325 }
1326 
1327 
1328 /*
1329  *      Initialize the DEV module. At boot time this walks the device list and
1330  *      unhooks any devices that fail to initialise (normally hardware not 
1331  *      present) and leaves us with a valid list of present and active devices.
1332  *
1333  */
1334 extern int lance_init(void);
1335 extern int ni65_init(void);
1336 extern int pi_init(void);
1337 extern void sdla_setup(void);
1338 extern void dlci_setup(void);
1339 
1340 int net_dev_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
1341 {
1342         struct device *dev, **dp;
1343 
1344         /*
1345          *      Initialise the packet receive queue.
1346          */
1347          
1348         skb_queue_head_init(&backlog);
1349         
1350         /*
1351          *      The bridge has to be up before the devices
1352          */
1353 
1354 #ifdef CONFIG_BRIDGE     
1355         br_init();
1356 #endif  
1357         
1358         /*
1359          * This is Very Ugly(tm).
1360          *
1361          * Some devices want to be initialized early..
1362          */
1363 #if defined(CONFIG_LANCE)
1364         lance_init();
1365 #endif
1366 #if defined(CONFIG_NI65)
1367         ni65_init();
1368 #endif
1369 #if defined(CONFIG_PI)
1370         pi_init();
1371 #endif  
1372 #if defined(CONFIG_PT)
1373         pt_init();
1374 #endif
1375 #if defined(CONFIG_DLCI)
1376         dlci_setup();
1377 #endif
1378 #if defined(CONFIG_SDLA)
1379         sdla_setup();
1380 #endif
1381         /*
1382          *      SLHC if present needs attaching so other people see it
1383          *      even if not opened.
1384          */
1385 #if (defined(CONFIG_SLIP) && defined(CONFIG_SLIP_COMPRESSED)) \
1386          || defined(CONFIG_PPP) \
1387     || (defined(CONFIG_ISDN) && defined(CONFIG_ISDN_PPP))
1388         slhc_install();
1389 #endif  
1390 
1391         /*
1392          *      Add the devices.
1393          *      If the call to dev->init fails, the dev is removed
1394          *      from the chain disconnecting the device until the
1395          *      next reboot.
1396          */
1397 
1398         dp = &dev_base;
1399         while ((dev = *dp) != NULL)
1400         {
1401                 int i;
1402                 for (i = 0; i < DEV_NUMBUFFS; i++)  {
1403                         skb_queue_head_init(dev->buffs + i);
1404                 }
1405 
1406                 if (dev->init && dev->init(dev)) 
1407                 {
1408                         /*
1409                          *      It failed to come up. Unhook it.
1410                          */
1411                         *dp = dev->next;
1412                 } 
1413                 else
1414                 {
1415                         dp = &dev->next;
1416                 }
1417         }
1418 
1419 #ifdef CONFIG_PROC_FS
1420         proc_net_register(&(struct proc_dir_entry) {
1421                 PROC_NET_DEV, 3, "dev",
1422                 S_IFREG | S_IRUGO, 1, 0, 0,
1423                 0, &proc_net_inode_operations,
1424                 dev_get_info
1425         });
1426 #endif
1427 
1428         /*      
1429          *      Initialise net_alias engine 
1430          *
1431          *              - register net_alias device notifier
1432          *              - register proc entries:        /proc/net/alias_types
1433          *                                                                      /proc/net/aliases
1434          */
1435 
1436 #ifdef CONFIG_NET_ALIAS
1437         net_alias_init();
1438 #endif
1439 
1440         init_bh(NET_BH, net_bh);
1441         return 0;
1442 }

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