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 link parsing failure on non-ethernet devices #1742

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions internal/server/ip/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type jsonLink struct {
AllMulticast int `json:"allmulti"`
Master string `json:"master"`
Up string `json:"operstate"`
Type string `json:"link_type"`
Info struct {
Kind string `json:"info_kind"`
} `json:"linkinfo"`
Expand Down Expand Up @@ -104,7 +105,7 @@ func LinkFromName(name string) (*Link, error) {
var links []jsonLink
err = json.Unmarshal([]byte(out), &links)
if err != nil {
return nil, fmt.Errorf("failed to decode JSON link representation: %w", err)
return nil, fmt.Errorf("Failed to decode JSON link representation: %w", err)
}

jl := &links[0]
Expand All @@ -117,7 +118,7 @@ func LinkFromName(name string) (*Link, error) {
Master: jl.Master,
}

if jl.Address != "" {
if jl.Type == "ether" && jl.Address != "" {
l.Address, err = net.ParseMAC(jl.Address)
if err != nil {
return nil, err
Expand Down