From owner-svn-src-all@freebsd.org Thu Jun 9 15:19:49 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56275AEF637; Thu, 9 Jun 2016 15:19:49 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 238DF1667; Thu, 9 Jun 2016 15:19:49 +0000 (UTC) (envelope-from lidl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u59FJmDp017294; Thu, 9 Jun 2016 15:19:48 GMT (envelope-from lidl@FreeBSD.org) Received: (from lidl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u59FJm84017293; Thu, 9 Jun 2016 15:19:48 GMT (envelope-from lidl@FreeBSD.org) Message-Id: <201606091519.u59FJm84017293@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lidl set sender to lidl@FreeBSD.org using -f From: Kurt Lidl Date: Thu, 9 Jun 2016 15:19:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301736 - head/contrib/blacklist/libexec X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2016 15:19:49 -0000 Author: lidl Date: Thu Jun 9 15:19:48 2016 New Revision: 301736 URL: https://svnweb.freebsd.org/changeset/base/301736 Log: Add IPFW support to blacklistd-helper Relnotes: YES Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6753 Modified: head/contrib/blacklist/libexec/blacklistd-helper Modified: head/contrib/blacklist/libexec/blacklistd-helper ============================================================================== --- head/contrib/blacklist/libexec/blacklistd-helper Thu Jun 9 14:44:05 2016 (r301735) +++ head/contrib/blacklist/libexec/blacklistd-helper Thu Jun 9 15:19:48 2016 (r301736) @@ -16,6 +16,11 @@ for f in npf pf; do break fi done +if [ -f "/etc/ipfw-blacklist.rc" ]; then + pf="ipfw" + . /etc/ipfw-blacklist.rc + ipfw_offset=${ipfw_offset:-2000} +fi if [ -z "$pf" ]; then echo "$0: Unsupported packet filter" 1>&2 @@ -43,6 +48,13 @@ esac case "$1" in add) case "$pf" in + ipfw) + rule=$(( $ipfw_offset + $6 )) # use $ipfw_offset+$port for rule number + tname="port$6" + /sbin/ipfw table $tname create type addr 2>/dev/null + /sbin/ipfw -q table $tname add "$addr/$mask" + /sbin/ipfw -q add $rule drop $3 from "table("$tname")" to any dst-port $6 + ;; npf) /sbin/npfctl rule "$2" add block in final $proto from \ "$addr/$mask" to any $port @@ -57,6 +69,9 @@ add) ;; rem) case "$pf" in + ipfw) + /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null + ;; npf) /sbin/npfctl rule "$2" rem-id "$7" ;; @@ -67,6 +82,9 @@ rem) ;; flush) case "$pf" in + ipfw) + /sbin/ipfw table "port$6" flush 2>/dev/null + ;; npf) /sbin/npfctl rule "$2" flush ;;