11 Dec, 2017

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    Notice that in some cases I replaced "fall through on else" and
    "otherwise fall through" comments with just a "fall through" comment,
    which is what GCC is expecting to find.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Johannes Berg

    Gustavo A. R. Silva
     

27 Nov, 2017

1 commit


20 Nov, 2017

1 commit

  • In preparation for unconditionally passing the struct timer_list pointer to
    all timer callbacks, switch to using the new timer_setup() and from_timer()
    to pass the timer pointer explicitly.

    Cc: Johannes Berg
    Cc: "David S. Miller"
    Cc: linux-wireless@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Signed-off-by: Kees Cook
    Signed-off-by: Johannes Berg

    Kees Cook
     

21 Sep, 2017

1 commit

  • This was created using the following spatch:
    @find@
    type S;
    expression M, M2;
    position p;
    @@
    offsetof(S, M) + sizeof(M2)@p

    @script:python@
    m << find.M;
    m2 << find.M2;
    @@
    if not m2.endswith('-> ' + m):
    cocci.include_match(False)

    @change@
    type find.S;
    expression find.M, find.M2;
    position find.p;
    @@
    -offsetof(S, M) + sizeof(M2)@p
    +offsetofend(S, M)

    Signed-off-by: Johannes Berg

    Johannes Berg
     

16 Jun, 2017

1 commit

  • There were many places that my previous spatch didn't find,
    as pointed out by yuan linyu in various patches.

    The following spatch found many more and also removes the
    now unnecessary casts:

    @@
    identifier p, p2;
    expression len;
    expression skb;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_zero(skb, len);
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, len);
    |
    -memset(p, 0, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_zero(skb, sizeof(t));
    )
    ... when != p
    (
    p2 = (t2)p;
    -memset(p2, 0, sizeof(*p));
    |
    -memset(p, 0, sizeof(*p));
    )

    @@
    expression skb, len;
    @@
    -memset(skb_put(skb, len), 0, len);
    +skb_put_zero(skb, len);

    Apply it to the tree (with one manual fixup to keep the
    comment in vxlan.c, which spatch removed.)

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

06 Mar, 2017

2 commits

  • Mesh failure average never be more than 100. Only in case of
    fixed path, average will be more than threshold limit (95%).
    With recent EWMA changes it may go upto 99 as it is scaled to
    100. It make sense to return maximum metric when average is
    greater than threshold limit.

    Signed-off-by: Rajkumar Manoharan
    Signed-off-by: Johannes Berg

    Manoharan, Rajkumar
     
  • As moving average is not considering fractional part, it will
    get stuck at the same level after certain state. For example,
    with current values, it can get stuck at 96. Fortunately the
    current threshold 95%, but if it were increased to 96 or more
    mesh paths would never be deactivated. Fix failure average
    movement by using EWMA helpers, which does take into account
    fractional parts.

    Signed-off-by: Rajkumar Manoharan
    [johannes: pick a larger EWMA factor for more precision with
    the limited range that we will feed into it, adjust to new API]
    Signed-off-by: Johannes Berg

    Manoharan, Rajkumar
     

23 Sep, 2016

1 commit


12 Sep, 2016

1 commit

  • A fixed mpath was not quite being treated as such:

    1) if a PERR frame was received, a fixed mpath was
    deactivated.

    2) queued path discovery for fixed mpath was potentially
    being considered, changing mpath state.

    3) other mpath flags were potentially being inherited when
    fixing the mpath. Just assign PATH_FIXED and SN_VALID.

    This solves several issues when fixing a mesh path in one
    direction. The reverse direction mpath should probably
    also be fixed, or root announcements at least be enabled.

    Signed-off-by: Thomas Pedersen
    Signed-off-by: Johannes Berg

    Pedersen, Thomas
     

11 Aug, 2016

1 commit

  • Mesh HWMP module will be able to rely on the HW
    RC algorithm if it exists, for path metric calculations.

    This allows the metric calculation mechanism to calculate
    a correct metric, based on PER and last TX rate both via
    HW RC algorithm if it exists or via parameters collected
    by the SW.

    Signed-off-by: Maxim Altshul
    Signed-off-by: Johannes Berg

    Maxim Altshul
     

10 Apr, 2016

1 commit


06 Apr, 2016

