Commit 2f2d76cc3e938389feee671b46252dde6880b3b7
Committed by
David S. Miller
1 parent
0343c5543b
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
dlm: Do not allocate a fd for peeloff
avoids allocating a fd that a) propagates to every kernel thread and usermodehelper b) is not properly released. References: http://article.gmane.org/gmane.linux.network.drbd/22529 Signed-off-by: Benjamin Poirier <bpoirier@suse.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 8 additions and 14 deletions Side-by-side Diff
fs/dlm/lowcomms.c
... | ... | @@ -52,6 +52,7 @@ |
52 | 52 | #include <linux/mutex.h> |
53 | 53 | #include <linux/sctp.h> |
54 | 54 | #include <linux/slab.h> |
55 | +#include <net/sctp/sctp.h> | |
55 | 56 | #include <net/sctp/user.h> |
56 | 57 | #include <net/ipv6.h> |
57 | 58 | |
... | ... | @@ -474,9 +475,6 @@ |
474 | 475 | int prim_len, ret; |
475 | 476 | int addr_len; |
476 | 477 | struct connection *new_con; |
477 | - sctp_peeloff_arg_t parg; | |
478 | - int parglen = sizeof(parg); | |
479 | - int err; | |
480 | 478 | |
481 | 479 | /* |
482 | 480 | * We get this before any data for an association. |
483 | 481 | |
484 | 482 | |
485 | 483 | |
... | ... | @@ -525,23 +523,19 @@ |
525 | 523 | return; |
526 | 524 | |
527 | 525 | /* Peel off a new sock */ |
528 | - parg.associd = sn->sn_assoc_change.sac_assoc_id; | |
529 | - ret = kernel_getsockopt(con->sock, IPPROTO_SCTP, | |
530 | - SCTP_SOCKOPT_PEELOFF, | |
531 | - (void *)&parg, &parglen); | |
526 | + sctp_lock_sock(con->sock->sk); | |
527 | + ret = sctp_do_peeloff(con->sock->sk, | |
528 | + sn->sn_assoc_change.sac_assoc_id, | |
529 | + &new_con->sock); | |
530 | + sctp_release_sock(con->sock->sk); | |
532 | 531 | if (ret < 0) { |
533 | 532 | log_print("Can't peel off a socket for " |
534 | 533 | "connection %d to node %d: err=%d", |
535 | - parg.associd, nodeid, ret); | |
534 | + (int)sn->sn_assoc_change.sac_assoc_id, | |
535 | + nodeid, ret); | |
536 | 536 | return; |
537 | 537 | } |
538 | - new_con->sock = sockfd_lookup(parg.sd, &err); | |
539 | - if (!new_con->sock) { | |
540 | - log_print("sockfd_lookup error %d", err); | |
541 | - return; | |
542 | - } | |
543 | 538 | add_sock(new_con->sock, new_con); |
544 | - sockfd_put(new_con->sock); | |
545 | 539 | |
546 | 540 | log_print("connecting to %d sctp association %d", |
547 | 541 | nodeid, (int)sn->sn_assoc_change.sac_assoc_id); |