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

Fix parsing of interface aliases in netdev linux #904

Merged
merged 1 commit into from
Apr 17, 2018
Merged

Conversation

SuperQ
Copy link
Member

@SuperQ SuperQ commented Apr 16, 2018

Very old kernels expose interface aliases as foo0:0, adjust the line
parsing to handle these names.

Signed-off-by: Ben Kochie [email protected]

Closes: #902

@SuperQ SuperQ requested a review from discordianfish April 16, 2018 12:36
@SuperQ SuperQ force-pushed the superq/if_alias branch 3 times, most recently from 172bedd to cc5415b Compare April 16, 2018 19:41
@SuperQ SuperQ requested a review from juliusv April 17, 2018 07:26
@brian-brazil
Copy link
Contributor

👍

Copy link
Member

@grobie grobie left a comment

Choose a reason for hiding this comment

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

Besides the error string formatting.

return nil, fmt.Errorf("invalid line in net/dev: %s", scanner.Text())
parts := procNetDevInterfaceRE.FindStringSubmatch(line)
if len(parts) != 3 {
return nil, fmt.Errorf("Couldn't get interface name, invalid line in net/dev: %q", line)
Copy link
Member

Choose a reason for hiding this comment

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


values := procNetDevFieldSep.Split(strings.TrimLeft(parts[2], " "), -1)
if len(values) != headerLength {
return nil, fmt.Errorf("Couldn't get values, invalid line in net/dev: %q", parts[2])
Copy link
Member

Choose a reason for hiding this comment

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

return nil, fmt.Errorf("invalid line in net/dev: %s", scanner.Text())
parts := procNetDevInterfaceRE.FindStringSubmatch(line)
if len(parts) != 3 {
return nil, fmt.Errorf("Couldn't get interface name, invalid line in net/dev: %q", line)
Copy link
Member

Choose a reason for hiding this comment

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

Very old kernels expose interface aliases as `foo0:0`, adjust the line
parsing to handle these names.

Signed-off-by: Ben Kochie <[email protected]>
@juliusv
Copy link
Member

juliusv commented Apr 17, 2018

👍

@SuperQ SuperQ merged commit 0f5be13 into master Apr 17, 2018
@SuperQ SuperQ deleted the superq/if_alias branch April 17, 2018 11:37
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.

4 participants