290adbe5f58055c93a04caf03f36443f748a1d17
[openwrt/openwrt.git] / package / network / utils / iproute2 / patches / 300-ip_tiny.patch
1 --- a/ip/Makefile
2 +++ b/ip/Makefile
3 @@ -17,6 +17,13 @@ ifeq ($(IP_CONFIG_SETNS),y)
4 CFLAGS += -DHAVE_SETNS
5 endif
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=ifcfg rtpr routel routef
16 TARGETS=ip rtmon
17 @@ -44,7 +51,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 @@ -73,30 +73,42 @@ static const struct cmd {
29 int (*func)(int argc, char **argv);
30 } cmds[] = {
31 { "address", do_ipaddr },
32 +#ifndef IPROUTE2_TINY
33 { "addrlabel", do_ipaddrlabel },
34 +#endif
35 { "maddress", do_multiaddr },
36 { "route", do_iproute },
37 { "rule", do_iprule },
38 { "neighbor", do_ipneigh },
39 { "neighbour", do_ipneigh },
40 +#ifndef IPROUTE2_TINY
41 { "ntable", do_ipntable },
42 { "ntbl", do_ipntable },
43 +#endif
44 { "link", do_iplink },
45 +#ifndef IPROUTE2_TINY
46 { "l2tp", do_ipl2tp },
47 { "fou", do_ipfou },
48 +#endif
49 { "tunnel", do_iptunnel },
50 { "tunl", do_iptunnel },
51 +#ifndef IPROUTE2_TINY
52 { "tuntap", do_iptuntap },
53 { "tap", do_iptuntap },
54 { "token", do_iptoken },
55 { "tcpmetrics", do_tcp_metrics },
56 { "tcp_metrics", do_tcp_metrics },
57 +#endif
58 { "monitor", do_ipmonitor },
59 +#ifndef IPROUTE2_TINY
60 { "xfrm", do_xfrm },
61 +#endif
62 { "mroute", do_multiroute },
63 { "mrule", do_multirule },
64 { "netns", do_netns },
65 +#ifndef IPROUTE2_TINY
66 { "netconf", do_ipnetconf },
67 +#endif
68 { "help", do_help },
69 { 0 }
70 };
71 --- a/lib/utils.c
72 +++ b/lib/utils.c
73 @@ -710,6 +710,7 @@ const char *rt_addr_n2a(int af, int len,
74 return inet_ntop(af, addr, buf, buflen);
75 case AF_MPLS:
76 return mpls_ntop(af, addr, buf, buflen);
77 +#ifndef IPROUTE2_TINY
78 case AF_IPX:
79 return ipx_ntop(af, addr, buf, buflen);
80 case AF_DECnet:
81 @@ -718,6 +719,7 @@ const char *rt_addr_n2a(int af, int len,
82 memcpy(dna.a_addr, addr, 2);
83 return dnet_ntop(af, &dna, buf, buflen);
84 }
85 +#endif
86 case AF_PACKET:
87 return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
88 default:
89 --- a/lib/Makefile
90 +++ b/lib/Makefile
91 @@ -4,6 +4,10 @@ ifeq ($(IP_CONFIG_SETNS),y)
92 CFLAGS += -DHAVE_SETNS
93 endif
94
95 +ifeq ($(IP_CONFIG_TINY),y)
96 + CFLAGS += -DIPROUTE2_TINY
97 +endif
98 +
99 CFLAGS += $(FPIC)
100
101 UTILOBJ = utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o \