14 May, 2015

1 commit

  • Currently vlan notifier handler will try to update all vlans
    for a device when that device comes up. A problem occurs,
    however, when the vlan device was set to promiscuous, but not
    by the user (ex: a bridge). In that case, dev->gflags are
    not updated. What results is that the lower device ends
    up with an extra promiscuity count. Here are the
    backtraces that prove this:
    [62852.052179] [] __dev_set_promiscuity+0x38/0x1e0
    [62852.052186] [] ? _raw_spin_unlock_bh+0x1b/0x40
    [62852.052188] [] ? dev_set_rx_mode+0x2e/0x40
    [62852.052190] [] dev_set_promiscuity+0x24/0x50
    [62852.052194] [] vlan_dev_open+0xd5/0x1f0 [8021q]
    [62852.052196] [] __dev_open+0xbf/0x140
    [62852.052198] [] __dev_change_flags+0x9d/0x170
    [62852.052200] [] dev_change_flags+0x29/0x60

    The above comes from the setting the vlan device to IFF_UP state.

    [62852.053569] [] __dev_set_promiscuity+0x38/0x1e0
    [62852.053571] [] ? vlan_dev_set_rx_mode+0x2b/0x30
    [8021q]
    [62852.053573] [] __dev_change_flags+0xe5/0x170
    [62852.053645] [] dev_change_flags+0x29/0x60
    [62852.053647] [] vlan_device_event+0x18a/0x690
    [8021q]
    [62852.053649] [] notifier_call_chain+0x4c/0x70
    [62852.053651] [] raw_notifier_call_chain+0x16/0x20
    [62852.053653] [] call_netdevice_notifiers+0x2d/0x60
    [62852.053654] [] __dev_notify_flags+0x33/0xa0
    [62852.053656] [] dev_change_flags+0x52/0x60
    [62852.053657] [] do_setlink+0x397/0xa40

    And this one comes from the notification code. What we end
    up with is a vlan with promiscuity count of 1 and and a physical
    device with a promiscuity count of 2. They should both have
    a count 1.

    To resolve this issue, vlan code can use dev_get_flags() api
    which correctly masks promiscuity and allmulti flags.

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

19 Mar, 2015

1 commit

  • When a networking device is taken down that has a non-trivial number
    of VLAN devices configured under it, we eat a full synchronize_net()
    for every such VLAN device.

    This is because of the call chain:

    NETDEV_DOWN notifier
    --> vlan_device_event()
    --> dev_change_flags()
    --> __dev_change_flags()
    --> __dev_close()
    --> __dev_close_many()
    --> dev_deactivate_many()
    --> synchronize_net()

    This is kind of rediculous because we already have infrastructure for
    batching doing operation X to a list of net devices so that we only
    incur one sync.

    So make use of that by exporting dev_close_many() and adjusting it's
    interfaace so that the caller can fully manage the batch list. Use
    this in vlan_device_event() and all the overhead goes away.

    Reported-by: Salam Noureddine
    Signed-off-by: David S. Miller

    David S. Miller
     

30 Jul, 2014

1 commit


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
     

17 May, 2014

1 commit

  • This reverts commit dc8eaaa006350d24030502a4521542e74b5cb39f.
    vlan: Fix lockdep warning when vlan dev handle notification

    Instead we use the new new API to find the lock subclass of
    our vlan device. This way we can support configurations where
    vlans are interspersed with other devices:
    bond -> vlan -> macvlan -> vlan

    Signed-off-by: Vlad Yasevich
    Signed-off-by: David S. Miller

    Vlad Yasevich
     

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
     

22 Jan, 2014

1 commit


27 Sep, 2013

2 commits

  • On netdev unregister we're removing also all of its sysfs-associated stuff,
    including the sysfs symlinks that are controlled by netdev neighbour code.
    Also, it's a subtle race condition - cause we can still access it after
    unregistering.

    Move the unlinking right before the unregistering to fix both.

    CC: Patrick McHardy
    CC: "David S. Miller"
    Signed-off-by: Veaceslav Falico
    Signed-off-by: David S. Miller

    Veaceslav Falico
     
  • Otherwise users might access it without being fully registered, as per
    sysfs - it only inits in register_netdevice(), so is unusable till it is
    called.

    CC: Patrick McHardy
    CC: "David S. Miller"
    Signed-off-by: Veaceslav Falico
    Signed-off-by: David S. Miller

    Veaceslav Falico
     

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
     

24 Jul, 2013

1 commit

  • Until now, bond_resend_igmp_join_requests() looks for vlans attached to
    bonding device, bridge where bonding act as port manually. It does not
    care of other scenarios, like stacked bonds or team device above. Make
    this more generic and use netdev notifier to propagate the event to
    upper devices and to actually call ip_mc_rejoin_groups().

    Signed-off-by: Jiri Pirko
    Acked-by: Veaceslav Falico
    Signed-off-by: David S. Miller

    Jiri Pirko
     

29 May, 2013

1 commit

  • So far, only net_device * could be passed along with netdevice notifier
    event. This patch provides a possibility to pass custom structure
    able to provide info that event listener needs to know.

    Signed-off-by: Jiri Pirko

    v2->v3: fix typo on simeth
    shortened dev_getter
    shortened notifier_info struct name
    v1->v2: fix notifier_call parameter in call_netdevice_notifier()
    Signed-off-by: David S. Miller

    Jiri Pirko
     

20 Apr, 2013

3 commits


25 Mar, 2013

1 commit

  • vlan_vid_del() could possibly free ->vlan_info after a RCU grace
    period, however, we may still refer to the freed memory area
    by 'grp' pointer. Found by code inspection.

    This patch moves vlan_vid_del() as behind as possible.

    Cc: Patrick McHardy
    Cc: "David S. Miller"
    Signed-off-by: Cong Wang
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Cong Wang
     

11 Feb, 2013

1 commit


30 Jan, 2013

1 commit

  • Instead of jumping aroung bugs that are easily fixed just don't let them in:
    affected drivers should be either fixed or have NETIF_F_HW_VLAN_FILTER
    removed from advertised features.

    Quick grep in drivers/net shows two drivers that have NETIF_F_HW_VLAN_FILTER
    but not ndo_vlan_rx_add/kill_vid(), but those are false-positives (features
    are commented out).

    OTOH two drivers have ndo_vlan_rx_add/kill_vid() implemented but don't
    advertise NETIF_F_HW_VLAN_FILTER. Those are:

    +ethernet/cisco/enic/enic_main.c
    +ethernet/qlogic/qlcnic/qlcnic_main.c

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

    Michał Mirosław
     

05 Jan, 2013

1 commit


01 Dec, 2012

1 commit

  • This bug is observed on running FCoE over a VLAN device associated w/
    a real device that has IFF_UNICAST_FLT set since FCoE would add unicast
    address such as FLOGI MAC to the VLAN interface that FCoE is on. Since
    currently, VLAN device is not inheriting the IFF_UNICAST_FLT flag from the
    parent real device even though the real device is capable of doing unicast
    filtering. This forces the VLAN device and its real device go to promiscuous
    mode unnecessarily even the added address is actually being added to the
    available unicast filter table in real device.

    Signed-off-by: Yi Zou
    Cc: devel@open-fcoe.org
    Signed-off-by: David S. Miller

    Yi Zou
     

19 Nov, 2012

1 commit

  • Allow an unpriviled user who has created a user namespace, and then
    created a network namespace to effectively use the new network
    namespace, by reducing capable(CAP_NET_ADMIN) and
    capable(CAP_NET_RAW) calls to be ns_capable(net->user_ns,
    CAP_NET_ADMIN), or capable(net->user_ns, CAP_NET_RAW) calls.

    Allow the vlan ioctls:
    SET_VLAN_INGRESS_PRIORITY_CMD
    SET_VLAN_EGRESS_PRIORITY_CMD
    SET_VLAN_FLAG_CMD
    SET_VLAN_NAME_TYPE_CMD
    ADD_VLAN_CMD
    DEL_VLAN_CMD

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

    Eric W. Biederman
     

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
     

19 Oct, 2012

1 commit


11 Jul, 2012

1 commit

  • In driver reload test there is a memory leak.
    The structure vlan_info was not freed when the driver was removed.
    It was not released since the nr_vids var is one after last vlan was removed.
    The nr_vids is one, since vlan zero is added to the interface when the interface
    is being set, but the vlan zero is not deleted at unregister.
    Fix - delete vlan zero when we unregister the device.

    Signed-off-by: Amir Hanania
    Acked-by: John Fastabend
    Tested-by: Aaron Brown
    Signed-off-by: Jeff Kirsher
    Signed-off-by: David S. Miller

    Amir Hanania
     

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
     

09 Dec, 2011

3 commits


02 Aug, 2011

1 commit

  • When assigning a NULL value to an RCU protected pointer, no barrier
    is needed. The rcu_assign_pointer, used to handle that but will soon
    change to not handle the special case.

    Convert all rcu_assign_pointer of NULL value.

    //smpl
    @@ expression P; @@

    - rcu_assign_pointer(P, NULL)
    + RCU_INIT_POINTER(P, NULL)

    //

    Signed-off-by: Stephen Hemminger
    Acked-by: Paul E. McKenney
    Signed-off-by: David S. Miller

    Stephen Hemminger
     

22 Jul, 2011

1 commit


21 Jun, 2011

1 commit


17 Jun, 2011

1 commit


03 Jun, 2011

1 commit

  • Use the current logging style.

    Add #define pr_fmt and remove embedded prefix from formats.

    Not converting the current pr_ uses to netdev_
    because all the output here is nicely prefaced with "8021q: ".

    Remove __func__ use from proc registration failure message.

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

    Joe Perches
     

27 May, 2011

1 commit

  • The below patch removes vlan_buggyright and vlan_copyright from vlan_proto_init,
    so that it prints out just the fullname of vlan and the version number.

    before:

    [ 30.438203] 802.1Q VLAN Support v1.8 Ben Greear
    [ 30.441542] All bugs added by David S. Miller

    after:

    [ 31.513910] 802.1Q VLAN Support v1.8

    Signed-off-by: Justin P. Mattock
    CC: Joe Perches
    CC: David S. Miller
    CC: Ben Greear
    Signed-off-by: David S. Miller

    Justin Mattock
     

12 May, 2011

1 commit


11 May, 2011

1 commit

  • ip link add link eth2 eth2.103 type vlan id 103 gvrp on loose_binding on
    ip link set eth2.103 up
    rmmod tg3 # driver providing eth2

    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: [] garp_request_leave+0x3e/0xc0 [garp]
    PGD 11d251067 PUD 11b9e0067 PMD 0
    Oops: 0000 [#1] SMP
    last sysfs file: /sys/devices/virtual/net/eth2.104/ifindex
    CPU 0
    Modules linked in: tg3(-) 8021q garp nfsd lockd auth_rpcgss sunrpc libphy sg [last unloaded: x_tables]

    Pid: 11494, comm: rmmod Tainted: G W 2.6.39-rc6-00261-gfd71257-dirty #580 HP ProLiant BL460c G6
    RIP: 0010:[] [] garp_request_leave+0x3e/0xc0 [garp]
    RSP: 0018:ffff88007a19bae8 EFLAGS: 00010286
    RAX: 0000000000000000 RBX: ffff88011b5e2000 RCX: 0000000000000002
    RDX: 0000000000000000 RSI: 0000000000000175 RDI: ffffffffa0030d5b
    RBP: ffff88007a19bb18 R08: 0000000000000001 R09: ffff88011bd64a00
    R10: ffff88011d34ec00 R11: 0000000000000000 R12: 0000000000000002
    R13: ffff88007a19bc48 R14: ffff88007a19bb88 R15: 0000000000000001
    FS: 0000000000000000(0000) GS:ffff88011fc00000(0063) knlGS:00000000f77d76c0
    CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b
    CR2: 0000000000000000 CR3: 000000011a675000 CR4: 00000000000006f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Process rmmod (pid: 11494, threadinfo ffff88007a19a000, task ffff8800798595c0)
    Stack:
    ffff88007a19bb36 ffff88011c84b800 ffff88011b5e2000 ffff88007a19bc48
    ffff88007a19bb88 0000000000000006 ffff88007a19bb38 ffffffffa003a5f6
    ffff88007a19bb38 670088007a19bba8 ffff88007a19bb58 ffffffffa00397e7
    Call Trace:
    [] vlan_gvrp_request_leave+0x46/0x50 [8021q]
    [] vlan_dev_stop+0xb7/0xc0 [8021q]
    [] __dev_close_many+0x87/0xe0
    [] dev_close_many+0x87/0x110
    [] rollback_registered_many+0xa0/0x240
    [] unregister_netdevice_many+0x19/0x60
    [] vlan_device_event+0x53b/0x550 [8021q]
    [] ? ip6mr_device_event+0xa8/0xd0
    [] notifier_call_chain+0x53/0x80
    [] __raw_notifier_call_chain+0x9/0x10
    [] raw_notifier_call_chain+0x11/0x20
    [] call_netdevice_notifiers+0x32/0x60
    [] rollback_registered_many+0x10f/0x240
    [] rollback_registered+0x2f/0x40
    [] unregister_netdevice_queue+0x58/0x90
    [] unregister_netdev+0x1b/0x30
    [] tg3_remove_one+0x6f/0x10b [tg3]

    We should call vlan_gvrp_request_leave() from unregister_vlan_dev(),
    not from vlan_dev_stop(), because vlan_gvrp_uninit_applicant()
    is called right after unregister_netdevice_queue(). In batch mode,
    unregister_netdevice_queue() doesn’t immediately call vlan_dev_stop().

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

    Eric Dumazet
     

10 May, 2011

1 commit

  • At VLAN dismantle phase, unregister_vlan_dev() makes one
    synchronize_net() call after vlan_group_set_device(grp, vlan_id, NULL).

    This call can be safely removed because we are calling
    unregister_netdevice_queue() to queue device for deletion, and this
    process needs at least one rcu grace period to complete.

    Signed-off-by: Eric Dumazet
    Cc: Ben Greear
    Cc: Patrick McHardy
    Cc: Paul E. McKenney
    Cc: Jesse Gross
    Cc: Michał Mirosław
    Acked-by: Jesse Gross
    Signed-off-by: David S. Miller

    Eric Dumazet
     

18 Apr, 2011

2 commits


13 Apr, 2011

1 commit

  • Now there are 2 paths for rx vlan frames. When rx-vlan-hw-accel is
    enabled, skb is untagged by NIC, vlan_tci is set and the skb gets into
    vlan code in __netif_receive_skb - vlan_hwaccel_do_receive.

    For non-rx-vlan-hw-accel however, tagged skb goes thru whole
    __netif_receive_skb, it's untagged in ptype_base hander and reinjected

    This incosistency is fixed by this patch. Vlan untagging happens early in
    __netif_receive_skb so the rest of code (ptype_all handlers, rx_handlers)
    see the skb like it was untagged by hw.

    Signed-off-by: Jiri Pirko

    v1->v2:
    remove "inline" from vlan_core.c functions
    Signed-off-by: David S. Miller

    Jiri Pirko