1. 04 Feb, 2011 2 commits
    • David S. Miller's avatar
      net: Fix bug in compat SIOCGETSGCNT handling. · 0033d5ad
      David S. Miller authored
      Commit 709b46e8 ("net: Add compat
      ioctl support for the ipv4 multicast ioctl SIOCGETSGCNT") added the
      correct plumbing to handle SIOCGETSGCNT properly.
      
      However, whilst definiting a proper "struct compat_sioc_sg_req" it
      isn't actually used in ipmr_compat_ioctl().
      
      Correct this oversight.
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0033d5ad
    • David S. Miller's avatar
      niu: Fix races between up/down and get_stats. · 9690c636
      David S. Miller authored
      As reported by Flavio Leitner, there is no synchronization to protect
      NIU's get_stats method from seeing a NULL pointer in either
      np->rx_rings or np->tx_rings.  In fact, as far as ->ndo_get_stats
      is concerned, these values are set completely asynchronously.
      
      Flavio attempted to fix this using a RW semaphore, which in fact
      works most of the time.  However, dev_get_stats() can be invoked
      from non-sleepable contexts in some cases, so this fix doesn't
      work in all cases.
      
      So instead, control the visibility of the np->{rx,tx}_ring pointers
      when the device is being brough up, and use properties of the device
      down sequence to our advantage.
      
      In niu_get_stats(), return immediately if netif_running() is false.
      The device shutdown sequence first marks the device as not running (by
      clearing the __LINK_STATE_START bit), then it performans a
      synchronize_rcu() (in dev_deactive_many()), and then finally it
      invokes the driver ->ndo_stop() method.
      
      This guarentees that all invocations of niu_get_stats() either see
      netif_running() as false, or they see the channel pointers before
      ->ndo_stop() clears them out.
      
      If netif_running() is true, protect against startup races by loading
      the np->{rx,tx}_rings pointer into a local variable, and punting if
      it is NULL.  Use ACCESS_ONCE to prevent the compiler from reloading
      the pointer on us.
      
      Also, during open, control the order in which the pointers and the
      ring counts become visible globally using SMP write memory barriers.
      We make sure the np->num_{rx,tx}_rings value is stable and visible
      before np->{rx,tx}_rings is.
      
      Such visibility control is not necessary on the niu_free_channels()
      side because of the RCU sequencing that happens during device down as
      described above.  We are always guarenteed that all niu_get_stats
      calls are finished, or will see netif_running() false, by the time
      ->ndo_stop is invoked.
      Reported-by: default avatarFlavio Leitner <fleitner@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9690c636
  2. 02 Feb, 2011 10 commits
  3. 01 Feb, 2011 16 commits
  4. 31 Jan, 2011 9 commits
  5. 30 Jan, 2011 3 commits
    • Sven Eckelmann's avatar
      batman-adv: Make vis info stack traversal threadsafe · 1181e1da
      Sven Eckelmann authored
      The batman-adv vis server has to a stack which stores all information
      about packets which should be send later. This stack is protected
      with a spinlock that is used to prevent concurrent write access to it.
      
      The send_vis_packets function has to take all elements from the stack
      and send them to other hosts over the primary interface. The send will
      be initiated without the lock which protects the stack.
      
      The implementation using list_for_each_entry_safe has the problem that
      it stores the next element as "safe ptr" to allow the deletion of the
      current element in the list. The list may be modified during the
      unlock/lock pair in the loop body which may make the safe pointer
      not pointing to correct next element.
      
      It is safer to remove and use the first element from the stack until no
      elements are available. This does not need reduntant information which
      would have to be validated each time the lock was removed.
      Reported-by: default avatarRussell Senior <russell@personaltelco.net>
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      1181e1da
    • Sven Eckelmann's avatar
      batman-adv: Remove vis info element in free_info · dda9fc6b
      Sven Eckelmann authored
      The free_info function will be called when no reference to the info
      object exists anymore. It must be ensured that the allocated memory
      gets freed and not only the elements which are managed by the info
      object.
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      dda9fc6b
    • Sven Eckelmann's avatar
      batman-adv: Remove vis info on hashing errors · 2674c158
      Sven Eckelmann authored
      A newly created vis info object must be removed when it couldn't be
      added to the hash. The old_info which has to be replaced was already
      removed and isn't related to the hash anymore.
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      2674c158