diff options
author | Johannes Berg <johannes.berg@intel.com> | 2018-09-27 11:28:36 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-01 23:05:31 -0700 |
commit | 33188bd6430ef06d206ae4fda2cc92f14f16fd20 (patch) | |
tree | bd3980a02a9896a5a1d60936b451ce40efc44349 /lib | |
parent | 3e48be05f3c7eb6f6126939e9d957903c5cfeee5 (diff) | |
download | linux-33188bd6430ef06d206ae4fda2cc92f14f16fd20.tar.gz linux-33188bd6430ef06d206ae4fda2cc92f14f16fd20.tar.bz2 linux-33188bd6430ef06d206ae4fda2cc92f14f16fd20.zip |
netlink: add validation function to policy
Add the ability to have an arbitrary validation function attached
to a netlink policy that doesn't already use the validation_data
pointer in another way.
This can be useful to validate for example the content of a binary
attribute, like in nl80211 the "(information) elements", which must
be valid streams of "u8 type, u8 length, u8 value[length]".
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/nlattr.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/nlattr.c b/lib/nlattr.c index 5670e4b7dfef..1e900bb414ef 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -300,6 +300,13 @@ static int validate_nla(const struct nlattr *nla, int maxtype, if (err) return err; break; + case NLA_VALIDATE_FUNCTION: + if (pt->validate) { + err = pt->validate(nla, extack); + if (err) + return err; + } + break; } return 0; |