From patchwork Mon Mar 6 23:57:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 735995 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 3vccR153DYz9sNS for ; Tue, 7 Mar 2017 11:07:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="BD909EVM"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754207AbdCGAG6 (ORCPT ); Mon, 6 Mar 2017 19:06:58 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:36035 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233AbdCGAG4 (ORCPT ); Mon, 6 Mar 2017 19:06:56 -0500 Received: by mail-pf0-f173.google.com with SMTP id o126so19514116pfb.3 for ; Mon, 06 Mar 2017 16:06:09 -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=vV9FrafrLrk4X/eoXCWR+Vdve25KnNc+GVppFm8lgSw=; b=BD909EVMwHQj8mjmgEM9HB6BcyyfWrHRNBcuzYNSXNqANbPXvyogjT+PsJ54PzmMwl SpRerIBzOt9HOdHuoNW+jdys1bLw90sarDHVIgaHaAxD3DRyf4jA/z6Z3VfkYTbuEXiR 6RqfGQoT/XKPH+QFZSGNpgDay8z6J+y7WlXOU= 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=vV9FrafrLrk4X/eoXCWR+Vdve25KnNc+GVppFm8lgSw=; b=Ped41jJCUIAhrQxIJkLqiy3E08UyNMlgUtpK0F4j+SQ+ndVZzextytAWqhHyYIE5AU mKx/cvHIefwLG3ZKmsFlfvRyt1mHFzmp5/px7z7xghX2N07DxuiVab4iC3bqxNEhzkuX WPvAGAbbiFiBFsldpKNVanSRi0DZPflfNU4OERer8E6E1ie4sA3TzG3Ri3U/WhFPZFrB fp4ApqG0jcjiem1KCd/uOgjwlu85XfchuF2xAOfRe5G0vmh6g/0wkpz1doqUIJqRijfC 0YeB7qxF+3dKXhFJipf4nWANSWmN0bIj0TGUid0mjq9/4CtAq/vanvxyA2QrFJhP98ZD KdEg== X-Gm-Message-State: AMke39m6CsfnxHm8u1zXU9cNCcRLY9aTR+3qXeksjC+xxqirnMV7mfmzpepj2AVSko35JvQI X-Received: by 10.84.238.195 with SMTP id l3mr30705483pln.180.1488844657080; Mon, 06 Mar 2017 15:57:37 -0800 (PST) Received: from kenny.it.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id r67sm41598499pfb.125.2017.03.06.15.57.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Mar 2017 15:57:36 -0800 (PST) From: David Ahern To: netdev@vger.kernel.org Cc: David Ahern Subject: [PATCH] net: ipv6: Remove redundant RTA_OIF in multipath routes Date: Mon, 6 Mar 2017 15:57:31 -0800 Message-Id: <1488844651-12737-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 Dinesh reported that RTA_MULTIPATH nexthops are 8-bytes larger with IPv6 than IPv4. The recent refactoring for multipath support in netlink messages does discriminate between non-multipath which needs the OIF and multipath which adds a rtnexthop struct for each hop making the RTA_OIF attribute redundant. Resolve by adding a flag to the info function to skip the oif for multipath. Fixes: beb1afac518d ("net: ipv6: Add support to dump multipath routes via RTA_MULTIPATH attribute") Reported-by: Dinesh Dutt Signed-off-by: David Ahern --- net/ipv6/route.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 229bfcc451ef..35c58b669ebd 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3299,7 +3299,6 @@ static size_t rt6_nlmsg_size(struct rt6_info *rt) nexthop_len = nla_total_size(0) /* RTA_MULTIPATH */ + NLA_ALIGN(sizeof(struct rtnexthop)) + nla_total_size(16) /* RTA_GATEWAY */ - + nla_total_size(4) /* RTA_OIF */ + lwtunnel_get_encap_size(rt->dst.lwtstate); nexthop_len *= rt->rt6i_nsiblings; @@ -3323,7 +3322,7 @@ static size_t rt6_nlmsg_size(struct rt6_info *rt) } static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt, - unsigned int *flags) + unsigned int *flags, bool skip_oif) { if (!netif_running(rt->dst.dev) || !netif_carrier_ok(rt->dst.dev)) { *flags |= RTNH_F_LINKDOWN; @@ -3336,7 +3335,8 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt, goto nla_put_failure; } - if (rt->dst.dev && + /* not needed for multipath encoding b/c it has a rtnexthop struct */ + if (!skip_oif && rt->dst.dev && nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) goto nla_put_failure; @@ -3350,6 +3350,7 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct rt6_info *rt, return -EMSGSIZE; } +/* add multipath next hop */ static int rt6_add_nexthop(struct sk_buff *skb, struct rt6_info *rt) { struct rtnexthop *rtnh; @@ -3362,7 +3363,7 @@ static int rt6_add_nexthop(struct sk_buff *skb, struct rt6_info *rt) rtnh->rtnh_hops = 0; rtnh->rtnh_ifindex = rt->dst.dev ? rt->dst.dev->ifindex : 0; - if (rt6_nexthop_info(skb, rt, &flags) < 0) + if (rt6_nexthop_info(skb, rt, &flags, true) < 0) goto nla_put_failure; rtnh->rtnh_flags = flags; @@ -3515,7 +3516,7 @@ static int rt6_fill_node(struct net *net, nla_nest_end(skb, mp); } else { - if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags) < 0) + if (rt6_nexthop_info(skb, rt, &rtm->rtm_flags, false) < 0) goto nla_put_failure; }