mm: rename deactivate_page to deactivate_file_page
[firefly-linux-kernel-4.4.55.git] / include / linux / netfilter.h
index 2517ece988209a611b324a0bb8ade2b566eeb645..63560d0a8dfe2802ec826d87921a8848fe56e68b 100644 (file)
@@ -44,11 +44,39 @@ int netfilter_init(void);
 struct sk_buff;
 
 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 sock *, struct sk_buff *);
+};
+
+static inline void nf_hook_state_init(struct nf_hook_state *p,
+                                     unsigned int hook,
+                                     int thresh, u_int8_t pf,
+                                     struct net_device *indev,
+                                     struct net_device *outdev,
+                                     struct sock *sk,
+                                     int (*okfn)(struct sock *, struct sk_buff *))
+{
+       p->hook = hook;
+       p->thresh = thresh;
+       p->pf = pf;
+       p->in = indev;
+       p->out = outdev;
+       p->sk = sk;
+       p->okfn = okfn;
+}
+
 typedef unsigned int nf_hookfn(const struct nf_hook_ops *ops,
                               struct sk_buff *skb,
-                              const struct net_device *in,
-                              const struct net_device *out,
-                              int (*okfn)(struct sk_buff *));
+                              const struct nf_hook_state *state);
 
 struct nf_hook_ops {
        struct list_head list;
@@ -118,9 +146,7 @@ static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook)
 }
 #endif
 
-int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
-                struct net_device *indev, struct net_device *outdev,
-                int (*okfn)(struct sk_buff *), int thresh);
+int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
 
 /**
  *     nf_hook_thresh - call a netfilter hook
@@ -130,21 +156,29 @@ int nf_hook_slow(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
  *     value indicates the packet has been consumed by the hook.
  */
 static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
+                                struct sock *sk,
                                 struct sk_buff *skb,
                                 struct net_device *indev,
                                 struct net_device *outdev,
-                                int (*okfn)(struct sk_buff *), int thresh)
+                                int (*okfn)(struct sock *, struct sk_buff *),
+                                int thresh)
 {
-       if (nf_hooks_active(pf, hook))
-               return nf_hook_slow(pf, hook, skb, indev, outdev, okfn, thresh);
+       if (nf_hooks_active(pf, hook)) {
+               struct nf_hook_state state;
+
+               nf_hook_state_init(&state, hook, thresh, pf,
+                                  indev, outdev, sk, okfn);
+               return nf_hook_slow(skb, &state);
+       }
        return 1;
 }
 
-static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
-                         struct net_device *indev, struct net_device *outdev,
-                         int (*okfn)(struct sk_buff *))
+static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
+                         struct sk_buff *skb, struct net_device *indev,
+                         struct net_device *outdev,
+                         int (*okfn)(struct sock *, struct sk_buff *))
 {
-       return nf_hook_thresh(pf, hook, skb, indev, outdev, okfn, INT_MIN);
+       return nf_hook_thresh(pf, hook, sk, skb, indev, outdev, okfn, INT_MIN);
 }
                    
 /* Activate hook; either okfn or kfree_skb called, unless a hook
@@ -165,35 +199,36 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
 */
 
 static inline int
-NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb,
-              struct net_device *in, struct net_device *out,
-              int (*okfn)(struct sk_buff *), int thresh)
+NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk,
+              struct sk_buff *skb, struct net_device *in,
+              struct net_device *out,
+              int (*okfn)(struct sock *, struct sk_buff *), int thresh)
 {
-       int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh);
+       int ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, thresh);
        if (ret == 1)
-               ret = okfn(skb);
+               ret = okfn(sk, skb);
        return ret;
 }
 
 static inline int
-NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sk_buff *skb,
-            struct net_device *in, struct net_device *out,
-            int (*okfn)(struct sk_buff *), bool cond)
+NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk,
+            struct sk_buff *skb, struct net_device *in, struct net_device *out,
+            int (*okfn)(struct sock *, struct sk_buff *), bool cond)
 {
        int ret;
 
        if (!cond ||
-           ((ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, INT_MIN)) == 1))
-               ret = okfn(skb);
+           ((ret = nf_hook_thresh(pf, hook, sk, skb, in, out, okfn, INT_MIN)) == 1))
+               ret = okfn(sk, skb);
        return ret;
 }
 
 static inline int
-NF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
+NF_HOOK(uint8_t pf, unsigned int hook, struct sock *sk, struct sk_buff *skb,
        struct net_device *in, struct net_device *out,
-       int (*okfn)(struct sk_buff *))
+       int (*okfn)(struct sock *, struct sk_buff *))
 {
-       return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, INT_MIN);
+       return NF_HOOK_THRESH(pf, hook, sk, skb, in, out, okfn, INT_MIN);
 }
 
 /* Call setsockopt() */
@@ -293,19 +328,21 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
 }
 
 #else /* !CONFIG_NETFILTER */
-#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
-#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb)
+#define NF_HOOK(pf, hook, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
+#define NF_HOOK_COND(pf, hook, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
 static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
+                                struct sock *sk,
                                 struct sk_buff *skb,
                                 struct net_device *indev,
                                 struct net_device *outdev,
-                                int (*okfn)(struct sk_buff *), int thresh)
+                                int (*okfn)(struct sock *sk, struct sk_buff *), int thresh)
 {
-       return okfn(skb);
+       return okfn(sk, skb);
 }
-static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sk_buff *skb,
-                         struct net_device *indev, struct net_device *outdev,
-                         int (*okfn)(struct sk_buff *))
+static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
+                         struct sk_buff *skb, struct net_device *indev,
+                         struct net_device *outdev,
+                         int (*okfn)(struct sock *, struct sk_buff *))
 {
        return 1;
 }