@@ -307,6 +307,7 @@ static const struct rt6_info ip6_null_entry_template = {
307
307
.rt6i_protocol = RTPROT_KERNEL ,
308
308
.rt6i_metric = ~(u32 ) 0 ,
309
309
.rt6i_ref = ATOMIC_INIT (1 ),
310
+ .fib6_type = RTN_UNREACHABLE ,
310
311
};
311
312
312
313
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
@@ -324,6 +325,7 @@ static const struct rt6_info ip6_prohibit_entry_template = {
324
325
.rt6i_protocol = RTPROT_KERNEL ,
325
326
.rt6i_metric = ~(u32 ) 0 ,
326
327
.rt6i_ref = ATOMIC_INIT (1 ),
328
+ .fib6_type = RTN_PROHIBIT ,
327
329
};
328
330
329
331
static const struct rt6_info ip6_blk_hole_entry_template = {
@@ -339,6 +341,7 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
339
341
.rt6i_protocol = RTPROT_KERNEL ,
340
342
.rt6i_metric = ~(u32 ) 0 ,
341
343
.rt6i_ref = ATOMIC_INIT (1 ),
344
+ .fib6_type = RTN_BLACKHOLE ,
342
345
};
343
346
344
347
#endif
@@ -2802,6 +2805,11 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
2802
2805
goto out ;
2803
2806
}
2804
2807
2808
+ if (cfg -> fc_type > RTN_MAX ) {
2809
+ NL_SET_ERR_MSG (extack , "Invalid route type" );
2810
+ goto out ;
2811
+ }
2812
+
2805
2813
if (cfg -> fc_dst_len > 128 ) {
2806
2814
NL_SET_ERR_MSG (extack , "Invalid prefix length" );
2807
2815
goto out ;
@@ -2914,6 +2922,8 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,
2914
2922
rt -> rt6i_metric = cfg -> fc_metric ;
2915
2923
rt -> rt6i_nh_weight = 1 ;
2916
2924
2925
+ rt -> fib6_type = cfg -> fc_type ;
2926
+
2917
2927
/* We cannot add true routes via loopback here,
2918
2928
they would result in kernel looping; promote them to reject routes
2919
2929
*/
@@ -3354,6 +3364,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net,
3354
3364
.fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO |
3355
3365
RTF_UP | RTF_PREF (pref ),
3356
3366
.fc_protocol = RTPROT_RA ,
3367
+ .fc_type = RTN_UNICAST ,
3357
3368
.fc_nlinfo .portid = 0 ,
3358
3369
.fc_nlinfo .nlh = NULL ,
3359
3370
.fc_nlinfo .nl_net = net ,
@@ -3410,6 +3421,7 @@ struct rt6_info *rt6_add_dflt_router(struct net *net,
3410
3421
.fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT |
3411
3422
RTF_UP | RTF_EXPIRES | RTF_PREF (pref ),
3412
3423
.fc_protocol = RTPROT_RA ,
3424
+ .fc_type = RTN_UNICAST ,
3413
3425
.fc_nlinfo .portid = 0 ,
3414
3426
.fc_nlinfo .nlh = NULL ,
3415
3427
.fc_nlinfo .nl_net = net ,
@@ -3485,6 +3497,7 @@ static void rtmsg_to_fib6_config(struct net *net,
3485
3497
cfg -> fc_dst_len = rtmsg -> rtmsg_dst_len ;
3486
3498
cfg -> fc_src_len = rtmsg -> rtmsg_src_len ;
3487
3499
cfg -> fc_flags = rtmsg -> rtmsg_flags ;
3500
+ cfg -> fc_type = rtmsg -> rtmsg_type ;
3488
3501
3489
3502
cfg -> fc_nlinfo .nl_net = net ;
3490
3503
@@ -3606,10 +3619,13 @@ struct rt6_info *addrconf_dst_alloc(struct net *net,
3606
3619
3607
3620
rt -> rt6i_protocol = RTPROT_KERNEL ;
3608
3621
rt -> rt6i_flags = RTF_UP | RTF_NONEXTHOP ;
3609
- if (anycast )
3622
+ if (anycast ) {
3623
+ rt -> fib6_type = RTN_ANYCAST ;
3610
3624
rt -> rt6i_flags |= RTF_ANYCAST ;
3611
- else
3625
+ } else {
3626
+ rt -> fib6_type = RTN_LOCAL ;
3612
3627
rt -> rt6i_flags |= RTF_LOCAL ;
3628
+ }
3613
3629
3614
3630
rt -> rt6i_gateway = * addr ;
3615
3631
rt -> rt6i_dst .addr = * addr ;
@@ -4509,30 +4525,8 @@ static int rt6_fill_node(struct net *net,
4509
4525
rtm -> rtm_table = table ;
4510
4526
if (nla_put_u32 (skb , RTA_TABLE , table ))
4511
4527
goto nla_put_failure ;
4512
- if (rt -> rt6i_flags & RTF_REJECT ) {
4513
- switch (rt -> dst .error ) {
4514
- case - EINVAL :
4515
- rtm -> rtm_type = RTN_BLACKHOLE ;
4516
- break ;
4517
- case - EACCES :
4518
- rtm -> rtm_type = RTN_PROHIBIT ;
4519
- break ;
4520
- case - EAGAIN :
4521
- rtm -> rtm_type = RTN_THROW ;
4522
- break ;
4523
- default :
4524
- rtm -> rtm_type = RTN_UNREACHABLE ;
4525
- break ;
4526
- }
4527
- }
4528
- else if (rt -> rt6i_flags & RTF_LOCAL )
4529
- rtm -> rtm_type = RTN_LOCAL ;
4530
- else if (rt -> rt6i_flags & RTF_ANYCAST )
4531
- rtm -> rtm_type = RTN_ANYCAST ;
4532
- else if (rt -> dst .dev && (rt -> dst .dev -> flags & IFF_LOOPBACK ))
4533
- rtm -> rtm_type = RTN_LOCAL ;
4534
- else
4535
- rtm -> rtm_type = RTN_UNICAST ;
4528
+
4529
+ rtm -> rtm_type = rt -> fib6_type ;
4536
4530
rtm -> rtm_flags = 0 ;
4537
4531
rtm -> rtm_scope = RT_SCOPE_UNIVERSE ;
4538
4532
rtm -> rtm_protocol = rt -> rt6i_protocol ;
0 commit comments