diff options
author | Robert Shearman <rshearma@brocade.com> | 2015-08-03 12:50:04 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-08-04 01:35:00 -0400 |
commit | a6affd24f439feddec04bab4d1e3ad6579868367 (patch) | |
tree | 4c022d3b90de98c9922ae1773802ef4a45bbb399 | |
parent | c961b1ccd0f258bdee808c61c2c2a0907a1fffda (diff) |
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: Robert Shearman <rshearma@brocade.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/uapi/linux/mpls.h | 2 | ||||
-rw-r--r-- | net/mpls/af_mpls.c | 21 |
2 files changed, 13 insertions, 10 deletions
diff --git a/include/uapi/linux/mpls.h b/include/uapi/linux/mpls.h index 139d4dd1cab8..24a6cb1aec86 100644 --- a/include/uapi/linux/mpls.h +++ b/include/uapi/linux/mpls.h | |||
@@ -41,4 +41,6 @@ struct mpls_label { | |||
41 | #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */ | 41 | #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */ |
42 | #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */ | 42 | #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */ |
43 | 43 | ||
44 | #define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */ | ||
45 | |||
44 | #endif /* _UAPI_MPLS_H */ | 46 | #endif /* _UAPI_MPLS_H */ |
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 88cfaa241c07..b6b9a6c4e784 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c | |||
@@ -293,7 +293,7 @@ static void mpls_notify_route(struct net *net, unsigned index, | |||
293 | struct mpls_route *rt = new ? new : old; | 293 | struct mpls_route *rt = new ? new : old; |
294 | unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0; | 294 | unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0; |
295 | /* Ignore reserved labels for now */ | 295 | /* Ignore reserved labels for now */ |
296 | if (rt && (index >= 16)) | 296 | if (rt && (index >= MPLS_LABEL_FIRST_UNRESERVED)) |
297 | rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags); | 297 | rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags); |
298 | } | 298 | } |
299 | 299 | ||
@@ -327,7 +327,8 @@ static unsigned find_free_label(struct net *net) | |||
327 | 327 | ||
328 | platform_label = rtnl_dereference(net->mpls.platform_label); | 328 | platform_label = rtnl_dereference(net->mpls.platform_label); |
329 | platform_labels = net->mpls.platform_labels; | 329 | platform_labels = net->mpls.platform_labels; |
330 | for (index = 16; index < platform_labels; index++) { | 330 | for (index = MPLS_LABEL_FIRST_UNRESERVED; index < platform_labels; |
331 | index++) { | ||
331 | if (!rtnl_dereference(platform_label[index])) | 332 | if (!rtnl_dereference(platform_label[index])) |
332 | return index; | 333 | return index; |
333 | } | 334 | } |
@@ -436,8 +437,8 @@ static int mpls_route_add(struct mpls_route_config *cfg) | |||
436 | index = find_free_label(net); | 437 | index = find_free_label(net); |
437 | } | 438 | } |
438 | 439 | ||
439 | /* The first 16 labels are reserved, and may not be set */ | 440 | /* Reserved labels may not be set */ |
440 | if (index < 16) | 441 | if (index < MPLS_LABEL_FIRST_UNRESERVED) |
441 | goto errout; | 442 | goto errout; |
442 | 443 | ||
443 | /* The full 20 bit range may not be supported. */ | 444 | /* The full 20 bit range may not be supported. */ |
@@ -516,8 +517,8 @@ static int mpls_route_del(struct mpls_route_config *cfg) | |||
516 | 517 | ||
517 | index = cfg->rc_label; | 518 | index = cfg->rc_label; |
518 | 519 | ||
519 | /* The first 16 labels are reserved, and may not be removed */ | 520 | /* Reserved labels may not be removed */ |
520 | if (index < 16) | 521 | if (index < MPLS_LABEL_FIRST_UNRESERVED) |
521 | goto errout; | 522 | goto errout; |
522 | 523 | ||
523 | /* The full 20 bit range may not be supported */ | 524 | /* 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 | &cfg->rc_label)) | 836 | &cfg->rc_label)) |
836 | goto errout; | 837 | goto errout; |
837 | 838 | ||
838 | /* The first 16 labels are reserved, and may not be set */ | 839 | /* Reserved labels may not be set */ |
839 | if (cfg->rc_label < 16) | 840 | if (cfg->rc_label < MPLS_LABEL_FIRST_UNRESERVED) |
840 | goto errout; | 841 | goto errout; |
841 | 842 | ||
842 | break; | 843 | break; |
@@ -961,8 +962,8 @@ static int mpls_dump_routes(struct sk_buff *skb, struct netlink_callback *cb) | |||
961 | ASSERT_RTNL(); | 962 | ASSERT_RTNL(); |
962 | 963 | ||
963 | index = cb->args[0]; | 964 | index = cb->args[0]; |
964 | if (index < 16) | 965 | if (index < MPLS_LABEL_FIRST_UNRESERVED) |
965 | index = 16; | 966 | index = MPLS_LABEL_FIRST_UNRESERVED; |
966 | 967 | ||
967 | platform_label = rtnl_dereference(net->mpls.platform_label); | 968 | platform_label = rtnl_dereference(net->mpls.platform_label); |
968 | platform_labels = net->mpls.platform_labels; | 969 | platform_labels = net->mpls.platform_labels; |