* [PATCH 09/25] netns ct: get proper netns from netdevice
@ 2008-06-22 1:08 Alexey Dobriyan
2008-06-23 10:35 ` Patrick McHardy
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2008-06-22 1:08 UTC (permalink / raw)
To: kaber
Cc: netdev, netfilter-devel, den, xemul, ebiederm, benjamin.thery,
dlezcano
Get netns from skb->dev on input, from skb->dst->dev on output to know
where to create or search for conntrack.
Is there some documentation re which device accessible from skb is valid
at which point?
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
net/netfilter/nf_conntrack_core.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -29,7 +29,7 @@
#include <linux/netdevice.h>
#include <linux/socket.h>
#include <linux/mm.h>
-
+#include <net/dst.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_l3proto.h>
#include <net/netfilter/nf_conntrack_l4proto.h>
@@ -615,6 +615,8 @@ resolve_normal_ct(struct sk_buff *skb,
int *set_reply,
enum ip_conntrack_info *ctinfo)
{
+ struct net_device *dev;
+ struct net *net;
struct nf_conntrack_tuple tuple;
struct nf_conntrack_tuple_hash *h;
struct nf_conn *ct;
@@ -626,10 +628,14 @@ resolve_normal_ct(struct sk_buff *skb,
return NULL;
}
+ dev = skb->dev;
+ if (!dev)
+ dev = skb->dst->dev;
+ net = dev_net(dev);
/* look for tuple match */
- h = nf_conntrack_find_get(&init_net, &tuple);
+ h = nf_conntrack_find_get(net, &tuple);
if (!h) {
- h = init_conntrack(&init_net, &tuple, l3proto, l4proto, skb, dataoff);
+ h = init_conntrack(net, &tuple, l3proto, l4proto, skb, dataoff);
if (!h)
return NULL;
if (IS_ERR(h))
--
1.5.4.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 09/25] netns ct: get proper netns from netdevice
2008-06-22 1:08 [PATCH 09/25] netns ct: get proper netns from netdevice Alexey Dobriyan
@ 2008-06-23 10:35 ` Patrick McHardy
0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2008-06-23 10:35 UTC (permalink / raw)
To: Alexey Dobriyan
Cc: netdev, netfilter-devel, den, xemul, ebiederm, benjamin.thery,
dlezcano
Alexey Dobriyan wrote:
> Get netns from skb->dev on input, from skb->dst->dev on output to know
> where to create or search for conntrack.
>
> Is there some documentation re which device accessible from skb is valid
> at which point?
For netfilter hooks, skb->dev points to the input device in
PREROUTING, INPUT, FORWARD, to the output device in POSTROUTING
and is invalid in OUTPUT.
> @@ -626,10 +628,14 @@ resolve_normal_ct(struct sk_buff *skb,
> return NULL;
> }
>
> + dev = skb->dev;
> + if (!dev)
> + dev = skb->dst->dev;
> + net = dev_net(dev);
Maybe just pass it though nf_conntrack_in from the hook functions,
those get the devices as arguments.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-23 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-22 1:08 [PATCH 09/25] netns ct: get proper netns from netdevice Alexey Dobriyan
2008-06-23 10:35 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).