ip: Use inline function dst_metric() instead of direct access to dst->metric[]

There are functions to refer to the value of dst->metric[THE_METRIC-1]
directly without use of a inline function "dst_metric" defined in
net/dst.h.

The following patch changes them to use the inline function
consistently.

Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Satoru SATOH and committed by
David S. Miller
5ffc02a1 0bbeafd0

+25 -24
+6 -6
net/decnet/dn_route.c
··· 235 else 236 min_mtu -= 21; 237 238 - if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= min_mtu) { 239 if (!(dst_metric_locked(dst, RTAX_MTU))) { 240 dst->metrics[RTAX_MTU-1] = mtu; 241 dst_set_expires(dst, dn_rt_mtu_expires); 242 } 243 if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { 244 u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; 245 - if (dst->metrics[RTAX_ADVMSS-1] > mss) 246 dst->metrics[RTAX_ADVMSS-1] = mss; 247 } 248 } ··· 805 rt->u.dst.neighbour = n; 806 } 807 808 - if (rt->u.dst.metrics[RTAX_MTU-1] == 0 || 809 - rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu) 810 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; 811 mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst)); 812 - if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0 || 813 - rt->u.dst.metrics[RTAX_ADVMSS-1] > mss) 814 rt->u.dst.metrics[RTAX_ADVMSS-1] = mss; 815 return 0; 816 }
··· 235 else 236 min_mtu -= 21; 237 238 + if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) { 239 if (!(dst_metric_locked(dst, RTAX_MTU))) { 240 dst->metrics[RTAX_MTU-1] = mtu; 241 dst_set_expires(dst, dn_rt_mtu_expires); 242 } 243 if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { 244 u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; 245 + if (dst_metric(dst, RTAX_ADVMSS) > mss) 246 dst->metrics[RTAX_ADVMSS-1] = mss; 247 } 248 } ··· 805 rt->u.dst.neighbour = n; 806 } 807 808 + if (dst_metric(&rt->u.dst, RTAX_MTU) == 0 || 809 + dst_metric(&rt->u.dst, RTAX_MTU) > rt->u.dst.dev->mtu) 810 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; 811 mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst)); 812 + if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0 || 813 + dst_metric(&rt->u.dst, RTAX_ADVMSS) > mss) 814 rt->u.dst.metrics[RTAX_ADVMSS-1] = mss; 815 return 0; 816 }
+8 -8
net/ipv4/route.c
··· 1468 1469 /* BSD 4.2 compatibility hack :-( */ 1470 if (mtu == 0 && 1471 - old_mtu >= rth->u.dst.metrics[RTAX_MTU-1] && 1472 old_mtu >= 68 + (iph->ihl << 2)) 1473 old_mtu -= iph->ihl << 2; 1474 1475 mtu = guess_mtu(old_mtu); 1476 } 1477 - if (mtu <= rth->u.dst.metrics[RTAX_MTU-1]) { 1478 - if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) { 1479 dst_confirm(&rth->u.dst); 1480 if (mtu < ip_rt_min_pmtu) { 1481 mtu = ip_rt_min_pmtu; ··· 1497 1498 static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) 1499 { 1500 - if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= 68 && 1501 !(dst_metric_locked(dst, RTAX_MTU))) { 1502 if (mtu < ip_rt_min_pmtu) { 1503 mtu = ip_rt_min_pmtu; ··· 1624 } else 1625 rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu; 1626 1627 - if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) 1628 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; 1629 - if (rt->u.dst.metrics[RTAX_MTU-1] > IP_MAX_MTU) 1630 rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; 1631 - if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0) 1632 rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, 1633 ip_rt_min_advmss); 1634 - if (rt->u.dst.metrics[RTAX_ADVMSS-1] > 65535 - 40) 1635 rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40; 1636 1637 #ifdef CONFIG_NET_CLS_ROUTE
··· 1468 1469 /* BSD 4.2 compatibility hack :-( */ 1470 if (mtu == 0 && 1471 + old_mtu >= dst_metric(&rth->u.dst, RTAX_MTU) && 1472 old_mtu >= 68 + (iph->ihl << 2)) 1473 old_mtu -= iph->ihl << 2; 1474 1475 mtu = guess_mtu(old_mtu); 1476 } 1477 + if (mtu <= dst_metric(&rth->u.dst, RTAX_MTU)) { 1478 + if (mtu < dst_metric(&rth->u.dst, RTAX_MTU)) { 1479 dst_confirm(&rth->u.dst); 1480 if (mtu < ip_rt_min_pmtu) { 1481 mtu = ip_rt_min_pmtu; ··· 1497 1498 static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) 1499 { 1500 + if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= 68 && 1501 !(dst_metric_locked(dst, RTAX_MTU))) { 1502 if (mtu < ip_rt_min_pmtu) { 1503 mtu = ip_rt_min_pmtu; ··· 1624 } else 1625 rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu; 1626 1627 + if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) 1628 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; 1629 + if (dst_metric(&rt->u.dst, RTAX_MTU) > IP_MAX_MTU) 1630 rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; 1631 + if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0) 1632 rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, 1633 ip_rt_min_advmss); 1634 + if (dst_metric(&rt->u.dst, RTAX_ADVMSS) > 65535 - 40) 1635 rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40; 1636 1637 #ifdef CONFIG_NET_CLS_ROUTE
+8 -7
net/ipv4/tcp_input.c
··· 66 #include <linux/mm.h> 67 #include <linux/module.h> 68 #include <linux/sysctl.h> 69 #include <net/tcp.h> 70 #include <net/inet_common.h> 71 #include <linux/ipsec.h> ··· 606 u32 rto_min = TCP_RTO_MIN; 607 608 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) 609 - rto_min = dst->metrics[RTAX_RTO_MIN - 1]; 610 return rto_min; 611 } 612 ··· 770 dst->metrics[RTAX_RTTVAR - 1] = m; 771 else 772 dst->metrics[RTAX_RTTVAR-1] -= 773 - (dst->metrics[RTAX_RTTVAR-1] - m)>>2; 774 } 775 776 if (tp->snd_ssthresh >= 0xFFFF) { ··· 789 dst->metrics[RTAX_SSTHRESH-1] = 790 max(tp->snd_cwnd >> 1, tp->snd_ssthresh); 791 if (!dst_metric_locked(dst, RTAX_CWND)) 792 - dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_cwnd) >> 1; 793 } else { 794 /* Else slow start did not finish, cwnd is non-sense, 795 ssthresh may be also invalid. 796 */ 797 if (!dst_metric_locked(dst, RTAX_CWND)) 798 - dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_ssthresh) >> 1; 799 - if (dst->metrics[RTAX_SSTHRESH-1] && 800 !dst_metric_locked(dst, RTAX_SSTHRESH) && 801 - tp->snd_ssthresh > dst->metrics[RTAX_SSTHRESH-1]) 802 dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh; 803 } 804 805 if (!dst_metric_locked(dst, RTAX_REORDERING)) { 806 - if (dst->metrics[RTAX_REORDERING-1] < tp->reordering && 807 tp->reordering != sysctl_tcp_reordering) 808 dst->metrics[RTAX_REORDERING-1] = tp->reordering; 809 }
··· 66 #include <linux/mm.h> 67 #include <linux/module.h> 68 #include <linux/sysctl.h> 69 + #include <net/dst.h> 70 #include <net/tcp.h> 71 #include <net/inet_common.h> 72 #include <linux/ipsec.h> ··· 605 u32 rto_min = TCP_RTO_MIN; 606 607 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) 608 + rto_min = dst_metric(dst, RTAX_RTO_MIN); 609 return rto_min; 610 } 611 ··· 769 dst->metrics[RTAX_RTTVAR - 1] = m; 770 else 771 dst->metrics[RTAX_RTTVAR-1] -= 772 + (dst_metric(dst, RTAX_RTTVAR) - m)>>2; 773 } 774 775 if (tp->snd_ssthresh >= 0xFFFF) { ··· 788 dst->metrics[RTAX_SSTHRESH-1] = 789 max(tp->snd_cwnd >> 1, tp->snd_ssthresh); 790 if (!dst_metric_locked(dst, RTAX_CWND)) 791 + dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_cwnd) >> 1; 792 } else { 793 /* Else slow start did not finish, cwnd is non-sense, 794 ssthresh may be also invalid. 795 */ 796 if (!dst_metric_locked(dst, RTAX_CWND)) 797 + dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_ssthresh) >> 1; 798 + if (dst_metric(dst, RTAX_SSTHRESH) && 799 !dst_metric_locked(dst, RTAX_SSTHRESH) && 800 + tp->snd_ssthresh > dst_metric(dst, RTAX_SSTHRESH)) 801 dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh; 802 } 803 804 if (!dst_metric_locked(dst, RTAX_REORDERING)) { 805 + if (dst_metric(dst, RTAX_REORDERING) < tp->reordering && 806 tp->reordering != sysctl_tcp_reordering) 807 dst->metrics[RTAX_REORDERING-1] = tp->reordering; 808 }
+3 -3
net/ipv6/route.c
··· 1243 } 1244 } 1245 1246 - if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) 1247 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; 1248 - if (!rt->u.dst.metrics[RTAX_MTU-1]) 1249 rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); 1250 - if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) 1251 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); 1252 rt->u.dst.dev = dev; 1253 rt->rt6i_idev = idev;
··· 1243 } 1244 } 1245 1246 + if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) 1247 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; 1248 + if (!dst_metric(&rt->u.dst, RTAX_MTU)) 1249 rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); 1250 + if (!dst_metric(&rt->u.dst, RTAX_ADVMSS)) 1251 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); 1252 rt->u.dst.dev = dev; 1253 rt->rt6i_idev = idev;