aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-09-20 14:58:35 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:19:47 -0400
commit68e1f188de535865d4543bae92d168c007857e7b (patch)
tree78f38adad0eb1bd6325d0c1744404d58bc355ada /net/ipv4
parent50b9f1d509eb998db73cd769c9511186474f566e (diff)
[NETFILTER]: ipt_TCPMSS: reformat
- fix whitespace error - break lines at 80 characters - reformat some expressions to be more readable Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/ipt_TCPMSS.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
index ac8a35eeea3f..bfc8d9c7d020 100644
--- a/net/ipv4/netfilter/ipt_TCPMSS.c
+++ b/net/ipv4/netfilter/ipt_TCPMSS.c
@@ -31,8 +31,10 @@ static inline unsigned int
31optlen(const u_int8_t *opt, unsigned int offset) 31optlen(const u_int8_t *opt, unsigned int offset)
32{ 32{
33 /* Beware zero-length options: make finite progress */ 33 /* Beware zero-length options: make finite progress */
34 if (opt[offset] <= TCPOPT_NOP || opt[offset+1] == 0) return 1; 34 if (opt[offset] <= TCPOPT_NOP || opt[offset+1] == 0)
35 else return opt[offset+1]; 35 return 1;
36 else
37 return opt[offset+1];
36} 38}
37 39
38static unsigned int 40static unsigned int
@@ -55,7 +57,6 @@ ipt_tcpmss_target(struct sk_buff **pskb,
55 57
56 iph = (*pskb)->nh.iph; 58 iph = (*pskb)->nh.iph;
57 tcplen = (*pskb)->len - iph->ihl*4; 59 tcplen = (*pskb)->len - iph->ihl*4;
58
59 tcph = (void *)iph + iph->ihl*4; 60 tcph = (void *)iph + iph->ihl*4;
60 61
61 /* Since it passed flags test in tcp match, we know it is is 62 /* Since it passed flags test in tcp match, we know it is is
@@ -71,37 +72,39 @@ ipt_tcpmss_target(struct sk_buff **pskb,
71 return NF_DROP; 72 return NF_DROP;
72 } 73 }
73 74
74 if(tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU) { 75 if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU) {
75 if(!(*pskb)->dst) { 76 if (!(*pskb)->dst) {
76 if (net_ratelimit()) 77 if (net_ratelimit())
77 printk(KERN_ERR 78 printk(KERN_ERR "ipt_tcpmss_target: "
78 "ipt_tcpmss_target: no dst?! can't determine path-MTU\n"); 79 "no dst?! can't determine path-MTU\n");
79 return NF_DROP; /* or IPT_CONTINUE ?? */ 80 return NF_DROP; /* or IPT_CONTINUE ?? */
80 } 81 }
81 82
82 if(dst_mtu((*pskb)->dst) <= (sizeof(struct iphdr) + sizeof(struct tcphdr))) { 83 if (dst_mtu((*pskb)->dst) <= sizeof(struct iphdr) +
84 sizeof(struct tcphdr)) {
83 if (net_ratelimit()) 85 if (net_ratelimit())
84 printk(KERN_ERR 86 printk(KERN_ERR "ipt_tcpmss_target: "
85 "ipt_tcpmss_target: unknown or invalid path-MTU (%d)\n", dst_mtu((*pskb)->dst)); 87 "unknown or invalid path-MTU (%d)\n",
88 dst_mtu((*pskb)->dst));
86 return NF_DROP; /* or IPT_CONTINUE ?? */ 89 return NF_DROP; /* or IPT_CONTINUE ?? */
87 } 90 }
88 91
89 newmss = dst_mtu((*pskb)->dst) - sizeof(struct iphdr) - sizeof(struct tcphdr); 92 newmss = dst_mtu((*pskb)->dst) - sizeof(struct iphdr) -
93 sizeof(struct tcphdr);
90 } else 94 } else
91 newmss = tcpmssinfo->mss; 95 newmss = tcpmssinfo->mss;
92 96
93 opt = (u_int8_t *)tcph; 97 opt = (u_int8_t *)tcph;
94 for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)){ 98 for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
95 if ((opt[i] == TCPOPT_MSS) && 99 if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
96 ((tcph->doff*4 - i) >= TCPOLEN_MSS) && 100 opt[i+1] == TCPOLEN_MSS) {
97 (opt[i+1] == TCPOLEN_MSS)) {
98 u_int16_t oldmss; 101 u_int16_t oldmss;
99 102
100 oldmss = (opt[i+2] << 8) | opt[i+3]; 103 oldmss = (opt[i+2] << 8) | opt[i+3];
101 104
102 if((tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU) && 105 if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU &&
103 (oldmss <= newmss)) 106 oldmss <= newmss)
104 return IPT_CONTINUE; 107 return IPT_CONTINUE;
105 108
106 opt[i+2] = (newmss & 0xff00) >> 8; 109 opt[i+2] = (newmss & 0xff00) >> 8;
107 opt[i+3] = (newmss & 0x00ff); 110 opt[i+3] = (newmss & 0x00ff);
@@ -113,7 +116,7 @@ ipt_tcpmss_target(struct sk_buff **pskb,
113 116
114 DEBUGP(KERN_INFO "ipt_tcpmss_target: %u.%u.%u.%u:%hu" 117 DEBUGP(KERN_INFO "ipt_tcpmss_target: %u.%u.%u.%u:%hu"
115 "->%u.%u.%u.%u:%hu changed TCP MSS option" 118 "->%u.%u.%u.%u:%hu changed TCP MSS option"
116 " (from %u to %u)\n", 119 " (from %u to %u)\n",
117 NIPQUAD((*pskb)->nh.iph->saddr), 120 NIPQUAD((*pskb)->nh.iph->saddr),
118 ntohs(tcph->source), 121 ntohs(tcph->source),
119 NIPQUAD((*pskb)->nh.iph->daddr), 122 NIPQUAD((*pskb)->nh.iph->daddr),
@@ -193,9 +196,9 @@ static inline int find_syn_match(const struct ipt_entry_match *m)
193{ 196{
194 const struct ipt_tcp *tcpinfo = (const struct ipt_tcp *)m->data; 197 const struct ipt_tcp *tcpinfo = (const struct ipt_tcp *)m->data;
195 198
196 if (strcmp(m->u.kernel.match->name, "tcp") == 0 199 if (strcmp(m->u.kernel.match->name, "tcp") == 0 &&
197 && (tcpinfo->flg_cmp & TH_SYN) 200 tcpinfo->flg_cmp & TH_SYN &&
198 && !(tcpinfo->invflags & IPT_TCP_INV_FLAGS)) 201 !(tcpinfo->invflags & IPT_TCP_INV_FLAGS))
199 return 1; 202 return 1;
200 203
201 return 0; 204 return 0;
@@ -212,11 +215,12 @@ ipt_tcpmss_checkentry(const char *tablename,
212 const struct ipt_tcpmss_info *tcpmssinfo = targinfo; 215 const struct ipt_tcpmss_info *tcpmssinfo = targinfo;
213 const struct ipt_entry *e = e_void; 216 const struct ipt_entry *e = e_void;
214 217
215 if((tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU) && 218 if (tcpmssinfo->mss == IPT_TCPMSS_CLAMP_PMTU &&
216 ((hook_mask & ~((1 << NF_IP_FORWARD) 219 (hook_mask & ~((1 << NF_IP_FORWARD) |
217 | (1 << NF_IP_LOCAL_OUT) 220 (1 << NF_IP_LOCAL_OUT) |
218 | (1 << NF_IP_POST_ROUTING))) != 0)) { 221 (1 << NF_IP_POST_ROUTING))) != 0) {
219 printk("TCPMSS: path-MTU clamping only supported in FORWARD, OUTPUT and POSTROUTING hooks\n"); 222 printk("TCPMSS: path-MTU clamping only supported in "
223 "FORWARD, OUTPUT and POSTROUTING hooks\n");
220 return 0; 224 return 0;
221 } 225 }
222 226