xref: /linux/tools/testing/selftests/net/Makefile (revision 3c107f36db061603bee7564fbd6388b1f1879fd3)
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)
6a6f68034SDavid S. Miller
7b69d540dSFlorian WestphalTEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
8509e56b3SMahesh Bandewar	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
902c7f38bSPeter OskolkovTEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh ip_defrag.sh
1075f0139fSWillem de BruijnTEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh psock_snd.sh
116254e5c6SPeter OskolkovTEST_PROGS += udpgro_bench.sh udpgro.sh test_vxlan_under_vrf.sh reuseport_addr_any.sh
123fb321fdSWillem de BruijnTEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh
133c28d99fSFrancesco RuggeriTEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh
14cd72e61bSNicolas DichtelTEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh fib_nexthop_nongw.sh
15ca3676f9SHangbin LiuTEST_PROGS += altnames.sh icmp.sh icmp_redirect.sh ip6_gre_headroom.sh
16919a23e9SHangbin LiuTEST_PROGS += route_localnet.sh
177f204a7dSKuniyuki IwashimaTEST_PROGS += reuseaddr_ports_exhausted.sh
185ef5c90eSJian YangTEST_PROGS += txtimestamp.sh
193f251d74SDavid AhernTEST_PROGS += vrf-xfrm-tests.sh
200558c396StannerloveTEST_PROGS += rxtimestamp.sh
21f3348a82SDanielle RatsonTEST_PROGS += devlink_port_split.py
22b7cc6d3cSIdo SchimmelTEST_PROGS += drop_monitor_tests.sh
231a017276SMichael JeansonTEST_PROGS += vrf_route_leaking.sh
24bbbc7aa4SGuillaume NaultTEST_PROGS += bareudp.sh
25c08e8baeSTaehee YooTEST_PROGS += amt.sh
269b0b7837SSeth David SchoenTEST_PROGS += unicast_extensions.sh
27a062260aSPaolo AbeniTEST_PROGS += udpgro_fwd.sh
28edae34a3SLina WangTEST_PROGS += udpgro_frglist.sh
291c3cadbeSPaolo AbeniTEST_PROGS += veth.sh
30968691c7SJustin IurmanTEST_PROGS += ioam6.sh
319af771d2SPaolo AbeniTEST_PROGS += gro.sh
32025efa0aSJakub KicinskiTEST_PROGS += gre_gso.sh
33b0ced8f2SJakub KicinskiTEST_PROGS += cmsg_so_mark.sh
3438dcd957SHangbin LiuTEST_PROGS += cmsg_time.sh cmsg_ipv6.sh
35653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt46_l3vpn_test.sh
36653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt4_l3vpn_test.sh
37653e7f19SHangbin LiuTEST_PROGS += srv6_end_dt6_l3vpn_test.sh
386ab4eb5aSAndrea MayerTEST_PROGS += srv6_hencap_red_l3vpn_test.sh
3995baa4e8SAndrea MayerTEST_PROGS += srv6_hl2encap_red_l2vpn_test.sh
4019d6356aSAndrea MayerTEST_PROGS += srv6_end_next_csid_l3vpn_test.sh
418883deb5SHangbin LiuTEST_PROGS += vrf_strict_mode_test.sh
42619ca0d0SJames PrestwoodTEST_PROGS += arp_ndisc_evict_nocarrier.sh
43f9a2fb73SArun Ajith STEST_PROGS += ndisc_unsolicited_na_test.sh
440ea7b0a4SJaehee ParkTEST_PROGS += arp_ndisc_untracked_subnets.sh
45ec8cb4f6SMartin KaFai LauTEST_PROGS += stress_reuseport_listen.sh
4688e500afSAdel AbouchaevTEST_PROGS += l2_tos_ttl_inherit.sh
47c35ecb95SJoanne KoongTEST_PROGS += bind_bhash.sh
48b99ac184SHangbin LiuTEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh
4917b67370SHangbin LiuTEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh
50acda655fSDavid AhernTEST_GEN_FILES =  socket nettest
516254e5c6SPeter OskolkovTEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
52358be656SWillem de BruijnTEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
5302c7f38bSPeter OskolkovTEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx ip_defrag
54ae24bab2SLorenz BauerTEST_GEN_FILES += so_txtime ipv6_flowlabel ipv6_flowlabel_mgr so_netns_cookie
5510fbcdd1SJason BaronTEST_GEN_FILES += tcp_fastopen_backup_key
56af8c8a45SSeongJae ParkTEST_GEN_FILES += fin_ack_lat
575ef5c90eSJian YangTEST_GEN_FILES += reuseaddr_ports_exhausted
585ef5c90eSJian YangTEST_GEN_FILES += hwtstamp_config rxtimestamp timestamping txtimestamp
59bc2652b7SDmitry SafonovTEST_GEN_FILES += ipsec
60968691c7SJustin IurmanTEST_GEN_FILES += ioam6_parser
617d157501SCoco LiTEST_GEN_FILES += gro
62e06d79fbSJosef BacikTEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
632e64fe46SCezar BulinaruTEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun tap
645ebfb4ccSCoco LiTEST_GEN_FILES += toeplitz
65a086ee24SJakub KicinskiTEST_GEN_FILES += cmsg_sender
66ec8cb4f6SMartin KaFai LauTEST_GEN_FILES += stress_reuseport_listen
6738dcd957SHangbin LiuTEST_PROGS += test_vxlan_vnifiltering.sh
68d8b6171bSPavel BegunkovTEST_GEN_FILES += io_uring_zerocopy_tx
697bcd9683SPavel BegunkovTEST_PROGS += io_uring_zerocopy_tx.sh
70c35ecb95SJoanne KoongTEST_GEN_FILES += bind_bhash
711be9ac87SJoanne KoongTEST_GEN_PROGS += sk_bind_sendto_listen
721be9ac87SJoanne KoongTEST_GEN_PROGS += sk_connect_zero_addr
73fd602f5cSPaul BlakeyTEST_PROGS += test_ingress_egress_chaining.sh
746df96146SKuniyuki IwashimaTEST_GEN_PROGS += so_incoming_cpu
75a61bd7b9SXin LongTEST_PROGS += sctp_vrf.sh
76a61bd7b9SXin LongTEST_GEN_FILES += sctp_hello
7791a7de85SWillem de BruijnTEST_GEN_FILES += csum
78*3c107f36SHangbin LiuTEST_GEN_FILES += nat6to4.o
795e29a910SMichael Ellerman
80b881d089SPo-Hsu LinTEST_FILES := settings
81b881d089SPo-Hsu Lin
825e29a910SMichael Ellermaninclude ../lib.mk
835e29a910SMichael Ellerman
84870f193dSFathi Boudra$(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
853e839363SDmitry Safonov$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
863e839363SDmitry Safonov$(OUTPUT)/tcp_inq: LDLIBS += -lpthread
87c35ecb95SJoanne Koong$(OUTPUT)/bind_bhash: LDLIBS += -lpthread
88*3c107f36SHangbin Liu
89*3c107f36SHangbin Liu# Rules to generate bpf obj nat6to4.o
90*3c107f36SHangbin LiuCLANG ?= clang
91*3c107f36SHangbin LiuSCRATCH_DIR := $(OUTPUT)/tools
92*3c107f36SHangbin LiuBUILD_DIR := $(SCRATCH_DIR)/build
93*3c107f36SHangbin LiuBPFDIR := $(abspath ../../../lib/bpf)
94*3c107f36SHangbin LiuAPIDIR := $(abspath ../../../include/uapi)
95*3c107f36SHangbin Liu
96*3c107f36SHangbin LiuCCINCLUDE += -I../bpf
97*3c107f36SHangbin LiuCCINCLUDE += -I../../../../usr/include/
98*3c107f36SHangbin LiuCCINCLUDE += -I$(SCRATCH_DIR)/include
99*3c107f36SHangbin Liu
100*3c107f36SHangbin LiuBPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
101*3c107f36SHangbin Liu
102*3c107f36SHangbin LiuMAKE_DIRS := $(BUILD_DIR)/libbpf
103*3c107f36SHangbin Liu$(MAKE_DIRS):
104*3c107f36SHangbin Liu	mkdir -p $@
105*3c107f36SHangbin Liu
106*3c107f36SHangbin Liu# Get Clang's default includes on this system, as opposed to those seen by
107*3c107f36SHangbin Liu# '-target bpf'. This fixes "missing" files on some architectures/distros,
108*3c107f36SHangbin Liu# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
109*3c107f36SHangbin Liu#
110*3c107f36SHangbin Liu# Use '-idirafter': Don't interfere with include mechanics except where the
111*3c107f36SHangbin Liu# build would have failed anyways.
112*3c107f36SHangbin Liudefine get_sys_includes
113*3c107f36SHangbin Liu$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
114*3c107f36SHangbin Liu	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
115*3c107f36SHangbin Liu$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
116*3c107f36SHangbin Liuendef
117*3c107f36SHangbin Liu
118*3c107f36SHangbin Liuifneq ($(CROSS_COMPILE),)
119*3c107f36SHangbin LiuCLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
120*3c107f36SHangbin Liuendif
121*3c107f36SHangbin Liu
122*3c107f36SHangbin LiuCLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
123*3c107f36SHangbin Liu
124*3c107f36SHangbin Liu$(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS)
125*3c107f36SHangbin Liu	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
126*3c107f36SHangbin Liu
127*3c107f36SHangbin Liu$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)		       \
128*3c107f36SHangbin Liu	   $(APIDIR)/linux/bpf.h					       \
129*3c107f36SHangbin Liu	   | $(BUILD_DIR)/libbpf
130*3c107f36SHangbin Liu	$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/     \
131*3c107f36SHangbin Liu		    EXTRA_CFLAGS='-g -O0'				       \
132*3c107f36SHangbin Liu		    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
133*3c107f36SHangbin Liu
134*3c107f36SHangbin LiuEXTRA_CLEAN := $(SCRATCH_DIR)
135