1 /* See the DRL-LICENSE file for this file's software license. */
8 /** Enumeration of identity types. */
11 /** Type used by identities that will limit all slivers on the machine. */
14 /** Type used by identities that will limit only a subset of slivers. */
18 /** Enumeration of identity member types. */
21 /** The member is an identifier (xid) of a single sliver. */
24 /** The member is an identifier (guid) of another sliver-set identity. */
29 * Linked list node containing address information for one of the identity's
32 typedef struct ident_peer {
33 /** The peer's IP address. */
36 /** Pointer to the next peer in the list or NULL if this is the last. */
37 struct ident_peer *next;
41 * Linked list node containing hierarchy information. For whole-machine
42 * identities, this is unnecessary. For sliver-set identities, this specifies
43 * which slivers and other sliver-sets belong in the set.
45 typedef struct ident_member {
46 /** The numerical xid or guid of the member. */
49 /** Specifies whether the value is an xid or guid. */
50 enum member_types type;
52 /** Pointer to the next member in the list or NULL if this is the last. */
53 struct ident_member *next;
57 * Linked list node containing identity information.
59 typedef struct ident_config {
60 /** The guid of this identity. */
63 /** The global DRL limit for this identity. */
66 /** The communication fabric (COMM_MESH or COMM_GOSSIP) for this identity.*/
67 enum commfabrics commfabric;
69 /** The gossip branch factor (when commfabric is COMM_GOSSIP). */
72 /** The flow accounting mechanism to be used by this identity. */
73 enum accountings accounting;
75 /** The fixed (1-second) ewma weight value for this identity. */
76 double fixed_ewma_weight;
78 /** The number of limiter intervals to wait between calls to estimate,
79 * allocate and enforce. */
80 int mainloop_intervals;
82 /** The number of limiter intervals to wait between communication. */
83 int communication_intervals;
85 /** The type of this identity. */
86 enum ident_types type;
88 /** List of the identity's peers. */
91 /** The number of peers. */
94 /** If this is set, the node goes under the root rather than machine nodes. */
97 /** List of the identity's members (type IDENT_SET only). */
98 ident_member *members;
100 /** Pointer to the next ident in the list or NULL if this is the last. */
101 struct ident_config *next;
105 * Structure used to pass two lists after parsing is complete.
107 typedef struct parsed_configs {
108 /** A list of IDENT_MACHINE type identities. */
109 ident_config *machines;
111 /** The number of machine identities. */
114 /** A list of IDENT_SET type identities. */
117 /** The number of set identities. */
120 /** Pointer to the tail of the machines list. */
121 ident_config *last_machine;
123 /** Pointer to the tail of the sets list. */
124 ident_config *last_set;
128 * Frees the specified ident and all of the memory associated with it and its
131 * @param ident The ident to free.
133 void free_ident(ident_config *ident);
136 * Frees the specified list of identities and all of the memory associated
139 * @param list The ident_config list to free.
141 void free_ident_list(ident_config *list);
144 * Uses libxml2 to parse a DRL configuration XML file and converts the
145 * information into a linked list of identities.
147 * @param configfile The path to the XML configuration file.
148 * @param configs A parsed_configs structure to be filled in with linked list
149 * of machine and set configs.
151 * @returns zero on success, non-zero on error.
153 int parse_drl_config(const char *configfile, parsed_configs *configs);
156 * Reads /proc/virtual to get a list of viable xids. It creates an array of
157 * leaf_t structures and a map that maps xid to the leaf_t in the array with
160 * @param instance The drl_instance_t to be filled in. This function sets
161 * the instance's leaf_map, leaves, and leaf_count fields.
163 * @returns zero on success, non-zero on error. (Possibly ENOMEM if memory
164 * allocation fails, or 1 if the cause of the error is unclear. */
165 int get_eligible_leaves(struct drl_instance *instance);
167 #endif /* _DRL_CONFIG_ */