From patchwork Wed Jan 11 22:29:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 714028 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tzNqx40gcz9s1h for ; Thu, 12 Jan 2017 09:30:05 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="Gblnu3BT"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756371AbdAKWaC (ORCPT ); Wed, 11 Jan 2017 17:30:02 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:33060 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574AbdAKWaA (ORCPT ); Wed, 11 Jan 2017 17:30:00 -0500 Received: by mail-pf0-f172.google.com with SMTP id y143so1050397pfb.0 for ; Wed, 11 Jan 2017 14:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id; bh=Ge6wNA3ky9ChhIb9uvLa0I4/gz6kivyQyuPc8SipBRE=; b=Gblnu3BTckVQyQ+LNFVb9mRUg9NAGNsfroZRWrRN6WfQqAMycofZoiluQ+dZE/RRJl LzAxlejhFbpfwtSkrnR+R6+nSLq2E6laFBZjWHimDcceRExREFmx/eNEwJs+oI11pYFV zctUTT1sHb+ZlRX2AhIO2MrkRyGYQdUzbv7W4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ge6wNA3ky9ChhIb9uvLa0I4/gz6kivyQyuPc8SipBRE=; b=VzPwSjSYKnXQhMV9X6rtA/y9QkNfCW9eWn2r8dlnJW/J1wC2BFZqCIfFt01dXQhzPA HeBA3vLDrMKTK27L+T324gH81v0PG7xqc/ODq2ZfT5oWtGibRXnHS3wUQON91DSLjOtf gdE3/q52w2ewlpsX0zd9dGoPB43v/URVZl/Rfw3UiCA/UZlJzrNoZjeavzCU0LsBj/Cz mPcMiekzUAS55h5rkubtx60laPrrc/VM4bZh1HkjCuvi1uGbMxwd4s6M6V+kCWcSGzra gOagqPIBheTrNvxy8hNRALoaRxaXRRCUGehvxzuRUkmcDsorL5LYBe54lZxW7xfN7PkN UKEQ== X-Gm-Message-State: AIkVDXKylhde5RYHCnca5xQv+h2PQqxuMX4VwD8YW3xP9hhIWsp2wFsDvrengIAvRIrfxko1 X-Received: by 10.98.28.129 with SMTP id c123mr12776285pfc.92.1484173800224; Wed, 11 Jan 2017 14:30:00 -0800 (PST) Received: from kenny.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id o1sm16190895pgf.35.2017.01.11.14.29.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 14:29:59 -0800 (PST) From: David Ahern To: netdev@vger.kernel.org Cc: roopa@cumulusnetworks.com, David Ahern Subject: [PATCH] net: lwtunnel: Handle lwtunnel_fill_encap failure Date: Wed, 11 Jan 2017 14:29:54 -0800 Message-Id: <1484173794-7777-1-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Handle failure in lwtunnel_fill_encap adding attributes to skb. Fixes: 571e722676fe ("ipv4: support for fib route lwtunnel encap attributes") Fixes: 19e42e451506 ("ipv6: support for fib route lwtunnel encap attributes") Signed-off-by: David Ahern --- net/ipv4/fib_semantics.c | 11 +++++++---- net/ipv6/route.c | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index eba1546b5031..9a375b908d01 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -1279,8 +1279,9 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event, nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid)) goto nla_put_failure; #endif - if (fi->fib_nh->nh_lwtstate) - lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate); + if (fi->fib_nh->nh_lwtstate && + lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate) < 0) + goto nla_put_failure; } #ifdef CONFIG_IP_ROUTE_MULTIPATH if (fi->fib_nhs > 1) { @@ -1316,8 +1317,10 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event, nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) goto nla_put_failure; #endif - if (nh->nh_lwtstate) - lwtunnel_fill_encap(skb, nh->nh_lwtstate); + if (nh->nh_lwtstate && + lwtunnel_fill_encap(skb, nh->nh_lwtstate) < 0) + goto nla_put_failure; + /* length of rtnetlink header + attributes */ rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh; } endfor_nexthops(fi); diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ce5aaf448c54..4f6b067c8753 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3317,7 +3317,8 @@ static int rt6_fill_node(struct net *net, if (nla_put_u8(skb, RTA_PREF, IPV6_EXTRACT_PREF(rt->rt6i_flags))) goto nla_put_failure; - lwtunnel_fill_encap(skb, rt->dst.lwtstate); + if (lwtunnel_fill_encap(skb, rt->dst.lwtstate) < 0) + goto nla_put_failure; nlmsg_end(skb, nlh); return 0;