[packages] natpmp: several fixes

- use service wrappers to launch natpmp, its builtin daemon setup is broken
- rework uci config to allow logical ifnames
- change and fix default config to use abstract "lan" and "wan" instead of hardcoded (and improperly formatted) device names

git-svn-id: svn://svn.openwrt.org/openwrt/packages@31644 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2012-05-07 18:21:47 +00:00
parent 6a421ce2a8
commit f90214ebbd
3 changed files with 49 additions and 37 deletions

View File

@ -1,5 +1,5 @@
# #
# Copyright (C) 2007-2011 OpenWrt.org # Copyright (C) 2007-2012 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=natpmp PKG_NAME:=natpmp
PKG_VERSION:=0.2.3 PKG_VERSION:=0.2.3
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_SOURCE_URL:=http://download.savannah.nongnu.org/releases/natpmp/ PKG_SOURCE_URL:=http://download.savannah.nongnu.org/releases/natpmp/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View File

@ -1,4 +1,4 @@
config natpmp config natpmp
option outbound_interface vlan0 option outbound_interface wan
option inbound_interfaces br-lan eth1 option inbound_interfaces lan
option iptables_chain natpmp option iptables_chain natpmp

View File

@ -2,6 +2,9 @@
START=70 START=70
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
IP=$(which ip) IP=$(which ip)
IPTABLES=$(which iptables) IPTABLES=$(which iptables)
NATPMP=/usr/sbin/natpmp NATPMP=/usr/sbin/natpmp
@ -19,6 +22,9 @@ start() {
config_load natpmp config_load natpmp
config_foreach natpmp_config natpmp config_foreach natpmp_config natpmp
include /lib/network
scan_interfaces
# Flush all the rules in the natpmp chain, or create it, if it doesn't exists. # Flush all the rules in the natpmp chain, or create it, if it doesn't exists.
$IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null || \ $IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null || \
$IPTABLES -t nat -N $IPTABLES_CHAIN $IPTABLES -t nat -N $IPTABLES_CHAIN
@ -30,6 +36,8 @@ start() {
# Iterate through the private interfaces. # Iterate through the private interfaces.
BIND_ARGS="" BIND_ARGS=""
for IF in $PRIVATE_IFS; do for IF in $PRIVATE_IFS; do
config_get IF "$IF" ifname "$IF"
# Get the IP address of this interface. # Get the IP address of this interface.
ADDR=`$IP addr show dev $IF 2>/dev/null | grep "^ *inet .* $IF\$" | cut -d " " -f 6 | cut -d / -f 1` ADDR=`$IP addr show dev $IF 2>/dev/null | grep "^ *inet .* $IF\$" | cut -d " " -f 6 | cut -d / -f 1`
if [ -n "$ADDR" ] ; then if [ -n "$ADDR" ] ; then
@ -45,7 +53,10 @@ start() {
exit 1 exit 1
fi fi
$NATPMP -p $PIDFILE -b -i "$PUBLIC_IF" $BIND_ARGS -- "$IPTABLES_CHAIN" config_get PUBLIC_IF "$PUBLIC_IF" ifname "$PUBLIC_IF"
SERVICE_PID_FILE="$PIDFILE"
service_start $NATPMP -i "$PUBLIC_IF" $BIND_ARGS -- "$IPTABLES_CHAIN"
} }
stop() { stop() {
@ -59,5 +70,6 @@ stop() {
$IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null && \ $IPTABLES -t nat -F $IPTABLES_CHAIN 2>/dev/null && \
$IPTABLES -t nat -X $IPTABLES_CHAIN $IPTABLES -t nat -X $IPTABLES_CHAIN
kill $(cat $PIDFILE) SERVICE_PID_FILE="$PIDFILE"
service_stop $NATPMP
} }