19 Apr, 2014

1 commit

  • When I open the LOCKDEP config and run these steps:

    modprobe 8021q
    vconfig add eth2 20
    vconfig add eth2.20 30
    ifconfig eth2 xx.xx.xx.xx

    then the Call Trace happened:

    [32524.386288] =============================================
    [32524.386293] [ INFO: possible recursive locking detected ]
    [32524.386298] 3.14.0-rc2-0.7-default+ #35 Tainted: G O
    [32524.386302] ---------------------------------------------
    [32524.386306] ifconfig/3103 is trying to acquire lock:
    [32524.386310] (&vlan_netdev_addr_lock_key/1){+.....}, at: [] dev_mc_sync+0x64/0xb0
    [32524.386326]
    [32524.386326] but task is already holding lock:
    [32524.386330] (&vlan_netdev_addr_lock_key/1){+.....}, at: [] dev_set_rx_mode+0x23/0x40
    [32524.386341]
    [32524.386341] other info that might help us debug this:
    [32524.386345] Possible unsafe locking scenario:
    [32524.386345]
    [32524.386350] CPU0
    [32524.386352] ----
    [32524.386354] lock(&vlan_netdev_addr_lock_key/1);
    [32524.386359] lock(&vlan_netdev_addr_lock_key/1);
    [32524.386364]
    [32524.386364] *** DEADLOCK ***
    [32524.386364]
    [32524.386368] May be due to missing lock nesting notation
    [32524.386368]
    [32524.386373] 2 locks held by ifconfig/3103:
    [32524.386376] #0: (rtnl_mutex){+.+.+.}, at: [] rtnl_lock+0x12/0x20
    [32524.386387] #1: (&vlan_netdev_addr_lock_key/1){+.....}, at: [] dev_set_rx_mode+0x23/0x40
    [32524.386398]
    [32524.386398] stack backtrace:
    [32524.386403] CPU: 1 PID: 3103 Comm: ifconfig Tainted: G O 3.14.0-rc2-0.7-default+ #35
    [32524.386409] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
    [32524.386414] ffffffff81ffae40 ffff8800d9625ae8 ffffffff814f68a2 ffff8800d9625bc8
    [32524.386421] ffffffff810a35fb ffff8800d8a8d9d0 00000000d9625b28 ffff8800d8a8e5d0
    [32524.386428] 000003cc00000000 0000000000000002 ffff8800d8a8e5f8 0000000000000000
    [32524.386435] Call Trace:
    [32524.386441] [] dump_stack+0x6a/0x78
    [32524.386448] [] __lock_acquire+0x7ab/0x1940
    [32524.386454] [] ? __lock_acquire+0x3ea/0x1940
    [32524.386459] [] lock_acquire+0xe4/0x110
    [32524.386464] [] ? dev_mc_sync+0x64/0xb0
    [32524.386471] [] _raw_spin_lock_nested+0x2a/0x40
    [32524.386476] [] ? dev_mc_sync+0x64/0xb0
    [32524.386481] [] dev_mc_sync+0x64/0xb0
    [32524.386489] [] vlan_dev_set_rx_mode+0x2b/0x50 [8021q]
    [32524.386495] [] __dev_set_rx_mode+0x5f/0xb0
    [32524.386500] [] dev_set_rx_mode+0x2b/0x40
    [32524.386506] [] __dev_open+0xef/0x150
    [32524.386511] [] __dev_change_flags+0xa7/0x190
    [32524.386516] [] dev_change_flags+0x32/0x80
    [32524.386524] [] devinet_ioctl+0x7d6/0x830
    [32524.386532] [] ? dev_ioctl+0x34b/0x660
    [32524.386540] [] inet_ioctl+0x80/0xa0
    [32524.386550] [] sock_do_ioctl+0x2d/0x60
    [32524.386558] [] sock_ioctl+0x82/0x2a0
    [32524.386568] [] do_vfs_ioctl+0x93/0x590
    [32524.386578] [] ? rcu_read_lock_held+0x45/0x50
    [32524.386586] [] ? __fget_light+0x105/0x110
    [32524.386594] [] SyS_ioctl+0x91/0xb0
    [32524.386604] [] system_call_fastpath+0x16/0x1b

    ========================================================================

    The reason is that all of the addr_lock_key for vlan dev have the same class,
    so if we change the status for vlan dev, the vlan dev and its real dev will
    hold the same class of addr_lock_key together, so the warning happened.

    we should distinguish the lock depth for vlan dev and its real dev.

    v1->v2: Convert the vlan_netdev_addr_lock_key to an array of eight elements, which
    could support to add 8 vlan id on a same vlan dev, I think it is enough for current
    scene, because a netdev's name is limited to IFNAMSIZ which could not hold 8 vlan id,
    and the vlan dev would not meet the same class key with its real dev.

    The new function vlan_dev_get_lockdep_subkey() will return the subkey and make the vlan
    dev could get a suitable class key.

    v2->v3: According David's suggestion, I use the subclass to distinguish the lock key for vlan dev
    and its real dev, but it make no sense, because the difference for subclass in the
    lock_class_key doesn't mean that the difference class for lock_key, so I use lock_depth
    to distinguish the different depth for every vlan dev, the same depth of the vlan dev
    could have the same lock_class_key, I import the MAX_LOCK_DEPTH from the include/linux/sched.h,
    I think it is enough here, the lockdep should never exceed that value.

    v3->v4: Add a huge array of locking keys will waste static kernel memory and is not a appropriate method,
    we could use _nested() variants to fix the problem, calculate the depth for every vlan dev,
    and use the depth as the subclass for addr_lock_key.

    Signed-off-by: Ding Tianhong
    Signed-off-by: David S. Miller

    dingtianhong
     

30 Mar, 2014

2 commits

  • Conflicts:
    drivers/net/ethernet/marvell/mvneta.c

    The mvneta.c conflict is a case of overlapping changes,
    a conversion to devm_ioremap_resource() vs. a conversion
    to netdev_alloc_pcpu_stats.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • The gfp parameter was added in:
    commit 47be03a28cc6c80e3aa2b3e8ed6d960ff0c5c0af
    Author: Amerigo Wang
    Date: Fri Aug 10 01:24:37 2012 +0000

    netpoll: use GFP_ATOMIC in slave_enable_netpoll() and __netpoll_setup()

    slave_enable_netpoll() and __netpoll_setup() may be called
    with read_lock() held, so should use GFP_ATOMIC to allocate
    memory. Eric suggested to pass gfp flags to __netpoll_setup().

    Cc: Eric Dumazet
    Cc: "David S. Miller"
    Reported-by: Dan Carpenter
    Signed-off-by: Eric Dumazet
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    The reason for the gfp parameter was removed in:
    commit c4cdef9b7183159c23c7302aaf270d64c549f557
    Author: dingtianhong
    Date: Tue Jul 23 15:25:27 2013 +0800

    bonding: don't call slave_xxx_netpoll under spinlocks

    The slave_xxx_netpoll will call synchronize_rcu_bh(),
    so the function may schedule and sleep, it should't be
    called under spinlocks.

    bond_netpoll_setup() and bond_netpoll_cleanup() are always
    protected by rtnl lock, it is no need to take the read lock,
    as the slave list couldn't be changed outside rtnl lock.

    Signed-off-by: Ding Tianhong
    Cc: Jay Vosburgh
    Cc: Andy Gospodarek
    Signed-off-by: David S. Miller

    Nothing else that calls __netpoll_setup or ndo_netpoll_setup
    requires a gfp paramter, so remove the gfp parameter from both
    of these functions making the code clearer.

    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

29 Mar, 2014

1 commit


28 Mar, 2014

1 commit

  • Currently, if the card supports CTAG acceleration we do not
    account for the vlan header even if we are configuring an
    8021AD vlan. This may not be best since we'll do software
    tagging for 8021AD which will cause data copy on skb head expansion
    Configure the length based on available hw offload capabilities and
    vlan protocol.

    CC: Patrick McHardy
    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

15 Mar, 2014

2 commits


11 Mar, 2014

1 commit

  • With TX VLAN offload enabled the source MAC address for frames sent using the
    VLAN interface is currently set to the address of the real interface. This is
    wrong since the VLAN interface may be configured with a different address.

    The bug was introduced in commit 2205369a314e12fcec4781cc73ac9c08fc2b47de
    ("vlan: Fix header ops passthru when doing TX VLAN offload.").

    This patch sets the source address before calling the create function of the
    real interface.

    Signed-off-by: Peter Boström
    Signed-off-by: David S. Miller

    Peter Boström
     

15 Feb, 2014

1 commit


22 Jan, 2014

1 commit


01 Jan, 2014

1 commit

  • When the vlan code detects that the real device can do TX VLAN offloads
    in hardware, it tries to arrange for the real device's header_ops to
    be invoked directly.

    But it does so illegally, by simply hooking the real device's
    header_ops up to the VLAN device.

    This doesn't work because we will end up invoking a set of header_ops
    routines which expect a device type which matches the real device, but
    will see a VLAN device instead.

    Fix this by providing a pass-thru set of header_ops which will arrange
    to pass the proper real device instead.

    To facilitate this add a dev_rebuild_header(). There are
    implementations which provide a ->cache and ->create but not a
    ->rebuild (f.e. PLIP). So we need a helper function just like
    dev_hard_header() to avoid crashes.

    Use this helper in the one existing place where the
    header_ops->rebuild was being invoked, the neighbour code.

    With lots of help from Florian Westphal.

    Signed-off-by: David S. Miller

    David S. Miller
     

14 Nov, 2013

1 commit

  • Pull core locking changes from Ingo Molnar:
    "The biggest changes:

    - add lockdep support for seqcount/seqlocks structures, this
    unearthed both bugs and required extra annotation.

    - move the various kernel locking primitives to the new
    kernel/locking/ directory"

    * 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (21 commits)
    block: Use u64_stats_init() to initialize seqcounts
    locking/lockdep: Mark __lockdep_count_forward_deps() as static
    lockdep/proc: Fix lock-time avg computation
    locking/doc: Update references to kernel/mutex.c
    ipv6: Fix possible ipv6 seqlock deadlock
    cpuset: Fix potential deadlock w/ set_mems_allowed
    seqcount: Add lockdep functionality to seqcount/seqlock structures
    net: Explicitly initialize u64_stats_sync structures for lockdep
    locking: Move the percpu-rwsem code to kernel/locking/
    locking: Move the lglocks code to kernel/locking/
    locking: Move the rwsem code to kernel/locking/
    locking: Move the rtmutex code to kernel/locking/
    locking: Move the semaphore core to kernel/locking/
    locking: Move the spinlock code to kernel/locking/
    locking: Move the lockdep code to kernel/locking/
    locking: Move the mutex code to kernel/locking/
    hung_task debugging: Add tracepoint to report the hang
    x86/locking/kconfig: Update paravirt spinlock Kconfig description
    lockstat: Report avg wait and hold times
    lockdep, x86/alternatives: Drop ancient lockdep fixup message
    ...

    Linus Torvalds
     

11 Nov, 2013

1 commit


08 Nov, 2013

1 commit

  • Provide a method for read-only access to the vlan device egress mapping.

    Do this by refactoring vlan_dev_get_egress_qos_mask() such that now it
    receives as an argument the skb priority instead of pointer to the skb.

    Such an access is needed for the IBoE stack where the control plane
    goes through the network stack. This is an add-on step on top of commit
    d4a968658c "net/route: export symbol ip_tos2prio" which allowed the RDMA-CM
    to use ip_tos2prio.

    Signed-off-by: Eyal Perry
    Signed-off-by: Hadar Hen Zion
    Signed-off-by: David S. Miller

    Eyal Perry
     

06 Nov, 2013

1 commit

  • In order to enable lockdep on seqcount/seqlock structures, we
    must explicitly initialize any locks.

    The u64_stats_sync structure, uses a seqcount, and thus we need
    to introduce a u64_stats_init() function and use it to initialize
    the structure.

    This unfortunately adds a lot of fairly trivial initialization code
    to a number of drivers. But the benefit of ensuring correctness makes
    this worth while.

    Because these changes are required for lockdep to be enabled, and the
    changes are quite trivial, I've not yet split this patch out into 30-some
    separate patches, as I figured it would be better to get the various
    maintainers thoughts on how to best merge this change along with
    the seqcount lockdep enablement.

    Feedback would be appreciated!

    Signed-off-by: John Stultz
    Acked-by: Julian Anastasov
    Signed-off-by: Peter Zijlstra
    Cc: Alexey Kuznetsov
    Cc: "David S. Miller"
    Cc: Eric Dumazet
    Cc: Hideaki YOSHIFUJI
    Cc: James Morris
    Cc: Jesse Gross
    Cc: Mathieu Desnoyers
    Cc: "Michael S. Tsirkin"
    Cc: Mirko Lindner
    Cc: Patrick McHardy
    Cc: Roger Luethi
    Cc: Rusty Russell
    Cc: Simon Horman
    Cc: Stephen Hemminger
    Cc: Steven Rostedt
    Cc: Thomas Petazzoni
    Cc: Wensong Zhang
    Cc: netdev@vger.kernel.org
    Link: http://lkml.kernel.org/r/1381186321-4906-2-git-send-email-john.stultz@linaro.org
    Signed-off-by: Ingo Molnar

    John Stultz
     

04 Sep, 2013

1 commit


04 Aug, 2013

