Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22162
b: refs/heads/master
c: dc808fe
h: refs/heads/master
v: v3
  • Loading branch information
Harald Welte authored and David S. Miller committed Mar 21, 2006
1 parent 5957f87 commit 35f969f
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 139 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d36f37bb1e1cbadca6dc90a840bb2bc9ab51c44
refs/heads/master: dc808fe28db59fadf4ec32d53f62477fa28f3be8
56 changes: 34 additions & 22 deletions trunk/include/net/netfilter/nf_conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ do { \

struct nf_conntrack_helper;

/* nf_conn feature for connections that have a helper */
struct nf_conn_help {
/* Helper. if any */
struct nf_conntrack_helper *helper;

union nf_conntrack_help help;

/* Current number of expected connections */
unsigned int expecting;
};


#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
struct nf_conn
{
Expand All @@ -81,45 +93,32 @@ struct nf_conn
/* Have we seen traffic both ways yet? (bitset) */
unsigned long status;

/* If we were expected by an expectation, this will be it */
struct nf_conn *master;

/* Timer function; drops refcnt when it goes off. */
struct timer_list timeout;

#ifdef CONFIG_NF_CT_ACCT
/* Accounting Information (same cache line as other written members) */
struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
#endif
/* If we were expected by an expectation, this will be it */
struct nf_conn *master;

/* Current number of expected connections */
unsigned int expecting;

/* Unique ID that identifies this conntrack*/
unsigned int id;

/* Helper. if any */
struct nf_conntrack_helper *helper;

/* features - nat, helper, ... used by allocating system */
u_int32_t features;

/* Storage reserved for other modules: */

union nf_conntrack_proto proto;

#if defined(CONFIG_NF_CONNTRACK_MARK)
u_int32_t mark;
#endif

/* These members are dynamically allocated. */

union nf_conntrack_help *help;
/* Storage reserved for other modules: */
union nf_conntrack_proto proto;

/* Layer 3 dependent members. (ex: NAT) */
union {
struct nf_conntrack_ipv4 *ipv4;
} l3proto;
void *data[0];
/* features dynamically at the end: helper, nat (both optional) */
char data[0];
};

struct nf_conntrack_expect
Expand Down Expand Up @@ -373,10 +372,23 @@ nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
#define NF_CT_F_NUM 4

extern int
nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size,
int (*init_conntrack)(struct nf_conn *, u_int32_t));
nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size);
extern void
nf_conntrack_unregister_cache(u_int32_t features);

/* valid combinations:
* basic: nf_conn, nf_conn .. nf_conn_help
* nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help
*/
static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
{
unsigned int offset = sizeof(struct nf_conn);

if (!(ct->features & NF_CT_F_HELP))
return NULL;

return (struct nf_conn_help *) ((void *)ct + offset);
}

#endif /* __KERNEL__ */
#endif /* _NF_CONNTRACK_H */
22 changes: 12 additions & 10 deletions trunk/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,21 @@ static unsigned int ipv4_conntrack_help(unsigned int hooknum,
{
struct nf_conn *ct;
enum ip_conntrack_info ctinfo;
struct nf_conn_help *help;

/* This is where we call the helper: as the packet goes out. */
ct = nf_ct_get(*pskb, &ctinfo);
if (ct && ct->helper) {
unsigned int ret;
ret = ct->helper->help(pskb,
(*pskb)->nh.raw - (*pskb)->data
+ (*pskb)->nh.iph->ihl*4,
ct, ctinfo);
if (ret != NF_ACCEPT)
return ret;
}
return NF_ACCEPT;
if (!ct)
return NF_ACCEPT;

help = nfct_help(ct);
if (!help || !help->helper)
return NF_ACCEPT;

return help->helper->help(pskb,
(*pskb)->nh.raw - (*pskb)->data
+ (*pskb)->nh.iph->ihl*4,
ct, ctinfo);
}

static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
Expand Down
39 changes: 22 additions & 17 deletions trunk/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,36 @@ static unsigned int ipv6_confirm(unsigned int hooknum,
int (*okfn)(struct sk_buff *))
{
struct nf_conn *ct;
struct nf_conn_help *help;
enum ip_conntrack_info ctinfo;
unsigned int ret, protoff;
unsigned int extoff = (u8*)((*pskb)->nh.ipv6h + 1)
- (*pskb)->data;
unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr;


/* This is where we call the helper: as the packet goes out. */
ct = nf_ct_get(*pskb, &ctinfo);
if (ct && ct->helper) {
unsigned int ret, protoff;
unsigned int extoff = (u8*)((*pskb)->nh.ipv6h + 1)
- (*pskb)->data;
unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr;

protoff = nf_ct_ipv6_skip_exthdr(*pskb, extoff, &pnum,
(*pskb)->len - extoff);
if (protoff < 0 || protoff > (*pskb)->len ||
pnum == NEXTHDR_FRAGMENT) {
DEBUGP("proto header not found\n");
return NF_ACCEPT;
}
if (!ct)
goto out;

ret = ct->helper->help(pskb, protoff, ct, ctinfo);
if (ret != NF_ACCEPT)
return ret;
help = nfct_help(ct);
if (!help || !help->helper)
goto out;

protoff = nf_ct_ipv6_skip_exthdr(*pskb, extoff, &pnum,
(*pskb)->len - extoff);
if (protoff < 0 || protoff > (*pskb)->len ||
pnum == NEXTHDR_FRAGMENT) {
DEBUGP("proto header not found\n");
return NF_ACCEPT;
}

ret = help->helper->help(pskb, protoff, ct, ctinfo);
if (ret != NF_ACCEPT)
return ret;
out:
/* We've seen it coming out the other side: confirm it */

return nf_conntrack_confirm(pskb);
}

Expand Down
Loading

0 comments on commit 35f969f

Please sign in to comment.