From: Johannes Berg <johannes@sipsolutions.net>
To: davem <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>, Thomas Graf <tgraf@suug.ch>
Subject: [PATCH] genetlink custom attribute type
Date: Tue, 26 Sep 2006 09:25:20 +0200 [thread overview]
Message-ID: <1159255520.2782.1.camel@ux156> (raw)
This patch adds an NLA_CUSTOM_CHECK type for netlink attributes
in order to be able to centrally define new attribute structures
instead of having to check these special types in each function
that uses such an attribute.
nl80211 will benefit from this because it needs an information
element attribute with a fixed type|length|value structure defined
in IEEE 802.11 which ought to be checked when passing an IE from
userspace.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
--- wireless-dev.orig/include/net/netlink.h 2006-09-13 22:06:09.979647141 +0200
+++ wireless-dev/include/net/netlink.h 2006-09-13 22:06:11.329647141 +0200
@@ -159,6 +159,7 @@ enum {
NLA_MSECS,
NLA_NESTED,
NLA_NUL_STRING,
+ NLA_CUSTOM_CHECK,
__NLA_TYPE_MAX,
};
@@ -176,6 +177,8 @@ enum {
* NLA_STRING Maximum length of string
* NLA_NUL_STRING Maximum length of string (excluding NUL)
* NLA_FLAG Unused
+ * NLA_CUSTOM_CHECK Unused, check function must be assigned,
+ * it must return 0 if the attribute is valid
* All other Exact length of attribute payload
*
* Example:
@@ -183,11 +186,13 @@ enum {
* [ATTR_FOO] = { .type = NLA_U16 },
* [ATTR_BAR] = { .type = NLA_STRING, len = BARSIZ },
* [ATTR_BAZ] = { .len = sizeof(struct mystruct) },
+ * [ATTR_CST] = { .type = NLA_CUSTOM_CHECK, .check = my_check },
* };
*/
struct nla_policy {
u16 type;
u16 len;
+ int (*check)(struct nlattr *nla);
};
extern void netlink_run_queue(struct sock *sk, unsigned int *qlen,
--- wireless-dev.orig/net/netlink/attr.c 2006-09-13 22:06:05.889647141 +0200
+++ wireless-dev/net/netlink/attr.c 2006-09-13 22:06:11.329647141 +0200
@@ -67,6 +67,9 @@ static int validate_nla(struct nlattr *n
}
break;
+ case NLA_CUSTOM_CHECK:
+ BUG_ON(!pt->check);
+ return pt->check(nla);
default:
if (pt->len)
minlen = pt->len;
next reply other threads:[~2006-09-26 7:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-26 7:25 Johannes Berg [this message]
2006-09-26 9:44 ` [PATCH] genetlink custom attribute type Thomas Graf
2006-09-26 10:04 ` Johannes Berg
2006-09-26 20:09 ` David Miller
2006-09-27 12:18 ` Johannes Berg
2006-10-02 13:49 ` Thomas Graf
2006-10-02 13:56 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1159255520.2782.1.camel@ux156 \
--to=johannes@sipsolutions.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).