Commit ce556b3a authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: xt_tcpmss: minor cleanups

- remove unused define
- remove useless wrapper function
- use new line for expression after condition
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5fa2a760
...@@ -18,21 +18,22 @@ ...@@ -18,21 +18,22 @@
#include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netfilter_ipv6/ip6_tables.h> #include <linux/netfilter_ipv6/ip6_tables.h>
#define TH_SYN 0x02
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
MODULE_DESCRIPTION("iptables TCP MSS match module"); MODULE_DESCRIPTION("iptables TCP MSS match module");
MODULE_ALIAS("ipt_tcpmss"); MODULE_ALIAS("ipt_tcpmss");
/* Returns 1 if the mss option is set and matched by the range, 0 otherwise */ static int
static inline int match(const struct sk_buff *skb,
mssoption_match(u_int16_t min, u_int16_t max, const struct net_device *in,
const struct sk_buff *skb, const struct net_device *out,
unsigned int protoff, const struct xt_match *match,
int invert, const void *matchinfo,
int *hotdrop) int offset,
unsigned int protoff,
int *hotdrop)
{ {
const struct xt_tcpmss_match_info *info = matchinfo;
struct tcphdr _tcph, *th; struct tcphdr _tcph, *th;
/* tcp.doff is only 4 bits, ie. max 15 * 4 bytes */ /* tcp.doff is only 4 bits, ie. max 15 * 4 bytes */
u8 _opt[15 * 4 - sizeof(_tcph)], *op; u8 _opt[15 * 4 - sizeof(_tcph)], *op;
...@@ -64,35 +65,22 @@ mssoption_match(u_int16_t min, u_int16_t max, ...@@ -64,35 +65,22 @@ mssoption_match(u_int16_t min, u_int16_t max,
mssval = (op[i+2] << 8) | op[i+3]; mssval = (op[i+2] << 8) | op[i+3];
return (mssval >= min && mssval <= max) ^ invert; return (mssval >= info->mss_min &&
mssval <= info->mss_max) ^ info->invert;
} }
if (op[i] < 2) i++; if (op[i] < 2)
else i += op[i+1]?:1; i++;
else
i += op[i+1] ? : 1;
} }
out: out:
return invert; return info->invert;
dropit: dropit:
*hotdrop = 1; *hotdrop = 1;
return 0; return 0;
} }
static int
match(const struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
const struct xt_match *match,
const void *matchinfo,
int offset,
unsigned int protoff,
int *hotdrop)
{
const struct xt_tcpmss_match_info *info = matchinfo;
return mssoption_match(info->mss_min, info->mss_max, skb, protoff,
info->invert, hotdrop);
}
static struct xt_match xt_tcpmss_match[] = { static struct xt_match xt_tcpmss_match[] = {
{ {
.name = "tcpmss", .name = "tcpmss",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment