Hi Masahiro, I love your patch! Yet something to improve: [auto build test ERROR on kbuild/for-next] [also build test ERROR on v5.5-rc5 next-20191220] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982] url: https://github.com/0day-ci/linux/commits/Masahiro-Yamada/kbuild-allow-modules-to-link-a-archives/20200106-112554 base: https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next config: x86_64-rhel (attached as .config) compiler: gcc-7 (Debian 7.5.0-3) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 If you fix the issue, kindly add following tag Reported-by: kbuild test robot All errors (new ones prefixed by >>): ld: net/tipc/socket.o: in function `tipc_nl_sk_walk': >> net/tipc/socket.c:3449: multiple definition of `tipc_nl_sk_walk'; net/tipc/socket.o:net/tipc/socket.c:3449: first defined here ld: net/tipc/socket.o: in function `tipc_dump_start': >> net/tipc/socket.c:3485: multiple definition of `tipc_dump_start'; net/tipc/socket.o:net/tipc/socket.c:3485: first defined here ld: net/tipc/socket.o: in function `tipc_dump_done': >> net/tipc/socket.c:3509: multiple definition of `tipc_dump_done'; net/tipc/socket.o:net/tipc/socket.c:3509: first defined here ld: net/tipc/socket.o: in function `tipc_sk_fill_sock_diag': >> net/tipc/socket.c:3521: multiple definition of `tipc_sk_fill_sock_diag'; net/tipc/socket.o:net/tipc/socket.c:3521: first defined here ld: net/tipc/socket.o: in function `tipc_sk_reinit': >> net/tipc/socket.c:2858: multiple definition of `tipc_sk_reinit'; net/tipc/socket.o:net/tipc/socket.c:2858: first defined here ld: net/tipc/socket.o: in function `tipc_sk_rht_init': >> net/tipc/socket.c:2946: multiple definition of `tipc_sk_rht_init'; net/tipc/socket.o:net/tipc/socket.c:2946: first defined here ld: net/tipc/socket.o: in function `tipc_sk_rht_destroy': >> net/tipc/socket.c:2953: multiple definition of `tipc_sk_rht_destroy'; net/tipc/socket.o:net/tipc/socket.c:2953: first defined here ld: net/tipc/socket.o: in function `tipc_socket_init': >> net/tipc/socket.c:3328: multiple definition of `tipc_socket_init'; net/tipc/socket.o:net/tipc/socket.c:3328: first defined here ld: net/tipc/socket.o: in function `tipc_socket_stop': >> net/tipc/socket.c:3351: multiple definition of `tipc_socket_stop'; net/tipc/socket.o:net/tipc/socket.c:3351: first defined here ld: net/tipc/socket.o: in function `__tipc_dump_start': >> net/tipc/socket.c:3491: multiple definition of `__tipc_dump_start'; net/tipc/socket.o:net/tipc/socket.c:3491: first defined here ld: net/tipc/socket.o: in function `tipc_nl_sk_dump': >> net/tipc/socket.c:3588: multiple definition of `tipc_nl_sk_dump'; net/tipc/socket.o:net/tipc/socket.c:3588: first defined here ld: net/tipc/socket.o: in function `tipc_nl_publ_dump': >> net/tipc/socket.c:3673: multiple definition of `tipc_nl_publ_dump'; net/tipc/socket.o:net/tipc/socket.c:3673: first defined here ld: net/tipc/socket.o: in function `tipc_sk_filtering': >> net/tipc/socket.c:3732: multiple definition of `tipc_sk_filtering'; net/tipc/socket.o:net/tipc/socket.c:3732: first defined here ld: net/tipc/socket.o: in function `tipc_sk_rcv': >> net/tipc/socket.c:2374: multiple definition of `tipc_sk_rcv'; net/tipc/socket.o:net/tipc/socket.c:2374: first defined here ld: net/tipc/socket.o: in function `tipc_sk_mcast_rcv': >> net/tipc/socket.c:1163: multiple definition of `tipc_sk_mcast_rcv'; net/tipc/socket.o:net/tipc/socket.c:1163: first defined here ld: net/tipc/socket.o: in function `tipc_sock_get_portid': >> net/tipc/socket.c:3782: multiple definition of `tipc_sock_get_portid'; net/tipc/socket.o:net/tipc/socket.c:3782: first defined here ld: net/tipc/socket.o: in function `tipc_sk_overlimit1': >> net/tipc/socket.c:3796: multiple definition of `tipc_sk_overlimit1'; net/tipc/socket.o:net/tipc/socket.c:3796: first defined here ld: net/tipc/socket.o: in function `tipc_sk_overlimit2': >> net/tipc/socket.c:3814: multiple definition of `tipc_sk_overlimit2'; net/tipc/socket.o:net/tipc/socket.c:3814: first defined here ld: net/tipc/socket.o: in function `tipc_sk_dump': >> net/tipc/socket.c:3833: multiple definition of `tipc_sk_dump'; net/tipc/socket.o:net/tipc/socket.c:3833: first defined here vim +3449 net/tipc/socket.c b97bf3fd8f6a16 Per Liden 2006-01-02 3321 b97bf3fd8f6a16 Per Liden 2006-01-02 3322 /** 4323add67792ce Per Liden 2006-01-18 3323 * tipc_socket_init - initialize TIPC socket interface b97bf3fd8f6a16 Per Liden 2006-01-02 3324 * b97bf3fd8f6a16 Per Liden 2006-01-02 3325 * Returns 0 on success, errno otherwise b97bf3fd8f6a16 Per Liden 2006-01-02 3326 */ 4323add67792ce Per Liden 2006-01-18 3327 int tipc_socket_init(void) b97bf3fd8f6a16 Per Liden 2006-01-02 @3328 { b97bf3fd8f6a16 Per Liden 2006-01-02 3329 int res; b97bf3fd8f6a16 Per Liden 2006-01-02 3330 b97bf3fd8f6a16 Per Liden 2006-01-02 3331 res = proto_register(&tipc_proto, 1); b97bf3fd8f6a16 Per Liden 2006-01-02 3332 if (res) { 2cf8aa19fe8bec Erik Hugne 2012-06-29 3333 pr_err("Failed to register TIPC protocol type\n"); b97bf3fd8f6a16 Per Liden 2006-01-02 3334 goto out; b97bf3fd8f6a16 Per Liden 2006-01-02 3335 } b97bf3fd8f6a16 Per Liden 2006-01-02 3336 b97bf3fd8f6a16 Per Liden 2006-01-02 3337 res = sock_register(&tipc_family_ops); b97bf3fd8f6a16 Per Liden 2006-01-02 3338 if (res) { 2cf8aa19fe8bec Erik Hugne 2012-06-29 3339 pr_err("Failed to register TIPC socket type\n"); b97bf3fd8f6a16 Per Liden 2006-01-02 3340 proto_unregister(&tipc_proto); b97bf3fd8f6a16 Per Liden 2006-01-02 3341 goto out; b97bf3fd8f6a16 Per Liden 2006-01-02 3342 } b97bf3fd8f6a16 Per Liden 2006-01-02 3343 out: b97bf3fd8f6a16 Per Liden 2006-01-02 3344 return res; b97bf3fd8f6a16 Per Liden 2006-01-02 3345 } b97bf3fd8f6a16 Per Liden 2006-01-02 3346 b97bf3fd8f6a16 Per Liden 2006-01-02 3347 /** 4323add67792ce Per Liden 2006-01-18 3348 * tipc_socket_stop - stop TIPC socket interface b97bf3fd8f6a16 Per Liden 2006-01-02 3349 */ 4323add67792ce Per Liden 2006-01-18 3350 void tipc_socket_stop(void) b97bf3fd8f6a16 Per Liden 2006-01-02 @3351 { b97bf3fd8f6a16 Per Liden 2006-01-02 3352 sock_unregister(tipc_family_ops.family); b97bf3fd8f6a16 Per Liden 2006-01-02 3353 proto_unregister(&tipc_proto); b97bf3fd8f6a16 Per Liden 2006-01-02 3354 } 34b78a127c4fd5 Richard Alpe 2014-11-20 3355 34b78a127c4fd5 Richard Alpe 2014-11-20 3356 /* Caller should hold socket lock for the passed tipc socket. */ d8182804cfd650 Richard Alpe 2014-11-24 3357 static int __tipc_nl_add_sk_con(struct sk_buff *skb, struct tipc_sock *tsk) 34b78a127c4fd5 Richard Alpe 2014-11-20 3358 { 34b78a127c4fd5 Richard Alpe 2014-11-20 3359 u32 peer_node; 34b78a127c4fd5 Richard Alpe 2014-11-20 3360 u32 peer_port; 34b78a127c4fd5 Richard Alpe 2014-11-20 3361 struct nlattr *nest; 34b78a127c4fd5 Richard Alpe 2014-11-20 3362 34b78a127c4fd5 Richard Alpe 2014-11-20 3363 peer_node = tsk_peer_node(tsk); 34b78a127c4fd5 Richard Alpe 2014-11-20 3364 peer_port = tsk_peer_port(tsk); 34b78a127c4fd5 Richard Alpe 2014-11-20 3365 ae0be8de9a53cd Michal Kubecek 2019-04-26 3366 nest = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_CON); 517ccc2aa50dbd Kangjie Lu 2019-03-16 3367 if (!nest) 517ccc2aa50dbd Kangjie Lu 2019-03-16 3368 return -EMSGSIZE; 34b78a127c4fd5 Richard Alpe 2014-11-20 3369 34b78a127c4fd5 Richard Alpe 2014-11-20 3370 if (nla_put_u32(skb, TIPC_NLA_CON_NODE, peer_node)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3371 goto msg_full; 34b78a127c4fd5 Richard Alpe 2014-11-20 3372 if (nla_put_u32(skb, TIPC_NLA_CON_SOCK, peer_port)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3373 goto msg_full; 34b78a127c4fd5 Richard Alpe 2014-11-20 3374 34b78a127c4fd5 Richard Alpe 2014-11-20 3375 if (tsk->conn_type != 0) { 34b78a127c4fd5 Richard Alpe 2014-11-20 3376 if (nla_put_flag(skb, TIPC_NLA_CON_FLAG)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3377 goto msg_full; 34b78a127c4fd5 Richard Alpe 2014-11-20 3378 if (nla_put_u32(skb, TIPC_NLA_CON_TYPE, tsk->conn_type)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3379 goto msg_full; 34b78a127c4fd5 Richard Alpe 2014-11-20 3380 if (nla_put_u32(skb, TIPC_NLA_CON_INST, tsk->conn_instance)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3381 goto msg_full; 34b78a127c4fd5 Richard Alpe 2014-11-20 3382 } 34b78a127c4fd5 Richard Alpe 2014-11-20 3383 nla_nest_end(skb, nest); 34b78a127c4fd5 Richard Alpe 2014-11-20 3384 34b78a127c4fd5 Richard Alpe 2014-11-20 3385 return 0; 34b78a127c4fd5 Richard Alpe 2014-11-20 3386 34b78a127c4fd5 Richard Alpe 2014-11-20 3387 msg_full: 34b78a127c4fd5 Richard Alpe 2014-11-20 3388 nla_nest_cancel(skb, nest); 34b78a127c4fd5 Richard Alpe 2014-11-20 3389 34b78a127c4fd5 Richard Alpe 2014-11-20 3390 return -EMSGSIZE; 34b78a127c4fd5 Richard Alpe 2014-11-20 3391 } 34b78a127c4fd5 Richard Alpe 2014-11-20 3392 dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3393 static int __tipc_nl_add_sk_info(struct sk_buff *skb, struct tipc_sock dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3394 *tsk) dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3395 { dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3396 struct net *net = sock_net(skb->sk); dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3397 struct sock *sk = &tsk->sk; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3398 dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3399 if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || 23fd3eace088ab Jon Maloy 2018-03-22 3400 nla_put_u32(skb, TIPC_NLA_SOCK_ADDR, tipc_own_addr(net))) dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3401 return -EMSGSIZE; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3402 dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3403 if (tipc_sk_connected(sk)) { dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3404 if (__tipc_nl_add_sk_con(skb, tsk)) dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3405 return -EMSGSIZE; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3406 } else if (!list_empty(&tsk->publications)) { dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3407 if (nla_put_flag(skb, TIPC_NLA_SOCK_HAS_PUBL)) dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3408 return -EMSGSIZE; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3409 } dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3410 return 0; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3411 } dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3412 34b78a127c4fd5 Richard Alpe 2014-11-20 3413 /* Caller should hold socket lock for the passed tipc socket. */ d8182804cfd650 Richard Alpe 2014-11-24 3414 static int __tipc_nl_add_sk(struct sk_buff *skb, struct netlink_callback *cb, 34b78a127c4fd5 Richard Alpe 2014-11-20 3415 struct tipc_sock *tsk) 34b78a127c4fd5 Richard Alpe 2014-11-20 3416 { 34b78a127c4fd5 Richard Alpe 2014-11-20 3417 struct nlattr *attrs; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3418 void *hdr; 34b78a127c4fd5 Richard Alpe 2014-11-20 3419 34b78a127c4fd5 Richard Alpe 2014-11-20 3420 hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, bfb3e5dd8dfd84 Richard Alpe 2015-02-09 3421 &tipc_genl_family, NLM_F_MULTI, TIPC_NL_SOCK_GET); 34b78a127c4fd5 Richard Alpe 2014-11-20 3422 if (!hdr) 34b78a127c4fd5 Richard Alpe 2014-11-20 3423 goto msg_cancel; 34b78a127c4fd5 Richard Alpe 2014-11-20 3424 ae0be8de9a53cd Michal Kubecek 2019-04-26 3425 attrs = nla_nest_start_noflag(skb, TIPC_NLA_SOCK); 34b78a127c4fd5 Richard Alpe 2014-11-20 3426 if (!attrs) 34b78a127c4fd5 Richard Alpe 2014-11-20 3427 goto genlmsg_cancel; 34b78a127c4fd5 Richard Alpe 2014-11-20 3428 dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3429 if (__tipc_nl_add_sk_info(skb, tsk)) 34b78a127c4fd5 Richard Alpe 2014-11-20 3430 goto attr_msg_cancel; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3431 34b78a127c4fd5 Richard Alpe 2014-11-20 3432 nla_nest_end(skb, attrs); 34b78a127c4fd5 Richard Alpe 2014-11-20 3433 genlmsg_end(skb, hdr); 34b78a127c4fd5 Richard Alpe 2014-11-20 3434 34b78a127c4fd5 Richard Alpe 2014-11-20 3435 return 0; 34b78a127c4fd5 Richard Alpe 2014-11-20 3436 34b78a127c4fd5 Richard Alpe 2014-11-20 3437 attr_msg_cancel: 34b78a127c4fd5 Richard Alpe 2014-11-20 3438 nla_nest_cancel(skb, attrs); 34b78a127c4fd5 Richard Alpe 2014-11-20 3439 genlmsg_cancel: 34b78a127c4fd5 Richard Alpe 2014-11-20 3440 genlmsg_cancel(skb, hdr); 34b78a127c4fd5 Richard Alpe 2014-11-20 3441 msg_cancel: 34b78a127c4fd5 Richard Alpe 2014-11-20 3442 return -EMSGSIZE; 34b78a127c4fd5 Richard Alpe 2014-11-20 3443 } 34b78a127c4fd5 Richard Alpe 2014-11-20 3444 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3445 int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb, dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3446 int (*skb_handler)(struct sk_buff *skb, dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3447 struct netlink_callback *cb, dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3448 struct tipc_sock *tsk)) 34b78a127c4fd5 Richard Alpe 2014-11-20 @3449 { 8f5c5fcf353302 Cong Wang 2018-09-04 3450 struct rhashtable_iter *iter = (void *)cb->args[4]; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3451 struct tipc_sock *tsk; dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3452 int err; 34b78a127c4fd5 Richard Alpe 2014-11-20 3453 9a07efa9aea2f4 Cong Wang 2018-08-24 3454 rhashtable_walk_start(iter); 9a07efa9aea2f4 Cong Wang 2018-08-24 3455 while ((tsk = rhashtable_walk_next(iter)) != NULL) { 9a07efa9aea2f4 Cong Wang 2018-08-24 3456 if (IS_ERR(tsk)) { 9a07efa9aea2f4 Cong Wang 2018-08-24 3457 err = PTR_ERR(tsk); 9a07efa9aea2f4 Cong Wang 2018-08-24 3458 if (err == -EAGAIN) { 9a07efa9aea2f4 Cong Wang 2018-08-24 3459 err = 0; d6e164e3215794 Richard Alpe 2015-01-16 3460 continue; d6e164e3215794 Richard Alpe 2015-01-16 3461 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3462 break; 9a07efa9aea2f4 Cong Wang 2018-08-24 3463 } 34b78a127c4fd5 Richard Alpe 2014-11-20 3464 9a07efa9aea2f4 Cong Wang 2018-08-24 3465 sock_hold(&tsk->sk); 9a07efa9aea2f4 Cong Wang 2018-08-24 3466 rhashtable_walk_stop(iter); 9a07efa9aea2f4 Cong Wang 2018-08-24 3467 lock_sock(&tsk->sk); dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3468 err = skb_handler(skb, cb, tsk); d6e164e3215794 Richard Alpe 2015-01-16 3469 if (err) { 9a07efa9aea2f4 Cong Wang 2018-08-24 3470 release_sock(&tsk->sk); 9a07efa9aea2f4 Cong Wang 2018-08-24 3471 sock_put(&tsk->sk); d6e164e3215794 Richard Alpe 2015-01-16 3472 goto out; 34b78a127c4fd5 Richard Alpe 2014-11-20 3473 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3474 release_sock(&tsk->sk); 9a07efa9aea2f4 Cong Wang 2018-08-24 3475 rhashtable_walk_start(iter); 9a07efa9aea2f4 Cong Wang 2018-08-24 3476 sock_put(&tsk->sk); d6e164e3215794 Richard Alpe 2015-01-16 3477 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3478 rhashtable_walk_stop(iter); d6e164e3215794 Richard Alpe 2015-01-16 3479 out: 34b78a127c4fd5 Richard Alpe 2014-11-20 3480 return skb->len; 34b78a127c4fd5 Richard Alpe 2014-11-20 3481 } c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3482 EXPORT_SYMBOL(tipc_nl_sk_walk); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3483 9a07efa9aea2f4 Cong Wang 2018-08-24 3484 int tipc_dump_start(struct netlink_callback *cb) 9a07efa9aea2f4 Cong Wang 2018-08-24 @3485 { 8f5c5fcf353302 Cong Wang 2018-09-04 3486 return __tipc_dump_start(cb, sock_net(cb->skb->sk)); 8f5c5fcf353302 Cong Wang 2018-09-04 3487 } 8f5c5fcf353302 Cong Wang 2018-09-04 3488 EXPORT_SYMBOL(tipc_dump_start); 8f5c5fcf353302 Cong Wang 2018-09-04 3489 8f5c5fcf353302 Cong Wang 2018-09-04 3490 int __tipc_dump_start(struct netlink_callback *cb, struct net *net) 8f5c5fcf353302 Cong Wang 2018-09-04 @3491 { 8f5c5fcf353302 Cong Wang 2018-09-04 3492 /* tipc_nl_name_table_dump() uses cb->args[0...3]. */ 8f5c5fcf353302 Cong Wang 2018-09-04 3493 struct rhashtable_iter *iter = (void *)cb->args[4]; 9a07efa9aea2f4 Cong Wang 2018-08-24 3494 struct tipc_net *tn = tipc_net(net); 9a07efa9aea2f4 Cong Wang 2018-08-24 3495 9a07efa9aea2f4 Cong Wang 2018-08-24 3496 if (!iter) { 9a07efa9aea2f4 Cong Wang 2018-08-24 3497 iter = kmalloc(sizeof(*iter), GFP_KERNEL); 9a07efa9aea2f4 Cong Wang 2018-08-24 3498 if (!iter) 9a07efa9aea2f4 Cong Wang 2018-08-24 3499 return -ENOMEM; 9a07efa9aea2f4 Cong Wang 2018-08-24 3500 8f5c5fcf353302 Cong Wang 2018-09-04 3501 cb->args[4] = (long)iter; 9a07efa9aea2f4 Cong Wang 2018-08-24 3502 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3503 9a07efa9aea2f4 Cong Wang 2018-08-24 3504 rhashtable_walk_enter(&tn->sk_rht, iter); 9a07efa9aea2f4 Cong Wang 2018-08-24 3505 return 0; 9a07efa9aea2f4 Cong Wang 2018-08-24 3506 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3507 9a07efa9aea2f4 Cong Wang 2018-08-24 3508 int tipc_dump_done(struct netlink_callback *cb) 9a07efa9aea2f4 Cong Wang 2018-08-24 @3509 { 8f5c5fcf353302 Cong Wang 2018-09-04 3510 struct rhashtable_iter *hti = (void *)cb->args[4]; 9a07efa9aea2f4 Cong Wang 2018-08-24 3511 9a07efa9aea2f4 Cong Wang 2018-08-24 3512 rhashtable_walk_exit(hti); 9a07efa9aea2f4 Cong Wang 2018-08-24 3513 kfree(hti); 9a07efa9aea2f4 Cong Wang 2018-08-24 3514 return 0; 9a07efa9aea2f4 Cong Wang 2018-08-24 3515 } 9a07efa9aea2f4 Cong Wang 2018-08-24 3516 EXPORT_SYMBOL(tipc_dump_done); 9a07efa9aea2f4 Cong Wang 2018-08-24 3517 e41f0548473eb7 Cong Wang 2018-04-06 3518 int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb, e41f0548473eb7 Cong Wang 2018-04-06 3519 struct tipc_sock *tsk, u32 sk_filter_state, c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3520 u64 (*tipc_diag_gen_cookie)(struct sock *sk)) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 @3521 { c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3522 struct sock *sk = &tsk->sk; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3523 struct nlattr *attrs; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3524 struct nlattr *stat; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3525 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3526 /*filter response w.r.t sk_state*/ c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3527 if (!(sk_filter_state & (1 << sk->sk_state))) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3528 return 0; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3529 ae0be8de9a53cd Michal Kubecek 2019-04-26 3530 attrs = nla_nest_start_noflag(skb, TIPC_NLA_SOCK); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3531 if (!attrs) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3532 goto msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3533 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3534 if (__tipc_nl_add_sk_info(skb, tsk)) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3535 goto attr_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3536 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3537 if (nla_put_u32(skb, TIPC_NLA_SOCK_TYPE, (u32)sk->sk_type) || c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3538 nla_put_u32(skb, TIPC_NLA_SOCK_TIPC_STATE, (u32)sk->sk_state) || c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3539 nla_put_u32(skb, TIPC_NLA_SOCK_INO, sock_i_ino(sk)) || c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3540 nla_put_u32(skb, TIPC_NLA_SOCK_UID, e41f0548473eb7 Cong Wang 2018-04-06 3541 from_kuid_munged(sk_user_ns(NETLINK_CB(cb->skb).sk), 4b2e6877b8793b GhantaKrishnamurthy MohanKrishna 2018-04-04 3542 sock_i_uid(sk))) || c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3543 nla_put_u64_64bit(skb, TIPC_NLA_SOCK_COOKIE, c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3544 tipc_diag_gen_cookie(sk), c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3545 TIPC_NLA_SOCK_PAD)) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3546 goto attr_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3547 ae0be8de9a53cd Michal Kubecek 2019-04-26 3548 stat = nla_nest_start_noflag(skb, TIPC_NLA_SOCK_STAT); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3549 if (!stat) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3550 goto attr_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3551 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3552 if (nla_put_u32(skb, TIPC_NLA_SOCK_STAT_RCVQ, c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3553 skb_queue_len(&sk->sk_receive_queue)) || c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3554 nla_put_u32(skb, TIPC_NLA_SOCK_STAT_SENDQ, 872619d8cf810c GhantaKrishnamurthy MohanKrishna 2018-03-21 3555 skb_queue_len(&sk->sk_write_queue)) || 872619d8cf810c GhantaKrishnamurthy MohanKrishna 2018-03-21 3556 nla_put_u32(skb, TIPC_NLA_SOCK_STAT_DROP, 872619d8cf810c GhantaKrishnamurthy MohanKrishna 2018-03-21 3557 atomic_read(&sk->sk_drops))) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3558 goto stat_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3559 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3560 if (tsk->cong_link_cnt && c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3561 nla_put_flag(skb, TIPC_NLA_SOCK_STAT_LINK_CONG)) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3562 goto stat_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3563 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3564 if (tsk_conn_cong(tsk) && c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3565 nla_put_flag(skb, TIPC_NLA_SOCK_STAT_CONN_CONG)) c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3566 goto stat_msg_cancel; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3567 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3568 nla_nest_end(skb, stat); a1be5a20f137bd GhantaKrishnamurthy MohanKrishna 2018-06-29 3569 a1be5a20f137bd GhantaKrishnamurthy MohanKrishna 2018-06-29 3570 if (tsk->group) a1be5a20f137bd GhantaKrishnamurthy MohanKrishna 2018-06-29 3571 if (tipc_group_fill_sock_diag(tsk->group, skb)) a1be5a20f137bd GhantaKrishnamurthy MohanKrishna 2018-06-29 3572 goto stat_msg_cancel; a1be5a20f137bd GhantaKrishnamurthy MohanKrishna 2018-06-29 3573 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3574 nla_nest_end(skb, attrs); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3575 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3576 return 0; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3577 c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3578 stat_msg_cancel: c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3579 nla_nest_cancel(skb, stat); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3580 attr_msg_cancel: c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3581 nla_nest_cancel(skb, attrs); c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3582 msg_cancel: c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3583 return -EMSGSIZE; c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3584 } c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3585 EXPORT_SYMBOL(tipc_sk_fill_sock_diag); 1a1a143daf84db Richard Alpe 2014-11-20 3586 dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3587 int tipc_nl_sk_dump(struct sk_buff *skb, struct netlink_callback *cb) dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 @3588 { c30b70deb5f486 GhantaKrishnamurthy MohanKrishna 2018-03-21 3589 return tipc_nl_sk_walk(skb, cb, __tipc_nl_add_sk); dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3590 } dfde331e757fd7 GhantaKrishnamurthy MohanKrishna 2018-03-21 3591 :::::: The code at line 3449 was first introduced by commit :::::: 34b78a127c4fd57cf3d5c64031693d10a8e0fae1 tipc: add sock dump to new netlink api :::::: TO: Richard Alpe :::::: CC: David S. Miller --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation