From patchwork Mon Mar 5 05:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 1689 Return-Path: Received: from mail01.ipfire.org (mail01.ipfire.org [IPv6:2001:470:7183:25::1]) by web02.i.ipfire.org (Postfix) with ESMTP id E85166095C for ; Sun, 4 Mar 2018 19:26:44 +0100 (CET) X-Virus-Scanned: ClamAV at mail01.ipfire.org X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=5 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id EEE3F111C4FE; Sun, 4 Mar 2018 18:26:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ipfire.org; s=201801; t=1520188004; x=1522780004; bh=qnuGqMWIkhGLFufSUnAgQ7qv8HDk7/0HXwri1R7Qw/0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:Sender:From:To:Cc: Date:Content-Type:Message-ID:In-Reply-To:Subject:Reply-To:Sender; b=opstHtD/dGeEk61bdvsJmpCTgguBkzHSne5HKiKZBnXSxAlxItF40BIT78ydmb9eU NFr33HDOqgVpPKaYE7Nu7O4ZusdlYlevlo7ZyFVGsv9qTANktp2+dkiS3qF0b6MP4i 9sfcNv8OfHqJZw0IMNN5zTa5IGXns1GfivduCEkww/lR7LoK9pG1f2iEtkj0DUnvuh xtZ6MIieIrbTibVdE+2obW7R5dY4LeW538SYYYSXK1Mp3b/op4rdkT8QkWn0NRT7V/ YnbDk3qhqgmBhMJJb+eMlBsTdfcQi+iehdn0fJeVP2bYQGlL+7JJjn5WYitvlUIGxh U9O53GSGMudnQ== X-Virus-Scanned: ClamAV at mail01.ipfire.org Received: from localhost.localdomain (unknown [46.183.103.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 3C361111C505; Sun, 4 Mar 2018 18:26:40 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ipfire.org; s=201801; t=1520188001; x=1522780001; bh=qnuGqMWIkhGLFufSUnAgQ7qv8HDk7/0HXwri1R7Qw/0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:From:To:Cc:Date: Content-Type:Message-ID:In-Reply-To:Subject:Reply-To:Sender; b=eBxWeJyLWXyHpVxl0iT6snZjictTvJi1XRTnWLGFFFFqaZF5U8aG0V4SpkdSEVX3b tJKTS0jMW9nmTsusT57CbV5B2Vvxbr6iN6SC9v9EqXxN9ySV+ksPBBwqSyPhChoDZ7 bijZvOIzM08cvbJgWFjaGxdKQeAB//Ebt9khgsiX4lpDAUAFKEwHSJq2gmo10psg4Y PaRDUHnQ9svu+IuULfnCBFmQbbnin9sehq8zfzYRTXvcJC3/htxbpqZPSRVFgMa6n2 oD6wehkGAto83qJ/u0agrMNMaFlNvRdouiqruIhSUsegsDK2Kr7SwNGw+C5oildfsN qotqbEFltAORg== From: Jonatan Schlag To: network@lists.ipfire.org Subject: [PATCH 5/5] ip-tunnel: choose the correct type based on the ip protocol Date: Sun, 4 Mar 2018 18:24:59 +0000 Message-Id: <1520187899-5759-5-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1520187899-5759-1-git-send-email-jonatan.schlag@ipfire.org> References: <1520187899-5759-1-git-send-email-jonatan.schlag@ipfire.org> X-BeenThere: network@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List for the network package List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: network-bounces@lists.ipfire.org Sender: "network" IPv4 and IPv6 need different types for iproute2. So in the _add function we have to determine the mode based on the IP protocol of the ${remote_address}. When we change ikey and okey we have to dertermine the mode the device have currently. Fixes: #11431 Signed-off-by: Jonatan Schlag --- src/functions/functions.ip-tunnel | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/functions/functions.ip-tunnel b/src/functions/functions.ip-tunnel index 0a0c210..3baf280 100644 --- a/src/functions/functions.ip-tunnel +++ b/src/functions/functions.ip-tunnel @@ -150,6 +150,9 @@ ip_tunnel_add() { cmd_args="${cmd_args} ikey ${ikey} okey ${okey}" fi + # Determine the mode based on the IP protocol + mode=$(ip_tunnel_convert_mode_to_iproute2_mode "${mode}" "${remote_address_protocol}") + log DEBUG "Creating tunnel device '${device}' (mode=${mode})..." # Create the device. @@ -208,8 +211,16 @@ ip_tunnel_change_keys() { return ${EXIT_ERROR} fi + # Determine the device type + local type="$(device_tunnel_get_type ${device})" + + if ! isoneof "type" vti vti6; then + log ERROR "Device type '${type}' is invalid" + return ${EXIT_ERROR} + fi + if ! cmd ip link change dev "${device}" \ - type vti ikey "${ikey}" okey "${okey}"; then + type "${type}" ikey "${ikey}" okey "${okey}"; then log ERROR "Could not change keys of device ${device}" return ${EXIT_ERROR} fi