Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 171744
b: refs/heads/master
c: a043897
h: refs/heads/master
v: v3
  • Loading branch information
Holger Schurig authored and John W. Linville committed Nov 13, 2009
1 parent 9e484f8 commit 21f3393
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f273fe55e3f3f0b66b7624c0102d3ef44bbdfe6a
refs/heads/master: a043897a314e8bcfc821d54fe4e591efed5936a3
76 changes: 33 additions & 43 deletions trunk/net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ nl80211_key_policy[NL80211_KEY_MAX + 1] __read_mostly = {
[NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG },
};

/* ifidx get helper */
static int nl80211_get_ifidx(struct netlink_callback *cb)
{
int res;

res = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
nl80211_fam.attrbuf, nl80211_fam.maxattr,
nl80211_policy);
if (res)
return res;

if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
return -EINVAL;

res = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
if (!res)
return -EINVAL;
return res;
}

/* IE validation */
static bool is_valid_ie_attr(const struct nlattr *attr)
{
Expand Down Expand Up @@ -1693,20 +1713,10 @@ static int nl80211_dump_station(struct sk_buff *skb,
int sta_idx = cb->args[1];
int err;

if (!ifidx) {
err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
nl80211_fam.attrbuf, nl80211_fam.maxattr,
nl80211_policy);
if (err)
return err;

if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
return -EINVAL;

ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
if (!ifidx)
return -EINVAL;
}
if (!ifidx)
ifidx = nl80211_get_ifidx(cb);
if (ifidx < 0)
return ifidx;

rtnl_lock();

Expand Down Expand Up @@ -2156,20 +2166,10 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
int path_idx = cb->args[1];
int err;

if (!ifidx) {
err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
nl80211_fam.attrbuf, nl80211_fam.maxattr,
nl80211_policy);
if (err)
return err;

if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
return -EINVAL;

ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
if (!ifidx)
return -EINVAL;
}
if (!ifidx)
ifidx = nl80211_get_ifidx(cb);
if (ifidx < 0)
return ifidx;

rtnl_lock();

Expand Down Expand Up @@ -3198,21 +3198,11 @@ static int nl80211_dump_scan(struct sk_buff *skb,
int start = cb->args[1], idx = 0;
int err;

if (!ifidx) {
err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
nl80211_fam.attrbuf, nl80211_fam.maxattr,
nl80211_policy);
if (err)
return err;

if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX])
return -EINVAL;

ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]);
if (!ifidx)
return -EINVAL;
cb->args[0] = ifidx;
}
if (!ifidx)
ifidx = nl80211_get_ifidx(cb);
if (ifidx < 0)
return ifidx;
cb->args[0] = ifidx;

dev = dev_get_by_index(sock_net(skb->sk), ifidx);
if (!dev)
Expand Down

0 comments on commit 21f3393

Please sign in to comment.