aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-03-25 23:08:37 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-25 23:08:37 -0400
commit359b9ab614aba71c2c3bc047efbd6d12dd4a2b9e (patch)
tree3399b1bf65d5d1faff0c4231f7a716c445c19d2a
parent4bb119eab7b724109d8eeb0f8d86ed1e4953d338 (diff)
[NETFILTER]: nf_conntrack_expect: support inactive expectations
This is useful for the SIP helper and signalling expectations. We don't want to create a full-blown expectation with a wildcard as source based on a single UDP packet, but need to know the final port anyways. With inactive expectations we can register the expectation and reserve the tuple, but wait for confirmation from the registrar before activating it. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h3
-rw-r--r--net/netfilter/nf_conntrack_expect.c25
2 files changed, 23 insertions, 5 deletions
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index f1bdcb4f3f2a..47c28dd07896 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -53,7 +53,8 @@ struct nf_conntrack_expect
53 struct rcu_head rcu; 53 struct rcu_head rcu;
54}; 54};
55 55
56#define NF_CT_EXPECT_PERMANENT 0x1 56#define NF_CT_EXPECT_PERMANENT 0x1
57#define NF_CT_EXPECT_INACTIVE 0x2
57 58
58int nf_conntrack_expect_init(void); 59int nf_conntrack_expect_init(void);
59void nf_conntrack_expect_fini(void); 60void nf_conntrack_expect_fini(void);
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 4c05a588116f..882602f1c0ef 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -126,9 +126,21 @@ EXPORT_SYMBOL_GPL(nf_ct_expect_find_get);
126struct nf_conntrack_expect * 126struct nf_conntrack_expect *
127nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple) 127nf_ct_find_expectation(const struct nf_conntrack_tuple *tuple)
128{ 128{
129 struct nf_conntrack_expect *exp; 129 struct nf_conntrack_expect *i, *exp = NULL;
130 struct hlist_node *n;
131 unsigned int h;
132
133 if (!nf_ct_expect_count)
134 return NULL;
130 135
131 exp = __nf_ct_expect_find(tuple); 136 h = nf_ct_expect_dst_hash(tuple);
137 hlist_for_each_entry(i, n, &nf_ct_expect_hash[h], hnode) {
138 if (!(i->flags & NF_CT_EXPECT_INACTIVE) &&
139 nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)) {
140 exp = i;
141 break;
142 }
143 }
132 if (!exp) 144 if (!exp)
133 return NULL; 145 return NULL;
134 146
@@ -460,6 +472,7 @@ static int exp_seq_show(struct seq_file *s, void *v)
460{ 472{
461 struct nf_conntrack_expect *expect; 473 struct nf_conntrack_expect *expect;
462 struct hlist_node *n = v; 474 struct hlist_node *n = v;
475 char *delim = "";
463 476
464 expect = hlist_entry(n, struct nf_conntrack_expect, hnode); 477 expect = hlist_entry(n, struct nf_conntrack_expect, hnode);
465 478
@@ -476,8 +489,12 @@ static int exp_seq_show(struct seq_file *s, void *v)
476 __nf_ct_l4proto_find(expect->tuple.src.l3num, 489 __nf_ct_l4proto_find(expect->tuple.src.l3num,
477 expect->tuple.dst.protonum)); 490 expect->tuple.dst.protonum));
478 491
479 if (expect->flags & NF_CT_EXPECT_PERMANENT) 492 if (expect->flags & NF_CT_EXPECT_PERMANENT) {
480 seq_printf(s, "PERMANENT "); 493 seq_printf(s, "PERMANENT");
494 delim = ",";
495 }
496 if (expect->flags & NF_CT_EXPECT_INACTIVE)
497 seq_printf(s, "%sINACTIVE", delim);
481 498
482 return seq_putc(s, '\n'); 499 return seq_putc(s, '\n');
483} 500}