aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorRichard Alpe <richard.alpe@ericsson.com>2015-02-09 03:50:12 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-09 16:20:48 -0500
commit5bfc335a637ad4aecededb67b0075aae72a6dbb3 (patch)
tree7989c7ee9e82df89663b088d8fcbca345aab467e /net/tipc
parent487d2a3a1326d339ce273ffbcd03247f2b7b052e (diff)
tipc: convert legacy nl media dump to nl compat
Convert TIPC_CMD_GET_MEDIA_NAMES to compat dumpit. Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/bearer.c20
-rw-r--r--net/tipc/bearer.h1
-rw-r--r--net/tipc/config.c3
-rw-r--r--net/tipc/netlink_compat.c19
4 files changed, 19 insertions, 24 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index de1c800ef806..c7e3b5d3baa9 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -124,26 +124,6 @@ void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a)
124} 124}
125 125
126/** 126/**
127 * tipc_media_get_names - record names of registered media in buffer
128 */
129struct sk_buff *tipc_media_get_names(void)
130{
131 struct sk_buff *buf;
132 int i;
133
134 buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME));
135 if (!buf)
136 return NULL;
137
138 for (i = 0; media_info_array[i] != NULL; i++) {
139 tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
140 media_info_array[i]->name,
141 strlen(media_info_array[i]->name) + 1);
142 }
143 return buf;
144}
145
146/**
147 * bearer_name_validate - validate & (optionally) deconstruct bearer name 127 * bearer_name_validate - validate & (optionally) deconstruct bearer name
148 * @name: ptr to bearer name string 128 * @name: ptr to bearer name string
149 * @name_parts: ptr to area for bearer name components (or NULL if not needed) 129 * @name_parts: ptr to area for bearer name components (or NULL if not needed)
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h
index 06f25d144871..6b17795ff8bc 100644
--- a/net/tipc/bearer.h
+++ b/net/tipc/bearer.h
@@ -196,7 +196,6 @@ int tipc_nl_media_set(struct sk_buff *skb, struct genl_info *info);
196int tipc_media_set_priority(const char *name, u32 new_value); 196int tipc_media_set_priority(const char *name, u32 new_value);
197int tipc_media_set_window(const char *name, u32 new_value); 197int tipc_media_set_window(const char *name, u32 new_value);
198void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a); 198void tipc_media_addr_printf(char *buf, int len, struct tipc_media_addr *a);
199struct sk_buff *tipc_media_get_names(void);
200int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b); 199int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b);
201void tipc_disable_l2_media(struct tipc_bearer *b); 200void tipc_disable_l2_media(struct tipc_bearer *b);
202int tipc_l2_send_msg(struct net *net, struct sk_buff *buf, 201int tipc_l2_send_msg(struct net *net, struct sk_buff *buf,
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 6e4c215879c8..df410823e889 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -209,9 +209,6 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
209 rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area, 209 rep_tlv_buf = tipc_node_get_nodes(net, req_tlv_area,
210 req_tlv_space); 210 req_tlv_space);
211 break; 211 break;
212 case TIPC_CMD_GET_MEDIA_NAMES:
213 rep_tlv_buf = tipc_media_get_names();
214 break;
215 case TIPC_CMD_SHOW_STATS: 212 case TIPC_CMD_SHOW_STATS:
216 rep_tlv_buf = tipc_show_stats(); 213 rep_tlv_buf = tipc_show_stats();
217 break; 214 break;
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 48e15a4a36d8..d23075efaa76 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -822,6 +822,19 @@ static int tipc_nl_compat_sk_dump(struct tipc_nl_compat_msg *msg,
822 return 0; 822 return 0;
823} 823}
824 824
825static int tipc_nl_compat_media_dump(struct tipc_nl_compat_msg *msg,
826 struct nlattr **attrs)
827{
828 struct nlattr *media[TIPC_NLA_MEDIA_MAX + 1];
829
830 nla_parse_nested(media, TIPC_NLA_MEDIA_MAX, attrs[TIPC_NLA_MEDIA],
831 NULL);
832
833 return tipc_add_tlv(msg->rep, TIPC_TLV_MEDIA_NAME,
834 nla_data(media[TIPC_NLA_MEDIA_NAME]),
835 nla_len(media[TIPC_NLA_MEDIA_NAME]));
836}
837
825static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg) 838static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
826{ 839{
827 struct tipc_nl_compat_cmd_dump dump; 840 struct tipc_nl_compat_cmd_dump dump;
@@ -885,6 +898,11 @@ static int tipc_nl_compat_handle(struct tipc_nl_compat_msg *msg)
885 dump.dumpit = tipc_nl_sk_dump; 898 dump.dumpit = tipc_nl_sk_dump;
886 dump.format = tipc_nl_compat_sk_dump; 899 dump.format = tipc_nl_compat_sk_dump;
887 return tipc_nl_compat_dumpit(&dump, msg); 900 return tipc_nl_compat_dumpit(&dump, msg);
901 case TIPC_CMD_GET_MEDIA_NAMES:
902 msg->rep_size = MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME);
903 dump.dumpit = tipc_nl_media_dump;
904 dump.format = tipc_nl_compat_media_dump;
905 return tipc_nl_compat_dumpit(&dump, msg);
888 } 906 }
889 907
890 return -EOPNOTSUPP; 908 return -EOPNOTSUPP;
@@ -992,6 +1010,7 @@ static int tipc_nl_compat_tmp_wrap(struct sk_buff *skb, struct genl_info *info)
992 case TIPC_CMD_RESET_LINK_STATS: 1010 case TIPC_CMD_RESET_LINK_STATS:
993 case TIPC_CMD_SHOW_NAME_TABLE: 1011 case TIPC_CMD_SHOW_NAME_TABLE:
994 case TIPC_CMD_SHOW_PORTS: 1012 case TIPC_CMD_SHOW_PORTS:
1013 case TIPC_CMD_GET_MEDIA_NAMES:
995 return tipc_nl_compat_recv(skb, info); 1014 return tipc_nl_compat_recv(skb, info);
996 } 1015 }
997 1016