2 commits

  • This fixes:

    net/mac80211/mesh_hwmp.c:603:26: warning: ‘target_metric’ may be used uninitialized in this function

    target_metric is only consumed when reply = true so no bug exists here,
    but not all versions of gcc realize it. Initialize to 0 to remove the
    warning.

    Signed-off-by: Jeff Mahoney
    Signed-off-by: Johannes Berg

    Jeff Mahoney
     
  • The mesh_path_reclaim() function, called from an rcu callback, cancels
    the mesh_path_timer associated with a mesh path. Unfortunately, this
    call can happen much later, perhaps after the hash table itself is
    destroyed.

    Such a situation led to the following crash in mesh_path_send_to_gates()
    when dereferencing the tbl pointer:

    [ 23.901661] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    [ 23.905516] IP: [] mesh_path_send_to_gates+0x2b/0x740
    [ 23.908757] PGD 99ca067 PUD 99c4067 PMD 0
    [ 23.910789] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
    [ 23.913485] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.5.0-rc6-wt+ #43
    [ 23.916675] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Debian-1.8.2-1 04/01/2014
    [ 23.920471] task: ffffffff81685500 ti: ffffffff81678000 task.ti: ffffffff81678000
    [ 23.922619] RIP: 0010:[] [] mesh_path_send_to_gates+0x2b/0x740
    [ 23.925237] RSP: 0018:ffff88000b403d30 EFLAGS: 00010286
    [ 23.926739] RAX: 0000000000000000 RBX: ffff880009bc0d20 RCX: 0000000000000102
    [ 23.928796] RDX: 000000000000002e RSI: 0000000000000001 RDI: ffff880009bc0d20
    [ 23.930895] RBP: ffff88000b403e18 R08: 0000000000000001 R09: 0000000000000001
    [ 23.932917] R10: 0000000000000000 R11: 0000000000000001 R12: ffff880009c20940
    [ 23.936370] R13: ffff880009bc0e70 R14: ffff880009c21c40 R15: ffff880009bc0d20
    [ 23.939823] FS: 0000000000000000(0000) GS:ffff88000b400000(0000) knlGS:0000000000000000
    [ 23.943688] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    [ 23.946429] CR2: 0000000000000008 CR3: 00000000099c5000 CR4: 00000000000006b0
    [ 23.949861] Stack:
    [ 23.950840] 000000000000002e ffff880009c20940 ffff88000b403da8 ffffffff8109e551
    [ 23.954467] ffffffff82711be2 000000000000002e 0000000000000000 ffffffff8166a5f5
    [ 23.958141] 0000000000685ce8 0000000000000246 ffff880009bc0d20 ffff880009c20940
    [ 23.961801] Call Trace:
    [ 23.962987]
    [ 23.963963] [] ? vprintk_emit+0x351/0x5e0
    [ 23.966782] [] ? vprintk_default+0x1f/0x30
    [ 23.969529] [] ? printk+0x48/0x50
    [ 23.971956] [] mesh_path_timer+0x133/0x160
    [ 23.974707] [] ? mesh_nexthop_resolve+0x230/0x230
    [ 23.977775] [] call_timer_fn+0xce/0x330
    [ 23.980448] [] ? call_timer_fn+0x5/0x330
    [ 23.983126] [] ? mesh_nexthop_resolve+0x230/0x230
    [ 23.986091] [] run_timer_softirq+0x22c/0x390

    Instead of cancelling in the RCU callback, set a new flag to prevent the
    timer from being rearmed, and then cancel the timer synchronously when
    freeing the mesh path. This leaves mesh_path_reclaim() doing nothing
    but kfree, so switch to kfree_rcu().

    Fixes: 3b302ada7f0a ("mac80211: mesh: move path tables into if_mesh")
    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     

05 Mar, 2016

1 commit


21 Oct, 2015

1 commit

  • Group station statistics by where they're (mostly) updated
    (TX, RX and TX-status) and group them into sub-structs of
    the struct sta_info.

    Also rename the variables since the grouping now makes it
    obvious where they belong.

    This makes it easier to identify where the statistics are
    updated in the code, and thus easier to think about them.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

17 Jul, 2015

