iwinfo: generic improvement of assoclist handling#19
Open
Ansuel wants to merge 4 commits intoopenwrt:masterfrom
Open
iwinfo: generic improvement of assoclist handling#19Ansuel wants to merge 4 commits intoopenwrt:masterfrom
Ansuel wants to merge 4 commits intoopenwrt:masterfrom
Conversation
Limit assoclist element to IWINFO_BUFSIZE. This is to fix a segfault if the clients are more than 140. Once the local buffer is filled, the function stop parsing additional clients and returns info for the parsed ones. Fixes: openwrt#15 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Make assoclist OP aware of the max allocated buffer. This is done by setting the third arg to the max allocated buffer. Function needs to use this info to stop parsing data if the max allocated buffer size is reached. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Update any assoclist user to account for NULL buf. This is common practice where a NULL buf is passed if only the len element needs to be filled. This is useful to know how much space allocate for a function. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Change print_assoclist to dynamically allocate buffer for assoclist. Assoclist is called 2 times, one to get the size of the buffer to allocate by passint to assoclist a NULL buf. Then a second time to actually fill the data. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Member
Author
|
@mrisaev can you check and test? |
benboguan
added a commit
to benboguan/immortalwrt-mt798x
that referenced
this pull request
Dec 24, 2024
benboguan
added a commit
to benboguan/immortalwrt-mt798x
that referenced
this pull request
Dec 25, 2024
benboguan
added a commit
to benboguan/immortalwrt-mt798x
that referenced
this pull request
Dec 25, 2024
benboguan
added a commit
to benboguan/immortalwrt-mt798x
that referenced
this pull request
Dec 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This small PR makes generic improvement of assoclist handling.
Idea is to prevent any API change. User still needs to update their function to account for NULL buffer and len but updates likes that will only improve a fragile code.
This improves the assoc list and maybe also reduce the memory footprint. Allocating a big enough BUFFER is problematic for assoclist as it can grow a lot as it will contain info for every associated station.
To handle this, implement common practice way to get the number of element to alloc and dynamically alloc the space.
To apply this logic assoc list function needs to be called twice but this should not cause additional overhead.