net: Check if sent packet is meant for us

If the destination IP address is one of our own address,
then reroute it back to us.

Jira: ZEP-1966

Change-Id: I8b93fc5425f3f18b0b9e85ca9a57cb122129c47f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-03-27 16:50:10 +03:00
commit d593914b17

View file

@ -621,7 +621,11 @@ static inline int check_ip_addr(struct net_buf *buf)
return -EADDRNOTAVAIL;
}
if (net_is_ipv6_addr_loopback(&NET_IPV6_BUF(buf)->dst)) {
/* If the destination address is our own, then route it
* back to us.
*/
if (net_is_ipv6_addr_loopback(&NET_IPV6_BUF(buf)->dst) ||
net_is_my_ipv6_addr(&NET_IPV6_BUF(buf)->dst)) {
struct in6_addr addr;
/* Swap the addresses so that in receiving side
@ -652,7 +656,11 @@ static inline int check_ip_addr(struct net_buf *buf)
return -EADDRNOTAVAIL;
}
if (net_is_ipv4_addr_loopback(&NET_IPV4_BUF(buf)->dst)) {
/* If the destination address is our own, then route it
* back to us.
*/
if (net_is_ipv4_addr_loopback(&NET_IPV4_BUF(buf)->dst) ||
net_is_my_ipv4_addr(&NET_IPV4_BUF(buf)->dst)) {
struct in_addr addr;
/* Swap the addresses so that in receiving side