Skip to content

Memory leak when sending messages between NFs with full rings #293

Description

@twood02

Bug Report

Current Behavior
If an NF tries to send a message to another NF using the onvm_nflib_send_msg_to_nf() function it will allocate memory to store the message and then enqueue the message for the other NF. If the enqueue fails (because the destination NF's ring is full), then the allocated memory will never be freed.

onvm_nflib_send_msg_to_nf(uint16_t dest, void *msg_data) {
int ret;
struct onvm_nf_msg *msg;
ret = rte_mempool_get(nf_msg_pool, (void**)(&msg));
if (ret != 0) {
RTE_LOG(INFO, APP, "Oh the huge manatee! Unable to allocate msg from pool :(\n");
return ret;
}
msg->msg_type = MSG_FROM_NF;
msg->msg_data = msg_data;
return rte_ring_enqueue(nfs[dest].msg_q, (void*)msg);
}

Expected behavior/code
If the enqueue fails, we should free the allocated message. So line 730 should be split into multiple lines that check if the enqueue succeeds or fails, calls rte_mempool_put on failure, and then returns the success/failure flag.

Steps to reproduce
I don't think any of our example NFs use this function (it has mainly been used in our research projects). We should create a simple test NF that demonstrates this functionality and helps us verify that the bug is fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions