1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2019 Oracle and/or its affiliates. All Rights Reserved. 4 5TST_SETUP="do_setup" 6TST_CLEANUP="do_cleanup" 7TST_NEEDS_DRIVERS="nf_tables" 8use_iptables=0 9cleanup_table=0 10cleanup_chain=0 11 12do_setup() 13{ 14 init 15 local ip_table="ip${TST_IPV6}" 16 17 if ! nft list table $ip_table filter > /dev/null 2>&1; then 18 ROD nft add table $ip_table filter 19 cleanup_table=1 20 fi 21 if ! nft list chain $ip_table filter INPUT > /dev/null 2>&1; then 22 ROD nft add chain $ip_table filter INPUT '{ type filter hook input priority 0; }' 23 cleanup_chain=1 24 fi 25} 26 27do_cleanup() 28{ 29 local ip_table="ip${TST_IPV6}" 30 31 [ "$cleanup_chain" = 1 ] && nft delete chain $ip_table filter INPUT >/dev/null 2>&1 32 [ "$cleanup_table" = 1 ] && nft delete table $ip_table filter >/dev/null 2>&1 33 cleanup 34} 35 36. iptables_lib.sh 37tst_run 38