Commit 3d1a5bbf authored by Andrew Zaborowski's avatar Andrew Zaborowski Committed by Johannes Berg

nl80211: Emit a SET_INTERFACE on iftype change

Let userspace learn about iftype changes by sending a notification
when handling the NL80211_CMD_SET_INTERFACE command.  There seems
to be no other place where the iftype can change: nl80211_set_interface
is the only caller of cfg80211_change_iface which is the only caller of
ops->change_virtual_intf.
Signed-off-by: default avatarAndrew Zaborowski <andrew.zaborowski@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent c90b670b
...@@ -2977,14 +2977,15 @@ static int nl80211_send_chandef(struct sk_buff *msg, ...@@ -2977,14 +2977,15 @@ static int nl80211_send_chandef(struct sk_buff *msg,
static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags, static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags,
struct cfg80211_registered_device *rdev, struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev, bool removal) struct wireless_dev *wdev,
enum nl80211_commands cmd)
{ {
struct net_device *dev = wdev->netdev; struct net_device *dev = wdev->netdev;
u8 cmd = NL80211_CMD_NEW_INTERFACE;
void *hdr; void *hdr;
if (removal) WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE &&
cmd = NL80211_CMD_DEL_INTERFACE; cmd != NL80211_CMD_DEL_INTERFACE &&
cmd != NL80211_CMD_SET_INTERFACE);
hdr = nl80211hdr_put(msg, portid, seq, flags, cmd); hdr = nl80211hdr_put(msg, portid, seq, flags, cmd);
if (!hdr) if (!hdr)
...@@ -3132,7 +3133,8 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * ...@@ -3132,7 +3133,8 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
} }
if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid, if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh->nlmsg_seq, NLM_F_MULTI,
rdev, wdev, false) < 0) { rdev, wdev,
NL80211_CMD_NEW_INTERFACE) < 0) {
goto out; goto out;
} }
if_idx++; if_idx++;
...@@ -3162,7 +3164,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -3162,7 +3164,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
return -ENOMEM; return -ENOMEM;
if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0,
rdev, wdev, false) < 0) { rdev, wdev, NL80211_CMD_NEW_INTERFACE) < 0) {
nlmsg_free(msg); nlmsg_free(msg);
return -ENOBUFS; return -ENOBUFS;
} }
...@@ -3352,6 +3354,12 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -3352,6 +3354,12 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
if (!err && params.use_4addr != -1) if (!err && params.use_4addr != -1)
dev->ieee80211_ptr->use_4addr = params.use_4addr; dev->ieee80211_ptr->use_4addr = params.use_4addr;
if (change && !err) {
struct wireless_dev *wdev = dev->ieee80211_ptr;
nl80211_notify_iface(rdev, wdev, NL80211_CMD_SET_INTERFACE);
}
return err; return err;
} }
...@@ -3443,7 +3451,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -3443,7 +3451,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
} }
if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0, if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0,
rdev, wdev, false) < 0) { rdev, wdev, NL80211_CMD_NEW_INTERFACE) < 0) {
nlmsg_free(msg); nlmsg_free(msg);
return -ENOBUFS; return -ENOBUFS;
} }
...@@ -14097,15 +14105,11 @@ void nl80211_notify_iface(struct cfg80211_registered_device *rdev, ...@@ -14097,15 +14105,11 @@ void nl80211_notify_iface(struct cfg80211_registered_device *rdev,
{ {
struct sk_buff *msg; struct sk_buff *msg;
WARN_ON(cmd != NL80211_CMD_NEW_INTERFACE &&
cmd != NL80211_CMD_DEL_INTERFACE);
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) if (!msg)
return; return;
if (nl80211_send_iface(msg, 0, 0, 0, rdev, wdev, if (nl80211_send_iface(msg, 0, 0, 0, rdev, wdev, cmd) < 0) {
cmd == NL80211_CMD_DEL_INTERFACE) < 0) {
nlmsg_free(msg); nlmsg_free(msg);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment