@@ -533,7 +533,7 @@ static void rt6_probe(struct fib6_info *rt)
533533 * Router Reachability Probe MUST be rate-limited
534534 * to no more than one per minute.
535535 */
536- if (!rt || !( rt -> fib6_flags & RTF_GATEWAY ) )
536+ if (!rt || !rt -> fib6_nh . fib_nh_has_gw )
537537 return ;
538538
539539 nh_gw = & rt -> fib6_nh .nh_gw ;
@@ -595,7 +595,7 @@ static inline enum rt6_nud_state rt6_check_neigh(struct fib6_info *rt)
595595 struct neighbour * neigh ;
596596
597597 if (rt -> fib6_flags & RTF_NONEXTHOP ||
598- !( rt -> fib6_flags & RTF_GATEWAY ) )
598+ !rt -> fib6_nh . fib_nh_has_gw )
599599 return RT6_NUD_SUCCEED ;
600600
601601 rcu_read_lock_bh ();
@@ -784,7 +784,7 @@ static struct fib6_info *rt6_select(struct net *net, struct fib6_node *fn,
784784
785785static bool rt6_is_gw_or_nonexthop (const struct fib6_info * rt )
786786{
787- return (rt -> fib6_flags & ( RTF_NONEXTHOP | RTF_GATEWAY )) ;
787+ return (rt -> fib6_flags & RTF_NONEXTHOP ) || rt -> fib6_nh . fib_nh_has_gw ;
788788}
789789
790790#ifdef CONFIG_IPV6_ROUTE_INFO
@@ -989,8 +989,11 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort)
989989
990990 rt -> rt6i_dst = ort -> fib6_dst ;
991991 rt -> rt6i_idev = dev ? in6_dev_get (dev ) : NULL ;
992- rt -> rt6i_gateway = ort -> fib6_nh .nh_gw ;
993992 rt -> rt6i_flags = ort -> fib6_flags ;
993+ if (ort -> fib6_nh .fib_nh_has_gw ) {
994+ rt -> rt6i_gateway = ort -> fib6_nh .nh_gw ;
995+ rt -> rt6i_flags |= RTF_GATEWAY ;
996+ }
994997 rt6_set_from (rt , ort );
995998#ifdef CONFIG_IPV6_SUBTREES
996999 rt -> rt6i_src = ort -> fib6_src ;
@@ -1872,7 +1875,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
18721875 rcu_read_unlock ();
18731876 return rt ;
18741877 } else if (unlikely ((fl6 -> flowi6_flags & FLOWI_FLAG_KNOWN_NH ) &&
1875- !( f6i -> fib6_flags & RTF_GATEWAY ) )) {
1878+ !f6i -> fib6_nh . fib_nh_has_gw )) {
18761879 /* Create a RTF_CACHE clone which will not be
18771880 * owned by the fib6 tree. It is for the special case where
18781881 * the daddr in the skb during the neighbor look-up is different
@@ -2442,7 +2445,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
24422445 continue ;
24432446 if (rt -> fib6_flags & RTF_REJECT )
24442447 break ;
2445- if (!( rt -> fib6_flags & RTF_GATEWAY ) )
2448+ if (!rt -> fib6_nh . fib_nh_has_gw )
24462449 continue ;
24472450 if (fl6 -> flowi6_oif != rt -> fib6_nh .nh_dev -> ifindex )
24482451 continue ;
@@ -2986,6 +2989,7 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
29862989 goto out ;
29872990
29882991 fib6_nh -> nh_gw = cfg -> fc_gateway ;
2992+ fib6_nh -> fib_nh_has_gw = 1 ;
29892993 }
29902994
29912995 err = - ENODEV ;
@@ -3121,7 +3125,7 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
31213125 rt -> fib6_table = table ;
31223126 rt -> fib6_metric = cfg -> fc_metric ;
31233127 rt -> fib6_type = cfg -> fc_type ;
3124- rt -> fib6_flags = cfg -> fc_flags ;
3128+ rt -> fib6_flags = cfg -> fc_flags & ~ RTF_GATEWAY ;
31253129
31263130 ipv6_addr_prefix (& rt -> fib6_dst .addr , & cfg -> fc_dst , cfg -> fc_dst_len );
31273131 rt -> fib6_dst .plen = cfg -> fc_dst_len ;
@@ -3490,7 +3494,8 @@ static struct fib6_info *rt6_get_route_info(struct net *net,
34903494 for_each_fib6_node_rt_rcu (fn ) {
34913495 if (rt -> fib6_nh .nh_dev -> ifindex != ifindex )
34923496 continue ;
3493- if ((rt -> fib6_flags & (RTF_ROUTEINFO |RTF_GATEWAY )) != (RTF_ROUTEINFO |RTF_GATEWAY ))
3497+ if (!(rt -> fib6_flags & RTF_ROUTEINFO ) ||
3498+ !rt -> fib6_nh .fib_nh_has_gw )
34943499 continue ;
34953500 if (!ipv6_addr_equal (& rt -> fib6_nh .nh_gw , gwaddr ))
34963501 continue ;
@@ -3811,14 +3816,15 @@ void rt6_remove_prefsrc(struct inet6_ifaddr *ifp)
38113816 fib6_clean_all (net , fib6_remove_prefsrc , & adni );
38123817}
38133818
3814- #define RTF_RA_ROUTER (RTF_ADDRCONF | RTF_DEFAULT | RTF_GATEWAY )
3819+ #define RTF_RA_ROUTER (RTF_ADDRCONF | RTF_DEFAULT)
38153820
38163821/* Remove routers and update dst entries when gateway turn into host. */
38173822static int fib6_clean_tohost (struct fib6_info * rt , void * arg )
38183823{
38193824 struct in6_addr * gateway = (struct in6_addr * )arg ;
38203825
38213826 if (((rt -> fib6_flags & RTF_RA_ROUTER ) == RTF_RA_ROUTER ) &&
3827+ rt -> fib6_nh .fib_nh_has_gw &&
38223828 ipv6_addr_equal (gateway , & rt -> fib6_nh .nh_gw )) {
38233829 return -1 ;
38243830 }
@@ -4607,7 +4613,7 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct fib6_info *rt,
46074613 rcu_read_unlock ();
46084614 }
46094615
4610- if (rt -> fib6_flags & RTF_GATEWAY ) {
4616+ if (rt -> fib6_nh . fib_nh_has_gw ) {
46114617 if (nla_put_in6_addr (skb , RTA_GATEWAY , & rt -> fib6_nh .nh_gw ) < 0 )
46124618 goto nla_put_failure ;
46134619 }
0 commit comments