Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: convert legacy nl bearer dump to nl compat

Introduce a framework for dumping netlink data from the new netlink
API and formatting it to the old legacy API format. This is done by
looping the dump data and calling a format handler for each entity, in
this case a bearer.

We dump until either all data is dumped or we reach the limited buffer
size of the legacy API. Remember, the legacy API doesn't scale.

In this commit we convert TIPC_CMD_GET_BEARER_NAMES to use the compat
layer.

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>

authored by

Richard Alpe and committed by
David S. Miller
d0796d1e bfb3e5dd

+278 -34
+5
include/uapi/linux/tipc_config.h
··· 272 272 (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type); 273 273 } 274 274 275 + static inline int TLV_GET_LEN(struct tlv_desc *tlv) 276 + { 277 + return ntohs(tlv->tlv_len); 278 + } 279 + 275 280 static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len) 276 281 { 277 282 struct tlv_desc *tlv_ptr;
-29
net/tipc/bearer.c
··· 205 205 return NULL; 206 206 } 207 207 208 - /** 209 - * tipc_bearer_get_names - record names of bearers in buffer 210 - */ 211 - struct sk_buff *tipc_bearer_get_names(struct net *net) 212 - { 213 - struct tipc_net *tn = net_generic(net, tipc_net_id); 214 - struct sk_buff *buf; 215 - struct tipc_bearer *b; 216 - int i, j; 217 - 218 - buf = tipc_cfg_reply_alloc(MAX_BEARERS * TLV_SPACE(TIPC_MAX_BEARER_NAME)); 219 - if (!buf) 220 - return NULL; 221 - 222 - for (i = 0; media_info_array[i] != NULL; i++) { 223 - for (j = 0; j < MAX_BEARERS; j++) { 224 - b = rtnl_dereference(tn->bearer_list[j]); 225 - if (!b) 226 - continue; 227 - if (b->media == media_info_array[i]) { 228 - tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, 229 - b->name, 230 - strlen(b->name) + 1); 231 - } 232 - } 233 - } 234 - return buf; 235 - } 236 - 237 208 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest) 238 209 { 239 210 struct tipc_net *tn = net_generic(net, tipc_net_id);
-1
net/tipc/bearer.h
··· 205 205 int tipc_l2_send_msg(struct net *net, struct sk_buff *buf, 206 206 struct tipc_bearer *b, struct tipc_media_addr *dest); 207 207 208 - struct sk_buff *tipc_bearer_get_names(struct net *net); 209 208 void tipc_bearer_add_dest(struct net *net, u32 bearer_id, u32 dest); 210 209 void tipc_bearer_remove_dest(struct net *net, u32 bearer_id, u32 dest); 211 210 struct tipc_bearer *tipc_bearer_find(struct net *net, const char *name);
-3
net/tipc/config.c
··· 252 252 rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area, 253 253 req_tlv_space); 254 254 break; 255 - case TIPC_CMD_GET_BEARER_NAMES: 256 - rep_tlv_buf = tipc_bearer_get_names(net); 257 - break; 258 255 case TIPC_CMD_GET_MEDIA_NAMES: 259 256 rep_tlv_buf = tipc_media_get_names(); 260 257 break;