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: <20220311080631.7e679bea@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date:   Fri, 11 Mar 2022 08:06:31 -0800
From:   Jakub Kicinski <kuba@...nel.org>
To:     Petr Machata <petrm@...dia.com>
Cc:     <netdev@...r.kernel.org>, "David S. Miller" <davem@...emloft.net>,
        Ido Schimmel <idosch@...dia.com>
Subject: Re: [PATCH net-next 1/3] netdevsim: Introduce support for L3
 offload xstats

On Fri, 11 Mar 2022 10:18:39 +0100 Petr Machata wrote:
> How about this?
> 
> struct nsim_dev_hwstats_fops {
> 	const struct file_operations fops;
> 	enum nsim_dev_hwstats_do action;
> 	enum netdev_offload_xstats_type type;
> };

Yeah, sure that also works. Using fops is relatively common, 
I thought, so:

+static ssize_t
+nsim_dev_hwstats_do_write(struct file *file,
+			  const char __user *data,
+			  size_t count, loff_t *ppos)
+{
+	struct nsim_dev_hwstats *hwstats = file->private_data;
+	struct list_head *hwsdev_list;
+	int ifindex;
+	int err;
+
+	err = kstrtoint_from_user(data, count, 0, &ifindex);
+	if (err)
+		return err;
+
+	hwsdev_list = nsim_dev_hwstats_get_list_head(hwstats, hwsfops->type);
+	if (WARN_ON(!hwsdev_list))
+		return -EINVAL;
+
+	switch (debugfs_real_fops(file)) {
+	case &nsim_dev_hwstats_l3_disable_fops:
+		err = nsim_dev_hwstats_disable_ifindex(hwstats, ifindex,
+						       NSIM_DEV_HWSTATS_DO_DISABLE,
+						       hwsdev_list);
+		break;

etc. would be the shortest version.

I'm okay with your version if you prefer, but the above works, right?
Or am I missing something?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