|
@@ -129,7 +129,6 @@ static struct rt6_info ip6_null_entry_template = {
|
|
.__use = 1,
|
|
.__use = 1,
|
|
.obsolete = -1,
|
|
.obsolete = -1,
|
|
.error = -ENETUNREACH,
|
|
.error = -ENETUNREACH,
|
|
- .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
|
|
|
|
.input = ip6_pkt_discard,
|
|
.input = ip6_pkt_discard,
|
|
.output = ip6_pkt_discard_out,
|
|
.output = ip6_pkt_discard_out,
|
|
},
|
|
},
|
|
@@ -150,7 +149,6 @@ static struct rt6_info ip6_prohibit_entry_template = {
|
|
.__use = 1,
|
|
.__use = 1,
|
|
.obsolete = -1,
|
|
.obsolete = -1,
|
|
.error = -EACCES,
|
|
.error = -EACCES,
|
|
- .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
|
|
|
|
.input = ip6_pkt_prohibit,
|
|
.input = ip6_pkt_prohibit,
|
|
.output = ip6_pkt_prohibit_out,
|
|
.output = ip6_pkt_prohibit_out,
|
|
},
|
|
},
|
|
@@ -166,7 +164,6 @@ static struct rt6_info ip6_blk_hole_entry_template = {
|
|
.__use = 1,
|
|
.__use = 1,
|
|
.obsolete = -1,
|
|
.obsolete = -1,
|
|
.error = -EINVAL,
|
|
.error = -EINVAL,
|
|
- .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
|
|
|
|
.input = dst_discard,
|
|
.input = dst_discard,
|
|
.output = dst_discard,
|
|
.output = dst_discard,
|
|
},
|
|
},
|
|
@@ -844,7 +841,7 @@ int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl
|
|
new->input = dst_discard;
|
|
new->input = dst_discard;
|
|
new->output = dst_discard;
|
|
new->output = dst_discard;
|
|
|
|
|
|
- memcpy(new->metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32));
|
|
|
|
|
|
+ dst_copy_metrics(new, &ort->dst);
|
|
new->dev = ort->dst.dev;
|
|
new->dev = ort->dst.dev;
|
|
if (new->dev)
|
|
if (new->dev)
|
|
dev_hold(new->dev);
|
|
dev_hold(new->dev);
|
|
@@ -928,10 +925,12 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
|
|
if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) {
|
|
if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) {
|
|
rt6->rt6i_flags |= RTF_MODIFIED;
|
|
rt6->rt6i_flags |= RTF_MODIFIED;
|
|
if (mtu < IPV6_MIN_MTU) {
|
|
if (mtu < IPV6_MIN_MTU) {
|
|
|
|
+ u32 features = dst_metric(dst, RTAX_FEATURES);
|
|
mtu = IPV6_MIN_MTU;
|
|
mtu = IPV6_MIN_MTU;
|
|
- dst->metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
|
|
+ features |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
+ dst_metric_set(dst, RTAX_FEATURES, features);
|
|
}
|
|
}
|
|
- dst->metrics[RTAX_MTU-1] = mtu;
|
|
|
|
|
|
+ dst_metric_set(dst, RTAX_MTU, mtu);
|
|
call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst);
|
|
call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -989,9 +988,9 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
|
|
rt->rt6i_idev = idev;
|
|
rt->rt6i_idev = idev;
|
|
rt->rt6i_nexthop = neigh;
|
|
rt->rt6i_nexthop = neigh;
|
|
atomic_set(&rt->dst.__refcnt, 1);
|
|
atomic_set(&rt->dst.__refcnt, 1);
|
|
- rt->dst.metrics[RTAX_HOPLIMIT-1] = 255;
|
|
|
|
- rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev);
|
|
|
|
- rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst));
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_MTU, ipv6_get_mtu(rt->rt6i_dev));
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_ADVMSS, ipv6_advmss(net, dst_mtu(&rt->dst)));
|
|
rt->dst.output = ip6_output;
|
|
rt->dst.output = ip6_output;
|
|
|
|
|
|
#if 0 /* there's no chance to use these for ndisc */
|
|
#if 0 /* there's no chance to use these for ndisc */
|
|
@@ -1305,17 +1304,17 @@ install_route:
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- rt->dst.metrics[type - 1] = nla_get_u32(nla);
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, type, nla_get_u32(nla));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dst_metric(&rt->dst, RTAX_HOPLIMIT) == 0)
|
|
if (dst_metric(&rt->dst, RTAX_HOPLIMIT) == 0)
|
|
- rt->dst.metrics[RTAX_HOPLIMIT-1] = -1;
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_HOPLIMIT, -1);
|
|
if (!dst_mtu(&rt->dst))
|
|
if (!dst_mtu(&rt->dst))
|
|
- rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev);
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_MTU, ipv6_get_mtu(dev));
|
|
if (!dst_metric(&rt->dst, RTAX_ADVMSS))
|
|
if (!dst_metric(&rt->dst, RTAX_ADVMSS))
|
|
- rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst));
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_ADVMSS, ipv6_advmss(net, dst_mtu(&rt->dst)));
|
|
rt->dst.dev = dev;
|
|
rt->dst.dev = dev;
|
|
rt->rt6i_idev = idev;
|
|
rt->rt6i_idev = idev;
|
|
rt->rt6i_table = table;
|
|
rt->rt6i_table = table;
|
|
@@ -1541,9 +1540,9 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src,
|
|
ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key);
|
|
ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key);
|
|
nrt->rt6i_nexthop = neigh_clone(neigh);
|
|
nrt->rt6i_nexthop = neigh_clone(neigh);
|
|
/* Reset pmtu, it may be better */
|
|
/* Reset pmtu, it may be better */
|
|
- nrt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev);
|
|
|
|
- nrt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dev_net(neigh->dev),
|
|
|
|
- dst_mtu(&nrt->dst));
|
|
|
|
|
|
+ dst_metric_set(&nrt->dst, RTAX_MTU, ipv6_get_mtu(neigh->dev));
|
|
|
|
+ dst_metric_set(&nrt->dst, RTAX_ADVMSS, ipv6_advmss(dev_net(neigh->dev),
|
|
|
|
+ dst_mtu(&nrt->dst)));
|
|
|
|
|
|
if (ip6_ins_rt(nrt))
|
|
if (ip6_ins_rt(nrt))
|
|
goto out;
|
|
goto out;
|
|
@@ -1602,9 +1601,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr,
|
|
would return automatically.
|
|
would return automatically.
|
|
*/
|
|
*/
|
|
if (rt->rt6i_flags & RTF_CACHE) {
|
|
if (rt->rt6i_flags & RTF_CACHE) {
|
|
- rt->dst.metrics[RTAX_MTU-1] = pmtu;
|
|
|
|
- if (allfrag)
|
|
|
|
- rt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_MTU, pmtu);
|
|
|
|
+ if (allfrag) {
|
|
|
|
+ u32 features = dst_metric(&rt->dst, RTAX_FEATURES);
|
|
|
|
+ features |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_FEATURES, features);
|
|
|
|
+ }
|
|
dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
|
|
dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires);
|
|
rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES;
|
|
rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES;
|
|
goto out;
|
|
goto out;
|
|
@@ -1621,9 +1623,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr,
|
|
nrt = rt6_alloc_clone(rt, daddr);
|
|
nrt = rt6_alloc_clone(rt, daddr);
|
|
|
|
|
|
if (nrt) {
|
|
if (nrt) {
|
|
- nrt->dst.metrics[RTAX_MTU-1] = pmtu;
|
|
|
|
- if (allfrag)
|
|
|
|
- nrt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
|
|
+ dst_metric_set(&nrt->dst, RTAX_MTU, pmtu);
|
|
|
|
+ if (allfrag) {
|
|
|
|
+ u32 features = dst_metric(&nrt->dst, RTAX_FEATURES);
|
|
|
|
+ features |= RTAX_FEATURE_ALLFRAG;
|
|
|
|
+ dst_metric_set(&nrt->dst, RTAX_FEATURES, features);
|
|
|
|
+ }
|
|
|
|
|
|
/* According to RFC 1981, detecting PMTU increase shouldn't be
|
|
/* According to RFC 1981, detecting PMTU increase shouldn't be
|
|
* happened within 5 mins, the recommended timer is 10 mins.
|
|
* happened within 5 mins, the recommended timer is 10 mins.
|
|
@@ -1674,7 +1679,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
|
|
rt->dst.input = ort->dst.input;
|
|
rt->dst.input = ort->dst.input;
|
|
rt->dst.output = ort->dst.output;
|
|
rt->dst.output = ort->dst.output;
|
|
|
|
|
|
- memcpy(rt->dst.metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32));
|
|
|
|
|
|
+ dst_copy_metrics(&rt->dst, &ort->dst);
|
|
rt->dst.error = ort->dst.error;
|
|
rt->dst.error = ort->dst.error;
|
|
rt->dst.dev = ort->dst.dev;
|
|
rt->dst.dev = ort->dst.dev;
|
|
if (rt->dst.dev)
|
|
if (rt->dst.dev)
|
|
@@ -1966,9 +1971,9 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
|
|
rt->dst.output = ip6_output;
|
|
rt->dst.output = ip6_output;
|
|
rt->rt6i_dev = net->loopback_dev;
|
|
rt->rt6i_dev = net->loopback_dev;
|
|
rt->rt6i_idev = idev;
|
|
rt->rt6i_idev = idev;
|
|
- rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev);
|
|
|
|
- rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst));
|
|
|
|
- rt->dst.metrics[RTAX_HOPLIMIT-1] = -1;
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_MTU, ipv6_get_mtu(rt->rt6i_dev));
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_ADVMSS, ipv6_advmss(net, dst_mtu(&rt->dst)));
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_HOPLIMIT, -1);
|
|
rt->dst.obsolete = -1;
|
|
rt->dst.obsolete = -1;
|
|
|
|
|
|
rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
|
|
rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
|
|
@@ -2068,8 +2073,8 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
|
|
(dst_mtu(&rt->dst) >= arg->mtu ||
|
|
(dst_mtu(&rt->dst) >= arg->mtu ||
|
|
(dst_mtu(&rt->dst) < arg->mtu &&
|
|
(dst_mtu(&rt->dst) < arg->mtu &&
|
|
dst_mtu(&rt->dst) == idev->cnf.mtu6))) {
|
|
dst_mtu(&rt->dst) == idev->cnf.mtu6))) {
|
|
- rt->dst.metrics[RTAX_MTU-1] = arg->mtu;
|
|
|
|
- rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, arg->mtu);
|
|
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu);
|
|
|
|
+ dst_metric_set(&rt->dst, RTAX_ADVMSS, ipv6_advmss(net, arg->mtu));
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -2295,7 +2300,7 @@ static int rt6_fill_node(struct net *net,
|
|
NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
|
|
NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
|
|
}
|
|
}
|
|
|
|
|
|
- if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0)
|
|
|
|
|
|
+ if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0)
|
|
goto nla_put_failure;
|
|
goto nla_put_failure;
|
|
|
|
|
|
if (rt->dst.neighbour)
|
|
if (rt->dst.neighbour)
|
|
@@ -2686,6 +2691,7 @@ static int __net_init ip6_route_net_init(struct net *net)
|
|
net->ipv6.ip6_null_entry->dst.path =
|
|
net->ipv6.ip6_null_entry->dst.path =
|
|
(struct dst_entry *)net->ipv6.ip6_null_entry;
|
|
(struct dst_entry *)net->ipv6.ip6_null_entry;
|
|
net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
|
|
+ dst_metric_set(&net->ipv6.ip6_null_entry->dst, RTAX_HOPLIMIT, 255);
|
|
|
|
|
|
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
|
|
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
|
|
net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
|
|
net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template,
|
|
@@ -2696,6 +2702,7 @@ static int __net_init ip6_route_net_init(struct net *net)
|
|
net->ipv6.ip6_prohibit_entry->dst.path =
|
|
net->ipv6.ip6_prohibit_entry->dst.path =
|
|
(struct dst_entry *)net->ipv6.ip6_prohibit_entry;
|
|
(struct dst_entry *)net->ipv6.ip6_prohibit_entry;
|
|
net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
|
|
+ dst_metric_set(&net->ipv6.ip6_prohibit_entry->dst, RTAX_HOPLIMIT, 255);
|
|
|
|
|
|
net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template,
|
|
net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template,
|
|
sizeof(*net->ipv6.ip6_blk_hole_entry),
|
|
sizeof(*net->ipv6.ip6_blk_hole_entry),
|
|
@@ -2705,6 +2712,7 @@ static int __net_init ip6_route_net_init(struct net *net)
|
|
net->ipv6.ip6_blk_hole_entry->dst.path =
|
|
net->ipv6.ip6_blk_hole_entry->dst.path =
|
|
(struct dst_entry *)net->ipv6.ip6_blk_hole_entry;
|
|
(struct dst_entry *)net->ipv6.ip6_blk_hole_entry;
|
|
net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops;
|
|
|
|
+ dst_metric_set(&net->ipv6.ip6_blk_hole_entry->dst, RTAX_HOPLIMIT, 255);
|
|
#endif
|
|
#endif
|
|
|
|
|
|
net->ipv6.sysctl.flush_delay = 0;
|
|
net->ipv6.sysctl.flush_delay = 0;
|