Skip to content
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
18 changes: 12 additions & 6 deletions src/k8s/pkg/utils/netlink.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package utils

import (
"encoding/json"
"fmt"
"net"
"os/exec"

"gopkg.in/yaml.v2"
)

type VXLANInterface struct {
Expand All @@ -13,12 +14,12 @@ type VXLANInterface struct {
}

var ipLinks []struct {
IfName string `json:"ifname"`
IfName string `json:"ifname" yaml:"ifname"`
LinkInfo struct {
InfoData struct {
Port *int `json:"port"`
} `json:"info_data"`
} `json:"linkinfo"`
Port *int `json:"port" yaml:"port"`
} `json:"info_data" yaml:"info_data"`
} `json:"linkinfo" yaml:"linkinfo"`
}

func ListVXLANInterfaces() ([]VXLANInterface, error) {
Expand All @@ -30,7 +31,12 @@ func ListVXLANInterfaces() ([]VXLANInterface, error) {
return vxlanDevices, fmt.Errorf("running ip command failed: %s", string(out))
}

if err := json.Unmarshal(out, &ipLinks); err != nil {
// NOTE: (mateoflorido) Parsing as YAML cleans up invalid JSON output
// produced by the iproute2 command in arm64. Currently, the Ubuntu package
// combines the VXLAN VNI value with the fan-map extension, resulting in
// invalid JSON, but a valid YAML.
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

// https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2121908
if err := yaml.Unmarshal(out, &ipLinks); err != nil {
return vxlanDevices, fmt.Errorf("unmarshaling ip command output failed: %w", err)
}

Expand Down
Loading