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
173 CTA_EXPECT_HELP_NAME,173 CTA_EXPECT_HELP_NAME,
174 CTA_EXPECT_ZONE,174 CTA_EXPECT_ZONE,
175 CTA_EXPECT_FLAGS,175 CTA_EXPECT_FLAGS,
176 CTA_EXPECT_CLASS,
176 __CTA_EXPECT_MAX177 __CTA_EXPECT_MAX
177};178};
178#define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1)179#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
1691 NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout));1691 NLA_PUT_BE32(skb, CTA_EXPECT_TIMEOUT, htonl(timeout));
1692 NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp));1692 NLA_PUT_BE32(skb, CTA_EXPECT_ID, htonl((unsigned long)exp));
1693 NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags));1693 NLA_PUT_BE32(skb, CTA_EXPECT_FLAGS, htonl(exp->flags));
1694 NLA_PUT_BE32(skb, CTA_EXPECT_CLASS, htonl(exp->class));
1694 help = nfct_help(master);1695 help = nfct_help(master);
1695 if (help) {1696 if (help) {
1696 struct nf_conntrack_helper *helper;1697 struct nf_conntrack_helper *helper;
@@ -1856,6 +1857,7 @@ static const struct nla_policy exp_nla_policy[CTA_EXPECT_MAX+1] = { · 159 unmodified lines
1856 [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING },1857 [CTA_EXPECT_HELP_NAME] = { .type = NLA_NUL_STRING },
1857 [CTA_EXPECT_ZONE] = { .type = NLA_U16 },1858 [CTA_EXPECT_ZONE] = { .type = NLA_U16 },
1858 [CTA_EXPECT_FLAGS] = { .type = NLA_U32 },1859 [CTA_EXPECT_FLAGS] = { .type = NLA_U32 },
1860 [CTA_EXPECT_CLASS] = { .type = NLA_U32 },
1859};1861};
1860 1862
1861static int1863static int
@@ -2043,6 +2045,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 181 unmodified lines
2043 struct nf_conn *ct;2045 struct nf_conn *ct;
2044 struct nf_conn_help *help;2046 struct nf_conn_help *help;
2045 struct nf_conntrack_helper *helper = NULL;2047 struct nf_conntrack_helper *helper = NULL;
2048 u_int32_t class = 0;
2046 int err = 0;2049 int err = 0;
2047 2050
2048 /* caller guarantees that those three CTA_EXPECT_* exist */2051 /* caller guarantees that those three CTA_EXPECT_* exist */
@@ -2088,6 +2091,13 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 39 unmodified lines
2088 }2091 }
2089 }2092 }
2090 2093
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 }
2091 exp = nf_ct_expect_alloc(ct);2101 exp = nf_ct_expect_alloc(ct);
2092 if (!exp) {2102 if (!exp) {
2093 err = -ENOMEM;2103 err = -ENOMEM;
@@ -2115,7 +2125,7 @@ ctnetlink_create_expect(struct net *net, u16 zone, · 21 unmodified lines
2115 exp->flags = 0;2125 exp->flags = 0;
2116 }2126 }
2117 2127
2118 exp->class = 0;2128 exp->class = class;
2119 exp->expectfn = NULL;2129 exp->expectfn = NULL;
2120 exp->master = ct;2130 exp->master = ct;
2121 exp->helper = helper;2131 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