lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Bridge Port with DHCP


From: Shaofeng Cen
Subject: Re: [lwip-users] Bridge Port with DHCP
Date: Mon, 13 Dec 2021 19:29:20 +0800

> Please help me to understand why that is a problem.
After I call port_netif->input, the tcpip_thread will call bridgeif_input,
Assuming that the dst->addr[0] &1 == 0.
Here is a part of code in bridgeif_input func, when dst->addr[0] & 1 == 0.

    /* is this for one of the local ports? */
    if (bridgeif_is_local_mac(br, dst)) {
      /* yes, send to cpu port only */
      LWIP_DEBUGF(BRIDGEIF_FW_DEBUG, ("br -> input(%p)\n", (void *)p));
      return br->netif->input(p, br->netif);
    }

    /* get dst port */
    dstports = bridgeif_find_dst_ports(br, dst);
    bridgeif_send_to_ports(br, p, dstports);
    /* no need to send to cpu, flooding is for external ports only */
    /* by  this, we consumed the pbuf */
    pbuf_free(p);
    /* always return ERR_OK here to prevent the caller freeing the pbuf */
    return ERR_OK;

If netif here is a tapif, and br->netif is a bridge_netif.
Before I use it, I call bridgeif_add_port and bridgeif_fdb_add to add port and fdb to the bridge. (I must call these two functions here, because fdb can filter the MAC address and func bridgeif_send_to_ports searchs corresponding port to forward the frame.)
So the func bridgeif_is_local_mac will return 1, func br->netif->input which is tcpip_input will be called, and the func will return.
But I want the network frame pass to bridgeif_send_to_ports, so portif->linkoutput will be called, and the frame will be written to the file descriptor in tap device.
I don’t know if you can understand what I said. My English is not so good.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]