Skip to content
Snippets Groups Projects
Commit 6ffe5a28 authored by Adam Wujek's avatar Adam Wujek
Browse files

userspace/tools/radiusvlan: fix receiving frames from other interfaces


Before the fix in some rare cases, radiusvlan could report a receive
of frames from another interface. This could lead to a wrong
authentication of a device connected to a port.

The problem is caused by a behaviour that if a socket is created it
listens on all interfaces until the bind function is called. It might
happen that later calls of recvfrom function will handle frames
received from other interfaces. To prevent that, radiusvlan flushes
all frames received before socket is bound to an interface.
The lost of frames is meaningless since all frames that radiusvlan
listens for are sent periodically.

Signed-off-by: default avatarAdam Wujek <dev_public@wujek.eu>
parent 7f67f414
Branches
Tags
No related merge requests found
......@@ -225,7 +225,7 @@ int rvlan_fsm(struct rvlan_dev *dev, fd_set *rdset)
req.mr_type = PACKET_MR_PROMISC;
if (setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&req, sizeof(req)) < 0) {
fprintf(stderr, "%s: can't make %s promoscuous: %s\n",
fprintf(stderr, "%s: can't make %s promiscuous: %s\n",
prgname, dev->name, strerror(errno));
close(sock);
return -1;
......@@ -253,6 +253,10 @@ int rvlan_fsm(struct rvlan_dev *dev, fd_set *rdset)
}
memcpy(dev->mac, &ifr.ifr_ifru.ifru_hwaddr.sa_data, ETH_ALEN);
/* Flush all already received frames */
while (recvfrom(sock, frame, sizeof(frame), MSG_TRUNC | MSG_DONTWAIT, (struct sockaddr *)&from, &fromlen) > 0) {
}
dev->poll_fd = sock;
dev->fsm_state = RVLAN_SNIFF;
break;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment