aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2014-07-16 20:41:01 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-17 00:38:18 -0400
commit0abd8ff21f19adddc465538354e9baaca63df073 (patch)
tree2bd115aaf2ed69960ae13e6784f322217ee11a53 /net/tipc
parent078bec826f7b73cf2a2397680537bcb7e075b492 (diff)
tipc: start using the new multicast functions
In this commit, we convert the socket multicast send function to directly call the new multicast/broadcast function (tipc_bclink_xmit2()) introduced in the previous commit. We do this instead of letting the call go via the now obsolete tipc_port_mcast_xmit(), hence saving a call level and some code complexity. We also remove the initial destination lookup at the message sending side, and replace that with an unconditional lookup at the receiving side, including on the sending node itself. This makes the destination lookup and message transfer more uniform than before. Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-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/bcast.c7
-rw-r--r--net/tipc/socket.c90
2 files changed, 56 insertions, 41 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index ac947251dd37..4a1c9afc9d74 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -496,7 +496,7 @@ void tipc_bclink_rcv(struct sk_buff *buf)
496 struct tipc_node *node; 496 struct tipc_node *node;
497 u32 next_in; 497 u32 next_in;
498 u32 seqno; 498 u32 seqno;
499 int deferred; 499 int deferred = 0;
500 500
501 /* Screen out unwanted broadcast messages */ 501 /* Screen out unwanted broadcast messages */
502 502
@@ -547,7 +547,7 @@ receive:
547 tipc_bclink_unlock(); 547 tipc_bclink_unlock();
548 tipc_node_unlock(node); 548 tipc_node_unlock(node);
549 if (likely(msg_mcast(msg))) 549 if (likely(msg_mcast(msg)))
550 tipc_port_mcast_rcv(buf, NULL); 550 tipc_sk_mcast_rcv(buf);
551 else 551 else
552 kfree_skb(buf); 552 kfree_skb(buf);
553 } else if (msg_user(msg) == MSG_BUNDLER) { 553 } else if (msg_user(msg) == MSG_BUNDLER) {
@@ -626,8 +626,7 @@ receive:
626 node->bclink.deferred_size += deferred; 626 node->bclink.deferred_size += deferred;
627 bclink_update_last_sent(node, seqno); 627 bclink_update_last_sent(node, seqno);
628 buf = NULL; 628 buf = NULL;
629 } else 629 }
630 deferred = 0;
631 630
632 tipc_bclink_lock(); 631 tipc_bclink_lock();
633 632
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 8d30995682b1..b28eea50c7fc 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -53,6 +53,7 @@ static void tipc_data_ready(struct sock *sk);
53static void tipc_write_space(struct sock *sk); 53static void tipc_write_space(struct sock *sk);
54static int tipc_release(struct socket *sock); 54static int tipc_release(struct socket *sock);
55static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags); 55static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags);
56static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p);
56 57
57static const struct proto_ops packet_ops; 58static const struct proto_ops packet_ops;
58static const struct proto_ops stream_ops; 59static const struct proto_ops stream_ops;
@@ -534,6 +535,58 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
534 return mask; 535 return mask;
535} 536}
536 537
538/**
539 * tipc_sendmcast - send multicast message
540 * @sock: socket structure
541 * @seq: destination address
542 * @iov: message data to send
543 * @dsz: total length of message data
544 * @timeo: timeout to wait for wakeup
545 *
546 * Called from function tipc_sendmsg(), which has done all sanity checks
547 * Returns the number of bytes sent on success, or errno
548 */
549static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq,
550 struct iovec *iov, size_t dsz, long timeo)
551{
552 struct sock *sk = sock->sk;
553 struct tipc_msg *mhdr = &tipc_sk(sk)->port.phdr;
554 struct sk_buff *buf;
555 uint mtu;
556 int rc;
557
558 msg_set_type(mhdr, TIPC_MCAST_MSG);
559 msg_set_lookup_scope(mhdr, TIPC_CLUSTER_SCOPE);
560 msg_set_destport(mhdr, 0);
561 msg_set_destnode(mhdr, 0);
562 msg_set_nametype(mhdr, seq->type);
563 msg_set_namelower(mhdr, seq->lower);
564 msg_set_nameupper(mhdr, seq->upper);
565 msg_set_hdr_sz(mhdr, MCAST_H_SIZE);
566
567new_mtu:
568 mtu = tipc_bclink_get_mtu();
569 rc = tipc_msg_build2(mhdr, iov, 0, dsz, mtu, &buf);
570 if (unlikely(rc < 0))
571 return rc;
572
573 do {
574 rc = tipc_bclink_xmit(buf);
575 if (likely(rc >= 0)) {
576 rc = dsz;
577 break;
578 }
579 if (rc == -EMSGSIZE)
580 goto new_mtu;
581 if (rc != -ELINKCONG)
582 break;
583 rc = tipc_wait_for_sndmsg(sock, &timeo);
584 if (rc)
585 kfree_skb_list(buf);
586 } while (!rc);
587 return rc;
588}
589
537/* tipc_sk_mcast_rcv - Deliver multicast message to all destination sockets 590/* tipc_sk_mcast_rcv - Deliver multicast message to all destination sockets
538 */ 591 */
539void tipc_sk_mcast_rcv(struct sk_buff *buf) 592void tipc_sk_mcast_rcv(struct sk_buff *buf)
@@ -670,43 +723,6 @@ static int tipc_wait_for_sndmsg(struct socket *sock, long *timeo_p)
670} 723}
671 724
672/** 725/**
673 * tipc_sendmcast - send multicast message
674 * @sock: socket structure
675 * @seq: destination address
676 * @iov: message data to send
677 * @dsz: total length of message data
678 * @timeo: timeout to wait for wakeup
679 *
680 * Called from function tipc_sendmsg(), which has done all sanity checks
681 * Returns the number of bytes sent on success, or errno
682 */
683static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq,
684 struct iovec *iov, size_t dsz, long timeo)
685{
686 struct sock *sk = sock->sk;
687 struct tipc_sock *tsk = tipc_sk(sk);
688 int rc;
689
690 do {
691 if (sock->state != SS_READY) {
692 rc = -EOPNOTSUPP;
693 break;
694 }
695 rc = tipc_port_mcast_xmit(&tsk->port, seq, iov, dsz);
696 if (likely(rc >= 0)) {
697 if (sock->state != SS_READY)
698 sock->state = SS_CONNECTING;
699 break;
700 }
701 if (rc != -ELINKCONG)
702 break;
703 rc = tipc_wait_for_sndmsg(sock, &timeo);
704 } while (!rc);
705
706 return rc;
707}
708
709/**
710 * tipc_sendmsg - send message in connectionless manner 726 * tipc_sendmsg - send message in connectionless manner
711 * @iocb: if NULL, indicates that socket lock is already held 727 * @iocb: if NULL, indicates that socket lock is already held
712 * @sock: socket structure 728 * @sock: socket structure