0

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

7
  • You have not given any info on the version of Ubuntu. How are you sending these packets what exact commands.
    – David
    Aug 25, 2021 at 5:57
  • To find the version, I used the command uname -srm. Here is the dump:
    – bobby
    Aug 25, 2021 at 17:50
  • To find the version, I used the command uname -srm. Here is the dump: Linux 4.19.0-xilinx-v2019.1 aarch64. Now for packet send: A socket is created using sock = socket(AF_PACKET, SOCK_RAW, htons(MY_ETHTYPE)); packet is sent with dmac 0xffff.ffff.ffff and smac is local interface mac. Packet is tagged with 0x8100000a or 0x81000014, ethertype as MY_ETHTYPE followed by payload. Packet is sent using call sendto(xmtSock, buf, bufSize, 0, (struct sockaddr *)sa_raw, sizeof(sa_raw)); sa_raw has sll_ifindex, sll_halen & sll_addr fields filed in.
    – bobby
    Aug 25, 2021 at 18:05
  • There is no version info in that. A version would be like Ubuntu 18.04
    – David
    Aug 26, 2021 at 5:24
  • Hi David, Which command I could use to find the version number?
    – bobby
    Aug 26, 2021 at 22:01

0

You must log in to answer this question.

Browse other questions tagged .