2
0

170-ip_tiny.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. --- a/ip/Makefile
  2. +++ b/ip/Makefile
  3. @@ -17,6 +17,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. @@ -46,7 +53,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. @@ -64,11 +64,17 @@ 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 := { address | addrlabel | fou | help | ila | ioam | l2tp | link |\n"
  31. " macsec | maddress | monitor | mptcp | mroute | mrule |\n"
  32. " neighbor | neighbour | netconf | netns | nexthop | ntable |\n"
  33. " ntbl | route | rule | sr | tap | tcpmetrics |\n"
  34. " token | tunnel | tuntap | vrf | xfrm }\n"
  35. +#else
  36. + "where OBJECT := { address | ila | link | macsec | maddress | monitor |\n"
  37. + " mroute | mrule | neighbor | neighbour | netns | route |\n"
  38. + " rule | sr | token | tunnel | vrf }\n"
  39. +#endif
  40. " OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
  41. " -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
  42. " -f[amily] { inet | inet6 | mpls | bridge | link } |\n"
  43. @@ -91,37 +97,51 @@ static const struct cmd {
  44. int (*func)(int argc, char **argv);
  45. } cmds[] = {
  46. { "address", do_ipaddr },
  47. +#ifndef IPROUTE2_TINY
  48. { "addrlabel", do_ipaddrlabel },
  49. +#endif
  50. { "maddress", do_multiaddr },
  51. { "route", do_iproute },
  52. { "rule", do_iprule },
  53. { "neighbor", do_ipneigh },
  54. { "neighbour", do_ipneigh },
  55. +#ifndef IPROUTE2_TINY
  56. { "ntable", do_ipntable },
  57. { "ntbl", do_ipntable },
  58. +#endif
  59. { "link", do_iplink },
  60. +#ifndef IPROUTE2_TINY
  61. { "l2tp", do_ipl2tp },
  62. { "fou", do_ipfou },
  63. +#endif
  64. { "ila", do_ipila },
  65. { "macsec", do_ipmacsec },
  66. { "tunnel", do_iptunnel },
  67. { "tunl", do_iptunnel },
  68. +#ifndef IPROUTE2_TINY
  69. { "tuntap", do_iptuntap },
  70. { "tap", do_iptuntap },
  71. { "token", do_iptoken },
  72. { "tcpmetrics", do_tcp_metrics },
  73. { "tcp_metrics", do_tcp_metrics },
  74. +#endif
  75. { "monitor", do_ipmonitor },
  76. +#ifndef IPROUTE2_TINY
  77. { "xfrm", do_xfrm },
  78. +#endif
  79. { "mroute", do_multiroute },
  80. { "mrule", do_multirule },
  81. { "netns", do_netns },
  82. +#ifndef IPROUTE2_TINY
  83. { "netconf", do_ipnetconf },
  84. +#endif
  85. { "vrf", do_ipvrf},
  86. { "sr", do_seg6 },
  87. +#ifndef IPROUTE2_TINY
  88. { "nexthop", do_ipnh },
  89. { "mptcp", do_mptcp },
  90. { "ioam", do_ioam6 },
  91. +#endif
  92. { "help", do_help },
  93. { 0 }
  94. };
  95. --- a/lib/Makefile
  96. +++ b/lib/Makefile
  97. @@ -3,6 +3,10 @@ include ../config.mk
  98. CFLAGS += $(FPIC)
  99. +ifeq ($(IP_CONFIG_TINY),y)
  100. + CFLAGS += -DIPROUTE2_TINY
  101. +endif
  102. +
  103. UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
  104. inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \
  105. names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o