From patchwork Tue May 19 09:06:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sascha Hlusiak X-Patchwork-Id: 27391 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id D0F7BB6F35 for ; Tue, 19 May 2009 19:05:17 +1000 (EST) Received: by ozlabs.org (Postfix) id BF40CDE0B6; Tue, 19 May 2009 19:05:17 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id F0A27DE0B0 for ; Tue, 19 May 2009 19:05:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbZESJFK (ORCPT ); Tue, 19 May 2009 05:05:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752265AbZESJFJ (ORCPT ); Tue, 19 May 2009 05:05:09 -0400 Received: from moutng.kundenserver.de ([212.227.126.188]:57947 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbZESJFI (ORCPT ); Tue, 19 May 2009 05:05:08 -0400 Received: from sascha.localnet (g226199194.adsl.alicedsl.de [92.226.199.194]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MKuxg-1M6LFp1ymz-0001AY; Tue, 19 May 2009 11:05:00 +0200 From: Sascha Hlusiak To: David Miller Subject: Re: [PATCH 1/5] sit: Fail to create tunnel, if it already exists Date: Tue, 19 May 2009 11:06:14 +0200 User-Agent: KMail/1.11.3 (Linux/2.6.29-gentoo-r4; KDE/4.2.3; i686; ; ) Cc: netdev@vger.kernel.org References: <1242396760-30568-1-git-send-email-contact@saschahlusiak.de> <20090518.154806.174728278.davem@davemloft.net> <20090518.193145.257080801.davem@davemloft.net> In-Reply-To: <20090518.193145.257080801.davem@davemloft.net> MIME-Version: 1.0 Message-Id: <200905191106.15044.contact@saschahlusiak.de> X-Provags-ID: V01U2FsdGVkX1/M2zyQRiXdwV34JbBQPNsbmjXCzAN+eixHlnU XvhM6YRE7H4tKRUgi9Sg+448DbclcW/jjOv3n18ClqLmnNh4PY kp3Jp1iDmQ9qgbBHywlhDrjFq06sXMC Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Am Dienstag 19 Mai 2009 04:31:45 schrieb David Miller: > From: David Miller > Date: Mon, 18 May 2009 15:48:06 -0700 (PDT) > > > All 5 patches applied to net-next-2.6, thanks. > > Actually, no, I reverted all of this garbage. > > Let me know when you have a version of your changes that > actually compile. > > CC [M] net/ipv6/sit.o > net/ipv6/sit.c: In function ‘ipip6_tunnel_rs_timer’: > net/ipv6/sit.c:235: error: incompatible type for argument 1 of ‘_spin_lock’ > net/ipv6/sit.c:256: error: invalid type argument of ‘->’ Thanks, fixed the offending patch. Compiled for me though so apology for the inconvenience. From 710a2df59c785c93d92a6f85fc0a5b3cc79c2f97 Mon Sep 17 00:00:00 2001 From: Sascha Hlusiak Date: Tue, 19 May 2009 11:00:27 +0200 Subject: [PATCH 5/5] sit: stateless autoconf for isatap From each potential router in the PRL, a router solicitation will be sent periodically. The rs_delay can be speficied when adding the PRL entry and defaults to 15 minutes. The RS is sent from every link local adress that's assigned to the tunnel interface. It's directed to the (guessed) linklocal address of the router and is sent through the tunnel. Better: send to ff02::2 encapsuled in unicast directed to router-v4. Signed-off-by: Sascha Hlusiak --- include/linux/if_tunnel.h | 2 +- include/net/ipip.h | 7 +++++ net/ipv6/ndisc.c | 1 + net/ipv6/sit.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletions(-) diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h index 5a9aae4..5eb9b0f 100644 --- a/include/linux/if_tunnel.h +++ b/include/linux/if_tunnel.h @@ -44,7 +44,7 @@ struct ip_tunnel_prl { __u16 flags; __u16 __reserved; __u32 datalen; - __u32 __reserved2; + __u32 rs_delay; /* data follows */ }; diff --git a/include/net/ipip.h b/include/net/ipip.h index fdf9bd7..5d3036f 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h @@ -28,11 +28,18 @@ struct ip_tunnel unsigned int prl_count; /* # of entries in PRL */ }; +/* ISATAP: default interval between RS in secondy */ +#define IPTUNNEL_RS_DEFAULT_DELAY (900) + struct ip_tunnel_prl_entry { struct ip_tunnel_prl_entry *next; __be32 addr; u16 flags; + unsigned long rs_delay; + struct timer_list rs_timer; + struct ip_tunnel *tunnel; + spinlock_t lock; }; #define IPTUNNEL_XMIT() do { \ diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 9f061d1..f787ac4 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -658,6 +658,7 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr, &icmp6h, NULL, send_sllao ? ND_OPT_SOURCE_LL_ADDR : 0); } +EXPORT_SYMBOL(ndisc_send_rs); static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 3fd0600..0535809 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -15,6 +15,7 @@ * Roger Venning : 6to4 support * Nate Thompson : 6to4 support * Fred Templin : isatap support + * Sascha Hlusiak : stateless autoconf for isatap */ #include @@ -222,6 +223,44 @@ failed: return NULL; } +static void ipip6_tunnel_rs_timer(unsigned long data) +{ + struct ip_tunnel_prl_entry *p = (struct ip_tunnel_prl_entry *) data; + struct inet6_dev *ifp; + struct inet6_ifaddr *addr; + + spin_lock(&p->lock); + ifp = __in6_dev_get(p->tunnel->dev); + + spin_lock(&ifp->lock); + for (addr = ifp->addr_list; addr; addr = addr->if_next) { + struct in6_addr rtr; + + if (!(ipv6_addr_type(&addr->addr) & IPV6_ADDR_LINKLOCAL)) + continue; + + /* Send RS to guessed linklocal address of router + * + * Better: send to ff02::2 encapsuled in unicast directly + * to router-v4 instead of guessing the v6 address. + * + * Cisco/Windows seem to not set the u/l bit correctly, + * so we won't guess right. + */ + ipv6_addr_set(&rtr, htonl(0xFE800000), 0, 0, 0); + if (!__ipv6_isatap_ifid(rtr.s6_addr + 8, + p->addr)) { + ndisc_send_rs(p->tunnel->dev, &addr->addr, &rtr); + } + } + spin_unlock(&ifp->lock); + + mod_timer(&p->rs_timer, jiffies + HZ * p->rs_delay); + spin_unlock(&p->lock); + + return; +} + static struct ip_tunnel_prl_entry * __ipip6_tunnel_locate_prl(struct ip_tunnel *t, __be32 addr) { @@ -280,6 +319,7 @@ static int ipip6_tunnel_get_prl(struct ip_tunnel *t, continue; kp[c].addr = prl->addr; kp[c].flags = prl->flags; + kp[c].rs_delay = prl->rs_delay; c++; if (kprl.addr != htonl(INADDR_ANY)) break; @@ -329,11 +369,23 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg) } p->next = t->prl; + p->tunnel = t; t->prl = p; t->prl_count++; + + spin_lock_init(&p->lock); + setup_timer(&p->rs_timer, ipip6_tunnel_rs_timer, (unsigned long) p); update: p->addr = a->addr; p->flags = a->flags; + p->rs_delay = a->rs_delay; + if (p->rs_delay == 0) + p->rs_delay = IPTUNNEL_RS_DEFAULT_DELAY; + spin_lock(&p->lock); + del_timer(&p->rs_timer); + if (p->flags & PRL_DEFAULT) + mod_timer(&p->rs_timer, jiffies + 1); + spin_unlock(&p->lock); out: write_unlock(&ipip6_lock); return err; @@ -352,6 +404,9 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) if ((*p)->addr == a->addr) { x = *p; *p = x->next; + spin_lock(&x->lock); + del_timer(&x->rs_timer); + spin_unlock(&x->lock); kfree(x); t->prl_count--; goto out; @@ -362,6 +417,9 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) while (t->prl) { x = t->prl; t->prl = t->prl->next; + spin_lock(&x->lock); + del_timer(&x->rs_timer); + spin_unlock(&x->lock); kfree(x); t->prl_count--; } -- 1.6.3