-
Notifications
You must be signed in to change notification settings - Fork 301
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
Fix LPM4 search error on non-existent entry #1223
base: master
Are you sure you want to change the base?
Conversation
The build failure appears to be just that the LPM tests need CPU affinity, or they error out. I made a patch some weeks ago to fix this but due to Snabb's needlessly complicated merge policies, now we have to live with every PR to master failing for the next month :( |
Hi @benagricola, Would you mind adding a test for this ? Pete |
Signed-off-by: Ben Agricola <bagricola@squiz.co.uk>
3be18c8
to
4ac4e69
Compare
@petebristow Added a test for nonexistent entries returning nil, and also a nonexact prefix test. Does this suffice? |
I'll merge this on the next sweep through PRs unless @petebristow has objections. |
Looks good to me. |
Having thought about this some more over in #1238 and looked at my internal version. The reason the search function doesn't react well to a missing entry is because parts of the code base assume there will always be a default route. It's not documented, nor are there assertions in the code. Given that it may be a bad idea to merge this. |
@petebristow so to confirm, the correct way to use the LPM library is to always add a default route entry. If there's no actual default route, storing a 'NOT FOUND' value of some sort is required? |
Yes as it stands. I'm thinking it would be better if What do you think ? |
Yep that sounds good. This is only a problem if you don't know that LPM requires a default / not found so implicitly adding one makes sense. I suppose you could still hit this issue if you deleted the implicitly added not found but as long as it's documented i think that makes sense. |
When attempting to
:search_bytes()
for an entry which doesn't exist, an error is generated:This is because LPM4:search attempts to retrieve
key
from the returned (nil
) value from:search_entry()
This fix checks that entry is not null before attempting to return the key.