Add ifreq pointer field to kernel_hwtstamp_config structure
Subsystems (3)
RFC PATCH v3 2/5 Add ifreq pointer field to kernel_hwtstamp_config structure
Considering the stackable nature of drivers there will be situations where a driver implementing ndo_hwtstamp_get/set functions will have to translate requests back to SIOCGHWTSTAMP/SIOCSHWTSTAMP IOCTLs to pass them to lower level drivers that do not provide ndo_hwtstamp_get/set callbacks. To simplify request translation in such scenarios let's include a pointer to the original struct ifreq to kernel_hwtstamp_config structure.
Suggested-by Jakub Kicinski <[email protected]>
Signed-off-by Maxim Georgiev <[email protected]>
--- include/linux/net_tstamp.h | 1 + net/core/dev_ioctl.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/linux/net_tstamp.h +1 -0
@@ -20,6 +20,7 @@ struct kernel_hwtstamp_config {int flags;int tx_type;int rx_filter; +struct ifreq *ifr; }; static inline void hwtstamp_config_to_kernel(struct kernel_hwtstamp_config *kernel_cfg,
net/core/dev_ioctl.c +4 -2
@@ -255,7 +255,7 @@ static int dev_eth_ioctl(struct net_device *dev,static int dev_get_hwtstamp (struct net_device *dev,struct ifreq *ifr) {const struct net_device_ops *ops = dev->netdev_ops; -struct kernel_hwtstamp_config kernel_cfg; +struct kernel_hwtstamp_config kernel_cfg = {};struct hwtstamp_config config;int err;
@@ -265,6 +265,7 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)if (!netif_device_present (dev))return -ENODEV ; + kernel_cfg.ifr = ifr; err = ops->ndo_hwtstamp_get (dev, &kernel_cfg,NULL );if (err)return err;
@@ -281,7 +282,7 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)struct netdev_notifier_hwtstamp_info info = { .info.dev = dev, }; -struct kernel_hwtstamp_config kernel_cfg; +struct kernel_hwtstamp_config kernel_cfg = {};struct netlink_ext_ack extack = {};struct hwtstamp_config cfg;int err;
@@ -290,6 +291,7 @@ static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)return -EFAULT ;hwtstamp_config_to_kernel (&kernel_cfg, &cfg); + kernel_cfg.ifr = ifr; err =net_hwtstamp_validate (&kernel_cfg);if (err)
Signature · 1 line
2.39.2