8 #include <linux/export.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
12 #include <linux/netdevice.h>
14 #include <linux/string.h>
15 #include <linux/types.h>
31 static int validate_nla(
const struct nlattr *
nla,
int maxtype,
35 int minlen = 0, attrlen = nla_len(nla),
type = nla_type(nla);
52 minlen =
min_t(
int, attrlen, pt->
len + 1);
56 if (!minlen ||
memchr(nla_data(nla),
'\0', minlen) ==
NULL)
65 char *
buf = nla_data(nla);
67 if (buf[attrlen - 1] ==
'\0')
70 if (attrlen > pt->
len)
76 if (pt->
len && attrlen > pt->
len)
81 if (attrlen < pt->
len)
101 minlen = nla_attr_minlen[pt->
type];
103 if (attrlen < minlen)
130 err = validate_nla(nla, maxtype, policy);
156 for (i = 0; i <
n; i++, p++) {
158 len += nla_total_size(p->
len);
159 else if (nla_attr_minlen[p->
type])
160 len += nla_total_size(nla_attr_minlen[p->
type]);
192 if (type > 0 && type <= maxtype) {
194 err = validate_nla(nla, maxtype, policy);
205 "attributes.\n", rem);
247 char *
src = nla_data(nla);
249 if (srclen > 0 && src[srclen - 1] ==
'\0')
253 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
277 memcpy(dest, nla_data(src), minlen);
294 d =
memcmp(nla_data(nla), data, size);
306 int len =
strlen(str) + 1;
310 d =
memcmp(nla_data(nla), str, len);
332 nla = (
struct nlattr *)
skb_put(skb, nla_total_size(attrlen));
334 nla->
nla_len = nla_attr_size(attrlen);
336 memset((
unsigned char *) nla + nla->
nla_len, 0, nla_padlen(attrlen));
377 if (
unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
419 memcpy(nla_data(nla), data, attrlen);
437 memcpy(start, data, attrlen);
451 int nla_put(
struct sk_buff *skb,
int attrtype,
int attrlen,
const void *data)
453 if (
unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))