Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66398
b: refs/heads/master
c: 8f4c1f9
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Graf authored and David S. Miller committed Oct 10, 2007
1 parent 12fa953 commit d25eeaa
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d5010db7ecfd6ec00119d3b185c4c0cd3265167
refs/heads/master: 8f4c1f9b049df3be11090f1c2c4738700302acae
14 changes: 14 additions & 0 deletions trunk/include/linux/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ struct nlattr
__u16 nla_type;
};

/*
* nla_type (16 bits)
* +---+---+-------------------------------+
* | N | O | Attribute Type |
* +---+---+-------------------------------+
* N := Carries nested attributes
* O := Payload stored in network byte order
*
* Note: The N and O flag are mutually exclusive.
*/
#define NLA_F_NESTED (1 << 15)
#define NLA_F_NET_BYTEORDER (1 << 14)
#define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)

#define NLA_ALIGNTO 4
#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
Expand Down
9 changes: 9 additions & 0 deletions trunk/include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,15 @@ static inline int nla_padlen(int payload)
return nla_total_size(payload) - nla_attr_size(payload);
}

/**
* nla_type - attribute type
* @nla: netlink attribute
*/
static inline int nla_type(const struct nlattr *nla)
{
return nla->nla_type & NLA_TYPE_MASK;
}

/**
* nla_data - head of payload
* @nla: netlink attribute
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
}

nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), remaining) {
switch (attr->nla_type) {
switch (nla_type(attr)) {
case RTA_DST:
cfg->fc_dst = nla_get_be32(attr);
break;
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv4/fib_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
int remaining;

nla_for_each_attr(nla, cfg->fc_mx, cfg->fc_mx_len, remaining) {
int type = nla->nla_type;
int type = nla_type(nla);

if (type) {
if (type > RTAX_MAX)
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ int ip6_route_add(struct fib6_config *cfg)
int remaining;

nla_for_each_attr(nla, cfg->fc_mx, cfg->fc_mx_len, remaining) {
int type = nla->nla_type;
int type = nla_type(nla);

if (type) {
if (type > RTAX_MAX) {
Expand Down
14 changes: 7 additions & 7 deletions trunk/net/netlabel/netlabel_cipso_v4.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static int netlbl_cipsov4_add_common(struct genl_info *info,
return -EINVAL;

nla_for_each_nested(nla, info->attrs[NLBL_CIPSOV4_A_TAGLST], nla_rem)
if (nla->nla_type == NLBL_CIPSOV4_A_TAG) {
if (nla_type(nla) == NLBL_CIPSOV4_A_TAG) {
if (iter >= CIPSO_V4_TAG_MAXCNT)
return -EINVAL;
doi_def->tags[iter++] = nla_get_u8(nla);
Expand Down Expand Up @@ -192,13 +192,13 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
nla_for_each_nested(nla_a,
info->attrs[NLBL_CIPSOV4_A_MLSLVLLST],
nla_a_rem)
if (nla_a->nla_type == NLBL_CIPSOV4_A_MLSLVL) {
if (nla_type(nla_a) == NLBL_CIPSOV4_A_MLSLVL) {
if (nla_validate_nested(nla_a,
NLBL_CIPSOV4_A_MAX,
netlbl_cipsov4_genl_policy) != 0)
goto add_std_failure;
nla_for_each_nested(nla_b, nla_a, nla_b_rem)
switch (nla_b->nla_type) {
switch (nla_type(nla_b)) {
case NLBL_CIPSOV4_A_MLSLVLLOC:
if (nla_get_u32(nla_b) >
CIPSO_V4_MAX_LOC_LVLS)
Expand Down Expand Up @@ -240,7 +240,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
nla_for_each_nested(nla_a,
info->attrs[NLBL_CIPSOV4_A_MLSLVLLST],
nla_a_rem)
if (nla_a->nla_type == NLBL_CIPSOV4_A_MLSLVL) {
if (nla_type(nla_a) == NLBL_CIPSOV4_A_MLSLVL) {
struct nlattr *lvl_loc;
struct nlattr *lvl_rem;

Expand All @@ -265,13 +265,13 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
nla_for_each_nested(nla_a,
info->attrs[NLBL_CIPSOV4_A_MLSCATLST],
nla_a_rem)
if (nla_a->nla_type == NLBL_CIPSOV4_A_MLSCAT) {
if (nla_type(nla_a) == NLBL_CIPSOV4_A_MLSCAT) {
if (nla_validate_nested(nla_a,
NLBL_CIPSOV4_A_MAX,
netlbl_cipsov4_genl_policy) != 0)
goto add_std_failure;
nla_for_each_nested(nla_b, nla_a, nla_b_rem)
switch (nla_b->nla_type) {
switch (nla_type(nla_b)) {
case NLBL_CIPSOV4_A_MLSCATLOC:
if (nla_get_u32(nla_b) >
CIPSO_V4_MAX_LOC_CATS)
Expand Down Expand Up @@ -315,7 +315,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info)
nla_for_each_nested(nla_a,
info->attrs[NLBL_CIPSOV4_A_MLSCATLST],
nla_a_rem)
if (nla_a->nla_type == NLBL_CIPSOV4_A_MLSCAT) {
if (nla_type(nla_a) == NLBL_CIPSOV4_A_MLSCAT) {
struct nlattr *cat_loc;
struct nlattr *cat_rem;

Expand Down
10 changes: 5 additions & 5 deletions trunk/net/netlink/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ static int validate_nla(struct nlattr *nla, int maxtype,
const struct nla_policy *policy)
{
const struct nla_policy *pt;
int minlen = 0, attrlen = nla_len(nla);
int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);

if (nla->nla_type <= 0 || nla->nla_type > maxtype)
if (type <= 0 || type > maxtype)
return 0;

pt = &policy[nla->nla_type];
pt = &policy[type];

BUG_ON(pt->type > NLA_TYPE_MAX);

Expand Down Expand Up @@ -149,7 +149,7 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));

nla_for_each_attr(nla, head, len, rem) {
u16 type = nla->nla_type;
u16 type = nla_type(nla);

if (type > 0 && type <= maxtype) {
if (policy) {
Expand Down Expand Up @@ -185,7 +185,7 @@ struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
int rem;

nla_for_each_attr(nla, head, len, rem)
if (nla->nla_type == attrtype)
if (nla_type(nla) == attrtype)
return nla;

return NULL;
Expand Down

0 comments on commit d25eeaa

Please sign in to comment.