func IsChainExists(v, tableName, chainName string) (bool, error) {
	if err := isSupportedIPVersion(v); err != nil {
		return false, err
	}
	conn, err := initNftConn()
	if err != nil {
		return false, err
	}
	chains, err := conn.ListChains()
	if err != nil {
		return false, err
	}
	for _, chain := range chains {
		if chain == nil {
			continue
		}
		if chain.Name != chainName {
			continue
		}
		if chain.Table.Name != tableName {
			continue
		}
		if v == "4" {
			if chain.Table.Family != nftables.TableFamilyIPv4 {
				continue
			}
		} else {
			if chain.Table.Family != nftables.TableFamilyIPv6 {
				continue
			}
		}
		return true, nil
	}
	return false, nil
}
IsChainExists checks whether a chain exists.
package utils
import (
	"fmt"
	"github.com/google/nftables"
)
var defaultDropPolicy = nftables.ChainPolicyDrop