{"record":{"id":"8471708c81189a96","repo":"k3s-io/k3s","slug":"unable-to-parse-cidr-for-interface-s-w","errorCode":null,"errorMessage":"unable to parse CIDR for interface %s: %w","messagePattern":"unable to parse CIDR for interface (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/net.go","lineNumber":287,"sourceCode":"func getIPFromInterface(ifaceName string) (string, error) {\n\tiface, err := net.InterfaceByName(ifaceName)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\taddrs, err := iface.Addrs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif iface.Flags&net.FlagUp == 0 {\n\t\treturn \"\", fmt.Errorf(\"the interface %s is not up\", ifaceName)\n\t}\n\n\tglobalUnicasts := []string{}\n\tglobalUnicastsIPv6 := []string{}\n\tfor _, addr := range addrs {\n\t\tip, _, err := net.ParseCIDR(addr.String())\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"unable to parse CIDR for interface %s: %w\", iface.Name, err)\n\t\t}\n\t\t// if not IPv4 adding it on IPv6 list\n\t\tif ip.To4() == nil {\n\t\t\tif ip.IsGlobalUnicast() {\n\t\t\t\tglobalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String())\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif ip.IsGlobalUnicast() {\n\t\t\tglobalUnicasts = append(globalUnicasts, ip.String())\n\t\t}\n\t}\n\n\tif len(globalUnicasts) > 1 {\n\t\treturn \"\", fmt.Errorf(\"multiple global unicast addresses defined for %s, please set ip from one of %v\", ifaceName, globalUnicasts)\n\t}\n\tif len(globalUnicasts) == 1 && len(globalUnicastsIPv6) == 0 {\n\t\treturn globalUnicasts[0], nil","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/util/net.go#L269-L305","documentation":"For every address on the interface the code formats addr.String() and re-parses it with net.ParseCIDR; a parse failure returns this error. The kernel normally reports interface addresses in 'ip/prefix' form, so a failure indicates an address entry that is a bare IP or otherwise not CIDR-shaped - atypical address entries on that interface.","triggerScenarios":"Interfaces carrying address entries whose String() form is not 'ip/len': some point-to-point tunnels, unusual address families, or platform/Go combinations that report non-standard addr strings.","commonSituations":"Exotic devices (ppp, some tunnel setups) matched by name by mistake; Go stdlib differences across versions when enumerating unusual address types; unusual address families on an interface selected in config.","solutions":["Inspect what the interface actually reports: ip addr show dev <iface>","Remove the odd address or point the interface option at a clean interface","If a tunnel/p2p device was matched by mistake, correct the interface name in config","If a plain global-unicast interface triggers this, capture `ip addr` output and report upstream"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func addrsParseAsCIDR(name string) error {\n\tiface, err := net.InterfaceByName(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\taddrs, _ := iface.Addrs()\n\tfor _, a := range addrs {\n\t\tif _, _, err := net.ParseCIDR(a.String()); err != nil {\n\t\t\treturn fmt.Errorf(\"address %q on %s is not CIDR form\", a.String(), name)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := util.GetIPFromInterface(name); err != nil {\n\tif strings.Contains(err.Error(), \"unable to parse CIDR for interface\") {\n\t\t// dump `ip addr show dev <name>` and inspect the odd address entry\n\t}\n\treturn err\n}","preventionTips":["Avoid pointing the node at p2p/tunnel interfaces with non-prefix addresses","Inspect ip addr output when adding unusual address types to a node","Report repro cases upstream - this path indicates non-standard address reporting"],"tags":["go","network","interface","cidr","parsing"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}