Skip to content

Replace podman with our own ixcont - #1789

Open
rical wants to merge 13 commits into
mainfrom
ixcont
Open

rical wants to merge 13 commits into
mainfrom
ixcont

Conversation

@rical

@rical rical commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Description

This replaces podman with ixcont, a small Python layer on top of crun
that we own, and drops CNI in favour of plain ip and nftables.

Why. We ship container images inside the read-only system image, but
podman had to unpack them into /var/lib/containers before running
them. That cost flash writes and boot time, and it left containers and
images behind when a container was removed from the startup-config
while the unit was off. Should close #1614.

What you get.

  • Embedded images are flattened at build time into /lib/oci/NAME and
    run straight from the squashfs. Nothing is unpacked at boot.
  • Runtime state lives in tmpfs. Pull the plug, or remove a container
    from the config, and only its named volumes remain.
  • Finit supervises the container directly, no conmon.
  • Networking is ours: a regular confd bridge, host interfaces moved
    into a named netns, per-interface forwarding, and one nftables table
    for masquerading and published ports.
  • Images can still be fetched as OCI archives over http(s)/ftp or
    pulled from a registry, now with skopeo.
  • podman, conmon, cni-plugins, k8s-logger and iptables are gone from
    the image.

What changes for users.

  • The YANG model is untouched and existing configurations keep working.
  • ixcont replaces podman and the old container script in the
    shell.
  • Gone from the CLI: container remove, container save, the port and
    detach options of container run, the checksum option of
    container load, and show container images all.
  • Container names may no longer contain a period.

For reviewers. One commit per subsystem: skopeo package, ixcont,
curiOS images, confd, yangerd, klish, build, test, doc. The part that
deserves the closest look is src/ixcont/ixcont/oci.py, which unpacks
untrusted image layers. Image signatures are not verified yet.

Known gaps compared to podman.

  • Embedded images are flattened as the build user, so file ownership
    inside them becomes root. Fine for the curiOS images, not for an
    image with non-root owned data.
  • docker-archive: and dir: image references only work when the
    content is an OCI layout. podman handled both natively.

Follow-ups.

  • No YANG revision yet: descriptions still mention podman, and the name
    restriction is enforced in confd, not in the model.
  • Registry pulls have no test coverage, as before.

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@rical rical changed the title Ixcont Replace podman with our own ixcont Nov 11, 2026
@troglobit
troglobit marked this pull request as ready for review November 11, 2026 17:49
@troglobit

Copy link
Copy Markdown
Contributor

I'm marking this ready for review, because all this looks fantastic and I see no reason holding it any longer. I'll do a proper read tomorrow. Thank you so much for this amazing work!

@wkz wkz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the way to go, for sure! 💯

Some things that struck me reading through this:

  • Are we still ceding too much control of network setup to ixcont in the pursuit of backwards compatibility? Now that we're getting rid of podman, it seems like we have a golden opportunity to remove all of the implicit networking features from it (CNI bridges with implicit nft rules, IP forwarding etc.), and let confd control all of it like any other interface setup.
  • I have probably not expressed this clearly at all, but what I meant by "running from a SquashFS", was to loopback mount a squashfs image and use that as the rootfs for a container; not to unpack an OCI archive into the Infix image at build-time (although that might also be a nice feature). This is why (AFK) I was going on about Apptainer and Singularity Image Format (SIF) images. This should also enable us to start containers from the System's own rootfs.
  • I would really like us to verify that whatever way we choose to go, we can create a container, specify no image (which would mean: use the system's rootfs) and launch e.g., a dnsmasq, frr, nft or httpd container with a custom config as a content mount. This should also remove the need to ship separate CuriOS images for this purpose. Again, as mentioned AFK, this means we should probably ship tini in Infix.

@troglobit troglobit left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agree with @wkz here. We should take this opportunity drop all CNI networking, including the awkward configuration syntax for that, this requires some clever migration script and a bit more logic, but so worth it.

@mattiaswal

mattiaswal commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Security review by Claude Mythos 5.2 (claude-mythos-5-2) of src/ixcont and the confd changes, at 6ca2005. Read from the code, only the first item was reproduced (locally, with oci.py and a two-member tar). Not run on a DUT.

High

1. A layer can chmod/chown any host directory (oci.py, _apply_layer, the directory attribute pass at the end)

The pass uses os.path.join(rootfs, m.name), but a later member in the same layer can have replaced a parent with a symlink. A layer with directory a/etc (mode 0777) followed by symlink a -> / ends with chown/chmod/utime on the host's /etc. With the PR's oci.py a directory outside the rootfs went from 0700 to 0777. Images are not verified and http/ftp is allowed, so the layer is attacker data.

Fix: resolve the path again with inside() in that pass, or go through a directory fd opened with O_NOFOLLOW.

Medium

2. oci-load name is used as a path (image.py, load())

name becomes the cache directory name and its YANG type, image-reference, allows / and ... oci.flatten() removes dst and dst.tmp and renames the unpacked image into place, so x/../../../../etc/foo deletes and replaces a directory anywhere. Only for a local source that is a valid OCI archive or layout, URL and registry sources ignore name. The RPC has no nacm:default-deny-all.

Fix: reject / in the name.

3. /run/containers/<name> is world-accessible

Created with os.makedirs defaults, podman's storage was under the 0700 /var/lib/containers.

  • The overlay at /run/containers/<name>/rootfs is its own mount, without nosuid/nodev. A local user on the host can run a setuid-root binary that the container or the image put there, or open a device node from the image.
  • config.json (all env values), state.json and the files/ content mounts are readable by local users. confd writes the source JSON 0600 and the old content directory was 0700.

Fix: create /run/containers and each runtime directory 0700.

4. Interface names from inside the container reach the host (net.py, _moved()/_teardown())

Every link whose ifalias names no existing host interface is given back and renamed to that alias. A container with net_admin sets the alias, so on teardown it puts an interface with a name of its choosing in the host namespace. Same class as the "interface names read from inside a container" fix.

Fix: only give back the interfaces recorded in the container's state.

Low

  • Volume seeding (cli.py, _volumes()) uses shutil.copytree on the image. A char device or FIFO in the volume target blocks setup or fills /var.
  • One bad publish entry breaks NAT for all containers: the nftables ruleset is one transaction, and the pattern allows what nft rejects, e.g. 80:80/foo or a bracketed IPv6 host address. The old rules stay.
  • A container named net or ipam gets /run/containers/net or /run/containers/ipam as its runtime directory, removing it wipes all container network descriptions or leases.
  • curl -u and skopeo --src-creds put credentials on the command line.
  • Build-time flattening makes everything root-owned (noted in the description), so a setuid file owned by another user in an image becomes setuid root in /lib/oci.
  • No size or time limit on fetch, pull or unpack.

Checked and fine

  • Config reaches ixcont as JSON and every command is an argv list, the old shell quoting problems are gone.
  • Member paths, hardlinks and whiteouts in _apply_layer stay inside the rootfs, only the deferred directory pass escapes.
  • The outer archive is extracted with the data filter, target Python is 3.12.14.
  • Capabilities, masked and read-only paths match podman's defaults, the device cgroup denies all unless privileged. No seccomp profile, same as before (seccomp_profile = "unconfined").

rical added 13 commits November 25, 2026 08:36
Buildroot only builds skopeo for the host.  Infix needs it on the
target to pull images from registries, it is the same registry client
podman used: TLS, tokens, manifest lists and digest pinning.  Built
with the Go OpenPGP implementation and without storage drivers, it only
ever copies into OCI layouts for ixcont to unpack.

Signed-off-by: Richard Alpe <richard@bit42.se>
Infix embeds container images in the read-only system image, yet podman
unpacked every image into /var/lib/containers at first boot, hashed the
archive twice on every boot, and left containers and images behind when
a container was removed from the configuration while the unit was off.
Both podman and CNI had to be worked around rather than used.

ixcont is a small Python layer over crun.  An image is a flat rootfs
directory with its OCI config: embedded ones are unpacked at build time
into /lib/oci and used in place as the overlay lower, fetched ones are
unpacked once into /var/lib/containers/images.  Per container, the
Finit pre: hook builds the OCI bundle in /run/containers/<name> from the
JSON confd writes, with the overlay upper in tmpfs, named volumes on
flash and content mounts as files.  crun starts the container detached
and writes the PID of its init, which Finit supervises directly, like
it supervised conmon.

Finit also restarts a container that exits, by its restart policy:
restart:always, restart:10 for retry, with its back-off between the
attempts, and norestart for never.  The option is on the service line,
which is that of a template, so there is one template per policy, made
from the same file.  Finit calls the post: hook for a container it has
stopped, and with oncrash:script when it gives up, to tear down and
record the exit, and to clear the container's condition: a reload for a
change elsewhere in the configuration would otherwise start it again.

Nothing of a container outlives its configuration.  All runtime state
is in tmpfs.  Finit only runs a cleanup: script for a service that is
removed while it runs, so the post: hook removes the runtime directory
itself when the configuration is gone, and confd asks for the same for
a container that had stopped before it was deleted.  State is never
written for a container without a runtime directory, the hooks of a
container and of its interfaces may run in any order.  At boot, once
confd has applied the startup configuration, a reconcile task prunes
the fetched images no configured container refers to.  It never
fetches anything itself.  The directories confd writes to when it
applies that configuration are made before, with the tmpfiles of the
package.

Images come from an OCI archive or layout, local or over http(s) and
ftp, or from a registry.  skopeo does the pulling, the registry client
podman used, into an OCI layout that is unpacked like an archive.  A
fetched image is fetched once, retried on network changes until that
succeeds, and fetched again only by the upgrade action.  It lists the
references it was fetched as, and only an exact match is reused: the
name of its directory says too little to tell two registries or two
tags apart.  A policy that accepts any image and a registries.conf
searching docker.io for unqualified names ship with the package,
signatures are for later.

A layer is untrusted input.  Every path in it is resolved the way the
container will see it, so a symlink, an absolute target or a .. never
leads out of the rootfs, for extraction, whiteouts and hard links
alike, and for the files the host later reads through the rootfs: the
image's passwd and group, and the directory a new volume is seeded
from.  File owners are the numeric IDs of the layer.

Networking is done with ip(8) and nftables, no CNI: each container
with interfaces gets a named netns, host interfaces are moved in with
their configured addresses and routes, bridge networks get a veth
pair, an address from the bridge's subnet, masquerading and published
ports as rules in table inet ixcont, regenerated from all container
state on every change.  Finit starts containers in parallel, so the
address leases and the ruleset are updated under a lock.  The host's
name of a moved interface is kept in ifalias, and teardown gives back
every interface whose alias is not on the host, whether or not the
setup got far enough to record it.

An unprivileged container gets podman's default capabilities, masked
and read-only paths, and its own cgroup namespace.  Root in the
container holds the allowed capabilities and passes none on, any other
user holds only what the configuration adds.

Signed-off-by: Richard Alpe <richard@bit42.se>
The embedded images are now flattened into /lib/oci/<name>/ by the
ixcont flattener at build time instead of shipping the OCI archive, so
the container runs straight from the read-only rootfs with nothing to
unpack or copy at boot.  The -latest symlink points at the directory.

Signed-off-by: Richard Alpe <richard@bit42.se>
Write each container's configuration as JSON, with the hostname
resolved, to /run/containers/<name>.json for ixcont to build the OCI
bundle from, instead of a podman command line in a shell script.  The
Finit instance is enabled as before, of the template for the restart
policy of the container, and the usr/container-<name> condition
replaces the manual handling: set unless the container is manual,
cleared to stop it without a restart.  The sha256 of the image
archive is no longer computed on every boot; the container is always
recreated from its configuration and the unpacked image, which is
cheap.

The container name is part of that condition, where a period has a
meaning of its own, so a name with one is rejected.  When a container
is deleted its configuration file goes first, which is what tells
ixcont to leave nothing behind, and ixcont is asked to remove the
state of one that had already stopped, which Finit has no hook for.

cni.c becomes ctrnet.c: instead of CNI conflists it writes the
container network to /run/containers/net/<ifname>.json, the type and
the addresses and routes of a host interface or the subnets of a
bridge.  A container bridge is a regular bridge that confd creates,
with the gateway address of each subnet and forwarding enabled on that
interface only, no global ip_forward.  The old container script and
its Finit template are replaced by the ixcont package.

Signed-off-by: Richard Alpe <richard@bit42.se>
The container monitor follows /run/containers with inotify, where
ixcont writes a state file when a container is created, started (OCI
poststart hook) and stopped, instead of a podman events stream.  The
collector reads the state files, asks crun whether the container runs
and takes limits and usage from the cgroup tree and the netns counters.
ctrnet gets the container networks from the same state files; the
named netns per container and the ifalias convention are unchanged.

A container whose setup failed has no image yet, so empty identity
leaves are left out rather than failing the YANG patterns and dropping
the entry.

Signed-off-by: Richard Alpe <richard@bit42.se>
Same admin-exec grammar, backed by ixcont.  The podman-only prune of
the storage graph and 'show container usage' of podman system df map
to ixcont prune and usage, 'container pull' takes a registry reference
as before.  Gone with podman's image store are 'container remove' and
'container save', the port and detach options of 'container run', the
checksum option of 'container load' and 'show container images all'.

Signed-off-by: Richard Alpe <richard@bit42.se>
Drop podman, conmon, cni-plugins, k8s-logger, the podman registry
configuration and the directories made at boot for podman and CNI, gate
the container support in confd, statd and klish on
BR2_PACKAGE_IXCONT.

iptables goes too.  podman selected it for CNI's port forwarding, and
the defconfigs enabled the iptables-nft tools on top of that.  With
podman gone there is no user left: firewalld and confd emit nftables,
and nothing in the tree uses the tc ipt/xt action, the one thing
iproute2 built against libxtables.  The iptables and ip6tables
commands disappear from the image.

The support archive collects the ixcont state and bundle per container
instead of podman inspect.

Signed-off-by: Richard Alpe <richard@bit42.se>
The embedded images are directories now, and the two tests that called
podman or the container script directly use ixcont.  The stray
container prune before the suite is no longer needed: a container
removed from the configuration leaves nothing behind.

The basic test's memory limit goes from 512 KiB to 64 MiB.  With the
image used read-only straight from the squashfs its page cache is
charged to the container, so 512 KiB is OOM-killed before init runs;
podman had already read the image into the page cache from another
cgroup when loading it.  The test still verifies that the limit is
applied and reported.

Signed-off-by: Richard Alpe <richard@bit42.se>
Signed-off-by: Richard Alpe <richard@bit42.se>
The container bridge was podman's way of connecting containers: a
bridge that made VETH pairs, handed out addresses from a pool,
masqueraded and published ports, all on its own and beside the bridges,
addresses and firewall the rest of the configuration describes.  It
came along when ixcont replaced podman, as code of our own.

An interface set as container-network is now only handed to its
container, with its addresses and the routes to add inside.  What it
connects to is set up like any other interface: a regular bridge with a
VETH pair, IP forwarding on the interfaces, port forwarding and
masquerading in the firewall.  The container-network type and subnets
are gone from the model, as are the published ports and the ip, ip6
and mac options of a container; the addresses and MAC address of the
interface itself are used.

In ixcont that leaves moving an interface into the container's
namespace and giving it back.  The address leases and the lock around
them, the nftables table and the VETH pairs go, and with the table the
dependency on nftables.  The published ports go from the operational
data and from the WebUI, which read but never showed them.

Configurations are migrated so they still load.  A container bridge is
removed, it existed for its containers only and nothing of it carries
over, with the references to it from containers, bridge ports and
firewall zones.  Published ports go, and the type and subnets are
dropped from the interfaces that were moved into a container, which
work as before.  A container that was on a bridge starts without that
connection until it is set up again the new way.

The bridge test builds that new way from what remains: a bridge with an
address, a VETH pair with one end as a bridge port and the other in the
container with a static address and a default route, and a port
forward in the firewall.

Signed-off-by: Richard Alpe <richard@bit42.se>
An image was a directory: unpacked at build time for the ones in the
system image, on flash for the fetched ones.  Unpacking is what we
wanted away from, it was only gone for the embedded images, and it put
a layer unpacker of our own between an untrusted image and the file
system.

A container now runs from one file in the Singularity Image Format, a
SquashFS with a header to find it by, loop mounted read-only below the
same overlay as before.  The file carries the OCI config, verbatim, and
where the image came from.  A SIF image is used as it is, from the
system image, a file or a URL.  An OCI image, from a registry or an
archive, is converted when it is fetched: the layers are merged into
one tar stream, whiteouts resolved, that sqfstar turns into the
SquashFS.  Nothing is unpacked on the way, so a layer has no file
system to write outside of, and owners, modes and devices survive a
conversion done by a regular user at build time, which the unpacked
directories did not.

A fetched image is one file named after its reference, replaced by an
upgrade, so the list of references per image is not needed.  What an
interrupted fetch left behind is removed at the next boot.  The other
skopeo transports, docker-archive: and dir:, go the same way as a
registry image, they were accepted but could not work.

The images in the system image are built as /lib/oci/NAME.sif and run
as they are, so there is no listing of archives to load first.  An
image may be given as a plain file name, and a configuration naming
the archive an embedded image once was still finds it.

Nothing is signed or verified yet.  Every image is opened in one place
for that check to go, and a converted image is unsigned by nature.  An
image without an OCI config, like one built by Apptainer, runs the
command of its container configuration.

Signed-off-by: Richard Alpe <richard@bit42.se>
Much of what a container is used for on a device is already in the
system: a web server, DNS and DHCP, routing, a packet filter.  Running
a second, separate instance of one of them took an image of its own,
built, shipped and upgraded beside the system that has the same
software.

A container without an image now gets the root file system of the
system image for its read-only root, where a SIF image has its
SquashFS, and all else is as for any container.  The running system's
/etc, /var, /cfg and /home are mounts of their own, so the container
sees the system as it was shipped, not as it is configured, and gets
its configuration as content mounts.  The system has no init for a
container, tini starts the command, which the container then must
have.  Its image ID is the version of the system, which it follows.

The test runs the web server of the system this way, with a page from
the configuration.

Signed-off-by: Richard Alpe <richard@bit42.se>
A container that exits is started again as its restart policy says:
never, 10 times, or always.  One that is no longer started stays that
way when other configuration changes, until the start action is called.
The containers run a command of the system, without an image.

Signed-off-by: Richard Alpe <richard@bit42.se>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Stray containers are not pruned

4 participants