Skip to content

Conversation

@soopel
Copy link
Contributor

@soopel soopel commented Oct 24, 2025

No description provided.

Copy link
Contributor Author

@soopel soopel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if there is no deadlock created by adding this mutex.

@soopel
Copy link
Contributor Author

soopel commented Oct 24, 2025

Please check if there is no deadlock created by adding this mutex.

Here is analysis by AI

Analysis Summary:

✅ No deadlock risk detected! Here's why:

Functions that lock group_mutex:

mcast_membership_report_on_query (our fix) - line 192
mt_mcast_join - line 572
mt_mcast_leave - line 677
Functions called while holding the lock in mcast_membership_report_on_query:

rte_pktmbuf_alloc - DPDK function, no mutex
mcast_fill_ipv4 - simple helper, no mutex usage
mcast_create_group_record_on_query - inline helper, no mutex usage
Only accesses data structures, no function calls that could acquire locks
Callers of mcast_membership_report_on_query:

mcast_membership_report_cb (timer callback) - no mutex usage
mt_mcast_restore - no mutex usage
mt_mcast_parse - no mutex usage
No recursive locking:

None of the callers hold group_mutex before calling the function
None of the callees try to acquire group_mutex
The mutex is not recursive (standard pthread mutex)
Conclusion: The mutex addition is safe and correct. There is no deadlock risk because:

No nested locking of the same mutex
No circular dependency with other locks
Callers don't hold the lock before calling
Functions called while holding the lock don't try to acquire it
The fix properly protects the shared data (group_num and group_list) without introducing deadlock risks.

…rship_report_on_query

Protect access to mcast->group_num and mcast->group_list with group_mutex
to prevent data race conditions. These fields are written with the mutex
held elsewhere, so reads must also be protected.

- Acquire group_mutex before reading group_num
- Keep mutex held during TAILQ_FOREACH iteration of group_list
- Add proper unlock on all early return paths (no groups, alloc failure)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants