aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-10 06:00:30 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-03-24 21:24:00 -0400
commit6b75d0908185bf853b188afa6f269426f6554c5b (patch)
tree85f28296077f3d873bbda249dc0eafcc911164fd /net
parent4725474584d6aa2f07b3d47442dfbc4f6544f65e (diff)
[IPV6]: Optimize hop-limit determination.
Last part of hop-limit determination is always: hoplimit = dst_metric(dst, RTAX_HOPLIMIT); if (hoplimit < 0) hoplimit = ipv6_get_hoplimit(dst->dev). Let's consolidate it as ip6_dst_hoplimit(dst). Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/icmp.c8
-rw-r--r--net/ipv6/ip6_output.c4
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/ipv6/route.c20
-rw-r--r--net/ipv6/udp.c4
6 files changed, 17 insertions, 27 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 6b5391ab8346..86332417b402 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -464,9 +464,7 @@ route_done:
464 else 464 else
465 hlimit = np->hop_limit; 465 hlimit = np->hop_limit;
466 if (hlimit < 0) 466 if (hlimit < 0)
467 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 467 hlimit = ip6_dst_hoplimit(dst);
468 if (hlimit < 0)
469 hlimit = ipv6_get_hoplimit(dst->dev);
470 468
471 tclass = np->tclass; 469 tclass = np->tclass;
472 if (tclass < 0) 470 if (tclass < 0)
@@ -560,9 +558,7 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
560 else 558 else
561 hlimit = np->hop_limit; 559 hlimit = np->hop_limit;
562 if (hlimit < 0) 560 if (hlimit < 0)
563 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 561 hlimit = ip6_dst_hoplimit(dst);
564 if (hlimit < 0)
565 hlimit = ipv6_get_hoplimit(dst->dev);
566 562
567 tclass = np->tclass; 563 tclass = np->tclass;
568 if (tclass < 0) 564 if (tclass < 0)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index ed6482667a25..2a4f08c8a02d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -237,9 +237,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
237 if (np) 237 if (np)
238 hlimit = np->hop_limit; 238 hlimit = np->hop_limit;
239 if (hlimit < 0) 239 if (hlimit < 0)
240 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 240 hlimit = ip6_dst_hoplimit(dst);
241 if (hlimit < 0)
242 hlimit = ipv6_get_hoplimit(dst->dev);
243 241
244 tclass = -1; 242 tclass = -1;
245 if (np) 243 if (np)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index c11c76cab371..8e29fb1d1df6 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -904,9 +904,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
904 dst = sk_dst_get(sk); 904 dst = sk_dst_get(sk);
905 if (dst) { 905 if (dst) {
906 if (val < 0) 906 if (val < 0)
907 val = dst_metric(dst, RTAX_HOPLIMIT); 907 val = ip6_dst_hoplimit(dst);
908 if (val < 0)
909 val = ipv6_get_hoplimit(dst->dev);
910 dst_release(dst); 908 dst_release(dst);
911 } 909 }
912 if (val < 0) 910 if (val < 0)
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index a9e4235157a2..548d0763f4d3 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -885,9 +885,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
885 else 885 else
886 hlimit = np->hop_limit; 886 hlimit = np->hop_limit;
887 if (hlimit < 0) 887 if (hlimit < 0)
888 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 888 hlimit = ip6_dst_hoplimit(dst);
889 if (hlimit < 0)
890 hlimit = ipv6_get_hoplimit(dst->dev);
891 } 889 }
892 890
893 if (tclass < 0) { 891 if (tclass < 0) {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a4b5aee0f68a..aa3f08718e44 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1034,15 +1034,17 @@ static int ipv6_get_mtu(struct net_device *dev)
1034 return mtu; 1034 return mtu;
1035} 1035}
1036 1036
1037int ipv6_get_hoplimit(struct net_device *dev) 1037int ip6_dst_hoplimit(struct dst_entry *dst)
1038{ 1038{
1039 int hoplimit = ipv6_devconf.hop_limit; 1039 int hoplimit = dst_metric(dst, RTAX_HOPLIMIT);
1040 struct inet6_dev *idev; 1040 if (hoplimit < 0) {
1041 1041 struct net_device *dev = dst->dev;
1042 idev = in6_dev_get(dev); 1042 struct inet6_dev *idev = in6_dev_get(dev);
1043 if (idev) { 1043 if (idev) {
1044 hoplimit = idev->cnf.hop_limit; 1044 hoplimit = idev->cnf.hop_limit;
1045 in6_dev_put(idev); 1045 in6_dev_put(idev);
1046 } else
1047 hoplimit = ipv6_devconf.hop_limit;
1046 } 1048 }
1047 return hoplimit; 1049 return hoplimit;
1048} 1050}
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 5f5d1218c34e..593d3efadaf9 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -792,9 +792,7 @@ do_udp_sendmsg:
792 else 792 else
793 hlimit = np->hop_limit; 793 hlimit = np->hop_limit;
794 if (hlimit < 0) 794 if (hlimit < 0)
795 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 795 hlimit = ip6_dst_hoplimit(dst);
796 if (hlimit < 0)
797 hlimit = ipv6_get_hoplimit(dst->dev);
798 } 796 }
799 797
800 if (tclass < 0) { 798 if (tclass < 0) {