1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2 #include <linux/types.h>
3 #include <linux/module.h>
5 #include <linux/ipv6.h>
9 #include <linux/netfilter/x_tables.h>
11 #include <linux/netfilter_ipv4/ip_tables.h>
12 #include <linux/netfilter_ipv6/ip6_tables.h>
27 return (port >= min && port <= max) ^ invert;
49 op = skb_header_pointer(skb, protoff +
sizeof(
struct tcphdr),
56 for (i = 0; i < optlen; ) {
57 if (op[i] == option)
return !invert;
79 pr_debug(
"Dropping evil TCP offset=1 frag.\n");
86 #define FWINVTCP(bool, invflg) ((bool) ^ !!(tcpinfo->invflags & (invflg)))
88 th = skb_header_pointer(skb, par->
thoff,
sizeof(_tcph), &_tcph);
92 pr_debug(
"Dropping evil TCP offset=0 tinygram.\n");
97 if (!port_match(tcpinfo->
spts[0], tcpinfo->
spts[1],
101 if (!port_match(tcpinfo->
dpts[0], tcpinfo->
dpts[1],
110 if (th->doff * 4 <
sizeof(_tcph)) {
114 if (!tcp_find_option(tcpinfo->
option, skb, par->
thoff,
115 th->doff*4 -
sizeof(_tcph),
141 uh = skb_header_pointer(skb, par->
thoff,
sizeof(_udph), &_udph);
145 pr_debug(
"Dropping evil UDP tinygram.\n");
150 return port_match(udpinfo->
spts[0], udpinfo->
spts[1],
153 && port_match(udpinfo->
dpts[0], udpinfo->
dpts[1],
170 .checkentry = tcp_mt_check,
172 .matchsize =
sizeof(
struct xt_tcp),
179 .checkentry = tcp_mt_check,
181 .matchsize =
sizeof(
struct xt_tcp),
188 .checkentry = udp_mt_check,
190 .matchsize =
sizeof(
struct xt_udp),
197 .checkentry = udp_mt_check,
199 .matchsize =
sizeof(
struct xt_udp),
206 .checkentry = udp_mt_check,
208 .matchsize =
sizeof(
struct xt_udp),
215 .checkentry = udp_mt_check,
217 .matchsize =
sizeof(
struct xt_udp),
223 static int __init tcpudp_mt_init(
void)
228 static void __exit tcpudp_mt_exit(
void)