[v2] mac80211: mesh: add mesh_param "mesh_nolearn" to skip path discovery

Message ID 20200616103911.20501-1-linus.luessing@c0d3.blue (mailing list archive)
State Not Applicable, archived
Delegated to: Simon Wunderlich
Headers
Series [v2] mac80211: mesh: add mesh_param "mesh_nolearn" to skip path discovery |

Commit Message

Linus Lüssing June 16, 2020, 10:39 a.m. UTC
  From: Linus Lüssing <ll@simonwunderlich.de>

Currently, before being able to forward a packet between two 802.11s
nodes, both a PLINK handshake is performed upon receiving a beacon and
then later a PREQ/PREP exchange for path discovery is performed on
demand upon receiving a data frame to forward.

When running a mesh protocol on top of an 802.11s interface, like
batman-adv, we do not need the multi-hop mesh routing capabilities of
802.11s and usually set mesh_fwding=0. However, even with mesh_fwding=0
the PREQ/PREP path discovery is still performed on demand. Even though
in this scenario the next hop PREQ/PREP will determine is always the
direct 11s neighbor node.

The new mesh_nolearn parameter allows to skip the PREQ/PREP exchange in
this scenario, leading to a reduced delay, reduced packet buffering and
simplifies HWMP in general.

mesh_nolearn is still rather conservative in that if the packet destination
is not a direct 11s neighbor, it will fall back to PREQ/PREP path
discovery.

For normal, multi-hop 802.11s mesh routing it is usually not advisable
to enable mesh_nolearn as a transmission to a direct but distant neighbor
might be worse than reaching that same node via a more robust /
higher throughput etc. multi-hop path.

Cc: Sven Eckelmann <sven@narfation.org>
Cc: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Linus Lüssing <ll@simonwunderlich.de>
---

Changelog v2:
* moved nolearn lookup closer into the actual nexthop_lookup function,
  so that the nolearn feature is not confusingly avoided on
  forwarded frames

 include/net/cfg80211.h        |  6 ++++++
 include/uapi/linux/nl80211.h  |  7 +++++++
 net/mac80211/cfg.c            |  2 ++
 net/mac80211/debugfs_netdev.c |  2 ++
 net/mac80211/mesh_hwmp.c      | 39 +++++++++++++++++++++++++++++++++++
 net/wireless/mesh.c           |  1 +
 net/wireless/nl80211.c        |  8 ++++++-
 net/wireless/trace.h          |  4 +++-
 8 files changed, 67 insertions(+), 2 deletions(-)
  

Comments

kernel test robot June 16, 2020, 5:41 p.m. UTC | #1
Hi "Linus,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211-next/master]
[also build test ERROR on mac80211/master v5.8-rc1 next-20200616]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-L-ssing/mac80211-mesh-add-mesh_param-mesh_nolearn-to-skip-path-discovery/20200616-183953
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 487ca07fcc75d52755c9fe2ee05bcb3b6eeeec44)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> net/wireless/nl80211.c:7100:13: error: too many arguments provided to function-like macro invocation
mask, NL80211_MESHCONF_NOLEARN,
^
net/wireless/nl80211.c:6972:9: note: macro 'FILL_IN_MESH_PARAM_IF_SET' defined here
#define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, mask, attr, fn)                  ^
>> net/wireless/nl80211.c:7099:2: error: use of undeclared identifier 'FILL_IN_MESH_PARAM_IF_SET'
FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
^
2 errors generated.

vim +7100 net/wireless/nl80211.c

  6979	
  6980		if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
  6981			return -EINVAL;
  6982		if (nla_parse_nested_deprecated(tb, NL80211_MESHCONF_ATTR_MAX, info->attrs[NL80211_ATTR_MESH_CONFIG], nl80211_meshconf_params_policy, info->extack))
  6983			return -EINVAL;
  6984	
  6985		/* This makes sure that there aren't more than 32 mesh config
  6986		 * parameters (otherwise our bitfield scheme would not work.) */
  6987		BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
  6988	
  6989		/* Fill in the params struct */
  6990		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, mask,
  6991					  NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
  6992		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, mask,
  6993					  NL80211_MESHCONF_CONFIRM_TIMEOUT,
  6994					  nla_get_u16);
  6995		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, mask,
  6996					  NL80211_MESHCONF_HOLDING_TIMEOUT,
  6997					  nla_get_u16);
  6998		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, mask,
  6999					  NL80211_MESHCONF_MAX_PEER_LINKS,
  7000					  nla_get_u16);
  7001		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, mask,
  7002					  NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
  7003		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, mask,
  7004					  NL80211_MESHCONF_TTL, nla_get_u8);
  7005		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, mask,
  7006					  NL80211_MESHCONF_ELEMENT_TTL, nla_get_u8);
  7007		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, mask,
  7008					  NL80211_MESHCONF_AUTO_OPEN_PLINKS,
  7009					  nla_get_u8);
  7010		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor,
  7011					  mask,
  7012					  NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
  7013					  nla_get_u32);
  7014		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, mask,
  7015					  NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
  7016					  nla_get_u8);
  7017		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, mask,
  7018					  NL80211_MESHCONF_PATH_REFRESH_TIME,
  7019					  nla_get_u32);
  7020		if (mask & BIT(NL80211_MESHCONF_PATH_REFRESH_TIME) &&
  7021		    (cfg->path_refresh_time < 1 || cfg->path_refresh_time > 65535))
  7022			return -EINVAL;
  7023		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, mask,
  7024					  NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
  7025					  nla_get_u16);
  7026		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
  7027					  mask,
  7028					  NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
  7029					  nla_get_u32);
  7030		if (mask & BIT(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT) &&
  7031		    (cfg->dot11MeshHWMPactivePathTimeout < 1 ||
  7032		     cfg->dot11MeshHWMPactivePathTimeout > 65535))
  7033			return -EINVAL;
  7034		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, mask,
  7035					  NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
  7036					  nla_get_u16);
  7037		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, mask,
  7038					  NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
  7039					  nla_get_u16);
  7040		FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
  7041					  dot11MeshHWMPnetDiameterTraversalTime, mask,
  7042					  NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
  7043					  nla_get_u16);
  7044		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask,
  7045					  NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8);
  7046		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask,
  7047					  NL80211_MESHCONF_HWMP_RANN_INTERVAL,
  7048					  nla_get_u16);
  7049		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshGateAnnouncementProtocol,
  7050					  mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
  7051					  nla_get_u8);
  7052		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, mask,
  7053					  NL80211_MESHCONF_FORWARDING, nla_get_u8);
  7054		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, mask,
  7055					  NL80211_MESHCONF_RSSI_THRESHOLD,
  7056					  nla_get_s32);
  7057		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConnectedToMeshGate, mask,
  7058					  NL80211_MESHCONF_CONNECTED_TO_GATE,
  7059					  nla_get_u8);
  7060		/*
  7061		 * Check HT operation mode based on
  7062		 * IEEE 802.11-2016 9.4.2.57 HT Operation element.
  7063		 */
  7064		if (tb[NL80211_MESHCONF_HT_OPMODE]) {
  7065			ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
  7066	
  7067			if (ht_opmode & ~(IEEE80211_HT_OP_MODE_PROTECTION |
  7068					  IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
  7069					  IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
  7070				return -EINVAL;
  7071	
  7072			/* NON_HT_STA bit is reserved, but some programs set it */
  7073			ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
  7074	
  7075			cfg->ht_opmode = ht_opmode;
  7076			mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
  7077		}
  7078		FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
  7079					  dot11MeshHWMPactivePathToRootTimeout, mask,
  7080					  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
  7081					  nla_get_u32);
  7082		if (mask & BIT(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT) &&
  7083		    (cfg->dot11MeshHWMPactivePathToRootTimeout < 1 ||
  7084		     cfg->dot11MeshHWMPactivePathToRootTimeout > 65535))
  7085			return -EINVAL;
  7086		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, mask,
  7087					  NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
  7088					  nla_get_u16);
  7089		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPconfirmationInterval,
  7090					  mask,
  7091					  NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
  7092					  nla_get_u16);
  7093		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, power_mode, mask,
  7094					  NL80211_MESHCONF_POWER_MODE, nla_get_u32);
  7095		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration, mask,
  7096					  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
  7097		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, mask,
  7098					  NL80211_MESHCONF_PLINK_TIMEOUT, nla_get_u32);
> 7099		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
> 7100					  mask, NL80211_MESHCONF_NOLEARN,
  7101					  nl80211_check_bool);
  7102		if (mask_out)
  7103			*mask_out = mask;
  7104	
  7105		return 0;
  7106	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
  
