blob: 149bcd2afcbb6cba0e4ce0c2616a6a4cda2eccce [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001--- a/ip/Makefile
2+++ b/ip/Makefile
3@@ -19,6 +19,13 @@ RTMONOBJ=rtmon.o
4
5 include ../config.mk
6
7+STATIC_SYM_FILTER:=
8+ifeq ($(IP_CONFIG_TINY),y)
9+ STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c
10+ CFLAGS += -DIPROUTE2_TINY
11+endif
12+STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c))
13+
14 ALLOBJ=$(IPOBJ) $(RTMONOBJ)
15 SCRIPTS=routel
16 TARGETS=ip rtmon
17@@ -48,7 +55,7 @@ else
18
19 ip: static-syms.o
20 static-syms.o: static-syms.h
21-static-syms.h: $(wildcard *.c)
22+static-syms.h: $(STATIC_SYM_SOURCES)
23 files="$^" ; \
24 for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
25 sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
26--- a/ip/ip.c
27+++ b/ip/ip.c
28@@ -61,11 +61,17 @@ static void usage(void)
29 fprintf(stderr,
30 "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
31 " ip [ -force ] -batch filename\n"
32+#ifndef IPROUTE2_TINY
33 "where OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link |\n"
34 " macsec | maddress | monitor | mptcp | mroute | mrule |\n"
35 " neighbor | neighbour | netconf | netns | nexthop | ntable |\n"
36 " ntbl | route | rule | sr | stats | tap | tcpmetrics |\n"
37 " token | tunnel | tuntap | vrf | xfrm }\n"
38+#else
39+ "where OBJECT := { address | help | link | maddress | monitor |\n"
40+ " neighbor | neighbour | netns | route |\n"
41+ " rule | stats | token | tunnel }\n"
42+#endif
43 " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
44 " -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
45 " -f[amily] { inet | inet6 | mpls | bridge | link } |\n"
46@@ -88,37 +94,49 @@ static const struct cmd {
47 int (*func)(int argc, char **argv);
48 } cmds[] = {
49 { "address", do_ipaddr },
50+#ifndef IPROUTE2_TINY
51 { "addrlabel", do_ipaddrlabel },
52+#endif
53 { "maddress", do_multiaddr },
54 { "route", do_iproute },
55 { "rule", do_iprule },
56 { "neighbor", do_ipneigh },
57 { "neighbour", do_ipneigh },
58+#ifndef IPROUTE2_TINY
59 { "ntable", do_ipntable },
60 { "ntbl", do_ipntable },
61+#endif
62 { "link", do_iplink },
63+#ifndef IPROUTE2_TINY
64 { "l2tp", do_ipl2tp },
65 { "fou", do_ipfou },
66 { "ila", do_ipila },
67 { "macsec", do_ipmacsec },
68+#endif
69 { "tunnel", do_iptunnel },
70 { "tunl", do_iptunnel },
71+#ifndef IPROUTE2_TINY
72 { "tuntap", do_iptuntap },
73 { "tap", do_iptuntap },
74 { "token", do_iptoken },
75 { "tcpmetrics", do_tcp_metrics },
76 { "tcp_metrics", do_tcp_metrics },
77+#endif
78 { "monitor", do_ipmonitor },
79+#ifndef IPROUTE2_TINY
80 { "xfrm", do_xfrm },
81 { "mroute", do_multiroute },
82 { "mrule", do_multirule },
83+#endif
84 { "netns", do_netns },
85+#ifndef IPROUTE2_TINY
86 { "netconf", do_ipnetconf },
87 { "vrf", do_ipvrf},
88 { "sr", do_seg6 },
89 { "nexthop", do_ipnh },
90 { "mptcp", do_mptcp },
91 { "ioam", do_ioam6 },
92+#endif
93 { "help", do_help },
94 { "stats", do_ipstats },
95 { 0 }
96--- a/lib/Makefile
97+++ b/lib/Makefile
98@@ -3,6 +3,10 @@ include ../config.mk
99
100 CFLAGS += $(FPIC)
101
102+ifeq ($(IP_CONFIG_TINY),y)
103+ CFLAGS += -DIPROUTE2_TINY
104+endif
105+
106 UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
107 inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \
108 names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o ppp_proto.o