__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# By Seth Schoen (c) 2021, for the IPv4 Unicast Extensions Project
# Thanks to David Ahern for help and advice on nettest modifications.
#
# Self-tests for IPv4 address extensions: the kernel's ability to accept
# certain traditionally unused or unallocated IPv4 addresses. For each kind
# of address, we test for interface assignment, ping, TCP, and forwarding.
# Must be run as root (to manipulate network namespaces and virtual
# interfaces).
#
# Things we test for here:
#
# * Currently the kernel accepts addresses in 0/8 and 240/4 as valid.
#
# * Notwithstanding that, 0.0.0.0 and 255.255.255.255 cannot be assigned.
#
# * Currently the kernel DOES NOT accept unicast use of the lowest
# address in an IPv4 subnet (e.g. 192.168.100.0/32 in 192.168.100.0/24).
# This is treated as a second broadcast address, for compatibility
# with 4.2BSD (!).
#
# * Currently the kernel DOES NOT accept unicast use of any of 127/8.
#
# * Currently the kernel DOES NOT accept unicast use of any of 224/4.
#
# These tests provide an easy way to flip the expected result of any
# of these behaviors for testing kernel patches that change them.
source lib.sh
check_gen_prog "nettest"
result=0
hide_output(){ exec 3>&1 4>&2 >/dev/null 2>/dev/null; }
show_output(){ exec >&3 2>&4; }
show_result(){
if [ $1 -eq 0 ]; then
printf "TEST: %-60s [ OK ]\n" "${2}"
else
printf "TEST: %-60s [FAIL]\n" "${2}"
result=1
fi
}
_do_segmenttest(){
# Perform a simple set of link tests between a pair of
# IP addresses on a shared (virtual) segment, using
# ping and nettest.
# foo --- bar
# Arguments: ip_a ip_b prefix_length test_description
#
# Caller must set up $foo_ns and $bar_ns namespaces
# containing linked veth devices foo and bar,
# respectively.
ip -n $foo_ns address add $1/$3 dev foo || return 1
ip -n $foo_ns link set foo up || return 1
ip -n $bar_ns address add $2/$3 dev bar || return 1
ip -n $bar_ns link set bar up || return 1
ip netns exec $foo_ns timeout 2 ping -c 1 $2 || return 1
ip netns exec $bar_ns timeout 2 ping -c 1 $1 || return 1
nettest -B -N $bar_ns -O $foo_ns -r $1 || return 1
nettest -B -N $foo_ns -O $bar_ns -r $2 || return 1
return 0
}
_do_route_test(){
# Perform a simple set of gateway tests.
#
# [foo] <---> [foo1]-[bar1] <---> [bar] /prefix
# host gateway host
#
# Arguments: foo_ip foo1_ip bar1_ip bar_ip prefix_len test_description
# Displays test result and returns success or failure.
# Caller must set up $foo_ns, $bar_ns, and $router_ns
# containing linked veth devices foo-foo1, bar1-bar
# (foo in $foo_ns, foo1 and bar1 in $router_ns, and
# bar in $bar_ns).
ip -n $foo_ns address add $1/$5 dev foo || return 1
ip -n $foo_ns link set foo up || return 1
ip -n $foo_ns route add default via $2 || return 1
ip -n $bar_ns address add $4/$5 dev bar || return 1
ip -n $bar_ns link set bar up || return 1
ip -n $bar_ns route add default via $3 || return 1
ip -n $router_ns address add $2/$5 dev foo1 || return 1
ip -n $router_ns link set foo1 up || return 1
ip -n $router_ns address add $3/$5 dev bar1 || return 1
ip -n $router_ns link set bar1 up || return 1
echo 1 | ip netns exec $router_ns tee /proc/sys/net/ipv4/ip_forward
ip netns exec $foo_ns timeout 2 ping -c 1 $2 || return 1
ip netns exec $foo_ns timeout 2 ping -c 1 $4 || return 1
ip netns exec $bar_ns timeout 2 ping -c 1 $3 || return 1
ip netns exec $bar_ns timeout 2 ping -c 1 $1 || return 1
nettest -B -N $bar_ns -O $foo_ns -r $1 || return 1
nettest -B -N $foo_ns -O $bar_ns -r $4 || return 1
return 0
}
segmenttest(){
# Sets up veth link and tries to connect over it.
# Arguments: ip_a ip_b prefix_len test_description
hide_output
setup_ns foo_ns bar_ns
ip link add foo netns $foo_ns type veth peer name bar netns $bar_ns
test_result=0
_do_segmenttest "$@" || test_result=1
ip netns pids $foo_ns | xargs -r kill -9
ip netns pids $bar_ns | xargs -r kill -9
cleanup_ns $foo_ns $bar_ns
show_output
# inverted tests will expect failure instead of success
[ -n "$expect_failure" ] && test_result=`expr 1 - $test_result`
show_result $test_result "$4"
}
route_test(){
# Sets up a simple gateway and tries to connect through it.
# [foo] <---> [foo1]-[bar1] <---> [bar] /prefix
# Arguments: foo_ip foo1_ip bar1_ip bar_ip prefix_len test_description
# Returns success or failure.
hide_output
setup_ns foo_ns bar_ns router_ns
ip link add foo netns $foo_ns type veth peer name foo1 netns $router_ns
ip link add bar netns $bar_ns type veth peer name bar1 netns $router_ns
test_result=0
_do_route_test "$@" || test_result=1
ip netns pids $foo_ns | xargs -r kill -9
ip netns pids $bar_ns | xargs -r kill -9
ip netns pids $router_ns | xargs -r kill -9
cleanup_ns $foo_ns $bar_ns $router_ns
show_output
# inverted tests will expect failure instead of success
[ -n "$expect_failure" ] && test_result=`expr 1 - $test_result`
show_result $test_result "$6"
}
echo "###########################################################################"
echo "Unicast address extensions tests (behavior of reserved IPv4 addresses)"
echo "###########################################################################"
#
# Test support for 240/4
segmenttest 240.1.2.1 240.1.2.4 24 "assign and ping within 240/4 (1 of 2) (is allowed)"
segmenttest 250.100.2.1 250.100.30.4 16 "assign and ping within 240/4 (2 of 2) (is allowed)"
#
# Test support for 0/8
segmenttest 0.1.2.17 0.1.2.23 24 "assign and ping within 0/8 (1 of 2) (is allowed)"
segmenttest 0.77.240.17 0.77.2.23 16 "assign and ping within 0/8 (2 of 2) (is allowed)"
#
# Even 255.255/16 is OK!
segmenttest 255.255.3.1 255.255.50.77 16 "assign and ping inside 255.255/16 (is allowed)"
#
# Or 255.255.255/24
segmenttest 255.255.255.1 255.255.255.254 24 "assign and ping inside 255.255.255/24 (is allowed)"
#
# Routing between different networks
route_test 240.5.6.7 240.5.6.1 255.1.2.1 255.1.2.3 24 "route between 240.5.6/24 and 255.1.2/24 (is allowed)"
route_test 0.200.6.7 0.200.38.1 245.99.101.1 245.99.200.111 16 "route between 0.200/16 and 245.99/16 (is allowed)"
#
# Test support for lowest address ending in .0
segmenttest 5.10.15.20 5.10.15.0 24 "assign and ping lowest address (/24)"
#
# Test support for lowest address not ending in .0
segmenttest 192.168.101.192 192.168.101.193 26 "assign and ping lowest address (/26)"
#
# Routing using lowest address as a gateway/endpoint
route_test 192.168.42.1 192.168.42.0 9.8.7.6 9.8.7.0 24 "routing using lowest address"
#
# ==============================================
# ==== TESTS THAT CURRENTLY EXPECT FAILURE =====
# ==============================================
expect_failure=true
# It should still not be possible to use 0.0.0.0 or 255.255.255.255
# as a unicast address. Thus, these tests expect failure.
segmenttest 0.0.1.5 0.0.0.0 16 "assigning 0.0.0.0 (is forbidden)"
segmenttest 255.255.255.1 255.255.255.255 16 "assigning 255.255.255.255 (is forbidden)"
#
# Test support for not having all of 127 be loopback
# Currently Linux does not allow this, so this should fail too
segmenttest 127.99.4.5 127.99.4.6 16 "assign and ping inside 127/8 (is forbidden)"
#
# Test support for unicast use of class D
# Currently Linux does not allow this, so this should fail too
segmenttest 225.1.2.3 225.1.2.200 24 "assign and ping class D address (is forbidden)"
#
# Routing using class D as a gateway
route_test 225.1.42.1 225.1.42.2 9.8.7.6 9.8.7.1 24 "routing using class D (is forbidden)"
#
# Routing using 127/8
# Currently Linux does not allow this, so this should fail too
route_test 127.99.2.3 127.99.2.4 200.1.2.3 200.1.2.4 24 "routing using 127/8 (is forbidden)"
#
unset expect_failure
# =====================================================
# ==== END OF TESTS THAT CURRENTLY EXPECT FAILURE =====
# =====================================================
exit ${result}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| af_unix | Folder | 0755 |
|
|
| forwarding | Folder | 0755 |
|
|
| hsr | Folder | 0755 |
|
|
| lib | Folder | 0755 |
|
|
| mptcp | Folder | 0755 |
|
|
| netfilter | Folder | 0755 |
|
|
| openvswitch | Folder | 0755 |
|
|
| packetdrill | Folder | 0755 |
|
|
| rds | Folder | 0755 |
|
|
| tcp_ao | Folder | 0755 |
|
|
| Makefile | File | 4.82 KB | 0644 |
|
| altnames.sh | File | 1.77 KB | 0755 |
|
| amt.sh | File | 9.2 KB | 0755 |
|
| arp_ndisc_evict_nocarrier.sh | File | 5.15 KB | 0755 |
|
| arp_ndisc_untracked_subnets.sh | File | 7.04 KB | 0755 |
|
| bareudp.sh | File | 20.79 KB | 0755 |
|
| big_tcp.sh | File | 5.49 KB | 0755 |
|
| bind_bhash.sh | File | 1.34 KB | 0755 |
|
| busy_poll_test.sh | File | 3.47 KB | 0755 |
|
| cmsg_ipv6.sh | File | 3.34 KB | 0755 |
|
| cmsg_so_mark.sh | File | 1.54 KB | 0755 |
|
| cmsg_so_priority.sh | File | 3.93 KB | 0755 |
|
| cmsg_time.sh | File | 2.22 KB | 0755 |
|
| drop_monitor_tests.sh | File | 4.34 KB | 0755 |
|
| fcnal-test.sh | File | 106.62 KB | 0755 |
|
| fdb_flush.sh | File | 21.04 KB | 0755 |
|
| fdb_notify.sh | File | 1.81 KB | 0755 |
|
| fib-onlink-tests.sh | File | 12.04 KB | 0755 |
|
| fib_nexthop_multiprefix.sh | File | 5.81 KB | 0755 |
|
| fib_nexthop_nongw.sh | File | 2.19 KB | 0755 |
|
| fib_nexthops.sh | File | 73.9 KB | 0755 |
|
| fib_rule_tests.sh | File | 17.66 KB | 0755 |
|
| fib_tests.sh | File | 77.47 KB | 0755 |
|
| fin_ack_lat.sh | File | 507 B | 0755 |
|
| fq_band_pktlimit.sh | File | 1.81 KB | 0755 |
|
| gre_gso.sh | File | 4.04 KB | 0755 |
|
| gro.sh | File | 2.27 KB | 0755 |
|
| icmp.sh | File | 2.52 KB | 0755 |
|
| icmp_redirect.sh | File | 12.49 KB | 0755 |
|
| in_netns.sh | File | 323 B | 0755 |
|
| io_uring_zerocopy_tx.sh | File | 3 KB | 0755 |
|
| ioam6.sh | File | 50.49 KB | 0755 |
|
| ip6_gre_headroom.sh | File | 1.37 KB | 0755 |
|
| ip_defrag.sh | File | 2.04 KB | 0755 |
|
| ip_local_port_range.sh | File | 153 B | 0755 |
|
| ipv6_flowlabel.sh | File | 1 KB | 0755 |
|
| ipv6_route_update_soft_lockup.sh | File | 10.8 KB | 0755 |
|
| l2_tos_ttl_inherit.sh | File | 13.95 KB | 0755 |
|
| l2tp.sh | File | 9.68 KB | 0755 |
|
| lib.sh | File | 8.65 KB | 0644 |
|
| lwt_dst_cache_ref_loop.sh | File | 5.94 KB | 0755 |
|
| msg_zerocopy.sh | File | 2.93 KB | 0755 |
|
| ndisc_unsolicited_na_test.sh | File | 5.85 KB | 0755 |
|
| net_helper.sh | File | 514 B | 0644 |
|
| netdevice.sh | File | 5.69 KB | 0755 |
|
| netns-name.sh | File | 2.4 KB | 0755 |
|
| netns-sysctl.sh | File | 910 B | 0755 |
|
| pmtu.sh | File | 78.42 KB | 0755 |
|
| psock_snd.sh | File | 2.2 KB | 0755 |
|
| reuseaddr_ports_exhausted.sh | File | 635 B | 0755 |
|
| reuseport_addr_any.sh | File | 81 B | 0755 |
|
| route_localnet.sh | File | 1.92 KB | 0755 |
|
| rps_default_mask.sh | File | 2.19 KB | 0755 |
|
| rtnetlink.sh | File | 35.16 KB | 0755 |
|
| rxtimestamp.sh | File | 79 B | 0755 |
|
| sctp_vrf.sh | File | 5.81 KB | 0755 |
|
| setup_loopback.sh | File | 2.7 KB | 0644 |
|
| setup_veth.sh | File | 1.01 KB | 0644 |
|
| so_txtime.sh | File | 2.71 KB | 0755 |
|
| srv6_end_dt46_l3vpn_test.sh | File | 20.57 KB | 0755 |
|
| srv6_end_dt4_l3vpn_test.sh | File | 16.92 KB | 0755 |
|
| srv6_end_dt6_l3vpn_test.sh | File | 17.11 KB | 0755 |
|
| srv6_end_dx4_netfilter_test.sh | File | 10.92 KB | 0755 |
|
| srv6_end_dx6_netfilter_test.sh | File | 11.13 KB | 0755 |
|
| srv6_end_flavors_test.sh | File | 23.56 KB | 0755 |
|
| srv6_end_next_csid_l3vpn_test.sh | File | 32.53 KB | 0755 |
|
| srv6_end_x_next_csid_l3vpn_test.sh | File | 35.46 KB | 0755 |
|
| srv6_hencap_red_l3vpn_test.sh | File | 23.15 KB | 0755 |
|
| srv6_hl2encap_red_l2vpn_test.sh | File | 20.51 KB | 0755 |
|
| stress_reuseport_listen.sh | File | 539 B | 0755 |
|
| tcp_fastopen_backup_key.sh | File | 1.06 KB | 0755 |
|
| test_blackhole_dev.sh | File | 280 B | 0755 |
|
| test_bpf.sh | File | 225 B | 0755 |
|
| test_bridge_backup_port.sh | File | 27.35 KB | 0755 |
|
| test_bridge_neigh_suppress.sh | File | 28.4 KB | 0755 |
|
| test_ingress_egress_chaining.sh | File | 2.14 KB | 0644 |
|
| test_vxlan_fdb_changelink.sh | File | 678 B | 0755 |
|
| test_vxlan_mdb.sh | File | 92.63 KB | 0755 |
|
| test_vxlan_nolocalbypass.sh | File | 5.57 KB | 0755 |
|
| test_vxlan_under_vrf.sh | File | 5.54 KB | 0755 |
|
| test_vxlan_vnifiltering.sh | File | 20.91 KB | 0755 |
|
| toeplitz.sh | File | 4.87 KB | 0755 |
|
| toeplitz_client.sh | File | 667 B | 0755 |
|
| traceroute.sh | File | 6.91 KB | 0755 |
|
| txtimestamp.sh | File | 1.84 KB | 0755 |
|
| udpgro.sh | File | 5.72 KB | 0755 |
|
| udpgro_bench.sh | File | 2.08 KB | 0755 |
|
| udpgro_frglist.sh | File | 2.43 KB | 0755 |
|
| udpgro_fwd.sh | File | 7.08 KB | 0755 |
|
| udpgso.sh | File | 2.42 KB | 0755 |
|
| udpgso_bench.sh | File | 2.83 KB | 0755 |
|
| unicast_extensions.sh | File | 7.77 KB | 0755 |
|
| veth.sh | File | 10.75 KB | 0755 |
|
| vlan_bridge_binding.sh | File | 4.49 KB | 0755 |
|
| vlan_hw_filter.sh | File | 819 B | 0755 |
|
| vrf-xfrm-tests.sh | File | 10.65 KB | 0755 |
|
| vrf_route_leaking.sh | File | 16.48 KB | 0755 |
|
| vrf_strict_mode_test.sh | File | 8 KB | 0755 |
|
| xfrm_policy.sh | File | 14.65 KB | 0755 |
|
| xfrm_policy_add_speed.sh | File | 1.51 KB | 0755 |
|