feat: init small iproute2
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 15s
build liminix / build_vm_qemu_mips (pull_request) Successful in 16s
build liminix / test_shell_customization (pull_request) Successful in 16s
build liminix / test_hostapd (pull_request) Successful in 16s
All checks were successful
build liminix / build_zyxel-nwa50ax_mips (pull_request) Successful in 15s
build liminix / build_vm_qemu_mips (pull_request) Successful in 16s
build liminix / test_shell_customization (pull_request) Successful in 16s
build liminix / test_hostapd (pull_request) Successful in 16s
This commit is contained in:
parent
1322de1ee0
commit
454ecb7e0a
11 changed files with 388 additions and 0 deletions
|
@ -66,6 +66,7 @@ in {
|
|||
go-l2tp = callPackage ./go-l2tp {};
|
||||
hi = callPackage ./hi {};
|
||||
ifwait = callPackage ./ifwait {};
|
||||
iproute2-small = callPackage ./iproute2-small {};
|
||||
initramfs-peek = callPackage ./initramfs-peek {};
|
||||
kernel-backport = callPackage ./kernel-backport {};
|
||||
kmodloader = callPackage ./kmodloader {};
|
||||
|
|
97
pkgs/iproute2-small/default.nix
Normal file
97
pkgs/iproute2-small/default.nix
Normal file
|
@ -0,0 +1,97 @@
|
|||
{ lib, stdenv, fetchurl
|
||||
, buildPackages, bison, flex, pkg-config
|
||||
, libelf, libnl-tiny
|
||||
, gitUpdater, breakpointHook, libmnl, db
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "iproute2";
|
||||
version = "6.7.0";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://kernel/linux/utils/net/${pname}/${pname}-${version}.tar.xz";
|
||||
hash = "sha256-/5Qt2YKNfR+Gf2H+cs5DMHjDHl2OSnjiDwLLWJLohB0=";
|
||||
};
|
||||
|
||||
LDFLAGS = "-Wl,--gc-sections -Wl,--as-needed"; # -flto=auto -fuse-linker-plugin
|
||||
CFLAGS = "-ffunction-sections -fdata-sections -Os -pipe -mno-branch-likely"; # -flto=auto -fno-fat-lto-objects
|
||||
CXXFLAGS = "-ffunction-sections -fdata-sections -Os -pipe -mno-branch-likely"; # -flto=auto -fno-fat-lto-objects
|
||||
|
||||
|
||||
patches = [
|
||||
./patches/120-no_arpd_ifstat_rtacct_lnstat.patch
|
||||
./patches/130-no_netem_tipc_dcb_man_vdpa.patch
|
||||
./patches/140-allow_pfifo_fast.patch
|
||||
./patches/160-libnetlink-pic.patch
|
||||
./patches/170-ip_tiny.patch
|
||||
./patches/175-reduce-dynamic-syms.patch
|
||||
./patches/180-drop_FAILED_POLICY.patch
|
||||
./patches/190-fix-nls-rpath-link.patch
|
||||
./patches/195-build_variant_ip_tc.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
# Don't try to create /var/lib/arpd:
|
||||
sed -e '/ARPDDIR/d' -i Makefile
|
||||
|
||||
substituteInPlace Makefile \
|
||||
--replace "CC := gcc" "CC ?= $CC"
|
||||
'';
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
makeFlags = [
|
||||
"PREFIX=$(out)"
|
||||
"SBINDIR=$(out)/sbin"
|
||||
"DOCDIR=$(TMPDIR)/share/doc/${pname}" # Don't install docs
|
||||
"HDRDIR=$(dev)/include/iproute2"
|
||||
|
||||
"V=1"
|
||||
|
||||
"BUILD_VARIANT=ip"
|
||||
] ++ lib.optionals stdenv.hostPlatform.isStatic [
|
||||
"SHARED_LIBS=n"
|
||||
# all build .so plugins:
|
||||
"TC_CONFIG_NO_XT=y"
|
||||
] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
|
||||
"HOSTCC=$(CC_FOR_BUILD)"
|
||||
];
|
||||
|
||||
buildFlags = [
|
||||
"CONFDIR=/etc/iproute2"
|
||||
];
|
||||
|
||||
installFlags = [
|
||||
"CONFDIR=$(out)/etc/iproute2"
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
rm -r $out/share
|
||||
rm -r $out/lib
|
||||
'';
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ]; # netem requires $HOSTCC
|
||||
nativeBuildInputs = [ bison flex pkg-config ];
|
||||
buildInputs = [
|
||||
# db
|
||||
# libelf
|
||||
# libnl-tiny
|
||||
# libmnl
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
passthru.updateScript = gitUpdater {
|
||||
# No nicer place to find latest release.
|
||||
url = "https://git.kernel.org/pub/scm/network/iproute2/iproute2.git";
|
||||
rev-prefix = "v";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://wiki.linuxfoundation.org/networking/iproute2";
|
||||
description = "A collection of utilities for controlling TCP/IP networking and traffic control in Linux";
|
||||
platforms = platforms.linux;
|
||||
license = licenses.gpl2;
|
||||
maintainers = with maintainers; [ primeos eelco fpletz globin ];
|
||||
};
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
--- a/misc/Makefile
|
||||
+++ b/misc/Makefile
|
||||
@@ -2,13 +2,13 @@
|
||||
SSOBJ=ss.o ssfilter_check.o ssfilter.tab.o
|
||||
LNSTATOBJ=lnstat.o lnstat_util.o
|
||||
|
||||
-TARGETS=ss nstat ifstat rtacct lnstat
|
||||
+TARGETS=ss nstat
|
||||
|
||||
include ../config.mk
|
||||
|
||||
-ifeq ($(HAVE_BERKELEY_DB),y)
|
||||
- TARGETS += arpd
|
||||
-endif
|
||||
+#ifeq ($(HAVE_BERKELEY_DB),y)
|
||||
+# TARGETS += arpd
|
||||
+#endif
|
||||
|
||||
all: $(TARGETS)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -68,9 +68,9 @@ WFLAGS += -Wmissing-declarations -Wold-s
|
||||
CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
|
||||
YACCFLAGS = -d -t -v
|
||||
|
||||
-SUBDIRS=lib ip tc bridge misc netem genl man
|
||||
+SUBDIRS=lib ip tc bridge misc genl
|
||||
ifeq ($(HAVE_MNL),y)
|
||||
-SUBDIRS += tipc devlink rdma dcb vdpa
|
||||
+SUBDIRS += devlink rdma
|
||||
endif
|
||||
|
||||
LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a
|
9
pkgs/iproute2-small/patches/140-allow_pfifo_fast.patch
Normal file
9
pkgs/iproute2-small/patches/140-allow_pfifo_fast.patch
Normal file
|
@ -0,0 +1,9 @@
|
|||
--- a/tc/q_fifo.c
|
||||
+++ b/tc/q_fifo.c
|
||||
@@ -90,5 +90,6 @@ struct qdisc_util pfifo_head_drop_qdisc_
|
||||
|
||||
struct qdisc_util pfifo_fast_qdisc_util = {
|
||||
.id = "pfifo_fast",
|
||||
+ .parse_qopt = fifo_parse_opt,
|
||||
.print_qopt = prio_print_opt,
|
||||
};
|
11
pkgs/iproute2-small/patches/160-libnetlink-pic.patch
Normal file
11
pkgs/iproute2-small/patches/160-libnetlink-pic.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/lib/Makefile
|
||||
+++ b/lib/Makefile
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
include ../config.mk
|
||||
|
||||
-CFLAGS += -fPIC
|
||||
+CFLAGS += $(FPIC)
|
||||
|
||||
UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
|
||||
inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \
|
108
pkgs/iproute2-small/patches/170-ip_tiny.patch
Normal file
108
pkgs/iproute2-small/patches/170-ip_tiny.patch
Normal file
|
@ -0,0 +1,108 @@
|
|||
--- a/ip/Makefile
|
||||
+++ b/ip/Makefile
|
||||
@@ -19,6 +19,13 @@ RTMONOBJ=rtmon.o
|
||||
|
||||
include ../config.mk
|
||||
|
||||
+STATIC_SYM_FILTER:=
|
||||
+ifeq ($(IP_CONFIG_TINY),y)
|
||||
+ STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c
|
||||
+ CFLAGS += -DIPROUTE2_TINY
|
||||
+endif
|
||||
+STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c))
|
||||
+
|
||||
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
|
||||
SCRIPTS=routel
|
||||
TARGETS=ip rtmon
|
||||
@@ -48,7 +55,7 @@ else
|
||||
|
||||
ip: static-syms.o
|
||||
static-syms.o: static-syms.h
|
||||
-static-syms.h: $(wildcard *.c)
|
||||
+static-syms.h: $(STATIC_SYM_SOURCES)
|
||||
files="$^" ; \
|
||||
for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
|
||||
sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
|
||||
--- a/ip/ip.c
|
||||
+++ b/ip/ip.c
|
||||
@@ -61,11 +61,17 @@ static void usage(void)
|
||||
fprintf(stderr,
|
||||
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||
" ip [ -force ] -batch filename\n"
|
||||
+#ifndef IPROUTE2_TINY
|
||||
"where OBJECT := { address | addrlabel | amt | fou | help | ila | ioam | l2tp |\n"
|
||||
" link | macsec | maddress | monitor | mptcp | mroute | mrule |\n"
|
||||
" neighbor | neighbour | netconf | netns | nexthop | ntable |\n"
|
||||
" ntbl | route | rule | sr | tap | tcpmetrics |\n"
|
||||
" token | tunnel | tuntap | vrf | xfrm }\n"
|
||||
+#else
|
||||
+ "where OBJECT := { address | link | maddress | monitor |\n"
|
||||
+ " neighbor | neighbour | netns | route |\n"
|
||||
+ " rule | token | tunnel }\n"
|
||||
+#endif
|
||||
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
|
||||
" -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
|
||||
" -f[amily] { inet | inet6 | mpls | bridge | link } |\n"
|
||||
@@ -88,37 +94,49 @@ static const struct cmd {
|
||||
int (*func)(int argc, char **argv);
|
||||
} cmds[] = {
|
||||
{ "address", do_ipaddr },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "addrlabel", do_ipaddrlabel },
|
||||
+#endif
|
||||
{ "maddress", do_multiaddr },
|
||||
{ "route", do_iproute },
|
||||
{ "rule", do_iprule },
|
||||
{ "neighbor", do_ipneigh },
|
||||
{ "neighbour", do_ipneigh },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "ntable", do_ipntable },
|
||||
{ "ntbl", do_ipntable },
|
||||
+#endif
|
||||
{ "link", do_iplink },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "l2tp", do_ipl2tp },
|
||||
{ "fou", do_ipfou },
|
||||
{ "ila", do_ipila },
|
||||
{ "macsec", do_ipmacsec },
|
||||
+#endif
|
||||
{ "tunnel", do_iptunnel },
|
||||
{ "tunl", do_iptunnel },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "tuntap", do_iptuntap },
|
||||
{ "tap", do_iptuntap },
|
||||
{ "token", do_iptoken },
|
||||
{ "tcpmetrics", do_tcp_metrics },
|
||||
{ "tcp_metrics", do_tcp_metrics },
|
||||
+#endif
|
||||
{ "monitor", do_ipmonitor },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "xfrm", do_xfrm },
|
||||
{ "mroute", do_multiroute },
|
||||
{ "mrule", do_multirule },
|
||||
+#endif
|
||||
{ "netns", do_netns },
|
||||
+#ifndef IPROUTE2_TINY
|
||||
{ "netconf", do_ipnetconf },
|
||||
{ "vrf", do_ipvrf},
|
||||
{ "sr", do_seg6 },
|
||||
{ "nexthop", do_ipnh },
|
||||
{ "mptcp", do_mptcp },
|
||||
{ "ioam", do_ioam6 },
|
||||
+#endif
|
||||
{ "help", do_help },
|
||||
{ "stats", do_ipstats },
|
||||
{ 0 }
|
||||
--- a/lib/Makefile
|
||||
+++ b/lib/Makefile
|
||||
@@ -3,6 +3,10 @@ include ../config.mk
|
||||
|
||||
CFLAGS += $(FPIC)
|
||||
|
||||
+ifeq ($(IP_CONFIG_TINY),y)
|
||||
+ CFLAGS += -DIPROUTE2_TINY
|
||||
+endif
|
||||
+
|
||||
UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
|
||||
inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \
|
||||
names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o ppp_proto.o
|
45
pkgs/iproute2-small/patches/175-reduce-dynamic-syms.patch
Normal file
45
pkgs/iproute2-small/patches/175-reduce-dynamic-syms.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
--- a/tc/Makefile
|
||||
+++ b/tc/Makefile
|
||||
@@ -106,7 +106,7 @@ LDLIBS += -L. -lm
|
||||
|
||||
ifeq ($(SHARED_LIBS),y)
|
||||
LDLIBS += -ldl
|
||||
-LDFLAGS += -Wl,-export-dynamic
|
||||
+LDFLAGS += -Wl,--dynamic-list=dynsyms.list
|
||||
endif
|
||||
|
||||
TCLIB := tc_core.o
|
||||
@@ -135,7 +135,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
all: tc $(TCSO)
|
||||
|
||||
tc: $(TCOBJ) $(LIBNETLINK) libtc.a
|
||||
- $(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
+ $(QUIET_LINK)$(CC) $(filter-out dynsyms.list, $^) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
libtc.a: $(TCLIB)
|
||||
$(QUIET_AR)$(AR) rcs $@ $^
|
||||
@@ -157,6 +157,7 @@ install: all
|
||||
clean:
|
||||
rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.tab.h; \
|
||||
rm -f emp_ematch.tab.*
|
||||
+ rm -f dynsyms.list
|
||||
|
||||
m_xt.so: m_xt.c
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o m_xt.so m_xt.c $$($(PKG_CONFIG) xtables --cflags --libs)
|
||||
@@ -193,4 +194,16 @@ static-syms.h: $(wildcard *.c)
|
||||
sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
|
||||
done > $@
|
||||
|
||||
+else
|
||||
+
|
||||
+tc: dynsyms.list
|
||||
+m_xt.so: dynsyms.list
|
||||
+dynsyms.list: $(wildcard *.c)
|
||||
+ files="$(filter-out $(patsubst %.so,%.c,$(TCSO)), $^)" ; \
|
||||
+ echo "{" > $@ ; \
|
||||
+ for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
|
||||
+ sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:\1;:;p}' $$files ; \
|
||||
+ done >> $@ ; \
|
||||
+ echo "show_stats; print_nl; print_tm; parse_rtattr; parse_rtattr_flags; get_u32; matches; addattr_l; addattr_nest; addattr_nest_end; };" >> $@
|
||||
+
|
||||
endif
|
41
pkgs/iproute2-small/patches/180-drop_FAILED_POLICY.patch
Normal file
41
pkgs/iproute2-small/patches/180-drop_FAILED_POLICY.patch
Normal file
|
@ -0,0 +1,41 @@
|
|||
From 4e7dbf76227e8c7be7897dc81def3011f637864d Mon Sep 17 00:00:00 2001
|
||||
From: Jonas Gorski <jogo@openwrt.org>
|
||||
Date: Thu, 30 May 2013 11:54:04 +0200
|
||||
Subject: [PATCH] add support for dropping with FAILED_POLICY
|
||||
|
||||
---
|
||||
include/linux/fib_rules.h | 4 ++++
|
||||
include/linux/rtnetlink.h | 1 +
|
||||
ip/rtm_map.c | 4 ++++
|
||||
3 files changed, 9 insertions(+)
|
||||
|
||||
--- a/ip/rtm_map.c
|
||||
+++ b/ip/rtm_map.c
|
||||
@@ -49,6 +49,8 @@ char *rtnl_rtntype_n2a(int id, char *buf
|
||||
return "nat";
|
||||
case RTN_XRESOLVE:
|
||||
return "xresolve";
|
||||
+ case RTN_FAILED_POLICY:
|
||||
+ return "failed_policy";
|
||||
default:
|
||||
snprintf(buf, len, "%d", id);
|
||||
return buf;
|
||||
@@ -84,6 +86,8 @@ int rtnl_rtntype_a2n(int *id, char *arg)
|
||||
res = RTN_UNICAST;
|
||||
else if (strcmp(arg, "throw") == 0)
|
||||
res = RTN_THROW;
|
||||
+ else if (strcmp(arg, "failed_policy") == 0)
|
||||
+ res = RTN_FAILED_POLICY;
|
||||
else {
|
||||
res = strtoul(arg, &end, 0);
|
||||
if (!end || end == arg || *end || res > 255)
|
||||
--- a/include/uapi/linux/rtnetlink.h
|
||||
+++ b/include/uapi/linux/rtnetlink.h
|
||||
@@ -265,6 +265,7 @@ enum {
|
||||
RTN_THROW, /* Not in this table */
|
||||
RTN_NAT, /* Translate this address */
|
||||
RTN_XRESOLVE, /* Use external resolver */
|
||||
+ RTN_FAILED_POLICY, /* Source address failed policy */
|
||||
__RTN_MAX
|
||||
};
|
||||
|
20
pkgs/iproute2-small/patches/190-fix-nls-rpath-link.patch
Normal file
20
pkgs/iproute2-small/patches/190-fix-nls-rpath-link.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -270,7 +270,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
EOF
|
||||
|
||||
- $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
||||
+ $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS $LDFLAGS >/dev/null 2>&1
|
||||
local ret=$?
|
||||
|
||||
rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test
|
||||
@@ -288,7 +288,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
EOF
|
||||
|
||||
- $CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
|
||||
+ $CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS $LDFLAGS >/dev/null 2>&1
|
||||
local ret=$?
|
||||
|
||||
rm -f $TMPDIR/libbpf_sec_test.c $TMPDIR/libbpf_sec_test
|
22
pkgs/iproute2-small/patches/195-build_variant_ip_tc.patch
Normal file
22
pkgs/iproute2-small/patches/195-build_variant_ip_tc.patch
Normal file
|
@ -0,0 +1,22 @@
|
|||
--- a/ip/Makefile
|
||||
+++ b/ip/Makefile
|
||||
@@ -28,7 +28,7 @@ STATIC_SYM_SOURCES:=$(filter-out $(STATI
|
||||
|
||||
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
|
||||
SCRIPTS=routel
|
||||
-TARGETS=ip rtmon
|
||||
+TARGETS=$(findstring ip,$(BUILD_VARIANT)) rtmon
|
||||
|
||||
all: $(TARGETS) $(SCRIPTS)
|
||||
|
||||
--- a/tc/Makefile
|
||||
+++ b/tc/Makefile
|
||||
@@ -132,7 +132,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
|
||||
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic $< -o $@
|
||||
|
||||
|
||||
-all: tc $(TCSO)
|
||||
+all: $(findstring tc,$(BUILD_VARIANT)) $(TCSO)
|
||||
|
||||
tc: $(TCOBJ) $(LIBNETLINK) libtc.a
|
||||
$(QUIET_LINK)$(CC) $(filter-out dynsyms.list, $^) $(LDFLAGS) $(LDLIBS) -o $@
|
Loading…
Add table
Reference in a new issue