Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mclagsyncd] fix out of order initialization #2274

Open
wants to merge 1 commit into
base: 202111
Choose a base branch
from

Conversation

bratashX
Copy link
Contributor

It's cherry-pick from master branch: #2112

What I did

Reorder class member variables.

Why I did it

I've encountered an issue with m_bufSize, it's initialization is random, some times it may be initializied with 0, some times with random value.

m_bufSize use MSG_BATCH_SIZE for initialization:

MclagLink::MclagLink(Select *select, int port) :
    MSG_BATCH_SIZE(256),
    m_bufSize(MCLAG_MAX_MSG_LEN * MSG_BATCH_SIZE),
    ...

but MSG_BATCH_SIZE declared after m_bufSize


class MclagLink : public Selectable {
  private:
    unsigned int m_bufSize;
    ...
    const int MSG_BATCH_SIZE;
    ...

so MSG_BATCH_SIZE will be initialized after m_bufSize, and m_bufSize will use MSG_BATCH_SIZE with uninitialized value.

How I verified it

Setup mclag topology, some times mclagsyncd will not be able to receive data after startup.

Details if related

More about this issue in cpp reference

IMHO it must be treated as compilation error, so it will be better to use-Werror=reorder parameter for compiler to avoid such issues.

Signed-off-by: Petro Bratash petrox.bratash@intel.com

@bratashX bratashX requested a review from prsunny as a code owner May 13, 2022 23:12
@bratashX bratashX force-pushed the 202111_mclagsyncd-out-of-order-initialization branch 2 times, most recently from a32b2f2 to 4e63220 Compare May 19, 2022 07:26
@bratashX bratashX force-pushed the 202111_mclagsyncd-out-of-order-initialization branch from 4e63220 to 5fbda09 Compare June 6, 2022 08:48
@bratashX bratashX force-pushed the 202111_mclagsyncd-out-of-order-initialization branch from 6fe7bc1 to 18807d9 Compare June 21, 2022 08:05
@bratashX
Copy link
Contributor Author

bratashX commented Aug 9, 2022

/easycla

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 9, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: bratashX / name: Petro Bratash (7d57217)

@bratashX bratashX force-pushed the 202111_mclagsyncd-out-of-order-initialization branch from 7014e9f to 7d57217 Compare August 9, 2022 11:44
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.

1 participant