From: Teck Choon Giam Subject: [PATCH] vif-common.sh to support tap network devices in iptables FORWARD chain Date: Tue, 7 Jul 2009 19:29:17 +0800 Message-ID: <9b5c9bb30907070429m19fa021yacef5f3c9d664ec5@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi Xen Development Team, I submit the below patch for your consideration. This is useful if antispoof is enabled and tap network devices are used. i.e. HVM windows. --- vif-common.sh.orig 2009-07-07 19:09:39.000000000 +0800 +++ vif-common.sh 2009-07-07 19:19:42.000000000 +0800 @@ -73,6 +73,21 @@ local c="-D" fi + # Added support for tap network devices in iptables FORWARD chain as this + # is required if antispoof is enabled or otherwise all packets to/from tap + # devices will be dropped. + # Start adding by Giam Teck Choon. + local tapif=`echo $vif | sed 's/vif/tap/'` + local checktapif=`cat /proc/net/dev | grep "${tapif}:" | grep -v grep` + + if [ -n "$checktapif" ] ; then + iptables "$c" FORWARD -m physdev --physdev-in "$tapif" "$@" -j ACCEPT \ + 2>/dev/null && + iptables "$c" FORWARD -m state --state RELATED,ESTABLISHED -m physdev \ + --physdev-out "$tapif" -j ACCEPT 2>/dev/null + fi + # End adding by Giam Teck Choon. + iptables "$c" FORWARD -m physdev --physdev-in "$vif" "$@" -j ACCEPT \ 2>/dev/null && iptables "$c" FORWARD -m state --state RELATED,ESTABLISHED -m physdev \ Thanks. Kindest regards, Giam Teck Choon