aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter/nfnetlink.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@netfilter.org>2005-08-09 23:03:40 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:39:14 -0400
commit927ccbcc28dceee29dad876982768cca29738564 (patch)
treea5bc50c92c1627e373e3cf9efbaec5c1d3f1b2b7 /net/netfilter/nfnetlink.c
parentbd9a26b7f2ee7567571bb5b7acc1a256c544a0dd (diff)
[NETFILTER]: attribute count is an attribute of message type, not subsytem
Prior to this patch, every nfnetlink subsystem had to specify it's attribute count. However, in reality the attribute count depends on the message type within the subsystem, not the subsystem itself. This patch moves 'attr_count' from 'struct nfnetlink_subsys' into nfnl_callback to fix this. Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netfilter/nfnetlink.c')
-rw-r--r--net/netfilter/nfnetlink.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 30b25f47f7c..578e4fe4094 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -155,8 +155,18 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
155 struct nlmsghdr *nlh, struct nfattr *cda[]) 155 struct nlmsghdr *nlh, struct nfattr *cda[])
156{ 156{
157 int min_len; 157 int min_len;
158 u_int16_t attr_count;
159 u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
158 160
159 memset(cda, 0, sizeof(struct nfattr *) * subsys->attr_count); 161 if (unlikely(cb_id >= subsys->cb_count)) {
162 DEBUGP("msgtype %u >= %u, returning\n",
163 cb_id, subsys->cb_count);
164 return -EINVAL;
165 }
166
167 attr_count = subsys->cb[cb_id].attr_count;
168
169 memset(cda, 0, sizeof(struct nfattr *) * attr_count);
160 170
161 /* check attribute lengths. */ 171 /* check attribute lengths. */
162 min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg)); 172 min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg));
@@ -170,7 +180,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
170 while (NFA_OK(attr, attrlen)) { 180 while (NFA_OK(attr, attrlen)) {
171 unsigned flavor = attr->nfa_type; 181 unsigned flavor = attr->nfa_type;
172 if (flavor) { 182 if (flavor) {
173 if (flavor > subsys->attr_count) 183 if (flavor > attr_count)
174 return -EINVAL; 184 return -EINVAL;
175 cda[flavor - 1] = attr; 185 cda[flavor - 1] = attr;
176 } 186 }
@@ -256,9 +266,11 @@ static inline int nfnetlink_rcv_msg(struct sk_buff *skb,
256 } 266 }
257 267
258 { 268 {
259 struct nfattr *cda[ss->attr_count]; 269 u_int16_t attr_count =
270 ss->cb[NFNL_MSG_TYPE(nlh->nlmsg_type)].attr_count;
271 struct nfattr *cda[attr_count];
260 272
261 memset(cda, 0, ss->attr_count*sizeof(struct nfattr *)); 273 memset(cda, 0, sizeof(struct nfattr *) * attr_count);
262 274
263 err = nfnetlink_check_attributes(ss, nlh, cda); 275 err = nfnetlink_check_attributes(ss, nlh, cda);
264 if (err < 0) 276 if (err < 0)