From 5e617f8410af1f624043e53ac73739cf876bd582 Mon Sep 17 00:00:00 2001 From: Gregory Nutt <gnutt@nuttx.org> Date: Tue, 4 Jul 2017 12:05:21 -0600 Subject: [PATCH] UDP networking: The TTL (time to live) was not being set in the IPv4 or IPv6 header unless the UDP socket was bound. --- net/devif/ipv6_forward.c | 6 +++++- net/devif/ipv6_input.c | 1 + net/udp/udp_conn.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/net/devif/ipv6_forward.c b/net/devif/ipv6_forward.c index 951ed25f34..eaf868533f 100644 --- a/net/devif/ipv6_forward.c +++ b/net/devif/ipv6_forward.c @@ -106,18 +106,20 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, { /* Otherwise, we will have to drop the packet */ - nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", + nwarn("WARNING: Dropping. Unsupported 6LoWPAN protocol: %d\n", ipv6->proto); #ifdef CONFIG_NET_STATISTICS g_netstats.ipv6.drop++; #endif + return -EPROTONOSUPPORT; } dev->d_len = 0; return OK; } + nwarn("WARNING: Dropping. Unsupported link layer\n"); return -EPFNOSUPPORT; } #else @@ -515,6 +517,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_decr_ttl(ipv6); if (ret < 1) { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); ret = -EMULTIHOP; goto drop; } @@ -548,6 +551,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) ret = ipv6_dev_forward(dev, fwddev, ipv6); if (ret < 0) { + nwarn("WARNING: ipv6_dev_forward faield: %d\n", ret); goto drop; } } diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 8d2a28776c..4d656f3749 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -370,6 +370,7 @@ int ipv6_input(FAR struct net_driver_s *dev) { /* Not destined for us and not forwardable... drop the packet. */ + nwarn("WARNING: Not destined for us; not forwardable... Dropping!\n"); #ifdef CONFIG_NET_STATISTICS g_netstats.ipv6.drop++; #endif diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 077a840566..daa7dce3c1 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -457,6 +457,7 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain) conn->domain = domain; #endif conn->lport = 0; + conn->ttl = IP_TTL; /* Enqueue the connection into the active list */ @@ -760,7 +761,6 @@ int udp_connect(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) #endif /* CONFIG_NET_IPv6 */ } - conn->ttl = IP_TTL; return OK; } -- GitLab