[Libct] Regarding network namespaces.
Monali Porob
Monali.Porob at huawei.com
Thu Jan 29 09:56:33 PST 2015
Hi Andrew ,
While trying things with network namespaces , I tried to use the libct_net_dev_add_ip_addr() in the test/ct_net_veth.c and found the callback is not getting spawned.
The test program exits with main:89: FAIL: CT is not alive . How should I use this api . I am assuming that the api can be used to set the IP address for the veth0 inside the namespace. Correct me here if that's not the case.
I have limited background of libnl.
I did try executing shell commands like ifconfig and setting up ip addresses on veth pairs. With this I could get the namespace communication set to the outside world using Routes .
I was wondering if libct APIs could be used to do the same . Hence tried using libct_net_dev_add_ip_addr(). Please suggest .
Thanks and Regards,
Monali
Changed ct_net_veth.c
int main(int argc, char **argv)
{
int p[2];
struct ct_arg ca;
libct_session_t s;
ct_handler_t ct;
ct_process_desc_t pd;
ct_process_t pr;
struct ct_net_veth_arg va;
ct_net_t nd;
ca.mark = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANON, 0, 0);
pipe(p);
ca.mark[0] = 0;
ca.mark[1] = 0;
ca.mark[2] = 0;
ca.wait_pipe = p[0];
va.host_name = VETH_HOST_NAME;
va.ct_name = VETH_CT_NAME;
s = libct_session_open_local();
ct = libct_container_create(s, "test");
pd = libct_process_desc_create(s);
libct_container_set_nsmask(ct, CLONE_NEWNET);
nd = libct_net_add(ct, CT_NET_VETH, &va);
if (libct_handle_is_err(nd))
return tst_err("Can't add hostnic");
if (libct_net_dev_set_mac_addr(nd, "00:11:22:33:44:55"))
return tst_err("Can't set mac");
//Added by Monali
if (libct_net_dev_add_ip_addr(nd, "VETH_CT_ADDR"))
return tst_err("Can't set addr");
pr = libct_container_spawn_cb(ct, pd, check_ct_net, &ca);
if (libct_handle_is_err(pr))
return tst_err("Can't spawn CT");
...Same as in git
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/libct/attachments/20150129/22a08782/attachment.html>
More information about the Libct
mailing list