@@ -248,12 +248,6 @@ static void ip6_rt_blackhole_redirect(struct dst_entry *dst, struct sock *sk,
248
248
{
249
249
}
250
250
251
- static u32 * ip6_rt_blackhole_cow_metrics (struct dst_entry * dst ,
252
- unsigned long old )
253
- {
254
- return NULL ;
255
- }
256
-
257
251
static struct dst_ops ip6_dst_blackhole_ops = {
258
252
.family = AF_INET6 ,
259
253
.destroy = ip6_dst_destroy ,
@@ -262,7 +256,7 @@ static struct dst_ops ip6_dst_blackhole_ops = {
262
256
.default_advmss = ip6_default_advmss ,
263
257
.update_pmtu = ip6_rt_blackhole_update_pmtu ,
264
258
.redirect = ip6_rt_blackhole_redirect ,
265
- .cow_metrics = ip6_rt_blackhole_cow_metrics ,
259
+ .cow_metrics = dst_cow_metrics_generic ,
266
260
.neigh_lookup = ip6_neigh_lookup ,
267
261
};
268
262
@@ -319,6 +313,15 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
319
313
320
314
#endif
321
315
316
+ static void rt6_info_init (struct rt6_info * rt )
317
+ {
318
+ struct dst_entry * dst = & rt -> dst ;
319
+
320
+ memset (dst + 1 , 0 , sizeof (* rt ) - sizeof (* dst ));
321
+ INIT_LIST_HEAD (& rt -> rt6i_siblings );
322
+ INIT_LIST_HEAD (& rt -> rt6i_uncached );
323
+ }
324
+
322
325
/* allocate dst with ip6_dst_ops */
323
326
static struct rt6_info * __ip6_dst_alloc (struct net * net ,
324
327
struct net_device * dev ,
@@ -327,13 +330,9 @@ static struct rt6_info *__ip6_dst_alloc(struct net *net,
327
330
struct rt6_info * rt = dst_alloc (& net -> ipv6 .ip6_dst_ops , dev ,
328
331
0 , DST_OBSOLETE_FORCE_CHK , flags );
329
332
330
- if (rt ) {
331
- struct dst_entry * dst = & rt -> dst ;
333
+ if (rt )
334
+ rt6_info_init ( rt ) ;
332
335
333
- memset (dst + 1 , 0 , sizeof (* rt ) - sizeof (* dst ));
334
- INIT_LIST_HEAD (& rt -> rt6i_siblings );
335
- INIT_LIST_HEAD (& rt -> rt6i_uncached );
336
- }
337
336
return rt ;
338
337
}
339
338
@@ -1214,24 +1213,20 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
1214
1213
1215
1214
rt = dst_alloc (& ip6_dst_blackhole_ops , ort -> dst .dev , 1 , DST_OBSOLETE_NONE , 0 );
1216
1215
if (rt ) {
1217
- new = & rt -> dst ;
1218
-
1219
- memset (new + 1 , 0 , sizeof (* rt ) - sizeof (* new ));
1216
+ rt6_info_init (rt );
1220
1217
1218
+ new = & rt -> dst ;
1221
1219
new -> __use = 1 ;
1222
1220
new -> input = dst_discard ;
1223
1221
new -> output = dst_discard_sk ;
1224
1222
1225
- if (dst_metrics_read_only (& ort -> dst ))
1226
- new -> _metrics = ort -> dst ._metrics ;
1227
- else
1228
- dst_copy_metrics (new , & ort -> dst );
1223
+ dst_copy_metrics (new , & ort -> dst );
1229
1224
rt -> rt6i_idev = ort -> rt6i_idev ;
1230
1225
if (rt -> rt6i_idev )
1231
1226
in6_dev_hold (rt -> rt6i_idev );
1232
1227
1233
1228
rt -> rt6i_gateway = ort -> rt6i_gateway ;
1234
- rt -> rt6i_flags = ort -> rt6i_flags ;
1229
+ rt -> rt6i_flags = ort -> rt6i_flags & ~ RTF_PCPU ;
1235
1230
rt -> rt6i_metric = 0 ;
1236
1231
1237
1232
memcpy (& rt -> rt6i_dst , & ort -> rt6i_dst , sizeof (struct rt6key ));
0 commit comments