Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: vpnc: devel

default vpnc-script gets default gateway too late

 

 

vpnc devel RSS feed   Index | Next | Previous | View Threaded


djk7wb at mst

Feb 13, 2010, 2:15 AM

Post #1 of 3 (1330 views)
Permalink
default vpnc-script gets default gateway too late

So, in trying to trace down an unusual issue I was having with vpnc (as well as a friend of mine), I started comparing routes... and noticed an unusual behavior:
x.x.x.0 0.0.0.0 255.255.254.0 U 0 0 0 tun0

Where x.x.x is the subnet that holds the vpn gateway. In a working configuration (such as that of network-manager-vpnc), there is a static route configured to the vpn gateway through the default gateway.

I noticed vpnc-script tried to fetch the default gateway and set a static route to the vpn gateway. But, it occurred to me that this process might be happening too late in the game for it to have any effect. Attached is a really half-baked patch which seems to resolve this problem for me.

The systems I've been running on are pretty standard Ubuntu 9.10 systems. I've also had this problem on Gentoo systems, which makes me believe this is not simply restricted to the Ubuntu or Debian specific packages. iproute is available on these systems, which may also be another factor.

My apologies if this patch seems messy--it probably is. It's 4am here, and the patch could probably use refactoring. Mostly, I wanted to send this along in case anyone else was seeing this unusual problem. The diff is also generated against Ubuntu's version of vpnc-script--I did glance over the Gentoo distribution, and saw the same lines, though I have not tested the patch. Similar lines were also found in vpnc-script.in with the 0.53 source distribution.

Thanks!

Doug Kelly
Attachments: vpnc-script.diff (0.37 KB)


dwmw2 at infradead

Mar 18, 2010, 1:17 AM

Post #2 of 3 (1149 views)
Permalink
Re: default vpnc-script gets default gateway too late [In reply to]

On Sat, 2010-02-13 at 04:15 -0600, Kelly, Douglas James wrote:
> I noticed vpnc-script tried to fetch the default gateway and set a
> static route to the vpn gateway. But, it occurred to me that this
> process might be happening too late in the game for it to have any
> effect. Attached is a really half-baked patch which seems to resolve
> this problem for me.

Thanks for the report and the patch.

Please could you confirm that this problem is fixed by the commit at
http://git.infradead.org/users/dwmw2/vpnc-scripts.git/commitdiff/9239bd81

> My apologies if this patch seems messy--it probably is. It's 4am
> here, and the patch could probably use refactoring.

For future reference, please could you use the '-u' option to diff when
generating a patch? The resulting patch will be much easier to read and
apply, especially to a file which may have had other modifications.

For example, your patch (quoted below) will simply give instructions to
"Add this line at line 447", but that'll add things in the wrong place
if some other changes have added lines earlier in the file. A unified
diff will have some context lines so that the addition can still happen
in the right place.

> 123c123
> < $IPROUTE route add `$IPROUTE route get "$VPNGATEWAY" | fix_ip_get_output`
> ---
> > $IPROUTE route add $VPNGATEWAY via $GATEWAY
> 170c170
> < route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
> ---
> > route add -host "$VPNGATEWAY" $route_syntax_gw "$GATEWAY"
> 447a448
> > GATEWAY=`netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'`

Here's how your patch would have looked if it had been generated with
the '-u' option -- you can see that it's actually much easier to read
and understand in the email, as well as having a much better chance of
applying cleanly:

--- vpnc-script~ 2010-03-18 08:07:19.000000000 +0000
+++ vpnc-script 2010-03-18 08:12:47.000000000 +0000
@@ -121,7 +121,7 @@ if [ -n "$IPROUTE" ]; then
}

set_vpngateway_route() {
- $IPROUTE route add `$IPROUTE route get "$VPNGATEWAY" | fix_ip_get_output`
+ $IPROUTE route add $VPNGATEWAY via $GATEWAY
$IPROUTE route flush cache
}

@@ -168,7 +168,7 @@ else # use route command
}

set_vpngateway_route() {
- route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
+ route add -host "$VPNGATEWAY" $route_syntax_gw $GATEWAY
}

del_vpngateway_route() {
@@ -446,6 +446,7 @@ do_connect() {
echo
fi

+ GATEWAY=`netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'`
do_ifconfig
set_vpngateway_route
if [ -n "$CISCO_SPLIT_INC" ]; then


--
David Woodhouse Open Source Technology Centre
David.Woodhouse [at] intel Intel Corporation

_______________________________________________
vpnc-devel mailing list
vpnc-devel [at] unix-ag
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/


djk7wb at mail

Mar 18, 2010, 8:48 AM

Post #3 of 3 (1146 views)
Permalink
Re: default vpnc-script gets default gateway too late [In reply to]

Sorry about that. I usually would remember to include unified diffs, but it was probably so early, I wasn't thinking clearly at the time.
Anyway, I did a quick rough check of the patch, and it looks good (did a quick test from my system and network). I'll double check with the user who originally reported the problem to me just to make sure, though.

Thanks for your help! The one line change you've made certainly is nicer than what I scraped together.

--Doug Kelly

-----Original Message-----
From: vpnc-devel-bounces [at] unix-ag [mailto:vpnc-devel-bounces [at] unix-ag] On Behalf Of David Woodhouse
Sent: Thursday, March 18, 2010 3:17 AM
To: vpnc list to send bug reports and discussions with developers
Subject: Re: [vpnc-devel] default vpnc-script gets default gateway too late

On Sat, 2010-02-13 at 04:15 -0600, Kelly, Douglas James wrote:
> I noticed vpnc-script tried to fetch the default gateway and set a
> static route to the vpn gateway. But, it occurred to me that this
> process might be happening too late in the game for it to have any
> effect. Attached is a really half-baked patch which seems to resolve
> this problem for me.

Thanks for the report and the patch.

Please could you confirm that this problem is fixed by the commit at
http://git.infradead.org/users/dwmw2/vpnc-scripts.git/commitdiff/9239bd81

> My apologies if this patch seems messy--it probably is. It's 4am
> here, and the patch could probably use refactoring.

For future reference, please could you use the '-u' option to diff when
generating a patch? The resulting patch will be much easier to read and
apply, especially to a file which may have had other modifications.

For example, your patch (quoted below) will simply give instructions to
"Add this line at line 447", but that'll add things in the wrong place
if some other changes have added lines earlier in the file. A unified
diff will have some context lines so that the addition can still happen
in the right place.

> 123c123
> < $IPROUTE route add `$IPROUTE route get "$VPNGATEWAY" | fix_ip_get_output`
> ---
> > $IPROUTE route add $VPNGATEWAY via $GATEWAY
> 170c170
> < route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
> ---
> > route add -host "$VPNGATEWAY" $route_syntax_gw "$GATEWAY"
> 447a448
> > GATEWAY=`netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'`

Here's how your patch would have looked if it had been generated with
the '-u' option -- you can see that it's actually much easier to read
and understand in the email, as well as having a much better chance of
applying cleanly:

--- vpnc-script~ 2010-03-18 08:07:19.000000000 +0000
+++ vpnc-script 2010-03-18 08:12:47.000000000 +0000
@@ -121,7 +121,7 @@ if [ -n "$IPROUTE" ]; then
}

set_vpngateway_route() {
- $IPROUTE route add `$IPROUTE route get "$VPNGATEWAY" | fix_ip_get_output`
+ $IPROUTE route add $VPNGATEWAY via $GATEWAY
$IPROUTE route flush cache
}

@@ -168,7 +168,7 @@ else # use route command
}

set_vpngateway_route() {
- route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`"
+ route add -host "$VPNGATEWAY" $route_syntax_gw $GATEWAY
}

del_vpngateway_route() {
@@ -446,6 +446,7 @@ do_connect() {
echo
fi

+ GATEWAY=`netstat -r -n | awk '/:/ { next; } /^(default|0\.0\.0\.0)/ { print $2; }'`
do_ifconfig
set_vpngateway_route
if [ -n "$CISCO_SPLIT_INC" ]; then


--
David Woodhouse Open Source Technology Centre
David.Woodhouse [at] intel Intel Corporation

_______________________________________________
vpnc-devel mailing list
vpnc-devel [at] unix-ag
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/
_______________________________________________
vpnc-devel mailing list
vpnc-devel [at] unix-ag
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/

vpnc devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.