github.com/cilium/cilium@v1.16.2/bpf/lib/clustermesh.h (about)

     1  /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
     2  
     3  #pragma once
     4  
     5  #include "lib/utils.h"
     6  
     7  #define CLUSTER_ID_LOWER_MASK 0x000000FF
     8  
     9  #ifndef __CLUSTERMESH_HELPERS__
    10  #define __CLUSTERMESH_HELPERS__
    11  /* these macros allow us to override the values in tests */
    12  #define IDENTITY_LEN get_identity_len()
    13  #define IDENTITY_MAX get_max_identity()
    14  
    15  static __always_inline __u32
    16  get_identity_len()
    17  {
    18  	__u32 identity_len = CONFIG(identity_length);
    19  	return identity_len;
    20  }
    21  
    22  #endif /* __CLUSTERMESH_HELPERS__ */
    23  
    24  
    25  static __always_inline __u32
    26  extract_cluster_id_from_identity(__u32 identity)
    27  {
    28  	return (__u32)(identity >> IDENTITY_LEN);
    29  }
    30  
    31  static __always_inline __u32
    32  get_max_identity()
    33  {
    34  	return (__u32)((1 << IDENTITY_LEN) - 1);
    35  }
    36  
    37  static __always_inline __maybe_unused __u32
    38  get_cluster_id_upper_mask()
    39  {
    40  	return (CLUSTER_ID_MAX & ~CLUSTER_ID_LOWER_MASK) << (8 + IDENTITY_LEN);
    41  }
    42  
    43  static __always_inline __maybe_unused __u32
    44  get_mark_magic_cluster_id_mask()
    45  {
    46  	return CLUSTER_ID_LOWER_MASK | get_cluster_id_upper_mask();
    47  }