170-ip_tiny.patch 3.7 KB

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