mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
net/netdev: add devif_loopback_out() to check the loopback case where a packet is being sent to itself. Modify the net driver to call this function in this case. This function will simply re-inject the packet back into the network and the network driver will not put anything on the wire.
This commit is contained in:
+14
-11
@@ -819,19 +819,22 @@ static int dm9x_txpoll(struct net_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Send the packet */
|
||||
|
||||
dm9x_transmit(priv);
|
||||
|
||||
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
|
||||
* that can be 2 packets, otherwise it is a single packet.
|
||||
*/
|
||||
|
||||
if (priv->dm_ntxpending > 1 || !priv->dm_b100M)
|
||||
if (!devif_loopback_out(&priv->dm_dev))
|
||||
{
|
||||
/* Returning a non-zero value will terminate the poll operation */
|
||||
/* Send the packet */
|
||||
|
||||
return 1;
|
||||
dm9x_transmit(priv);
|
||||
|
||||
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
|
||||
* that can be 2 packets, otherwise it is a single packet.
|
||||
*/
|
||||
|
||||
if (priv->dm_ntxpending > 1 || !priv->dm_b100M)
|
||||
{
|
||||
/* Returning a non-zero value will terminate the poll operation */
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1213,13 +1213,16 @@ static int enc_txpoll(struct net_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Send the packet */
|
||||
if (!devif_loopback_out(&priv->dev))
|
||||
{
|
||||
/* Send the packet */
|
||||
|
||||
enc_transmit(priv);
|
||||
enc_transmit(priv);
|
||||
|
||||
/* Stop the poll now because we can queue only one packet */
|
||||
/* Stop the poll now because we can queue only one packet */
|
||||
|
||||
return -EBUSY;
|
||||
return -EBUSY;
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
|
||||
@@ -1194,9 +1194,12 @@ static int enc_txpoll(struct net_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Send the packet */
|
||||
if (!devif_loopback_out(&priv->dev))
|
||||
{
|
||||
/* Send the packet */
|
||||
|
||||
ret = enc_txenqueue(priv);
|
||||
ret = enc_txenqueue(priv);
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
|
||||
@@ -388,13 +388,16 @@ static int ftmac100_txpoll(struct net_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Send the packet */
|
||||
if (!devif_loopback_out(&priv->ft_dev))
|
||||
{
|
||||
/* Send the packet */
|
||||
|
||||
ftmac100_transmit(priv);
|
||||
ftmac100_transmit(priv);
|
||||
|
||||
/* Check if there is room in the device to hold another packet. If not,
|
||||
* return a non-zero value to terminate the poll.
|
||||
*/
|
||||
/* Check if there is room in the device to hold another packet. If not,
|
||||
* return a non-zero value to terminate the poll.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
|
||||
+14
-6
@@ -299,13 +299,21 @@ static int skel_txpoll(FAR struct net_driver_s *dev)
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/* Send the packet */
|
||||
|
||||
skel_transmit(priv);
|
||||
|
||||
/* Check if there is room in the device to hold another packet. If not,
|
||||
* return a non-zero value to terminate the poll.
|
||||
/* Check if the network is sending this packet to the IP address of
|
||||
* this device. If so, just loop the packet back into the network but
|
||||
* don't attmpt to put it on the wire.
|
||||
*/
|
||||
|
||||
if (!devif_loopback_out(&priv->sk_dev))
|
||||
{
|
||||
/* Send the packet */
|
||||
|
||||
skel_transmit(priv);
|
||||
|
||||
/* Check if there is room in the device to hold another packet. If not,
|
||||
* return a non-zero value to terminate the poll.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
|
||||
+4
-1
@@ -405,7 +405,10 @@ static int slip_txpoll(FAR struct net_driver_s *dev)
|
||||
|
||||
if (priv->dev.d_len > 0)
|
||||
{
|
||||
slip_transmit(priv);
|
||||
if (!devif_loopback_out(&priv->dev))
|
||||
{
|
||||
slip_transmit(priv);
|
||||
}
|
||||
}
|
||||
|
||||
/* If zero is returned, the polling will continue until all connections have
|
||||
|
||||
Reference in New Issue
Block a user