netfilter: Pass struct net into the netfilter hooks
[deliverable/linux.git] / include / linux / netfilter.h
index 36a652531791e7abfaf5fe55afada5a36425ea75..295f2650b5dc23569ce2eedac593f0802e6e3144 100644 (file)
@@ -54,6 +54,7 @@ struct nf_hook_state {
        struct net_device *in;
        struct net_device *out;
        struct sock *sk;
+       struct net *net;
        struct list_head *hook_list;
        int (*okfn)(struct sock *, struct sk_buff *);
 };
@@ -65,6 +66,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
                                      struct net_device *indev,
                                      struct net_device *outdev,
                                      struct sock *sk,
+                                     struct net *net,
                                      int (*okfn)(struct sock *, struct sk_buff *))
 {
        p->hook = hook;
@@ -73,6 +75,7 @@ static inline void nf_hook_state_init(struct nf_hook_state *p,
        p->in = indev;
        p->out = outdev;
        p->sk = sk;
+       p->net = net;
        p->hook_list = hook_list;
        p->okfn = okfn;
 }
@@ -167,6 +170,7 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state);
  *     value indicates the packet has been consumed by the hook.
  */
 static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
+                                struct net *net,
                                 struct sock *sk,
                                 struct sk_buff *skb,
                                 struct net_device *indev,
@@ -174,25 +178,24 @@ static inline int nf_hook_thresh(u_int8_t pf, unsigned int hook,
                                 int (*okfn)(struct sock *, struct sk_buff *),
                                 int thresh)
 {
-       struct net *net = dev_net(indev ? indev : outdev);
        struct list_head *hook_list = &net->nf.hooks[pf][hook];
 
        if (nf_hook_list_active(hook_list, pf, hook)) {
                struct nf_hook_state state;
 
                nf_hook_state_init(&state, hook_list, hook, thresh,
-                                  pf, indev, outdev, sk, okfn);
+                                  pf, indev, outdev, sk, net, okfn);
                return nf_hook_slow(skb, &state);
        }
        return 1;
 }
 
-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,
+static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
+                         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, sk, skb, indev, outdev, okfn, INT_MIN);
+       return nf_hook_thresh(pf, hook, net, sk, skb, indev, outdev, okfn, INT_MIN);
 }
                    
 /* Activate hook; either okfn or kfree_skb called, unless a hook
@@ -213,36 +216,36 @@ static inline int nf_hook(u_int8_t pf, unsigned int hook, struct sock *sk,
 */
 
 static inline int
-NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sock *sk,
+NF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct net *net, 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, sk, skb, in, out, okfn, thresh);
+       int ret = nf_hook_thresh(pf, hook, net, sk, skb, in, out, okfn, thresh);
        if (ret == 1)
                ret = okfn(sk, skb);
        return ret;
 }
 
 static inline int
-NF_HOOK_COND(uint8_t pf, unsigned int hook, struct sock *sk,
+NF_HOOK_COND(uint8_t pf, unsigned int hook, struct net *net, 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, sk, skb, in, out, okfn, INT_MIN)) == 1))
+           ((ret = nf_hook_thresh(pf, hook, net, 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 sock *sk, struct sk_buff *skb,
+NF_HOOK(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, struct sk_buff *skb,
        struct net_device *in, struct net_device *out,
        int (*okfn)(struct sock *, struct sk_buff *))
 {
-       return NF_HOOK_THRESH(pf, hook, sk, skb, in, out, okfn, INT_MIN);
+       return NF_HOOK_THRESH(pf, hook, net, sk, skb, in, out, okfn, INT_MIN);
 }
 
 /* Call setsockopt() */
@@ -342,20 +345,11 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
 }
 
 #else /* !CONFIG_NETFILTER */
-#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 sock *sk, struct sk_buff *), int thresh)
-{
-       return okfn(sk, skb);
-}
-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,
+#define NF_HOOK(pf, hook, net, sk, skb, indev, outdev, okfn) (okfn)(sk, skb)
+#define NF_HOOK_COND(pf, hook, net, sk, skb, indev, outdev, okfn, cond) (okfn)(sk, skb)
+static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
+                         struct sock *sk, struct sk_buff *skb,
+                         struct net_device *indev, struct net_device *outdev,
                          int (*okfn)(struct sock *, struct sk_buff *))
 {
        return 1;
This page took 0.029701 seconds and 5 git commands to generate.