Commit 0d098fc4 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV6] Ensure to use interface hoplimit by default.

Signed-off-by: default avatarHideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
parent 8b123d00
...@@ -102,6 +102,8 @@ extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr); ...@@ -102,6 +102,8 @@ extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr);
extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len);
extern int ipv6_get_hoplimit(struct net_device *dev);
/* /*
* anycast prototypes (anycast.c) * anycast prototypes (anycast.c)
*/ */
......
...@@ -381,6 +381,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, ...@@ -381,6 +381,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
hlimit = np->hop_limit; hlimit = np->hop_limit;
if (hlimit < 0) if (hlimit < 0)
hlimit = dst_metric(dst, RTAX_HOPLIMIT); hlimit = dst_metric(dst, RTAX_HOPLIMIT);
if (hlimit < 0)
hlimit = ipv6_get_hoplimit(dst->dev);
msg.skb = skb; msg.skb = skb;
msg.offset = skb->nh.raw - skb->data; msg.offset = skb->nh.raw - skb->data;
...@@ -467,6 +469,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb) ...@@ -467,6 +469,8 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
hlimit = np->hop_limit; hlimit = np->hop_limit;
if (hlimit < 0) if (hlimit < 0)
hlimit = dst_metric(dst, RTAX_HOPLIMIT); hlimit = dst_metric(dst, RTAX_HOPLIMIT);
if (hlimit < 0)
hlimit = ipv6_get_hoplimit(dst->dev);
idev = in6_dev_get(skb->dev); idev = in6_dev_get(skb->dev);
......
...@@ -253,6 +253,8 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, ...@@ -253,6 +253,8 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
hlimit = np->hop_limit; hlimit = np->hop_limit;
if (hlimit < 0) if (hlimit < 0)
hlimit = dst_metric(dst, RTAX_HOPLIMIT); hlimit = dst_metric(dst, RTAX_HOPLIMIT);
if (hlimit < 0)
hlimit = ipv6_get_hoplimit(dst->dev);
hdr->payload_len = htons(seg_len); hdr->payload_len = htons(seg_len);
hdr->nexthdr = proto; hdr->nexthdr = proto;
......
...@@ -1128,8 +1128,11 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1128,8 +1128,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (rt) if (rt)
rt->rt6i_expires = jiffies + (HZ * lifetime); rt->rt6i_expires = jiffies + (HZ * lifetime);
if (ra_msg->icmph.icmp6_hop_limit) if (ra_msg->icmph.icmp6_hop_limit) {
in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit; in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
if (rt)
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = ra_msg->icmph.icmp6_hop_limit;
}
/* /*
* Update Reachable Time and Retrans Timer * Update Reachable Time and Retrans Timer
......
...@@ -756,6 +756,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -756,6 +756,8 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
hlimit = np->hop_limit; hlimit = np->hop_limit;
if (hlimit < 0) if (hlimit < 0)
hlimit = dst_metric(dst, RTAX_HOPLIMIT); hlimit = dst_metric(dst, RTAX_HOPLIMIT);
if (hlimit < 0)
hlimit = ipv6_get_hoplimit(dst->dev);
} }
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
......
...@@ -771,7 +771,7 @@ static int ipv6_get_mtu(struct net_device *dev) ...@@ -771,7 +771,7 @@ static int ipv6_get_mtu(struct net_device *dev)
return mtu; return mtu;
} }
static int ipv6_get_hoplimit(struct net_device *dev) int ipv6_get_hoplimit(struct net_device *dev)
{ {
int hoplimit = ipv6_devconf.hop_limit; int hoplimit = ipv6_devconf.hop_limit;
struct inet6_dev *idev; struct inet6_dev *idev;
...@@ -967,15 +967,8 @@ int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr) ...@@ -967,15 +967,8 @@ int ip6_route_add(struct in6_rtmsg *rtmsg, struct nlmsghdr *nlh, void *_rtattr)
} }
} }
if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) { 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] = -1;
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]) if (!rt->u.dst.metrics[RTAX_MTU-1])
rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev);
if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) if (!rt->u.dst.metrics[RTAX_ADVMSS-1])
...@@ -1414,7 +1407,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, ...@@ -1414,7 +1407,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
rt->rt6i_idev = idev; rt->rt6i_idev = idev;
rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev);
rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_pmtu(&rt->u.dst)); rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_pmtu(&rt->u.dst));
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = ipv6_get_hoplimit(rt->rt6i_dev); rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1;
rt->u.dst.obsolete = -1; rt->u.dst.obsolete = -1;
rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP;
......
...@@ -811,6 +811,8 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -811,6 +811,8 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
hlimit = np->hop_limit; hlimit = np->hop_limit;
if (hlimit < 0) if (hlimit < 0)
hlimit = dst_metric(dst, RTAX_HOPLIMIT); hlimit = dst_metric(dst, RTAX_HOPLIMIT);
if (hlimit < 0)
hlimit = ipv6_get_hoplimit(dst->dev);
} }
if (msg->msg_flags&MSG_CONFIRM) if (msg->msg_flags&MSG_CONFIRM)
......
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