Re: [RFC PATCH net-next 4/7] net: ethtool: add a netlink command to list PHYs

From
Russell King (Oracle) <linux@armlinux.org.uk>
Date
2023-09-07 16:07:39
Also in
lkml
Reply to
Maxime Chevallier, 2023-09-07
On Thu, Sep 07, 2023 at 11:24:02AM +0200, Maxime Chevallier wrote:
quoted hunk ↗ jump to hunk
+#define PHY_MAX_ENTRIES	16
+
+struct phy_list_reply_data {
+	struct ethnl_reply_data		base;
+	u8 n_phys;
+	u32 phy_indices[PHY_MAX_ENTRIES];
Please could you detail the decision making behind 16 entries - is this
arbitary or based on something?

Also, please consider what we should do if we happen to have more than
16 entries.

Finally, using u8 before an array of u32 can leave 3 bytes of padding.
It would be better to use u32 for n_phys to avoid that padding.
quoted hunk ↗ jump to hunk
+	mutex_lock(&phy_ns->ns_lock);
+	list_for_each_entry(phydev, &phy_ns->phys, node)
+		data->phy_indices[data->n_phys++] = phydev->phyindex;
I think this loop should limit its iterations to ensure that the
array can't overflow.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Thread (35 messages) 35 messages, 6 authors, last reply 2023-10-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help