diff options
author | Richard Alpe <richard.alpe@ericsson.com> | 2014-11-20 04:29:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-21 15:01:30 -0500 |
commit | 315c00bc9f2bd17f7ad7ed8119ca49b1125af507 (patch) | |
tree | dfa45dd6c8ee275b7b708fb96838d48e492919c7 /net/tipc/bearer.c | |
parent | 35b9dd7607f049466a66427e58818b29aeae9ea7 (diff) |
tipc: add bearer set to new netlink api
Add TIPC_NL_BEARER_SET command to the new tipc netlink API.
This command can set one or more link properties for a particular
bearer.
Netlink logical layout of bearer set message:
-> bearer
-> name
-> link properties
[ -> tolerance ]
[ -> priority ]
[ -> window ]
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r-- | net/tipc/bearer.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index d49b8c25dd11..6d547d0b3f31 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -849,3 +849,52 @@ int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info) | |||
849 | 849 | ||
850 | return 0; | 850 | return 0; |
851 | } | 851 | } |
852 | |||
853 | int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info) | ||
854 | { | ||
855 | int err; | ||
856 | char *name; | ||
857 | struct tipc_bearer *b; | ||
858 | struct nlattr *attrs[TIPC_NLA_BEARER_MAX + 1]; | ||
859 | |||
860 | if (!info->attrs[TIPC_NLA_BEARER]) | ||
861 | return -EINVAL; | ||
862 | |||
863 | err = nla_parse_nested(attrs, TIPC_NLA_BEARER_MAX, | ||
864 | info->attrs[TIPC_NLA_BEARER], | ||
865 | tipc_nl_bearer_policy); | ||
866 | if (err) | ||
867 | return err; | ||
868 | |||
869 | if (!attrs[TIPC_NLA_BEARER_NAME]) | ||
870 | return -EINVAL; | ||
871 | name = nla_data(attrs[TIPC_NLA_BEARER_NAME]); | ||
872 | |||
873 | rtnl_lock(); | ||
874 | b = tipc_bearer_find(name); | ||
875 | if (!b) { | ||
876 | rtnl_unlock(); | ||
877 | return -EINVAL; | ||
878 | } | ||
879 | |||
880 | if (attrs[TIPC_NLA_BEARER_PROP]) { | ||
881 | struct nlattr *props[TIPC_NLA_PROP_MAX + 1]; | ||
882 | |||
883 | err = tipc_nl_parse_link_prop(attrs[TIPC_NLA_BEARER_PROP], | ||
884 | props); | ||
885 | if (err) { | ||
886 | rtnl_unlock(); | ||
887 | return err; | ||
888 | } | ||
889 | |||
890 | if (props[TIPC_NLA_PROP_TOL]) | ||
891 | b->tolerance = nla_get_u32(props[TIPC_NLA_PROP_TOL]); | ||
892 | if (props[TIPC_NLA_PROP_PRIO]) | ||
893 | b->priority = nla_get_u32(props[TIPC_NLA_PROP_PRIO]); | ||
894 | if (props[TIPC_NLA_PROP_WIN]) | ||
895 | b->window = nla_get_u32(props[TIPC_NLA_PROP_WIN]); | ||
896 | } | ||
897 | rtnl_unlock(); | ||
898 | |||
899 | return 0; | ||
900 | } | ||