Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Robert Shearman and committed by
David S. Miller
a6affd24 c961b1cc

+13 -10
+2
include/uapi/linux/mpls.h
··· 41 41 #define MPLS_LABEL_OAMALERT 14 /* RFC3429 */ 42 42 #define MPLS_LABEL_EXTENSION 15 /* RFC7274 */ 43 43 44 + #define MPLS_LABEL_FIRST_UNRESERVED 16 /* RFC3032 */ 45 + 44 46 #endif /* _UAPI_MPLS_H */
+11 -10
net/mpls/af_mpls.c
··· 293 293 struct mpls_route *rt = new ? new : old; 294 294 unsigned nlm_flags = (old && new) ? NLM_F_REPLACE : 0; 295 295 /* Ignore reserved labels for now */ 296 - if (rt && (index >= 16)) 296 + if (rt && (index >= MPLS_LABEL_FIRST_UNRESERVED)) 297 297 rtmsg_lfib(event, index, rt, nlh, net, portid, nlm_flags); 298 298 } 299 299 ··· 327 327 328 328 platform_label = rtnl_dereference(net->mpls.platform_label); 329 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 332 if (!rtnl_dereference(platform_label[index])) 332 333 return index; 333 334 } ··· 437 436 index = find_free_label(net); 438 437 } 439 438 440 - /* The first 16 labels are reserved, and may not be set */ 441 - if (index < 16) 439 + /* Reserved labels may not be set */ 440 + if (index < MPLS_LABEL_FIRST_UNRESERVED) 442 441 goto errout; 443 442 444 443 /* The full 20 bit range may not be supported. */ ··· 517 516 518 517 index = cfg->rc_label; 519 518 520 - /* The first 16 labels are reserved, and may not be removed */ 521 - if (index < 16) 519 + /* Reserved labels may not be removed */ 520 + if (index < MPLS_LABEL_FIRST_UNRESERVED) 522 521 goto errout; 523 522 524 523 /* The full 20 bit range may not be supported */ ··· 836 835 &cfg->rc_label)) 837 836 goto errout; 838 837 839 - /* The first 16 labels are reserved, and may not be set */ 840 - if (cfg->rc_label < 16) 838 + /* Reserved labels may not be set */ 839 + if (cfg->rc_label < MPLS_LABEL_FIRST_UNRESERVED) 841 840 goto errout; 842 841 843 842 break; ··· 962 961 ASSERT_RTNL(); 963 962 964 963 index = cb->args[0]; 965 - if (index < 16) 966 - index = 16; 964 + if (index < MPLS_LABEL_FIRST_UNRESERVED) 965 + index = MPLS_LABEL_FIRST_UNRESERVED; 967 966 968 967 platform_label = rtnl_dereference(net->mpls.platform_label); 969 968 platform_labels = net->mpls.platform_labels;