aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils/iproute2/patches/300-ip_tiny.patch
blob: d8f39d39107ae5165585ffa1c9e3da587bdf239e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -16,6 +16,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=ifcfg rtpr routel routef
 TARGETS=ip rtmon
@@ -45,7 +52,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
@@ -48,10 +48,16 @@ static void usage(void)
 	fprintf(stderr,
 "Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
 "       ip [ -force ] -batch filename\n"
+#ifndef IPROUTE2_TINY
 "where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |\n"
 "                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |\n"
 "                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |\n"
 "                   vrf | sr }\n"
+#else
+"where  OBJECT := { link | address | route | rule | neigh | tunnel | maddress |\n"
+"                   mroute | mrule | monitor | netns | macsec | token | ila |\n"
+"                   vrf | sr }\n"
+#endif
 "       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
 "                    -h[uman-readable] | -iec |\n"
 "                    -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n"
@@ -73,32 +79,44 @@ 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 },
+#endif
 	{ "ila",	do_ipila },
 	{ "macsec",	do_ipmacsec },
 	{ "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 },
+#endif
 	{ "mroute",	do_multiroute },
 	{ "mrule",	do_multirule },
 	{ "netns",	do_netns },
+#ifndef IPROUTE2_TINY
 	{ "netconf",	do_ipnetconf },
+#endif
 	{ "vrf",	do_ipvrf},
 	{ "sr",		do_seg6 },
 	{ "help",	do_help },
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -983,6 +983,7 @@ const char *rt_addr_n2a_r(int af, int le
 		return inet_ntop(af, addr, buf, buflen);
 	case AF_MPLS:
 		return mpls_ntop(af, addr, buf, buflen);
+#ifndef IPROUTE2_TINY
 	case AF_IPX:
 		return ipx_ntop(af, addr, buf, buflen);
 	case AF_DECnet:
@@ -992,6 +993,7 @@ const char *rt_addr_n2a_r(int af, int le
 		memcpy(dna.a_addr, addr, 2);
 		return dnet_ntop(af, &dna, buf, buflen);
 	}
+#endif
 	case AF_PACKET:
 		return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
 	case AF_BRIDGE:
--- 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 rt_names.o ll_types.o ll_proto.o ll_addr.o \
 	inet_proto.o namespace.o json_writer.o json_print.o \
 	names.o color.o bpf.o exec.o fs.o