History

netfilter: ctnetlink: allow to set expectation class

This patch allows you to set the expectation class.

Pablo Neira Ayuso committed 14 years ago

Commit b8c5e521 parent 660fdb22 files · +12 −1Browse files

Unified · Split

2 files
  1. include/linux/netfilter/nfnetlink_conntrack.h +1 −0
  2. net/netfilter/nf_conntrack_netlink.c +11 −1
include/linux/netfilter/nfnetlink_conntrack.h+1−0
@@ -173,6 +173,7 @@ enum ctattr_expect { · 172 unmodified lines
173173 CTA_EXPECT_HELP_NAME,
174174 CTA_EXPECT_ZONE,
175175 CTA_EXPECT_FLAGS,
176+ CTA_EXPECT_CLASS,
176177 __CTA_EXPECT_MAX
177178 };
178179 #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1)
net/netfilter/nf_conntrack_netlink.c+11−1
@@ -1691,6 +1691,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 1690 unmodified lines
16911691 NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout));
16921692 NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp));
16931693 NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags));
1694+ NLA_PUT_BE32(skb, CTA_EXPECT_CLASS, htonl(exp->class));
16941695 help = nfct_help(master);
16951696 if (help) {
16961697 struct nf_conntrack_helper *helper;
@@ -1856,6 +1857,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { · 159 unmodified lines
18561857 [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING },
18571858 [CTA_EXPECT_ZONE] = { .type = NLA_U16 },
18581859 [CTA_EXPECT_FLAGS] = { .type = NLA_U32 },
1860+ [CTA_EXPECT_CLASS] = { .type = NLA_U32 },
18591861 };
18601862
18611863 static int
@@ -2043,6 +2045,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 181 unmodified lines
20432045 struct nf_conn *ct;
20442046 struct nf_conn_help *help;
20452047 struct nf_conntrack_helper *helper = NULL;
2048+ u_int32_t class = 0;
20462049 int err = 0;
20472050
20482051 /* caller guarantees that those three CTA_EXPECT_* exist */
@@ -2088,6 +2091,13 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 39 unmodified lines
20882091 }
20892092 }
20902093
2094+ if (cda[CTA_EXPECT_CLASS] && helper) {
2095+ class = ntohl(nla_get_be32(cda[CTA_EXPECT_CLASS]));
2096+ if (class > helper->expect_class_max) {
2097+ err = -EINVAL;
2098+ goto out;
2099+ }
2100+ }
20912101 exp = nf_ct_expect_alloc(ct);
20922102 if (!exp) {
20932103 err = -ENOMEM;
@@ -2115,7 +2125,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 21 unmodified lines
21152125 exp->flags = 0;
21162126 }
21172127
2118− exp->class = 0;
2128+ exp->class = class;
21192129 exp->expectfn = NULL;
21202130 exp->master = ct;
21212131 exp->helper = helper;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t