{"record":{"id":"1d219246929e3830","repo":"netbirdio/netbird","slug":"link-by-name-w","errorCode":null,"errorMessage":"link by name: %w","messagePattern":"link by name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/iface/device/wg_link_freebsd.go","lineNumber":64,"sourceCode":"\tif err := l.link.SetMTU(mtu); err != nil {\n\t\treturn fmt.Errorf(\"set mtu: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (l *wgLink) up() error {\n\tif err := l.link.Up(); err != nil {\n\t\treturn fmt.Errorf(\"up: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (l *wgLink) assignAddr(address *wgaddr.Address) error {\n\tlink, err := freebsd.LinkByName(l.name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"link by name: %w\", err)\n\t}\n\n\tprefixLen := address.Network.Bits()\n\tmaskBits := uint32(0xffffffff) << (32 - prefixLen)\n\tmask := fmt.Sprintf(\"0x%08x\", maskBits)\n\n\tlog.Infof(\"assign addr %s mask %s to %s interface\", address.IP, mask, l.name)\n\n\tif err := link.AssignAddr(address.IP.String(), mask); err != nil {\n\t\treturn fmt.Errorf(\"assign addr: %w\", err)\n\t}\n\n\tif address.HasIPv6() {\n\t\tlog.Infof(\"assign IPv6 addr %s to %s interface\", address.IPv6String(), l.name)\n\t\tcmd := exec.Command(\"ifconfig\", l.name, \"inet6\", address.IPv6String())\n\t\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\t\tlog.Warnf(\"failed to assign IPv6 address %s to %s, continuing v4-only: %s: %v\", address.IPv6String(), l.name, string(out), err)\n\t\t\taddress.ClearIPv6()","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/client/iface/device/wg_link_freebsd.go#L46-L82","documentation":"At the start of freebsd wgLink.assignAddr, freebsd.LinkByName(l.name) runs `ifconfig <name>` to obtain the interface object; failure is wrapped as 'link by name'. LinkByName itself can fail on a missing interface (parsed ifconfig output), unparseable output, a name mismatch (ErrNameDoesNotMatch), or a generic command failure. This is the IPv4 configuration path, so it is fatal.","triggerScenarios":"The wg interface does not exist at assignment time (creation failed earlier or the interface was destroyed), ifconfig missing from PATH, or ifconfig output that cannot be parsed.","commonSituations":"Race between interface creation and address assignment; leftover name conflicts; running inside a jail where the interface is not visible.","solutions":["Run `ifconfig <name>` manually right before starting the agent to confirm the interface exists","Check earlier log lines for a failed create step that made the interface absent","Ensure stable interface naming and adequate privileges","Verify ifconfig is present in PATH for the daemon"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// fail early if the interface is not visible\nif _, err := freebsd.LinkByName(ifaceName); err != nil {\n    return fmt.Errorf(\"interface %s not found before assign: %w\", ifaceName, err)\n}","typeGuard":null,"tryCatchPattern":"if err := link.assignAddr(addr); err != nil {\n    if errors.Is(err, freebsd.ErrDoesNotExist) {\n        // interface absent: recreate it and retry assignment\n    }\n    return err\n}","preventionTips":["Verify interface existence immediately before configuration steps","Ensure creation succeeded before assigning addresses","Check jail/vnet visibility of the interface"],"tags":["freebsd","ifconfig","interface","ip-address","go"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}