1 commit

  • This patch cleanup 2 points for the usage of vlan_dev_priv(dev):
    * In vlan_dev.c/vlan_dev_hard_header, we should use the var *vlan directly
    after grabing the pointer at the beginning with
    *vlan = vlan_dev_priv(dev);
    when we need to access the fields of *vlan.
    * In vlan.c/register_vlan_device, add the var *vlan pointer
    struct vlan_dev_priv *vlan;
    to cleanup the code to access the fields of vlan_dev_priv(new_dev).

    Signed-off-by: Wang Sheng-Hui
    Signed-off-by: David S. Miller

    Wang Sheng-Hui
     

19 Jul, 2013

1 commit

  • egress_priority_map[] hash table updates are protected by rtnl,
    and we never remove elements until device is dismantled.

    We have to make sure that before inserting an new element in hash table,
    all its fields are committed to memory or else another cpu could
    find corrupt values and crash.

    Signed-off-by: Eric Dumazet
    Cc: Patrick McHardy
    Signed-off-by: David S. Miller

    Eric Dumazet
     

03 May, 2013

1 commit


20 Apr, 2013

3 commits


12 Feb, 2013

1 commit

  • __netpoll_rcu_free is used to free netpoll structures when the rtnl_lock is
    already held. The mechanism is used to asynchronously call __netpoll_cleanup
    outside of the holding of the rtnl_lock, so as to avoid deadlock.
    Unfortunately, __netpoll_cleanup modifies pointers (dev->np), which means the
    rtnl_lock must be held while calling it. Further, it cannot be held, because
    rcu callbacks may be issued in softirq contexts, which cannot sleep.

    Fix this by converting the rcu callback to a work queue that is guaranteed to
    get scheduled in process context, so that we can hold the rtnl properly while
    calling __netpoll_cleanup

    Tested successfully by myself.

    Signed-off-by: Neil Horman
    CC: "David S. Miller"
    CC: Cong Wang
    CC: Eric Dumazet
    Signed-off-by: David S. Miller

    Neil Horman
     

11 Feb, 2013

1 commit


07 Jan, 2013

1 commit

  • Use strlcpy where possible to ensure the string is \0 terminated.
    Use always sizeof(string) instead of 32, ETHTOOL_BUSINFO_LEN
    and custom defines.
    Use snprintf instead of sprint.
    Remove unnecessary inits of ->fw_version
    Remove unnecessary inits of drvinfo struct.

    Signed-off-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Jiri Pirko
     

09 Nov, 2012

1 commit


02 Nov, 2012

1 commit

  • #if defined(CONFIG_FOO) || defined(CONFIG_FOO_MODULE)

    can be replaced by

    #if IS_ENABLED(CONFIG_FOO)

    Cc: David S. Miller
    Signed-off-by: Cong Wang
    Signed-off-by: David S. Miller

    Amerigo Wang
     

15 Aug, 2012

4 commits


18 Jul, 2012

1 commit


17 May, 2012

1 commit


11 May, 2012

1 commit

  • This reverts commit 8a83a00b0735190384a348156837918271034144.

    It causes regressions for S390 devices, because it does an
    unconditional DST drop on SKBs for vlans and the QETH device
    needs the neighbour entry hung off the DST for certain things
    on transmit.

    Arnd can't remember exactly why he even needed this change.

    Conflicts:

    drivers/net/macvlan.c
    net/8021q/vlan_dev.c
    net/core/dev.c

    Signed-off-by: David S. Miller

    David S. Miller
     

10 May, 2012

1 commit

  • Use the new bool function ether_addr_equal to add
    some clarity and reduce the likelihood for misuse
    of compare_ether_addr for sorting.

    Done via cocci script:

    $ cat compare_ether_addr.cocci
    @@
    expression a,b;
    @@
    - !compare_ether_addr(a, b)
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - compare_ether_addr(a, b)
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !ether_addr_equal(a, b) == 0
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !ether_addr_equal(a, b) != 0
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - ether_addr_equal(a, b) == 0
    + !ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - ether_addr_equal(a, b) != 0
    + ether_addr_equal(a, b)

    @@
    expression a,b;
    @@
    - !!ether_addr_equal(a, b)
    + ether_addr_equal(a, b)

    Signed-off-by: Joe Perches
    Signed-off-by: David S. Miller

    Joe Perches
     

14 Dec, 2011

1 commit

  • commit 6d4cdf47d2 (vlan: add 802.1q netpoll support) forgot to declare
    as static some private functions.

    Signed-off-by: Eric Dumazet
    CC: Benjamin LaHaise
    Signed-off-by: David S. Miller

    Eric Dumazet
     

09 Dec, 2011

2 commits


17 Nov, 2011

2 commits