11 #include <linux/module.h>
12 #include <linux/netfilter_ipv6/ip6_tables.h>
13 #include <linux/slab.h>
19 #define MANGLE_VALID_HOOKS ((1 << NF_INET_PRE_ROUTING) | \
20 (1 << NF_INET_LOCAL_IN) | \
21 (1 << NF_INET_FORWARD) | \
22 (1 << NF_INET_LOCAL_OUT) | \
23 (1 << NF_INET_POST_ROUTING))
25 static const struct xt_table packet_mangler = {
43 if (skb->
len <
sizeof(
struct iphdr) ||
44 ip_hdrlen(skb) <
sizeof(
struct iphdr)) {
54 hop_limit = ipv6_hdr(skb)->hop_limit;
57 flowlabel = *((
u_int32_t *)ipv6_hdr(skb));
60 dev_net(out)->ipv6.ip6table_mangle);
66 ipv6_hdr(skb)->hop_limit != hop_limit ||
67 flowlabel != *((
u_int32_t *)ipv6_hdr(skb))))
75 ip6table_mangle_hook(
unsigned int hook,
struct sk_buff *skb,
80 return ip6t_mangle_out(skb, out);
83 dev_net(out)->ipv6.ip6table_mangle);
86 dev_net(in)->ipv6.ip6table_mangle);
97 net->ipv6.ip6table_mangle =
100 return PTR_RET(net->ipv6.ip6table_mangle);
103 static void __net_exit ip6table_mangle_net_exit(
struct net *net)
109 .init = ip6table_mangle_net_init,
110 .exit = ip6table_mangle_net_exit,
113 static int __init ip6table_mangle_init(
void)
122 mangle_ops =
xt_hook_link(&packet_mangler, ip6table_mangle_hook);
123 if (IS_ERR(mangle_ops)) {
124 ret = PTR_ERR(mangle_ops);
135 static void __exit ip6table_mangle_fini(
void)