iproute2: update to 4.19.0
[openwrt/openwrt.git] / package / network / utils / iproute2 / patches / 170-ip_tiny.patch
1 --- a/ip/Makefile
2 +++ b/ip/Makefile
3 @@ -16,6 +16,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=ifcfg rtpr routel routef
16 TARGETS=ip rtmon
17 @@ -45,7 +52,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 @@ -47,10 +47,16 @@ 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 := { link | address | addrlabel | route | rule | neigh | ntable |\n"
34 " tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |\n"
35 " netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila |\n"
36 " vrf | sr }\n"
37 +#else
38 +"where OBJECT := { link | address | route | rule | neigh | tunnel | maddress |\n"
39 +" mroute | mrule | monitor | netns | macsec | token | ila |\n"
40 +" vrf | sr }\n"
41 +#endif
42 " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
43 " -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
44 " -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n"
45 @@ -72,32 +78,44 @@ static const struct cmd {
46 int (*func)(int argc, char **argv);
47 } cmds[] = {
48 { "address", do_ipaddr },
49 +#ifndef IPROUTE2_TINY
50 { "addrlabel", do_ipaddrlabel },
51 +#endif
52 { "maddress", do_multiaddr },
53 { "route", do_iproute },
54 { "rule", do_iprule },
55 { "neighbor", do_ipneigh },
56 { "neighbour", do_ipneigh },
57 +#ifndef IPROUTE2_TINY
58 { "ntable", do_ipntable },
59 { "ntbl", do_ipntable },
60 +#endif
61 { "link", do_iplink },
62 +#ifndef IPROUTE2_TINY
63 { "l2tp", do_ipl2tp },
64 { "fou", do_ipfou },
65 +#endif
66 { "ila", do_ipila },
67 { "macsec", do_ipmacsec },
68 { "tunnel", do_iptunnel },
69 { "tunl", do_iptunnel },
70 +#ifndef IPROUTE2_TINY
71 { "tuntap", do_iptuntap },
72 { "tap", do_iptuntap },
73 { "token", do_iptoken },
74 { "tcpmetrics", do_tcp_metrics },
75 { "tcp_metrics", do_tcp_metrics },
76 +#endif
77 { "monitor", do_ipmonitor },
78 +#ifndef IPROUTE2_TINY
79 { "xfrm", do_xfrm },
80 +#endif
81 { "mroute", do_multiroute },
82 { "mrule", do_multirule },
83 { "netns", do_netns },
84 +#ifndef IPROUTE2_TINY
85 { "netconf", do_ipnetconf },
86 +#endif
87 { "vrf", do_ipvrf},
88 { "sr", do_seg6 },
89 { "help", do_help },
90 --- a/lib/utils.c
91 +++ b/lib/utils.c
92 @@ -1012,6 +1012,7 @@ const char *rt_addr_n2a_r(int af, int le
93 return inet_ntop(af, addr, buf, buflen);
94 case AF_MPLS:
95 return mpls_ntop(af, addr, buf, buflen);
96 +#ifndef IPROUTE2_TINY
97 case AF_IPX:
98 return ipx_ntop(af, addr, buf, buflen);
99 case AF_DECnet:
100 @@ -1021,6 +1022,7 @@ const char *rt_addr_n2a_r(int af, int le
101 memcpy(dna.a_addr, addr, 2);
102 return dnet_ntop(af, &dna, buf, buflen);
103 }
104 +#endif
105 case AF_PACKET:
106 return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
107 case AF_BRIDGE:
108 --- a/lib/Makefile
109 +++ b/lib/Makefile
110 @@ -3,6 +3,10 @@ include ../config.mk
111
112 CFLAGS += $(FPIC)
113
114 +ifeq ($(IP_CONFIG_TINY),y)
115 + CFLAGS += -DIPROUTE2_TINY
116 +endif
117 +
118 UTILOBJ = utils.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
119 inet_proto.o namespace.o json_writer.o json_print.o \
120 names.o color.o bpf.o exec.o fs.o