2017-09-08 14:16:46

by Benjamin Beichler

[permalink] [raw]
Subject: [RFC 4/4] mac80211_hwsim: add radio idx param to netlink callback of radio creation

Since the radio index is already a valid NL attribute, this patch simply
try to read it and create the radio specific to this index by the
previously used scheme.

Since this allows to create radios out of row, we need to search for a
free index for a new radio, when the index is not present as parameter.

Signed-off-by: Benjamin Beichler <[email protected]>
---
drivers/net/wireless/mac80211_hwsim.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 5dd4be2a8487..faa0e39523aa 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2436,6 +2436,7 @@ struct hwsim_new_radio_params {
bool destroy_on_close;
const char *hwname;
bool no_vif;
+ int idx;
};

static void hwsim_mcast_config_msg(struct sk_buff *mcast_skb,
@@ -2645,13 +2646,9 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
skb_queue_head_init(&data->pending);

SET_IEEE80211_DEV(hw, data->dev);
- eth_zero_addr(addr);
- addr[0] = 0x02;
- addr[3] = idx >> 8;
- addr[4] = idx;
- memcpy(data->addresses[0].addr, addr, ETH_ALEN);
- memcpy(data->addresses[1].addr, addr, ETH_ALEN);
- data->addresses[1].addr[0] |= 0x40;
+ memcpy(data->addresses[0].addr, &mac.addr, ETH_ALEN);
+ memcpy(data->addresses[1].addr, &mac.addr, ETH_ALEN);
+ data->addresses[0].addr[0] = 0x02;
hw->wiphy->n_addresses = 2;
hw->wiphy->addresses = data->addresses;

@@ -3304,6 +3301,11 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
param.regd = hwsim_world_regdom_custom[idx];
}

+ if (info->attrs[HWSIM_ATTR_RADIO_ID])
+ param.idx = nla_get_u32(info->attrs[HWSIM_ATTR_RADIO_ID]);
+ else
+ param.idx = -1;
+
return mac80211_hwsim_new_radio(info, &param);
}

--
2.14.1


2017-09-08 14:28:08

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 4/4] mac80211_hwsim: add radio idx param to netlink callback of radio creation

On Fri, 2017-09-08 at 16:11 +0200, Benjamin Beichler wrote:
> Since the radio index is already a valid NL attribute, this patch
> simply
> try to read it and create the radio specific to this index by the
> previously used scheme.
>
> Since this allows to create radios out of row, we need to search for
> a
> free index for a new radio, when the index is not present as
> parameter.

This seems like a bad idea, what's the point? You can always change the
MAC address later if you want.

Also, you don't seem to actually do what you said, with the -1.

johannes

2017-09-08 14:43:15

by Benjamin Beichler

[permalink] [raw]
Subject: Re: [RFC 4/4] mac80211_hwsim: add radio idx param to netlink callback of radio creation


>> Since the radio index is already a valid NL attribute, this patch >> simply try to read it and create the radio specific to this index >>
by the previously used scheme. >> >> Since this allows to create radios
out of row, we need to search >> for a free index for a new radio, when
the index is not present as >> parameter. > > This seems like a bad
idea, what's the point? You can always change > the MAC address later if
you want. AFAIK, you can change the MAC-Address of an interface on the
phy, but not the perm address of the phy. But for frames sent to a
wmediumd always the perm address is used to identify the sender and
receiver. It is really annoying to additionally keep a translation table
in userspace to manage between random ids/mac-addresses to them you use
in a simulation for this.


> > > Also, you don't seem to actually do what you said, with the -1.
OK, I see this is badly mixed up with patch 1, which introduces the
hashlist stuff.

--
M.Sc. Benjamin Beichler

Universität Rostock, Fakultät für Informatik und Elektrotechnik
Institut für Angewandte Mikroelektronik und Datentechnik

University of Rostock, Department of CS and EE
Institute of Applied Microelectronics and CE

Richard-Wagner-Straße 31
18119 Rostock
Deutschland/Germany

phone: +49 (0) 381 498 - 7278
email: [email protected]
www: http://www.imd.uni-rostock.de/



Attachments:
smime.p7s (5.03 kB)
S/MIME Cryptographic Signature

2017-09-08 14:46:41

by Johannes Berg

[permalink] [raw]
Subject: Re: [RFC 4/4] mac80211_hwsim: add radio idx param to netlink callback of radio creation

Uh. Is there anything you can do not to mangle your replies? I don't
even know what you're replying to etc.

> AFAIK, you can change the MAC-Address of an interface on
> the phy, but not the perm address of the phy. But for frames sent to
> a wmediumd always the perm address is used to identify the sender and
> receiver. It is really annoying to additionally keep a translation
> table in userspace to manage between random ids/mac-addresses to them
> you use in a simulation for this.

I think we tried to fix that once, but that caused more problems ...

I'd rather allow you to then specify the MAC address though - the
index/address mapping doesn't need to be the identity, after all.

johannes