Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300513
b: refs/heads/master
c: 2615598
h: refs/heads/master
i:
  300511: 6987138
v: v3
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Apr 5, 2012
1 parent 3d60de9 commit 5e71e15
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 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: bd856615c128c40d189d6dd68dde7afe15ed3446
refs/heads/master: 2615598fc100451c71b83d06bdf5faead619a40e
30 changes: 26 additions & 4 deletions trunk/drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,10 +1145,7 @@ team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
},
[TEAM_ATTR_OPTION_CHANGED] = { .type = NLA_FLAG },
[TEAM_ATTR_OPTION_TYPE] = { .type = NLA_U8 },
[TEAM_ATTR_OPTION_DATA] = {
.type = NLA_BINARY,
.len = TEAM_STRING_MAX_LEN,
},
[TEAM_ATTR_OPTION_DATA] = { .type = NLA_BINARY },
};

static int team_nl_cmd_noop(struct sk_buff *skb, struct genl_info *info)
Expand Down Expand Up @@ -1257,6 +1254,7 @@ static int team_nl_fill_options_get(struct sk_buff *skb,
list_for_each_entry(option, &team->option_list, list) {
struct nlattr *option_item;
long arg;
struct team_option_binary tbinary;

/* Include only changed options if fill all mode is not on */
if (!fillall && !option->changed)
Expand Down Expand Up @@ -1290,6 +1288,15 @@ static int team_nl_fill_options_get(struct sk_buff *skb,
(char *) arg))
goto nla_put_failure;
break;
case TEAM_OPTION_TYPE_BINARY:
if (nla_put_u8(skb, TEAM_ATTR_OPTION_TYPE, NLA_BINARY))
goto nla_put_failure;
arg = (long) &tbinary;
team_option_get(team, option, &arg);
if (nla_put(skb, TEAM_ATTR_OPTION_DATA,
tbinary.data_len, tbinary.data))
goto nla_put_failure;
break;
default:
BUG();
}
Expand Down Expand Up @@ -1374,6 +1381,9 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
case NLA_STRING:
opt_type = TEAM_OPTION_TYPE_STRING;
break;
case NLA_BINARY:
opt_type = TEAM_OPTION_TYPE_BINARY;
break;
default:
goto team_put;
}
Expand All @@ -1382,19 +1392,31 @@ static int team_nl_cmd_options_set(struct sk_buff *skb, struct genl_info *info)
list_for_each_entry(option, &team->option_list, list) {
long arg;
struct nlattr *opt_data_attr;
struct team_option_binary tbinary;
int data_len;

if (option->type != opt_type ||
strcmp(option->name, opt_name))
continue;
opt_found = true;
opt_data_attr = mode_attrs[TEAM_ATTR_OPTION_DATA];
data_len = nla_len(opt_data_attr);
switch (opt_type) {
case TEAM_OPTION_TYPE_U32:
arg = nla_get_u32(opt_data_attr);
break;
case TEAM_OPTION_TYPE_STRING:
if (data_len > TEAM_STRING_MAX_LEN) {
err = -EINVAL;
goto team_put;
}
arg = (long) nla_data(opt_data_attr);
break;
case TEAM_OPTION_TYPE_BINARY:
tbinary.data_len = data_len;
tbinary.data = nla_data(opt_data_attr);
arg = (long) &tbinary;
break;
default:
BUG();
}
Expand Down
8 changes: 8 additions & 0 deletions trunk/include/linux/if_team.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct team_mode_ops {
enum team_option_type {
TEAM_OPTION_TYPE_U32,
TEAM_OPTION_TYPE_STRING,
TEAM_OPTION_TYPE_BINARY,
};

struct team_option {
Expand All @@ -82,6 +83,13 @@ struct team_option {
bool removed;
};

struct team_option_binary {
u32 data_len;
void *data;
};

#define team_optarg_tbinary(arg) (*((struct team_option_binary **) arg))

struct team_mode {
struct list_head list;
const char *kind;
Expand Down

0 comments on commit 5e71e15

Please sign in to comment.