Skip to content

Commit 107a9f4

Browse files
committed
netfilter: Add nf_hook_state initializer function.
This way we can consolidate where we setup new nf_hook_state objects, to make sure the entire thing is initialized. The only other place an nf_hook_object is instantiated is nf_queue, wherein a structure copy is used. Signed-off-by: David S. Miller <[email protected]>
1 parent a3786a5 commit 107a9f4

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

include/linux/netfilter.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ struct nf_hook_state {
5454
int (*okfn)(struct sk_buff *);
5555
};
5656

57+
static inline void nf_hook_state_init(struct nf_hook_state *p,
58+
unsigned int hook,
59+
int thresh, u_int8_t pf,
60+
struct net_device *indev,
61+
struct net_device *outdev,
62+
int (*okfn)(struct sk_buff *))
63+
{
64+
p->hook = hook;
65+
p->thresh = thresh;
66+
p->pf = pf;
67+
p->in = indev;
68+
p->out = outdev;
69+
p->okfn = okfn;
70+
}
71+
5772
typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
5873
struct sk_buff *skb,
5974
const struct nf_hook_state *state);
@@ -142,15 +157,10 @@ static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
142157
int (*okfn)(struct sk_buff *), int thresh)
143158
{
144159
if (nf_hooks_active(pf, hook)) {
145-
struct nf_hook_state state = {
146-
.hook = hook,
147-
.thresh = thresh,
148-
.pf = pf,
149-
.in = indev,
150-
.out = outdev,
151-
.okfn = okfn
152-
};
160+
struct nf_hook_state state;
153161

162+
nf_hook_state_init(&state, hook, thresh, pf,
163+
indev, outdev, okfn);
154164
return nf_hook_slow(skb, &state);
155165
}
156166
return 1;

0 commit comments

Comments
 (0)