-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rudimentary support of VPP #290529
base: master
Are you sure you want to change the base?
Rudimentary support of VPP #290529
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ pkgs, config, lib, ... }: | ||
let | ||
inherit (lib) mkEnableOption mkPackageOption mkIf types mkOption; | ||
cfg = config.services.vpp; | ||
in | ||
{ | ||
options.services.vpp = { | ||
enable = mkEnableOption '' | ||
vector packet processing framework. | ||
|
||
VPP replaces the Linux network stack by a userspace-based network stack, | ||
driven by `vppctl`. You can enable the Linux Control Plane to continue | ||
to interop with Linux APIs. | ||
''; | ||
|
||
package = mkPackageOption pkgs "vpp" { }; | ||
|
||
configFile = mkOption { | ||
type = types.path; | ||
description = "VPP configuration file for startup"; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
users.groups.vpp = {}; | ||
environment.systemPackages = [ cfg.package ]; | ||
boot.kernel.sysctl = { | ||
"vm.nr_hugepages" = lib.mkDefault 1024; | ||
"max_map_count" = lib.mkDefault 3096; | ||
"hugetlb_shm_group" = lib.mkDefault 0; | ||
# Assert that shm max ≥ total size of hugepages. | ||
"shmmax" = lib.mkDefault 2147483648; | ||
}; | ||
systemd.services.vpp = { | ||
description = "Vector Packet Processing process"; | ||
after = [ "syslog.target" "network.target" "auditd.service" ]; | ||
serviceConfig = { | ||
ExecStartPre = [ | ||
"-${pkgs.coreutils}/bin/rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api" | ||
"-/run/current-system/sw/bin/modprobe uio_pci_generic" | ||
]; | ||
|
||
ExecStart = "${cfg.package}/bin/vpp -c ${cfg.configFile}"; | ||
Type = "simple"; | ||
Restart = "on-failure"; | ||
RestartSec = "5s"; | ||
RuntimeDirectory = "vpp"; | ||
}; | ||
wantedBy = [ "multi-user.target" ]; | ||
}; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ./make-test-python.nix ({ pkgs, lib, ... }: | ||
{ | ||
name = "vpp"; | ||
|
||
meta = with pkgs.lib.maintainers; { | ||
maintainers = [ raitobezarius ]; | ||
}; | ||
|
||
nodes = { | ||
node = { ... }: { | ||
# Clearly, VPP is hungry of hugepages… | ||
virtualisation.memorySize = 4096; | ||
services.vpp = { | ||
enable = true; | ||
configFile = pkgs.writeText "startup.conf" '' | ||
unix { | ||
nodaemon | ||
nosyslog | ||
full-coredump | ||
cli-listen /run/vpp/cli.sock | ||
} | ||
|
||
api-trace { | ||
on | ||
} | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
start_all() | ||
node.wait_for_unit("multi-user.target") | ||
node.wait_for_unit("vpp.service") | ||
node.succeed("vppctl show version | grep -i nixos") | ||
node.succeed("vppctl show interface | grep -i local0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since |
||
''; | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ lib | ||
, stdenv | ||
, fetchFromGitHub | ||
, cmake | ||
, openssl | ||
, python3 | ||
, subunit | ||
, dpdk | ||
, mbedtls_2 | ||
, rdma-core | ||
, libnl | ||
, libmnl | ||
, libpcap | ||
, check | ||
, fetchpatch | ||
}: | ||
|
||
stdenv.mkDerivation rec { | ||
pname = "vpp"; | ||
version = "23.10"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "FDio"; | ||
repo = "vpp"; | ||
rev = "v${version}"; | ||
hash = "sha256-YcDMDHvKIL2tOD98hTcuyQrL5pk80olYKNWiN+BA49U="; | ||
}; | ||
|
||
patches = [ | ||
# Important fix part of 24.02 for the Linux Control Plane. | ||
(fetchpatch { | ||
name = "fix-looping-netlink-messages.patch"; | ||
url = "https://gerrit.fd.io/r/changes/vpp~39622/revisions/9/patch?download"; | ||
decode = "base64 -d"; | ||
stripLen = 1; | ||
hash = "sha256-0ZDKJgXrmTzlVSSapdEoP27znKuWUrnjTXZZ4JrximA="; | ||
}) | ||
# Does not apply cleanly. | ||
# (fetchpatch { | ||
# name = "fix-optional-labels-for-prometheus.patch"; | ||
# url = "https://gerrit.fd.io/r/changes/vpp~40199/revisions/4/patch?download"; | ||
# decode = "base64 -d"; | ||
# stripLen = 1; | ||
# hash = "sha256-exuR4DucNtER2t1ecsjuNxzmhfZkhx6ABeeXmf/qQ4U="; | ||
# }) | ||
]; | ||
|
||
postPatch = '' | ||
patchShebangs scripts/ | ||
substituteInPlace CMakeLists.txt \ | ||
--replace "plugins tools/vppapigen tools/g2 tools/perftool cmake pkg" "plugins tools/vppapigen tools/g2 tools/perftool cmake" | ||
''; | ||
|
||
preConfigure = '' | ||
echo "${version}-nixos" > scripts/.version | ||
scripts/version | ||
''; | ||
|
||
postConfigure = '' | ||
patchShebangs ../tools/ | ||
patchShebangs ../vpp-api/ | ||
''; | ||
|
||
sourceRoot = "source/src"; | ||
|
||
cmakeFlags = [ "-DVPP_PLATFORM=default" ]; | ||
|
||
# A bunch of GCC13 warnings I suppose. | ||
env.NIX_CFLAGS_COMPILE = "-Wno-array-bounds -Wno-error"; | ||
|
||
nativeBuildInputs = [ | ||
cmake | ||
]; | ||
|
||
buildInputs = [ | ||
openssl | ||
subunit | ||
dpdk | ||
rdma-core | ||
mbedtls_2 | ||
check | ||
libnl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the version of libnl? The Linux Control Plane wants >=3.7.0 for certain operations (like inter-family nexthop, and all MPLS). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3.7.0, we usually have latest released versions, but I can hard assert on the libnl version to offer warnings to users. |
||
libmnl | ||
libpcap | ||
(python3.withPackages (ps: [ ps.ply ])) | ||
]; | ||
|
||
meta = with lib; { | ||
description = ""; | ||
homepage = "https://github.com/FDio/vpp"; | ||
license = licenses.asl20; | ||
maintainers = with maintainers; [ raitobezarius ]; | ||
mainProgram = "vpp"; | ||
platforms = platforms.all; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be aware that many deployments will use vfio_pci kernel module instead of uio_pci_generic.
Perhaps load them both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, will do