300-ip_tiny.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. --- a/ip/Makefile
  2. +++ b/ip/Makefile
  3. @@ -15,6 +15,13 @@ ifeq ($(IP_CONFIG_SETNS),y)
  4. CFLAGS += -DHAVE_SETNS
  5. endif
  6. +STATIC_SYM_FILTER:=
  7. +ifeq ($(IP_CONFIG_TINY),y)
  8. + STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c
  9. + CFLAGS += -DIPROUTE2_TINY
  10. +endif
  11. +STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c))
  12. +
  13. ALLOBJ=$(IPOBJ) $(RTMONOBJ)
  14. SCRIPTS=ifcfg rtpr routel routef
  15. TARGETS=ip rtmon
  16. @@ -42,7 +49,7 @@ else
  17. ip: static-syms.o
  18. static-syms.o: static-syms.h
  19. -static-syms.h: $(wildcard *.c)
  20. +static-syms.h: $(STATIC_SYM_SOURCES)
  21. files="$^" ; \
  22. for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
  23. sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
  24. --- a/ip/ip.c
  25. +++ b/ip/ip.c
  26. @@ -66,29 +66,41 @@ static const struct cmd {
  27. int (*func)(int argc, char **argv);
  28. } cmds[] = {
  29. { "address", do_ipaddr },
  30. +#ifndef IPROUTE2_TINY
  31. { "addrlabel", do_ipaddrlabel },
  32. +#endif
  33. { "maddress", do_multiaddr },
  34. { "route", do_iproute },
  35. { "rule", do_iprule },
  36. { "neighbor", do_ipneigh },
  37. { "neighbour", do_ipneigh },
  38. +#ifndef IPROUTE2_TINY
  39. { "ntable", do_ipntable },
  40. { "ntbl", do_ipntable },
  41. +#endif
  42. { "link", do_iplink },
  43. +#ifndef IPROUTE2_TINY
  44. { "l2tp", do_ipl2tp },
  45. +#endif
  46. { "tunnel", do_iptunnel },
  47. { "tunl", do_iptunnel },
  48. +#ifndef IPROUTE2_TINY
  49. { "tuntap", do_iptuntap },
  50. { "tap", do_iptuntap },
  51. { "token", do_iptoken },
  52. { "tcpmetrics", do_tcp_metrics },
  53. { "tcp_metrics",do_tcp_metrics },
  54. +#endif
  55. { "monitor", do_ipmonitor },
  56. +#ifndef IPROUTE2_TINY
  57. { "xfrm", do_xfrm },
  58. +#endif
  59. { "mroute", do_multiroute },
  60. { "mrule", do_multirule },
  61. { "netns", do_netns },
  62. +#ifndef IPROUTE2_TINY
  63. { "netconf", do_ipnetconf },
  64. +#endif
  65. { "help", do_help },
  66. { 0 }
  67. };
  68. --- a/lib/utils.c
  69. +++ b/lib/utils.c
  70. @@ -627,6 +627,7 @@ const char *rt_addr_n2a(int af, int len,
  71. case AF_INET:
  72. case AF_INET6:
  73. return inet_ntop(af, addr, buf, buflen);
  74. +#ifndef IPROUTE2_TINY
  75. case AF_IPX:
  76. return ipx_ntop(af, addr, buf, buflen);
  77. case AF_DECnet:
  78. @@ -635,6 +636,7 @@ const char *rt_addr_n2a(int af, int len,
  79. memcpy(dna.a_addr, addr, 2);
  80. return dnet_ntop(af, &dna, buf, buflen);
  81. }
  82. +#endif
  83. default:
  84. return "???";
  85. }
  86. @@ -710,6 +712,7 @@ const char *format_host(int af, int len,
  87. case AF_INET6:
  88. len = 16;
  89. break;
  90. +#ifndef IPROUTE2_TINY
  91. case AF_IPX:
  92. len = 10;
  93. break;
  94. @@ -720,6 +723,7 @@ const char *format_host(int af, int len,
  95. len = 2;
  96. break;
  97. #endif
  98. +#endif
  99. default: ;
  100. }
  101. }
  102. --- a/lib/Makefile
  103. +++ b/lib/Makefile
  104. @@ -1,5 +1,9 @@
  105. include ../Config
  106. +ifeq ($(IP_CONFIG_TINY),y)
  107. + CFLAGS += -DIPROUTE2_TINY
  108. +endif
  109. +
  110. CFLAGS += $(FPIC)
  111. UTILOBJ=utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o inet_proto.o