MCPcopy Create free account
hub / github.com/F-Stack/f-stack / memif_msg_receive

Function memif_msg_receive

dpdk/drivers/net/memif/memif_socket.c:632–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632static int
633memif_msg_receive(struct memif_control_channel *cc)
634{
635 char ctl[CMSG_SPACE(sizeof(int)) +
636 CMSG_SPACE(sizeof(struct ucred))] = { 0 };
637 struct msghdr mh = { 0 };
638 struct iovec iov[1];
639 memif_msg_t msg = { 0 };
640 ssize_t size;
641 int ret = 0;
642 struct ucred *cr __rte_unused;
643 cr = 0;
644 struct cmsghdr *cmsg;
645 int afd = -1;
646 int i;
647 struct pmd_internals *pmd;
648 struct pmd_process_private *proc_private;
649
650 iov[0].iov_base = (void *)&msg;
651 iov[0].iov_len = sizeof(memif_msg_t);
652 mh.msg_iov = iov;
653 mh.msg_iovlen = 1;
654 mh.msg_control = ctl;
655 mh.msg_controllen = sizeof(ctl);
656
657 if (rte_intr_fd_get(cc->intr_handle) < 0)
658 return -1;
659
660 size = recvmsg(rte_intr_fd_get(cc->intr_handle), &mh, 0);
661 if (size != sizeof(memif_msg_t)) {
662 MIF_LOG(DEBUG, "Invalid message size = %zd", size);
663 if (size > 0)
664 /* 0 means end-of-file, negative size means error,
665 * don't send further disconnect message in such cases.
666 */
667 memif_msg_enq_disconnect(cc, "Invalid message size", 0);
668 return -1;
669 }
670 MIF_LOG(DEBUG, "Received msg type: %u.", msg.type);
671
672 cmsg = CMSG_FIRSTHDR(&mh);
673 while (cmsg) {
674 if (cmsg->cmsg_level == SOL_SOCKET) {
675 if (cmsg->cmsg_type == SCM_CREDENTIALS)
676 cr = (struct ucred *)CMSG_DATA(cmsg);
677 else if (cmsg->cmsg_type == SCM_RIGHTS)
678 rte_memcpy(&afd, CMSG_DATA(cmsg), sizeof(int));
679 }
680 cmsg = CMSG_NXTHDR(&mh, cmsg);
681 }
682
683 if (cc->dev == NULL && msg.type != MEMIF_MSG_TYPE_INIT) {
684 MIF_LOG(DEBUG, "Unexpected message.");
685 memif_msg_enq_disconnect(cc, "Unexpected message", 0);
686 return -1;
687 }
688
689 /* get device from hash data */

Callers 1

memif_intr_handlerFunction · 0.85

Calls 15

rte_intr_fd_getFunction · 0.85
recvmsgFunction · 0.85
memif_msg_enq_disconnectFunction · 0.85
memif_msg_receive_helloFunction · 0.85
memif_msg_enq_initFunction · 0.85
memif_msg_enq_add_regionFunction · 0.85
memif_msg_enq_add_ringFunction · 0.85
memif_msg_enq_connectFunction · 0.85
memif_msg_receive_initFunction · 0.85
memif_msg_enq_ackFunction · 0.85

Tested by

no test coverage detected