Skip to content

bridge: skip the IPAM CHECK when no IPAM plugin is configured - #1318

Merged
mlguerrero12 merged 1 commit into
containernetworking:mainfrom
spicysharkco:fix/bridge-check-without-ipam
Nov 9, 2026
Merged

mlguerrero12 merged 1 commit into
containernetworking:mainfrom
spicysharkco:fix/bridge-check-without-ipam

Conversation

@spicysharkco

Copy link
Copy Markdown
Contributor

A bridge network without an ipam type is L2-only. ADD, DEL and STATUS
already skip IPAM for it (n.IPAM.Type != ""), but CHECK does not.

Config: a bridge config with "ipam": {}, the L2-only form documented at
https://www.cni.dev/plugins/current/main/bridge/ and used by the existing
L2 specs, cniVersion 0.4.0 or later, and the prevResult returned by a
successful ADD.

Input: CNI_COMMAND=CHECK with that config.

Base output: no plugin name provided. The same failure comes from every
cniVersion that has CHECK (0.4.0, 1.0.0 and 1.1.0 in the specs; the 0.3.x
testers do not run CHECK).

Expected: CHECK validates the bridge, the veth pair and the container
interface from prevResult, as it does with IPAM, and returns no error.

Cause: ipam.ExecCheck(n.IPAM.Type, ...) runs unconditionally with an
empty type:

// run the IPAM plugin and get back the config to apply
err = ipam.ExecCheck(n.IPAM.Type, args.StdinData)
if err != nil {
return err
}

Fix: call it only when n.IPAM.Type is set, as macvlan, ipvlan, tap and
host-device do in their CHECK.

Visible change: CHECK on an L2-only bridge returns success (or the
normal prevResult validation errors) instead of no plugin name provided. Configs with an ipam type behave as before.

Test: a new ADD/DEL/CHECK spec for an L2-only bridge. cmdAddDelCheckTest
no longer loads the host-local config for an L2 case, since an L2 config
has no ranges. The spec fails at base for 0.4.0, 1.0.0 and 1.1.0 with
no plugin name provided (the 0.3.x tester does not run CHECK, so those
two pass either way), and passes at head.

go test -count=1 -run TestBridge ./plugins/main/bridge/ \
  -ginkgo.focus='l2 bridge and veth with ADD/DEL/CHECK'

Base: 2 passed, 3 failed. Head: 5 passed. Whole package at head:
343 passed, 0 failed.

A bridge config without an ipam type is an L2-only network. ADD, DEL
and STATUS already skip IPAM for it, but CHECK always called the IPAM
plugin with an empty name and failed with "no plugin name provided"
for a healthy L2-only bridge.

Only call the IPAM plugin in CHECK when an ipam type is set, as macvlan,
ipvlan, tap and host-device do. The remaining prevResult checks still
run.

Add an ADD/DEL/CHECK spec for an L2-only bridge and let
cmdAddDelCheckTest skip the host-local config load for it.

Signed-off-by: spicysharkco <321699413+spicysharkco@users.noreply.github.com>
@mlguerrero12
mlguerrero12 force-pushed the fix/bridge-check-without-ipam branch from 897b7f2 to 151c2d1 Compare November 9, 2026 14:53
@mlguerrero12
mlguerrero12 merged commit 49fe545 into containernetworking:main Nov 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants