Commit 006ed14e authored by Jon Maloy's avatar Jon Maloy Committed by David S. Miller

tipc: simplify signature of tipc_nametbl_lookup_group()

We reduce the signature of tipc_nametbl_lookup_group() by using a
struct tipc_uaddr pointer. This entails a couple of minor changes in the
functions tipc_send_group_mcast/anycast/unicast/bcast() in socket.c
Signed-off-by: default avatarJon Maloy <jmaloy@redhat.com>
Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Acked-by: default avatarHoang Le <hoang.h.le@dektech.com.au>
Acked-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
Acked-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 833f8670
...@@ -621,31 +621,31 @@ bool tipc_nametbl_lookup_anycast(struct net *net, ...@@ -621,31 +621,31 @@ bool tipc_nametbl_lookup_anycast(struct net *net,
* destination socket/node pairs matching the given address. * destination socket/node pairs matching the given address.
* The requester may or may not want to exclude himself from the list. * The requester may or may not want to exclude himself from the list.
*/ */
bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance, bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua,
u32 scope, struct list_head *dsts, struct list_head *dsts, int *dstcnt,
int *dstcnt, u32 exclude, u32 exclude, bool mcast)
bool mcast)
{ {
u32 self = tipc_own_addr(net); u32 self = tipc_own_addr(net);
u32 inst = ua->sa.instance;
struct service_range *sr; struct service_range *sr;
struct tipc_service *sc; struct tipc_service *sc;
struct publication *p; struct publication *p;
*dstcnt = 0; *dstcnt = 0;
rcu_read_lock(); rcu_read_lock();
sc = tipc_service_find(net, type); sc = tipc_service_find(net, ua->sa.type);
if (unlikely(!sc)) if (unlikely(!sc))
goto exit; goto exit;
spin_lock_bh(&sc->lock); spin_lock_bh(&sc->lock);
/* Todo: a full search i.e. service_range_foreach_match() instead? */ /* Todo: a full search i.e. service_range_foreach_match() instead? */
sr = service_range_match_first(sc->ranges.rb_node, instance, instance); sr = service_range_match_first(sc->ranges.rb_node, inst, inst);
if (!sr) if (!sr)
goto no_match; goto no_match;
list_for_each_entry(p, &sr->all_publ, all_publ) { list_for_each_entry(p, &sr->all_publ, all_publ) {
if (p->scope != scope) if (p->scope != ua->scope)
continue; continue;
if (p->sk.ref == exclude && p->sk.node == self) if (p->sk.ref == exclude && p->sk.node == self)
continue; continue;
......
...@@ -116,10 +116,9 @@ void tipc_nametbl_lookup_mcast_sockets(struct net *net, struct tipc_uaddr *ua, ...@@ -116,10 +116,9 @@ void tipc_nametbl_lookup_mcast_sockets(struct net *net, struct tipc_uaddr *ua,
bool exact, struct list_head *dports); bool exact, struct list_head *dports);
void tipc_nametbl_lookup_mcast_nodes(struct net *net, struct tipc_uaddr *ua, void tipc_nametbl_lookup_mcast_nodes(struct net *net, struct tipc_uaddr *ua,
struct tipc_nlist *nodes); struct tipc_nlist *nodes);
bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance, bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua,
u32 domain, struct list_head *dsts, struct list_head *dsts, int *dstcnt,
int *dstcnt, u32 exclude, u32 exclude, bool mcast);
bool all);
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp, void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
u32 type, u32 domain); u32 type, u32 domain);
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua, struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
......
...@@ -958,7 +958,7 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m, ...@@ -958,7 +958,7 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,
int dlen, long timeout) int dlen, long timeout)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); struct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;
int blks = tsk_blocks(GROUP_H_SIZE + dlen); int blks = tsk_blocks(GROUP_H_SIZE + dlen);
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
...@@ -966,8 +966,8 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m, ...@@ -966,8 +966,8 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,
u32 node, port; u32 node, port;
int rc; int rc;
node = dest->addr.id.node; node = ua->sk.node;
port = dest->addr.id.ref; port = ua->sk.ref;
if (!port && !node) if (!port && !node)
return -EHOSTUNREACH; return -EHOSTUNREACH;
...@@ -1001,7 +1001,7 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m, ...@@ -1001,7 +1001,7 @@ static int tipc_send_group_unicast(struct socket *sock, struct msghdr *m,
static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m, static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
int dlen, long timeout) int dlen, long timeout)
{ {
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); struct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
struct list_head *cong_links = &tsk->cong_links; struct list_head *cong_links = &tsk->cong_links;
...@@ -1012,16 +1012,13 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m, ...@@ -1012,16 +1012,13 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
u32 node, port, exclude; u32 node, port, exclude;
struct list_head dsts; struct list_head dsts;
u32 type, inst, scope;
int lookups = 0; int lookups = 0;
int dstcnt, rc; int dstcnt, rc;
bool cong; bool cong;
INIT_LIST_HEAD(&dsts); INIT_LIST_HEAD(&dsts);
ua->sa.type = msg_nametype(hdr);
type = msg_nametype(hdr); ua->scope = msg_lookup_scope(hdr);
inst = dest->addr.name.name.instance;
scope = msg_lookup_scope(hdr);
while (++lookups < 4) { while (++lookups < 4) {
exclude = tipc_group_exclude(tsk->group); exclude = tipc_group_exclude(tsk->group);
...@@ -1030,9 +1027,8 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m, ...@@ -1030,9 +1027,8 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
/* Look for a non-congested destination member, if any */ /* Look for a non-congested destination member, if any */
while (1) { while (1) {
if (!tipc_nametbl_lookup_group(net, type, inst, scope, if (!tipc_nametbl_lookup_group(net, ua, &dsts, &dstcnt,
&dsts, &dstcnt, exclude, exclude, false))
false))
return -EHOSTUNREACH; return -EHOSTUNREACH;
tipc_dest_pop(&dsts, &node, &port); tipc_dest_pop(&dsts, &node, &port);
cong = tipc_group_cong(tsk->group, node, port, blks, cong = tipc_group_cong(tsk->group, node, port, blks,
...@@ -1087,7 +1083,7 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m, ...@@ -1087,7 +1083,7 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m, static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
int dlen, long timeout) int dlen, long timeout)
{ {
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name); struct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
...@@ -1112,9 +1108,9 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m, ...@@ -1112,9 +1108,9 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
return -EHOSTUNREACH; return -EHOSTUNREACH;
/* Complete message header */ /* Complete message header */
if (dest) { if (ua) {
msg_set_type(hdr, TIPC_GRP_MCAST_MSG); msg_set_type(hdr, TIPC_GRP_MCAST_MSG);
msg_set_nameinst(hdr, dest->addr.name.name.instance); msg_set_nameinst(hdr, ua->sa.instance);
} else { } else {
msg_set_type(hdr, TIPC_GRP_BCAST_MSG); msg_set_type(hdr, TIPC_GRP_BCAST_MSG);
msg_set_nameinst(hdr, 0); msg_set_nameinst(hdr, 0);
...@@ -1161,29 +1157,25 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m, ...@@ -1161,29 +1157,25 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,
static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m, static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
int dlen, long timeout) int dlen, long timeout)
{ {
struct tipc_uaddr *ua = (struct tipc_uaddr *)m->msg_name;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
struct tipc_sock *tsk = tipc_sk(sk); struct tipc_sock *tsk = tipc_sk(sk);
struct tipc_group *grp = tsk->group; struct tipc_group *grp = tsk->group;
struct tipc_msg *hdr = &tsk->phdr; struct tipc_msg *hdr = &tsk->phdr;
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
u32 type, inst, scope, exclude;
struct list_head dsts; struct list_head dsts;
u32 dstcnt; u32 dstcnt, exclude;
INIT_LIST_HEAD(&dsts); INIT_LIST_HEAD(&dsts);
ua->sa.type = msg_nametype(hdr);
type = msg_nametype(hdr); ua->scope = msg_lookup_scope(hdr);
inst = dest->addr.name.name.instance;
scope = msg_lookup_scope(hdr);
exclude = tipc_group_exclude(grp); exclude = tipc_group_exclude(grp);
if (!tipc_nametbl_lookup_group(net, type, inst, scope, &dsts, if (!tipc_nametbl_lookup_group(net, ua, &dsts, &dstcnt, exclude, true))
&dstcnt, exclude, true))
return -EHOSTUNREACH; return -EHOSTUNREACH;
if (dstcnt == 1) { if (dstcnt == 1) {
tipc_dest_pop(&dsts, &dest->addr.id.node, &dest->addr.id.ref); tipc_dest_pop(&dsts, &ua->sk.node, &ua->sk.ref);
return tipc_send_group_unicast(sock, m, dlen, timeout); return tipc_send_group_unicast(sock, m, dlen, timeout);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment