Score:0

2 sent pkts have tag for vlan 10 & 20, one should be received on socket created on eth1.10 and another on socket for eth1.20. But it doesn't happen

cn flag

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

David avatar
cn flag
You have not given any info on the version of Ubuntu. How are you sending these packets what exact commands.
bobby avatar
cn flag
To find the version, I used the command uname -srm. Here is the dump:
bobby avatar
cn flag
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.
David avatar
cn flag
There is no version info in that. A version would be like Ubuntu 18.04
bobby avatar
cn flag
Hi David, Which command I could use to find the version number?
David avatar
cn flag
Open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon. Use the lsb_release -a command to display the Ubuntu version. Your Ubuntu version will be shown in the Description line. BTW a quick search on google could have given you this info.
bobby avatar
cn flag
lsb_release was not being supported. I found /etc/os-release after googling. Here is the dump: ID ="petalinux" Version="2019.1 (thud)". I guess it means it is not ubuntu. But still if you could point me to changes that might be needed to make the similar code to work on ubuntu, I will really appreciate. thanks
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.