aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorGao Feng <fgao@ikuai8.com>2016-09-06 22:40:24 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-24 15:13:21 -0400
commit50f4c7b73f831a53fa9ddeb9bdf4cfb5b23d3aa7 (patch)
treeec56a874a264b53e2313340d2c42c9e6cb27ea86 /net
parent4004d5c374dabcbce201e16442e4596b764cc60b (diff)
netfilter: xt_TCPMSS: Refactor the codes to decrease one condition check and more readable
The origin codes perform two condition checks with dst_mtu(skb_dst(skb)) and in_mtu. And the last statement is "min(dst_mtu(skb_dst(skb)), in_mtu) - minlen". It may let reader think about how about the result. Would it be negative. Now assign the result of min(dst_mtu(skb_dst(skb)), in_mtu) to a new variable, then only perform one condition check, and it is more readable. Signed-off-by: Gao Feng <fgao@ikuai8.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/xt_TCPMSS.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index e118397254af..872db2d0e2a9 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -110,18 +110,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
110 if (info->mss == XT_TCPMSS_CLAMP_PMTU) { 110 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
111 struct net *net = par->net; 111 struct net *net = par->net;
112 unsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family); 112 unsigned int in_mtu = tcpmss_reverse_mtu(net, skb, family);
113 unsigned int min_mtu = min(dst_mtu(skb_dst(skb)), in_mtu);
113 114
114 if (dst_mtu(skb_dst(skb)) <= minlen) { 115 if (min_mtu <= minlen) {
115 net_err_ratelimited("unknown or invalid path-MTU (%u)\n", 116 net_err_ratelimited("unknown or invalid path-MTU (%u)\n",
116 dst_mtu(skb_dst(skb))); 117 min_mtu);
117 return -1; 118 return -1;
118 } 119 }
119 if (in_mtu <= minlen) { 120 newmss = min_mtu - minlen;
120 net_err_ratelimited("unknown or invalid path-MTU (%u)\n",
121 in_mtu);
122 return -1;
123 }
124 newmss = min(dst_mtu(skb_dst(skb)), in_mtu) - minlen;
125 } else 121 } else
126 newmss = info->mss; 122 newmss = info->mss;
127 123