| 559 | } |
| 560 | |
| 561 | static int |
| 562 | open_socket_fd(void) |
| 563 | { |
| 564 | struct sockaddr_un un; |
| 565 | |
| 566 | peer_name[0] = '\0'; |
| 567 | if (rte_eal_process_type() == RTE_PROC_SECONDARY) |
| 568 | snprintf(peer_name, sizeof(peer_name), |
| 569 | "%d_%"PRIx64, getpid(), rte_rdtsc()); |
| 570 | |
| 571 | mp_fd = socket(AF_UNIX, SOCK_DGRAM, 0); |
| 572 | if (mp_fd < 0) { |
| 573 | RTE_LOG(ERR, EAL, "failed to create unix socket\n"); |
| 574 | return -1; |
| 575 | } |
| 576 | |
| 577 | memset(&un, 0, sizeof(un)); |
| 578 | un.sun_family = AF_UNIX; |
| 579 | |
| 580 | create_socket_path(peer_name, un.sun_path, sizeof(un.sun_path)); |
| 581 | |
| 582 | unlink(un.sun_path); /* May still exist since last run */ |
| 583 | |
| 584 | if (bind(mp_fd, (struct sockaddr *)&un, sizeof(un)) < 0) { |
| 585 | RTE_LOG(ERR, EAL, "failed to bind %s: %s\n", |
| 586 | un.sun_path, strerror(errno)); |
| 587 | close(mp_fd); |
| 588 | return -1; |
| 589 | } |
| 590 | |
| 591 | RTE_LOG(INFO, EAL, "Multi-process socket %s\n", un.sun_path); |
| 592 | return mp_fd; |
| 593 | } |
| 594 | |
| 595 | static void |
| 596 | close_socket_fd(int fd) |
no test coverage detected