ICMP or ICMPv6 Raw packets sent from application to host interface not going in rx path
by shivanagouda.rm from LinuxQuestions.org on (#5KF3D)
ICMP or ICMPv6 Raw packets sent from application to host interface not going in rx path
ARP or ICMPv6 packets sent from application to host interface eth0 packets processed by a Linux IP stack,
-- Packets are not landing on rx path of eth0 interface. This means rx counter on eth0 interface are not getting incremented. But could see retransmitting of packets happening on eth0 interface.
-- Basically I am trying get the DHCPv6 IP for an interface through the application.
Any one faced this kind of an issue? Is IP stack is not accepting rx packets and what is the reason for it.
Code snippet:
-------------
if ((raw_sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
printf( "Failed to open raw socket");
return -1;
}
strncpy(if_mac.ifr_name, "eth0", MAX_IFACE_LEN);
if (ioctl(inband_raw_sockfd, SIOCGIFHWADDR, &if_mac) < 0)
{
printf( "SIOCGIFHWADDR error");
}
strncpy(if_idx.ifr_name, "eth0", MAX_IFACE_LEN);
if (ioctl(inband_raw_sockfd, SIOCGIFINDEX, &if_idx) < 0) {
printf( "SIOCGIFINDEX error");
return;
}
socket_address.sll_ifindex = if_idx.ifr_ifindex;
socket_address.sll_halen = ETH_ALEN;
/* buff contains the data/packet received*/
if (sendto(inband_raw_sockfd, buff, (len - VLAN_HDR_LEN), 0, (struct sockaddr*)&socket_address, sizeof(socket_address)) < 0){
printf( "Send to interface failed errno : %d", errno);
}
ARP or ICMPv6 packets sent from application to host interface eth0 packets processed by a Linux IP stack,
-- Packets are not landing on rx path of eth0 interface. This means rx counter on eth0 interface are not getting incremented. But could see retransmitting of packets happening on eth0 interface.
-- Basically I am trying get the DHCPv6 IP for an interface through the application.
Any one faced this kind of an issue? Is IP stack is not accepting rx packets and what is the reason for it.
Code snippet:
-------------
if ((raw_sockfd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW)) == -1) {
printf( "Failed to open raw socket");
return -1;
}
strncpy(if_mac.ifr_name, "eth0", MAX_IFACE_LEN);
if (ioctl(inband_raw_sockfd, SIOCGIFHWADDR, &if_mac) < 0)
{
printf( "SIOCGIFHWADDR error");
}
strncpy(if_idx.ifr_name, "eth0", MAX_IFACE_LEN);
if (ioctl(inband_raw_sockfd, SIOCGIFINDEX, &if_idx) < 0) {
printf( "SIOCGIFINDEX error");
return;
}
socket_address.sll_ifindex = if_idx.ifr_ifindex;
socket_address.sll_halen = ETH_ALEN;
/* buff contains the data/packet received*/
if (sendto(inband_raw_sockfd, buff, (len - VLAN_HDR_LEN), 0, (struct sockaddr*)&socket_address, sizeof(socket_address)) < 0){
printf( "Send to interface failed errno : %d", errno);
}