[PATCH 1/4] Support routes with different devs and gateways

Gernot Hillier gernot.hillier at siemens.com
Wed Oct 18 05:39:05 PDT 2017


Hi!

Am 17.10.2017 um 14:35 schrieb [ext] Gernot Hillier:
> Am 17.10.2017 um 12:12 schrieb David Woodhouse:
>> On Tue, 2017-10-17 at 10:54 +0200, Gernot Hillier wrote:
>>> Ah, and BTW, these are global, not local variables. Something which made
>>> me scratching my head for quite some time when looking for a bug in the
>>> /sbin/route case with re-enabled route cleanup (my patch no. 4).
>>> set_network_route used to call del_network_route which overwrote the
>>> used global variables...
>>
>> Yeah, that occurred to me as I was typing the word "local". Perhaps
>> they *should* really be "local" variables.
> 
> Hmm, I just implemented this and was about to submit a patch - but
> finally noticed too late that we specify /bin/sh as interpreter. :-(
> 
> It seems that ash and dash support "local" keyword, but sh as specified
> in
> http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
> seems to lack this feature. :-(
>
> Suggestions?

After discussing with a colleague, I have three suggestions:

1. Just use unique variable names, e.g. prefixing them per function

2. Just switch shebang to /bin/bash. The script already uses "local"
statements, so it is already broken on systems which only have /bin/sh.

3. Implement local variables using some dirty tricks, e.g. with a
sub-shell, something like this:

del_network_route() {
    NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" NETDEV="$4" (
        $IPROUTE route $route_syntax_del "$NETWORK/$NETMASKLEN" dev
"$NETDEV"
        $IPROUTE route flush cache
    )
}


Any preference? If yes, I can provide a patch.

-- 
Gernot
Siemens AG, Corporate Competence Center Embedded Linux




More information about the openconnect-devel mailing list