xref: /linux/tools/testing/selftests/net/Makefile (revision 6b88ce902f0bdcb3694a6ceddc8b3d0b40db3772)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2a6f68034SDavid S. Miller# Makefile for net selftests
3a6f68034SDavid S. Miller
43c2c3c16SDaniel BorkmannCFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
550f4143dSMuhammad Usama AnjumCFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES)
63645c71bSMahmoud Maatuq# Additional include paths needed by kselftest.h
73645c71bSMahmoud MaatuqCFLAGS += -I../
8a6f68034SDavid S. Miller
9b69d540dSFlorian WestphalTEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
10509e56b3SMahesh Bandewar	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
1102c7f38bSPeter OskolkovTEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh ip_defrag.sh
1275f0139fSWillem de BruijnTEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh psock_snd.sh
136254e5c6SPeter OskolkovTEST_PROGS += udpgro_bench.sh udpgro.sh test_vxlan_under_vrf.sh reuseport_addr_any.sh
143fb321fdSWillem de BruijnTEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh
153c28d99fSFrancesco RuggeriTEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh
16cd72e61bSNicolas DichtelTEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh fib_nexthop_nongw.sh
17ca3676f9SHangbin LiuTEST_PROGS += altnames.sh icmp.sh icmp_redirect.sh ip6_gre_headroom.sh
18919a23e9SHangbin LiuTEST_PROGS += route_localnet.sh
197f204a7dSKuniyuki IwashimaTEST_PROGS += reuseaddr_ports_exhausted.sh
205ef5c90eSJian YangTEST_PROGS += txtimestamp.sh
213f251d74SDavid AhernTEST_PROGS += vrf-xfrm-tests.sh
220558c396StannerloveTEST_PROGS += rxtimestamp.sh
23b7cc6d3cSIdo SchimmelTEST_PROGS += drop_monitor_tests.sh
241a017276SMichael JeansonTEST_PROGS += vrf_route_leaking.sh
25bbbc7aa4SGuillaume NaultTEST_PROGS += bareudp.sh
26c08e8baeSTaehee YooTEST_PROGS += amt.sh
279b0b7837SSeth David SchoenTEST_PROGS += unicast_extensions.sh
28a062260aSPaolo AbeniTEST_PROGS += udpgro_fwd.sh
29edae34a3SLina WangTEST_PROGS += udpgro_frglist.sh
301c3cadbeSPaolo AbeniTEST_PROGS += veth.sh
31968691c7SJustin IurmanTEST_PROGS += ioam6.sh
329af771d2SPaolo AbeniTEST_PROGS += gro.sh
33025efa0aSJakub KicinskiTEST_PROGS += gre_gso.sh
34b0ced8f2SJakub KicinskiTEST_PROGS += cmsg_so_mark.sh
3538dcd957SHangbin LiuTEST_PROGS += cmsg_time.sh cmsg_ipv6.sh
363920431dSJakub KicinskiTEST_PROGS += netns-name.sh
37796c8c7fSJakub KicinskiTEST_PROGS += nl_netdev.py
38653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt46_l3vpn_test.sh
39653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt4_l3vpn_test.sh
40653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt6_l3vpn_test.sh
416ab4eb5aSAndrea MayerTEST_PROGS += srv6_hencap_red_l3vpn_test.sh
4295baa4e8SAndrea MayerTEST_PROGS += srv6_hl2encap_red_l2vpn_test.sh
4319d6356aSAndrea MayerTEST_PROGS += srv6_end_next_csid_l3vpn_test.sh
441c53717cSPaolo LungaroniTEST_PROGS += srv6_end_x_next_csid_l3vpn_test.sh
455198cb40SAndrea MayerTEST_PROGS += srv6_end_flavors_test.sh
468883deb5SHangbin LiuTEST_PROGS += vrf_strict_mode_test.sh
47619ca0d0SJames PrestwoodTEST_PROGS += arp_ndisc_evict_nocarrier.sh
48f9a2fb73SArun Ajith STEST_PROGS += ndisc_unsolicited_na_test.sh
490ea7b0a4SJaehee ParkTEST_PROGS += arp_ndisc_untracked_subnets.sh
50ec8cb4f6SMartin KaFai LauTEST_PROGS += stress_reuseport_listen.sh
5188e500afSAdel AbouchaevTEST_PROGS += l2_tos_ttl_inherit.sh
52c35ecb95SJoanne KoongTEST_PROGS += bind_bhash.sh
53ae543965SJakub SitnickiTEST_PROGS += ip_local_port_range.sh
54c12e0d5fSPaolo AbeniTEST_PROGS += rps_default_mask.sh
556bb382bcSXin LongTEST_PROGS += big_tcp.sh
5606efafd8SBenjamin PoirierTEST_PROGS_EXTENDED := toeplitz_client.sh toeplitz.sh
57acda655fSDavid AhernTEST_GEN_FILES =  socket nettest
586254e5c6SPeter OskolkovTEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
59358be656SWillem de BruijnTEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
6002c7f38bSPeter OskolkovTEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx ip_defrag
61ae24bab2SLorenz BauerTEST_GEN_FILES += so_txtime ipv6_flowlabel ipv6_flowlabel_mgr so_netns_cookie
6210fbcdd1SJason BaronTEST_GEN_FILES += tcp_fastopen_backup_key
63af8c8a45SSeongJae ParkTEST_GEN_FILES += fin_ack_lat
645ef5c90eSJian YangTEST_GEN_FILES += reuseaddr_ports_exhausted
655ef5c90eSJian YangTEST_GEN_FILES += hwtstamp_config rxtimestamp timestamping txtimestamp
66bc2652b7SDmitry SafonovTEST_GEN_FILES += ipsec
67968691c7SJustin IurmanTEST_GEN_FILES += ioam6_parser
687d157501SCoco LiTEST_GEN_FILES += gro
69e06d79fbSJosef BacikTEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
702e64fe46SCezar BulinaruTEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun tap
715ebfb4ccSCoco LiTEST_GEN_FILES += toeplitz
72a086ee24SJakub KicinskiTEST_GEN_FILES += cmsg_sender
73ec8cb4f6SMartin KaFai LauTEST_GEN_FILES += stress_reuseport_listen
7438dcd957SHangbin LiuTEST_PROGS += test_vxlan_vnifiltering.sh
75d8b6171bSPavel BegunkovTEST_GEN_FILES += io_uring_zerocopy_tx
767bcd9683SPavel BegunkovTEST_PROGS += io_uring_zerocopy_tx.sh
77c35ecb95SJoanne KoongTEST_GEN_FILES += bind_bhash
781be9ac87SJoanne KoongTEST_GEN_PROGS += sk_bind_sendto_listen
791be9ac87SJoanne KoongTEST_GEN_PROGS += sk_connect_zero_addr
80fd602f5cSPaul BlakeyTEST_PROGS += test_ingress_egress_chaining.sh
816df96146SKuniyuki IwashimaTEST_GEN_PROGS += so_incoming_cpu
82a61bd7b9SXin LongTEST_PROGS += sctp_vrf.sh
83a61bd7b9SXin LongTEST_GEN_FILES += sctp_hello
8491a7de85SWillem de BruijnTEST_GEN_FILES += csum
85ae543965SJakub SitnickiTEST_GEN_FILES += ip_local_port_range
8613715acfSKuniyuki IwashimaTEST_GEN_FILES += bind_wildcard
8762199e3fSIdo SchimmelTEST_PROGS += test_vxlan_mdb.sh
887648ac72SIdo SchimmelTEST_PROGS += test_bridge_neigh_suppress.sh
89305c0418SVladimir NikishkinTEST_PROGS += test_vxlan_nolocalbypass.sh
90b4084530SIdo SchimmelTEST_PROGS += test_bridge_backup_port.sh
9196eece69SAmit CohenTEST_PROGS += fdb_flush.sh
92a0bc96c0SWillem de BruijnTEST_PROGS += fq_band_pktlimit.sh
932258b666SLiu JianTEST_PROGS += vlan_hw_filter.sh
94e59f0e93SJakub KicinskiTEST_PROGS += bpf_offload.py
955e29a910SMichael Ellerman
96b881d089SPo-Hsu LinTEST_FILES := settings
9706efafd8SBenjamin PoirierTEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh
98b881d089SPo-Hsu Lin
99*6b88ce90SJakub KicinskiTEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c))
100*6b88ce90SJakub Kicinski
101876e3247SPaolo AbeniTEST_INCLUDES := forwarding/lib.sh
102876e3247SPaolo Abeni
1035e29a910SMichael Ellermaninclude ../lib.mk
1045e29a910SMichael Ellerman
105870f193dSFathi Boudra$(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
1065c5945dcSXiaoyan Li$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto
1073e839363SDmitry Safonov$(OUTPUT)/tcp_inq: LDLIBS += -lpthread
108c35ecb95SJoanne Koong$(OUTPUT)/bind_bhash: LDLIBS += -lpthread
109ba6e0e5cSBreno Leitao$(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/
1103c107f36SHangbin Liu
11198cb12ebSPaolo Abeni# Rules to generate bpf objs
1123c107f36SHangbin LiuCLANG ?= clang
1133c107f36SHangbin LiuSCRATCH_DIR := $(OUTPUT)/tools
1143c107f36SHangbin LiuBUILD_DIR := $(SCRATCH_DIR)/build
1153c107f36SHangbin LiuBPFDIR := $(abspath ../../../lib/bpf)
1163c107f36SHangbin LiuAPIDIR := $(abspath ../../../include/uapi)
1173c107f36SHangbin Liu
1183c107f36SHangbin LiuCCINCLUDE += -I../bpf
1193c107f36SHangbin LiuCCINCLUDE += -I../../../../usr/include/
1203c107f36SHangbin LiuCCINCLUDE += -I$(SCRATCH_DIR)/include
1213c107f36SHangbin Liu
1223c107f36SHangbin LiuBPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
1233c107f36SHangbin Liu
1243c107f36SHangbin LiuMAKE_DIRS := $(BUILD_DIR)/libbpf
1253c107f36SHangbin Liu$(MAKE_DIRS):
1266fc6d7f5SJakub Kicinski	$(call msg,MKDIR,,$@)
1276fc6d7f5SJakub Kicinski	$(Q)mkdir -p $@
1283c107f36SHangbin Liu
1293c107f36SHangbin Liu# Get Clang's default includes on this system, as opposed to those seen by
130bbaf1ff0SFangrui Song# '--target=bpf'. This fixes "missing" files on some architectures/distros,
1313c107f36SHangbin Liu# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
1323c107f36SHangbin Liu#
1333c107f36SHangbin Liu# Use '-idirafter': Don't interfere with include mechanics except where the
1343c107f36SHangbin Liu# build would have failed anyways.
1353c107f36SHangbin Liudefine get_sys_includes
1363c107f36SHangbin Liu$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
1373c107f36SHangbin Liu	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
1383c107f36SHangbin Liu$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
1393c107f36SHangbin Liuendef
1403c107f36SHangbin Liu
1413c107f36SHangbin Liuifneq ($(CROSS_COMPILE),)
1423c107f36SHangbin LiuCLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
1433c107f36SHangbin Liuendif
1443c107f36SHangbin Liu
1453c107f36SHangbin LiuCLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
1463c107f36SHangbin Liu
147*6b88ce90SJakub KicinskiBPF_PROG_OBJS := $(patsubst %.c,$(OUTPUT)/%.o,$(wildcard *.bpf.c))
148e59f0e93SJakub Kicinski
149e59f0e93SJakub Kicinski$(BPF_PROG_OBJS): $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS)
1506fc6d7f5SJakub Kicinski	$(call msg,BPF_PROG,,$@)
1516fc6d7f5SJakub Kicinski	$(Q)$(CLANG) -O2 -g --target=bpf $(CCINCLUDE) $(CLANG_SYS_INCLUDES) \
152b1c2ce11SJakub Kicinski	-c $< -o $@
1533c107f36SHangbin Liu
1543c107f36SHangbin Liu$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)		       \
1553c107f36SHangbin Liu	   $(APIDIR)/linux/bpf.h					       \
1563c107f36SHangbin Liu	   | $(BUILD_DIR)/libbpf
1576fc6d7f5SJakub Kicinski	$(call msg,MAKE,,$@)
1586fc6d7f5SJakub Kicinski	$(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
1593c107f36SHangbin Liu		    EXTRA_CFLAGS='-g -O0'				       \
1603c107f36SHangbin Liu		    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
1613c107f36SHangbin Liu
1623c107f36SHangbin LiuEXTRA_CLEAN := $(SCRATCH_DIR)
163