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 12. iptables_lib.sh 13 14do_setup() 15{ 16 init 17 local ip_table="ip${TST_IPV6}" 18 19 if ! nft list table $ip_table filter > /dev/null 2>&1; then 20 ROD nft add table $ip_table filter 21 cleanup_table=1 22 fi 23 if ! nft list chain $ip_table filter INPUT > /dev/null 2>&1; then 24 ROD nft add chain $ip_table filter INPUT '{ type filter hook input priority 0; }' 25 cleanup_chain=1 26 fi 27} 28 29do_cleanup() 30{ 31 local ip_table="ip${TST_IPV6}" 32 33 [ "$cleanup_chain" = 1 ] && nft delete chain $ip_table filter INPUT >/dev/null 2>&1 34 [ "$cleanup_table" = 1 ] && nft delete table $ip_table filter >/dev/null 2>&1 35 cleanup 36} 37 38tst_run 39