12 #include <linux/module.h>
15 #include <linux/ipv6.h>
16 #include <linux/tcp.h>
19 #include <linux/netfilter/x_tables.h>
25 if (opt[offset] <=
TCPOPT_NOP || opt[offset+1] == 0)
34 unsigned int tcphoff,
unsigned int minlen)
36 unsigned int optl,
i,
j;
44 tcph = (
struct tcphdr *)(skb_network_header(skb) + tcphoff);
51 for (i =
sizeof(
struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
52 optl = optlen(opt, i);
54 if (i + optl > tcp_hdrlen(skb))
60 for (j = 0; j < optl; ++
j) {
63 if ((i + j) % 2 == 0) {
67 inet_proto_csum_replace2(&tcph->
check, skb,
htons(o),
79 return tcpoptstrip_mangle_packet(skb, par->
targinfo, ip_hdrlen(skb),
83 #if IS_ENABLED(CONFIG_IP6_NF_MANGLE)
87 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
97 return tcpoptstrip_mangle_packet(skb, par->
targinfo, tcphoff,
98 sizeof(*ipv6h) +
sizeof(
struct tcphdr));
104 .name =
"TCPOPTSTRIP",
108 .target = tcpoptstrip_tg4,
112 #if IS_ENABLED(CONFIG_IP6_NF_MANGLE)
114 .name =
"TCPOPTSTRIP",
118 .target = tcpoptstrip_tg6,
125 static int __init tcpoptstrip_tg_init(
void)
131 static void __exit tcpoptstrip_tg_exit(
void)