300-ip_tiny.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. +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. @@ -44,7 +51,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. @@ -73,30 +73,42 @@ 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. { "fou", do_ipfou },
  46. +#endif
  47. { "tunnel", do_iptunnel },
  48. { "tunl", do_iptunnel },
  49. +#ifndef IPROUTE2_TINY
  50. { "tuntap", do_iptuntap },
  51. { "tap", do_iptuntap },
  52. { "token", do_iptoken },
  53. { "tcpmetrics", do_tcp_metrics },
  54. { "tcp_metrics", do_tcp_metrics },
  55. +#endif
  56. { "monitor", do_ipmonitor },
  57. +#ifndef IPROUTE2_TINY
  58. { "xfrm", do_xfrm },
  59. +#endif
  60. { "mroute", do_multiroute },
  61. { "mrule", do_multirule },
  62. { "netns", do_netns },
  63. +#ifndef IPROUTE2_TINY
  64. { "netconf", do_ipnetconf },
  65. +#endif
  66. { "help", do_help },
  67. { 0 }
  68. };
  69. --- a/lib/utils.c
  70. +++ b/lib/utils.c
  71. @@ -710,6 +710,7 @@ const char *rt_addr_n2a(int af, int len,
  72. return inet_ntop(af, addr, buf, buflen);
  73. case AF_MPLS:
  74. return mpls_ntop(af, addr, buf, buflen);
  75. +#ifndef IPROUTE2_TINY
  76. case AF_IPX:
  77. return ipx_ntop(af, addr, buf, buflen);
  78. case AF_DECnet:
  79. @@ -718,6 +719,7 @@ const char *rt_addr_n2a(int af, int len,
  80. memcpy(dna.a_addr, addr, 2);
  81. return dnet_ntop(af, &dna, buf, buflen);
  82. }
  83. +#endif
  84. case AF_PACKET:
  85. return ll_addr_n2a(addr, len, ARPHRD_VOID, buf, buflen);
  86. default:
  87. --- a/lib/Makefile
  88. +++ b/lib/Makefile
  89. @@ -4,6 +4,10 @@ ifeq ($(IP_CONFIG_SETNS),y)
  90. CFLAGS += -DHAVE_SETNS
  91. endif
  92. +ifeq ($(IP_CONFIG_TINY),y)
  93. + CFLAGS += -DIPROUTE2_TINY
  94. +endif
  95. +
  96. CFLAGS += $(FPIC)
  97. UTILOBJ = utils.o rt_names.o ll_types.o ll_proto.o ll_addr.o \