6 commits

  • This value is only used in mesh, so move it into the new mesh
    sub-struct of the station info.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • This patch does the following:
    - Remove unnecessary flags field used by PERR element
    - Use the per target flags defined in
    - Process the target only subfield based on case E2 of
    IEEE802.11-2012 13.10.9.3

    Signed-off-by: Chun-Yeow Yeoh
    Signed-off-by: Johannes Berg

    Chun-Yeow Yeoh
     
  • When processing a PREQ or PREP it's critical to use the incoming SN. If
    that is improperly done routing loops and other types of badness can
    happen. But the code was always processing path messages for deactivated
    paths. This path fixes that so that if we have a valid SN then we use it
    to verify that it is a message we can accept. For reference the relevant
    section of the standard is 13.10.8.4 which doesn't address the deactivated
    path case at all.

    I also included a special case for when our peer reboots or restarts
    networking. This is an important case because without it there can be a
    very long delay before we accept path messages from that peer. It's also a
    simple case and intimately associated with processing messages for
    deactivated paths so I used one patch instead of two.

    Signed-off-by: Alexis Green
    Signed-off-by: Johannes Berg

    Jesse Jones
     
  • The 2012 spec mentions that path SNs can be invalid when created (see
    section 13.10.8.4 table 13-9) but AFAICT never talks about invalidating
    SNs. Which makes sense: if we have figured out the path to a target at a
    certain SN then we want to remember that fact. Failing to do so can lead
    to routing loops because if we don't have a valid SN then we have no way
    of knowing whether an incoming path message leads to or away from the
    target.

    However currently when discovery fails we zero out mpath->flags which
    clears MESH_PATH_SN_VALID. This patch fixes that so that only the
    discovery relevant flags are cleared.

    Signed-off-by: Alexis Green
    Signed-off-by: Johannes Berg

    Jesse Jones
     
  • When the nexthop is unable to resolve its own nexthop it will send back a
    PERR with a zero target_sn. According to section 13.10.11.4.3 step b in the
    2012 standard that perr should be forwarded and the associated mpath->sn
    should be incremented. Neither one of those was happening which is rather
    bad because the originator was not told that packets are black holing.

    Signed-off-by: Alexis Green
    CC: Jesse Jones
    Signed-off-by: Johannes Berg

    Alexis Green
     
  • There are now a fairly large number of mesh fields that really
    aren't needed in any other modes; move those into their own
    structure and allocate them separately.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

10 Jun, 2015

2 commits

  • This patch fixes a bug in hwmp_preq_frame_process where the wrong metric
    can be used when forwarding a PREQ. This happens because the code uses
    the same metric variable to record the value of the metric to the source
    of the PREQ and the value of the metric to the target of the PREQ.

    This comes into play when both reply and forward are set which happens
    when IEEE80211_PREQ_PROACTIVE_PREP_FLAG is set and when MP_F_DO | MP_F_RF
    is set. The original code had a special case to handle the first case
    but not the second.

    The patch uses distinct variables for the two metrics which makes the
    code flow much clearer and removes the need to restore the original
    value of metric when forwarding.

    Signed-off-by: Alexis Green
    CC: Jesse Jones
    Signed-off-by: Johannes Berg

    Alexis Green
     
  • The last hop metric should refer to link cost (this is how
    hwmp_route_info_get uses it for example). But in mesh_rx_path_sel_frame
    we are not dealing with link cost but with the total cost to the origin
    of a PREQ or PREP.

    Signed-off-by: Alexis Green
    CC: Jesse Jones
    Signed-off-by: Johannes Berg

    Alexis Green
     

16 Jul, 2014

1 commit


22 Apr, 2014

2 commits

  • When a path target responds to a path request, its response
    always contains the most up-to-date information; accordingly,
    it should use the latest target_sn, regardless of
    net_traversal_jiffies(). Otherwise, only the first path
    response is considered when constructing a path, as it will
    have the highest target_sn of all replies during that period.

    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     
  • u16_field_get() is a simple wrapper around get_unaligned_le16(),
    and it is being assigned to a u16, so there's no need to
    promote to u32 in the middle.

    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     

26 Nov, 2013

2 commits

  • Use put_unaligned_le16 and put_unaligned_le32 for
    mesh_path_error_tx and mesh_path_sel_frame_tx.

    Signed-off-by: Chun-Yeow Yeoh
    Signed-off-by: Johannes Berg

    Chun-Yeow Yeoh
     
  • This adds generic cipher scheme support to mac80211, such schemes
    are fully under control by the driver. On hw registration drivers
    may specify additional HW ciphers with a scheme how these ciphers
    have to be handled by mac80211 TX/RR. A cipher scheme specifies a
    cipher suite value, a size of the security header to be added to
    or stripped from frames and how the PN is to be verified on RX.

    Signed-off-by: Max Stepanov
    Signed-off-by: Johannes Berg

    Max Stepanov
     

16 Apr, 2013

1 commit

  • VHT introduces multiple IEs that need to be parsed for a
    wide bandwidth channel switch. Two are (currently) needed
    in mac80211:
    * wide bandwidth channel switch element
    * channel switch wrapper element

    The former is contained in the latter for beacons and probe
    responses, but not for the spectrum management action frames
    so the IE parser needs a new argument to differentiate them.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

08 Apr, 2013

2 commits

  • Most times that mesh_path_add() is called, it is followed by
    a lookup to get the just-added mpath. We can instead just
    return the new mpath in the case that we allocated one (or the
    existing one if already there), so do that. Also, reorder the
    code in mesh_path_add a bit so that we don't need to allocate
    in the pre-existing case.

    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     
  • The mesh hwmp debug message is a bit confusing. The "sending PREP
    to %p" should be the MAC address of mesh STA that has originated
    the PREQ message and the "received PREP from %pM" should be the MAC
    address of the mesh STA that has originated the PREP message.

    Signed-off-by: Chun-Yeow Yeoh
    Signed-off-by: Johannes Berg

    Chun-Yeow Yeoh
     

15 Feb, 2013

2 commits


05 Feb, 2013

1 commit

  • Add routines to
    - maintain a PS mode for each peer and a non-peer PS mode
    - indicate own PS mode in transmitted frames
    - track neighbor STAs power modes
    - buffer frames when neighbors are in PS mode
    - add TIM and Awake Window IE to beacons
    - release frames in Mesh Peer Service Periods

    Add local_pm to sta_info to represent the link-specific power
    mode at this station towards the remote station. When a peer
    link is established, use the default power mode stored in mesh
    config. Update the PS status if the peering status of a neighbor
    changes.
    Maintain a mesh power mode for non-peer mesh STAs. Set the
    non-peer power mode to active mode during peering. Authenticated
    mesh peering is currently not working when either node is
    configured to be in power save mode.

    Indicate the current power mode in transmitted frames. Use QoS
    Nulls to indicate mesh power mode transitions.
    For performance reasons, calls to the function setting the frame
    flags are placed in HWMP routing routines, as there the STA
    pointer is already available.

    Add peer_pm to sta_info to represent the peer's link-specific
    power mode towards the local station. Add nonpeer_pm to
    represent the peer's power mode towards all non-peer stations.
    Track power modes based on received frames.

    Add the ps_data structure to ieee80211_if_mesh (for TIM map, PS
    neighbor counter and group-addressed frame buffer).

    Set WLAN_STA_PS flag for STA in PS mode to use the unicast frame
    buffering routines in the tx path. Update num_sta_ps to buffer
    and release group-addressed frames after DTIM beacons.

    Announce the awake window duration in beacons if in light or
    deep sleep mode towards any peer or non-peer. Create a TIM IE
    similarly to AP mode and add it to mesh beacons. Parse received
    Awake Window IEs and check TIM IEs for buffered frames.

    Release frames towards peers in mesh Peer Service Periods. Use
    the corresponding trigger frames and monitor the MPSP status.
    Append a QoS Null as trigger frame if neccessary to properly end
    the MPSP. Currently, in HT channels MPSPs behave imperfectly and
    show large delay spikes and frame losses.

    Signed-off-by: Marco Porsch
    Signed-off-by: Ivan Bezyazychnyy
    Signed-off-by: Mike Krinkin
    Signed-off-by: Max Filippov
    Signed-off-by: Johannes Berg

    Marco Porsch
     

29 Jan, 2013

1 commit


17 Jan, 2013

2 commits

  • Mesh PERR action frames are robust and thus may be encrypted, so add
    proper head/tailroom to allow this. Fixes this warning when operating
    a Mesh STA on ath5k:

    WARNING: at net/mac80211/wpa.c:427 ccmp_encrypt_skb.isra.5+0x7b/0x1a0 [mac80211]()
    Call Trace:
    [] warn_slowpath_common+0x63/0x78
    [] warn_slowpath_null+0xf/0x13
    [] ccmp_encrypt_skb.isra.5+0x7b/0x1a0 [mac80211]
    [] ieee80211_crypto_ccmp_encrypt+0x1f/0x37 [mac80211]
    [] invoke_tx_handlers+0xcad/0x10bd [mac80211]
    [] ieee80211_tx+0x87/0xb3 [mac80211]
    [] ieee80211_tx_pending+0xcc/0x170 [mac80211]
    [] tasklet_action+0x3e/0x65

    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     
  • A user reported warnings in ath5k due to transmitting frames with no
    rates set up. The frames were Mesh PERR frames, and some debugging
    showed an empty control block with just the vif pointer:

    > [ 562.522682] XXX txinfo: 00000000: 00 00 00 00 00 00 00 00 00 00 00
    > 00 00 00 00 00 ................
    > [ 562.522688] XXX txinfo: 00000010: 00 00 00 00 00 00 00 00 54 b8 f2
    > db 00 00 00 00 ........T.......
    > [ 562.522693] XXX txinfo: 00000020: 00 00 00 00 00 00 00 00 00 00 00
    > 00 00 00 00 00 ................

    Set the IEEE80211_TX_INTFL_NEED_TXPROCESSING flag to ensure that
    rate control gets run before the frame is sent.

    Signed-off-by: Bob Copeland
    Signed-off-by: Johannes Berg

    Bob Copeland
     

04 Jan, 2013

1 commit


20 Aug, 2012

1 commit

  • Use skb_queue_walk_safe instead, and fix a few issues:

    - didn't free old skbs on moving
    - didn't react to failed skb alloc
    - needlessly held a local pointer to the destination frame queue
    - didn't check destination queue length before adding skb

    Signed-off-by: Thomas Pedersen
    Signed-off-by: Johannes Berg

    Thomas Pedersen
     

11 Jul, 2012

1 commit