From: Jon Maloy <jon.maloy@ericsson.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <mohan.krishna.ghanta.krishnamurthy@ericsson.com>,
<tung.q.nguyen@dektech.com.au>, <hoang.h.le@dektech.com.au>,
<jon.maloy@ericsson.com>, <canh.d.luu@dektech.com.au>,
<ying.xue@windriver.com>, <tipc-discussion@lists.sourceforge.net>
Subject: [net-next 02/10] tipc: remove unnecessary function pointers
Date: Thu, 15 Feb 2018 10:40:43 +0100 [thread overview]
Message-ID: <1518687651-26561-3-git-send-email-jon.maloy@ericsson.com> (raw)
In-Reply-To: <1518687651-26561-1-git-send-email-jon.maloy@ericsson.com>
Interaction between the functionality in server.c and subscr.c is
done via function pointers installed in struct server. This makes
the code harder to follow, and doesn't serve any obvious purpose.
Here, we replace the function pointers with direct function calls.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/server.c | 21 ++++++++++-----------
net/tipc/server.h | 5 -----
net/tipc/subscr.c | 27 ++++++---------------------
net/tipc/subscr.h | 4 ++++
4 files changed, 20 insertions(+), 37 deletions(-)
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 04a6dd9..8aa2a33 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -33,6 +33,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "subscr.h"
#include "server.h"
#include "core.h"
#include "socket.h"
@@ -182,7 +183,6 @@ static void tipc_register_callbacks(struct socket *sock, struct tipc_conn *con)
static void tipc_close_conn(struct tipc_conn *con)
{
- struct tipc_server *s = con->server;
struct sock *sk = con->sock->sk;
bool disconnect = false;
@@ -191,7 +191,7 @@ static void tipc_close_conn(struct tipc_conn *con)
if (disconnect) {
sk->sk_user_data = NULL;
if (con->conid)
- s->tipc_conn_release(con->conid, con->usr_data);
+ tipc_subscrb_delete(con->usr_data);
}
write_unlock_bh(&sk->sk_callback_lock);
@@ -240,7 +240,6 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
{
struct tipc_server *s = con->server;
struct sock *sk = con->sock->sk;
- struct sockaddr_tipc addr;
struct msghdr msg = {};
struct kvec iov;
void *buf;
@@ -254,7 +253,7 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
iov.iov_base = buf;
iov.iov_len = s->max_rcvbuf_size;
- msg.msg_name = &addr;
+ msg.msg_name = NULL;
iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, iov.iov_len);
ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT);
if (ret <= 0) {
@@ -264,8 +263,8 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
read_lock_bh(&sk->sk_callback_lock);
if (test_bit(CF_CONNECTED, &con->flags))
- ret = s->tipc_conn_recvmsg(sock_net(con->sock->sk), con->conid,
- &addr, con->usr_data, buf, ret);
+ ret = tipc_subscrb_rcv(sock_net(con->sock->sk), con->conid,
+ con->usr_data, buf, ret);
read_unlock_bh(&sk->sk_callback_lock);
kmem_cache_free(s->rcvbuf_cache, buf);
if (ret < 0)
@@ -284,7 +283,6 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
static int tipc_accept_from_sock(struct tipc_conn *con)
{
- struct tipc_server *s = con->server;
struct socket *sock = con->sock;
struct socket *newsock;
struct tipc_conn *newcon;
@@ -305,7 +303,8 @@ static int tipc_accept_from_sock(struct tipc_conn *con)
tipc_register_callbacks(newsock, newcon);
/* Notify that new connection is incoming */
- newcon->usr_data = s->tipc_conn_new(newcon->conid);
+ newcon->usr_data = tipc_subscrb_create(newcon->conid);
+
if (!newcon->usr_data) {
sock_release(newsock);
conn_put(newcon);
@@ -489,7 +488,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
*conid = con->conid;
s = con->server;
- scbr = s->tipc_conn_new(*conid);
+ scbr = tipc_subscrb_create(*conid);
if (!scbr) {
conn_put(con);
return false;
@@ -497,7 +496,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
con->usr_data = scbr;
con->sock = NULL;
- s->tipc_conn_recvmsg(net, *conid, NULL, scbr, &sub, sizeof(sub));
+ tipc_subscrb_rcv(net, *conid, scbr, &sub, sizeof(sub));
return true;
}
@@ -513,7 +512,7 @@ void tipc_topsrv_kern_unsubscr(struct net *net, int conid)
test_and_clear_bit(CF_CONNECTED, &con->flags);
srv = con->server;
if (con->conid)
- srv->tipc_conn_release(con->conid, con->usr_data);
+ tipc_subscrb_delete(con->usr_data);
conn_put(con);
conn_put(con);
}
diff --git a/net/tipc/server.h b/net/tipc/server.h
index 434736d..b4b83bd 100644
--- a/net/tipc/server.h
+++ b/net/tipc/server.h
@@ -72,11 +72,6 @@ struct tipc_server {
struct workqueue_struct *rcv_wq;
struct workqueue_struct *send_wq;
int max_rcvbuf_size;
- void *(*tipc_conn_new)(int conid);
- void (*tipc_conn_release)(int conid, void *usr_data);
- int (*tipc_conn_recvmsg)(struct net *net, int conid,
- struct sockaddr_tipc *addr, void *usr_data,
- void *buf, size_t len);
struct sockaddr_tipc *saddr;
char name[TIPC_SERVER_NAME_LEN];
};
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index eaef826..b86fbbf 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -220,7 +220,7 @@ static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber,
spin_unlock_bh(&subscriber->lock);
}
-static struct tipc_subscriber *tipc_subscrb_create(int conid)
+struct tipc_subscriber *tipc_subscrb_create(int conid)
{
struct tipc_subscriber *subscriber;
@@ -237,7 +237,7 @@ static struct tipc_subscriber *tipc_subscrb_create(int conid)
return subscriber;
}
-static void tipc_subscrb_delete(struct tipc_subscriber *subscriber)
+void tipc_subscrb_delete(struct tipc_subscriber *subscriber)
{
tipc_subscrb_subscrp_delete(subscriber, NULL);
tipc_subscrb_put(subscriber);
@@ -315,16 +315,10 @@ static int tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s,
return 0;
}
-/* Handle one termination request for the subscriber */
-static void tipc_subscrb_release_cb(int conid, void *usr_data)
-{
- tipc_subscrb_delete((struct tipc_subscriber *)usr_data);
-}
-
-/* Handle one request to create a new subscription for the subscriber */
-static int tipc_subscrb_rcv_cb(struct net *net, int conid,
- struct sockaddr_tipc *addr, void *usr_data,
- void *buf, size_t len)
+/* Handle one request to create a new subscription for the subscriber
+ */
+int tipc_subscrb_rcv(struct net *net, int conid, void *usr_data,
+ void *buf, size_t len)
{
struct tipc_subscriber *subscriber = usr_data;
struct tipc_subscr *s = (struct tipc_subscr *)buf;
@@ -345,12 +339,6 @@ static int tipc_subscrb_rcv_cb(struct net *net, int conid,
return tipc_subscrp_subscribe(net, s, subscriber, swap, status);
}
-/* Handle one request to establish a new subscriber */
-static void *tipc_subscrb_connect_cb(int conid)
-{
- return (void *)tipc_subscrb_create(conid);
-}
-
int tipc_topsrv_start(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
@@ -376,9 +364,6 @@ int tipc_topsrv_start(struct net *net)
topsrv->net = net;
topsrv->saddr = saddr;
topsrv->max_rcvbuf_size = sizeof(struct tipc_subscr);
- topsrv->tipc_conn_recvmsg = tipc_subscrb_rcv_cb;
- topsrv->tipc_conn_new = tipc_subscrb_connect_cb;
- topsrv->tipc_conn_release = tipc_subscrb_release_cb;
strncpy(topsrv->name, name, strlen(name) + 1);
tn->topsrv = topsrv;
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index f3edca7..a736f29 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -67,6 +67,10 @@ struct tipc_subscription {
struct tipc_event evt;
};
+struct tipc_subscriber *tipc_subscrb_create(int conid);
+void tipc_subscrb_delete(struct tipc_subscriber *subscriber);
+int tipc_subscrb_rcv(struct net *net, int conid, void *usr_data,
+ void *buf, size_t len);
int tipc_subscrp_check_overlap(struct tipc_name_seq *seq, u32 found_lower,
u32 found_upper);
void tipc_subscrp_report_overlap(struct tipc_subscription *sub,
--
2.1.4
next prev parent reply other threads:[~2018-02-15 9:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 9:40 [net-next 00/10] tipc: de-generealize topology server Jon Maloy
2018-02-15 9:40 ` [net-next 01/10] tipc: remove redundant code in " Jon Maloy
2018-02-15 9:40 ` Jon Maloy [this message]
2018-02-15 9:40 ` [net-next 03/10] tipc: eliminate struct tipc_subscriber Jon Maloy
2018-02-15 9:40 ` [net-next 04/10] tipc: simplify interaction between subscription and topology connection Jon Maloy
2018-02-15 9:40 ` [net-next 05/10] tipc: simplify endianness handling in topology subscriber Jon Maloy
2018-02-15 9:40 ` [net-next 06/10] tipc: collapse subscription creation functions Jon Maloy
2018-02-15 9:40 ` [net-next 07/10] tipc: some prefix changes Jon Maloy
2018-02-15 9:40 ` [net-next 08/10] tipc: make struct tipc_server private for server.c Jon Maloy
2018-02-15 9:40 ` [net-next 09/10] tipc: separate topology server listener socket from subcsriber sockets Jon Maloy
2018-02-17 18:35 ` [tipc] 5fb6af56fa: BUG:sleeping_function_called_from_invalid_context_at_net/core/sock.c kernel test robot
2018-02-15 9:40 ` [net-next 10/10] tipc: rename tipc_server to tipc_topsrv Jon Maloy
2018-02-16 20:29 ` [net-next 00/10] tipc: de-generealize topology server David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518687651-26561-3-git-send-email-jon.maloy@ericsson.com \
--to=jon.maloy@ericsson.com \
--cc=canh.d.luu@dektech.com.au \
--cc=davem@davemloft.net \
--cc=hoang.h.le@dektech.com.au \
--cc=mohan.krishna.ghanta.krishnamurthy@ericsson.com \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@dektech.com.au \
--cc=ying.xue@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).