move ipset and ip6set logic out for simpler code