Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136049
b: refs/heads/master
c: e487eb9
h: refs/heads/master
i:
  136047: e78b8b5
v: v3
  • Loading branch information
Holger Eitzenberger authored and Patrick McHardy committed Mar 25, 2009
1 parent b30a251 commit 60ed129
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d0dba7255b541f1651a88e75ebdb20dd45509c2f
refs/heads/master: e487eb99cf9381a4f8254fa01747a85818da612b
1 change: 1 addition & 0 deletions trunk/include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ extern int nla_validate(struct nlattr *head, int len, int maxtype,
extern int nla_parse(struct nlattr *tb[], int maxtype,
struct nlattr *head, int len,
const struct nla_policy *policy);
extern int nla_policy_len(const struct nla_policy *, int);
extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype);
extern size_t nla_strlcpy(char *dst, const struct nlattr *nla,
size_t dstsize);
Expand Down
27 changes: 27 additions & 0 deletions trunk/net/netlink/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,32 @@ int nla_validate(struct nlattr *head, int len, int maxtype,
return err;
}

/**
* nla_policy_len - Determin the max. length of a policy
* @policy: policy to use
* @n: number of policies
*
* Determines the max. length of the policy. It is currently used
* to allocated Netlink buffers roughly the size of the actual
* message.
*
* Returns 0 on success or a negative error code.
*/
int
nla_policy_len(const struct nla_policy *p, int n)
{
int i, len = 0;

for (i = 0; i < n; i++) {
if (p->len)
len += nla_total_size(p->len);
else if (nla_attr_minlen[p->type])
len += nla_total_size(nla_attr_minlen[p->type]);
}

return len;
}

/**
* nla_parse - Parse a stream of attributes into a tb buffer
* @tb: destination array with maxtype+1 elements
Expand Down Expand Up @@ -456,6 +482,7 @@ int nla_append(struct sk_buff *skb, int attrlen, const void *data)
}

EXPORT_SYMBOL(nla_validate);
EXPORT_SYMBOL(nla_policy_len);
EXPORT_SYMBOL(nla_parse);
EXPORT_SYMBOL(nla_find);
EXPORT_SYMBOL(nla_strlcpy);
Expand Down

0 comments on commit 60ed129

Please sign in to comment.