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