lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190612160534.23533-8-andrew@lunn.ch>
Date:   Wed, 12 Jun 2019 18:05:28 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     netdev <netdev@...r.kernel.org>
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Raju.Lakkaraju@...rochip.com, Andrew Lunn <andrew@...n.ch>
Subject: [PATCH RFC 07/13] net: phy: cable test: Use request seq in broadcast reply

An ethtool netlink action is used to start the cable test. Use the
sequence number from this action in the multicast later used to send
the results of the cable test, so that the results can be match back
to the request.

Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
 drivers/net/phy/phy.c           | 5 +++--
 include/linux/ethtool_netlink.h | 1 +
 include/linux/phy.h             | 6 ++++--
 net/ethtool/actions.c           | 3 ++-
 net/ethtool/netlink.c           | 8 ++++++--
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index db8a5957acdd..3c614639ce20 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -486,7 +486,7 @@ static void phy_cable_test_abort(struct phy_device *phydev)
 }
 
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack)
+			 struct netlink_ext_ack *extack, u32 seq)
 {
 	int err = -ENOMEM;
 	int ret;
@@ -512,7 +512,8 @@ int phy_start_cable_test(struct phy_device *phydev,
 	if (!phydev->skb)
 		goto out;
 
-	phydev->ehdr = ethnl_bcastmsg_put(phydev->skb, ETHNL_CMD_EVENT);
+	phydev->ehdr = ethnl_bcastmsg_put_seq(phydev->skb, ETHNL_CMD_EVENT,
+					      seq);
 	if (!phydev->ehdr)
 		goto out_free;
 
diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h
index 7d98592cd8a1..66a91e629694 100644
--- a/include/linux/ethtool_netlink.h
+++ b/include/linux/ethtool_netlink.h
@@ -29,6 +29,7 @@ static inline struct nlattr *ethnl_nest_start(struct sk_buff *skb,
 
 int ethnl_fill_dev(struct sk_buff *msg, struct net_device *dev, u16 attrtype);
 void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
+void *ethnl_bcastmsg_put_seq(struct sk_buff *skb, u8 cmd, u32 seq);
 int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
 
 #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index da8cc97b55dc..cea151c66ac1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1077,11 +1077,13 @@ int phy_reset_after_clk_enable(struct phy_device *phydev);
 
 #if IS_ENABLED(CONFIG_PHYLIB)
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack);
+			 struct netlink_ext_ack *extack,
+			 u32 seq);
 #else
 static inline
 int phy_start_cable_test(struct phy_device *phydev,
-			 struct netlink_ext_ack *extack)
+			 struct netlink_ext_ack *extack,
+			 u32 seq)
 {
 	NL_SET_ERR_MSG(extack, "Kernel not compiled with PHYLIB support");
 	return -EOPNOTSUPP;
diff --git a/net/ethtool/actions.c b/net/ethtool/actions.c
index 8a26ae1b2ada..8595cc27d532 100644
--- a/net/ethtool/actions.c
+++ b/net/ethtool/actions.c
@@ -440,7 +440,8 @@ int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info)
 	if (ret < 0)
 		goto out_rtnl;
 
-	ret = phy_start_cable_test(dev->phydev, info->extack);
+	ret = phy_start_cable_test(dev->phydev, info->extack, info->snd_seq);
+
 	ethnl_after_ops(dev);
 
 	if (ret == 0)
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 894dc81536c9..9d97de1c86aa 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -240,10 +240,14 @@ struct sk_buff *ethnl_reply_init(size_t payload, struct net_device *dev, u8 cmd,
 	return NULL;
 }
 
+void *ethnl_bcastmsg_put_seq(struct sk_buff *skb, u8 cmd, u32 seq)
+{
+	return genlmsg_put(skb, 0, seq, &ethtool_genl_family, 0, cmd);
+}
+
 void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd)
 {
-	return genlmsg_put(skb, 0, ++ethnl_bcast_seq, &ethtool_genl_family, 0,
-			   cmd);
+	return ethnl_bcastmsg_put_seq(skb, cmd, ++ethnl_bcast_seq);
 }
 
 int ethnl_multicast(struct sk_buff *skb, struct net_device *dev)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