From f7627929d5d69e13d4f80c1713b3f83db1ccf862 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 22 Nov 2010 19:55:05 +0000 Subject: [PATCH] Fixed bug #31722: IP packets sent with an AutoIP source addr must be sent link-local --- CHANGELOG | 4 ++++ src/netif/etharp.c | 27 +++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1327c1f9..7f0a945b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -233,6 +233,10 @@ HISTORY ++ Bugfixes: + 2010-11-20: Simon Goldschmidt + * etharp.c: Fixed bug #31722: IP packets sent with an AutoIP source addr + must be sent link-local + 2010-11-20: Simon Goldschmidt * timers.c: patch #7329: tcp_timer_needed prototype was ifdef'ed out for LWIP_TIMERS==0 diff --git a/src/netif/etharp.c b/src/netif/etharp.c index edd9958f..2857ee69 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -871,14 +871,25 @@ etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) /* outside local network? */ if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask)) && !ip_addr_islinklocal(ipaddr)) { - /* interface has default gateway? */ - if (!ip_addr_isany(&netif->gw)) { - /* send to hardware address of default gateway IP address */ - ipaddr = &(netif->gw); - /* no default gateway available */ - } else { - /* no route to destination error (default gateway missing) */ - return ERR_RTE; +#if LWIP_AUTOIP + struct ip_hdr *iphdr = (struct ip_hdr*)((u8_t*)q->payload + + sizeof(struct eth_hdr)); + /* According to RFC 3297, chapter 2.6.2 (Forwarding Rules), a packet with + a link-local source address must always be "directly to its destination + on the same physical link. The host MUST NOT send the packet to any + router for forwarding". */ + if (!ip_addr_islinklocal(&iphdr->src)) +#endif /* LWIP_AUTOIP */ + { + /* interface has default gateway? */ + if (!ip_addr_isany(&netif->gw)) { + /* send to hardware address of default gateway IP address */ + ipaddr = &(netif->gw); + /* no default gateway available */ + } else { + /* no route to destination error (default gateway missing) */ + return ERR_RTE; + } } } #if LWIP_NETIF_HWADDRHINT