Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=xdp-tools
  3. PKG_RELEASE:=2
  4. PKG_VERSION:=1.5.8
  5. PKG_HASH:=e7b9717074c511fef34aab6e22b16af55fb33307505a5785d25a82b542e596ae
  6. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  7. PKG_SOURCE_URL:=https://codeload.github.com/xdp-project/xdp-tools/tar.gz/v$(PKG_VERSION)?
  8. PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_VERSION))
  9. PKG_MAINTAINER:=Daniel Golle <[email protected]>
  10. PKG_BUILD_DEPENDS:=bpf-headers bpftool/host
  11. include $(INCLUDE_DIR)/package.mk
  12. include $(INCLUDE_DIR)/bpf.mk
  13. include $(INCLUDE_DIR)/nls.mk
  14. PKG_BUILD_PARALLEL:=1
  15. PKG_INSTALL:=1
  16. define Package/libxdp
  17. SECTION:=libs
  18. CATEGORY:=Libraries
  19. TITLE:=libxdp - Library for use with XDP
  20. LICENSE:=LGPL-2.1 OR BSD-2-Clause
  21. ABI_VERSION:=$(PKG_ABI_VERSION)
  22. URL:=https://github.com/xdp-project/xdp-tools/
  23. DEPENDS:=+libbpf $(BPF_DEPENDS)
  24. endef
  25. define Package/libxdp/description
  26. libxdp - library for attaching XDP programs and using AF_XDP sockets
  27. endef
  28. define Package/xdp-tools/Default
  29. SECTION:=net
  30. CATEGORY:=Network
  31. LICENSE:=GPL-2.0-only
  32. URL:=https://github.com/xdp-project/xdp-tools/
  33. DEPENDS:=+libxdp
  34. endef
  35. define Package/xdp-bench
  36. $(call Package/xdp-tools/Default)
  37. TITLE:=xdp-bench - an XDP benchmarking tool
  38. DEPENDS+=@KERNEL_DEBUG_INFO_BTF @KERNEL_KPROBES
  39. endef
  40. define Package/xdp-bench/description
  41. XDP-bench is a benchmarking utility for exercising the different operation modes
  42. of XDP. It is intended to be a simple program demonstrating the various operating
  43. modes; these include dropping packets, hairpin forwarding (using the XDP_TX return
  44. code), and redirection using the various in-kernel packet redirection facilities.
  45. endef
  46. define Package/xdp-filter
  47. $(call Package/xdp-tools/Default)
  48. TITLE:=xdp-filter - a simple XDP-powered packet filter
  49. endef
  50. define Package/xdp-filter/description
  51. xdp-filter is a packet filtering utility powered by XDP. It is deliberately
  52. simple and so does not have the same matching capabilities as, e.g.,
  53. netfilter. Instead, thanks to XDP, it can achieve very high drop rates:
  54. tens of millions of packets per second on a single CPU core.
  55. endef
  56. define Package/xdp-forward
  57. $(call Package/xdp-tools/Default)
  58. TITLE:=xdp-forward - the XDP forwarding plane
  59. DEPENDS+=@KERNEL_DEBUG_INFO_BTF
  60. endef
  61. define Package/xdp-forward/description
  62. xdp-forward is an XDP forwarding plane, which will accelerate
  63. packet forwarding using XDP. To use it, simply load it on
  64. the set of interfaces to accelerate forwarding between.
  65. The userspace component of xdp-forward will then configure and
  66. load XDP programs on those interfaces, and forward packets between
  67. them using XDP_REDIRECT, using the kernel routing table or
  68. netfilter flowtable to determine the destination for each packet.
  69. endef
  70. define Package/xdp-loader
  71. $(call Package/xdp-tools/Default)
  72. TITLE:=xdp-loader - an XDP program loader
  73. endef
  74. define Package/xdp-loader/description
  75. xdp-loader is a simple loader for XDP programs with support for attaching
  76. multiple programs to the same interface. To achieve this it exposes the same
  77. load and unload semantics exposed by the libxdp library.
  78. endef
  79. define Package/xdp-monitor
  80. $(call Package/xdp-tools/Default)
  81. TITLE:=xdp-monitor - a simple XDP tracepoint monitoring tool
  82. DEPENDS+=@KERNEL_DEBUG_INFO_BTF @KERNEL_KPROBES
  83. endef
  84. define Package/xdp-monitor/description
  85. XDP-monitor is a tool that monitors various XDP related statistics and
  86. events using BPF tracepoints infrastructure, trying to be as low overhead
  87. as possible.
  88. endef
  89. define Package/xdp-trafficgen
  90. $(call Package/xdp-tools/Default)
  91. TITLE:=xdp-trafficgen - an XDP-based packet generator
  92. DEPENDS+=@KERNEL_DEBUG_INFO_BTF @KERNEL_KPROBES
  93. endef
  94. define Package/xdp-trafficgen/description
  95. XDP-trafficgen is a packet generator utilising the XDP kernel subsystem
  96. to generate packets transmit them through a network interface.
  97. Packets are dynamically generated and transmitted in the kernel,
  98. allowing for high performance (millions of packets per second per core).
  99. XDP-trafficgen supports generating UDP traffic with fixed or dynamic
  100. destination ports, and also has basic support for generating dummy
  101. TCP traffic on a single flow.
  102. endef
  103. define Package/xdpdump
  104. $(call Package/xdp-tools/Default)
  105. TITLE:=xdpdump - tool for capturing packets at the XDP layer
  106. DEPENDS+=+libpcap
  107. endef
  108. define Package/xdpdump/description
  109. xdpdump - a simple tcpdump like tool for capturing packets at the XDP layer
  110. endef
  111. TARGET_LDFLAGS += $(INTL_LDFLAGS)
  112. CONFIGURE_VARS += \
  113. FORCE_SYSTEM_LIBBPF=1 \
  114. CC="$(TARGET_CC)" \
  115. CFLAGS="$(TARGET_CFLAGS)" \
  116. LDFLAGS="$(TARGET_LDFLAGS)" \
  117. CLANG="$(CLANG)" \
  118. BPFTOOL="$(STAGING_DIR_HOST)/usr/sbin/bpftool"
  119. ifneq ($(findstring s,$(OPENWRT_VERBOSE)),)
  120. MAKE_FLAGS+=V=1
  121. endif
  122. MAKE_VARS += \
  123. PREFIX=/usr \
  124. RUNDIR=/tmp/run \
  125. CFLAGS="$(TARGET_CFLAGS)" \
  126. LDFLAGS="$(TARGET_LDFLAGS)"
  127. define Build/InstallDev
  128. $(INSTALL_DIR) $(1)/usr/include/xdp
  129. $(CP) $(PKG_INSTALL_DIR)/usr/include/xdp/*.h $(1)/usr/include/xdp/
  130. $(INSTALL_DIR) $(1)/usr/lib/bpf
  131. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.{a,so*} $(1)/usr/lib/
  132. $(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
  133. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  134. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libxdp.pc \
  135. $(1)/usr/lib/pkgconfig/
  136. $(SED) 's,/usr/include,$$$${prefix}/include,g' \
  137. $(1)/usr/lib/pkgconfig/libxdp.pc
  138. $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
  139. $(1)/usr/lib/pkgconfig/libxdp.pc
  140. endef
  141. define Package/xdp-bench/install
  142. $(INSTALL_DIR) $(1)/usr/sbin
  143. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-bench $(1)/usr/sbin
  144. endef
  145. define Package/xdp-filter/install
  146. $(INSTALL_DIR) $(1)/usr/sbin
  147. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-filter $(1)/usr/sbin
  148. endef
  149. define Package/xdp-forward/install
  150. $(INSTALL_DIR) $(1)/usr/sbin
  151. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-forward $(1)/usr/sbin
  152. endef
  153. define Package/xdp-loader/install
  154. $(INSTALL_DIR) $(1)/usr/sbin
  155. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-loader $(1)/usr/sbin
  156. endef
  157. define Package/xdp-monitor/install
  158. $(INSTALL_DIR) $(1)/usr/sbin
  159. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-monitor $(1)/usr/sbin
  160. endef
  161. define Package/xdp-trafficgen/install
  162. $(INSTALL_DIR) $(1)/usr/sbin
  163. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-trafficgen $(1)/usr/sbin
  164. endef
  165. define Package/xdpdump/install
  166. $(INSTALL_DIR) $(1)/usr/sbin
  167. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdpdump $(1)/usr/sbin
  168. endef
  169. define Package/libxdp/install
  170. $(INSTALL_DIR) $(1)/usr/lib/bpf
  171. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.so.* $(1)/usr/lib/
  172. $(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
  173. endef
  174. $(eval $(call BuildPackage,libxdp))
  175. $(eval $(call BuildPackage,xdp-bench))
  176. $(eval $(call BuildPackage,xdp-filter))
  177. $(eval $(call BuildPackage,xdp-forward))
  178. $(eval $(call BuildPackage,xdp-loader))
  179. $(eval $(call BuildPackage,xdp-monitor))
  180. $(eval $(call BuildPackage,xdp-trafficgen))
  181. $(eval $(call BuildPackage,xdpdump))