Commit a87815b7 authored by Miquel Raynal's avatar Miquel Raynal Committed by Stefan Schmidt

ieee802154: hwsim: Record the address filter values

As a first step, introduce a basic implementation for the
->set_hw_addr_filt() hook. In a second step, the values recorded here
will be used to perform proper filtering during reception.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
Link: https://lore.kernel.org/r/20221007085310.503366-5-miquel.raynal@bootlin.comSigned-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
parent ac8037c3
...@@ -47,6 +47,7 @@ static const struct genl_multicast_group hwsim_mcgrps[] = { ...@@ -47,6 +47,7 @@ static const struct genl_multicast_group hwsim_mcgrps[] = {
struct hwsim_pib { struct hwsim_pib {
u8 page; u8 page;
u8 channel; u8 channel;
struct ieee802154_hw_addr_filt filt;
struct rcu_head rcu; struct rcu_head rcu;
}; };
...@@ -101,6 +102,38 @@ static int hwsim_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) ...@@ -101,6 +102,38 @@ static int hwsim_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
pib->channel = channel; pib->channel = channel;
pib_old = rtnl_dereference(phy->pib); pib_old = rtnl_dereference(phy->pib);
pib->filt.short_addr = pib_old->filt.short_addr;
pib->filt.pan_id = pib_old->filt.pan_id;
pib->filt.ieee_addr = pib_old->filt.ieee_addr;
pib->filt.pan_coord = pib_old->filt.pan_coord;
rcu_assign_pointer(phy->pib, pib);
kfree_rcu(pib_old, rcu);
return 0;
}
static int hwsim_hw_addr_filt(struct ieee802154_hw *hw,
struct ieee802154_hw_addr_filt *filt,
unsigned long changed)
{
struct hwsim_phy *phy = hw->priv;
struct hwsim_pib *pib, *pib_old;
pib = kzalloc(sizeof(*pib), GFP_KERNEL);
if (!pib)
return -ENOMEM;
pib_old = rtnl_dereference(phy->pib);
pib->page = pib_old->page;
pib->channel = pib_old->channel;
pib->filt.short_addr = filt->short_addr;
pib->filt.pan_id = filt->pan_id;
pib->filt.ieee_addr = filt->ieee_addr;
pib->filt.pan_coord = filt->pan_coord;
rcu_assign_pointer(phy->pib, pib); rcu_assign_pointer(phy->pib, pib);
kfree_rcu(pib_old, rcu); kfree_rcu(pib_old, rcu);
return 0; return 0;
...@@ -172,6 +205,7 @@ static const struct ieee802154_ops hwsim_ops = { ...@@ -172,6 +205,7 @@ static const struct ieee802154_ops hwsim_ops = {
.start = hwsim_hw_start, .start = hwsim_hw_start,
.stop = hwsim_hw_stop, .stop = hwsim_hw_stop,
.set_promiscuous_mode = hwsim_set_promiscuous_mode, .set_promiscuous_mode = hwsim_set_promiscuous_mode,
.set_hw_addr_filt = hwsim_hw_addr_filt,
}; };
static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
...@@ -787,6 +821,8 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev, ...@@ -787,6 +821,8 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
} }
pib->channel = 13; pib->channel = 13;
pib->filt.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
pib->filt.pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
rcu_assign_pointer(phy->pib, pib); rcu_assign_pointer(phy->pib, pib);
phy->idx = idx; phy->idx = idx;
INIT_LIST_HEAD(&phy->edges); INIT_LIST_HEAD(&phy->edges);
......
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