aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2015-08-13 13:03:23 (GMT)
committerJouni Malinen <j@w1.fi>2015-08-28 09:49:17 (GMT)
commitf429ec443f4166c747fbf31944f05b51fffbc735 (patch)
tree649dc32be8aec2125b5bb51656b409c16f03f3bb /src
parent80bb38742c7d319aa15dfda4485345d27b3b4281 (diff)
downloadhostap-f429ec443f4166c747fbf31944f05b51fffbc735.zip
hostap-f429ec443f4166c747fbf31944f05b51fffbc735.tar.gz
hostap-f429ec443f4166c747fbf31944f05b51fffbc735.tar.bz2
nl80211: Use nla_put_nested() to set NL80211_ATTR_MAC_ADDRS
This allows an empty nested list (i.e., no MAC addresses) to be included in the NL80211_CMD_SET_MAC_ACL message unlike with nla_nest_start()/nla_nest_end() where the current libnl implementation removes the "empty" attribute and causes cfg80211 to reject the command. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/driver_nl80211.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 96eb90b..00b173f 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3258,7 +3258,7 @@ static int wpa_driver_nl80211_set_acl(void *priv,
struct i802_bss *bss = priv;
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
- struct nlattr *acl;
+ struct nl_msg *acl;
unsigned int i;
int ret;
@@ -3271,23 +3271,26 @@ static int wpa_driver_nl80211_set_acl(void *priv,
wpa_printf(MSG_DEBUG, "nl80211: Set %s ACL (num_mac_acl=%u)",
params->acl_policy ? "Accept" : "Deny", params->num_mac_acl);
+ acl = nlmsg_alloc();
+ if (!acl)
+ return -ENOMEM;
+ for (i = 0; i < params->num_mac_acl; i++) {
+ if (nla_put(acl, i + 1, ETH_ALEN, params->mac_acl[i].addr)) {
+ nlmsg_free(acl);
+ return -ENOMEM;
+ }
+ }
+
if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_SET_MAC_ACL)) ||
nla_put_u32(msg, NL80211_ATTR_ACL_POLICY, params->acl_policy ?
NL80211_ACL_POLICY_DENY_UNLESS_LISTED :
NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED) ||
- (acl = nla_nest_start(msg, NL80211_ATTR_MAC_ADDRS)) == NULL) {
+ nla_put_nested(msg, NL80211_ATTR_MAC_ADDRS, acl)) {
nlmsg_free(msg);
+ nlmsg_free(acl);
return -ENOMEM;
}
-
- for (i = 0; i < params->num_mac_acl; i++) {
- if (nla_put(msg, i + 1, ETH_ALEN, params->mac_acl[i].addr)) {
- nlmsg_free(msg);
- return -ENOMEM;
- }
- }
-
- nla_nest_end(msg, acl);
+ nlmsg_free(acl);
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
if (ret) {