summaryrefslogtreecommitdiff
path: root/src/tethering.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2010-11-14 00:13:51 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2010-11-14 00:13:51 +0100
commitfd055d3137297e8da486a0787f5a94fcd99f58d1 (patch)
tree6bd16b7bb3620cdb65cafce75241edcdb20562b9 /src/tethering.c
parent606be0e289acbcc27ea594be2c21e9750f410991 (diff)
downloadconnman-fd055d3137297e8da486a0787f5a94fcd99f58d1.tar.gz
connman-fd055d3137297e8da486a0787f5a94fcd99f58d1.tar.bz2
connman-fd055d3137297e8da486a0787f5a94fcd99f58d1.zip
tethering: Flush POSTROUTING table when needed
Diffstat (limited to 'src/tethering.c')
-rw-r--r--src/tethering.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/tethering.c b/src/tethering.c
index 35b407d8..ad159a15 100644
--- a/src/tethering.c
+++ b/src/tethering.c
@@ -113,7 +113,11 @@ static int enable_nat(const char *interface)
if (err < 0)
return err;
- /* TODO: Flush nat POSTROUTING chain */
+ /* POSTROUTING flush */
+ err = __connman_iptables_command("-t nat -F POSTROUTING");
+ if (err < 0)
+ return err;
+
/* Enable masquerading */
err = __connman_iptables_command("-t nat -A POSTROUTING "
"-o %s -j MASQUERADE", interface);
@@ -125,10 +129,17 @@ static int enable_nat(const char *interface)
static void disable_nat(const char *interface)
{
+ int err;
+
/* Disable IPv4 forwarding */
enable_ip_forward(FALSE);
- /* TODO: Flush nat POSTROUTING chain */
+ /* POSTROUTING flush */
+ err = __connman_iptables_command("-t nat -F POSTROUTING");
+ if (err < 0)
+ return;
+
+ __connman_iptables_commit("nat");
}
void __connman_tethering_set_enabled(void)