Skip to content

Commit 5ffc02a

Browse files
ssatodavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0bbeafd commit 5ffc02a

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

net/decnet/dn_route.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
235235
else
236236
min_mtu -= 21;
237237

238-
if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= min_mtu) {
238+
if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) {
239239
if (!(dst_metric_locked(dst, RTAX_MTU))) {
240240
dst->metrics[RTAX_MTU-1] = mtu;
241241
dst_set_expires(dst, dn_rt_mtu_expires);
242242
}
243243
if (!(dst_metric_locked(dst, RTAX_ADVMSS))) {
244244
u32 mss = mtu - DN_MAX_NSP_DATA_HEADER;
245-
if (dst->metrics[RTAX_ADVMSS-1] > mss)
245+
if (dst_metric(dst, RTAX_ADVMSS) > mss)
246246
dst->metrics[RTAX_ADVMSS-1] = mss;
247247
}
248248
}
@@ -805,12 +805,12 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
805805
rt->u.dst.neighbour = n;
806806
}
807807

808-
if (rt->u.dst.metrics[RTAX_MTU-1] == 0 ||
809-
rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu)
808+
if (dst_metric(&rt->u.dst, RTAX_MTU) == 0 ||
809+
dst_metric(&rt->u.dst, RTAX_MTU) > rt->u.dst.dev->mtu)
810810
rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
811811
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)
812+
if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0 ||
813+
dst_metric(&rt->u.dst, RTAX_ADVMSS) > mss)
814814
rt->u.dst.metrics[RTAX_ADVMSS-1] = mss;
815815
return 0;
816816
}

net/ipv4/route.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,14 +1468,14 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
14681468

14691469
/* BSD 4.2 compatibility hack :-( */
14701470
if (mtu == 0 &&
1471-
old_mtu >= rth->u.dst.metrics[RTAX_MTU-1] &&
1471+
old_mtu >= dst_metric(&rth->u.dst, RTAX_MTU) &&
14721472
old_mtu >= 68 + (iph->ihl << 2))
14731473
old_mtu -= iph->ihl << 2;
14741474

14751475
mtu = guess_mtu(old_mtu);
14761476
}
1477-
if (mtu <= rth->u.dst.metrics[RTAX_MTU-1]) {
1478-
if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) {
1477+
if (mtu <= dst_metric(&rth->u.dst, RTAX_MTU)) {
1478+
if (mtu < dst_metric(&rth->u.dst, RTAX_MTU)) {
14791479
dst_confirm(&rth->u.dst);
14801480
if (mtu < ip_rt_min_pmtu) {
14811481
mtu = ip_rt_min_pmtu;
@@ -1497,7 +1497,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
14971497

14981498
static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
14991499
{
1500-
if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= 68 &&
1500+
if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= 68 &&
15011501
!(dst_metric_locked(dst, RTAX_MTU))) {
15021502
if (mtu < ip_rt_min_pmtu) {
15031503
mtu = ip_rt_min_pmtu;
@@ -1624,14 +1624,14 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
16241624
} else
16251625
rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu;
16261626

1627-
if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0)
1627+
if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0)
16281628
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl;
1629-
if (rt->u.dst.metrics[RTAX_MTU-1] > IP_MAX_MTU)
1629+
if (dst_metric(&rt->u.dst, RTAX_MTU) > IP_MAX_MTU)
16301630
rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU;
1631-
if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0)
1631+
if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0)
16321632
rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40,
16331633
ip_rt_min_advmss);
1634-
if (rt->u.dst.metrics[RTAX_ADVMSS-1] > 65535 - 40)
1634+
if (dst_metric(&rt->u.dst, RTAX_ADVMSS) > 65535 - 40)
16351635
rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40;
16361636

16371637
#ifdef CONFIG_NET_CLS_ROUTE

net/ipv4/tcp_input.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include <linux/mm.h>
6767
#include <linux/module.h>
6868
#include <linux/sysctl.h>
69+
#include <net/dst.h>
6970
#include <net/tcp.h>
7071
#include <net/inet_common.h>
7172
#include <linux/ipsec.h>
@@ -605,7 +606,7 @@ static u32 tcp_rto_min(struct sock *sk)
605606
u32 rto_min = TCP_RTO_MIN;
606607

607608
if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
608-
rto_min = dst->metrics[RTAX_RTO_MIN - 1];
609+
rto_min = dst_metric(dst, RTAX_RTO_MIN);
609610
return rto_min;
610611
}
611612

@@ -769,7 +770,7 @@ void tcp_update_metrics(struct sock *sk)
769770
dst->metrics[RTAX_RTTVAR - 1] = m;
770771
else
771772
dst->metrics[RTAX_RTTVAR-1] -=
772-
(dst->metrics[RTAX_RTTVAR-1] - m)>>2;
773+
(dst_metric(dst, RTAX_RTTVAR) - m)>>2;
773774
}
774775

775776
if (tp->snd_ssthresh >= 0xFFFF) {
@@ -788,21 +789,21 @@ void tcp_update_metrics(struct sock *sk)
788789
dst->metrics[RTAX_SSTHRESH-1] =
789790
max(tp->snd_cwnd >> 1, tp->snd_ssthresh);
790791
if (!dst_metric_locked(dst, RTAX_CWND))
791-
dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_cwnd) >> 1;
792+
dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_cwnd) >> 1;
792793
} else {
793794
/* Else slow start did not finish, cwnd is non-sense,
794795
ssthresh may be also invalid.
795796
*/
796797
if (!dst_metric_locked(dst, RTAX_CWND))
797-
dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_ssthresh) >> 1;
798-
if (dst->metrics[RTAX_SSTHRESH-1] &&
798+
dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_ssthresh) >> 1;
799+
if (dst_metric(dst, RTAX_SSTHRESH) &&
799800
!dst_metric_locked(dst, RTAX_SSTHRESH) &&
800-
tp->snd_ssthresh > dst->metrics[RTAX_SSTHRESH-1])
801+
tp->snd_ssthresh > dst_metric(dst, RTAX_SSTHRESH))
801802
dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh;
802803
}
803804

804805
if (!dst_metric_locked(dst, RTAX_REORDERING)) {
805-
if (dst->metrics[RTAX_REORDERING-1] < tp->reordering &&
806+
if (dst_metric(dst, RTAX_REORDERING) < tp->reordering &&
806807
tp->reordering != sysctl_tcp_reordering)
807808
dst->metrics[RTAX_REORDERING-1] = tp->reordering;
808809
}

net/ipv6/route.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,11 @@ int ip6_route_add(struct fib6_config *cfg)
12431243
}
12441244
}
12451245

1246-
if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0)
1246+
if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0)
12471247
rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1;
1248-
if (!rt->u.dst.metrics[RTAX_MTU-1])
1248+
if (!dst_metric(&rt->u.dst, RTAX_MTU))
12491249
rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev);
1250-
if (!rt->u.dst.metrics[RTAX_ADVMSS-1])
1250+
if (!dst_metric(&rt->u.dst, RTAX_ADVMSS))
12511251
rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst));
12521252
rt->u.dst.dev = dev;
12531253
rt->rt6i_idev = idev;

0 commit comments

Comments
 (0)