From patchwork Wed Sep 9 13:45:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 515864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48E0A14028F for ; Wed, 9 Sep 2015 23:49:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=eVWKCZOV; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 36E6828C047; Wed, 9 Sep 2015 15:45:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 6D2AD28BD6C for ; Wed, 9 Sep 2015 15:45:19 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -8.5 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 9 Sep 2015 15:45:19 +0200 (CEST) Received: by wicge5 with SMTP id ge5so155926787wic.0 for ; Wed, 09 Sep 2015 06:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I7zBCzcNOIXXhDXzA1BVUkmEb03k7ueVftA02HIsrZE=; b=eVWKCZOV/paXcNYCINnWE9PcE1LJvm24Fh6X1otColPRiza/Gd1sO+t2w1aCBEJ3Bi Mte/vRelDbDi6IDIJLIKiFKOIdnZKLUuwBLLcFQZE7jZmHgVyVHsVawxPPTrRQ+tm1GV nPTaqqRnqAxJV+HcEgwkzCoHR8phNTD4QOqmaIYMR0HgUI72pRCffxj3sz4fMWIWtMAg cqOs+nhkDjzX6ALLJSKomNSdOQhW3HqdHxFEWQfbYp1mMzVGWsWW0BItPFYJ5721Zz6B mEX/v7wq9XGEtK529KzXALenvMpaXl0ihOwzJp9bWNsQT0/k2f3EIBUSXJlsiobuAXcn alMA== X-Received: by 10.194.172.130 with SMTP id bc2mr62683350wjc.85.1441806382068; Wed, 09 Sep 2015 06:46:22 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id fu5sm6764421wic.0.2015.09.09.06.46.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 06:46:21 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Wed, 9 Sep 2015 15:45:52 +0200 Message-Id: <1441806352-18030-6-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441806352-18030-1-git-send-email-dedeckeh@gmail.com> References: <1441806352-18030-1-git-send-email-dedeckeh@gmail.com> Cc: Hans Dedecker , cyrus@openwrt.org Subject: [OpenWrt-Devel] [PATCH netifd 6/6] interface-ip: Set route table when enabling interface ip settings X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Routes are now inserted in the correct routing table when interface ip4table and/or ip6table was changed during interface_change_config Signed-off-by: Hans Dedecker --- interface-ip.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interface-ip.c b/interface-ip.c index d5f6aff..8eb2ff3 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -1234,6 +1234,15 @@ void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled) if (!(route->flags & DEVROUTE_METRIC)) route->metric = ip->iface->metric; + if (!(route->flags & DEVROUTE_TABLE)) { + route->flags &= ~DEVROUTE_SRCTABLE; + route->table = ((route->flags & DEVADDR_FAMILY) == DEVADDR_INET6) ? + iface->ip6table : iface->ip4table; + + if (route->table) + route->flags |= DEVROUTE_SRCTABLE; + } + if (system_add_route(dev, route)) route->failed = true; } else