13 #include <linux/module.h>
15 #include <linux/netfilter_ipv4/ip_tables.h>
16 #include <linux/slab.h>
23 #define FILTER_VALID_HOOKS ((1 << NF_INET_LOCAL_IN) | \
24 (1 << NF_INET_FORWARD) | \
25 (1 << NF_INET_LOCAL_OUT))
27 static const struct xt_table packet_filter = {
44 ip_hdrlen(skb) <
sizeof(
struct iphdr)))
48 net = dev_net((in !=
NULL) ? in : out);
55 static bool forward =
true;
58 static int __net_init iptable_filter_net_init(
struct net *net)
69 net->
ipv4.iptable_filter =
72 return PTR_RET(net->
ipv4.iptable_filter);
75 static void __net_exit iptable_filter_net_exit(
struct net *net)
81 .init = iptable_filter_net_init,
82 .exit = iptable_filter_net_exit,
85 static int __init iptable_filter_init(
void)
94 filter_ops =
xt_hook_link(&packet_filter, iptable_filter_hook);
95 if (IS_ERR(filter_ops)) {
96 ret = PTR_ERR(filter_ops);
103 static void __exit iptable_filter_fini(
void)