
djk7wb at mail
Mar 18, 2010, 8:48 AM
Post #3 of 3
(1029 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/
|