aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-02-17 07:05:49 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-02-17 07:05:49 +0000
commit252a728256d60770dfaea235dae4e21648be5407 (patch)
treea5d5b354449b01144114d1a56cb9f5f3d2e2ab11
parentChanges to Windows build system: added GENOUT_PREBUILT mode (diff)
downloadopenvpn-252a728256d60770dfaea235dae4e21648be5407.tar.xz
Cleanup IP address for persistence interfaces for tap and also using
ifconfig, gentoo#209055 (Alon Bar-Lev). git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2748 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to '')
-rw-r--r--tun.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/tun.c b/tun.c
index 39c6722..349a4de 100644
--- a/tun.c
+++ b/tun.c
@@ -1220,26 +1220,44 @@ close_tun (struct tuntap *tt)
{
if (tt)
{
-#ifdef CONFIG_FEATURE_IPROUTE
if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig)
{
char command_line[256];
struct gc_arena gc = gc_new ();
+#ifdef CONFIG_FEATURE_IPROUTE
+ if (is_tun_p2p (tt))
+ {
+ openvpn_snprintf (command_line, sizeof (command_line),
+ "%s addr del dev %s local %s peer %s",
+ iproute_path,
+ tt->actual_name,
+ print_in_addr_t (tt->local, 0, &gc),
+ print_in_addr_t (tt->remote_netmask, 0, &gc)
+ );
+ }
+ else
+ {
+ openvpn_snprintf (command_line, sizeof (command_line),
+ "%s addr del dev %s %s/%d",
+ iproute_path,
+ tt->actual_name,
+ print_in_addr_t (tt->local, 0, &gc),
+ count_netmask_bits(print_in_addr_t (tt->remote_netmask, 0, &gc))
+ );
+ }
+#else
openvpn_snprintf (command_line, sizeof (command_line),
- "%s addr del dev %s local %s peer %s",
- iproute_path,
- tt->actual_name,
- print_in_addr_t (tt->local, 0, &gc),
- print_in_addr_t (tt->remote_netmask, 0, &gc)
- );
+ IFCONFIG_PATH "%s addr 0.0.0.0",
+ tt->actual_name
+ );
+#endif
msg (M_INFO, "%s", command_line);
system_check (command_line, NULL, S_FATAL, "Linux ip addr del failed");
gc_free (&gc);
}
-#endif
close_tun_generic (tt);
free (tt);
}