From: "Wani, Shaiq" <shaiq.wani@intel.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: "stephen@networkplumber.org" <stephen@networkplumber.org>
Subject: RE: [PATCH v1] net/cpfl: get running host ID for CPFL PMD
Date: Tue, 21 May 2024 12:43:46 +0000 [thread overview]
Message-ID: <SJ0PR11MB591830FD477347B68CBE531B92EA2@SJ0PR11MB5918.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240520112618.717dc714@hermes.local>
-----Original Message-----
From: Stephen Hemminger <stephen@networkplumber.org>
Sent: Monday, May 20, 2024 11:56 PM
To: Wani, Shaiq <shaiq.wani@intel.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] net/cpfl: get running host ID for CPFL PMD
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.
Thanks for your comment.
I will look for another approach to implement this.
prev parent reply other threads:[~2024-05-21 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 4:44 Shaiq Wani
2024-05-20 18:26 ` Stephen Hemminger
2024-05-21 12:43 ` Wani, Shaiq [this message]
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=SJ0PR11MB591830FD477347B68CBE531B92EA2@SJ0PR11MB5918.namprd11.prod.outlook.com \
--to=shaiq.wani@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).