aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2014-11-20 04:29:09 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-21 15:01:30 -0500
commit315c00bc9f2bd17f7ad7ed8119ca49b1125af507 (patch)
treedfa45dd6c8ee275b7b708fb96838d48e492919c7 /net/tipc
parent35b9dd7607f049466a66427e58818b29aeae9ea7 (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')
-rw-r--r--net/tipc/bearer.c49
-rw-r--r--net/tipc/bearer.h1
-rw-r--r--net/tipc/netlink.c5
3 files changed, 55 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
853int 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}
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 2d07e35f91fc..c6cf9df31375 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -182,6 +182,7 @@ int tipc_nl_bearer_disable(struct sk_buff *skb, struct genl_info *info);
182int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info); 182int tipc_nl_bearer_enable(struct sk_buff *skb, struct genl_info *info);
183int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb); 183int tipc_nl_bearer_dump(struct sk_buff *skb, struct netlink_callback *cb);
184int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info); 184int tipc_nl_bearer_get(struct sk_buff *skb, struct genl_info *info);
185int tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info);
185 186
186int tipc_media_set_priority(const char *name, u32 new_value); 187int tipc_media_set_priority(const char *name, u32 new_value);
187int tipc_media_set_window(const char *name, u32 new_value); 188int tipc_media_set_window(const char *name, u32 new_value);
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 0c00422512fa..a5291314a210 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -118,6 +118,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
118 .doit = tipc_nl_bearer_get, 118 .doit = tipc_nl_bearer_get,
119 .dumpit = tipc_nl_bearer_dump, 119 .dumpit = tipc_nl_bearer_dump,
120 .policy = tipc_nl_policy, 120 .policy = tipc_nl_policy,
121 },
122 {
123 .cmd = TIPC_NL_BEARER_SET,
124 .doit = tipc_nl_bearer_set,
125 .policy = tipc_nl_policy,
121 } 126 }
122}; 127};
123 128