Commit 16daa730 authored by David S. Miller's avatar David S. Miller

[NET]: Hoplimit is a metric not a route attribute.

parent 0ee27163
......@@ -13,15 +13,6 @@
#ifndef _LINUX_IPV6_ROUTE_H
#define _LINUX_IPV6_ROUTE_H
enum
{
RTA_IPV6_UNSPEC,
RTA_IPV6_HOPLIMIT,
};
#define RTA_IPV6_MAX RTA_IPV6_HOPLIMIT
#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
#define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */
#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */
......
......@@ -201,10 +201,9 @@ enum rtattr_type_t
RTA_FLOW,
RTA_CACHEINFO,
RTA_SESSION,
RTA_HOPLIMIT,
};
#define RTA_MAX RTA_HOPLIMIT
#define RTA_MAX RTA_SESSION
#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
......@@ -283,9 +282,11 @@ enum
#define RTAX_ADVMSS RTAX_ADVMSS
RTAX_REORDERING,
#define RTAX_REORDERING RTAX_REORDERING
RTAX_HOPLIMIT,
#define RTAX_HOPLIMIT RTAX_HOPLIMIT
};
#define RTAX_MAX RTAX_REORDERING
#define RTAX_MAX RTAX_HOPLIMIT
struct rta_session
{
......
......@@ -19,7 +19,6 @@ struct dn_kern_rta
u32 *rta_flow;
struct rta_cacheinfo *rta_ci;
struct rta_session *rta_sess;
u8 *rta_hoplimit;
};
struct dn_fib_res {
......
......@@ -67,7 +67,6 @@ struct rt6_info
u32 rt6i_flags;
u32 rt6i_metric;
u8 rt6i_hoplimit;
atomic_t rt6i_ref;
struct rt6key rt6i_dst;
......
......@@ -38,7 +38,6 @@ struct kern_rta
u32 *rta_flow;
struct rta_cacheinfo *rta_ci;
struct rta_session *rta_sess;
u8 *rta_hoplimit;
};
struct fib_nh
......
......@@ -362,7 +362,7 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
else
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
}
plen = skb->nh.raw - skb->data;
......@@ -443,7 +443,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
else
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
}
idev = in6_dev_get(skb->dev);
......
......@@ -249,7 +249,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
if (np)
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
hdr->payload_len = htons(seg_len);
hdr->nexthdr = proto;
......@@ -609,7 +609,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
else
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
}
jumbolen = 0;
......
......@@ -397,7 +397,7 @@ static inline void ndisc_rt_init(struct rt6_info *rt, struct net_device *dev,
rt->rt6i_expires = 0;
rt->rt6i_flags = RTF_LOCAL;
rt->rt6i_metric = 0;
rt->rt6i_hoplimit = 255;
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255;
rt->u.dst.output = ndisc_output;
}
......
......@@ -677,7 +677,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
else
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
}
if (msg->msg_flags&MSG_CONFIRM)
......
......@@ -108,6 +108,7 @@ struct rt6_info ip6_null_entry = {
.dev = &loopback_dev,
.obsolete = -1,
.error = -ENETUNREACH,
.metrics[RTAX_HOPLIMIT-1] = 255,
.input = ip6_pkt_discard,
.output = ip6_pkt_discard,
.ops = &ip6_dst_ops,
......@@ -116,7 +117,6 @@ struct rt6_info ip6_null_entry = {
},
.rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
.rt6i_metric = ~(u32) 0,
.rt6i_hoplimit = 255,
.rt6i_ref = ATOMIC_INIT(1),
};
......@@ -769,13 +769,6 @@ int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr)
}
}
if (ipv6_addr_is_multicast(&rt->rt6i_dst.addr))
rt->rt6i_hoplimit = IPV6_DEFAULT_MCASTHOPS;
else if (rta && rta[RTA_HOPLIMIT-1])
memcpy(&rt->rt6i_hoplimit, RTA_DATA(rta[RTA_HOPLIMIT-1]), 1);
else
rt->rt6i_hoplimit = ipv6_get_hoplimit(dev);
rt->rt6i_flags = rtmsg->rtmsg_flags;
install_route:
......@@ -796,6 +789,16 @@ int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr)
attr = RTA_NEXT(attr, attrlen);
}
}
if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) {
if (ipv6_addr_is_multicast(&rt->rt6i_dst.addr))
rt->u.dst.metrics[RTAX_HOPLIMIT-1] =
IPV6_DEFAULT_MCASTHOPS;
else
rt->u.dst.metrics[RTAX_HOPLIMIT-1] =
ipv6_get_hoplimit(dev);
}
if (!rt->u.dst.metrics[RTAX_MTU-1])
rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev);
if (!rt->u.dst.metrics[RTAX_ADVMSS-1])
......@@ -964,7 +967,6 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *saddr,
nrt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, dst_pmtu(&nrt->u.dst) - 60, ip6_rt_min_advmss);
if (nrt->u.dst.metrics[RTAX_ADVMSS-1] > 65535-20)
nrt->u.dst.metrics[RTAX_ADVMSS-1] = 65535;
nrt->rt6i_hoplimit = ipv6_get_hoplimit(neigh->dev);
if (rt6_ins(nrt, NULL, NULL))
goto out;
......@@ -1080,7 +1082,6 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort)
if (rt->u.dst.dev)
dev_hold(rt->u.dst.dev);
rt->u.dst.lastuse = jiffies;
rt->rt6i_hoplimit = ort->rt6i_hoplimit;
rt->rt6i_expires = 0;
ipv6_addr_copy(&rt->rt6i_gateway, &ort->rt6i_gateway);
......@@ -1226,7 +1227,7 @@ int ip6_rt_addr_add(struct in6_addr *addr, struct net_device *dev)
rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, dst_pmtu(&rt->u.dst) - 60, ip6_rt_min_advmss);
if (rt->u.dst.metrics[RTAX_ADVMSS-1] > 65535-20)
rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535;
rt->rt6i_hoplimit = ipv6_get_hoplimit(rt->rt6i_dev);
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = ipv6_get_hoplimit(rt->rt6i_dev);
rt->u.dst.obsolete = -1;
rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
......
......@@ -968,7 +968,7 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg
else
hlimit = np->hop_limit;
if (hlimit < 0)
hlimit = ((struct rt6_info*)dst)->rt6i_hoplimit;
hlimit = dst_metric(dst, RTAX_HOPLIMIT);
}
if (msg->msg_flags&MSG_CONFIRM)
......
......@@ -153,7 +153,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
x->u.rt6.rt6i_flags = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL);
x->u.rt6.rt6i_metric = rt0->rt6i_metric;
x->u.rt6.rt6i_node = rt0->rt6i_node;
x->u.rt6.rt6i_hoplimit = rt0->rt6i_hoplimit;
x->u.rt6.rt6i_gateway = rt0->rt6i_gateway;
memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
header_len -= x->u.dst.xfrm->props.header_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment