From: Robert Shearman <rshearma@brocade.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, Robert Shearman <rshearma@brocade.com>
Subject: [PATCH net-next v3 1/4] mpls: Use definition for reserved label checks
Date: Mon, 30 Mar 2015 19:15:53 +0100 [thread overview]
Message-ID: <1427739356-28113-2-git-send-email-rshearma@brocade.com> (raw)
In-Reply-To: <1427739356-28113-1-git-send-email-rshearma@brocade.com>
In multiple locations there are checks for whether the label in hand
is a reserved label or not using the arbritray value of 16. Factor
this out into a #define for better maintainability and for
documentation.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
net/mpls/af_mpls.c | 20 ++++++++++----------
net/mpls/internal.h | 1 +
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index db8a2ea6d4de..0d6763a895d6 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -276,7 +276,7 @@ static void mpls_notify_route(struct net *net, unsigned index,
struct mpls_route *rt = new ? new : old;
unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0;
/* Ignore reserved labels for now */
- if (rt && (index >= 16))
+ if (rt && (index >= LABEL_FIRST_UNRESERVED))
rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags);
}
@@ -310,7 +310,7 @@ static unsigned find_free_label(struct net *net)
platform_label = rtnl_dereference(net->mpls.platform_label);
platform_labels = net->mpls.platform_labels;
- for (index = 16; index < platform_labels; index++) {
+ for (index = LABEL_FIRST_UNRESERVED; index < platform_labels; index++) {
if (!rtnl_dereference(platform_label[index]))
return index;
}
@@ -335,8 +335,8 @@ static int mpls_route_add(struct mpls_route_config *cfg)
index = find_free_label(net);
}
- /* The first 16 labels are reserved, and may not be set */
- if (index < 16)
+ /* Reserved labels may not be set */
+ if (index < LABEL_FIRST_UNRESERVED)
goto errout;
/* The full 20 bit range may not be supported. */
@@ -413,8 +413,8 @@ static int mpls_route_del(struct mpls_route_config *cfg)
index = cfg->rc_label;
- /* The first 16 labels are reserved, and may not be removed */
- if (index < 16)
+ /* Reserved labels may not be removed */
+ if (index < LABEL_FIRST_UNRESERVED)
goto errout;
/* The full 20 bit range may not be supported */
@@ -610,8 +610,8 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
&cfg->rc_label))
goto errout;
- /* The first 16 labels are reserved, and may not be set */
- if (cfg->rc_label < 16)
+ /* Reserved labels may not be set */
+ if (cfg->rc_label < LABEL_FIRST_UNRESERVED)
goto errout;
break;
@@ -736,8 +736,8 @@ static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
ASSERT_RTNL();
index = cb->args[0];
- if (index < 16)
- index = 16;
+ if (index < LABEL_FIRST_UNRESERVED)
+ index = LABEL_FIRST_UNRESERVED;
platform_label = rtnl_dereference(net->mpls.platform_label);
platform_labels = net->mpls.platform_labels;
diff --git a/net/mpls/internal.h b/net/mpls/internal.h
index fb6de92052c4..5732283ee1b9 100644
--- a/net/mpls/internal.h
+++ b/net/mpls/internal.h
@@ -9,6 +9,7 @@
#define LABEL_GAL 13 /* RFC5586 */
#define LABEL_OAM_ALERT 14 /* RFC3429 */
#define LABEL_EXTENSION 15 /* RFC7274 */
+#define LABEL_FIRST_UNRESERVED 16 /* RFC3032 */
struct mpls_shim_hdr {
--
2.1.4
next prev parent reply other threads:[~2015-03-30 18:17 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 21:32 [PATCH net-next 0/5] mpls: Behaviour-changing improvements Robert Shearman
2015-03-19 21:32 ` [PATCH net-next 1/5] mpls: Use definition for reserved label checks Robert Shearman
2015-03-20 0:41 ` Eric W. Biederman
2015-03-20 14:12 ` Robert Shearman
2015-03-19 21:32 ` [PATCH net-next 2/5] mpls: Remove incorrect PHP comment Robert Shearman
2015-03-19 21:32 ` [PATCH net-next 3/5] mpls: Differentiate implicit-null and unlabeled neighbours Robert Shearman
2015-03-19 21:32 ` [PATCH net-next 4/5] mpls: Per-device enabling of packet forwarding Robert Shearman
2015-03-19 21:32 ` [PATCH net-next 5/5] mpls: Allow payload type to be associated with label routes Robert Shearman
2015-03-20 15:42 ` [PATCH net-next v2 0/5] mpls: Behaviour-changing improvements Robert Shearman
2015-03-20 15:42 ` [PATCH net-next v2 1/5] mpls: Use definition for reserved label checks Robert Shearman
2015-03-22 19:09 ` Eric W. Biederman
2015-03-20 15:42 ` [PATCH net-next v2 2/5] mpls: Remove incorrect PHP comment Robert Shearman
2015-03-22 19:12 ` Eric W. Biederman
2015-03-23 11:32 ` Robert Shearman
2015-03-23 18:16 ` Eric W. Biederman
2015-03-24 15:18 ` Robert Shearman
2015-03-24 18:43 ` Vivek Venkatraman
2015-03-20 15:42 ` [PATCH net-next v2 3/5] mpls: Differentiate implicit-null and unlabeled neighbours Robert Shearman
2015-03-22 19:49 ` Eric W. Biederman
2015-03-22 21:06 ` Eric W. Biederman
2015-03-23 11:47 ` Robert Shearman
2015-03-20 15:42 ` [PATCH net-next v2 4/5] mpls: Per-device enabling of packet forwarding Robert Shearman
2015-03-22 20:02 ` Eric W. Biederman
2015-03-22 20:34 ` Eric W. Biederman
2015-03-23 13:42 ` Robert Shearman
2015-03-23 13:10 ` Robert Shearman
2015-03-20 15:42 ` [PATCH net-next v2 5/5] mpls: Allow payload type to be associated with label routes Robert Shearman
2015-03-22 20:56 ` Eric W. Biederman
2015-03-23 14:02 ` Robert Shearman
2015-03-30 18:15 ` [PATCH net-next v3 0/4] mpls: Behaviour-changing improvements Robert Shearman
2015-03-30 18:15 ` Robert Shearman [this message]
2015-03-30 18:15 ` [PATCH net-next v3 2/4] mpls: Differentiate implicit-null and unlabeled neighbours Robert Shearman
2015-04-07 16:56 ` Eric W. Biederman
2015-04-08 17:08 ` Robert Shearman
2015-03-30 18:15 ` [PATCH net-next v3 3/4] mpls: Per-device enabling of packet input Robert Shearman
2015-04-07 17:02 ` Eric W. Biederman
2015-04-08 14:29 ` Robert Shearman
2015-04-08 14:44 ` Eric W. Biederman
2015-03-30 18:15 ` [PATCH net-next v3 4/4] mpls: Allow payload type to be associated with label routes Robert Shearman
2015-04-07 17:19 ` Eric W. Biederman
2015-04-08 14:03 ` Robert Shearman
2015-04-01 19:30 ` [PATCH net-next v3 0/4] mpls: Behaviour-changing improvements David Miller
2015-04-01 21:14 ` Eric W. Biederman
2015-04-01 23:49 ` Robert Shearman
2015-04-06 20:02 ` David Miller
2015-04-14 22:44 ` [PATCH net-next v4 0/6] " Robert Shearman
2015-04-14 22:44 ` [PATCH net-next v4 1/6] mpls: Use definition for reserved label checks Robert Shearman
2015-04-14 22:44 ` [PATCH net-next v4 2/6] mpls: Per-device MPLS state Robert Shearman
2015-04-14 22:45 ` [PATCH net-next v4 3/6] mpls: Per-device enabling of packet input Robert Shearman
2015-04-14 22:45 ` [PATCH net-next v4 4/6] mpls: Allow payload type to be associated with label routes Robert Shearman
2015-04-14 22:45 ` [PATCH net-next v4 5/6] mpls: Differentiate implicit-null and unlabeled neighbours Robert Shearman
2015-04-14 22:45 ` [PATCH net-next v4 6/6] mpls: Prevent use of implicit NULL label as outgoing label Robert Shearman
2015-04-21 20:34 ` [PATCH 0/3] mpls: ABI changes for security and correctness Robert Shearman
2015-04-21 20:34 ` [PATCH 1/3] mpls: Per-device MPLS state Robert Shearman
2015-04-21 20:34 ` [PATCH 2/3] mpls: Per-device enabling of packet input Robert Shearman
2015-04-21 20:34 ` [PATCH 3/3] mpls: Prevent use of implicit NULL label as outgoing label Robert Shearman
2015-04-22 0:29 ` [PATCH 0/3] mpls: ABI changes for security and correctness Eric W. Biederman
2015-04-22 2:12 ` David Miller
2015-04-22 10:10 ` Robert Shearman
2015-04-22 10:14 ` [PATCH v2 " Robert Shearman
2015-04-22 10:14 ` [PATCH v2 1/3] mpls: Per-device MPLS state Robert Shearman
2015-04-22 15:25 ` Eric W. Biederman
2015-04-22 10:14 ` [PATCH v2 2/3] mpls: Per-device enabling of packet input Robert Shearman
2015-04-22 16:27 ` Eric W. Biederman
2015-04-22 10:14 ` [PATCH v2 3/3] mpls: Prevent use of implicit NULL label as outgoing label Robert Shearman
2015-04-22 16:32 ` Eric W. Biederman
2015-04-22 16:47 ` [PATCH v2 0/3] mpls: ABI changes for security and correctness Eric W. Biederman
2015-04-22 18:25 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427739356-28113-2-git-send-email-rshearma@brocade.com \
--to=rshearma@brocade.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).