Commit a6affd24 authored by Robert Shearman's avatar Robert Shearman Committed by David S. Miller

mpls: Use definition for reserved label checks

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.
Signed-off-by: default avatarRobert Shearman <rshearma@brocade.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c961b1cc
...@@ -41,4 +41,6 @@ struct mpls_label { ...@@ -41,4 +41,6 @@ struct mpls_label {
#define MPLS_LABEL_OAMALERT 14 /* RFC3429 */ #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */
#define MPLS_LABEL_EXTENSION 15 /* RFC7274 */ #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */
#define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */
#endif /* _UAPI_MPLS_H */ #endif /* _UAPI_MPLS_H */
...@@ -293,7 +293,7 @@ static void mpls_notify_route(struct net *net, unsigned index, ...@@ -293,7 +293,7 @@ static void mpls_notify_route(struct net *net, unsigned index,
struct mpls_route *rt = new ? new : old; struct mpls_route *rt = new ? new : old;
unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0; unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0;
/* Ignore reserved labels for now */ /* Ignore reserved labels for now */
if (rt && (index >= 16)) if (rt && (index >= MPLS_LABEL_FIRST_UNRESERVED))
rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags); rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags);
} }
...@@ -327,7 +327,8 @@ static unsigned find_free_label(struct net *net) ...@@ -327,7 +327,8 @@ static unsigned find_free_label(struct net *net)
platform_label = rtnl_dereference(net->mpls.platform_label); platform_label = rtnl_dereference(net->mpls.platform_label);
platform_labels = net->mpls.platform_labels; platform_labels = net->mpls.platform_labels;
for (index = 16; index < platform_labels; index++) { for (index = MPLS_LABEL_FIRST_UNRESERVED; index < platform_labels;
index++) {
if (!rtnl_dereference(platform_label[index])) if (!rtnl_dereference(platform_label[index]))
return index; return index;
} }
...@@ -436,8 +437,8 @@ static int mpls_route_add(struct mpls_route_config *cfg) ...@@ -436,8 +437,8 @@ static int mpls_route_add(struct mpls_route_config *cfg)
index = find_free_label(net); index = find_free_label(net);
} }
/* The first 16 labels are reserved, and may not be set */ /* Reserved labels may not be set */
if (index < 16) if (index < MPLS_LABEL_FIRST_UNRESERVED)
goto errout; goto errout;
/* The full 20 bit range may not be supported. */ /* The full 20 bit range may not be supported. */
...@@ -516,8 +517,8 @@ static int mpls_route_del(struct mpls_route_config *cfg) ...@@ -516,8 +517,8 @@ static int mpls_route_del(struct mpls_route_config *cfg)
index = cfg->rc_label; index = cfg->rc_label;
/* The first 16 labels are reserved, and may not be removed */ /* Reserved labels may not be removed */
if (index < 16) if (index < MPLS_LABEL_FIRST_UNRESERVED)
goto errout; goto errout;
/* The full 20 bit range may not be supported */ /* The full 20 bit range may not be supported */
...@@ -835,8 +836,8 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -835,8 +836,8 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
&cfg->rc_label)) &cfg->rc_label))
goto errout; goto errout;
/* The first 16 labels are reserved, and may not be set */ /* Reserved labels may not be set */
if (cfg->rc_label < 16) if (cfg->rc_label < MPLS_LABEL_FIRST_UNRESERVED)
goto errout; goto errout;
break; break;
...@@ -961,8 +962,8 @@ static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -961,8 +962,8 @@ static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb)
ASSERT_RTNL(); ASSERT_RTNL();
index = cb->args[0]; index = cb->args[0];
if (index < 16) if (index < MPLS_LABEL_FIRST_UNRESERVED)
index = 16; index = MPLS_LABEL_FIRST_UNRESERVED;
platform_label = rtnl_dereference(net->mpls.platform_label); platform_label = rtnl_dereference(net->mpls.platform_label);
platform_labels = net->mpls.platform_labels; platform_labels = net->mpls.platform_labels;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment