1

Hi I have an embedded device which is 2 different port. One is communicate with raw socket another device. Other port is using TCP/IP packet type. When I plug these two ports into the switch which is same vlan it cause a network problem. My device can not connect TCP/IP socket for a while(~ 15second) Also my Raw Socket couldn't communicate with other raw socket device(Other device raw socket also plug same switch). There is shown below WireShark log wireshark pcap tcp packet drop

But if I managed the switch different Vlan's. I mean configure Tcp ports different and raw ports different Vlan. Then problem is solved.

Here is my raw socket source code;

int createRawSocket( char* sznetwork_interface_name ) { int i,ioctl_sock,ifindex, raw_sock=0;

ioctl_sock = socket ( AF_INET, SOCK_DGRAM, 0 );
if ( ioctl_sock < 0 )
{
  printf("\nFailed to create ioctl_sock socket\n");
 return -1;
}

/*Create raw socket*/
raw_sock = socket ( AF_PACKET, SOCK_RAW, htons ( ETH_P_ALL ));
if ( raw_sock < 0 )
{
      printf("\nFailed to create raw_sock socket\n");
      return -1;
}
strncpy ( abc_config.ifr.ifr_name, sznetwork_interface_name, sizeof (abc_config.ifr.ifr_name ));

/*Get the interface index*/
if ( ioctl ( ioctl_sock, SIOCGIFINDEX, &abc_config.ifr ) != 0 )
{
      printf ("\nFailed to call ioctl 3\n");
      return -1;
}
ifindex = abc_config.ifr.ifr_ifindex;
printf("Successfully got RAW interface index: %i\n\r", ifindex);

/*
 * prepare sockaddr_ll
 */
abc_config.socket_address.sll_family =  AF_PACKET;
abc_config.socket_address.sll_ifindex  = abc_config.ifr.ifr_ifindex;

 /*Bind to the raw socket*/
if( bind(raw_sock, (struct sockaddr *)&abc_config.socket_address, sizeof(abc_config.socket_address)) < 0 )
{
      printf("\nFailed to bind \n");
   return -1;
}

/*
 * retrieve corresponding MAC
 */
if (ioctl(raw_sock, SIOCGIFHWADDR, &abc_config.ifr) == -1) {
    perror("SIOCGIFINDEX");
    close(raw_sock);
    return ERROR;
}
abc_config.abc_raw_socket = raw_sock;
abc_config.abc_raw_state = RAW_READY;
return raw_sock;}

First I was consider htons ( ETH_P_ALL ) cause all incoming packet allowing. This is causing the traffic to increase and I thought the connection cannot be established Then I changed the socket initializing with the raw_sock = socket ( AF_PACKET, SOCK_RAW, IPPROTO_RAW); this time any kind of packet wasn't received. My etherytpe of raw packet for transmit : 0xcd03 and receive: 0xdd04.

By the way embedded device has a Marvell 88E6097, 8 FE + 3 GE Stackable Ethernet Switch with QoS and 802.1Q inside the circuit. Raw and TCP socket connected this swicth.

What can be the problem ?

Thank's a lot.

Caglarr
  • 31
  • 5
  • Do your ports have different MAC addresses? – user253751 Aug 28 '20 at 10:50
  • Yes ofc. All ports have different MAC addresses. – Caglarr Aug 31 '20 at 06:05
  • Does your device send traffic that it receives on one port through the other port? i.e. does it act like a switch? – user253751 Aug 31 '20 at 09:39
  • Hi, device has a Marvell switch. Marvell doesn't allow frame or packet forwarding one port to another. I guess problem occur due to broadcast packets in network. Thanks for your help :) – Caglarr Sep 01 '20 at 14:03
  • It has a switch that doesn't allow frame forwarding? That is strange because the purpose of a switch is to forward frames. – user253751 Sep 01 '20 at 14:13
  • Hi again, I mean e.g. one packet arrive your address but after doesn't send anywhere in switch internal ports unless broadcast packets. By the way ofc switchs forward packets one port to another. – Caglarr Sep 15 '20 at 06:17
  • So, to be clear: You have a switch in your device, and another switch outside. And you plugged two ports from one switch into the other switch? That creates a loop which is not allowed in Ethernet. – user253751 Sep 15 '20 at 10:50

1 Answers1

0

I solved the problem via bridge method. Here is the bridge command which is added linux device.

brctl addbr br1 
brctl addif br1 eth3 
ifconfig br1 up
Caglarr
  • 31
  • 5