diff options
author | Jon Maloy <jon.maloy@ericsson.com> | 2018-02-15 10:40:42 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-02-16 15:26:33 -0500 |
commit | 27469b7352b5197cffa0e3dadb5f1127f055da27 (patch) | |
tree | 3d69eb67760f1e213820be002e634990be8edf35 | |
parent | 35ed663f5f4f70dd750ea3e0166c5b90db9feea3 (diff) | |
download | blackbird-op-linux-27469b7352b5197cffa0e3dadb5f1127f055da27.tar.gz blackbird-op-linux-27469b7352b5197cffa0e3dadb5f1127f055da27.zip |
tipc: remove redundant code in topology server
The socket handling in the topology server is unnecessarily generic.
It is prepared to handle both SOCK_RDM, SOCK_DGRAM and SOCK_STREAM
type sockets, as well as the only socket type which is really used,
SOCK_SEQPACKET.
We now remove this redundant code to make the code more readable.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/server.c | 36 | ||||
-rw-r--r-- | net/tipc/server.h | 4 | ||||
-rw-r--r-- | net/tipc/subscr.c | 4 |
3 files changed, 9 insertions, 35 deletions
diff --git a/net/tipc/server.c b/net/tipc/server.c index df0c563c90cd..04a6dd99dd65 100644 --- a/net/tipc/server.c +++ b/net/tipc/server.c @@ -82,7 +82,6 @@ struct tipc_conn { struct outqueue_entry { struct list_head list; struct kvec iov; - struct sockaddr_tipc dest; }; static void tipc_recv_work(struct work_struct *work); @@ -93,7 +92,6 @@ static void tipc_conn_kref_release(struct kref *kref) { struct tipc_conn *con = container_of(kref, struct tipc_conn, kref); struct tipc_server *s = con->server; - struct sockaddr_tipc *saddr = s->saddr; struct socket *sock = con->sock; struct sock *sk; @@ -103,8 +101,6 @@ static void tipc_conn_kref_release(struct kref *kref) __module_get(sock->ops->owner); __module_get(sk->sk_prot_creator->owner); } - saddr->scope = -TIPC_NODE_SCOPE; - kernel_bind(sock, (struct sockaddr *)saddr, sizeof(*saddr)); sock_release(sock); con->sock = NULL; } @@ -325,36 +321,24 @@ static struct socket *tipc_create_listen_sock(struct tipc_conn *con) { struct tipc_server *s = con->server; struct socket *sock = NULL; + int imp = TIPC_CRITICAL_IMPORTANCE; int ret; ret = sock_create_kern(s->net, AF_TIPC, SOCK_SEQPACKET, 0, &sock); if (ret < 0) return NULL; ret = kernel_setsockopt(sock, SOL_TIPC, TIPC_IMPORTANCE, - (char *)&s->imp, sizeof(s->imp)); + (char *)&imp, sizeof(imp)); if (ret < 0) goto create_err; ret = kernel_bind(sock, (struct sockaddr *)s->saddr, sizeof(*s->saddr)); if (ret < 0) goto create_err; - switch (s->type) { - case SOCK_STREAM: - case SOCK_SEQPACKET: - con->rx_action = tipc_accept_from_sock; - - ret = kernel_listen(sock, 0); - if (ret < 0) - goto create_err; - break; - case SOCK_DGRAM: - case SOCK_RDM: - con->rx_action = tipc_receive_from_sock; - break; - default: - pr_err("Unknown socket type %d\n", s->type); + con->rx_action = tipc_accept_from_sock; + ret = kernel_listen(sock, 0); + if (ret < 0) goto create_err; - } /* As server's listening socket owner and creator is the same module, * we have to decrease TIPC module reference count to guarantee that @@ -444,7 +428,7 @@ static void tipc_clean_outqueues(struct tipc_conn *con) } int tipc_conn_sendmsg(struct tipc_server *s, int conid, - struct sockaddr_tipc *addr, void *data, size_t len) + void *data, size_t len) { struct outqueue_entry *e; struct tipc_conn *con; @@ -464,9 +448,6 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid, return -ENOMEM; } - if (addr) - memcpy(&e->dest, addr, sizeof(struct sockaddr_tipc)); - spin_lock_bh(&con->outqueue_lock); list_add_tail(&e->list, &con->outqueue); spin_unlock_bh(&con->outqueue_lock); @@ -575,10 +556,6 @@ static void tipc_send_to_sock(struct tipc_conn *con) if (con->sock) { memset(&msg, 0, sizeof(msg)); msg.msg_flags = MSG_DONTWAIT; - if (s->type == SOCK_DGRAM || s->type == SOCK_RDM) { - msg.msg_name = &e->dest; - msg.msg_namelen = sizeof(struct sockaddr_tipc); - } ret = kernel_sendmsg(con->sock, &msg, &e->iov, 1, e->iov.iov_len); if (ret == -EWOULDBLOCK || ret == 0) { @@ -591,6 +568,7 @@ static void tipc_send_to_sock(struct tipc_conn *con) evt = e->iov.iov_base; tipc_send_kern_top_evt(s->net, evt); } + /* Don't starve users filling buffers */ if (++count >= MAX_SEND_MSG_COUNT) { cond_resched(); diff --git a/net/tipc/server.h b/net/tipc/server.h index 64df7513cd70..434736d545c2 100644 --- a/net/tipc/server.h +++ b/net/tipc/server.h @@ -79,12 +79,10 @@ struct tipc_server { void *buf, size_t len); struct sockaddr_tipc *saddr; char name[TIPC_SERVER_NAME_LEN]; - int imp; - int type; }; int tipc_conn_sendmsg(struct tipc_server *s, int conid, - struct sockaddr_tipc *addr, void *data, size_t len); + void *data, size_t len); bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower, u32 upper, u32 filter, int *conid); diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 68e26470c516..eaef826fc06d 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c @@ -81,7 +81,7 @@ static void tipc_subscrp_send_event(struct tipc_subscription *sub, sub->evt.found_upper = htohl(found_upper, sub->swap); sub->evt.port.ref = htohl(port_ref, sub->swap); sub->evt.port.node = htohl(node, sub->swap); - tipc_conn_sendmsg(tn->topsrv, subscriber->conid, NULL, + tipc_conn_sendmsg(tn->topsrv, subscriber->conid, msg_sect.iov_base, msg_sect.iov_len); } @@ -375,8 +375,6 @@ int tipc_topsrv_start(struct net *net) } topsrv->net = net; topsrv->saddr = saddr; - topsrv->imp = TIPC_CRITICAL_IMPORTANCE; - topsrv->type = SOCK_SEQPACKET; topsrv->max_rcvbuf_size = sizeof(struct tipc_subscr); topsrv->tipc_conn_recvmsg = tipc_subscrb_rcv_cb; topsrv->tipc_conn_new = tipc_subscrb_connect_cb; |