-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas Gruenbacher
authored and
Philipp Reisner
committed
Nov 8, 2012
1 parent
93c2b12
commit 5d598e8
Showing
7 changed files
with
67 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 7c3063cc6f0e75cdf312f5f318f9a4c02e460397 | ||
refs/heads/master: 01b39b50d34733646fe46a582fa60d3b53f6180d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "drbd_wrappers.h" | ||
#include <linux/kernel.h> | ||
#include <net/netlink.h> | ||
#include <linux/drbd_genl_api.h> | ||
#include "drbd_nla.h" | ||
|
||
static int drbd_nla_check_mandatory(int maxtype, struct nlattr *nla) | ||
{ | ||
struct nlattr *head = nla_data(nla); | ||
int len = nla_len(nla); | ||
int rem; | ||
|
||
/* | ||
* validate_nla (called from nla_parse_nested) ignores attributes | ||
* beyond maxtype, and does not understand the DRBD_GENLA_F_MANDATORY flag. | ||
* In order to have it validate attributes with the DRBD_GENLA_F_MANDATORY | ||
* flag set also, check and remove that flag before calling | ||
* nla_parse_nested. | ||
*/ | ||
|
||
nla_for_each_attr(nla, head, len, rem) { | ||
if (nla->nla_type & DRBD_GENLA_F_MANDATORY) { | ||
nla->nla_type &= ~DRBD_GENLA_F_MANDATORY; | ||
if (nla_type(nla) > maxtype) | ||
return -EOPNOTSUPP; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, | ||
const struct nla_policy *policy) | ||
{ | ||
int err; | ||
|
||
err = drbd_nla_check_mandatory(maxtype, nla); | ||
if (!err) | ||
err = nla_parse_nested(tb, maxtype, nla, policy); | ||
|
||
return err; | ||
} | ||
|
||
struct nlattr *drbd_nla_find_nested(int maxtype, struct nlattr *nla, int attrtype) | ||
{ | ||
int err; | ||
/* | ||
* If any nested attribute has the DRBD_GENLA_F_MANDATORY flag set and | ||
* we don't know about that attribute, reject all the nested | ||
* attributes. | ||
*/ | ||
err = drbd_nla_check_mandatory(maxtype, nla); | ||
if (err) | ||
return ERR_PTR(err); | ||
return nla_find_nested(nla, attrtype); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef __DRBD_NLA_H | ||
#define __DRBD_NLA_H | ||
|
||
extern int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, | ||
const struct nla_policy *policy); | ||
extern struct nlattr *drbd_nla_find_nested(int maxtype, struct nlattr *nla, int attrtype); | ||
|
||
#endif /* __DRBD_NLA_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters