25 Feb, 2020

1 commit


08 Nov, 2019

1 commit


21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

13 Apr, 2019

1 commit


01 Apr, 2018

1 commit

  • This function calls call_netdevice_notifier(), which also
    may take net_rwsem. So, we can't use net_rwsem here.

    This patch makes callers of this functions take pernet_ops_rwsem,
    like register_netdevice_notifier() does. This will protect
    the modifications of net_namespace_list, and allows notifiers
    to take it (they won't have to care about context).

    Since __rtnl_link_unregister() is used on module load
    and unload (which are not frequent operations), this looks
    for me better, than make all call_netdevice_notifier()
    always executing in "protected net_namespace_list" context.

    Also, this fixes the problem we had a deal in 328fbe747ad4
    "Close race between {un, }register_netdevice_notifier and ...",
    and guarantees __rtnl_link_unregister() does not skip
    exitting net.

    Signed-off-by: Kirill Tkhai
    Signed-off-by: David S. Miller

    Kirill Tkhai
     

03 Dec, 2017

1 commit


26 Sep, 2017

1 commit

  • These two drivers (dummy and ifb) call ether_setup(), after commit
    61e84623ace3 ("net: centralize net_device min/max MTU checking"), the
    range of mtu is [min_mtu, max_mtu], which is [68, 1500] by default.

    These two devices should not have limits on MTU. This patch set their
    min_mtu/max_mtu to 0. So that dev_set_mtu() will not check the mtu range,
    and can be set with any value.

    CC: Eric Dumazet
    CC: Sabrina Dubroca
    Signed-off-by: Zhang Shengju
    Signed-off-by: David S. Miller

    Zhang Shengju
     

19 Sep, 2017

1 commit


18 Jul, 2017

1 commit


27 Jun, 2017

1 commit


08 Jun, 2017

1 commit

  • Network devices can allocate reasources and private memory using
    netdev_ops->ndo_init(). However, the release of these resources
    can occur in one of two different places.

    Either netdev_ops->ndo_uninit() or netdev->destructor().

    The decision of which operation frees the resources depends upon
    whether it is necessary for all netdev refs to be released before it
    is safe to perform the freeing.

    netdev_ops->ndo_uninit() presumably can occur right after the
    NETDEV_UNREGISTER notifier completes and the unicast and multicast
    address lists are flushed.

    netdev->destructor(), on the other hand, does not run until the
    netdev references all go away.

    Further complicating the situation is that netdev->destructor()
    almost universally does also a free_netdev().

    This creates a problem for the logic in register_netdevice().
    Because all callers of register_netdevice() manage the freeing
    of the netdev, and invoke free_netdev(dev) if register_netdevice()
    fails.

    If netdev_ops->ndo_init() succeeds, but something else fails inside
    of register_netdevice(), it does call ndo_ops->ndo_uninit(). But
    it is not able to invoke netdev->destructor().

    This is because netdev->destructor() will do a free_netdev() and
    then the caller of register_netdevice() will do the same.

    However, this means that the resources that would normally be released
    by netdev->destructor() will not be.

    Over the years drivers have added local hacks to deal with this, by
    invoking their destructor parts by hand when register_netdevice()
    fails.

    Many drivers do not try to deal with this, and instead we have leaks.

    Let's close this hole by formalizing the distinction between what
    private things need to be freed up by netdev->destructor() and whether
    the driver needs unregister_netdevice() to perform the free_netdev().

    netdev->priv_destructor() performs all actions to free up the private
    resources that used to be freed by netdev->destructor(), except for
    free_netdev().

    netdev->needs_free_netdev is a boolean that indicates whether
    free_netdev() should be done at the end of unregister_netdevice().

    Now, register_netdevice() can sanely release all resources after
    ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
    and netdev->priv_destructor().

    And at the end of unregister_netdevice(), we invoke
    netdev->priv_destructor() and optionally call free_netdev().

    Signed-off-by: David S. Miller

    David S. Miller
     

22 Mar, 2017

1 commit

  • This enables developing code that uses SOF_TIMESTAMPING_TX_SOFTWARE
    by using localhost addresses (without needing to send packets outside),
    as well as enabling unit and functional testing of TX timestamping code
    without needing hardware support or network access.

    It also fulfills the expectation of software network devices supporting
    software-based timestamping.

    Tested on qemu using txtimestamping.c from the kernel selftests, and
    ethtool -T.

    Signed-off-by: Ezequiel Lara Gomez
    Signed-off-by: David S. Miller

    Ezequiel Lara Gomez
     

25 Jan, 2017

1 commit

  • The idea for this was born when testing VF support in iproute2 which was
    impeded by hardware requirements. In fact, not every VF-capable hardware
    driver implements all netdev ops, so testing the interface is still hard
    to do even with a well-sorted hardware shelf.

    To overcome this and allow for testing the user-kernel interface, this
    patch allows to turn dummy into a PF with a configurable amount of VFs.

    Since my patch series 'bus-agnostic-num-vf' has been accepted,
    implementing the required interfaces is pretty straightforward: Iff
    'num_vfs' module parameter was given a value >0, a dummy bus type is
    being registered which implements the 'num_vf()' callback. Additionally,
    a dummy parent device common to all dummy devices is registered which
    sits on the above dummy bus.

    Joint work with Sabrina Dubroca.

    Signed-off-by: Sabrina Dubroca
    Signed-off-by: Phil Sutter
    Signed-off-by: David S. Miller

    Phil Sutter
     

09 Jan, 2017

1 commit

  • The network device operation for reading statistics is only called
    in one place, and it ignores the return value. Having a structure
    return value is potentially confusing because some future driver could
    incorrectly assume that the return value was used.

    Fix all drivers with ndo_get_stats64 to have a void function.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    stephen hemminger
     

08 Dec, 2016

1 commit


22 Oct, 2015

1 commit

  • While testing my SIT/GRO patch using netfilter TEE module and a dummy
    device, I found some features were missing :

    TSO IPv6, UFO, and encapsulated traffic.

    ethtool -k dummy0 now gives :
    ...
    tcp-segmentation-offload: on
    tx-tcp-segmentation: on
    tx-tcp-ecn-segmentation: on
    tx-tcp6-segmentation: on
    udp-fragmentation-offload: on
    ...
    tx-gre-segmentation: on
    tx-ipip-segmentation: on
    tx-sit-segmentation: on
    tx-udp_tnl-segmentation: on

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

19 Aug, 2015

1 commit


10 Dec, 2014

2 commits


16 Jul, 2014

1 commit

  • Extend alloc_netdev{,_mq{,s}}() to take name_assign_type as argument, and convert
    all users to pass NET_NAME_UNKNOWN.

    Coccinelle patch:

    @@
    expression sizeof_priv, name, setup, txqs, rxqs, count;
    @@

    (
    -alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs)
    +alloc_netdev_mqs(sizeof_priv, name, NET_NAME_UNKNOWN, setup, txqs, rxqs)
    |
    -alloc_netdev_mq(sizeof_priv, name, setup, count)
    +alloc_netdev_mq(sizeof_priv, name, NET_NAME_UNKNOWN, setup, count)
    |
    -alloc_netdev(sizeof_priv, name, setup)
    +alloc_netdev(sizeof_priv, name, NET_NAME_UNKNOWN, setup)
    )

    v9: move comments here from the wrong commit

    Signed-off-by: Tom Gundersen
    Reviewed-by: David Herrmann
    Signed-off-by: David S. Miller

    Tom Gundersen
     

15 Mar, 2014

1 commit

  • Replace the bh safe variant with the hard irq safe variant.

    We need a hard irq safe variant to deal with netpoll transmitting
    packets from hard irq context, and we need it in most if not all of
    the places using the bh safe variant.

    Except on 32bit uni-processor the code is exactly the same so don't
    bother with a bh variant, just have a hard irq safe variant that
    everyone can use.

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

    Eric W. Biederman
     

15 Feb, 2014

1 commit


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
     

12 Jul, 2013

1 commit

  • We rename the dummy in modprobe.conf like this:

    install dummy0 /sbin/modprobe -o dummy0 --ignore-install dummy
    install dummy1 /sbin/modprobe -o dummy1 --ignore-install dummy

    We got oops when we run the command:

    modprobe dummy0
    modprobe dummy1

    ------------[ cut here ]------------

    [ 3302.187584] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    [ 3302.195411] IP: [] __rtnl_link_unregister+0x9a/0xd0
    [ 3302.201844] PGD 85c94a067 PUD 8517bd067 PMD 0
    [ 3302.206305] Oops: 0002 [#1] SMP
    [ 3302.299737] task: ffff88105ccea300 ti: ffff880eba4a0000 task.ti: ffff880eba4a0000
    [ 3302.307186] RIP: 0010:[] [] __rtnl_link_unregister+0x9a/0xd0
    [ 3302.316044] RSP: 0018:ffff880eba4a1dd8 EFLAGS: 00010246
    [ 3302.321332] RAX: 0000000000000000 RBX: ffffffff81a9d738 RCX: 0000000000000002
    [ 3302.328436] RDX: 0000000000000000 RSI: ffffffffa04d602c RDI: ffff880eba4a1dd8
    [ 3302.335541] RBP: ffff880eba4a1e18 R08: dead000000200200 R09: dead000000100100
    [ 3302.342644] R10: 0000000000000080 R11: 0000000000000003 R12: ffffffff81a9d788
    [ 3302.349748] R13: ffffffffa04d7020 R14: ffffffff81a9d670 R15: ffff880eba4a1dd8
    [ 3302.364910] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 3302.370630] CR2: 0000000000000008 CR3: 000000085e15e000 CR4: 00000000000427e0
    [ 3302.377734] DR0: 0000000000000003 DR1: 00000000000000b0 DR2: 0000000000000001
    [ 3302.384838] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    [ 3302.391940] Stack:
    [ 3302.393944] ffff880eba4a1dd8 ffff880eba4a1dd8 ffff880eba4a1e18 ffffffffa04d70c0
    [ 3302.401350] 00000000ffffffef ffffffffa01a8000 0000000000000000 ffffffff816111c8
    [ 3302.408758] ffff880eba4a1e48 ffffffffa01a80be ffff880eba4a1e48 ffffffffa04d70c0
    [ 3302.416164] Call Trace:
    [ 3302.418605] [] ? 0xffffffffa01a7fff
    [ 3302.423727] [] dummy_init_module+0xbe/0x1000 [dummy0]
    [ 3302.430405] [] ? 0xffffffffa01a7fff
    [ 3302.435535] [] do_one_initcall+0x152/0x1b0
    [ 3302.441263] [] do_init_module+0x7b/0x200
    [ 3302.446824] [] load_module+0x4e2/0x530
    [ 3302.452215] [] ? ddebug_dyndbg_boot_param_cb+0x60/0x60
    [ 3302.458979] [] SyS_init_module+0xd1/0x130
    [ 3302.464627] [] system_call_fastpath+0x16/0x1b
    [ 3302.490090] RIP [] __rtnl_link_unregister+0x9a/0xd0
    [ 3302.496607] RSP
    [ 3302.500084] CR2: 0000000000000008
    [ 3302.503466] ---[ end trace 8342d49cd49f78ed ]---

    The reason is that when loading dummy, if __rtnl_link_register() return failed,
    the init_module should return and avoid take the wrong path.

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

    dingtianhong
     

29 Dec, 2012

1 commit


23 Jul, 2012

1 commit

  • Fix race condition in several network drivers when reading stats on 32bit
    UP architectures. These drivers update their stats in a BH context and
    therefore should use u64_stats_fetch_begin_bh/u64_stats_fetch_retry_bh
    instead of u64_stats_fetch_begin/u64_stats_fetch_retry when reading the
    stats.

    Signed-off-by: Kevin Groeneveld
    Signed-off-by: David S. Miller

    Kevin Groeneveld
     

30 Jun, 2012

1 commit


11 Jun, 2012

1 commit

  • Trying to "modprobe dummy numdummies=30000" triggers :

    INFO: rcu_sched self-detected stall on CPU { 8} (t=60000 jiffies)

    After this splat, RTNL is locked and reboot is needed.

    We must call cond_resched() to avoid this, even holding RTNL.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

17 Apr, 2012

1 commit

  • In register_netdevice(), when ndo_init() is successful and later
    some error occurred, ndo_uninit() will be called.
    So dummy deivce is desirable to implement ndo_uninit() method
    to free percpu stats for this case.
    And, ndo_uninit() is also called along with dev->destructor() when
    device is unregistered, so in order to prevent dev->dstats from
    being freed twice, dev->destructor is modified to free_netdev().

    Signed-off-by: Hiroaki SHIMODA
    Signed-off-by: David S. Miller

    Hiroaki SHIMODA
     

16 Feb, 2012

1 commit


17 Nov, 2011

1 commit

  • Only distinct use is checking if NETIF_F_NOCACHE_COPY should be
    enabled by default. The check heuristics is altered a bit here,
    so it hits other people than before. The default shouldn't be
    trusted for performance-critical cases anyway.

    For all other uses NETIF_F_NO_CSUM is equivalent to NETIF_F_HW_CSUM.

    Signed-off-by: Michał Mirosław
    Signed-off-by: David S. Miller

    Michał Mirosław
     

18 Aug, 2011

1 commit


06 May, 2011

1 commit

  • Force dev_alloc_name() to be called from register_netdevice() by
    dev_get_valid_name(). That allows to remove multiple explicit
    dev_alloc_name() calls.

    The possibility to call dev_alloc_name in advance remains.

    This also fixes veth creation regresion caused by
    84c49d8c3e4abefb0a41a77b25aa37ebe8d6b743

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

    Jiri Pirko
     

30 Sep, 2010

1 commit

  • Converts dummy network device driver to :

    - percpu stats

    - 64bit stats

    - lockless xmit (NETIF_F_LLTX)

    - performance features added (NETIF_F_SG | NETIF_F_FRAGLIST |
    NETIF_F_TSO | NETIF_F_NO_CSUM | NETIF_F_HIGHDMA)

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

01 Sep, 2009

1 commit


06 Jul, 2009

1 commit


21 Nov, 2008

1 commit


11 Oct, 2007

1 commit

  • It's been a useless no-op for long enough in 2.6 so I figured it's time to
    remove it. The number of people that could object because they're
    maintaining unified 2.4 and 2.6 drivers is probably rather small.

    [ Handled drivers added by netdev tree and some missed IRDA cases... -DaveM ]

    Signed-off-by: Ralf Baechle
    Signed-off-by: Jeff Garzik
    Signed-off-by: David S. Miller

    Ralf Baechle
     

12 Jul, 2007

2 commits

  • Drivers need to validate the initial addresses in their netlink attribute
    validation function or manually reject them if they can't support this.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • All drivers need to unregister their devices in the module unload function.
    While doing so they must hold the rtnl and atomically unregister the
    rtnl_link ops as well. This makes the rtnl_link_unregister function that
    takes the rtnl itself completely useless.

    Provide default newlink/dellink functions, make __rtnl_link_unregister and
    rtnl_link_unregister unregister all devices with matching rtnl_link_ops and
    change the existing users to take advantage of that.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy