[PATCH v1] net/cpfl: get running host ID for CPFL PMD

Stephen Hemminger stephen at networkplumber.org
Mon May 20 20:26:18 CEST 2024


On Mon, 20 May 2024 04:44:15 +0000
Shaiq Wani <shaiq.wani at intel.com> wrote:

> +static uint8_t
> +get_running_host_id(void)
> +{
> +	char buf[BUFSIZ];
> +	FILE *fd;
> +	uint8_t host_id = CPFL_INVALID_HOST_ID;
> +
> +	fd = fopen("/etc/issue.net", "r");
> +	if (fd == NULL) {
> +		PMD_INIT_LOG(ERR, "Cannot open /etc/issue.net\n");
> +		return host_id;
> +	}
>  
> +	if (fgets(buf, sizeof(buf), fd)) {
> +		/* get the first line */
> +		if (strstr(buf, "IMC"))
> +			PMD_INIT_LOG(ERR, "CPFL PMD cannot running on IMC.");
> +		else if (strstr(buf, "ACC"))
> +			host_id = CPFL_HOST_ID_ACC;
> +		else
> +			host_id = CPFL_HOST_ID_HOST;
> +	}
>  
> +	fclose(fd);
> +	return host_id;
> +}

This seems weird and problematic. You are making assumptions about /etc/issue.net
which the is the message file used by SSH for login message.

On an embedded firmware ROM this may work. But on other platforms this is
a user modifiable file.


More information about the dev mailing list