-
Notifications
You must be signed in to change notification settings - Fork 159
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
Conversation
pkg/debug/spec.sh
Outdated
@@ -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" ] |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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....
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR provides two fixes for the spec.sh script: