@@ -54,7 +54,7 @@ struct nf_hook_state {
5454 struct net_device * in ;
5555 struct net_device * out ;
5656 struct sock * sk ;
57- int (* okfn )(struct sk_buff * );
57+ int (* okfn )(struct sock * , struct sk_buff * );
5858};
5959
6060static inline void nf_hook_state_init (struct nf_hook_state * p ,
@@ -63,7 +63,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
6363 struct net_device * indev ,
6464 struct net_device * outdev ,
6565 struct sock * sk ,
66- int (* okfn )(struct sk_buff * ))
66+ int (* okfn )(struct sock * , struct sk_buff * ))
6767{
6868 p -> hook = hook ;
6969 p -> thresh = thresh ;
@@ -156,26 +156,29 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
156156 * value indicates the packet has been consumed by the hook.
157157 */
158158static inline int nf_hook_thresh (u_int8_t pf , unsigned int hook ,
159+ struct sock * sk ,
159160 struct sk_buff * skb ,
160161 struct net_device * indev ,
161162 struct net_device * outdev ,
162- int (* okfn )(struct sk_buff * ), int thresh )
163+ int (* okfn )(struct sock * , struct sk_buff * ),
164+ int thresh )
163165{
164166 if (nf_hooks_active (pf , hook )) {
165167 struct nf_hook_state state ;
166168
167169 nf_hook_state_init (& state , hook , thresh , pf ,
168- indev , outdev , NULL , okfn );
170+ indev , outdev , sk , okfn );
169171 return nf_hook_slow (skb , & state );
170172 }
171173 return 1 ;
172174}
173175
174- static inline int nf_hook (u_int8_t pf , unsigned int hook , struct sk_buff * skb ,
175- struct net_device * indev , struct net_device * outdev ,
176- int (* okfn )(struct sk_buff * ))
176+ static inline int nf_hook (u_int8_t pf , unsigned int hook , struct sock * sk ,
177+ struct sk_buff * skb , struct net_device * indev ,
178+ struct net_device * outdev ,
179+ int (* okfn )(struct sock * , struct sk_buff * ))
177180{
178- return nf_hook_thresh (pf , hook , skb , indev , outdev , okfn , INT_MIN );
181+ return nf_hook_thresh (pf , hook , sk , skb , indev , outdev , okfn , INT_MIN );
179182}
180183
181184/* Activate hook; either okfn or kfree_skb called, unless a hook
@@ -196,35 +199,36 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
196199*/
197200
198201static inline int
199- NF_HOOK_THRESH (uint8_t pf , unsigned int hook , struct sk_buff * skb ,
200- struct net_device * in , struct net_device * out ,
201- int (* okfn )(struct sk_buff * ), int thresh )
202+ NF_HOOK_THRESH (uint8_t pf , unsigned int hook , struct sock * sk ,
203+ struct sk_buff * skb , struct net_device * in ,
204+ struct net_device * out ,
205+ int (* okfn )(struct sock * , struct sk_buff * ), int thresh )
202206{
203- int ret = nf_hook_thresh (pf , hook , skb , in , out , okfn , thresh );
207+ int ret = nf_hook_thresh (pf , hook , sk , skb , in , out , okfn , thresh );
204208 if (ret == 1 )
205- ret = okfn (skb );
209+ ret = okfn (sk , skb );
206210 return ret ;
207211}
208212
209213static inline int
210- NF_HOOK_COND (uint8_t pf , unsigned int hook , struct sk_buff * skb ,
211- struct net_device * in , struct net_device * out ,
212- int (* okfn )(struct sk_buff * ), bool cond )
214+ NF_HOOK_COND (uint8_t pf , unsigned int hook , struct sock * sk ,
215+ struct sk_buff * skb , struct net_device * in , struct net_device * out ,
216+ int (* okfn )(struct sock * , struct sk_buff * ), bool cond )
213217{
214218 int ret ;
215219
216220 if (!cond ||
217- ((ret = nf_hook_thresh (pf , hook , skb , in , out , okfn , INT_MIN )) == 1 ))
218- ret = okfn (skb );
221+ ((ret = nf_hook_thresh (pf , hook , sk , skb , in , out , okfn , INT_MIN )) == 1 ))
222+ ret = okfn (sk , skb );
219223 return ret ;
220224}
221225
222226static inline int
223- NF_HOOK (uint8_t pf , unsigned int hook , struct sk_buff * skb ,
227+ NF_HOOK (uint8_t pf , unsigned int hook , struct sock * sk , struct sk_buff * skb ,
224228 struct net_device * in , struct net_device * out ,
225- int (* okfn )(struct sk_buff * ))
229+ int (* okfn )(struct sock * , struct sk_buff * ))
226230{
227- return NF_HOOK_THRESH (pf , hook , skb , in , out , okfn , INT_MIN );
231+ return NF_HOOK_THRESH (pf , hook , sk , skb , in , out , okfn , INT_MIN );
228232}
229233
230234/* Call setsockopt() */
@@ -324,19 +328,21 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
324328}
325329
326330#else /* !CONFIG_NETFILTER */
327- #define NF_HOOK (pf , hook , skb , indev , outdev , okfn ) (okfn)(skb)
328- #define NF_HOOK_COND (pf , hook , skb , indev , outdev , okfn , cond ) (okfn)(skb)
331+ #define NF_HOOK (pf , hook , sk , skb , indev , outdev , okfn ) (okfn)(sk, skb)
332+ #define NF_HOOK_COND (pf , hook , sk , skb , indev , outdev , okfn , cond ) (okfn)(sk, skb)
329333static inline int nf_hook_thresh (u_int8_t pf , unsigned int hook ,
334+ struct sock * sk ,
330335 struct sk_buff * skb ,
331336 struct net_device * indev ,
332337 struct net_device * outdev ,
333- int (* okfn )(struct sk_buff * ), int thresh )
338+ int (* okfn )(struct sock * sk , struct sk_buff * ), int thresh )
334339{
335- return okfn (skb );
340+ return okfn (sk , skb );
336341}
337- static inline int nf_hook (u_int8_t pf , unsigned int hook , struct sk_buff * skb ,
338- struct net_device * indev , struct net_device * outdev ,
339- int (* okfn )(struct sk_buff * ))
342+ static inline int nf_hook (u_int8_t pf , unsigned int hook , struct sock * sk ,
343+ struct sk_buff * skb , struct net_device * indev ,
344+ struct net_device * outdev ,
345+ int (* okfn )(struct sock * , struct sk_buff * ))
340346{
341347 return 1 ;
342348}
0 commit comments