xref: /linux/tools/testing/selftests/net/Makefile (revision c894ec016c9d0418dd832202225a8c64f450d71e)
1# SPDX-License-Identifier: GPL-2.0
2# Makefile for net selftests
3
4CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g
5CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES)
6
7TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \
8	      rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
9TEST_PROGS += fib_tests.sh fib-onlink-tests.sh pmtu.sh udpgso.sh ip_defrag.sh
10TEST_PROGS += udpgso_bench.sh fib_rule_tests.sh msg_zerocopy.sh psock_snd.sh
11TEST_PROGS += udpgro_bench.sh udpgro.sh test_vxlan_under_vrf.sh reuseport_addr_any.sh
12TEST_PROGS += test_vxlan_fdb_changelink.sh so_txtime.sh ipv6_flowlabel.sh
13TEST_PROGS += tcp_fastopen_backup_key.sh fcnal-test.sh l2tp.sh traceroute.sh
14TEST_PROGS += fin_ack_lat.sh fib_nexthop_multiprefix.sh fib_nexthops.sh fib_nexthop_nongw.sh
15TEST_PROGS += altnames.sh icmp.sh icmp_redirect.sh ip6_gre_headroom.sh
16TEST_PROGS += route_localnet.sh
17TEST_PROGS += reuseaddr_ports_exhausted.sh
18TEST_PROGS += txtimestamp.sh
19TEST_PROGS += vrf-xfrm-tests.sh
20TEST_PROGS += rxtimestamp.sh
21TEST_PROGS += devlink_port_split.py
22TEST_PROGS += drop_monitor_tests.sh
23TEST_PROGS += vrf_route_leaking.sh
24TEST_PROGS += bareudp.sh
25TEST_PROGS += amt.sh
26TEST_PROGS += unicast_extensions.sh
27TEST_PROGS += udpgro_fwd.sh
28TEST_PROGS += udpgro_frglist.sh
29TEST_PROGS += veth.sh
30TEST_PROGS += ioam6.sh
31TEST_PROGS += gro.sh
32TEST_PROGS += gre_gso.sh
33TEST_PROGS += cmsg_so_mark.sh
34TEST_PROGS += cmsg_time.sh cmsg_ipv6.sh
35TEST_PROGS += srv6_end_dt46_l3vpn_test.sh
36TEST_PROGS += srv6_end_dt4_l3vpn_test.sh
37TEST_PROGS += srv6_end_dt6_l3vpn_test.sh
38TEST_PROGS += srv6_hencap_red_l3vpn_test.sh
39TEST_PROGS += srv6_hl2encap_red_l2vpn_test.sh
40TEST_PROGS += srv6_end_next_csid_l3vpn_test.sh
41TEST_PROGS += srv6_end_flavors_test.sh
42TEST_PROGS += vrf_strict_mode_test.sh
43TEST_PROGS += arp_ndisc_evict_nocarrier.sh
44TEST_PROGS += ndisc_unsolicited_na_test.sh
45TEST_PROGS += arp_ndisc_untracked_subnets.sh
46TEST_PROGS += stress_reuseport_listen.sh
47TEST_PROGS += l2_tos_ttl_inherit.sh
48TEST_PROGS += bind_bhash.sh
49TEST_PROGS += ip_local_port_range.sh
50TEST_PROGS += rps_default_mask.sh
51TEST_PROGS += big_tcp.sh
52TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh
53TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh
54TEST_GEN_FILES =  socket nettest
55TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any
56TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite
57TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx ip_defrag
58TEST_GEN_FILES += so_txtime ipv6_flowlabel ipv6_flowlabel_mgr so_netns_cookie
59TEST_GEN_FILES += tcp_fastopen_backup_key
60TEST_GEN_FILES += fin_ack_lat
61TEST_GEN_FILES += reuseaddr_ports_exhausted
62TEST_GEN_FILES += hwtstamp_config rxtimestamp timestamping txtimestamp
63TEST_GEN_FILES += ipsec
64TEST_GEN_FILES += ioam6_parser
65TEST_GEN_FILES += gro
66TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa
67TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun tap
68TEST_GEN_FILES += toeplitz
69TEST_GEN_FILES += cmsg_sender
70TEST_GEN_FILES += stress_reuseport_listen
71TEST_PROGS += test_vxlan_vnifiltering.sh
72TEST_GEN_FILES += io_uring_zerocopy_tx
73TEST_PROGS += io_uring_zerocopy_tx.sh
74TEST_GEN_FILES += bind_bhash
75TEST_GEN_PROGS += sk_bind_sendto_listen
76TEST_GEN_PROGS += sk_connect_zero_addr
77TEST_PROGS += test_ingress_egress_chaining.sh
78TEST_GEN_PROGS += so_incoming_cpu
79TEST_PROGS += sctp_vrf.sh
80TEST_GEN_FILES += sctp_hello
81TEST_GEN_FILES += csum
82TEST_GEN_FILES += nat6to4.o
83TEST_GEN_FILES += ip_local_port_range
84TEST_GEN_FILES += bind_wildcard
85TEST_PROGS += test_vxlan_mdb.sh
86TEST_PROGS += test_bridge_neigh_suppress.sh
87
88TEST_FILES := settings
89
90include ../lib.mk
91
92$(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
93$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto
94$(OUTPUT)/tcp_inq: LDLIBS += -lpthread
95$(OUTPUT)/bind_bhash: LDLIBS += -lpthread
96
97# Rules to generate bpf obj nat6to4.o
98CLANG ?= clang
99SCRATCH_DIR := $(OUTPUT)/tools
100BUILD_DIR := $(SCRATCH_DIR)/build
101BPFDIR := $(abspath ../../../lib/bpf)
102APIDIR := $(abspath ../../../include/uapi)
103
104CCINCLUDE += -I../bpf
105CCINCLUDE += -I../../../../usr/include/
106CCINCLUDE += -I$(SCRATCH_DIR)/include
107
108BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
109
110MAKE_DIRS := $(BUILD_DIR)/libbpf
111$(MAKE_DIRS):
112	mkdir -p $@
113
114# Get Clang's default includes on this system, as opposed to those seen by
115# '-target bpf'. This fixes "missing" files on some architectures/distros,
116# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
117#
118# Use '-idirafter': Don't interfere with include mechanics except where the
119# build would have failed anyways.
120define get_sys_includes
121$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
122	| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
123$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}')
124endef
125
126ifneq ($(CROSS_COMPILE),)
127CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%))
128endif
129
130CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH))
131
132$(OUTPUT)/nat6to4.o: nat6to4.c $(BPFOBJ) | $(MAKE_DIRS)
133	$(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) $(CLANG_SYS_INCLUDES) -o $@
134
135$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile)		       \
136	   $(APIDIR)/linux/bpf.h					       \
137	   | $(BUILD_DIR)/libbpf
138	$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/     \
139		    EXTRA_CFLAGS='-g -O0'				       \
140		    DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
141
142EXTRA_CLEAN := $(SCRATCH_DIR)
143