]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ip-tunnel: Make local address optional
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 11:57:32 +0000 (11:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 4 Aug 2017 11:57:32 +0000 (11:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.ip-tunnel

index 5e6bd8e63f2ae2990fbe7bea78b69e29a13a2f24..195ee9320366b7c7fa11e07a649776449f52d562 100644 (file)
@@ -82,8 +82,6 @@ ip_tunnel_add() {
                return ${EXIT_ERROR}
        fi
 
-       assert isset local_address
-
        local cmd_args
 
        # Apply TTL if a value has been set.
@@ -91,6 +89,11 @@ ip_tunnel_add() {
                cmd_args="${cmd_args} ttl ${ttl}"
        fi
 
+       # Apply local address if a value has been set.
+       if isset local_address; then
+               cmd_args="${cmd_args} local ${local_address}"
+       fi
+
        # Apply remote address if a value has been set.
        if isset remote_address; then
                cmd_args="${cmd_args} remote ${remote_address}"
@@ -104,8 +107,7 @@ ip_tunnel_add() {
        log DEBUG "Creating tunnel device '${device}' (mode=${mode})..."
 
        # Create the device.
-       if ! cmd ip tunnel add ${device} mode ${mode} \
-                       local ${local_address} ${cmd_args}; then
+       if ! cmd ip tunnel add ${device} mode ${mode} ${cmd_args}; then
                error "Could not create tunnel device ${device}"
                return ${EXIT_ERROR}
        fi