cgroup-network.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "libnetdata/libnetdata.h"
  3. #ifdef HAVE_SETNS
  4. #ifndef _GNU_SOURCE
  5. #define _GNU_SOURCE /* See feature_test_macros(7) */
  6. #endif
  7. #include <sched.h>
  8. #endif
  9. char environment_variable2[FILENAME_MAX + 50] = "";
  10. char *environment[] = {
  11. "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",
  12. environment_variable2,
  13. NULL
  14. };
  15. // ----------------------------------------------------------------------------
  16. // callback required by fatal()
  17. void netdata_cleanup_and_exit(int ret) {
  18. exit(ret);
  19. }
  20. void send_statistics( const char *action, const char *action_result, const char *action_data) {
  21. (void) action;
  22. (void) action_result;
  23. (void) action_data;
  24. return;
  25. }
  26. // callbacks required by popen()
  27. void signals_block(void) {};
  28. void signals_unblock(void) {};
  29. void signals_reset(void) {};
  30. // callback required by eval()
  31. int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) {
  32. (void)variable;
  33. (void)hash;
  34. (void)rc;
  35. (void)result;
  36. return 0;
  37. };
  38. // required by get_system_cpus()
  39. char *netdata_configured_host_prefix = "";
  40. // ----------------------------------------------------------------------------
  41. struct iface {
  42. const char *device;
  43. uint32_t hash;
  44. unsigned int ifindex;
  45. unsigned int iflink;
  46. struct iface *next;
  47. };
  48. unsigned int read_iface_iflink(const char *prefix, const char *iface) {
  49. if(!prefix) prefix = "";
  50. char filename[FILENAME_MAX + 1];
  51. snprintfz(filename, FILENAME_MAX, "%s/sys/class/net/%s/iflink", prefix, iface);
  52. unsigned long long iflink = 0;
  53. int ret = read_single_number_file(filename, &iflink);
  54. if(ret) error("Cannot read '%s'.", filename);
  55. return (unsigned int)iflink;
  56. }
  57. unsigned int read_iface_ifindex(const char *prefix, const char *iface) {
  58. if(!prefix) prefix = "";
  59. char filename[FILENAME_MAX + 1];
  60. snprintfz(filename, FILENAME_MAX, "%s/sys/class/net/%s/ifindex", prefix, iface);
  61. unsigned long long ifindex = 0;
  62. int ret = read_single_number_file(filename, &ifindex);
  63. if(ret) error("Cannot read '%s'.", filename);
  64. return (unsigned int)ifindex;
  65. }
  66. struct iface *read_proc_net_dev(const char *scope, const char *prefix) {
  67. if(!prefix) prefix = "";
  68. procfile *ff = NULL;
  69. char filename[FILENAME_MAX + 1];
  70. snprintfz(filename, FILENAME_MAX, "%s%s", prefix, (*prefix)?"/proc/1/net/dev":"/proc/net/dev");
  71. #ifdef NETDATA_INTERNAL_CHECKS
  72. info("parsing '%s'", filename);
  73. #endif
  74. ff = procfile_open(filename, " \t,:|", PROCFILE_FLAG_DEFAULT);
  75. if(unlikely(!ff)) {
  76. error("Cannot open file '%s'", filename);
  77. return NULL;
  78. }
  79. ff = procfile_readall(ff);
  80. if(unlikely(!ff)) {
  81. error("Cannot read file '%s'", filename);
  82. return NULL;
  83. }
  84. size_t lines = procfile_lines(ff), l;
  85. struct iface *root = NULL;
  86. for(l = 2; l < lines ;l++) {
  87. if (unlikely(procfile_linewords(ff, l) < 1)) continue;
  88. struct iface *t = callocz(1, sizeof(struct iface));
  89. t->device = strdupz(procfile_lineword(ff, l, 0));
  90. t->hash = simple_hash(t->device);
  91. t->ifindex = read_iface_ifindex(prefix, t->device);
  92. t->iflink = read_iface_iflink(prefix, t->device);
  93. t->next = root;
  94. root = t;
  95. #ifdef NETDATA_INTERNAL_CHECKS
  96. info("added %s interface '%s', ifindex %u, iflink %u", scope, t->device, t->ifindex, t->iflink);
  97. #endif
  98. }
  99. procfile_close(ff);
  100. return root;
  101. }
  102. void free_iface(struct iface *iface) {
  103. freez((void *)iface->device);
  104. freez(iface);
  105. }
  106. void free_host_ifaces(struct iface *iface) {
  107. while(iface) {
  108. struct iface *t = iface->next;
  109. free_iface(iface);
  110. iface = t;
  111. }
  112. }
  113. int iface_is_eligible(struct iface *iface) {
  114. if(iface->iflink != iface->ifindex)
  115. return 1;
  116. return 0;
  117. }
  118. int eligible_ifaces(struct iface *root) {
  119. int eligible = 0;
  120. struct iface *t;
  121. for(t = root; t ; t = t->next)
  122. if(iface_is_eligible(t))
  123. eligible++;
  124. return eligible;
  125. }
  126. static void continue_as_child(void) {
  127. pid_t child = fork();
  128. int status;
  129. pid_t ret;
  130. if (child < 0)
  131. error("fork() failed");
  132. /* Only the child returns */
  133. if (child == 0)
  134. return;
  135. for (;;) {
  136. ret = waitpid(child, &status, WUNTRACED);
  137. if ((ret == child) && (WIFSTOPPED(status))) {
  138. /* The child suspended so suspend us as well */
  139. kill(getpid(), SIGSTOP);
  140. kill(child, SIGCONT);
  141. } else {
  142. break;
  143. }
  144. }
  145. /* Return the child's exit code if possible */
  146. if (WIFEXITED(status)) {
  147. exit(WEXITSTATUS(status));
  148. } else if (WIFSIGNALED(status)) {
  149. kill(getpid(), WTERMSIG(status));
  150. }
  151. exit(EXIT_FAILURE);
  152. }
  153. int proc_pid_fd(const char *prefix, const char *ns, pid_t pid) {
  154. if(!prefix) prefix = "";
  155. char filename[FILENAME_MAX + 1];
  156. snprintfz(filename, FILENAME_MAX, "%s/proc/%d/%s", prefix, (int)pid, ns);
  157. int fd = open(filename, O_RDONLY);
  158. if(fd == -1)
  159. error("Cannot open proc_pid_fd() file '%s'", filename);
  160. return fd;
  161. }
  162. static struct ns {
  163. int nstype;
  164. int fd;
  165. int status;
  166. const char *name;
  167. const char *path;
  168. } all_ns[] = {
  169. // { .nstype = CLONE_NEWUSER, .fd = -1, .status = -1, .name = "user", .path = "ns/user" },
  170. // { .nstype = CLONE_NEWCGROUP, .fd = -1, .status = -1, .name = "cgroup", .path = "ns/cgroup" },
  171. // { .nstype = CLONE_NEWIPC, .fd = -1, .status = -1, .name = "ipc", .path = "ns/ipc" },
  172. // { .nstype = CLONE_NEWUTS, .fd = -1, .status = -1, .name = "uts", .path = "ns/uts" },
  173. { .nstype = CLONE_NEWNET, .fd = -1, .status = -1, .name = "network", .path = "ns/net" },
  174. { .nstype = CLONE_NEWPID, .fd = -1, .status = -1, .name = "pid", .path = "ns/pid" },
  175. { .nstype = CLONE_NEWNS, .fd = -1, .status = -1, .name = "mount", .path = "ns/mnt" },
  176. // terminator
  177. { .nstype = 0, .fd = -1, .status = -1, .name = NULL, .path = NULL }
  178. };
  179. int switch_namespace(const char *prefix, pid_t pid) {
  180. if(!prefix) prefix = "";
  181. #ifdef HAVE_SETNS
  182. int i;
  183. for(i = 0; all_ns[i].name ; i++)
  184. all_ns[i].fd = proc_pid_fd(prefix, all_ns[i].path, pid);
  185. int root_fd = proc_pid_fd(prefix, "root", pid);
  186. int cwd_fd = proc_pid_fd(prefix, "cwd", pid);
  187. setgroups(0, NULL);
  188. // 2 passes - found it at nsenter source code
  189. // this is related CLONE_NEWUSER functionality
  190. // This code cannot switch user namespace (it can all the other namespaces)
  191. // Fortunately, we don't need to switch user namespaces.
  192. int pass;
  193. for(pass = 0; pass < 2 ;pass++) {
  194. for(i = 0; all_ns[i].name ; i++) {
  195. if (all_ns[i].fd != -1 && all_ns[i].status == -1) {
  196. if(setns(all_ns[i].fd, all_ns[i].nstype) == -1) {
  197. if(pass == 1) {
  198. all_ns[i].status = 0;
  199. error("Cannot switch to %s namespace of pid %d", all_ns[i].name, (int) pid);
  200. }
  201. }
  202. else
  203. all_ns[i].status = 1;
  204. }
  205. }
  206. }
  207. setgroups(0, NULL);
  208. if(root_fd != -1) {
  209. if(fchdir(root_fd) < 0)
  210. error("Cannot fchdir() to pid %d root directory", (int)pid);
  211. if(chroot(".") < 0)
  212. error("Cannot chroot() to pid %d root directory", (int)pid);
  213. close(root_fd);
  214. }
  215. if(cwd_fd != -1) {
  216. if(fchdir(cwd_fd) < 0)
  217. error("Cannot fchdir() to pid %d current working directory", (int)pid);
  218. close(cwd_fd);
  219. }
  220. int do_fork = 0;
  221. for(i = 0; all_ns[i].name ; i++)
  222. if(all_ns[i].fd != -1) {
  223. // CLONE_NEWPID requires a fork() to become effective
  224. if(all_ns[i].nstype == CLONE_NEWPID && all_ns[i].status)
  225. do_fork = 1;
  226. close(all_ns[i].fd);
  227. }
  228. if(do_fork)
  229. continue_as_child();
  230. return 0;
  231. #else
  232. errno = ENOSYS;
  233. error("setns() is missing on this system.");
  234. return 1;
  235. #endif
  236. }
  237. pid_t read_pid_from_cgroup_file(const char *filename) {
  238. int fd = open(filename, procfile_open_flags);
  239. if(fd == -1) {
  240. error("Cannot open pid_from_cgroup() file '%s'.", filename);
  241. return 0;
  242. }
  243. FILE *fp = fdopen(fd, "r");
  244. if(!fp) {
  245. error("Cannot upgrade fd to fp for file '%s'.", filename);
  246. return 0;
  247. }
  248. char buffer[100 + 1];
  249. pid_t pid = 0;
  250. char *s;
  251. while((s = fgets(buffer, 100, fp))) {
  252. buffer[100] = '\0';
  253. pid = atoi(s);
  254. if(pid > 0) break;
  255. }
  256. fclose(fp);
  257. #ifdef NETDATA_INTERNAL_CHECKS
  258. if(pid > 0) info("found pid %d on file '%s'", pid, filename);
  259. #endif
  260. return pid;
  261. }
  262. pid_t read_pid_from_cgroup_files(const char *path) {
  263. char filename[FILENAME_MAX + 1];
  264. snprintfz(filename, FILENAME_MAX, "%s/cgroup.procs", path);
  265. pid_t pid = read_pid_from_cgroup_file(filename);
  266. if(pid > 0) return pid;
  267. snprintfz(filename, FILENAME_MAX, "%s/tasks", path);
  268. return read_pid_from_cgroup_file(filename);
  269. }
  270. pid_t read_pid_from_cgroup(const char *path) {
  271. pid_t pid = read_pid_from_cgroup_files(path);
  272. if (pid > 0) return pid;
  273. DIR *dir = opendir(path);
  274. if (!dir) {
  275. error("cannot read directory '%s'", path);
  276. return 0;
  277. }
  278. struct dirent *de = NULL;
  279. while ((de = readdir(dir))) {
  280. if (de->d_type == DT_DIR
  281. && (
  282. (de->d_name[0] == '.' && de->d_name[1] == '\0')
  283. || (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')
  284. ))
  285. continue;
  286. if (de->d_type == DT_DIR) {
  287. char filename[FILENAME_MAX + 1];
  288. snprintfz(filename, FILENAME_MAX, "%s/%s", path, de->d_name);
  289. pid = read_pid_from_cgroup(filename);
  290. if(pid > 0) break;
  291. }
  292. }
  293. closedir(dir);
  294. return pid;
  295. }
  296. // ----------------------------------------------------------------------------
  297. // send the result to netdata
  298. struct found_device {
  299. const char *host_device;
  300. const char *guest_device;
  301. uint32_t host_device_hash;
  302. struct found_device *next;
  303. } *detected_devices = NULL;
  304. void add_device(const char *host, const char *guest) {
  305. #ifdef NETDATA_INTERNAL_CHECKS
  306. info("adding device with host '%s', guest '%s'", host, guest);
  307. #endif
  308. uint32_t hash = simple_hash(host);
  309. if(guest && (!*guest || strcmp(host, guest) == 0))
  310. guest = NULL;
  311. struct found_device *f;
  312. for(f = detected_devices; f ; f = f->next) {
  313. if(f->host_device_hash == hash && !strcmp(host, f->host_device)) {
  314. if(guest && (!f->guest_device || !strcmp(f->host_device, f->guest_device))) {
  315. if(f->guest_device) freez((void *)f->guest_device);
  316. f->guest_device = strdupz(guest);
  317. }
  318. return;
  319. }
  320. }
  321. f = mallocz(sizeof(struct found_device));
  322. f->host_device = strdupz(host);
  323. f->host_device_hash = hash;
  324. f->guest_device = (guest)?strdupz(guest):NULL;
  325. f->next = detected_devices;
  326. detected_devices = f;
  327. }
  328. int send_devices(void) {
  329. int found = 0;
  330. struct found_device *f;
  331. for(f = detected_devices; f ; f = f->next) {
  332. found++;
  333. printf("%s %s\n", f->host_device, (f->guest_device)?f->guest_device:f->host_device);
  334. }
  335. return found;
  336. }
  337. // ----------------------------------------------------------------------------
  338. // this function should be called only **ONCE**
  339. // also it has to be the **LAST** to be called
  340. // since it switches namespaces, so after this call, everything is different!
  341. void detect_veth_interfaces(pid_t pid) {
  342. struct iface *cgroup = NULL;
  343. struct iface *host, *h, *c;
  344. host = read_proc_net_dev("host", netdata_configured_host_prefix);
  345. if(!host) {
  346. errno = 0;
  347. error("cannot read host interface list.");
  348. goto cleanup;
  349. }
  350. if(!eligible_ifaces(host)) {
  351. errno = 0;
  352. error("there are no double-linked host interfaces available.");
  353. goto cleanup;
  354. }
  355. if(switch_namespace(netdata_configured_host_prefix, pid)) {
  356. errno = 0;
  357. error("cannot switch to the namespace of pid %u", (unsigned int) pid);
  358. goto cleanup;
  359. }
  360. #ifdef NETDATA_INTERNAL_CHECKS
  361. info("switched to namespaces of pid %d", pid);
  362. #endif
  363. cgroup = read_proc_net_dev("cgroup", NULL);
  364. if(!cgroup) {
  365. errno = 0;
  366. error("cannot read cgroup interface list.");
  367. goto cleanup;
  368. }
  369. if(!eligible_ifaces(cgroup)) {
  370. errno = 0;
  371. error("there are not double-linked cgroup interfaces available.");
  372. goto cleanup;
  373. }
  374. for(h = host; h ; h = h->next) {
  375. if(iface_is_eligible(h)) {
  376. for (c = cgroup; c; c = c->next) {
  377. if(iface_is_eligible(c) && h->ifindex == c->iflink && h->iflink == c->ifindex) {
  378. add_device(h->device, c->device);
  379. }
  380. }
  381. }
  382. }
  383. cleanup:
  384. free_host_ifaces(cgroup);
  385. free_host_ifaces(host);
  386. }
  387. // ----------------------------------------------------------------------------
  388. // call the external helper
  389. #define CGROUP_NETWORK_INTERFACE_MAX_LINE 2048
  390. void call_the_helper(pid_t pid, const char *cgroup) {
  391. if(setresuid(0, 0, 0) == -1)
  392. error("setresuid(0, 0, 0) failed.");
  393. char command[CGROUP_NETWORK_INTERFACE_MAX_LINE + 1];
  394. if(cgroup)
  395. snprintfz(command, CGROUP_NETWORK_INTERFACE_MAX_LINE, "exec " PLUGINS_DIR "/cgroup-network-helper.sh --cgroup '%s'", cgroup);
  396. else
  397. snprintfz(command, CGROUP_NETWORK_INTERFACE_MAX_LINE, "exec " PLUGINS_DIR "/cgroup-network-helper.sh --pid %d", pid);
  398. info("running: %s", command);
  399. pid_t cgroup_pid;
  400. FILE *fp = mypopene(command, &cgroup_pid, environment);
  401. if(fp) {
  402. char buffer[CGROUP_NETWORK_INTERFACE_MAX_LINE + 1];
  403. char *s;
  404. while((s = fgets(buffer, CGROUP_NETWORK_INTERFACE_MAX_LINE, fp))) {
  405. trim(s);
  406. if(*s && *s != '\n') {
  407. char *t = s;
  408. while(*t && *t != ' ') t++;
  409. if(*t == ' ') {
  410. *t = '\0';
  411. t++;
  412. }
  413. if(!*s || !*t) continue;
  414. add_device(s, t);
  415. }
  416. }
  417. mypclose(fp, cgroup_pid);
  418. }
  419. else
  420. error("cannot execute cgroup-network helper script: %s", command);
  421. }
  422. int is_valid_path_symbol(char c) {
  423. switch(c) {
  424. case '/': // path separators
  425. case '\\': // needed for virsh domains \x2d1\x2dname
  426. case ' ': // space
  427. case '-': // hyphen
  428. case '_': // underscore
  429. case '.': // dot
  430. case ',': // comma
  431. return 1;
  432. default:
  433. return 0;
  434. }
  435. }
  436. // we will pass this path a shell script running as root
  437. // so, we need to make sure the path will be valid
  438. // and will not include anything that could allow
  439. // the caller use shell expansion for gaining escalated
  440. // privileges.
  441. int verify_path(const char *path) {
  442. struct stat sb;
  443. char c;
  444. const char *s = path;
  445. while((c = *s++)) {
  446. if(!( isalnum(c) || is_valid_path_symbol(c) )) {
  447. error("invalid character in path '%s'", path);
  448. return -1;
  449. }
  450. }
  451. if(strstr(path, "\\") && !strstr(path, "\\x")) {
  452. error("invalid escape sequence in path '%s'", path);
  453. return 1;
  454. }
  455. if(strstr(path, "/../")) {
  456. error("invalid parent path sequence detected in '%s'", path);
  457. return 1;
  458. }
  459. if(path[0] != '/') {
  460. error("only absolute path names are supported - invalid path '%s'", path);
  461. return -1;
  462. }
  463. if (stat(path, &sb) == -1) {
  464. error("cannot stat() path '%s'", path);
  465. return -1;
  466. }
  467. if((sb.st_mode & S_IFMT) != S_IFDIR) {
  468. error("path '%s' is not a directory", path);
  469. return -1;
  470. }
  471. return 0;
  472. }
  473. /*
  474. char *fix_path_variable(void) {
  475. const char *path = getenv("PATH");
  476. if(!path || !*path) return 0;
  477. char *p = strdupz(path);
  478. char *safe_path = callocz(1, strlen(p) + strlen("PATH=") + 1);
  479. strcpy(safe_path, "PATH=");
  480. int added = 0;
  481. char *ptr = p;
  482. while(ptr && *ptr) {
  483. char *s = strsep(&ptr, ":");
  484. if(s && *s) {
  485. if(verify_path(s) == -1) {
  486. error("the PATH variable includes an invalid path '%s' - removed it.", s);
  487. }
  488. else {
  489. info("the PATH variable includes a valid path '%s'.", s);
  490. if(added) strcat(safe_path, ":");
  491. strcat(safe_path, s);
  492. added++;
  493. }
  494. }
  495. }
  496. info("unsafe PATH: '%s'.", path);
  497. info(" safe PATH: '%s'.", safe_path);
  498. freez(p);
  499. return safe_path;
  500. }
  501. */
  502. // ----------------------------------------------------------------------------
  503. // main
  504. void usage(void) {
  505. fprintf(stderr, "%s [ -p PID | --pid PID | --cgroup /path/to/cgroup ]\n", program_name);
  506. exit(1);
  507. }
  508. int main(int argc, char **argv) {
  509. pid_t pid = 0;
  510. program_name = argv[0];
  511. program_version = VERSION;
  512. error_log_syslog = 0;
  513. // since cgroup-network runs as root, prevent it from opening symbolic links
  514. procfile_open_flags = O_RDONLY|O_NOFOLLOW;
  515. // ------------------------------------------------------------------------
  516. // make sure NETDATA_HOST_PREFIX is safe
  517. netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
  518. if(verify_netdata_host_prefix() == -1) exit(1);
  519. if(netdata_configured_host_prefix[0] != '\0' && verify_path(netdata_configured_host_prefix) == -1)
  520. fatal("invalid NETDATA_HOST_PREFIX '%s'", netdata_configured_host_prefix);
  521. // ------------------------------------------------------------------------
  522. // build a safe environment for our script
  523. // the first environment variable is a fixed PATH=
  524. snprintfz(environment_variable2, sizeof(environment_variable2) - 1, "NETDATA_HOST_PREFIX=%s", netdata_configured_host_prefix);
  525. // ------------------------------------------------------------------------
  526. if(argc == 2 && (!strcmp(argv[1], "version") || !strcmp(argv[1], "-version") || !strcmp(argv[1], "--version") || !strcmp(argv[1], "-v") || !strcmp(argv[1], "-V"))) {
  527. fprintf(stderr, "cgroup-network %s\n", VERSION);
  528. exit(0);
  529. }
  530. if(argc != 3)
  531. usage();
  532. if(!strcmp(argv[1], "-p") || !strcmp(argv[1], "--pid")) {
  533. pid = atoi(argv[2]);
  534. if(pid <= 0) {
  535. errno = 0;
  536. error("Invalid pid %d given", (int) pid);
  537. return 2;
  538. }
  539. call_the_helper(pid, NULL);
  540. }
  541. else if(!strcmp(argv[1], "--cgroup")) {
  542. char *cgroup = argv[2];
  543. if(verify_path(cgroup) == -1)
  544. fatal("cgroup '%s' does not exist or is not valid.", cgroup);
  545. pid = read_pid_from_cgroup(cgroup);
  546. call_the_helper(pid, cgroup);
  547. if(pid <= 0 && !detected_devices) {
  548. errno = 0;
  549. error("Cannot find a cgroup PID from cgroup '%s'", cgroup);
  550. }
  551. }
  552. else
  553. usage();
  554. if(pid > 0)
  555. detect_veth_interfaces(pid);
  556. int found = send_devices();
  557. if(found <= 0) return 1;
  558. return 0;
  559. }