Message ID | 20230918150809.275058-12-miquel.raynal@bootlin.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | ieee802154: Associations between devices | expand |
Hi Miquel, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] [also build test ERROR on net/main linus/master v6.6-rc2 next-20230918] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Miquel-Raynal/ieee802154-Let-PAN-IDs-be-reset/20230919-002634 base: net-next/main patch link: https://lore.kernel.org/r/20230918150809.275058-12-miquel.raynal%40bootlin.com patch subject: [PATCH wpan-next v3 11/11] ieee802154: Give the user the association list config: powerpc64-randconfig-001-20230919 (https://download.01.org/0day-ci/archive/20230919/202309191044.4ABvPP5X-lkp@intel.com/config) compiler: powerpc64-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191044.4ABvPP5X-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202309191044.4ABvPP5X-lkp@intel.com/ All errors (new ones prefixed by >>): net/ieee802154/nl802154.c: In function 'nl802154_list_associations': >> net/ieee802154/nl802154.c:1778:15: error: implicit declaration of function 'nl802154_prepare_wpan_dev_dump' [-Werror=implicit-function-declaration] 1778 | err = nl802154_prepare_wpan_dev_dump(skb, cb, &rdev, &wpan_dev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> net/ieee802154/nl802154.c:1811:9: error: implicit declaration of function 'nl802154_finish_wpan_dev_dump' [-Werror=implicit-function-declaration] 1811 | nl802154_finish_wpan_dev_dump(rdev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors vim +/nl802154_prepare_wpan_dev_dump +1778 net/ieee802154/nl802154.c 1769 1770 static int nl802154_list_associations(struct sk_buff *skb, 1771 struct netlink_callback *cb) 1772 { 1773 struct cfg802154_registered_device *rdev; 1774 struct ieee802154_pan_device *child; 1775 struct wpan_dev *wpan_dev; 1776 int err; 1777 > 1778 err = nl802154_prepare_wpan_dev_dump(skb, cb, &rdev, &wpan_dev); 1779 if (err) 1780 return err; 1781 1782 mutex_lock(&wpan_dev->association_lock); 1783 1784 if (cb->args[2]) 1785 goto out; 1786 1787 if (wpan_dev->parent) { 1788 err = nl802154_send_peer_info(skb, cb, cb->nlh->nlmsg_seq, 1789 NLM_F_MULTI, rdev, wpan_dev, 1790 wpan_dev->parent, 1791 NL802154_PEER_TYPE_PARENT); 1792 if (err < 0) 1793 goto out_err; 1794 } 1795 1796 list_for_each_entry(child, &wpan_dev->children, node) { 1797 err = nl802154_send_peer_info(skb, cb, cb->nlh->nlmsg_seq, 1798 NLM_F_MULTI, rdev, wpan_dev, 1799 child, 1800 NL802154_PEER_TYPE_CHILD); 1801 if (err < 0) 1802 goto out_err; 1803 } 1804 1805 cb->args[2] = 1; 1806 out: 1807 err = skb->len; 1808 out_err: 1809 mutex_unlock(&wpan_dev->association_lock); 1810 > 1811 nl802154_finish_wpan_dev_dump(rdev); 1812 1813 return err; 1814 } 1815
Hello, > net/ieee802154/nl802154.c: In function 'nl802154_list_associations': > >> net/ieee802154/nl802154.c:1778:15: error: implicit declaration of function 'nl802154_prepare_wpan_dev_dump' [-Werror=implicit-function-declaration] > 1778 | err = nl802154_prepare_wpan_dev_dump(skb, cb, &rdev, &wpan_dev); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >> net/ieee802154/nl802154.c:1811:9: error: implicit declaration of function 'nl802154_finish_wpan_dev_dump' [-Werror=implicit-function-declaration] > 1811 | nl802154_finish_wpan_dev_dump(rdev); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > cc1: some warnings being treated as errors > > > vim +/nl802154_prepare_wpan_dev_dump +1778 net/ieee802154/nl802154.c > > 1769 > 1770 static int nl802154_list_associations(struct sk_buff *skb, > 1771 struct netlink_callback *cb) > 1772 { > 1773 struct cfg802154_registered_device *rdev; > 1774 struct ieee802154_pan_device *child; > 1775 struct wpan_dev *wpan_dev; > 1776 int err; > 1777 > > 1778 err = nl802154_prepare_wpan_dev_dump(skb, cb, &rdev, &wpan_dev); [...] > > 1811 nl802154_finish_wpan_dev_dump(rdev); These two are defined within #ifdef EXPERIMENTAL. I will move them out as I need them as well inthe !EXPERIMENTAL case. Good that kernel test robot eventually catch that. Thanks, Miquèl
diff --git a/include/net/nl802154.h b/include/net/nl802154.h index 8b26faae49e8..4c752f799957 100644 --- a/include/net/nl802154.h +++ b/include/net/nl802154.h @@ -81,6 +81,7 @@ enum nl802154_commands { NL802154_CMD_ASSOCIATE, NL802154_CMD_DISASSOCIATE, NL802154_CMD_SET_MAX_ASSOCIATIONS, + NL802154_CMD_LIST_ASSOCIATIONS, /* add new commands above here */ @@ -151,6 +152,7 @@ enum nl802154_attrs { NL802154_ATTR_SCAN_DONE_REASON, NL802154_ATTR_BEACON_INTERVAL, NL802154_ATTR_MAX_ASSOCIATIONS, + NL802154_ATTR_PEER, /* add attributes here, update the policy in nl802154.c */ @@ -389,8 +391,6 @@ enum nl802154_supported_bool_states { NL802154_SUPPORTED_BOOL_MAX = __NL802154_SUPPORTED_BOOL_AFTER_LAST - 1 }; -#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL - enum nl802154_dev_addr_modes { NL802154_DEV_ADDR_NONE, __NL802154_DEV_ADDR_INVALID, @@ -410,12 +410,26 @@ enum nl802154_dev_addr_attrs { NL802154_DEV_ADDR_ATTR_SHORT, NL802154_DEV_ADDR_ATTR_EXTENDED, NL802154_DEV_ADDR_ATTR_PAD, + NL802154_DEV_ADDR_ATTR_PEER_TYPE, /* keep last */ __NL802154_DEV_ADDR_ATTR_AFTER_LAST, NL802154_DEV_ADDR_ATTR_MAX = __NL802154_DEV_ADDR_ATTR_AFTER_LAST - 1 }; +enum nl802154_peer_type { + NL802154_PEER_TYPE_UNSPEC, + + NL802154_PEER_TYPE_PARENT, + NL802154_PEER_TYPE_CHILD, + + /* keep last */ + __NL802154_PEER_TYPE_AFTER_LAST, + NL802154_PEER_TYPE_MAX = __NL802154_PEER_TYPE_AFTER_LAST - 1 +}; + +#ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL + enum nl802154_key_id_modes { NL802154_KEY_ID_MODE_IMPLICIT, NL802154_KEY_ID_MODE_INDEX, diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c index e16e57fc34d0..1218e6095808 100644 --- a/net/ieee802154/nl802154.c +++ b/net/ieee802154/nl802154.c @@ -235,6 +235,7 @@ static const struct nla_policy nl802154_policy[NL802154_ATTR_MAX+1] = { [NL802154_ATTR_BEACON_INTERVAL] = NLA_POLICY_MAX(NLA_U8, IEEE802154_ACTIVE_SCAN_DURATION), [NL802154_ATTR_MAX_ASSOCIATIONS] = { .type = NLA_U32 }, + [NL802154_ATTR_PEER] = { .type = NLA_NESTED }, #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL [NL802154_ATTR_SEC_ENABLED] = { .type = NLA_U8, }, @@ -1717,6 +1718,101 @@ static int nl802154_set_max_associations(struct sk_buff *skb, struct genl_info * return 0; } +static int nl802154_send_peer_info(struct sk_buff *msg, + struct netlink_callback *cb, + u32 seq, int flags, + struct cfg802154_registered_device *rdev, + struct wpan_dev *wpan_dev, + struct ieee802154_pan_device *peer, + enum nl802154_peer_type type) +{ + struct nlattr *nla; + void *hdr; + + ASSERT_RTNL(); + + hdr = nl802154hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags, + NL802154_CMD_LIST_ASSOCIATIONS); + if (!hdr) + return -ENOBUFS; + + genl_dump_check_consistent(cb, hdr); + + nla = nla_nest_start_noflag(msg, NL802154_ATTR_PEER); + if (!nla) + goto nla_put_failure; + + if (nla_put_u8(msg, NL802154_DEV_ADDR_ATTR_PEER_TYPE, type)) + goto nla_put_failure; + + if (nla_put_u8(msg, NL802154_DEV_ADDR_ATTR_MODE, peer->mode)) + goto nla_put_failure; + + if (nla_put(msg, NL802154_DEV_ADDR_ATTR_SHORT, + IEEE802154_SHORT_ADDR_LEN, &peer->short_addr)) + goto nla_put_failure; + + if (nla_put(msg, NL802154_DEV_ADDR_ATTR_EXTENDED, + IEEE802154_EXTENDED_ADDR_LEN, &peer->extended_addr)) + goto nla_put_failure; + + nla_nest_end(msg, nla); + + genlmsg_end(msg, hdr); + + return 0; + + nla_put_failure: + genlmsg_cancel(msg, hdr); + return -EMSGSIZE; +} + +static int nl802154_list_associations(struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct cfg802154_registered_device *rdev; + struct ieee802154_pan_device *child; + struct wpan_dev *wpan_dev; + int err; + + err = nl802154_prepare_wpan_dev_dump(skb, cb, &rdev, &wpan_dev); + if (err) + return err; + + mutex_lock(&wpan_dev->association_lock); + + if (cb->args[2]) + goto out; + + if (wpan_dev->parent) { + err = nl802154_send_peer_info(skb, cb, cb->nlh->nlmsg_seq, + NLM_F_MULTI, rdev, wpan_dev, + wpan_dev->parent, + NL802154_PEER_TYPE_PARENT); + if (err < 0) + goto out_err; + } + + list_for_each_entry(child, &wpan_dev->children, node) { + err = nl802154_send_peer_info(skb, cb, cb->nlh->nlmsg_seq, + NLM_F_MULTI, rdev, wpan_dev, + child, + NL802154_PEER_TYPE_CHILD); + if (err < 0) + goto out_err; + } + + cb->args[2] = 1; +out: + err = skb->len; +out_err: + mutex_unlock(&wpan_dev->association_lock); + + nl802154_finish_wpan_dev_dump(rdev); + + return err; +} + #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL static const struct nla_policy nl802154_dev_addr_policy[NL802154_DEV_ADDR_ATTR_MAX + 1] = { [NL802154_DEV_ADDR_ATTR_PAN_ID] = { .type = NLA_U16 }, @@ -2861,6 +2957,11 @@ static const struct genl_ops nl802154_ops[] = { .internal_flags = NL802154_FLAG_NEED_NETDEV | NL802154_FLAG_NEED_RTNL, }, + { + .cmd = NL802154_CMD_LIST_ASSOCIATIONS, + .dumpit = nl802154_list_associations, + /* can be retrieved by unprivileged users */ + }, #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL { .cmd = NL802154_CMD_SET_SEC_PARAMS,
Upon request, we must be able to provide to the user the list of associations currently in place. Let's add a new netlink command and attribute for this purpose. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- include/net/nl802154.h | 18 ++++++- net/ieee802154/nl802154.c | 101 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 2 deletions(-)