From 2a2be49d2c1dd84ca2b96e05b07a59a793c5e7c5 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 8 Mar 2010 18:17:52 +0000 Subject: [PATCH] task #10241 (AutoIP: don't break existing connections when assiging routable address): when checking incoming packets and aborting existing connection on address change, filter out link-local addresses. --- CHANGELOG | 6 ++++++ src/core/ipv4/ip.c | 8 +++++++- src/core/netif.c | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0a9dbcbc..8dd390d3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -158,6 +158,12 @@ HISTORY ++ Bugfixes: + 2010-03-08: Simon Goldschmidt + * netif.c, ipv4/ip.c: task #10241 (AutoIP: don't break existing connections + when assiging routable address): when checking incoming packets and + aborting existing connection on address change, filter out link-local + addresses. + 2010-03-06: Simon Goldschmidt * sockets.c: Fixed LWIP_NETIF_TX_SINGLE_PBUF for LWIP_TCPIP_CORE_LOCKING diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 57c8f552..e92c5431 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -296,7 +296,13 @@ ip_input(struct pbuf *p, struct netif *inp) /* unicast to this interface address? */ if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) || /* or broadcast on this interface network address? */ - ip_addr_isbroadcast(&(iphdr->dest), netif)) { + ip_addr_isbroadcast(&(iphdr->dest), netif) +#if LWIP_AUTOIP + /* connections to link-local addresses must persist after changing + the netif's address (RFC3927 ch. 1.9) */ + || ip_addr_islinklocal(&(iphdr->dest)) +#endif /* LWIP_AUTOIP */ + ) { LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n", netif->name[0], netif->name[1])); /* break out of for loop */ diff --git a/src/core/netif.c b/src/core/netif.c index b5be77c6..0036842b 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -331,7 +331,12 @@ netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr) pcb = tcp_active_pcbs; while (pcb != NULL) { /* PCB bound to current local interface address? */ - if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) { + if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr)) +#if LWIP_AUTOIP + /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ + && !ip_addr_islinklocal(&(pcb->local_ip)) +#endif /* LWIP_AUTOIP */ + ) { /* this connection must be aborted */ struct tcp_pcb *next = pcb->next; LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb));