From f4e5ddbe83c1ccf90f40e3d614aa2d94458c5d8c Mon Sep 17 00:00:00 2001
From: Gert Doering <gert@greenie.muc.de>
Date: Sat, 30 Oct 2010 21:03:16 +0200
Subject: [PATCH 2/2] Make "topology subnet" work on Solaris (ifconfig + route metric changes
by Kazuyoshi Aizawa, adding of local "connected subnet" route by me)
Tested on OpenSolaris/i386, no impact for other TARGETs.
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
route.c | 8 +++-----
tun.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/route.c b/route.c
index 20f62d5..c63eb41 100644
a
|
b
|
add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s |
952 | 952 | argv_printf (&argv, "%s add", |
953 | 953 | ROUTE_PATH); |
954 | 954 | |
955 | | #if 0 |
956 | | if (r->metric_defined) |
957 | | argv_printf_cat (&argv, "-rtt %d", r->metric); |
958 | | #endif |
959 | | |
960 | 955 | argv_printf_cat (&argv, "%s -netmask %s %s", |
961 | 956 | network, |
962 | 957 | netmask, |
963 | 958 | gateway); |
964 | 959 | |
| 960 | if (r->metric_defined) |
| 961 | argv_printf_cat (&argv, "%d", r->metric); |
| 962 | |
965 | 963 | argv_msg (D_ROUTE, &argv); |
966 | 964 | status = openvpn_execve_check (&argv, es, 0, "ERROR: Solaris route add command failed"); |
967 | 965 | |
diff --git a/tun.c b/tun.c
index f001a64..0e4476e 100644
a
|
b
|
do_ifconfig (struct tuntap *tt, |
702 | 702 | ); |
703 | 703 | } |
704 | 704 | else |
| 705 | if (tt->topology == TOP_SUBNET) |
| 706 | { |
| 707 | argv_printf (&argv, |
| 708 | "%s %s %s %s netmask %s mtu %d up", |
| 709 | IFCONFIG_PATH, |
| 710 | actual, |
| 711 | ifconfig_local, |
| 712 | ifconfig_local, |
| 713 | ifconfig_remote_netmask, |
| 714 | tun_mtu |
| 715 | ); |
| 716 | } |
| 717 | else |
705 | 718 | argv_printf (&argv, |
706 | 719 | " %s %s %s netmask %s broadcast + up", |
707 | 720 | IFCONFIG_PATH, |
… |
… |
do_ifconfig (struct tuntap *tt, |
714 | 727 | if (!openvpn_execve_check (&argv, es, 0, "Solaris ifconfig phase-2 failed")) |
715 | 728 | solaris_error_close (tt, es, actual); |
716 | 729 | |
| 730 | if (!tun && tt->topology == TOP_SUBNET) |
| 731 | { |
| 732 | /* Add a network route for the local tun interface */ |
| 733 | struct route r; |
| 734 | CLEAR (r); |
| 735 | r.defined = true; |
| 736 | r.network = tt->local & tt->remote_netmask; |
| 737 | r.netmask = tt->remote_netmask; |
| 738 | r.gateway = tt->local; |
| 739 | r.metric_defined = true; |
| 740 | r.metric = 0; |
| 741 | add_route (&r, tt, 0, es); |
| 742 | } |
| 743 | |
717 | 744 | tt->did_ifconfig = true; |
718 | 745 | |
719 | 746 | #elif defined(TARGET_OPENBSD) |