{"record":{"id":"9a04245bc8cc86c6","repo":"cilium/cilium","slug":"xdp-mode-conflict-trying-to-set-conflicting-modes","errorCode":null,"errorMessage":"XDP mode conflict: trying to set conflicting modes %s and %s","messagePattern":"XDP mode conflict: trying to set conflicting modes (.+?) and (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/datapath/xdp/xdp.go","lineNumber":106,"sourceCode":"\t\t\t// that's the default. If an enabler wishes to enforce that\n\t\t\t// XDP is disabled, it should use a verifier.\n\t\t\tif e.mode == AccelerationModeDisabled {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Ensure ModeNative takes precedence over ModeBestEffort.\n\t\t\t// It doesn't make sense the other way around.\n\t\t\tif e.mode == AccelerationModeBestEffort && cfg.mode == AccelerationModeNative {\n\t\t\t\tcontinue\n\t\t\t} else if cfg.mode == AccelerationModeBestEffort && e.mode == AccelerationModeNative {\n\t\t\t\tcfg.mode = e.mode\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// If a mode has been set and the enabler requests a conflicting\n\t\t\t// mode, then raise an error.\n\t\t\tif cfg.mode != AccelerationModeDisabled {\n\t\t\t\treturn cfg, fmt.Errorf(\"XDP mode conflict: trying to set conflicting modes %s and %s\",\n\t\t\t\t\tcfg.mode, e.mode)\n\t\t\t}\n\n\t\t\tcfg.mode = e.mode\n\t\t}\n\t}\n\n\t// Perform validation at the end, when the config is fully determined,\n\t// to ensure that processing order does not play a role in the validation.\n\tfor _, v := range allValidators {\n\t\tif err := v(cfg.AccelerationMode(), cfg.Mode()); err != nil {\n\t\t\treturn cfg, err\n\t\t}\n\t}\n\n\treturn cfg, nil\n}\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/datapath/xdp/xdp.go#L88-L124","documentation":"newConfig walks all registered XDP enablers; once one enabler sets a non-disabled mode, a later enabler requesting a different non-disabled mode is a conflict. The config is rejected because only a single XDP acceleration mode can be active on the datapath. Disabled can coexist with setting a mode, but two distinct enabled modes cannot.","triggerScenarios":"Registering multiple XDP enablers where one sets e.g. AccelerationModeNative and another sets AccelerationModeGeneric (or best-effort) before newConfig runs; e.g. bpf-lb-acceleration and another feature both requesting XDP with different modes.","commonSituations":"Enabling multiple cilium features that each want to attach XDP with different acceleration settings (e.g. nodeport with native acceleration plus a generic-mode feature); user sets both --bpf-lb-acceleration=generic and a policy needing native mode.","solutions":["Set the same acceleration mode for all features/enablers requesting XDP","Disable XDP acceleration in one of the conflicting features (use AccelerationModeDisabled)","Reorder/consolidate configuration so only one component sets the XDP mode","Check which features attach XDP enablers via cilium-dbg and agent debug logs"],"exampleFix":"// before\nnewXDP(cfg, WithXDPMode(AccelerationModeNative), WithXDPMode(AccelerationModeGeneric))\n// after\nnewXDP(cfg, WithXDPMode(AccelerationModeNative), WithXDPMode(AccelerationModeNative))","handlingStrategy":"validation","validationCode":"if requestedMode != AccelerationModeDisabled && configuredMode != AccelerationModeDisabled && requestedMode != configuredMode {\n\treturn fmt.Errorf(\"conflicting xdp modes: %s vs %s\", configuredMode, requestedMode)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := newXDP(cfg, opts...)\nif err != nil {\n\tif strings.Contains(err.Error(), \"XDP mode conflict\") {\n\t\tlog.Warn(\"falling back to disabled XDP due to mode conflict\")\n\t\tcfg, err = newXDP(cfg, WithXDPMode(AccelerationModeDisabled))\n\t}\n\tif err != nil { return err }\n}","preventionTips":["Standardize one acceleration mode across all features that enable XDP","Audit all WithXDPMode call sites for consistency","Disable XDP explicitly in features that do not require it"],"tags":["xdp","datapath","config-conflict"],"backgroundTag":"conflicting-configuration-values","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}