Turn lip_namespace into a vector
This commit is contained in:
26
lcpng.c
26
lcpng.c
@ -26,8 +26,8 @@ lcp_main_t lcp_main;
|
||||
u8 *lcp_get_default_ns(void) {
|
||||
lcp_main_t *lcpm = &lcp_main;
|
||||
|
||||
if (lcpm->default_namespace[0] == 0)
|
||||
return 0;
|
||||
if (!lcpm->default_namespace || lcpm->default_namespace[0] == 0)
|
||||
return NULL;
|
||||
return lcpm->default_namespace;
|
||||
}
|
||||
|
||||
@ -53,20 +53,20 @@ int lcp_set_default_ns(u8 *ns) {
|
||||
|
||||
if (!p || *p == 0)
|
||||
{
|
||||
clib_memset(lcpm->default_namespace, 0, sizeof(lcpm->default_namespace));
|
||||
if (lcpm->default_ns_fd > 0)
|
||||
close(lcpm->default_ns_fd);
|
||||
lcpm->default_ns_fd = 0;
|
||||
return 0;
|
||||
lcpm->default_namespace = NULL;
|
||||
if (lcpm->default_ns_fd > 0)
|
||||
close (lcpm->default_ns_fd);
|
||||
lcpm->default_ns_fd = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
clib_strncpy((char *)lcpm->default_namespace, p, LCP_NS_LEN - 1);
|
||||
vec_validate_init_c_string (lcpm->default_namespace, p,
|
||||
clib_strnlen (p, LCP_NS_LEN));
|
||||
s = format (0, "/var/run/netns/%s%c", (char *) lcpm->default_namespace, 0);
|
||||
lcpm->default_ns_fd = open ((char *) s, O_RDONLY);
|
||||
vec_free (s);
|
||||
|
||||
s = format(0, "/var/run/netns/%s%c", (char *)lcpm->default_namespace, 0);
|
||||
lcpm->default_ns_fd = open((char *)s, O_RDONLY);
|
||||
vec_free(s);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
2
lcpng.h
2
lcpng.h
@ -22,7 +22,7 @@
|
||||
typedef struct lcp_main_s
|
||||
{
|
||||
u16 msg_id_base; /* API message ID base */
|
||||
u8 default_namespace[LCP_NS_LEN]; /* default namespace if set */
|
||||
u8 *default_namespace; /* default namespace if set */
|
||||
int default_ns_fd;
|
||||
u8 lcp_auto_subint; /* Automatically create/delete LCP sub-interfaces */
|
||||
u8 lcp_sync; /* Automatically sync VPP changes to LCP */
|
||||
|
@ -264,11 +264,7 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name,
|
||||
lip->lip_host_name = vec_dup (host_name);
|
||||
lip->lip_host_type = host_type;
|
||||
lip->lip_vif_index = host_index;
|
||||
|
||||
// TODO(pim) - understand why vec_dup(ns) returns 'nil' here
|
||||
lip->lip_namespace = 0;
|
||||
if (ns && ns[0] != 0)
|
||||
lip->lip_namespace = (u8 *) strdup ((const char *) ns);
|
||||
lip->lip_namespace = vec_dup (ns);
|
||||
|
||||
/*
|
||||
* First use of this host interface.
|
||||
@ -457,8 +453,7 @@ lcp_itf_pair_del (u32 phy_sw_if_index)
|
||||
hash_unset (lip_db_by_vif, lip->lip_vif_index);
|
||||
|
||||
vec_free (lip->lip_host_name);
|
||||
if (lip->lip_namespace)
|
||||
free (lip->lip_namespace);
|
||||
vec_free (lip->lip_namespace);
|
||||
pool_put (lcp_itf_pair_pool, lip);
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user