From patchwork Sat Mar 25 17:03:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 743497 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 3vr6823Jgzz9s7R for ; Sun, 26 Mar 2017 04:04:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="eEVXtsdj"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751651AbdCYREB (ORCPT ); Sat, 25 Mar 2017 13:04:01 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:34666 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751644AbdCYRD7 (ORCPT ); Sat, 25 Mar 2017 13:03:59 -0400 Received: by mail-pg0-f50.google.com with SMTP id 21so9499671pgg.1 for ; Sat, 25 Mar 2017 10:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WlbxOO/437F7S1X9XD2w/lFrPBnmVT6EhRwslKeJ/pA=; b=eEVXtsdj07PucQSF/sLvjXA+odszWHa5CLGRo6x2KkXEU5HH0DCHqYwIujVB9EKoV2 GqyRz5vkjCvdZ5eyVW0cJIaXAiWklDEPhe3x9xSjecTJ40ybuxkGPYNgFTUq9hHy3l/x f2JtCBaiJRO+Av6twnjcC4FGh9NF/HkXX8ZB4= 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:in-reply-to :references; bh=WlbxOO/437F7S1X9XD2w/lFrPBnmVT6EhRwslKeJ/pA=; b=VblkpnpZGCvndNTmwobdHgedu8fXrMuEEP513SDdan7WwyBWn+4LMrG83dTxlYcBan ETZh+mw7Gvh3uBj9uOjEVKnt8WGuABpA6iuyzGT86Bau2XPjRa7EOMK/Yh6dAeOoOXnz wnmoABaGRAD2tOcFeRHL/ujeWmqg01VP0lzyIzXjavjkRlfOqlfFC9V2rVuIcEO0xBNL gYG/tEkjZa/AQBs/ux90iXcyEiWcb6YSCGtLNS2yGpEeU27Qj7cDsV4TLTZUGdjSGYEY iMiDnRWiIFHSfjrmOJMJAaeRm6XTYjFil9bWKi6ihG2rGdm1uNAu+AFszuMBoArESNsC GksQ== X-Gm-Message-State: AFeK/H0LUaIL/h290uKGmo4q42gvFp++k9EWz7kWxKMqNSDy0mKqOvcHJA3PXEowjFW9LdMD X-Received: by 10.84.232.70 with SMTP id f6mr18811524pln.102.1490461418938; Sat, 25 Mar 2017 10:03:38 -0700 (PDT) Received: from kenny.it.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id y6sm11633203pgc.1.2017.03.25.10.03.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Mar 2017 10:03:38 -0700 (PDT) From: David Ahern To: netdev@vger.kernel.org Cc: roopa@cumulusnetworks.com, rshearma@brocade.com, ebiederm@xmission.com, David Ahern Subject: [PATCH net-next 4/4] net: mpls: Increase max number of labels for lwt encap Date: Sat, 25 Mar 2017 10:03:28 -0700 Message-Id: <1490461408-9551-5-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490461408-9551-1-git-send-email-dsa@cumulusnetworks.com> References: <1490461408-9551-1-git-send-email-dsa@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Alow users to push down more labels per MPLS encap. Same logic as LSR use case, so re-use the maximum number of labels. Signed-off-by: David Ahern --- include/net/mpls_iptunnel.h | 4 +--- net/mpls/af_mpls.c | 5 ----- net/mpls/internal.h | 5 +++++ net/mpls/mpls_iptunnel.c | 13 ++++++++++--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/net/mpls_iptunnel.h b/include/net/mpls_iptunnel.h index a18af6a16eb5..038fa9985521 100644 --- a/include/net/mpls_iptunnel.h +++ b/include/net/mpls_iptunnel.h @@ -14,13 +14,11 @@ #ifndef _NET_MPLS_IPTUNNEL_H #define _NET_MPLS_IPTUNNEL_H 1 -#define MAX_NEW_LABELS 2 - struct mpls_iptunnel_encap { - u32 label[MAX_NEW_LABELS]; u8 labels; u8 ttl_propagate; u8 default_ttl; + u32 label[0]; }; static inline struct mpls_iptunnel_encap *mpls_lwtunnel_encap(struct lwtunnel_state *lwtstate) diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 3023c261a04b..0ced87a51326 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c @@ -24,11 +24,6 @@ #include #include "internal.h" -/* put a reasonable limit on the number of labels - * we will accept from userspace - */ -#define MAX_NEW_LABELS 12 - /* Maximum number of labels to look ahead at when selecting a path of * a multipath route */ diff --git a/net/mpls/internal.h b/net/mpls/internal.h index 302d48f54b57..d43f8bc52653 100644 --- a/net/mpls/internal.h +++ b/net/mpls/internal.h @@ -2,6 +2,11 @@ #define MPLS_INTERNAL_H #include +/* put a reasonable limit on the number of labels + * we will accept from userspace + */ +#define MAX_NEW_LABELS 12 + struct mpls_entry_decoded { u32 label; u8 ttl; diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c index 22f71fce0bfb..fe00e98667cf 100644 --- a/net/mpls/mpls_iptunnel.c +++ b/net/mpls/mpls_iptunnel.c @@ -164,6 +164,7 @@ static int mpls_build_state(struct nlattr *nla, struct mpls_iptunnel_encap *tun_encap_info; struct nlattr *tb[MPLS_IPTUNNEL_MAX + 1]; struct lwtunnel_state *newts; + u8 n_labels; int ret; ret = nla_parse_nested(tb, MPLS_IPTUNNEL_MAX, nla, @@ -175,12 +176,18 @@ static int mpls_build_state(struct nlattr *nla, return -EINVAL; - newts = lwtunnel_state_alloc(sizeof(*tun_encap_info)); + /* determine number of labels */ + if (nla_get_labels(tb[MPLS_IPTUNNEL_DST], + MAX_NEW_LABELS, &n_labels, NULL)) + return -EINVAL; + + newts = lwtunnel_state_alloc(sizeof(*tun_encap_info) + + n_labels * sizeof(u32)); if (!newts) return -ENOMEM; tun_encap_info = mpls_lwtunnel_encap(newts); - ret = nla_get_labels(tb[MPLS_IPTUNNEL_DST], MAX_NEW_LABELS, + ret = nla_get_labels(tb[MPLS_IPTUNNEL_DST], n_labels, &tun_encap_info->labels, tun_encap_info->label); if (ret) goto errout; @@ -257,7 +264,7 @@ static int mpls_encap_cmp(struct lwtunnel_state *a, struct lwtunnel_state *b) a_hdr->default_ttl != b_hdr->default_ttl) return 1; - for (l = 0; l < MAX_NEW_LABELS; l++) + for (l = 0; l < a_hdr->labels; l++) if (a_hdr->label[l] != b_hdr->label[l]) return 1; return 0;