* [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host
@ 2014-05-15 7:56 Duan Jiong
2014-05-15 21:34 ` Hannes Frederic Sowa
2014-05-16 3:26 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Duan Jiong @ 2014-05-15 7:56 UTC (permalink / raw)
To: David Miller, Hannes Frederic Sowa; +Cc: netdev
RFC 4861 states in 7.2.5:
The IsRouter flag in the cache entry MUST be set based on the
Router flag in the received advertisement. In those cases
where the IsRouter flag changes from TRUE to FALSE as a result
of this update, the node MUST remove that router from the
Default Router List and update the Destination Cache entries
for all destinations using that neighbor as a router as
specified in Section 7.3.3. This is needed to detect when a
node that is used as a router stops forwarding packets due to
being configured as a host.
Currently, when dealing with NA Message which IsRouter flag changes from
TRUE to FALSE, the kernel only removes router from the Default Router List,
and don't update the Destination Cache entries.
Now in order to update those Destination Cache entries, i introduce
function rt6_clean_tohost().
Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---
Changes for v2:
fix format as suggested
delete those Destination Cache entries rather than to make them unreachable.
include/net/ip6_route.h | 1 +
net/ipv6/ndisc.c | 7 ++-----
net/ipv6/route.c | 21 +++++++++++++++++++++
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 6c4f5ea..216cecc 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -127,6 +127,7 @@ int rt6_dump_route(struct rt6_info *rt, void *p_arg);
void rt6_ifdown(struct net *net, struct net_device *dev);
void rt6_mtu_change(struct net_device *dev, unsigned int mtu);
void rt6_remove_prefsrc(struct inet6_ifaddr *ifp);
+void rt6_clean_tohost(struct net *net, struct in6_addr *gateway);
/*
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 09a22f4..ca8d4ea 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -851,7 +851,7 @@ out:
static void ndisc_recv_na(struct sk_buff *skb)
{
struct nd_msg *msg = (struct nd_msg *)skb_transport_header(skb);
- const struct in6_addr *saddr = &ipv6_hdr(skb)->saddr;
+ struct in6_addr *saddr = &ipv6_hdr(skb)->saddr;
const struct in6_addr *daddr = &ipv6_hdr(skb)->daddr;
u8 *lladdr = NULL;
u32 ndoptlen = skb_tail_pointer(skb) - (skb_transport_header(skb) +
@@ -944,10 +944,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
/*
* Change: router to host
*/
- struct rt6_info *rt;
- rt = rt6_get_dflt_router(saddr, dev);
- if (rt)
- ip6_del_rt(rt);
+ rt6_clean_tohost(dev_net(dev), saddr);
}
out:
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 004fffb..58c449a 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2234,6 +2234,27 @@ void rt6_remove_prefsrc(struct inet6_ifaddr *ifp)
fib6_clean_all(net, fib6_remove_prefsrc, &adni);
}
+#define RTF_RA_ROUTER (RTF_ADDRCONF | RTF_DEFAULT | RTF_GATEWAY)
+#define RTF_CACHE_GATEWAY (RTF_GATEWAY | RTF_CACHE)
+
+/* Remove routers and update dst entries when gateway turn into host. */
+static int fib6_clean_tohost(struct rt6_info *rt, void *arg)
+{
+ struct in6_addr *gateway = (struct in6_addr *)arg;
+
+ if ((((rt->rt6i_flags & RTF_RA_ROUTER) == RTF_RA_ROUTER) ||
+ ((rt->rt6i_flags & RTF_CACHE_GATEWAY) == RTF_CACHE_GATEWAY)) &&
+ ipv6_addr_equal(gateway, &rt->rt6i_gateway)) {
+ return -1;
+ }
+ return 0;
+}
+
+void rt6_clean_tohost(struct net *net, struct in6_addr *gateway)
+{
+ fib6_clean_all(net, fib6_clean_tohost, gateway);
+}
+
struct arg_dev_net {
struct net_device *dev;
struct net *net;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host
2014-05-15 7:56 [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host Duan Jiong
@ 2014-05-15 21:34 ` Hannes Frederic Sowa
2014-05-16 3:26 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Hannes Frederic Sowa @ 2014-05-15 21:34 UTC (permalink / raw)
To: Duan Jiong, David Miller; +Cc: netdev
On Thu, May 15, 2014, at 0:56, Duan Jiong wrote:
>
> RFC 4861 states in 7.2.5:
>
> The IsRouter flag in the cache entry MUST be set based on the
> Router flag in the received advertisement. In those cases
> where the IsRouter flag changes from TRUE to FALSE as a result
> of this update, the node MUST remove that router from the
> Default Router List and update the Destination Cache entries
> for all destinations using that neighbor as a router as
> specified in Section 7.3.3. This is needed to detect when a
> node that is used as a router stops forwarding packets due to
> being configured as a host.
>
> Currently, when dealing with NA Message which IsRouter flag changes from
> TRUE to FALSE, the kernel only removes router from the Default Router
> List,
> and don't update the Destination Cache entries.
>
> Now in order to update those Destination Cache entries, i introduce
> function rt6_clean_tohost().
>
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host
2014-05-15 7:56 [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host Duan Jiong
2014-05-15 21:34 ` Hannes Frederic Sowa
@ 2014-05-16 3:26 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-05-16 3:26 UTC (permalink / raw)
To: duanj.fnst; +Cc: hannes, netdev
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Thu, 15 May 2014 15:56:14 +0800
>
> RFC 4861 states in 7.2.5:
>
> The IsRouter flag in the cache entry MUST be set based on the
> Router flag in the received advertisement. In those cases
> where the IsRouter flag changes from TRUE to FALSE as a result
> of this update, the node MUST remove that router from the
> Default Router List and update the Destination Cache entries
> for all destinations using that neighbor as a router as
> specified in Section 7.3.3. This is needed to detect when a
> node that is used as a router stops forwarding packets due to
> being configured as a host.
>
> Currently, when dealing with NA Message which IsRouter flag changes from
> TRUE to FALSE, the kernel only removes router from the Default Router List,
> and don't update the Destination Cache entries.
>
> Now in order to update those Destination Cache entries, i introduce
> function rt6_clean_tohost().
>
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-16 3:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 7:56 [PATCH v2] ipv6: update Destination Cache entries when gateway turn into host Duan Jiong
2014-05-15 21:34 ` Hannes Frederic Sowa
2014-05-16 3:26 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).