-
Notifications
You must be signed in to change notification settings - Fork 139
Description
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.
openNetVM/onvm/onvm_nflib/onvm_nflib.c
Lines 717 to 731 in 61ce33a
| 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.