Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1. commit 9eb0db7e3ff347614cb1fac418c3b39e28ed33e4
  2. Author: Florian Westphal <fw@strlen.de>
  3. Date:   Tue Jul 28 13:15:43 2015 +0200
  4.  
  5.     ipv6: don't reject link-local local nexthop address on other interface
  6.    
  7.    48ed7b26faa7 ("ipv6: reject locally assigned nexthop addresses") is too
  8.    strict; it rejects following corner-case:
  9.    
  10.    ip -6 route add default via fe80::12:34:56 dev eth1
  11.    
  12.    (where the nexthop link-local address is assigned to a different interface).
  13.    
  14.    We fix this by restricting search to given device if nh is linklocal.
  15.    
  16.    Joint work with Hannes Frederic Sowa.
  17.    
  18.    Fixes: 48ed7b26faa7 ("ipv6: reject locally assigned nexthop addresses")
  19.    Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
  20.    Signed-off-by: Florian Westphal <fw@strlen.de>
  21.  
  22. diff --git a/net/ipv6/route.c b/net/ipv6/route.c
  23. index 6090969..9de4d2b 100644
  24. --- a/net/ipv6/route.c
  25. +++ b/net/ipv6/route.c
  26. @@ -1831,6 +1831,7 @@ int ip6_route_add(struct fib6_config *cfg)
  27.                int gwa_type;
  28.  
  29.                gw_addr = &cfg->fc_gateway;
  30. +               gwa_type = ipv6_addr_type(gw_addr);
  31.  
  32.                /* if gw_addr is local we will fail to detect this in case
  33.                 * address is still TENTATIVE (DAD in progress). rt6_lookup()
  34. @@ -1838,11 +1839,12 @@ int ip6_route_add(struct fib6_config *cfg)
  35.                 * prefix route was assigned to, which might be non-loopback.
  36.                 */
  37.                err = -EINVAL;
  38. -               if (ipv6_chk_addr_and_flags(net, gw_addr, NULL, 0, 0))
  39. +               if (ipv6_chk_addr_and_flags(net, gw_addr,
  40. +                                           gwa_type & IPV6_ADDR_LINKLOCAL ?
  41. +                                           dev : NULL, 0, 0))
  42.                        goto out;
  43.  
  44.                rt->rt6i_gateway = *gw_addr;
  45. -               gwa_type = ipv6_addr_type(gw_addr);
  46.  
  47.                if (gwa_type != (IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST)) {
  48.                        struct rt6_info *grt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement