Author | 高华涛 |
---|---|
Date | 2021-01-22 |
- |
The cni-operator module encapsulates the libcni module, provides a more reasonable and friendly network management interface for generation, and is responsible for loading and updating network configuration files.
/*
* Description: Network management module initialization: Initialize libcni network module and network management layer data;;
* cache_dir: Network cache configuration file storage directory;
* conf_path: cni configuration file storage directory;
* bin_paths: cni plugin storage directory list;
* bin_paths_len: directory listing length;
* Return value: return 0 on success, non-zero on failure
*/
int cni_manager_store_init(const char *cache_dir, const char *conf_path, const char * const *bin_paths, size_t bin_paths_len);
/*
* Description: According to the filtering rules, load the cni configuration file to the memory;
* store: cni configuration list;
* res_len: length of cni configuration list;
* filter_ops: Customize the cni configuration loading rules, and load the configuration files that meet the rules;
* Return value: return 0 on success, non-zero on failure
*/
int get_net_conflist_from_dir(struct cni_network_list_conf ***store, size_t *res_len, cni_conf_filter_t filter_ops);
/*
* Description: Create a container loopback network
* id: container id;
* netns: container network namespace;
* Return value: return 0 on success, non-zero on failure
*/
int attach_loopback(const char *id, const char *netns);
/*
* Description: delete the container loopback network
* id: container id;
* netns: container network namespace;
* Return value: return 0 on success, non-zero on failure
*/
int detach_loopback(const char *id, const char *netns);
/*
* Description: Create a container single network plane;
* manager: The set of parameters required for container network creation;
* list: network configuration;
* result: record necessary network information;
* Return value: return 0 on success, non-zero on failure
*/
int attach_network_plane(const struct cni_manager *manager, const struct cni_network_list_conf *list, struct cni_opt_result **result);
/*
* Description: delete the container single network plane;
* manager: The set of parameters required for container network deletion;
* list: network configuration;
* result: record necessary network information;
* Return value: return 0 on success, non-zero on failure
*/
int detach_network_plane(const struct cni_manager *manager, const struct cni_network_list_conf *list, struct cni_opt_result **result);
/*
* Description: Check the status of the single network plane of the container;
* manager: set of parameters required for container network check;
* list: network configuration;
* result: record necessary network information;
* Return value: return 0 on success, non-zero on failure
*/
int check_network_plane(const struct cni_manager *manager, const struct cni_network_list_conf *list, struct cni_opt_result **result);
/*
* Description: get the CNI version information supported by the plugins required for the single network plane of the container;
* list: network configuration;
* result_version_list: record the CNI version supported by the plugins;
* Return value: return 0 on success, non-zero on failure
*/
int version_network_plane(const struct cni_network_list_conf *list, struct cni_result_version_list **result_version_list);