All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Shaiq Wani <shaiq.wani@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] net/cpfl: get running host ID for CPFL PMD
Date: Mon, 20 May 2024 11:26:18 -0700	[thread overview]
Message-ID: <20240520112618.717dc714@hermes.local> (raw)
In-Reply-To: <20240520044415.2307157-1-shaiq.wani@intel.com>

On Mon, 20 May 2024 04:44:15 +0000
Shaiq Wani <shaiq.wani@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.

  reply	other threads:[~2024-05-20 18:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-20  4:44 [PATCH v1] net/cpfl: get running host ID for CPFL PMD Shaiq Wani
2024-05-20 18:26 ` Stephen Hemminger [this message]
2024-05-21 12:43   ` Wani, Shaiq

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240520112618.717dc714@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=shaiq.wani@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.