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]
Date:   Sun, 31 Jan 2021 10:26:22 -0700
From:   David Ahern <dsahern@...il.com>
To:     Parav Pandit <parav@...dia.com>, stephen@...workplumber.org,
        netdev@...r.kernel.org
Cc:     Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH iproute2-next 3/5] devlink: Supporting add and delete of
 devlink port

On 1/29/21 9:56 AM, Parav Pandit wrote:
> @@ -1383,6 +1389,37 @@ static int reload_limit_get(struct dl *dl, const char *limitstr,
>  	return 0;
>  }
>  
> +static int port_flavour_parse(const char *flavour, uint16_t *value)
> +{
> +	if (!flavour)
> +		return -EINVAL;
> +
> +	if (strcmp(flavour, "physical") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PHYSICAL;
> +		return 0;
> +	} else if (strcmp(flavour, "cpu") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_CPU;
> +		return 0;
> +	} else if (strcmp(flavour, "dsa") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_DSA;
> +		return 0;
> +	} else if (strcmp(flavour, "pcipf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_PF;
> +		return 0;
> +	} else if (strcmp(flavour, "pcivf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_VF;
> +		return 0;
> +	} else if (strcmp(flavour, "pcisf") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_PCI_SF;
> +		return 0;
> +	} else if (strcmp(flavour, "virtual") == 0) {
> +		*value = DEVLINK_PORT_FLAVOUR_VIRTUAL;
> +		return 0;
> +	} else {
> +		return -EINVAL;
> +	}
> +}
use a struct for the string - value conversions; that should have been
done for port_flavour_name so it can be refactored to use that kind of
relationship. This function is just the inverse of it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