It is currently always set to NULL, but nf_queue is adjusted to be
prepared for it being set to a real socket by taking and releasing a
reference to that socket when necessary.
Signed-off-by: David S. Miller <davem@davemloft.net>
struct nf_hook_ops;
+struct sock;
+
struct nf_hook_state {
unsigned int hook;
int thresh;
u_int8_t pf;
struct net_device *in;
struct net_device *out;
+ struct sock *sk;
int (*okfn)(struct sk_buff *);
};
int thresh, u_int8_t pf,
struct net_device *indev,
struct net_device *outdev,
+ struct sock *sk,
int (*okfn)(struct sk_buff *))
{
p->hook = hook;
p->pf = pf;
p->in = indev;
p->out = outdev;
+ p->sk = sk;
p->okfn = okfn;
}
struct nf_hook_state state;
nf_hook_state_init(&state, hook, thresh, pf,
- indev, outdev, okfn);
+ indev, outdev, NULL, okfn);
return nf_hook_slow(skb, &state);
}
return 1;
dev_put(state->in);
if (state->out)
dev_put(state->out);
+ if (state->sk)
+ sock_put(state->sk);
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
if (entry->skb->nf_bridge) {
struct nf_bridge_info *nf_bridge = entry->skb->nf_bridge;
dev_hold(state->in);
if (state->out)
dev_hold(state->out);
+ if (state->sk)
+ sock_hold(state->sk);
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
if (entry->skb->nf_bridge) {
struct nf_bridge_info *nf_bridge = entry->skb->nf_bridge;