On Wed, Dec 9, 2020 at 2:51 AM <jma...@redhat.com> wrote: > > From: Jon Maloy <jma...@redhat.com> > > We simplify the call signatures for tipc_nametbl_insert_publ() and > tipc_publ_create() so that fewer parameters are passed around. > > Signed-off-by: Jon Maloy <jma...@redhat.com> > --- > net/tipc/name_distr.c | 23 ++++++++-------- > net/tipc/name_table.c | 61 +++++++++++++++++++------------------------ > net/tipc/name_table.h | 10 ++++--- > net/tipc/socket.c | 8 ++---- > 4 files changed, 47 insertions(+), 55 deletions(-) > > diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c > index 721d2fca3d6f..df42fc2b4536 100644 > --- a/net/tipc/name_distr.c > +++ b/net/tipc/name_distr.c > @@ -293,30 +293,31 @@ static bool tipc_update_nametbl(struct net *net, struct > distr_item *i, > u32 node, u32 dtype) > { > struct publication *p = NULL; > - u32 lower = ntohl(i->lower); > - u32 upper = ntohl(i->upper); > - u32 type = ntohl(i->type); > - u32 port = ntohl(i->port); > + struct tipc_socket_addr sk; > + struct tipc_uaddr ua; > u32 key = ntohl(i->key); > > + tipc_uaddr(&ua, TIPC_SERVICE_RANGE, TIPC_CLUSTER_SCOPE, > + ntohl(i->type), ntohl(i->lower), ntohl(i->upper)); > + sk.ref = ntohl(i->port); > + sk.node = node; > + > if (dtype == PUBLICATION) { > - p = tipc_nametbl_insert_publ(net, type, lower, upper, > - TIPC_CLUSTER_SCOPE, node, > - port, key); > + p = tipc_nametbl_insert_publ(net, &ua, &sk, key); > if (p) { > tipc_node_subscribe(net, &p->binding_node, node); > return true; > } > } else if (dtype == WITHDRAWAL) { > - p = tipc_nametbl_remove_publ(net, type, lower, > - upper, node, key); > + p = tipc_nametbl_remove_publ(net, ua.sr.type, ua.sr.lower, > + ua.sr.upper, node, key); > if (p) { > tipc_node_unsubscribe(net, &p->binding_node, node); > kfree_rcu(p, rcu); > return true; > } > - pr_warn_ratelimited("Failed to remove binding %u,%u from > %x\n", > - type, lower, node); > + pr_warn_ratelimited("Failed to remove binding %u,%u from > %u\n", > + ua.sr.type, ua.sr.lower, node); > } else { > pr_warn("Unrecognized name table message received\n"); > } > diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c > index d951e9345122..ba96d5fc57f3 100644 > --- a/net/tipc/name_table.c > +++ b/net/tipc/name_table.c > @@ -222,36 +222,30 @@ static int hash(int x) > > /** > * tipc_publ_create - create a publication structure > - * @type: name sequence type > - * @lower: name sequence lower bound > - * @upper: name sequence upper bound > - * @scope: publication scope > - * @node: network address of publishing socket > - * @port: publishing port > + * @ua: the service range the user is binding to > + * @sk: the address of the socket thatis bound > * @key: publication key > */ > -static struct publication *tipc_publ_create(u32 type, u32 lower, u32 upper, > - u32 scope, u32 node, u32 port, > +static struct publication *tipc_publ_create(struct tipc_uaddr *ua, > + struct tipc_socket_addr *sk, > u32 key) > { > - struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC); > + struct publication *p = kzalloc(sizeof(*p), GFP_ATOMIC); > > - if (!publ) > + if (!p) > return NULL; > > - publ->sr.type = type; > - publ->sr.lower = lower; > - publ->sr.upper = upper; > - publ->scope = scope; > - publ->sk.node = node; > - publ->sk.ref = port; > - publ->key = key; > - INIT_LIST_HEAD(&publ->binding_sock); > - INIT_LIST_HEAD(&publ->binding_node); > - INIT_LIST_HEAD(&publ->local_publ); > - INIT_LIST_HEAD(&publ->all_publ); > - INIT_LIST_HEAD(&publ->list); > - return publ; > + p->sr = ua->sr; > + p->sk = *sk; > + p->addrtype = ua->addrtype; > + p->scope = ua->scope; > + p->key = key; > + INIT_LIST_HEAD(&p->binding_sock); > + INIT_LIST_HEAD(&p->binding_node); > + INIT_LIST_HEAD(&p->local_publ); > + INIT_LIST_HEAD(&p->all_publ); > + INIT_LIST_HEAD(&p->list); > + return p; > } > > /** > @@ -468,23 +462,24 @@ static struct tipc_service *tipc_service_find(struct > net *net, u32 type) > return NULL; > }; > > -struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, > - u32 lower, u32 upper, > - u32 scope, u32 node, > - u32 port, u32 key) > +struct publication *tipc_nametbl_insert_publ(struct net *net, > + struct tipc_uaddr *ua, > + struct tipc_socket_addr *sk, > + u32 key) > { > struct name_table *nt = tipc_name_table(net); > struct tipc_service *sc; > struct publication *p; > + u32 type = ua->sr.type; > bool res = false; > > - p = tipc_publ_create(type, lower, upper, scope, node, port, key); > + p = tipc_publ_create(ua, sk, key); > if (!p) > return NULL; > > - if (scope > TIPC_NODE_SCOPE || lower > upper) { > - pr_debug("Failed to bind illegal {%u,%u,%u} with scope %u\n", > - type, lower, upper, scope); > + if (ua->sr.lower > ua->sr.upper) { > + pr_debug("Failed to bind illegal {%u,%u,%u} from node %u\n", > + type, ua->sr.lower, ua->sr.upper, sk->node); > return NULL; > } > sc = tipc_service_find(net, type); > @@ -758,9 +753,7 @@ struct publication *tipc_nametbl_publish(struct net *net, > struct tipc_uaddr *ua, > goto exit; > } > > - p = tipc_nametbl_insert_publ(net, ua->sr.type, ua->sr.lower, > - ua->sr.upper, ua->scope, > - sk->node, sk->ref, key); > + p = tipc_nametbl_insert_publ(net, ua, sk, key); > if (p) { > nt->local_publ_count++; > skb = tipc_named_publish(net, p); > diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h > index 5e969e060509..e12b9eb2c7f1 100644 > --- a/net/tipc/name_table.h > +++ b/net/tipc/name_table.h > @@ -75,7 +75,8 @@ struct tipc_uaddr; > struct publication { > struct tipc_service_range sr; > struct tipc_socket_addr sk; > - u32 scope; > + u16 addrtype; > + u16 scope; It would be nice to add some description for this change in the changelog.
> u32 key; > u32 id; > struct list_head binding_node; > @@ -125,9 +126,10 @@ struct publication *tipc_nametbl_publish(struct net > *net, struct tipc_uaddr *ua, > struct tipc_socket_addr *sk, u32 > key); > int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 upper, > u32 key); > -struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, > - u32 lower, u32 upper, u32 scope, > - u32 node, u32 ref, u32 key); > +struct publication *tipc_nametbl_insert_publ(struct net *net, > + struct tipc_uaddr *ua, > + struct tipc_socket_addr *sk, > + u32 key); > struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type, > u32 lower, u32 upper, > u32 node, u32 key); > diff --git a/net/tipc/socket.c b/net/tipc/socket.c > index 598c8611b75f..0a92ebdd096d 100644 > --- a/net/tipc/socket.c > +++ b/net/tipc/socket.c > @@ -3088,12 +3088,8 @@ static int tipc_sk_join(struct tipc_sock *tsk, struct > tipc_group_req *mreq) > msg_set_nametype(hdr, mreq->type); > msg_set_dest_droppable(hdr, true); > tipc_nametbl_build_group(net, grp, mreq->type, mreq->scope); > - > - ua.sr.type = mreq->type; > - ua.sr.lower = mreq->instance; > - ua.sr.upper = ua.sr.lower; > - ua.scope = mreq->scope; > - ua.addrtype = TIPC_SERVICE_RANGE; > + tipc_uaddr(&ua, TIPC_SERVICE_RANGE, mreq->scope, > + mreq->type, mreq->instance, mreq->instance); > rc = tipc_sk_publish(tsk, &ua); > if (rc) { > tipc_group_delete(net, grp); > -- > 2.28.0 > > > > _______________________________________________ > tipc-discussion mailing list > tipc-discussion@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tipc-discussion _______________________________________________ tipc-discussion mailing list tipc-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tipc-discussion