0

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);

bobby
  • 1
  • I've never tried anything like this, but does [this](https://www.kanadas.com/program-e/2012/05/a_test_program_for_sendingrece.html) help? :) – tink Aug 18 '21 at 02:24
  • I really appreciate your response. But it is a different scenario and it didn't help. Let me know if you have any other pointers. – bobby Aug 19 '21 at 22:26

0 Answers0