#include "compat_xtables.h"
#define PFX KBUILD_MODNAME ": "
-static void delude_send_reset(struct net *net, struct sock *sk,
- struct sk_buff *oldskb, unsigned int hook)
+static void delude_send_reset(struct sk_buff *oldskb,
+ const struct xt_action_param *par)
{
struct tcphdr _otcph, *tcph;
const struct tcphdr *oth;
return;
/* Check checksum */
- if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP))
+ if (nf_ip_checksum(oldskb, par->state->hook, ip_hdrlen(oldskb),
+ IPPROTO_TCP))
return;
nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) +
addr_type = RTN_UNSPEC;
#ifdef CONFIG_BRIDGE_NETFILTER
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
- if (hook != NF_INET_FORWARD || ((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF) != NULL &&
+ if (par->state->hook != NF_INET_FORWARD ||
+ ((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF) != NULL &&
((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF))->physoutdev))
#else
- if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
+ if (par->state->hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
nskb->nf_bridge->physoutdev))
#endif
#else
- if (hook != NF_INET_FORWARD)
+ if (par->state->hook != NF_INET_FORWARD)
#endif
addr_type = RTN_LOCAL;
/* ip_route_me_harder expects skb->dst to be set */
skb_dst_set(nskb, dst_clone(skb_dst(oldskb)));
- if (ip_route_me_harder(net, sk, nskb, addr_type))
+ if (ip_route_me_harder(par_net(par), par->state->sk, nskb, addr_type))
goto free_nskb;
else
niph = ip_hdr(nskb);
goto free_nskb;
nf_ct_attach(nskb, oldskb);
-
- ip_local_out(net, nskb->sk, nskb);
+ ip_local_out(par_net(par), nskb->sk, nskb);
return;
free_nskb:
* a problem, as that is supported since Linux 2.6.35. But since we do not
* actually want to have a connection open, we are still going to drop it.
*/
- delude_send_reset(par_net(par), par->state->sk, skb, par->state->hook);
+ delude_send_reset(skb, par);
return NF_DROP;
}
return true;
}
-static void tarpit_tcp4(struct net *net, struct sock *sk,
- struct sk_buff *oldskb, unsigned int hook, unsigned int mode)
+static void tarpit_tcp4(const struct xt_action_param *par,
+ struct sk_buff *oldskb, unsigned int mode)
{
struct tcphdr _otcph, *tcph;
const struct tcphdr *oth;
return;
/* Check checksum. */
- if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP))
+ if (nf_ip_checksum(oldskb, par->state->hook, ip_hdrlen(oldskb),
+ IPPROTO_TCP))
return;
/*
#ifdef CONFIG_BRIDGE_NETFILTER
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
- if (hook != NF_INET_FORWARD || ((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF) != NULL &&
+ if (par->state->hook != NF_INET_FORWARD ||
+ ((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF) != NULL &&
((struct nf_bridge_info *)skb_ext_find(nskb, SKB_EXT_BRIDGE_NF))->physoutdev))
#else
- if (hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
+ if (par->state->hook != NF_INET_FORWARD || (nskb->nf_bridge != NULL &&
nskb->nf_bridge->physoutdev != NULL))
#endif
#else
- if (hook != NF_INET_FORWARD)
+ if (par->state->hook != NF_INET_FORWARD)
#endif
addr_type = RTN_LOCAL;
- if (ip_route_me_harder(net, sk, nskb, addr_type) != 0)
+ if (ip_route_me_harder(par_net(par), par->state->sk, nskb, addr_type) != 0)
goto free_nskb;
else
niph = ip_hdr(nskb);
goto free_nskb;
nf_ct_attach(nskb, oldskb);
- NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
- skb_dst(nskb)->dev, dst_output);
+ NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, par_net(par), nskb->sk, nskb,
+ NULL, skb_dst(nskb)->dev, dst_output);
return;
free_nskb:
}
#ifdef WITH_IPV6
-static void tarpit_tcp6(struct net *net, struct sock *sock,
- struct sk_buff *oldskb, unsigned int hook, unsigned int mode)
+static void tarpit_tcp6(const struct xt_action_param *par,
+ struct sk_buff *oldskb, unsigned int mode)
{
struct sk_buff *nskb;
struct tcphdr *tcph, oth;
&ipv6_hdr(nskb)->daddr, sizeof(struct tcphdr),
IPPROTO_TCP,
csum_partial(tcph, sizeof(struct tcphdr), 0));
- if (ip6_route_me_harder(net, nskb->sk, nskb))
+ if (ip6_route_me_harder(par_net(par), nskb->sk, nskb))
goto free_nskb;
nskb->ip_summed = CHECKSUM_NONE;
nf_ct_attach(nskb, oldskb);
- NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, nskb->sk, nskb, NULL,
- skb_dst(nskb)->dev, dst_output);
+ NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, par_net(par), nskb->sk, nskb,
+ NULL, skb_dst(nskb)->dev, dst_output);
return;
free_nskb:
/* We are not interested in fragments */
if (iph->frag_off & htons(IP_OFFSET))
return NF_DROP;
- tarpit_tcp4(par_net(par), par->state->sk, skb, par->state->hook,
- info->variant);
+ tarpit_tcp4(par, skb, info->variant);
return NF_DROP;
}
pr_debug("addr is not unicast.\n");
return NF_DROP;
}
- tarpit_tcp6(par_net(par), par->state->sk, skb, par->state->hook,
- info->variant);
+ tarpit_tcp6(par, skb, info->variant);
return NF_DROP;
}
#endif