summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-21 17:44:12 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-21 17:44:12 -0600
commit2cd4aa56287b47f0a5c15d2630ae25c0c6d13c2e (patch)
treef72d1dbc8cfc8c36f42fbde49889c90e6ce9aca6
parent5b6a95d7ee9637c03970a15abcadc06738a48a9e (diff)
downloadnuttx-2cd4aa56287b47f0a5c15d2630ae25c0c6d13c2e.tar.gz
nuttx-2cd4aa56287b47f0a5c15d2630ae25c0c6d13c2e.tar.bz2
nuttx-2cd4aa56287b47f0a5c15d2630ae25c0c6d13c2e.zip
Fix routing of muli-network UDP packets
-rw-r--r--apps/examples/bridge/bridge_main.c3
-rw-r--r--nuttx/net/udp/udp_conn.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/apps/examples/bridge/bridge_main.c b/apps/examples/bridge/bridge_main.c
index 78ee23a60..cd2563ad4 100644
--- a/apps/examples/bridge/bridge_main.c
+++ b/apps/examples/bridge/bridge_main.c
@@ -635,8 +635,7 @@ static int bridge_net2_worker(int argc, char *argv[])
/* Send the newly received packet out network 1 */
- printf("NET2: Sending %d bytes on network 1\n", nrecvd);
- printf("NET1: Sending %d bytes on network 1: %d.%d.%d.%d:%d\n",
+ printf("NET2: Sending %d bytes on network 1: %d.%d.%d.%d:%d\n",
nrecvd,
CONFIG_EXAMPLES_BRIDGE_NET1_IPHOST >> 24,
(CONFIG_EXAMPLES_BRIDGE_NET1_IPHOST >> 16) & 0xff,
diff --git a/nuttx/net/udp/udp_conn.c b/nuttx/net/udp/udp_conn.c
index e45abc540..42c4cf6c1 100644
--- a/nuttx/net/udp/udp_conn.c
+++ b/nuttx/net/udp/udp_conn.c
@@ -350,6 +350,10 @@ FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf)
* number in the received packet.
* - The remote port number is checked if the connection is bound
* to a remote port.
+ * - If multiple network interfaces are supported, then the local
+ * IP address is available and we will insist that the
+ * destination IP matches the bound address (or the destination
+ * IP address is a broadcase address).
* - Finally, if the connection is bound to a remote IP address,
* the source IP address of the packet is checked. Broadcast
* addresses are also accepted.
@@ -360,6 +364,10 @@ FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf)
if (conn->lport != 0 && buf->destport == conn->lport &&
(conn->rport == 0 || buf->srcport == conn->rport) &&
+#ifdef CONFIG_NETDEV_MULTINIC
+ (net_ipaddr_hdrcmp(buf->destipaddr, &g_alloneaddr) ||
+ net_ipaddr_hdrcmp(buf->destipaddr, &conn->lipaddr)) &&
+#endif
(net_ipaddr_cmp(conn->ripaddr, g_allzeroaddr) ||
net_ipaddr_cmp(conn->ripaddr, g_alloneaddr) ||
net_ipaddr_hdrcmp(buf->srcipaddr, &conn->ripaddr)))