Search Linux Wireless

Re: [PATCH V3 net-next 2/4] ethtool: extend coalesce setting uAPI with CQE mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 20.08.21 10:35, Yufeng Mo wrote:
> In order to support more coalesce parameters through netlink,
> add two new parameter kernel_coal and extack for .set_coalesce
> and .get_coalesce, then some extra info can return to user with
> the netlink API.
> 
> Signed-off-by: Yufeng Mo <moyufeng@xxxxxxxxxx>
> Signed-off-by: Huazhong Tan <tanhuazhong@xxxxxxxxxx>
> ---

[...]

> index 81fa36a..f2abc31 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -1619,12 +1619,14 @@ static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
>  						   void __user *useraddr)
>  {
>  	struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
> +	struct kernel_ethtool_coalesce kernel_coalesce = {};
>  	int ret;
>  
>  	if (!dev->ethtool_ops->get_coalesce)
>  		return -EOPNOTSUPP;
>  
> -	ret = dev->ethtool_ops->get_coalesce(dev, &coalesce);
> +	ret = dev->ethtool_ops->get_coalesce(dev, &coalesce, &kernel_coalesce,
> +					     NULL);
>  	if (ret)
>  		return ret;
>  
> @@ -1691,19 +1693,26 @@ ethtool_set_coalesce_supported(struct net_device *dev,
>  static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
>  						   void __user *useraddr)
>  {
> +	struct kernel_ethtool_coalesce kernel_coalesce = {};
>  	struct ethtool_coalesce coalesce;
>  	int ret;
>  
> -	if (!dev->ethtool_ops->set_coalesce)
> +	if (!dev->ethtool_ops->set_coalesce && !dev->ethtool_ops->get_coalesce)
>  		return -EOPNOTSUPP;
>  

This needs to be

	if (!set_coalesce || !get_coalesce)
		return -EOPNOTSUPP;

Otherwise you end up calling a NULL pointer below if just _one_ of the
callbacks is available.


> +	ret = dev->ethtool_ops->get_coalesce(dev, &coalesce, &kernel_coalesce,
> +					     NULL);
> +	if (ret)
> +		return ret;
> +
>  	if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
>  		return -EFAULT;
>  
>  	if (!ethtool_set_coalesce_supported(dev, &coalesce))
>  		return -EOPNOTSUPP;
>  
> -	ret = dev->ethtool_ops->set_coalesce(dev, &coalesce);
> +	ret = dev->ethtool_ops->set_coalesce(dev, &coalesce, &kernel_coalesce,
> +					     NULL);
>  	if (!ret)
>  		ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF, NULL);
>  	return ret;
> 




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux