On 2020/2/11 上午5:45, Vikram Garhwal wrote:
+                }
+            } else {
+                /* Normal mode Tx. */
+                generate_frame(&frame, data);
+
+                can_bus_client_send(&s->bus_client, &frame, 1);
I had a quick glance at can_bus_client_send():

It did:

      QTAILQ_FOREACH(peer, &bus->clients, next) {
          if (peer->info->can_receive(peer)) {
              if (peer == client) {
                  /* No loopback support for now */
                  continue;
              }
              if (peer->info->receive(peer, frames, frames_cnt) > 0) {
                  ret = 1;
              }
          }
      }

which looks not correct. We need to use qemu_send_packet() instead of
calling peer->info->receive() directly which bypasses filters completely.
[Vikram Garhwal] Can you please elaborate it bit more on why do we need to 
filter outgoing message? So, I can either add a filter before sending the 
packets. I am unable to understand the use case for it. For any message which 
is incoming, we are filtering it for sure before storing in update_rx_fifo().


I might be not clear, I meant the netfilters supported by qemu which allows you to attach a filter to a specific NetClientState, see qemu_send_packet_async_with_flags. It doesn't mean the filter implemented in your own NIC model.

Thanks


Also, I can see existing CAN models like CAN sja1000 and CAN Kavser are using it 
same can_bus_client_send() function. However, this doesn't mean that it is the 
correct way to send & receive packets.


Reply via email to