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
WireGuard examples not working any longer #888
Comments
Edit: this was probably not the issue. Setting |
Yep, thanks. To be fixed asap. |
Nope, it makes sense. Pretty much. This particular NLA size is fixed and now differs from what the kernel expects, and that's the cause. Now let's see how can we fix that keeping compatibility as much as we can. |
Wireguard in kernel check family and size of data if (attrs[WGPEER_A_ENDPOINT]) {
struct sockaddr *addr = nla_data(attrs[WGPEER_A_ENDPOINT]);
size_t len = nla_len(attrs[WGPEER_A_ENDPOINT]);
if ((len == sizeof(struct sockaddr_in) &&
addr->sa_family == AF_INET) ||
(len == sizeof(struct sockaddr_in6) &&
addr->sa_family == AF_INET6)) {
struct endpoint endpoint = { { { 0 } } };
memcpy(&endpoint.addr, addr, len);
wg_socket_set_peer_endpoint(peer, &endpoint);
}
} https://github.com/torvalds/linux/blob/master/drivers/net/wireguard/netlink.c And struct sockaddr_in has got char sin_zero[8];, that's why setting addr6 to 8s in fields restores the correct behaviour I think. We may put addr6 to s and set it's size, same for scope_id class parse_endpoint(nla):
fields = (
('family', 'H'),
('port', '>H'),
('addr4', '4s'),
('addr6', 's'),
('scope_id', 's'),
)
def decode(self):
nla.decode(self)
if self['family'] == AF_INET:
self['addr'] = inet_ntop(AF_INET, self['addr4'])
else:
self['addr'] = inet_ntop(AF_INET6, self['addr6'])
del self['addr4']
del self['addr6']
def encode(self):
if self['addr'].find(":") > -1:
self['family'] = AF_INET6
self['addr4'] = b'\x00\x00\x00\x00'
self['addr6'] = inet_pton(AF_INET6, self['addr'])
self['scope_id'] = b'\x00\x00\x00\x00'
else:
self['family'] = AF_INET
self['addr4'] = inet_pton(AF_INET, self['addr'])
self['addr6'] = b'\x00\x00\x00\x00\x00\x00\x00\x00' # sin_zero[8]
self['scope_id'] = b''
self['port'] = int(self['port'])
nla.encode(self) I can't test now but it should work on ip4&6. |
Yep, just found that code in the kernel. Fixing the library. |
Fixed, tonight comes the update. |
Should work. If not — pls let me know. Tests will follow. |
Tests added. |
Seems to work again in our use case 👍 |
Great. The next release will be tagged on Saturday. |
Hi,
probably due to #882 the examples for WireGuard interfaces are no longer working.
If I try to:
With version 0.6.8
wg
outputsWith version 0.6.7 it outputs correctly
There is no error message or something. In another software, we get with version 0.6.8 the following messages:
unsupported event ignored: <class 'pr2modules.netlink.nlmsg'>
as well as
exception <(22, 'Invalid argument')> in source localhost
/cc @inemajo
The text was updated successfully, but these errors were encountered: