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