Skip to content

Commit

Permalink
Clean-up ip forwarding
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Dec 11, 2013
1 parent 8c2832b commit 1a7dceb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/usb_moded-network.c
Expand Up @@ -99,6 +99,15 @@ static void set_usb_ip_forward(struct mode_list_elem *data)
free((char *)nat_interface);
}

/**
* Remove ip forward
*/
static void clean_usb_ip_forward(void)
{
write_to_file("/proc/sys/net/ipv4/ip_forward", "0");
system("/sbin/iptables -F FORWARD");
}

/**
* Read dns settings from /etc/resolv.conf
*/
Expand Down Expand Up @@ -502,7 +511,9 @@ int usb_network_down(struct mode_list_elem *data)
sprintf(command, "ifconfig %s down\n", interface);
system(command);

/* TODO: Do dhcp client shutdown */
/* dhcp client shutdown happens on disconnect automatically */
if(data->nat)
clean_usb_ip_forward();

free((char *)interface);

Expand Down

0 comments on commit 1a7dceb

Please sign in to comment.