mac80211: mesh: factor out common plink close code

Reject and accepted close events always put the host in the
holding state and send a close frame to the peer.  Do this in
a single place to save some duplicated code.  Drop the reason
field from the caller as it is no longer needed.  Also, use the
sta->plid value instead of plid local since it is valid for
all close cases.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh: cleanup plink open when !matches_local

Drop the else from "if (x) { return; } else ... " and
remove the unnecessary llid assignment.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh: set matches_local more obviously

This change keeps the existing values for matches_local depending
on ftype, but moves the initialization closer to where it is used.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh_plink: group basic fitness checks

The initial frame checks differ depending on whether this is
a new peer or not, but they were all intermixed with sta checks
as necessary.  Group them together so the two cases are clearer.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh: rewrite rssi_threshold_check in C

Use C instead of cpp for type checking.  Also swap the arguments
into the usual sdata -> sta order.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh_plink: collapse the two switch statements together

The matches_local check can just be done when looking at the
individual action types.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: mesh_plink: don't ignore holding timer

The ignore_plink_timer flag is set when doing mod_timer() if
the timer was not previously active.  This is to avoid executing
the timeout if del_timer() was subsequently called.  However,
del_timer() only happens if we are moving to ESTAB state or
get a close frame while in HOLDING.

We cannot leave HOLDING and re-enter ESTAB unless we receive a
close frame (in which case ignore_plink_timer is already set) or
if the timeout expires, so there actually isn't a case where
this is needed on mod_timer().
mac80211: return -ENOMEM in mesh_plink_frame_tx

All other paths return an error code, do the same here.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: extract mesh estab code into a function

Removes some code duplication.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: hold sta->lock across plink fsm switch()

Rather than unlock at the end of each case, do it once after
all is said and done.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
mac80211: remove unused mesh_mgmt_ies_add() prototype

Said function was removed some time ago.

Signed-off-by: Bob Copeland <me@bobcopeland.com>