Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec.sh: Remove CAN Bus interfaces from network device list and fix JSON field #3930

Merged
merged 1 commit into from
May 24, 2024

Conversation

rene
Copy link
Contributor

@rene rene commented May 22, 2024

This PR provides two fixes for the spec.sh script:

  • Do not list CAN Bus interfaces as network interfaces, since they are listed as dedicated I/O adapters.
  • CAN Bus interfaces are listed as IO_TYPE_CAN. Add quotes to this string in order to not break the JSON format.

@rene rene requested a review from rouming as a code owner May 22, 2024 13:33
@@ -478,7 +478,8 @@ for ETH in /sys/class/net/*; do
COST=0
ZTYPE=1
isUSB=$(readlink "$ETH" | grep -Eo '/usb[0-9]/' || true)
if [ "$isUSB" != "" ]
isCAN=$(cat "$ETH"/type)
if [ "$isUSB" != "" ] || [ "$isCAN" = "280" ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of the magic 280? Can you add a comment about it?

And wouldn't it make sense to set isCAN=(cat ETH/type = 280)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eriknordmark , it's just the constant defined for CAN devices by the kernel: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_arp.h#L56

I'm not sure I got your second comment, are you talking about do something like the following?

isCAN=$([ `cat "$ETH"/type` = 280 ])

I just followed the same logic for checking USB....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUSB is effectively a boolean, but isCAN is not. So it is harder to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this name is a bit unfortunate, but isCAN is just like isUSB.... for isUSB it reads the symbolic link of the device and greps for /usb[0-9]/ printing the matched string (if it matches), so the result is effectively a string, as the type of isCAN. Nevertheless I've changed the logic to be more similar, I think now it's better...

…SON field

- Do not list CAN Bus interfaces as network interfaces, since they are
  listed as dedicated I/O adapters.

- CAN Bus interfaces are listed as IO_TYPE_CAN. Add quotes to this string
  in order to not break the JSON format.

Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eriknordmark eriknordmark merged commit 6dc09fc into lf-edge:master May 24, 2024
23 checks passed
@rene rene deleted the fix-spec-sh branch August 2, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants