Add a helper that lets you call a Python function (or lambda) in the
context of a network samespace.
Example:
with infamy.IsolatedMacVlan("eth0") as ns:
res = ns.call(lambda: subprocess.run(["ip", "link"],
capture_output=True))
print(res.stdout, f"\n[exitcode:{res.returncode}]")
The call to subprocess.run will be executed in the context of the
network namespace, and thus only list "lo" and the "iface"
macvlan.
The return value of the function passed to ns.call() is passed back
over a multiprocessing.Pipe, which requires that the object be
"picklable". This is true for most objects (even more complex ones
like the CompletedProcess object seen in the example above). Some
notable exceptions are things like file objects, sockets, etc.
The setns(2) syscall is unfortunately not available in current
versions of Python shipped with neither Ubuntu nor Alpine at the time
of this writing. Therefore, shoot from the hip, assume that we're
running on an x86_64 CPU, and just hotwire the syscall directly with
some constants we found in a dumpster.
Documentation
Infix is a Linux Network Operating System (NOS) based on Buildroot, and sysrepo. A powerful mix that ease porting to different platforms, simplify long-term maintenance, and provide made-easy management using NETCONF1 (remote) or the built-in command line interface (CLI) (click the foldout for an example).
Example CLI Session
The CLI configure context is automatically generated from the loaded YANG models and their corresponding sysrepo plugins. The following is brief example of how to set the IP address of an interface:
admin@infix-12-34-56:/> configure
admin@infix-12-34-56:/config/> edit interface eth0
admin@infix-12-34-56:/config/interface/eth0/> set ipv4 <TAB>
address autoconf bind-ni-name enabled
forwarding mtu neighbor
admin@infix-12-34-56:/config/interface/eth0/> set ipv4 address 192.168.2.200 prefix-length 24
admin@infix-12-34-56:/config/interface/eth0/> show
type ethernet;
ipv4 {
address 192.168.2.200 {
prefix-length 24;
}
}
ipv6
admin@infix-12-34-56:/config/interface/eth0/> diff
interfaces {
interface eth0 {
+ ipv4 {
+ address 192.168.2.200 {
+ prefix-length 24;
+ }
+ }
}
}
admin@infix-12-34-56:/config/interface/eth0/> leave
admin@infix-12-34-56:/> show interfaces
INTERFACE PROTOCOL STATE DATA
eth0 ethernet UP 52:54:00:12:34:56
ipv4 192.168.2.200/24 (static)
ipv6 fe80::5054:ff:fe12:3456/64 (link-layer)
lo ethernet UP 00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@infix-12-34-56:/> copy running-config startup-config
Click here for more details.
Infix can run on many different types of architectures and boards, much thanks to Linux and Buildroot. Currently the focus is on 64-bit ARM devices, optionally with switching fabric supported by Linux switchdev. The following boards are fully supported:
- Marvell CN9130 CRB
- Marvell EspressoBIN
- Microchip SparX-5i PCB135 (eMMC)
An x86_64 build is also available, primarily intended for development and testing, but can also be used for evaluation and demo purposes. For more information, see: Infix in Virtual Environments.
See the GitHub Releases page for our pre-built images. The Latest Build has the bleeding edge images, if possible we recommend using a versioned release.
For customer specific builds of Infix, see your product repository.
-
NETCONF or RESTCONF, https://datatracker.ietf.org/doc/html/rfc8040, for more information, see Infix Variants. ↩︎