kernel test robot June 16, 2020, 9:23 p.m. UTC | #2
Hi "Linus,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on mac80211-next/master]
[also build test ERROR on mac80211/master v5.8-rc1 next-20200616]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-L-ssing/mac80211-mesh-add-mesh_param-mesh_nolearn-to-skip-path-discovery/20200616-183953
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: i386-debian-10.3 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce (this is a W=1 build):
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

net/wireless/nl80211.c: In function 'nl80211_parse_mesh_config':
>> net/wireless/nl80211.c:7101:25: error: macro "FILL_IN_MESH_PARAM_IF_SET" passed 8 arguments, but takes just 6
7101 |       nl80211_check_bool);
|                         ^
net/wireless/nl80211.c:6972: note: macro "FILL_IN_MESH_PARAM_IF_SET" defined here
6972 | #define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, mask, attr, fn)          |
>> net/wireless/nl80211.c:7099:2: error: 'FILL_IN_MESH_PARAM_IF_SET' undeclared (first use in this function)
7099 |  FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
|  ^~~~~~~~~~~~~~~~~~~~~~~~~
net/wireless/nl80211.c:7099:2: note: each undeclared identifier is reported only once for each function it appears in

vim +/FILL_IN_MESH_PARAM_IF_SET +7101 net/wireless/nl80211.c

  6979	
  6980		if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
  6981			return -EINVAL;
  6982		if (nla_parse_nested_deprecated(tb, NL80211_MESHCONF_ATTR_MAX, info->attrs[NL80211_ATTR_MESH_CONFIG], nl80211_meshconf_params_policy, info->extack))
  6983			return -EINVAL;
  6984	
  6985		/* This makes sure that there aren't more than 32 mesh config
  6986		 * parameters (otherwise our bitfield scheme would not work.) */
  6987		BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
  6988	
  6989		/* Fill in the params struct */
  6990		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, mask,
  6991					  NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
  6992		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, mask,
  6993					  NL80211_MESHCONF_CONFIRM_TIMEOUT,
  6994					  nla_get_u16);
  6995		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, mask,
  6996					  NL80211_MESHCONF_HOLDING_TIMEOUT,
  6997					  nla_get_u16);
  6998		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, mask,
  6999					  NL80211_MESHCONF_MAX_PEER_LINKS,
  7000					  nla_get_u16);
  7001		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, mask,
  7002					  NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
  7003		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, mask,
  7004					  NL80211_MESHCONF_TTL, nla_get_u8);
  7005		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, mask,
  7006					  NL80211_MESHCONF_ELEMENT_TTL, nla_get_u8);
  7007		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, mask,
  7008					  NL80211_MESHCONF_AUTO_OPEN_PLINKS,
  7009					  nla_get_u8);
  7010		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor,
  7011					  mask,
  7012					  NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
  7013					  nla_get_u32);
  7014		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, mask,
  7015					  NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
  7016					  nla_get_u8);
  7017		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, mask,
  7018					  NL80211_MESHCONF_PATH_REFRESH_TIME,
  7019					  nla_get_u32);
  7020		if (mask & BIT(NL80211_MESHCONF_PATH_REFRESH_TIME) &&
  7021		    (cfg->path_refresh_time < 1 || cfg->path_refresh_time > 65535))
  7022			return -EINVAL;
  7023		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, mask,
  7024					  NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
  7025					  nla_get_u16);
  7026		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
  7027					  mask,
  7028					  NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
  7029					  nla_get_u32);
  7030		if (mask & BIT(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT) &&
  7031		    (cfg->dot11MeshHWMPactivePathTimeout < 1 ||
  7032		     cfg->dot11MeshHWMPactivePathTimeout > 65535))
  7033			return -EINVAL;
  7034		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, mask,
  7035					  NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
  7036					  nla_get_u16);
  7037		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, mask,
  7038					  NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
  7039					  nla_get_u16);
  7040		FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
  7041					  dot11MeshHWMPnetDiameterTraversalTime, mask,
  7042					  NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
  7043					  nla_get_u16);
  7044		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask,
  7045					  NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8);
  7046		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask,
  7047					  NL80211_MESHCONF_HWMP_RANN_INTERVAL,
  7048					  nla_get_u16);
  7049		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshGateAnnouncementProtocol,
  7050					  mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
  7051					  nla_get_u8);
  7052		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, mask,
  7053					  NL80211_MESHCONF_FORWARDING, nla_get_u8);
  7054		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, mask,
  7055					  NL80211_MESHCONF_RSSI_THRESHOLD,
  7056					  nla_get_s32);
  7057		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConnectedToMeshGate, mask,
  7058					  NL80211_MESHCONF_CONNECTED_TO_GATE,
  7059					  nla_get_u8);
  7060		/*
  7061		 * Check HT operation mode based on
  7062		 * IEEE 802.11-2016 9.4.2.57 HT Operation element.
  7063		 */
  7064		if (tb[NL80211_MESHCONF_HT_OPMODE]) {
  7065			ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
  7066	
  7067			if (ht_opmode & ~(IEEE80211_HT_OP_MODE_PROTECTION |
  7068					  IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
  7069					  IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
  7070				return -EINVAL;
  7071	
  7072			/* NON_HT_STA bit is reserved, but some programs set it */
  7073			ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
  7074	
  7075			cfg->ht_opmode = ht_opmode;
  7076			mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
  7077		}
  7078		FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
  7079					  dot11MeshHWMPactivePathToRootTimeout, mask,
  7080					  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
  7081					  nla_get_u32);
  7082		if (mask & BIT(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT) &&
  7083		    (cfg->dot11MeshHWMPactivePathToRootTimeout < 1 ||
  7084		     cfg->dot11MeshHWMPactivePathToRootTimeout > 65535))
  7085			return -EINVAL;
  7086		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, mask,
  7087					  NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
  7088					  nla_get_u16);
  7089		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPconfirmationInterval,
  7090					  mask,
  7091					  NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
  7092					  nla_get_u16);
  7093		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, power_mode, mask,
  7094					  NL80211_MESHCONF_POWER_MODE, nla_get_u32);
  7095		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration, mask,
  7096					  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
  7097		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, mask,
  7098					  NL80211_MESHCONF_PLINK_TIMEOUT, nla_get_u32);
> 7099		FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
  7100					  mask, NL80211_MESHCONF_NOLEARN,
> 7101					  nl80211_check_bool);
  7102		if (mask_out)
  7103			*mask_out = mask;
  7104	
  7105		return 0;
  7106	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
  
kernel test robot June 17, 2020, 1:27 p.m. UTC | #3
Hi "Linus,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on mac80211/master v5.8-rc1 next-20200616]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Linus-L-ssing/mac80211-mesh-add-mesh_param-mesh_nolearn-to-skip-path-discovery/20200616-183953
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
config: arm64-randconfig-s031-20200615 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-rc1-3-g55607964-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 ARCH=arm64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> net/wireless/nl80211.c:7099:9: sparse: sparse: macro "FILL_IN_MESH_PARAM_IF_SET" passed 8 arguments, but takes just 6
   net/wireless/nl80211.c:7099:9: sparse: sparse: undefined identifier 'FILL_IN_MESH_PARAM_IF_SET'

# https://github.com/0day-ci/linux/commit/d86bcd2b4a9457a527e9c5dd610ad12c07d386a4
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout d86bcd2b4a9457a527e9c5dd610ad12c07d386a4
vim +/FILL_IN_MESH_PARAM_IF_SET +7099 net/wireless/nl80211.c

bd90fdcc5fbd99 Johannes Berg     2010-12-03  6979  
24bdd9f4c9af75 Javier Cardona    2010-12-16  6980  	if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6981  		return -EINVAL;
8cb081746c031f Johannes Berg     2019-04-26  6982  	if (nla_parse_nested_deprecated(tb, NL80211_MESHCONF_ATTR_MAX, info->attrs[NL80211_ATTR_MESH_CONFIG], nl80211_meshconf_params_policy, info->extack))
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6983  		return -EINVAL;
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6984  
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6985  	/* This makes sure that there aren't more than 32 mesh config
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6986  	 * parameters (otherwise our bitfield scheme would not work.) */
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6987  	BUILD_BUG_ON(NL80211_MESHCONF_ATTR_MAX > 32);
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6988  
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  6989  	/* Fill in the params struct */
ab0d76f6823cc3 Johannes Berg     2018-10-02  6990  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshRetryTimeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6991  				  NL80211_MESHCONF_RETRY_TIMEOUT, nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  6992  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConfirmTimeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6993  				  NL80211_MESHCONF_CONFIRM_TIMEOUT,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6994  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  6995  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHoldingTimeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6996  				  NL80211_MESHCONF_HOLDING_TIMEOUT,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6997  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  6998  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxPeerLinks, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  6999  				  NL80211_MESHCONF_MAX_PEER_LINKS,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7000  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7001  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshMaxRetries, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7002  				  NL80211_MESHCONF_MAX_RETRIES, nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7003  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshTTL, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7004  				  NL80211_MESHCONF_TTL, nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7005  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, element_ttl, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7006  				  NL80211_MESHCONF_ELEMENT_TTL, nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7007  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, auto_open_plinks, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7008  				  NL80211_MESHCONF_AUTO_OPEN_PLINKS,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7009  				  nla_get_u8);
ea54fba20985b7 Marco Porsch      2013-01-07  7010  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNbrOffsetMaxNeighbor,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7011  				  mask,
a4f606ea73d56d Chun-Yeow Yeoh    2012-06-11  7012  				  NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7013  				  nla_get_u32);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7014  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPmaxPREQretries, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7015  				  NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7016  				  nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7017  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, path_refresh_time, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7018  				  NL80211_MESHCONF_PATH_REFRESH_TIME,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7019  				  nla_get_u32);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7020  	if (mask & BIT(NL80211_MESHCONF_PATH_REFRESH_TIME) &&
ab0d76f6823cc3 Johannes Berg     2018-10-02  7021  	    (cfg->path_refresh_time < 1 || cfg->path_refresh_time > 65535))
ab0d76f6823cc3 Johannes Berg     2018-10-02  7022  		return -EINVAL;
ab0d76f6823cc3 Johannes Berg     2018-10-02  7023  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, min_discovery_timeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7024  				  NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7025  				  nla_get_u16);
ea54fba20985b7 Marco Porsch      2013-01-07  7026  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathTimeout,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7027  				  mask,
a4f606ea73d56d Chun-Yeow Yeoh    2012-06-11  7028  				  NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7029  				  nla_get_u32);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7030  	if (mask & BIT(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT) &&
ab0d76f6823cc3 Johannes Berg     2018-10-02  7031  	    (cfg->dot11MeshHWMPactivePathTimeout < 1 ||
ab0d76f6823cc3 Johannes Berg     2018-10-02  7032  	     cfg->dot11MeshHWMPactivePathTimeout > 65535))
ab0d76f6823cc3 Johannes Berg     2018-10-02  7033  		return -EINVAL;
ab0d76f6823cc3 Johannes Berg     2018-10-02  7034  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPpreqMinInterval, mask,
ea54fba20985b7 Marco Porsch      2013-01-07  7035  				  NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7036  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7037  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPperrMinInterval, mask,
ea54fba20985b7 Marco Porsch      2013-01-07  7038  				  NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7039  				  nla_get_u16);
93da9cc17c5ae8 colin@cozybit.com 2008-10-21  7040  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7041  				  dot11MeshHWMPnetDiameterTraversalTime, mask,
a4f606ea73d56d Chun-Yeow Yeoh    2012-06-11  7042  				  NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7043  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7044  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRootMode, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7045  				  NL80211_MESHCONF_HWMP_ROOTMODE, nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7046  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPRannInterval, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7047  				  NL80211_MESHCONF_HWMP_RANN_INTERVAL,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7048  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7049  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshGateAnnouncementProtocol,
ea54fba20985b7 Marco Porsch      2013-01-07  7050  				  mask, NL80211_MESHCONF_GATE_ANNOUNCEMENTS,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7051  				  nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7052  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshForwarding, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7053  				  NL80211_MESHCONF_FORWARDING, nla_get_u8);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7054  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7055  				  NL80211_MESHCONF_RSSI_THRESHOLD,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7056  				  nla_get_s32);
01d66fbd5b18ac Bob Copeland      2018-10-25  7057  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshConnectedToMeshGate, mask,
01d66fbd5b18ac Bob Copeland      2018-10-25  7058  				  NL80211_MESHCONF_CONNECTED_TO_GATE,
01d66fbd5b18ac Bob Copeland      2018-10-25  7059  				  nla_get_u8);
9757235f451c27 Masashi Honma     2016-08-03  7060  	/*
9757235f451c27 Masashi Honma     2016-08-03  7061  	 * Check HT operation mode based on
188f60ab8e787f Bob Copeland      2018-06-24  7062  	 * IEEE 802.11-2016 9.4.2.57 HT Operation element.
9757235f451c27 Masashi Honma     2016-08-03  7063  	 */
9757235f451c27 Masashi Honma     2016-08-03  7064  	if (tb[NL80211_MESHCONF_HT_OPMODE]) {
9757235f451c27 Masashi Honma     2016-08-03  7065  		ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]);
9757235f451c27 Masashi Honma     2016-08-03  7066  
9757235f451c27 Masashi Honma     2016-08-03  7067  		if (ht_opmode & ~(IEEE80211_HT_OP_MODE_PROTECTION |
9757235f451c27 Masashi Honma     2016-08-03  7068  				  IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT |
9757235f451c27 Masashi Honma     2016-08-03  7069  				  IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))
9757235f451c27 Masashi Honma     2016-08-03  7070  			return -EINVAL;
9757235f451c27 Masashi Honma     2016-08-03  7071  
188f60ab8e787f Bob Copeland      2018-06-24  7072  		/* NON_HT_STA bit is reserved, but some programs set it */
188f60ab8e787f Bob Copeland      2018-06-24  7073  		ht_opmode &= ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
9757235f451c27 Masashi Honma     2016-08-03  7074  
9757235f451c27 Masashi Honma     2016-08-03  7075  		cfg->ht_opmode = ht_opmode;
fd551bac479585 Masashi Honma     2017-01-26  7076  		mask |= (1 << (NL80211_MESHCONF_HT_OPMODE - 1));
9757235f451c27 Masashi Honma     2016-08-03  7077  	}
728b19e5fb9bbe Chun-Yeow Yeoh    2012-06-14  7078  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7079  				  dot11MeshHWMPactivePathToRootTimeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7080  				  NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7081  				  nla_get_u32);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7082  	if (mask & BIT(NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT) &&
ab0d76f6823cc3 Johannes Berg     2018-10-02  7083  	    (cfg->dot11MeshHWMPactivePathToRootTimeout < 1 ||
ab0d76f6823cc3 Johannes Berg     2018-10-02  7084  	     cfg->dot11MeshHWMPactivePathToRootTimeout > 65535))
ab0d76f6823cc3 Johannes Berg     2018-10-02  7085  		return -EINVAL;
ab0d76f6823cc3 Johannes Berg     2018-10-02  7086  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMProotInterval, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7087  				  NL80211_MESHCONF_HWMP_ROOT_INTERVAL,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7088  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7089  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPconfirmationInterval,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7090  				  mask,
728b19e5fb9bbe Chun-Yeow Yeoh    2012-06-14  7091  				  NL80211_MESHCONF_HWMP_CONFIRMATION_INTERVAL,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7092  				  nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7093  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, power_mode, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7094  				  NL80211_MESHCONF_POWER_MODE, nla_get_u32);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7095  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshAwakeWindowDuration, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7096  				  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
ab0d76f6823cc3 Johannes Berg     2018-10-02  7097  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, mask,
ab0d76f6823cc3 Johannes Berg     2018-10-02  7098  				  NL80211_MESHCONF_PLINK_TIMEOUT, nla_get_u32);
d86bcd2b4a9457 Linus Lüssing     2020-06-16 @7099  	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
d86bcd2b4a9457 Linus Lüssing     2020-06-16  7100  				  mask, NL80211_MESHCONF_NOLEARN,
d86bcd2b4a9457 Linus Lüssing     2020-06-16  7101  				  nl80211_check_bool);
bd90fdcc5fbd99 Johannes Berg     2010-12-03  7102  	if (mask_out)
bd90fdcc5fbd99 Johannes Berg     2010-12-03  7103  		*mask_out = mask;
c80d545da3f7c0 Javier Cardona    2010-12-16  7104  
bd90fdcc5fbd99 Johannes Berg     2010-12-03  7105  	return 0;
bd90fdcc5fbd99 Johannes Berg     2010-12-03  7106  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
  

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fc7e8807838d..5ffb35592a23 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1853,6 +1853,11 @@  struct bss_parameters {
  *      connected to a mesh gate in mesh formation info.  If false, the
  *      value in mesh formation is determined by the presence of root paths
  *      in the mesh path table
+ * @dot11MeshNolearn: Try to avoid multi-hop path discovery (e.g. PREQ/PREP
+ *      for HWMP) if the destination is a direct neighbor. Note that this might
+ *      not be the optimal decision as a multi-hop route might be better. So
+ *      if using this setting you will likely also want to disable
+ *      dot11MeshForwarding and use another mesh routing protocol on top.
  */
 struct mesh_config {
 	u16 dot11MeshRetryTimeout;
@@ -1884,6 +1889,7 @@  struct mesh_config {
 	enum nl80211_mesh_power_mode power_mode;
 	u16 dot11MeshAwakeWindowDuration;
 	u32 plink_timeout;
+	bool dot11MeshNolearn;
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 4e6339ab1fce..f6560bb9644c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4236,6 +4236,12 @@  enum nl80211_mesh_power_mode {
  *	field.  If left unset then the mesh formation field will only
  *	advertise such if there is an active root mesh path.
  *
+ * @NL80211_MESHCONF_NOLEARN: Try to avoid multi-hop path discovery (e.g.
+ *      PREQ/PREP for HWMP) if the destination is a direct neighbor. Note that
+ *      this might not be the optimal decision as a multi-hop route might be
+ *      better. So if using this setting you will likely also want to disable
+ *      dot11MeshForwarding and use another mesh routing protocol on top.
+ *
  * @__NL80211_MESHCONF_ATTR_AFTER_LAST: internal use
  */
 enum nl80211_meshconf_params {
@@ -4269,6 +4275,7 @@  enum nl80211_meshconf_params {
 	NL80211_MESHCONF_AWAKE_WINDOW,
 	NL80211_MESHCONF_PLINK_TIMEOUT,
 	NL80211_MESHCONF_CONNECTED_TO_GATE,
+	NL80211_MESHCONF_NOLEARN,
 
 	/* keep last */
 	__NL80211_MESHCONF_ATTR_AFTER_LAST,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9b360544ad6f..f48e095e912a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2126,6 +2126,8 @@  static int ieee80211_update_mesh_config(struct wiphy *wiphy,
 	if (_chg_mesh_attr(NL80211_MESHCONF_CONNECTED_TO_GATE, mask))
 		conf->dot11MeshConnectedToMeshGate =
 			nconf->dot11MeshConnectedToMeshGate;
+	if (_chg_mesh_attr(NL80211_MESHCONF_NOLEARN, mask))
+		conf->dot11MeshNolearn = nconf->dot11MeshNolearn;
 	ieee80211_mbss_info_change_notify(sdata, BSS_CHANGED_BEACON);
 	return 0;
 }
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index d7e955127d5c..09eab2c3f380 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -638,6 +638,7 @@  IEEE80211_IF_FILE(dot11MeshAwakeWindowDuration,
 		  u.mesh.mshcfg.dot11MeshAwakeWindowDuration, DEC);
 IEEE80211_IF_FILE(dot11MeshConnectedToMeshGate,
 		  u.mesh.mshcfg.dot11MeshConnectedToMeshGate, DEC);
+IEEE80211_IF_FILE(dot11MeshNolearn, u.mesh.mshcfg.dot11MeshNolearn, DEC);
 #endif
 
 #define DEBUGFS_ADD_MODE(name, mode) \
@@ -762,6 +763,7 @@  static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
 	MESHPARAMS_ADD(power_mode);
 	MESHPARAMS_ADD(dot11MeshAwakeWindowDuration);
 	MESHPARAMS_ADD(dot11MeshConnectedToMeshGate);
+	MESHPARAMS_ADD(dot11MeshNolearn);
 #undef MESHPARAMS_ADD
 }
 #endif
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index aa5150929996..615db30b765a 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -1175,6 +1175,40 @@  int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
 	return -ENOENT;
 }
 
+/**
+ * mesh_nexthop_lookup_nolearn - try to set next hop without path discovery
+ * @skb: 802.11 frame to be sent
+ * @sdata: network subif the frame will be sent through
+ *
+ * Check if the meshDA (addr3) of a unicast frame is a direct neighbor.
+ * And if so, set the RA (addr1) to it to transmit to this node directly,
+ * avoiding PREP/PREP path discovery.
+ *
+ * Returns: 0 if the next hop was found and -ENOENT otherwise.
+ */
+static int mesh_nexthop_lookup_nolearn(struct ieee80211_sub_if_data *sdata,
+				       struct sk_buff *skb)
+{
+	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+	struct sta_info *sta;
+
+	if (is_multicast_ether_addr(hdr->addr1))
+		return -ENOENT;
+
+	rcu_read_lock();
+	sta = sta_info_get(sdata, hdr->addr3);
+
+	if (!sta || sta->mesh->plink_state != NL80211_PLINK_ESTAB) {
+		rcu_read_unlock();
+		return -ENOENT;
+	}
+	rcu_read_unlock();
+
+	memcpy(hdr->addr1, hdr->addr3, ETH_ALEN);
+	memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
+	return 0;
+}
+
 /**
  * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame. Calling
  * this function is considered "using" the associated mpath, so preempt a path
@@ -1188,11 +1222,16 @@  int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
 int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata,
 			struct sk_buff *skb)
 {
+	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 	struct mesh_path *mpath;
 	struct sta_info *next_hop;
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
 	u8 *target_addr = hdr->addr3;
 
+	if (ifmsh->mshcfg.dot11MeshNolearn &&
+	    !mesh_nexthop_lookup_nolearn(sdata, skb))
+		return 0;
+
 	mpath = mesh_path_lookup(sdata, target_addr);
 	if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE))
 		return -ENOENT;
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c
index eac5aa1419fc..e4e363138279 100644
--- a/net/wireless/mesh.c
+++ b/net/wireless/mesh.c
@@ -78,6 +78,7 @@  const struct mesh_config default_mesh_config = {
 	.power_mode = NL80211_MESH_POWER_ACTIVE,
 	.dot11MeshAwakeWindowDuration = MESH_DEFAULT_AWAKE_WINDOW,
 	.plink_timeout = MESH_DEFAULT_PLINK_TIMEOUT,
+	.dot11MeshNolearn = false,
 };
 
 const struct mesh_setup default_mesh_setup = {
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 263ae395ad44..b0b7f110064f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6884,7 +6884,9 @@  static int nl80211_get_mesh_config(struct sk_buff *skb,
 	    nla_put_u32(msg, NL80211_MESHCONF_PLINK_TIMEOUT,
 			cur_params.plink_timeout) ||
 	    nla_put_u8(msg, NL80211_MESHCONF_CONNECTED_TO_GATE,
-		       cur_params.dot11MeshConnectedToMeshGate))
+		       cur_params.dot11MeshConnectedToMeshGate) ||
+	    nla_put_u8(msg, NL80211_MESHCONF_NOLEARN,
+		       cur_params.dot11MeshNolearn))
 		goto nla_put_failure;
 	nla_nest_end(msg, pinfoattr);
 	genlmsg_end(msg, hdr);
@@ -6942,6 +6944,7 @@  nl80211_meshconf_params_policy[NL80211_MESHCONF_ATTR_MAX+1] = {
 	[NL80211_MESHCONF_AWAKE_WINDOW] = { .type = NLA_U16 },
 	[NL80211_MESHCONF_PLINK_TIMEOUT] = { .type = NLA_U32 },
 	[NL80211_MESHCONF_CONNECTED_TO_GATE] = NLA_POLICY_RANGE(NLA_U8, 0, 1),
+	[NL80211_MESHCONF_NOLEARN] = { .type = NLA_U8 },
 };
 
 static const struct nla_policy
@@ -7093,6 +7096,9 @@  do {									\
 				  NL80211_MESHCONF_AWAKE_WINDOW, nla_get_u16);
 	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, plink_timeout, mask,
 				  NL80211_MESHCONF_PLINK_TIMEOUT, nla_get_u32);
+	FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshNolearn, 0, 1,
+				  mask, NL80211_MESHCONF_NOLEARN,
+				  nl80211_check_bool);
 	if (mask_out)
 		*mask_out = mask;
 
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index b23cab016521..6e218a0acd4e 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -68,7 +68,8 @@ 
 		       __field(u16, ht_opmode)				   \
 		       __field(u32, dot11MeshHWMPactivePathToRootTimeout)  \
 		       __field(u16, dot11MeshHWMProotInterval)		   \
-		       __field(u16, dot11MeshHWMPconfirmationInterval)
+		       __field(u16, dot11MeshHWMPconfirmationInterval)	   \
+		       __field(bool, dot11MeshNolearn)
 #define MESH_CFG_ASSIGN							      \
 	do {								      \
 		__entry->dot11MeshRetryTimeout = conf->dot11MeshRetryTimeout; \
@@ -109,6 +110,7 @@ 
 				conf->dot11MeshHWMProotInterval;	      \
 		__entry->dot11MeshHWMPconfirmationInterval =		      \
 				conf->dot11MeshHWMPconfirmationInterval;      \
+		__entry->dot11MeshNolearn = conf->dot11MeshNolearn;	      \
 	} while (0)
 
 #define CHAN_ENTRY __field(enum nl80211_band, band) \