{"record":{"id":"0a0c2caf72be0743","repo":"slackhq/nebula","slug":"unknown-address-type-v","errorCode":null,"errorMessage":"unknown address type %v","messagePattern":"unknown address type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"overlay/tun_freebsd.go","lineNumber":471,"sourceCode":"\t\t\t\tPreferred: 0,\n\t\t\t\tVltime:    0xffffffff,\n\t\t\t\tPltime:    0xffffffff,\n\t\t\t},\n\t\t\tFlags: IN6_IFF_NODAD,\n\t\t}\n\t\ts, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_DGRAM, syscall.IPPROTO_IP)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer syscall.Close(s)\n\n\t\tif err := ioctl(uintptr(s), OSIOCAIFADDR_IN6, uintptr(unsafe.Pointer(&ifr))); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set tun address %s: %s\", cidr.Addr().String(), err)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"unknown address type %v\", cidr)\n}\n\nfunc (t *tun) Activate() error {\n\t// Setup our default MTU\n\terr := t.setMTU()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlinkAddr, err := getLinkAddr(t.Device)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif linkAddr == nil {\n\t\treturn fmt.Errorf(\"unable to discover link_addr for tun interface\")\n\t}\n\tt.linkAddr = linkAddr\n","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/overlay/tun_freebsd.go#L453-L489","documentation":"addIp handles only IPv4 (Is4 family path) and IPv6 (Is6 path) addresses. If the configured netip.Prefix is neither (zero-value Prefix, or an unparseable fallback), it returns this error at the end of the function. It is a defensive guard — in practice it means the configured VPN network list contained a malformed or zero Prefix.","triggerScenarios":"Activate() → addIp() receiving a netip.Prefix that is neither Is4 nor Is6 — typically the zero value netip.Prefix{} resulting from a failed ParsePrefix whose error was ignored, or an empty/placeholder network list entry.","commonSituations":"Config parsing that swallows errors and stores zero-valued prefixes; building vpnNetworks programmatically with netip.PrefixFrom(0,0); template/placeholder config values never replaced.","solutions":["Validate all prefixes with netip.ParsePrefix and check the error at config load time","Reject the zero-value Prefix{} explicitly before constructing the tun","Log and skip invalid network entries instead of passing them to addIp","Check where vpnNetworks is populated for ignored parse errors"],"exampleFix":"// before\nnets = append(nets, netip.PrefixFrom(cfgNet, bits)) // may yield zero Prefix on bad input\n// after\np, err := netip.ParsePrefix(cfgNet)\nif err != nil {\n    return fmt.Errorf(\"invalid vpn network %q: %w\", cfgNet, err)\n}\nnets = append(nets, p)","handlingStrategy":"validation","validationCode":"func validateNetworks(nets []netip.Prefix) error {\n    for _, n := range nets {\n        if !n.IsValid() || (!n.Addr().Is4() && !n.Addr().Is6()) {\n            return fmt.Errorf(\"invalid vpn network prefix: %v\", n)\n        }\n    }\n    return nil\n}\n// call before newTun/Activate: validateNetworks(vpnNetworks)","typeGuard":"func isValidPrefix(p netip.Prefix) bool { return p.IsValid() && (p.Addr().Is4() || p.Addr().Is6()) }","tryCatchPattern":"if err := dev.Activate(); err != nil {\n    if strings.Contains(err.Error(), \"unknown address type\") {\n        return fmt.Errorf(\"config error: vpnNetworks contains an invalid/zero prefix: %w\", err)\n    }\n    return err\n}","preventionTips":["Always check the error from netip.ParsePrefix; never store zero-valued Prefix","Reject netip.Prefix{} and PrefixFrom(0,0) at config validation","Fuzz/validate the network list before constructing the device","Avoid placeholder config values that reach addIp unvalidated"],"tags":["freebsd","tun","address-family","config-validation","netip"],"backgroundTag":"invalid-address-family","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}