Ideally I would expect that if the sent packet has tag for vlan 10, it should be received on socket created on eth1.10 and if the the sent packet has tag for vlan 20, it should be received on socket created on eth1.20.
But the packets sent with vlan tag 10 & 20 are received on both sockets. Why I am receiving 4 packets while only 2 packets were sent and also all received packets are untagged (without vlan tag)? What might be the issue?
here is the relevant code: Create: sock = socket(AF_PACKET, SOCK_RAW, htons(MY_ETHTYPE));
memset(&if_opts, 0, sizeof(if_opts));
strncpy(if_opts.ifr_name, "eth1.10", IFNAMSIZ - 1);
setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, (void *)&if_opts, sizeof(if_opts);
ioctl(sock, SIOCGIFFLAGS, &if_opts);
if_opts.ifr_flags |= IFF_PROMISC;
ioctl(sock, SIOCSIFFLAGS, &if_opts);
setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE,
"eth1.10",
sizeof("eth1.10"));
Recv: size = recvfrom(sock, buf, BUF_SIZE, MSG_DONTWAIT, NULL, NULL);