1. 11 10月, 2007 16 次提交
    • J
      [NET]: split dev_ifsioc() according to locking · 14e3e079
      Jeff Garzik 提交于
      This always bugged me: dev_ioctl() called dev_ifsioc() either inside
      read_lock(dev_base_lock) or rtnl_lock(), depending on the ioctl being
      executed.
      
      This change moves the ioctls executed inside dev_base_lock to a new
      function, dev_ifsioc_locked().  Now the locking context is completely
      clear to the reader.
      Signed-off-by: NJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      14e3e079
    • S
      [NET]: sparse warning fixes · cfcabdcc
      Stephen Hemminger 提交于
      Fix a bunch of sparse warnings. Mostly about 0 used as
      NULL pointer, and shadowed variable declarations.
      One notable case was that hash size should have been unsigned.
      Signed-off-by: NStephen Hemminger <shemminger@linux-foundation.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cfcabdcc
    • S
      [NET]: Move hardware header operations out of netdevice. · 3b04ddde
      Stephen Hemminger 提交于
      Since hardware header operations are part of the protocol class
      not the device instance, make them into a separate object and
      save memory.
      Signed-off-by: NStephen Hemminger <shemminger@linux-foundation.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3b04ddde
    • E
      [NET]: Fix running without sysfs · 8b41d188
      Eric W. Biederman 提交于
      When sysfs support is compiled out the kernel still keeps and maintains
      the kobject tree.  So it is not safe to skip our kobject reference counting or
      to avoid becoming members of the kobject tree.  It is safe to not add
      the networking specific sysfs attributes.
      
      This patch removes the sysfs special cases from net/core/dev.c
      renames functions from netdev_sysfs_xxxx to netdev_kobject_xxxx
      and always compiles in net-sysfs.c
      
      net-sysfs.c is modified with a CONFIG_SYSFS guard around the parts
      that are actually sysfs specific.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8b41d188
    • P
      [NET]: Cleanup calling netdev notifiers. · 056925ab
      Pavel Emelyanov 提交于
      The call_netdev_notifiers routine can successfully be used in
      the net/core_dev.c itself.
      
      This will save 6 lines of code and 62 ;) bytes of .text section.
      
      62 is rather small, but I have one more patch saving ~30 bytes
      from netns code (sent to Eric), so altogether they can save
      some more noticeable amount.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      056925ab
    • P
      [NETNS]: Consolidate hashes creation in netdev_init() · 30d97d35
      Pavel Emelyanov 提交于
      The dev_name_hash and the dev_index_hash are now booth kmalloc-ed
      (and each element is properly initialized as usually) so I think
      it's worth consolidating this code making it look nicer (and
      saving 28 bytes of .text section ;) )
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      30d97d35
    • E
      [NET]: Fix the prototype of call_netdevice_notifiers. · ad7379d4
      Eric W. Biederman 提交于
      This replaces the void * parameter with a struct net_device * which
      is what is actually required.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ad7379d4
    • J
      [NET]: migrate HARD_TX_LOCK to header file · 22dd7495
      Jamal Hadi Salim 提交于
      HARD_TX_LOCK micro is a nice aggregation that could be used
      in other spots. move it to netdevice.h
      Also makes sure the previously superflous cpu arguement is used.
      Thanks to DaveM for the suggestions.
      Signed-off-by: NJamal Hadi Salim <hadi@cyberus.ca>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      22dd7495
    • E
      [NET]: Fix race when opening a proc file while a network namespace is exiting. · 077130c0
      Eric W. Biederman 提交于
      The problem:  proc_net files remember which network namespace the are
      against but do not remember hold a reference count (as that would pin
      the network namespace).   So we currently have a small window where
      the reference count on a network namespace may be incremented when opening
      a /proc file when it has already gone to zero.
      
      To fix this introduce maybe_get_net and get_proc_net.
      
      maybe_get_net increments the network namespace reference count only if it is
      greater then zero, ensuring we don't increment a reference count after it
      has gone to zero.
      
      get_proc_net handles all of the magic to go from a proc inode to the network
      namespace instance and call maybe_get_net on it.
      
      PROC_NET the old accessor is removed so that we don't get confused and use
      the wrong helper function.
      
      Then I fix up the callers to use get_proc_net and handle the case case
      where get_proc_net returns NULL.  In that case I return -ENXIO because
      effectively the network namespace has already gone away so the files
      we are trying to access don't exist anymore.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NPaul E. McKenney <paulmck@us.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      077130c0
    • D
      [NET]: Add a might_sleep() to dev_close(). · 9d5010db
      David S. Miller 提交于
      Requested by Johannes Berg.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9d5010db
    • E
      [NET]: Implement network device movement between namespaces · ce286d32
      Eric W. Biederman 提交于
      This patch introduces NETIF_F_NETNS_LOCAL a flag to indicate
      a network device is local to a single network namespace and
      should never be moved.  Useful for pseudo devices that we
      need an instance in each network namespace (like the loopback
      device) and for any device we find that cannot handle multiple
      network namespaces so we may trap them in the initial network
      namespace.
      
      This patch introduces the function dev_change_net_namespace
      a function used to move a network device from one network
      namespace to another.  To the network device nothing
      special appears to happen, to the components of the network
      stack it appears as if the network device was unregistered
      in the network namespace it is in, and a new device
      was registered in the network namespace the device
      was moved to.
      
      This patch sets up a namespace device destructor that
      upon the exit of a network namespace moves all of the
      movable network devices  to the initial network namespace
      so they are not lost.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ce286d32
    • E
      [NET]: Factor out __dev_alloc_name from dev_alloc_name · b267b179
      Eric W. Biederman 提交于
      When forcibly changing the network namespace of a device
      I need something that can generate a name for the device
      in the new namespace without overwriting the old name.
      
      __dev_alloc_name provides me that functionality.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b267b179
    • E
      [NET]: Make the device list and device lookups per namespace. · 881d966b
      Eric W. Biederman 提交于
      This patch makes most of the generic device layer network
      namespace safe.  This patch makes dev_base_head a
      network namespace variable, and then it picks up
      a few associated variables.  The functions:
      dev_getbyhwaddr
      dev_getfirsthwbytype
      dev_get_by_flags
      dev_get_by_name
      __dev_get_by_name
      dev_get_by_index
      __dev_get_by_index
      dev_ioctl
      dev_ethtool
      dev_load
      wireless_process_ioctl
      
      were modified to take a network namespace argument, and
      deal with it.
      
      vlan_ioctl_set and brioctl_set were modified so their
      hooks will receive a network namespace argument.
      
      So basically anthing in the core of the network stack that was
      affected to by the change of dev_base was modified to handle
      multiple network namespaces.  The rest of the network stack was
      simply modified to explicitly use &init_net the initial network
      namespace.  This can be fixed when those components of the network
      stack are modified to handle multiple network namespaces.
      
      For now the ifindex generator is left global.
      
      Fundametally ifindex numbers are per namespace, or else
      we will have corner case problems with migration when
      we get that far.
      
      At the same time there are assumptions in the network stack
      that the ifindex of a network device won't change.  Making
      the ifindex number global seems a good compromise until
      the network stack can cope with ifindex changes when
      you change namespaces, and the like.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      881d966b
    • E
      [NET]: Initialize the network namespace of network devices. · 6d34b1c2
      Eric W. Biederman 提交于
      Except for carefully selected pseudo devices all network
      interfaces should start out in the initial network namespace.
      Ultimately it will be register_netdev that examines what
      dev->nd_net is set to and places a device in a network namespace.
      
      This patch modifies alloc_netdev to initialize the network
      namespace a device is in with the initial network namespace.
      This gets it right for the vast majority of devices so their
      drivers need not be modified and for those few pseudo devices
      that need something different they can change this parameter
      before calling register_netdevice.
      
      The network namespace parameter on a network device is not
      reference counted as the devices are inside of a network namespace
      and cannot remain in that namespace past the lifetime of the
      network namespace.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6d34b1c2
    • E
      [NET]: Make /proc/net per network namespace · 457c4cbc
      Eric W. Biederman 提交于
      This patch makes /proc/net per network namespace.  It modifies the global
      variables proc_net and proc_net_stat to be per network namespace.
      The proc_net file helpers are modified to take a network namespace argument,
      and all of their callers are fixed to pass &init_net for that argument.
      This ensures that all of the /proc/net files are only visible and
      usable in the initial network namespace until the code behind them
      has been updated to be handle multiple network namespaces.
      
      Making /proc/net per namespace is necessary as at least some files
      in /proc/net depend upon the set of network devices which is per
      network namespace, and even more files in /proc/net have contents
      that are relevant to a single network namespace.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      457c4cbc
    • S
      [NET]: Make NAPI polling independent of struct net_device objects. · bea3348e
      Stephen Hemminger 提交于
      Several devices have multiple independant RX queues per net
      device, and some have a single interrupt doorbell for several
      queues.
      
      In either case, it's easier to support layouts like that if the
      structure representing the poll is independant from the net
      device itself.
      
      The signature of the ->poll() call back goes from:
      
      	int foo_poll(struct net_device *dev, int *budget)
      
      to
      
      	int foo_poll(struct napi_struct *napi, int budget)
      
      The caller is returned the number of RX packets processed (or
      the number of "NAPI credits" consumed if you want to get
      abstract).  The callee no longer messes around bumping
      dev->quota, *budget, etc. because that is all handled in the
      caller upon return.
      
      The napi_struct is to be embedded in the device driver private data
      structures.
      
      Furthermore, it is the driver's responsibility to disable all NAPI
      instances in it's ->stop() device close handler.  Since the
      napi_struct is privatized into the driver's private data structures,
      only the driver knows how to get at all of the napi_struct instances
      it may have per-device.
      
      With lots of help and suggestions from Rusty Russell, Roland Dreier,
      Michael Chan, Jeff Garzik, and Jamal Hadi Salim.
      
      Bug fixes from Thomas Graf, Roland Dreier, Peter Zijlstra,
      Joseph Fannin, Scott Wood, Hans J. Koch, and Michael Chan.
      
      [ Ported to current tree and all drivers converted.  Integrated
        Stephen's follow-on kerneldoc additions, and restored poll_list
        handling to the old style to fix mutual exclusion issues.  -DaveM ]
      Signed-off-by: NStephen Hemminger <shemminger@linux-foundation.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bea3348e
  2. 14 8月, 2007 1 次提交
  3. 31 7月, 2007 4 次提交
    • H
      [NET]: Allow netdev REGISTER/CHANGENAME events to fail · fcc5a03a
      Herbert Xu 提交于
      This patch adds code to allow errors to be passed up from event
      handlers of NETDEV_REGISTER and NETDEV_CHANGENAME.  It also adds
      the notifier_from_errno/notifier_to_errnor helpers to pass the
      errno value up to the notifier caller.
      
      If an error is detected when a device is registered, it causes
      that operation to fail.  A NETDEV_UNREGISTER will be sent to
      all event handlers.
      
      Similarly if NETDEV_CHANGENAME fails the original name is restored
      and a new NETDEV_CHANGENAME event is sent.
      
      As such all event handlers must be idempotent with respect to
      these events.
      
      When an event handler is registered NETDEV_REGISTER events are
      sent for all devices currently registered.  Should any of them
      fail, we will send NETDEV_GOING_DOWN/NETDEV_DOWN/NETDEV_UNREGISTER
      events to that handler for the devices which have already been
      registered with it.  The handler registration itself will fail.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fcc5a03a
    • H
      [NET]: Take dev_base_lock when moving device name hash list entry · 7f988eab
      Herbert Xu 提交于
      When we added name-based hashing the dev_base_lock was designated as the
      lock to take when changing the name hash list.  Unfortunately, because
      it was a preexisting lock that just happened to be taken in the right
      spots we neglected to take it in dev_change_name.
      
      The race can affect calles of __dev_get_by_name that do so without taking
      the RTNL.  They may end up walking down the wrong hash chain and end up
      missing the device that they're looking for.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7f988eab
    • H
      [NET]: Call uninit if necessary in register_netdevice · 7ce1b0ed
      Herbert Xu 提交于
      This patch makes register_netdevice call dev->uninit if the regsitration
      fails after dev->init has completed successfully.  Very few drivers use
      the init/uninit calls but at least one (drivers/net/wan/sealevel.c) may
      leak without this change.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7ce1b0ed
    • R
      [NET]: kernel-doc fixes · 0ed72ec4
      Randy Dunlap 提交于
      Fix kernel-doc omissions in net/:
      
      Warning(linux-2.6.23-rc1//net/core/dev.c:2728): No description found for parameter 'addr'
      Warning(linux-2.6.23-rc1//net/core/dev.c:2752): No description found for parameter 'addr'
      Warning(linux-2.6.23-rc1//net/core/dev.c:3839): No description found for parameter 'net_dma'
      Warning(linux-2.6.23-rc1//net/core/dev.c:3877): No description found for parameter 'state'
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0ed72ec4
  4. 21 7月, 2007 1 次提交
  5. 19 7月, 2007 1 次提交
  6. 18 7月, 2007 3 次提交
  7. 15 7月, 2007 2 次提交
    • P
      [NET]: Add macvlan driver · b863ceb7
      Patrick McHardy 提交于
      Add macvlan driver, which allows to create virtual ethernet devices
      based on MAC address.
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b863ceb7
    • P
      [NET]: Add net_device change_rx_mode callback · 24023451
      Patrick McHardy 提交于
      Currently the set_multicast_list (and set_rx_mode) callbacks are
      responsible for configuring the device according to the IFF_PROMISC,
      IFF_MULTICAST and IFF_ALLMULTI flags and the mc_list (and uc_list in
      case of set_rx_mode).
      
      These callbacks can be invoked from BH context without the rtnl_mutex
      by dev_mc_add/dev_mc_delete, which makes reading the device flags and
      promiscous/allmulti count racy. For real hardware drivers that just
      commit all changes to the hardware this is not a real problem since
      the stack guarantees to call them for every change, so at least the
      final call will not race and commit the correct configuration to the
      hardware.
      
      For software devices that want to synchronize promiscous and multicast
      state to an underlying device however this can cause corruption of the
      underlying device's flags or promisc/allmulti counts.
      
      When the software device is concurrently put in promiscous or allmulti
      mode while set_multicast_list is invoked from bottem half context, the
      device might synchronize the change to the underlying device without
      holding the rtnl_mutex, which races with concurrent changes to the
      underlying device.
      
      Add a dev->change_rx_flags hook that is invoked when any of the flags
      that affect rx filtering change (under the rtnl_mutex), which allows
      drivers to perform synchronization immediately and only synchronize
      the address lists in set_multicast_list/set_rx_mode.
      Signed-off-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      24023451
  8. 13 7月, 2007 1 次提交
    • D
      dmaengine: make clients responsible for managing channels · d379b01e
      Dan Williams 提交于
      The current implementation assumes that a channel will only be used by one
      client at a time.  In order to enable channel sharing the dmaengine core is
      changed to a model where clients subscribe to channel-available-events.
      Instead of tracking how many channels a client wants and how many it has
      received the core just broadcasts the available channels and lets the
      clients optionally take a reference.  The core learns about the clients'
      needs at dma_event_callback time.
      
      In support of multiple operation types, clients can specify a capability
      mask to only be notified of channels that satisfy a certain set of
      capabilities.
      
      Changelog:
      * removed DMA_TX_ARRAY_INIT, no longer needed
      * dma_client_chan_free -> dma_chan_release: switch to global reference
        counting only at device unregistration time, before it was also happening
        at client unregistration time
      * clients now return dma_state_client to dmaengine (ack, dup, nak)
      * checkpatch.pl fixes
      * fixup merge with git-ioat
      
      Cc: Chris Leech <christopher.leech@intel.com>
      Signed-off-by: NShannon Nelson <shannon.nelson@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      d379b01e
  9. 11 7月, 2007 6 次提交
  10. 24 6月, 2007 1 次提交
  11. 08 6月, 2007 1 次提交
  12. 20 5月, 2007 1 次提交
  13. 18 5月, 2007 1 次提交
  14. 10 5月, 2007 1 次提交
    • R
      Add suspend-related notifications for CPU hotplug · 8bb78442
      Rafael J. Wysocki 提交于
      Since nonboot CPUs are now disabled after tasks and devices have been
      frozen and the CPU hotplug infrastructure is used for this purpose, we need
      special CPU hotplug notifications that will help the CPU-hotplug-aware
      subsystems distinguish normal CPU hotplug events from CPU hotplug events
      related to a system-wide suspend or resume operation in progress.  This
      patch introduces such notifications and causes them to be used during
      suspend and resume transitions.  It also changes all of the
      CPU-hotplug-aware subsystems to take these notifications into consideration
      (for now they are handled in the same way as the corresponding "normal"
      ones).
      
      [oleg@tv-sign.ru: cleanups]
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bb78442