Skip to content

Commit ce556b3

Browse files
kaberDavid S. Miller
authored andcommitted
[NETFILTER]: xt_tcpmss: minor cleanups
- remove unused define - remove useless wrapper function - use new line for expression after condition Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5fa2a76 commit ce556b3

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

net/netfilter/xt_tcpmss.c

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@
1818
#include <linux/netfilter_ipv4/ip_tables.h>
1919
#include <linux/netfilter_ipv6/ip6_tables.h>
2020

21-
#define TH_SYN 0x02
22-
2321
MODULE_LICENSE("GPL");
2422
MODULE_AUTHOR("Marc Boucher <[email protected]>");
2523
MODULE_DESCRIPTION("iptables TCP MSS match module");
2624
MODULE_ALIAS("ipt_tcpmss");
2725

28-
/* Returns 1 if the mss option is set and matched by the range, 0 otherwise */
29-
static inline int
30-
mssoption_match(u_int16_t min, u_int16_t max,
31-
const struct sk_buff *skb,
32-
unsigned int protoff,
33-
int invert,
34-
int *hotdrop)
26+
static int
27+
match(const struct sk_buff *skb,
28+
const struct net_device *in,
29+
const struct net_device *out,
30+
const struct xt_match *match,
31+
const void *matchinfo,
32+
int offset,
33+
unsigned int protoff,
34+
int *hotdrop)
3535
{
36+
const struct xt_tcpmss_match_info *info = matchinfo;
3637
struct tcphdr _tcph, *th;
3738
/* tcp.doff is only 4 bits, ie. max 15 * 4 bytes */
3839
u8 _opt[15 * 4 - sizeof(_tcph)], *op;
@@ -64,35 +65,22 @@ mssoption_match(u_int16_t min, u_int16_t max,
6465

6566
mssval = (op[i+2] << 8) | op[i+3];
6667

67-
return (mssval >= min && mssval <= max) ^ invert;
68+
return (mssval >= info->mss_min &&
69+
mssval <= info->mss_max) ^ info->invert;
6870
}
69-
if (op[i] < 2) i++;
70-
else i += op[i+1]?:1;
71+
if (op[i] < 2)
72+
i++;
73+
else
74+
i += op[i+1] ? : 1;
7175
}
7276
out:
73-
return invert;
77+
return info->invert;
7478

75-
dropit:
79+
dropit:
7680
*hotdrop = 1;
7781
return 0;
7882
}
7983

80-
static int
81-
match(const struct sk_buff *skb,
82-
const struct net_device *in,
83-
const struct net_device *out,
84-
const struct xt_match *match,
85-
const void *matchinfo,
86-
int offset,
87-
unsigned int protoff,
88-
int *hotdrop)
89-
{
90-
const struct xt_tcpmss_match_info *info = matchinfo;
91-
92-
return mssoption_match(info->mss_min, info->mss_max, skb, protoff,
93-
info->invert, hotdrop);
94-
}
95-
9684
static struct xt_match xt_tcpmss_match[] = {
9785
{
9886
.name = "tcpmss",

0 commit comments

Comments
 (0)