mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
drivers/net/tun.c: Fixes a problem reported by Masayuki Ishikwawa: Recently I noticed that ARP response packet is corrupted when I tried to run bluekitchen with the latest tun.c in TAP mode. If I revert commit 8193c28e91, then it works again.
This commit is contained in:
+62
-27
@@ -619,6 +619,33 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
|||||||
|
|
||||||
arp_ipin(&priv->dev);
|
arp_ipin(&priv->dev);
|
||||||
ipv4_input(&priv->dev);
|
ipv4_input(&priv->dev);
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that should be
|
||||||
|
* sent out on the network, the field d_len will set to a value > 0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (priv->dev.d_len > 0)
|
||||||
|
{
|
||||||
|
/* Update the Ethernet header with the correct MAC address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
if (IFF_IS_IPv4(priv->dev.d_flags))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
arp_out(&priv->dev);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
neighbor_out(&priv->dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* And send the packet */
|
||||||
|
|
||||||
|
priv->write_d_len = priv->dev.d_len;
|
||||||
|
tun_fd_transmit(priv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -631,6 +658,31 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
|||||||
/* Give the IPv6 packet to the network layer. */
|
/* Give the IPv6 packet to the network layer. */
|
||||||
|
|
||||||
ipv6_input(&priv->dev);
|
ipv6_input(&priv->dev);
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that should be
|
||||||
|
* sent out on the network, the field d_len will set to a value > 0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (priv->dev.d_len > 0)
|
||||||
|
{
|
||||||
|
/* Update the Ethernet header with the correct MAC address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
if (IFF_IS_IPv4(priv->dev.d_flags))
|
||||||
|
{
|
||||||
|
arp_out(&priv->dev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
{
|
||||||
|
neighbor_out(&priv->dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
priv->write_d_len = priv->dev.d_len;
|
||||||
|
tun_fd_transmit(priv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -639,40 +691,23 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
|||||||
{
|
{
|
||||||
arp_arpin(&priv->dev);
|
arp_arpin(&priv->dev);
|
||||||
NETDEV_RXARP(&priv->dev);
|
NETDEV_RXARP(&priv->dev);
|
||||||
|
|
||||||
|
/* If the above function invocation resulted in data that should be
|
||||||
|
* sent out on the network, the field d_len will set to a value > 0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (priv->dev.d_len > 0)
|
||||||
|
{
|
||||||
|
priv->write_d_len = priv->dev.d_len;
|
||||||
|
tun_fd_transmit(priv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NETDEV_RXDROPPED(&priv->dev);
|
NETDEV_RXDROPPED(&priv->dev);
|
||||||
priv->dev.d_len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the above function invocation resulted in data that should be
|
|
||||||
* sent out on the network, the field d_len will set to a value > 0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (priv->dev.d_len > 0)
|
|
||||||
{
|
|
||||||
/* Update the Ethernet header with the correct MAC address */
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
|
||||||
if (IFF_IS_IPv4(priv->dev.d_flags))
|
|
||||||
{
|
|
||||||
arp_out(&priv->dev);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
if (IFF_IS_IPv6(priv->dev.d_flags))
|
|
||||||
{
|
|
||||||
neighbor_out(&priv->dev);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* And send the packet */
|
|
||||||
|
|
||||||
priv->write_d_len = priv->dev.d_len;
|
|
||||||
tun_fd_transmit(priv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user