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

Fix checking for netlink errors when receiving only a single message #50

Merged
merged 3 commits into from
Oct 31, 2017
Merged

Conversation

RalfJung
Copy link
Member

The current implementation fails to raise an exception when an error is returned.

This masks a problem where on newer kernels, tunneldigger fails to create tunnels because l2tpv3 session IDs have to be globally unique.

@kostko
Copy link
Member

kostko commented Oct 29, 2017

Thanks! Please rebase on master as Travis tests were fixed (there was a netfilter policy change on Travis, which broke our tests).

@RalfJung
Copy link
Member Author

Done.

os.strerror(errno), errno))
err.errno = errno
raise err
# A non-error message
Copy link
Member

Choose a reason for hiding this comment

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

Add an empty line above.

os.strerror(errno), errno))
err.errno = errno
raise err
# an ack
Copy link
Member

Choose a reason for hiding this comment

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

This is only possible in case the errno contained in the message is zero. Currently, the handling in this case is inconsistent when multiple is True (error message is skipped and not included in the final list) and when multiple is False (error message is appended to the list of received messages). I think this should be unified.

Copy link
Member Author

Choose a reason for hiding this comment

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

When multiple is False, the entire point of calling this message is to receive the ACK. If we skip it, all uses of multiple=False will break.

Maybe it makes more sense to have a dedicated function recv_ack, and rename this one into recv_until_done?

Copy link
Member

Choose a reason for hiding this comment

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

I see, so an ACK is actually a message of type NLMSG_ERROR, but with an errno payload of zero. The problem with two methods is that they would most likely be very similar, so perhaps it would be better to just document this behavior in the method's documentation block.

This whole netlink code is really ugly as it was imported from somewhere else and we should eventually refactor it.

Copy link
Member Author

Choose a reason for hiding this comment

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

an ACK is actually a message of type NLMSG_ERROR, but with an errno payload of zero.

Correct.

better to just document this behavior in the method's documentation block.

Will do.

@RalfJung
Copy link
Member Author

I rebased and added documentation to recv.

@RalfJung
Copy link
Member Author

Rebased.

@kostko kostko merged commit 882af3b into wlanslovenija:master Oct 31, 2017
@RalfJung RalfJung deleted the netlink branch November 1, 2017 12:33
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.

None yet

2 participants