tipc: cleanups and simplifications
Subsystems (3)
[email protected]
maintainercover tipc: cleanups and simplifications
From: Jon Maloy <[email protected]>
We do a number of cleanups and simplifications, especially regarding call signatures in the binding table. This makes the code easier to understand and serves as preparation for upcoming functional additions.
Jon Maloy (16):
tipc: re-organize members of struct publication
tipc: move creation of publication item one level up in call chain
tipc: introduce new unified address type for internal use
tipc: simplify signature of tipc_namtbl_publish()
tipc: simplify call signatures for publication creation
tipc: simplify signature of tipc_nametbl_withdraw() functions
tipc: rename binding table lookup functions
tipc: refactor tipc_sendmsg() and tipc_lookup_anycast()
tipc: simplify signature of tipc_namtbl_lookup_mcast_sockets()
tipc: simplify signature of tipc_nametbl_lookup_mcast_nodes()
tipc: simplify signature of tipc_nametbl_lookup_group()
tipc: simplify signature of tipc_service_find_range()
tipc: simplify signature of tipc_find_service()
tipc: simplify api between binding table and topology server
tipc: add host-endian copy of user subscription to struct
tipc_subscription
tipc: remove some unnecessary warnings
net/tipc/addr.c | 1 + net/tipc/addr.h | 46 ++++- net/tipc/msg.c | 23 ++- net/tipc/name_distr.c | 93 +++++---- net/tipc/name_table.c | 426 +++++++++++++++++++++--------------------- net/tipc/name_table.h | 63 +++---- net/tipc/net.c | 8 +- net/tipc/node.c | 28 +-- net/tipc/socket.c | 319 ++++++++++++++++--------------- net/tipc/subscr.c | 86 +++++---- net/tipc/subscr.h | 14 +- 11 files changed, 578 insertions(+), 529 deletions(-)
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 1/16 tipc: re-organize members of struct publication
From: Jon Maloy <[email protected]>
In a future commit we will introduce more members to struct publication. In order to keep this structure comprehensible we now group some of its current fields into the sub-structures where they really belong,
- A struct tipc_service_range for the functional address the publication is representing.
- A struct tipc_socket_addr for the socket bound to that service range.
We also rename the stack variable 'publ' to just 'p' in a few places. This is just as easy to understand in the given context, and keeps the number of wrapped code lines to a minimum.
There are no functional changes in this commit.
--- net/tipc/name_distr.c | 66 +++++++++++++++++++++---------------------- net/tipc/name_table.c | 66 +++++++++++++++++++++---------------------- net/tipc/name_table.h | 17 ++++------- net/tipc/socket.c | 40 +++++++++++++------------- 4 files changed, 92 insertions(+), 97 deletions(-)
net/tipc/name_distr.c +33 -33
@@ -1,8 +1,9 @@/* * net/tipc/name_distr.c: TIPC name distribution code * -* Copyright (c) 2000-2006, 2014, Ericsson AB +* Copyright (c) 2000-2006, 2014-2019, Ericsson AB * Copyright (c) 2005, 2010-2011, Wind River Systems +* Copyright (c) 2020-2021, Red Hat Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -55,10 +56,10 @@ struct distr_queue_item {*/ static void publ_to_item (struct distr_item *i,struct publication *p) { - i->type =htonl (p->type); - i->lower =htonl (p->lower); - i->upper =htonl (p->upper); - i->port =htonl (p->port); + i->type =htonl (p->sr.type); + i->lower =htonl (p->sr.lower); + i->upper =htonl (p->sr.upper); + i->port =htonl (p->sk.ref); i->key =htonl (p->key); }
@@ -90,20 +91,20 @@ static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,/** * tipc_named_publish - tell other nodes about a new publication by this node * @net: the associated network namespace -* @publ: the new publication +* @p: the new publication */ -struct sk_buff *tipc_named_publish (struct net *net,struct publication *publ) +struct sk_buff *tipc_named_publish (struct net *net,struct publication *p) {struct name_table *nt =tipc_name_table (net);struct distr_item *item;struct sk_buff *skb; -if (publ->scope ==TIPC_NODE_SCOPE ) { -list_add_tail_rcu (&publ->binding_node, &nt->node_scope); +if (p->scope ==TIPC_NODE_SCOPE ) { +list_add_tail_rcu (&p->binding_node, &nt->node_scope);return NULL ; }write_lock_bh (&nt->cluster_scope_lock); -list_add_tail (&publ->binding_node, &nt->cluster_scope); +list_add_tail (&p->binding_node, &nt->cluster_scope);write_unlock_bh (&nt->cluster_scope_lock); skb =named_prepare_buf (net,PUBLICATION ,ITEM_SIZE ,0 );if (!skb) {
@@ -113,25 +114,25 @@ struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ)msg_set_named_seqno (buf_msg (skb), nt->snd_nxt++);msg_set_non_legacy (buf_msg (skb)); item = (struct distr_item *)msg_data (buf_msg (skb)); -publ_to_item (item, publ); +publ_to_item (item, p);return skb; }/** * tipc_named_withdraw - tell other nodes about a withdrawn publication by this node * @net: the associated network namespace -* @publ: the withdrawn publication +* @p: the withdrawn publication */ -struct sk_buff *tipc_named_withdraw (struct net *net,struct publication *publ) +struct sk_buff *tipc_named_withdraw (struct net *net,struct publication *p) {struct name_table *nt =tipc_name_table (net);struct distr_item *item;struct sk_buff *skb;write_lock_bh (&nt->cluster_scope_lock); -list_del (&publ->binding_node); +list_del (&p->binding_node);write_unlock_bh (&nt->cluster_scope_lock); -if (publ->scope ==TIPC_NODE_SCOPE ) +if (p->scope ==TIPC_NODE_SCOPE )return NULL ; skb =named_prepare_buf (net,WITHDRAWAL ,ITEM_SIZE ,0 );
@@ -142,7 +143,7 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ)msg_set_named_seqno (buf_msg (skb), nt->snd_nxt++);msg_set_non_legacy (buf_msg (skb)); item = (struct distr_item *)msg_data (buf_msg (skb)); -publ_to_item (item, publ); +publ_to_item (item, p);return skb; }
@@ -233,33 +234,32 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)/** * tipc_publ_purge - remove publication associated with a failed node * @net: the associated network namespace -* @publ: the publication to remove +* @p: the publication to remove * @addr: failed node's address * * Invoked for each publication issued by a newly failed node. * Removes publication structure from name table & deletes it. */ -static void tipc_publ_purge (struct net *net,struct publication *publ,u32 addr) +static void tipc_publ_purge (struct net *net,struct publication *p,u32 addr) {struct tipc_net *tn =tipc_net (net); -struct publication *p; +struct publication *_p;spin_lock_bh (&tn->nametbl_lock); - p =tipc_nametbl_remove_publ (net, publ->type, publ->lower, publ->upper, - publ->node, publ->key); -if (p) -tipc_node_unsubscribe (net, &p->binding_node, addr); + _p =tipc_nametbl_remove_publ (net, p->sr.type, p->sr.lower, + p->sr.upper, p->sk.node, p->key); +if (_p) +tipc_node_unsubscribe (net, &_p->binding_node, addr);spin_unlock_bh (&tn->nametbl_lock); -if (p != publ) { +if (_p != p) {pr_err ("Unable to remove publication from failed node\n" " (type=%u, lower=%u, node=0x%x, port=%u, key=%u)\n" , - publ->type, publ->lower, publ->node, publ->port, - publ->key); + p->sr.type, p->sr.lower, p->sk.node, p->sk.ref, p->key); } -if (p) -kfree_rcu (p, rcu); +if (_p) +kfree_rcu (_p, rcu); } void tipc_publ_notify(struct net *net, struct list_head *nsub_list,
@@ -410,15 +410,15 @@ void tipc_named_reinit(struct net *net) {struct name_table *nt =tipc_name_table (net);struct tipc_net *tn =tipc_net (net); -struct publication *publ; +struct publication *p;u32 self =tipc_own_addr (net);spin_lock_bh (&tn->nametbl_lock); -list_for_each_entry_rcu (publ, &nt->node_scope, binding_node) - publ->node = self; -list_for_each_entry_rcu (publ, &nt->cluster_scope, binding_node) - publ->node = self; +list_for_each_entry_rcu (p, &nt->node_scope, binding_node) + p->sk.node = self; +list_for_each_entry_rcu (p, &nt->cluster_scope, binding_node) + p->sk.node = self; nt->rc_dests =0 ;spin_unlock_bh (&tn->nametbl_lock); }
net/tipc/name_table.c +33 -33
155 lines not on this page · raw message
net/tipc/name_table.h +6 -11
@@ -3,6 +3,7 @@* * Copyright (c) 2000-2006, 2014-2018, Ericsson AB * Copyright (c) 2004-2005, 2010-2011, Wind River Systems +* Copyright (c) 2020-2021, Red Hat Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -50,13 +51,10 @@ struct tipc_group;#define TIPC_NAMETBL_SIZE 1024/* must be a power of 2 */ /** -* struct publication - info about a published (name or) name sequence -* @type: name sequence type -* @lower: name sequence lower bound -* @upper: name sequence upper bound +* struct publication - info about a published service address or range +* @sr: service range represented by this publication +* @sk: address of socket bound to this publication * @scope: scope of publication, TIPC_NODE_SCOPE or TIPC_CLUSTER_SCOPE -* @node: network address of publishing socket's node -* @port: publishing port * @key: publication key, unique across the cluster * @id: publication id * @binding_node: all publications from the same node which bound this one
@@ -74,12 +72,9 @@ struct tipc_group;* @rcu: RCU callback head used for deferred freeing */ struct publication { -u32 type; -u32 lower; -u32 upper; +struct tipc_service_range sr; +struct tipc_socket_addr sk;u32 scope; -u32 node; -u32 port;u32 key;u32 id;struct list_head binding_node;
net/tipc/socket.c +20 -20
@@ -3,7 +3,7 @@* * Copyright (c) 2001-2007, 2012-2019, Ericsson AB * Copyright (c) 2004-2008, 2010-2013, Wind River Systems -* Copyright (c) 2020, Red Hat Inc +* Copyright (c) 2020-2021, Red Hat Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -2923,30 +2923,30 @@ static int tipc_sk_withdraw(struct tipc_sock *tsk, uint scope, struct tipc_service_range const *seq) {struct net *net =sock_net (&tsk->sk); -struct publication *publ; +struct publication *p;struct publication *safe;int rc = -EINVAL ;if (scope !=TIPC_NODE_SCOPE ) scope =TIPC_CLUSTER_SCOPE ; -list_for_each_entry_safe (publ, safe, &tsk->publications, binding_sock) { +list_for_each_entry_safe (p, safe, &tsk->publications, binding_sock) {if (seq) { -if (publ->scope != scope) +if (p->scope != scope)continue ; -if (publ->type != seq->type) +if (p->sr.type != seq->type)continue ; -if (publ->lower != seq->lower) +if (p->sr.lower != seq->lower)continue ; -if (publ->upper != seq->upper) +if (p->sr.upper != seq->upper)break ; -tipc_nametbl_withdraw (net, publ->type, publ->lower, - publ->upper, publ->key); +tipc_nametbl_withdraw (net, p->sr.type, p->sr.lower, + p->sr.upper, p->key); rc =0 ;break ; } -tipc_nametbl_withdraw (net, publ->type, publ->lower, - publ->upper, publ->key); +tipc_nametbl_withdraw (net, p->sr.type, p->sr.lower, + p->sr.upper, p->key); rc =0 ; }if (list_empty (&tsk->publications))
@@ -3711,11 +3711,11 @@ static int __tipc_nl_add_sk_publ(struct sk_buff *skb,if (nla_put_u32 (skb,TIPC_NLA_PUBL_KEY , publ->key)) goto attr_msg_cancel; -if (nla_put_u32 (skb,TIPC_NLA_PUBL_TYPE , publ->type)) +if (nla_put_u32 (skb,TIPC_NLA_PUBL_TYPE , publ->sr.type)) goto attr_msg_cancel; -if (nla_put_u32 (skb,TIPC_NLA_PUBL_LOWER , publ->lower)) +if (nla_put_u32 (skb,TIPC_NLA_PUBL_LOWER , publ->sr.lower)) goto attr_msg_cancel; -if (nla_put_u32 (skb,TIPC_NLA_PUBL_UPPER , publ->upper)) +if (nla_put_u32 (skb,TIPC_NLA_PUBL_UPPER , publ->sr.upper)) goto attr_msg_cancel;nla_nest_end (skb, attrs);
@@ -3863,9 +3863,9 @@ bool tipc_sk_filtering(struct sock *sk) p =list_first_entry_or_null (&tsk->publications, struct publication, binding_sock);if (p) { - type = p->type; - lower = p->lower; - upper = p->upper; + type = p->sr.type; + lower = p->sr.lower; + upper = p->sr.upper; } }
@@ -3964,9 +3964,9 @@ int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf)if (tsk->published) { p =list_first_entry_or_null (&tsk->publications, struct publication, binding_sock); - i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->type :0 ); - i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->lower :0 ); - i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->upper :0 ); + i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->sr.type :0 ); + i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->sr.lower :0 ); + i +=scnprintf (buf + i, sz - i," %u" , (p) ? p->sr.upper :0 ); } i +=scnprintf (buf + i, sz - i," | %u" , tsk->snd_win); i +=scnprintf (buf + i, sz - i," %u" , tsk->rcv_win);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 2/16 tipc: move creation of publication item one level up in call chain
In reply to [email protected]From: Jon Maloy <[email protected]>
We instantiate struct publication in tipc_nametbl_insert_publ() instead of as currently in tipc_service_insert_publ(). This has the advantage that we can pass a pointer to the publication struct to the next call levels, instead of the numerous individual parameters we pass on now. It also gives us a location to keep the contents of the additional fields we will introduce in a later commit.
--- net/tipc/name_table.c | 65 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-)
net/tipc/name_table.c +32 -33
@@ -327,49 +327,48 @@ static struct service_range *tipc_service_create_range(struct tipc_service *sc,return sr; } -static struct publication *tipc_service_insert_publ (struct net *net, -struct tipc_service *sc, -u32 type,u32 lower, -u32 upper,u32 scope, -u32 node,u32 port, -u32 key) +static bool tipc_service_insert_publ (struct net *net, +struct tipc_service *sc, +struct publication *p) {struct tipc_subscription *sub, *tmp;struct service_range *sr; -struct publication *p; +struct publication *_p; +u32 node = p->sk.node;bool first = false; +bool res = false; - sr =tipc_service_create_range (sc, lower, upper); +spin_lock_bh (&sc->lock); + sr =tipc_service_create_range (sc, p->sr.lower, p->sr.upper);if (!sr) - goto err; + goto exit; first =list_empty (&sr->all_publ);/* Return if the publication already exists */ -list_for_each_entry (p, &sr->all_publ, all_publ) { -if (p->key == key && (!p->sk.node || p->sk.node == node)) -return NULL ; +list_for_each_entry (_p, &sr->all_publ, all_publ) { +if (_p->key == p->key && (!_p->sk.node || _p->sk.node == node)) + goto exit; } -/* Create and insert publication */ - p =tipc_publ_create (type, lower, upper, scope, node, port, key); -if (!p) - goto err; -/* Suppose there shouldn't be a huge gap btw publs i.e. >INT_MAX */ - p->id = sc->publ_cnt++; -if (in_own_node (net, node)) +if (in_own_node (net, p->sk.node))list_add (&p->local_publ, &sr->local_publ);list_add (&p->all_publ, &sr->all_publ); + p->id = sc->publ_cnt++;/* Any subscriptions waiting for notification? */ list_for_each_entry_safe (sub, tmp, &sc->subscriptions, service_list) { -tipc_sub_report_overlap (sub, p->sr.lower, p->sr.upper,TIPC_PUBLISHED , - p->sk.ref, p->sk.node, p->scope, first); +tipc_sub_report_overlap (sub, p->sr.lower, p->sr.upper, +TIPC_PUBLISHED , p->sk.ref, p->sk.node, + p->scope, first); } -return p; -err: -pr_warn ("Failed to bind to %u,%u,%u, no memory\n" , type, lower, upper); -return NULL ; + res = true; +exit: +if (!res) +pr_warn ("Failed to bind to %u,%u,%u\n" , + p->sr.type, p->sr.lower, p->sr.upper); +spin_unlock_bh (&sc->lock); +return res; }/**
@@ -482,6 +481,10 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,struct tipc_service *sc;struct publication *p; + p =tipc_publ_create (type, lower, upper, scope, node, port, 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);
@@ -490,14 +493,10 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, sc =tipc_service_find (net, type);if (!sc) sc =tipc_service_create (type, &nt->services[hash (type)]); -if (!sc) -return NULL ; - -spin_lock_bh (&sc->lock); - p =tipc_service_insert_publ (net, sc, type, lower, upper, - scope, node, port, key); -spin_unlock_bh (&sc->lock); -return p; +if (sc &&tipc_service_insert_publ (net, sc, p)) +return p; +kfree (p); +return NULL ; } struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 3/16 tipc: introduce new unified address type for internal use
In reply to [email protected]From: Jon Maloy <[email protected]>
We introduce a simplified version of struct sockaddr_tipc, using anonymous unions and structures. Apart from being nicer to work with, this struct will come in handy when we in a later commit add another address type.
--- net/tipc/addr.c | 1 + net/tipc/addr.h | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-)
net/tipc/addr.c +1 -0
@@ -3,6 +3,7 @@* * Copyright (c) 2000-2006, 2018, Ericsson AB * Copyright (c) 2004-2005, 2010-2011, Wind River Systems +* Copyright (c) 2020-2021, Red Hat Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without
net/tipc/addr.h +45 -1
58 lines not on this page · raw message
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 4/16 tipc: simplify signature of tipc_namtbl_publish()
In reply to [email protected]From: Jon Maloy <[email protected]>
Using the new address structure tipc_uaddr, we simplify the signature of function tipc_sk_publish() and tipc_namtbl_publish() so that fewer parameters need to be passed around.
--- net/tipc/name_table.c | 10 +++--- net/tipc/name_table.h | 6 ++-- net/tipc/net.c | 8 +++-- net/tipc/node.c | 29 ++++++++--------- net/tipc/socket.c | 73 +++++++++++++++++++++++-------------------- 5 files changed, 68 insertions(+), 58 deletions(-)
net/tipc/name_table.c +5 -5
@@ -740,9 +740,8 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,/* tipc_nametbl_publish - add service binding to name table */ -struct publication *tipc_nametbl_publish (struct net *net,u32 type,u32 lower, -u32 upper,u32 scope,u32 port, -u32 key) +struct publication *tipc_nametbl_publish (struct net *net,struct tipc_uaddr *ua, +struct tipc_socket_addr *sk,u32 key) {struct name_table *nt =tipc_name_table (net);struct tipc_net *tn =tipc_net (net);
@@ -757,8 +756,9 @@ struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, goto exit; } - p =tipc_nametbl_insert_publ (net, type, lower, upper, scope, -tipc_own_addr (net), port, key); + p =tipc_nametbl_insert_publ (net, ua->sr.type, ua->sr.lower, + ua->sr.upper, ua->scope, + sk->node, sk->ref, key);if (p) { nt->local_publ_count++; skb =tipc_named_publish (net, p);
net/tipc/name_table.h +3 -3
@@ -42,6 +42,7 @@ struct tipc_subscription;struct tipc_plist ;struct tipc_nlist ;struct tipc_group ; +struct tipc_uaddr ;/* * TIPC name types reserved for internal TIPC use (both current and planned)
@@ -120,9 +121,8 @@ void tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower,bool tipc_nametbl_lookup (struct net *net,u32 type,u32 instance,u32 domain,struct list_head *dsts,int *dstcnt,u32 exclude,bool all); -struct publication *tipc_nametbl_publish (struct net *net,u32 type,u32 lower, -u32 upper,u32 scope,u32 port, -u32 key); +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,
net/tipc/net.c +6 -2
@@ -125,6 +125,11 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)static void tipc_net_finalize (struct net *net,u32 addr) {struct tipc_net *tn =tipc_net (net); +struct tipc_socket_addr sk = {0 , addr}; +struct tipc_uaddr ua; + +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_CLUSTER_SCOPE , +TIPC_NODE_STATE , addr, addr);if (cmpxchg (&tn->node_addr,0 , addr))return ;
@@ -132,8 +137,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)tipc_named_reinit (net);tipc_sk_reinit (net);tipc_mon_reinit_self (net); -tipc_nametbl_publish (net,TIPC_NODE_STATE , addr, addr, -TIPC_CLUSTER_SCOPE ,0 , addr); +tipc_nametbl_publish (net, &ua, &sk, addr); }void tipc_net_finalize_work (struct work_struct *work)
net/tipc/node.c +15 -14
@@ -398,21 +398,23 @@ static void tipc_node_write_unlock_fast(struct tipc_node *n)static void tipc_node_write_unlock (struct tipc_node *n) __releases(n->lock) { +struct tipc_socket_addr sk;struct net *net = n->net; -u32 addr =0 ;u32 flags = n->action_flags; -u32 link_id =0 ; -u32 bearer_id;struct list_head *publ_list; +struct tipc_uaddr ua; +u32 bearer_id;if (likely (!flags)) {write_unlock_bh (&n->lock);return ; } - addr = n->addr; - link_id = n->link_id; - bearer_id = link_id &0xffff ; +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , +TIPC_LINK_STATE , n->addr, n->addr); + sk.ref = n->link_id; + sk.node = n->addr; + bearer_id = n->link_id &0xffff ; publ_list = &n->publ_list; n->action_flags &= ~(TIPC_NOTIFY_NODE_DOWN | TIPC_NOTIFY_NODE_UP |
@@ -421,20 +423,19 @@ static void tipc_node_write_unlock(struct tipc_node *n)write_unlock_bh (&n->lock);if (flags &TIPC_NOTIFY_NODE_DOWN ) -tipc_publ_notify (net, publ_list, addr, n->capabilities); +tipc_publ_notify (net, publ_list, n->addr, n->capabilities);if (flags &TIPC_NOTIFY_NODE_UP ) -tipc_named_node_up (net, addr, n->capabilities); +tipc_named_node_up (net, n->addr, n->capabilities);if (flags &TIPC_NOTIFY_LINK_UP ) { -tipc_mon_peer_up (net, addr, bearer_id); -tipc_nametbl_publish (net,TIPC_LINK_STATE , addr, addr, -TIPC_NODE_SCOPE , link_id, link_id); +tipc_mon_peer_up (net, n->addr, bearer_id); +tipc_nametbl_publish (net, &ua, &sk, n->link_id); }if (flags &TIPC_NOTIFY_LINK_DOWN ) { -tipc_mon_peer_down (net, addr, bearer_id); -tipc_nametbl_withdraw (net,TIPC_LINK_STATE , addr, - addr, link_id); +tipc_mon_peer_down (net, n->addr, bearer_id); +tipc_nametbl_withdraw (net,TIPC_LINK_STATE , n->addr, + n->addr, n->link_id); } }
net/tipc/socket.c +39 -34
155 lines not on this page · raw message
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 5/16 tipc: simplify call signatures for publication creation
In reply to [email protected]From: Jon Maloy <[email protected]>
We simplify the call signatures for tipc_nametbl_insert_publ() and tipc_publ_create() so that fewer parameters are passed around.
--- net/tipc/name_distr.c | 23 ++++++++++++----------- net/tipc/name_table.c | 42 +++++++++++++++++------------------------- net/tipc/name_table.h | 9 +++++---- 3 files changed, 34 insertions(+), 40 deletions(-)
net/tipc/name_distr.c +12 -11
@@ -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" ); }
net/tipc/name_table.c +17 -25
76 lines not on this page · raw message
net/tipc/name_table.h +5 -4
@@ -75,7 +75,7 @@ struct tipc_uaddr;struct publication {struct tipc_service_range sr;struct tipc_socket_addr sk; -u32 scope; +u16 scope;u32 key;u32 id;struct list_head binding_node;
@@ -125,9 +125,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);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 6/16 tipc: simplify signature of tipc_nametbl_withdraw() functions
In reply to [email protected]From: Jon Maloy <[email protected]>
Following the principles of the preceding commits, we reduce the number of parameters passed along in tipc_sk_withdraw(), tipc_nametbl_withdraw() and associated functions.
--- net/tipc/name_distr.c | 11 ++++---- net/tipc/name_table.c | 51 ++++++++++++++++++----------------- net/tipc/name_table.h | 11 ++++---- net/tipc/node.c | 3 +-- net/tipc/socket.c | 62 +++++++++++++++++++++---------------------- 5 files changed, 70 insertions(+), 68 deletions(-)
net/tipc/name_distr.c +6 -5
@@ -244,17 +244,19 @@ static void tipc_publ_purge(struct net *net, struct publication *p, u32 addr) {struct tipc_net *tn =tipc_net (net);struct publication *_p; +struct tipc_uaddr ua; +tipc_uaddr (&ua,TIPC_SERVICE_RANGE , p->scope, p->sr.type, + p->sr.lower, p->sr.upper);spin_lock_bh (&tn->nametbl_lock); - _p =tipc_nametbl_remove_publ (net, p->sr.type, p->sr.lower, - p->sr.upper, p->sk.node, p->key); + _p =tipc_nametbl_remove_publ (net, &ua, &p->sk, p->key);if (_p)tipc_node_unsubscribe (net, &_p->binding_node, addr);spin_unlock_bh (&tn->nametbl_lock);if (_p != p) {pr_err ("Unable to remove publication from failed node\n" -" (type=%u, lower=%u, node=0x%x, port=%u, key=%u)\n" , +" (type=%u, lower=%u, node=%u, port=%u, key=%u)\n" , p->sr.type, p->sr.lower, p->sk.node, p->sk.ref, p->key); }
@@ -309,8 +311,7 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,return true; } }else if (dtype ==WITHDRAWAL ) { - p =tipc_nametbl_remove_publ (net, ua.sr.type, ua.sr.lower, - ua.sr.upper, node, key); + p =tipc_nametbl_remove_publ (net, &ua, &sk, key);if (p) {tipc_node_unsubscribe (net, &p->binding_node, node);kfree_rcu (p, rcu);
net/tipc/name_table.c +26 -25
119 lines not on this page · raw message
net/tipc/name_table.h +6 -5
@@ -123,15 +123,16 @@ bool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 domain, bool all);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); +void tipc_nametbl_withdraw (struct net *net,struct tipc_uaddr *ua, +struct tipc_socket_addr *sk,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); +struct publication *tipc_nametbl_remove_publ (struct net *net, +struct tipc_uaddr *ua, +struct tipc_socket_addr *sk, +u32 key);bool tipc_nametbl_subscribe (struct tipc_subscription *s);void tipc_nametbl_unsubscribe (struct tipc_subscription *s);int tipc_nametbl_init (struct net *net);
net/tipc/node.c +1 -2
@@ -434,8 +434,7 @@ static void tipc_node_write_unlock(struct tipc_node *n) }if (flags &TIPC_NOTIFY_LINK_DOWN ) {tipc_mon_peer_down (net, n->addr, bearer_id); -tipc_nametbl_withdraw (net,TIPC_LINK_STATE , n->addr, - n->addr, n->link_id); +tipc_nametbl_withdraw (net, &ua, &sk, n->link_id); } }
net/tipc/socket.c +31 -31
113 lines not on this page · raw message
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 7/16 tipc: rename binding table lookup functions
In reply to [email protected]From: Jon Maloy <[email protected]>
The binding table provides four different lookup functions, which purpose is not obvious neither by their names nor by the (lack of) descriptions.
We now give these functions names that better match their purposes, and improve the comments that describe what they are doing.
--- net/tipc/msg.c | 4 ++-- net/tipc/name_table.c | 51 ++++++++++++++++++++++++++++--------------- net/tipc/name_table.h | 19 +++++++++------- net/tipc/socket.c | 19 ++++++++-------- 4 files changed, 56 insertions(+), 37 deletions(-)
net/tipc/msg.c +2 -2
@@ -723,8 +723,8 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err)if (msg_reroute_cnt (msg))return false; dnode =tipc_scope2node (net,msg_lookup_scope (msg)); - dport =tipc_nametbl_translate (net,msg_nametype (msg), -msg_nameinst (msg), &dnode); + dport =tipc_nametbl_lookup_anycast (net,msg_nametype (msg), +msg_nameinst (msg), &dnode);if (!dport)return false;msg_incr_reroute_cnt (msg);
net/tipc/name_table.c +33 -18
93 lines not on this page · raw message
net/tipc/name_table.h +11 -8
@@ -111,16 +111,19 @@ struct name_table {int tipc_nl_name_table_dump (struct sk_buff *skb,struct netlink_callback *cb); -u32 tipc_nametbl_translate (struct net *net,u32 type,u32 instance,u32 *node); -void tipc_nametbl_mc_lookup (struct net *net,u32 type,u32 lower,u32 upper, -u32 scope,bool exact,struct list_head *dports); +u32 tipc_nametbl_lookup_anycast (struct net *net,u32 type,u32 instance, +u32 *node); +void tipc_nametbl_lookup_mcast_sockets (struct net *net,u32 type,u32 lower, +u32 upper,u32 scope,bool exact, +struct list_head *dports); +void tipc_nametbl_lookup_mcast_nodes (struct net *net,u32 type,u32 lower, +u32 upper,struct tipc_nlist *nodes); +bool tipc_nametbl_lookup_group (struct net *net,u32 type,u32 instance, +u32 domain,struct list_head *dsts, +int *dstcnt,u32 exclude, +bool all);void tipc_nametbl_build_group (struct net *net,struct tipc_group *grp,u32 type,u32 domain); -void tipc_nametbl_lookup_dst_nodes (struct net *net,u32 type,u32 lower, -u32 upper,struct tipc_nlist *nodes); -bool tipc_nametbl_lookup (struct net *net,u32 type,u32 instance,u32 domain, -struct list_head *dsts,int *dstcnt,u32 exclude, -bool all);struct publication *tipc_nametbl_publish (struct net *net,struct tipc_uaddr *ua,struct tipc_socket_addr *sk,u32 key); void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,
net/tipc/socket.c +10 -9
@@ -863,8 +863,8 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,/* Lookup destination nodes */ tipc_nlist_init (&dsts,tipc_own_addr (net)); -tipc_nametbl_lookup_dst_nodes (net, seq->type, seq->lower, - seq->upper, &dsts); +tipc_nametbl_lookup_mcast_nodes (net, seq->type, seq->lower, + seq->upper, &dsts);if (!dsts.local && !dsts.remote)return -EHOSTUNREACH ;
@@ -1032,8 +1032,9 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,/* Look for a non-congested destination member, if any */ while (1 ) { -if (!tipc_nametbl_lookup (net, type, inst, scope, &dsts, - &dstcnt, exclude, false)) +if (!tipc_nametbl_lookup_group (net, type, inst, scope, + &dsts, &dstcnt, exclude, + false))return -EHOSTUNREACH ;tipc_dest_pop (&dsts, &node, &port); cong = tipc_group_cong(tsk->group, node, port, blks,
@@ -1179,8 +1180,8 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m, scope =msg_lookup_scope (hdr); exclude =tipc_group_exclude (grp); -if (!tipc_nametbl_lookup (net, type, inst, scope, &dsts, - &dstcnt, exclude, true)) +if (!tipc_nametbl_lookup_group (net, type, inst, scope, &dsts, + &dstcnt, exclude, true))return -EHOSTUNREACH ;if (dstcnt ==1 ) {
@@ -1254,8 +1255,8 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, }/* Create destination port list: */ -tipc_nametbl_mc_lookup (net, type, lower, upper, - scope, exact, &dports); +tipc_nametbl_lookup_mcast_sockets (net, type, lower, upper, + scope, exact, &dports);/* Clone message per destination */ while (tipc_dest_pop (&dports,NULL , &portid)) {
@@ -1485,7 +1486,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) type = dest->addr.name.name.type; inst = dest->addr.name.name.instance; dnode = dest->addr.name.domain; - dport =tipc_nametbl_translate (net, type, inst, &dnode); + dport =tipc_nametbl_lookup_anycast (net, type, inst, &dnode);if (unlikely (!dport && !dnode))return -EHOSTUNREACH ; }else if (dest->addrtype ==TIPC_SOCKET_ADDR ) {
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 8/16 tipc: refactor tipc_sendmsg() and tipc_lookup_anycast()
In reply to [email protected]From: Jon Maloy <[email protected]>
We simplify the signature if function tipc_nametbl_lookup_anycast(), using address structures instead of discrete integers.
This also makes it possible to make some improvements to the functions __tipc_sendmsg() in socket.c and tipc_msg_lookup_dest() in msg.c.
--- net/tipc/msg.c | 23 ++++++------ net/tipc/name_table.c | 75 +++++++++++++++++++------------------- net/tipc/name_table.h | 5 ++- net/tipc/socket.c | 83 +++++++++++++++++++++---------------------- 4 files changed, 91 insertions(+), 95 deletions(-)
net/tipc/msg.c +13 -10
@@ -707,8 +707,11 @@ bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy)bool tipc_msg_lookup_dest (struct net *net,struct sk_buff *skb,int *err) {struct tipc_msg *msg =buf_msg (skb); -u32 dport, dnode; -u32 onode =tipc_own_addr (net); +u32 scope =msg_lookup_scope (msg); +u32 self =tipc_own_addr (net); +u32 inst =msg_nameinst (msg); +struct tipc_socket_addr sk; +struct tipc_uaddr ua;if (!msg_isdata (msg))return false;
@@ -722,16 +725,16 @@ bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err) msg =buf_msg (skb);if (msg_reroute_cnt (msg))return false; - dnode =tipc_scope2node (net,msg_lookup_scope (msg)); - dport =tipc_nametbl_lookup_anycast (net,msg_nametype (msg), -msg_nameinst (msg), &dnode); -if (!dport) +tipc_uaddr (&ua,TIPC_SERVICE_RANGE , scope, +msg_nametype (msg), inst, inst); + sk.node =tipc_scope2node (net, scope); +if (!tipc_nametbl_lookup_anycast (net, &ua, &sk))return false;msg_incr_reroute_cnt (msg); -if (dnode != onode) -msg_set_prevnode (msg, onode); -msg_set_destnode (msg, dnode); -msg_set_destport (msg, dport); +if (sk.node != self) +msg_set_prevnode (msg, self); +msg_set_destnode (msg, sk.node); +msg_set_destport (msg, sk.ref); *err =TIPC_OK ;return true;
net/tipc/name_table.c +36 -39
110 lines not on this page · raw message
net/tipc/name_table.h +2 -3
@@ -110,9 +110,8 @@ struct name_table { };int tipc_nl_name_table_dump (struct sk_buff *skb,struct netlink_callback *cb); - -u32 tipc_nametbl_lookup_anycast (struct net *net,u32 type,u32 instance, -u32 *node); +bool tipc_nametbl_lookup_anycast (struct net *net,struct tipc_uaddr *ua, +struct tipc_socket_addr *sk);void tipc_nametbl_lookup_mcast_sockets (struct net *net,u32 type,u32 lower,u32 upper,u32 scope,bool exact,struct list_head *dports);
net/tipc/socket.c +40 -43
148 lines not on this page · raw message
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 9/16 tipc: simplify signature of tipc_namtbl_lookup_mcast_sockets()
In reply to [email protected]From: Jon Maloy <[email protected]>
We reduce the signature of this function according to the same principle as the preceding commits.
--- net/tipc/name_table.c | 10 +++++----- net/tipc/name_table.h | 5 ++--- net/tipc/socket.c | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 19 deletions(-)
net/tipc/name_table.c +5 -5
@@ -668,21 +668,21 @@ bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,* Used on nodes which have received a multicast/broadcast message * Returns a list of local sockets */ -void tipc_nametbl_lookup_mcast_sockets (struct net *net,u32 type,u32 lower, -u32 upper,u32 scope,bool exact, -struct list_head *dports) +void tipc_nametbl_lookup_mcast_sockets (struct net *net,struct tipc_uaddr *ua, +bool exact,struct list_head *dports) {struct service_range *sr;struct tipc_service *sc;struct publication *p; +u32 scope = ua->scope;rcu_read_lock (); - sc =tipc_service_find (net, type); + sc =tipc_service_find (net, ua->sr.type);if (!sc) goto exit;spin_lock_bh (&sc->lock); - service_range_foreach_match(sr, sc, lower, upper) { + service_range_foreach_match(sr, sc, ua->sr.lower, ua->sr.upper) {list_for_each_entry (p, &sr->local_publ, local_publ) {if (p->scope == scope || (!exact && p->scope < scope))tipc_dest_push (dports,0 , p->sk.ref);
net/tipc/name_table.h +2 -3
@@ -112,9 +112,8 @@ struct name_table {int tipc_nl_name_table_dump (struct sk_buff *skb,struct netlink_callback *cb);bool tipc_nametbl_lookup_anycast (struct net *net,struct tipc_uaddr *ua,struct tipc_socket_addr *sk); -void tipc_nametbl_lookup_mcast_sockets (struct net *net,u32 type,u32 lower, -u32 upper,u32 scope,bool exact, -struct list_head *dports); +void tipc_nametbl_lookup_mcast_sockets (struct net *net,struct tipc_uaddr *ua, +bool exact,struct list_head *dports);void tipc_nametbl_lookup_mcast_nodes (struct net *net,u32 type,u32 lower,u32 upper,struct tipc_nlist *nodes); bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance,
net/tipc/socket.c +11 -11
@@ -1205,17 +1205,18 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, struct sk_buff_head *inputq) {u32 self =tipc_own_addr (net); -u32 type, lower, upper, scope;struct sk_buff *skb, *_skb;u32 portid, onode;struct sk_buff_head tmpq;struct list_head dports;struct tipc_msg *hdr; +struct tipc_uaddr ua;int user, mtyp, hlen;bool exact;__skb_queue_head_init (&tmpq);INIT_LIST_HEAD (&dports); + ua.addrtype =TIPC_SERVICE_RANGE ; skb =tipc_skb_peek (arrvq, &inputq->lock);for (; skb; skb =tipc_skb_peek (arrvq, &inputq->lock)) {
@@ -1224,7 +1225,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, mtyp =msg_type (hdr); hlen =skb_headroom (skb) +msg_hdr_sz (hdr); onode =msg_orignode (hdr); - type =msg_nametype (hdr); + ua.sr.type =msg_nametype (hdr);if (mtyp ==TIPC_GRP_UCAST_MSG || user ==GROUP_PROTOCOL ) {spin_lock_bh (&inputq->lock);
@@ -1239,24 +1240,23 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,/* Group messages require exact scope match */ if (msg_in_group (hdr)) { - lower =0 ; - upper = ~0 ; - scope =msg_lookup_scope (hdr); + ua.sr.lower =0 ; + ua.sr.upper = ~0 ; + ua.scope =msg_lookup_scope (hdr); exact = true; }else {/* TIPC_NODE_SCOPE means "any scope" in this context */ if (onode == self) - scope =TIPC_NODE_SCOPE ; + ua.scope =TIPC_NODE_SCOPE ;else - scope =TIPC_CLUSTER_SCOPE ; + ua.scope =TIPC_CLUSTER_SCOPE ; exact = false; - lower =msg_namelower (hdr); - upper =msg_nameupper (hdr); + ua.sr.lower =msg_namelower (hdr); + ua.sr.upper =msg_nameupper (hdr); }/* Create destination port list: */ -tipc_nametbl_lookup_mcast_sockets (net, type, lower, upper, - scope, exact, &dports); +tipc_nametbl_lookup_mcast_sockets (net, &ua, exact, &dports);/* Clone message per destination */ while (tipc_dest_pop (&dports,NULL , &portid)) {
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 10/16 tipc: simplify signature of tipc_nametbl_lookup_mcast_nodes()
In reply to [email protected]From: Jon Maloy <[email protected]>
We follow up the preceding commits by reducing the signature of the function tipc_nametbl_lookup_mcast_nodes().
--- net/tipc/name_table.c | 8 ++++---- net/tipc/name_table.h | 4 ++-- net/tipc/socket.c | 18 ++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-)
net/tipc/name_table.c +4 -4
@@ -698,20 +698,20 @@ void tipc_nametbl_lookup_mcast_sockets(struct net *net, struct tipc_uaddr *ua,* Used on nodes which are sending out a multicast/broadcast message * Returns a list of nodes, including own node if applicable */ -void tipc_nametbl_lookup_mcast_nodes (struct net *net,u32 type,u32 lower, -u32 upper,struct tipc_nlist *nodes) +void tipc_nametbl_lookup_mcast_nodes (struct net *net,struct tipc_uaddr *ua, +struct tipc_nlist *nodes) {struct service_range *sr;struct tipc_service *sc;struct publication *p;rcu_read_lock (); - sc =tipc_service_find (net, type); + sc =tipc_service_find (net, ua->sr.type);if (!sc) goto exit;spin_lock_bh (&sc->lock); - service_range_foreach_match(sr, sc, lower, upper) { + service_range_foreach_match(sr, sc, ua->sr.lower, ua->sr.upper) {list_for_each_entry (p, &sr->all_publ, all_publ) {tipc_nlist_add (nodes, p->sk.node); }
net/tipc/name_table.h +2 -2
@@ -114,8 +114,8 @@ bool tipc_nametbl_lookup_anycast(struct net *net, struct tipc_uaddr *ua, struct tipc_socket_addr *sk);void tipc_nametbl_lookup_mcast_sockets (struct net *net,struct tipc_uaddr *ua,bool exact,struct list_head *dports); -void tipc_nametbl_lookup_mcast_nodes (struct net *net,u32 type,u32 lower, -u32 upper,struct tipc_nlist *nodes); +void tipc_nametbl_lookup_mcast_nodes (struct net *net,struct tipc_uaddr *ua, +struct tipc_nlist *nodes); bool tipc_nametbl_lookup_group(struct net *net, u32 type, u32 instance, u32 domain, struct list_head *dsts, int *dstcnt, u32 exclude,
net/tipc/socket.c +8 -10
@@ -832,7 +832,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,/** * tipc_sendmcast - send multicast message * @sock: socket structure -* @seq: destination address +* @ua: destination address struct * @msg: message to send * @dlen: length of data to send * @timeout: timeout to wait for wakeup
@@ -840,7 +840,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,* Called from function tipc_sendmsg(), which has done all sanity checks * Return: the number of bytes sent on success, or errno */ -static int tipc_sendmcast (struct socket *sock,struct tipc_service_range *seq, +static int tipc_sendmcast (struct socket *sock,struct tipc_uaddr *ua,struct msghdr *msg,size_t dlen,long timeout) {struct sock *sk = sock->sk;
@@ -848,7 +848,6 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,struct tipc_msg *hdr = &tsk->phdr;struct net *net =sock_net (sk);int mtu =tipc_bcast_get_mtu (net); -struct tipc_mc_method *method = &tsk->mc_method;struct sk_buff_head pkts;struct tipc_nlist dsts;int rc;
@@ -863,8 +862,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,/* Lookup destination nodes */ tipc_nlist_init (&dsts,tipc_own_addr (net)); -tipc_nametbl_lookup_mcast_nodes (net, seq->type, seq->lower, - seq->upper, &dsts); +tipc_nametbl_lookup_mcast_nodes (net, ua, &dsts);if (!dsts.local && !dsts.remote)return -EHOSTUNREACH ;
@@ -874,9 +872,9 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,msg_set_lookup_scope (hdr,TIPC_CLUSTER_SCOPE );msg_set_destport (hdr,0 );msg_set_destnode (hdr,0 ); -msg_set_nametype (hdr, seq->type); -msg_set_namelower (hdr, seq->lower); -msg_set_nameupper (hdr, seq->upper); +msg_set_nametype (hdr, ua->sr.type); +msg_set_namelower (hdr, ua->sr.lower); +msg_set_nameupper (hdr, ua->sr.upper);/* Build message as chain of buffers */ __skb_queue_head_init (&pkts);
@@ -886,7 +884,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_service_range *seq,if (unlikely (rc == dlen)) {trace_tipc_sk_sendmcast (sk,skb_peek (&pkts),TIPC_DUMP_SK_SNDQ ," " ); - rc =tipc_mcast_xmit (net, &pkts, method, &dsts, + rc =tipc_mcast_xmit (net, &pkts, &tsk->mc_method, &dsts, &tsk->cong_link_cnt); }
@@ -1479,7 +1477,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)/* Determine destination */ if (atype ==TIPC_SERVICE_RANGE ) { -return tipc_sendmcast (sock, &ua->sr, m, dlen, timeout); +return tipc_sendmcast (sock, ua, m, dlen, timeout); }else if (atype ==TIPC_SERVICE_ADDR ) { skaddr.node = ua->lookup_node; ua->scope =tipc_node2scope (skaddr.node);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 11/16 tipc: simplify signature of tipc_nametbl_lookup_group()
In reply to [email protected]From: Jon Maloy <[email protected]>
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
--- net/tipc/name_table.c | 14 +++++++------- net/tipc/name_table.h | 7 +++---- net/tipc/socket.c | 42 +++++++++++++++++------------------------- 3 files changed, 27 insertions(+), 36 deletions(-)
net/tipc/name_table.c +7 -7
@@ -621,31 +621,31 @@ bool tipc_nametbl_lookup_anycast(struct net *net,* destination socket/node pairs matching the given address. * 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, -u32 scope,struct list_head *dsts, -int *dstcnt,u32 exclude, -bool mcast) +bool tipc_nametbl_lookup_group (struct net *net,struct tipc_uaddr *ua, +struct list_head *dsts,int *dstcnt, +u32 exclude,bool mcast) {u32 self =tipc_own_addr (net); +u32 inst = ua->sa.instance;struct service_range *sr;struct tipc_service *sc;struct publication *p; *dstcnt =0 ;rcu_read_lock (); - sc =tipc_service_find (net, type); + sc =tipc_service_find (net, ua->sa.type);if (unlikely (!sc)) goto exit;spin_lock_bh (&sc->lock);/* 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) goto no_match;list_for_each_entry (p, &sr->all_publ, all_publ) { -if (p->scope != scope) +if (p->scope != ua->scope)continue ;if (p->sk.ref == exclude && p->sk.node == self)continue ;
net/tipc/name_table.h +3 -4
@@ -116,10 +116,9 @@ void tipc_nametbl_lookup_mcast_sockets(struct net *net, struct tipc_uaddr *ua, bool exact, struct list_head *dports);void tipc_nametbl_lookup_mcast_nodes (struct net *net,struct tipc_uaddr *ua,struct tipc_nlist *nodes); -bool tipc_nametbl_lookup_group (struct net *net,u32 type,u32 instance, -u32 domain,struct list_head *dsts, -int *dstcnt,u32 exclude, -bool all); +bool tipc_nametbl_lookup_group (struct net *net,struct tipc_uaddr *ua, +struct list_head *dsts,int *dstcnt, +u32 exclude,bool mcast);void tipc_nametbl_build_group (struct net *net,struct tipc_group *grp,u32 type,u32 domain); struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
net/tipc/socket.c +17 -25
109 lines not on this page · raw message
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 12/16 tipc: simplify signature of tipc_service_find_range()
In reply to [email protected]From: Jon Maloy <[email protected]>
We simplify the signatures of the functions tipc_service_create_range() and tipc_service_find_range().
--- net/tipc/name_table.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/tipc/name_table.c +8 -6
@@ -275,13 +275,13 @@ static struct tipc_service *tipc_service_create(u32 type, struct hlist_head *hd)/* tipc_service_find_range - find service range matching publication parameters */ static struct service_range *tipc_service_find_range (struct tipc_service *sc, -u32 lower,u32 upper) +struct tipc_uaddr *ua) {struct service_range *sr; - service_range_foreach_match(sr, sc, lower, upper) { + service_range_foreach_match(sr, sc, ua->sr.lower, ua->sr.upper) {/* Look for exact match */ -if (sr->lower == lower && sr->upper == upper) +if (sr->lower == ua->sr.lower && sr->upper == ua->sr.upper)return sr; }
@@ -289,10 +289,12 @@ static struct service_range *tipc_service_find_range(struct tipc_service *sc, }static struct service_range *tipc_service_create_range (struct tipc_service *sc, -u32 lower,u32 upper) +struct publication *p) {struct rb_node **n, *parent =NULL ;struct service_range *sr; +u32 lower = p->sr.lower; +u32 upper = p->sr.upper; n = &sc->ranges.rb_node;while (*n) {
@@ -332,7 +334,7 @@ static bool tipc_service_insert_publ(struct net *net,bool res = false;spin_lock_bh (&sc->lock); - sr =tipc_service_create_range (sc, p->sr.lower, p->sr.upper); + sr =tipc_service_create_range (sc, p);if (!sr) goto exit;
@@ -513,7 +515,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,return NULL ;spin_lock_bh (&sc->lock); - sr =tipc_service_find_range (sc, lower, upper); + sr =tipc_service_find_range (sc, ua);if (!sr) goto exit; p =tipc_service_remove_publ (sr, sk, key);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 13/16 tipc: simplify signature of tipc_find_service()
In reply to [email protected]From: Jon Maloy <[email protected]>
We reduce the signature of tipc_find_service() and tipc_create_service(). The reason for doing this might not be obvious, but we plan to let struct tipc_uaddr contain information that is relevant for these functions in a later commit.
--- net/tipc/name_table.c | 62 ++++++++++++++++++++++++++----------------- net/tipc/name_table.h | 2 +- net/tipc/socket.c | 2 +- 3 files changed, 39 insertions(+), 27 deletions(-)
net/tipc/name_table.c +37 -25
@@ -249,25 +249,30 @@ static struct publication *tipc_publ_create(struct tipc_uaddr *ua,/** * tipc_service_create - create a service structure for the specified 'type' -* @type: service type -* @hd: name_table services list +* @net: network namespace +* @ua: address representing the service to be bound * * Allocates a single range structure and sets it to all 0's. */ -static struct tipc_service *tipc_service_create (u32 type,struct hlist_head *hd) +static struct tipc_service *tipc_service_create (struct net *net, +struct tipc_uaddr *ua) { -struct tipc_service *service =kzalloc (sizeof (*service),GFP_ATOMIC ); +struct name_table *nt =tipc_name_table (net); +struct tipc_service *service; +struct hlist_head *hd; + service =kzalloc (sizeof (*service),GFP_ATOMIC );if (!service) {pr_warn ("Service creation failed, no memory\n" );return NULL ; }spin_lock_init (&service->lock); - service->type = type; + service->type = ua->sr.type; service->ranges =RB_ROOT ;INIT_HLIST_NODE (&service->service_list);INIT_LIST_HEAD (&service->subscriptions); + hd = &nt->services[hash (ua->sr.type)];hlist_add_head_rcu (&service->service_list, hd);return service; }
@@ -455,15 +460,16 @@ static void tipc_service_subscribe(struct tipc_service *service, } } -static struct tipc_service *tipc_service_find (struct net *net,u32 type) +static struct tipc_service *tipc_service_find (struct net *net, +struct tipc_uaddr *ua) {struct name_table *nt =tipc_name_table (net);struct hlist_head *service_head;struct tipc_service *service; - service_head = &nt->services[hash (type)]; + service_head = &nt->services[hash (ua->sr.type)];hlist_for_each_entry_rcu (service, service_head, service_list) { -if (service->type == type) +if (service->type == ua->sr.type)return service; }return NULL ;
@@ -474,7 +480,6 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, 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;
@@ -488,9 +493,9 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, type, ua->sr.lower, ua->sr.upper, sk->node);return NULL ; } - sc =tipc_service_find (net, type); + sc =tipc_service_find (net, ua);if (!sc) - sc =tipc_service_create (type, &nt->services[hash (type)]); + sc =tipc_service_create (net, ua);if (sc &&tipc_service_insert_publ (net, sc, p))return p;kfree (p);
@@ -510,7 +515,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,u32 lower = ua->sr.lower;bool last; - sc =tipc_service_find (net, ua->sr.type); + sc =tipc_service_find (net, ua);if (!sc)return NULL ;
@@ -582,7 +587,7 @@ bool tipc_nametbl_lookup_anycast(struct net *net,return true;rcu_read_lock (); - sc =tipc_service_find (net, ua->sr.type); + sc =tipc_service_find (net, ua);if (unlikely (!sc)) goto exit;
@@ -635,7 +640,7 @@ bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua, *dstcnt =0 ;rcu_read_lock (); - sc =tipc_service_find (net, ua->sa.type); + sc =tipc_service_find (net, ua);if (unlikely (!sc)) goto exit;
@@ -679,7 +684,7 @@ void tipc_nametbl_lookup_mcast_sockets(struct net *net, struct tipc_uaddr *ua,u32 scope = ua->scope;rcu_read_lock (); - sc =tipc_service_find (net, ua->sr.type); + sc =tipc_service_find (net, ua);if (!sc) goto exit;
@@ -708,7 +713,7 @@ void tipc_nametbl_lookup_mcast_nodes(struct net *net, struct tipc_uaddr *ua,struct publication *p;rcu_read_lock (); - sc =tipc_service_find (net, ua->sr.type); + sc =tipc_service_find (net, ua);if (!sc) goto exit;
@@ -726,7 +731,7 @@ void tipc_nametbl_lookup_mcast_nodes(struct net *net, struct tipc_uaddr *ua,/* tipc_nametbl_build_group - build list of communication group members */ void tipc_nametbl_build_group (struct net *net,struct tipc_group *grp, -u32 type,u32 scope) +struct tipc_uaddr *ua) {struct service_range *sr;struct tipc_service *sc;
@@ -734,7 +739,7 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,struct rb_node *n;rcu_read_lock (); - sc =tipc_service_find (net, type); + sc =tipc_service_find (net, ua);if (!sc) goto exit;
@@ -742,9 +747,10 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,for (n =rb_first (&sc->ranges); n; n =rb_next (n)) { sr = container_of(n, struct service_range, tree_node);list_for_each_entry (p, &sr->all_publ, all_publ) { -if (p->scope != scope) +if (p->scope != ua->scope)continue ; -tipc_group_add_member (grp, p->sk.node, p->sk.ref, p->sr.lower); +tipc_group_add_member (grp, p->sk.node, p->sk.ref, + p->sr.lower); } }spin_unlock_bh (&sc->lock);
@@ -826,17 +832,18 @@ void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,*/ bool tipc_nametbl_subscribe (struct tipc_subscription *sub) { -struct name_table *nt =tipc_name_table (sub->net);struct tipc_net *tn =tipc_net (sub->net);struct tipc_subscr *s = &sub->evt.s;u32 type =tipc_sub_read (s, seq.type);struct tipc_service *sc; +struct tipc_uaddr ua;bool res = true; +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type,0 ,0 );spin_lock_bh (&tn->nametbl_lock); - sc =tipc_service_find (sub->net, type); + sc =tipc_service_find (sub->net, &ua);if (!sc) - sc =tipc_service_create (type, &nt->services[hash (type)]); + sc =tipc_service_create (sub->net, &ua);if (sc) {spin_lock_bh (&sc->lock);tipc_service_subscribe (sc, sub);
@@ -861,9 +868,11 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *sub)struct tipc_subscr *s = &sub->evt.s;u32 type =tipc_sub_read (s, seq.type);struct tipc_service *sc; +struct tipc_uaddr ua; +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type,0 ,0 );spin_lock_bh (&tn->nametbl_lock); - sc =tipc_service_find (sub->net, type); + sc =tipc_service_find (sub->net, &ua);if (!sc) goto exit;
@@ -1052,6 +1061,7 @@ static int tipc_nl_service_list(struct net *net, struct tipc_nl_msg *msg,struct tipc_net *tn =tipc_net (net);struct tipc_service *service =NULL ;struct hlist_head *head; +struct tipc_uaddr ua;int err;int i;
@@ -1065,7 +1075,9 @@ static int tipc_nl_service_list(struct net *net, struct tipc_nl_msg *msg,if (*last_type || (!i && *last_key && (*last_lower == *last_key))) { - service =tipc_service_find (net, *last_type); +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , + *last_type, *last_lower, *last_lower); + service =tipc_service_find (net, &ua);if (!service)return -EPIPE ; }else {
net/tipc/name_table.h +1 -1
@@ -120,7 +120,7 @@ bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua, struct list_head *dsts, int *dstcnt, u32 exclude, bool mcast);void tipc_nametbl_build_group (struct net *net,struct tipc_group *grp, -u32 type,u32 domain); +struct tipc_uaddr *ua);struct publication *tipc_nametbl_publish (struct net *net,struct tipc_uaddr *ua,struct tipc_socket_addr *sk,u32 key); void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,
net/tipc/socket.c +1 -1
@@ -3075,9 +3075,9 @@ static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq)msg_set_lookup_scope (hdr, mreq->scope);msg_set_nametype (hdr, mreq->type);msg_set_dest_droppable (hdr, true); -tipc_nametbl_build_group (net, grp, mreq->type, mreq->scope);tipc_uaddr (&ua,TIPC_SERVICE_RANGE , mreq->scope, mreq->type, mreq->instance, mreq->instance); +tipc_nametbl_build_group (net, grp, &ua); rc =tipc_sk_publish (tsk, &ua);if (rc) {tipc_group_delete (net, grp);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 14/16 tipc: simplify api between binding table and topology server
In reply to [email protected]From: Jon Maloy <[email protected]>
The function tipc_report_overlap() is called from the binding table with numerous parameters taken from an instance of struct publication. A closer look reveals that it always is safe to send along a pointer to the instance itself, and hence reduce the call signature. We do that in this commit.
--- net/tipc/name_table.c | 21 ++++++--------- net/tipc/subscr.c | 59 +++++++++++++++++++++++-------------------- net/tipc/subscr.h | 11 +++----- 3 files changed, 43 insertions(+), 48 deletions(-)
net/tipc/name_table.c +8 -13
@@ -358,9 +358,7 @@ static bool tipc_service_insert_publ(struct net *net,/* Any subscriptions waiting for notification? */ list_for_each_entry_safe (sub, tmp, &sc->subscriptions, service_list) { -tipc_sub_report_overlap (sub, p->sr.lower, p->sr.upper, -TIPC_PUBLISHED , p->sk.ref, p->sk.node, - p->scope, first); +tipc_sub_report_overlap (sub, p,TIPC_PUBLISHED , first); } res = true; exit:
@@ -453,9 +451,7 @@ static void tipc_service_subscribe(struct tipc_service *service,/* Sort the publications before reporting */ list_sort (NULL , &publ_list, tipc_publ_sort);list_for_each_entry_safe (p, tmp, &publ_list, list) { -tipc_sub_report_overlap (sub, p->sr.lower, p->sr.upper, -TIPC_PUBLISHED , p->sk.ref, p->sk.node, - p->scope, true); +tipc_sub_report_overlap (sub, p,TIPC_PUBLISHED , true);list_del_init (&p->list); } }
@@ -511,8 +507,6 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,struct publication *p =NULL ;struct service_range *sr;struct tipc_service *sc; -u32 upper = ua->sr.upper; -u32 lower = ua->sr.lower;bool last; sc =tipc_service_find (net, ua);
@@ -530,8 +524,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,/* Notify any waiting subscriptions */ last =list_empty (&sr->all_publ);list_for_each_entry_safe (sub, tmp, &sc->subscriptions, service_list) { -tipc_sub_report_overlap (sub, lower, upper,TIPC_WITHDRAWN , - sk->ref, sk->node, ua->scope, last); +tipc_sub_report_overlap (sub, p,TIPC_WITHDRAWN , last); }/* Remove service range item if this was its last publication */
@@ -540,7 +533,7 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,kfree (sr); } -/* Delete service item if this no more publications and subscriptions */ +/* Delete service item if no more publications and subscriptions */ if (RB_EMPTY_ROOT (&sc->ranges) &&list_empty (&sc->subscriptions)) {hlist_del_init_rcu (&sc->service_list);kfree_rcu (sc, rcu);
@@ -839,7 +832,8 @@ bool tipc_nametbl_subscribe(struct tipc_subscription *sub)struct tipc_uaddr ua;bool res = true; -tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type,0 ,0 ); +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type, +tipc_sub_read (s, seq.lower),tipc_sub_read (s, seq.upper));spin_lock_bh (&tn->nametbl_lock); sc =tipc_service_find (sub->net, &ua);if (!sc)
@@ -870,7 +864,8 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *sub)struct tipc_service *sc;struct tipc_uaddr ua; -tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type,0 ,0 ); +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type, +tipc_sub_read (s, seq.lower),tipc_sub_read (s, seq.upper));spin_lock_bh (&tn->nametbl_lock); sc =tipc_service_find (sub->net, &ua);if (!sc)
net/tipc/subscr.c +31 -28
109 lines not on this page · raw message
net/tipc/subscr.h +4 -7
@@ -3,7 +3,7 @@* * Copyright (c) 2003-2017, Ericsson AB * Copyright (c) 2005-2007, 2012-2013, Wind River Systems -* Copyright (c) 2020, Red Hat Inc +* Copyright (c) 2020-2021, Red Hat Inc * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@#define TIPC_MAX_SUBSCR 65535#define TIPC_MAX_PUBL 65535 +struct publication ;struct tipc_subscription ;struct tipc_conn ;
@@ -74,13 +75,9 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net,struct tipc_subscr *s, int conid);void tipc_sub_unsubscribe (struct tipc_subscription *sub); - -int tipc_sub_check_overlap (struct tipc_service_range *seq, -u32 found_lower,u32 found_upper);void tipc_sub_report_overlap (struct tipc_subscription *sub, -u32 found_lower,u32 found_upper, -u32 event,u32 port,u32 node, -u32 scope,int must); +struct publication *p, +u32 event,bool must);int __net_init tipc_topsrv_init_net (struct net *net); void __net_exit tipc_topsrv_exit_net(struct net *net);
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 15/16 tipc: add host-endian copy of user subscription to struct tipc_subscription
In reply to [email protected]From: Jon Maloy <[email protected]>
We reduce and localize the usage of the tipc_sub_xx() macros by adding a corresponding member, with fields set in host-endian format, to struct tipc_subscription.
--- net/tipc/name_table.c | 29 +++++++++++----------------- net/tipc/subscr.c | 45 +++++++++++++++++++++++-------------------- net/tipc/subscr.h | 3 ++- 3 files changed, 37 insertions(+), 40 deletions(-)
net/tipc/name_table.c +11 -18
@@ -416,17 +416,14 @@ static int tipc_publ_sort(void *priv, struct list_head *a,static void tipc_service_subscribe (struct tipc_service *service,struct tipc_subscription *sub) { -struct tipc_subscr *sb = &sub->evt.s;struct publication *p, *first, *tmp;struct list_head publ_list;struct service_range *sr; -struct tipc_service_range r; -u32 filter; +u32 filter, lower, upper; - r.type =tipc_sub_read (sb, seq.type); - r.lower =tipc_sub_read (sb, seq.lower); - r.upper =tipc_sub_read (sb, seq.upper); - filter =tipc_sub_read (sb, filter); + filter = sub->s.filter; + lower = sub->s.seq.lower; + upper = sub->s.seq.upper;tipc_sub_get (sub);list_add (&sub->service_list, &service->subscriptions);
@@ -435,7 +432,7 @@ static void tipc_service_subscribe(struct tipc_service *service,return ;INIT_LIST_HEAD (&publ_list); - service_range_foreach_match(sr, service, r.lower, r.upper) { + service_range_foreach_match(sr, service, lower, upper) { first =NULL ;list_for_each_entry (p, &sr->all_publ, all_publ) {if (filter &TIPC_SUB_PORTS )
@@ -826,14 +823,13 @@ void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,bool tipc_nametbl_subscribe (struct tipc_subscription *sub) {struct tipc_net *tn =tipc_net (sub->net); -struct tipc_subscr *s = &sub->evt.s; -u32 type =tipc_sub_read (s, seq.type); +u32 type = sub->s.seq.type;struct tipc_service *sc;struct tipc_uaddr ua;bool res = true;tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type, -tipc_sub_read (s, seq.lower),tipc_sub_read (s, seq.upper)); + sub->s.seq.lower, sub->s.seq.upper);spin_lock_bh (&tn->nametbl_lock); sc =tipc_service_find (sub->net, &ua);if (!sc)
@@ -843,9 +839,8 @@ bool tipc_nametbl_subscribe(struct tipc_subscription *sub)tipc_service_subscribe (sc, sub);spin_unlock_bh (&sc->lock); }else { -pr_warn ("Failed to subscribe for {%u,%u,%u}\n" , type, -tipc_sub_read (s, seq.lower), -tipc_sub_read (s, seq.upper)); +pr_warn ("Failed to subscribe for {%u,%u,%u}\n" , + type, sub->s.seq.lower, sub->s.seq.upper); res = false; }spin_unlock_bh (&tn->nametbl_lock);
@@ -859,13 +854,11 @@ bool tipc_nametbl_subscribe(struct tipc_subscription *sub)void tipc_nametbl_unsubscribe (struct tipc_subscription *sub) {struct tipc_net *tn =tipc_net (sub->net); -struct tipc_subscr *s = &sub->evt.s; -u32 type =tipc_sub_read (s, seq.type);struct tipc_service *sc;struct tipc_uaddr ua; -tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , type, -tipc_sub_read (s, seq.lower),tipc_sub_read (s, seq.upper)); +tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_NODE_SCOPE , + sub->s.seq.type, sub->s.seq.lower, sub->s.seq.upper);spin_lock_bh (&tn->nametbl_lock); sc =tipc_service_find (sub->net, &ua);if (!sc)
net/tipc/subscr.c +24 -21
79 lines not on this page · raw message
net/tipc/subscr.h +2 -1
@@ -60,12 +60,13 @@ struct tipc_conn;* @lock: serialize up/down and timer events */ struct tipc_subscription { +struct tipc_subscr s; +struct tipc_event evt;struct kref kref;struct net *net;struct timer_list timer;struct list_head service_list;struct list_head sub_list; -struct tipc_event evt;int conid;bool inactive;spinlock_t lock;
Signature · 1 line
2.29.2
[email protected]
maintainerPATCH 16/16 tipc: remove some unnecessary warnings
In reply to [email protected]From: Jon Maloy <[email protected]>
We move some warning printouts to more strategic locations to avoid duplicates and yield more detailed information about the reported problem.
--- net/tipc/name_distr.c | 7 ------- net/tipc/name_table.c | 30 ++++++++++++++++-------------- 2 files changed, 16 insertions(+), 21 deletions(-)
net/tipc/name_distr.c +0 -7
@@ -253,13 +253,6 @@ static void tipc_publ_purge(struct net *net, struct publication *p, u32 addr)if (_p)tipc_node_unsubscribe (net, &_p->binding_node, addr);spin_unlock_bh (&tn->nametbl_lock); - -if (_p != p) { -pr_err ("Unable to remove publication from failed node\n" -" (type=%u, lower=%u, node=%u, port=%u, key=%u)\n" , - p->sr.type, p->sr.lower, p->sk.node, p->sk.ref, p->key); - } -if (_p)kfree_rcu (_p, rcu); }
net/tipc/name_table.c +16 -14
@@ -337,6 +337,7 @@ static bool tipc_service_insert_publ(struct net *net,u32 node = p->sk.node;bool first = false;bool res = false; +u32 key = p->key;spin_lock_bh (&sc->lock); sr =tipc_service_create_range (sc, p);
@@ -347,8 +348,12 @@ static bool tipc_service_insert_publ(struct net *net,/* Return if the publication already exists */ list_for_each_entry (_p, &sr->all_publ, all_publ) { -if (_p->key == p->key && (!_p->sk.node || _p->sk.node == node)) +if (_p->key == key && (!_p->sk.node || _p->sk.node == node)) { +pr_debug ("Failed to bind duplicate %u,%u,%u/%u:%u/%u\n" , + p->sr.type, p->sr.lower, p->sr.upper, + node, p->sk.ref, key); goto exit; + } }if (in_own_node (net, p->sk.node))
@@ -475,17 +480,11 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, {struct tipc_service *sc;struct publication *p; -u32 type = ua->sr.type; p =tipc_publ_create (ua, sk, key);if (!p)return NULL ; -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, ua);if (!sc) sc =tipc_service_create (net, ua);
@@ -508,15 +507,15 @@ struct publication *tipc_nametbl_remove_publ(struct net *net, sc =tipc_service_find (net, ua);if (!sc) -return NULL ; + goto exit;spin_lock_bh (&sc->lock); sr =tipc_service_find_range (sc, ua);if (!sr) - goto exit; + goto unlock; p =tipc_service_remove_publ (sr, sk, key);if (!p) - goto exit; + goto unlock;/* Notify any waiting subscriptions */ last =list_empty (&sr->all_publ);
@@ -535,8 +534,14 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,hlist_del_init_rcu (&sc->service_list);kfree_rcu (sc, rcu); } -exit: +unlock:spin_unlock_bh (&sc->lock); +exit: +if (!p) { +pr_err ("Failed to remove unknown binding: %u,%u,%u/%u:%u/%u\n" , + ua->sr.type, ua->sr.lower, ua->sr.upper, + sk->node, sk->ref, key); + }return p; }
@@ -805,9 +810,6 @@ void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua, skb =tipc_named_withdraw (net, p);list_del_init (&p->binding_sock);kfree_rcu (p, rcu); - }else { -pr_err ("Failed to remove local publication {%u,%u,%u}/%u\n" , - ua->sr.type, ua->sr.lower, ua->sr.upper, key); } rc_dests = nt->rc_dests;spin_unlock_bh (&tn->nametbl_lock);
Signature · 1 line
2.29.2
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 25 lines · On Tue, 16 Mar 2021 22:06:07 -0400 you wrote:
From: Jon Maloy <[email protected]>
We do a number of cleanups and simplifications, especially regarding call signatures in the binding table. This makes the code easier to understand and serves as preparation for upcoming functional additions.
Jon Maloy (16):
tipc: re-organize members of struct publication
tipc: move creation of publication item one level up in call chain
tipc: introduce new unified address type for internal use
tipc: simplify signature oftipc_namtbl_publish()
tipc: simplify call signatures for publication creation
tipc: simplify signature oftipc_nametbl_withdraw()functions
tipc: rename binding table lookup functions
tipc: refactortipc_sendmsg()andtipc_lookup_anycast()
tipc: simplify signature oftipc_namtbl_lookup_mcast_sockets()
tipc: simplify signature oftipc_nametbl_lookup_mcast_nodes()
tipc: simplify signature oftipc_nametbl_lookup_group()
tipc: simplify signature oftipc_service_find_range()
tipc: simplify signature oftipc_find_service()
tipc: simplify api between binding table and topology server
tipc: add host-endian copy of user subscription to struct
tipc_subscription
tipc: remove some unnecessary warnings
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,01/16] tipc: re-organize members of struct publication
https://git.kernel.org/netdev/net-next/c/998d3907f419 - [net-next,02/16] tipc: move creation of publication item one level up in call chain https://git.kernel.org/netdev/net-next/c/b26b5aa9cebe - [net-next,03/16] tipc: introduce new unified address type for internal use https://git.kernel.org/netdev/net-next/c/7823f04f34b8 - [net-next,04/16] tipc: simplify signature of tipc_namtbl_publish() https://git.kernel.org/netdev/net-next/c/50a3499ab853 - [net-next,05/16] tipc: simplify call signatures for publication creation https://git.kernel.org/netdev/net-next/c/a45ffa68573e - [net-next,06/16] tipc: simplify signature of tipc_nametbl_withdraw() functions https://git.kernel.org/netdev/net-next/c/2c98da079063 - [net-next,07/16] tipc: rename binding table lookup functions https://git.kernel.org/netdev/net-next/c/66db239c4894 - [net-next,08/16] tipc: refactor tipc_sendmsg() and tipc_lookup_anycast() https://git.kernel.org/netdev/net-next/c/908148bc5046 - [net-next,09/16] tipc: simplify signature of tipc_namtbl_lookup_mcast_sockets() https://git.kernel.org/netdev/net-next/c/45ceea2d403b - [net-next,10/16] tipc: simplify signature of tipc_nametbl_lookup_mcast_nodes() https://git.kernel.org/netdev/net-next/c/833f867089e5 - [net-next,11/16] tipc: simplify signature of tipc_nametbl_lookup_group() https://git.kernel.org/netdev/net-next/c/006ed14ef82b - [net-next,12/16] tipc: simplify signature of tipc_service_find_range() https://git.kernel.org/netdev/net-next/c/13c9d23f6ac3 - [net-next,13/16] tipc: simplify signature of tipc_find_service() https://git.kernel.org/netdev/net-next/c/6e44867b01e6 - [net-next,14/16] tipc: simplify api between binding table and topology server https://git.kernel.org/netdev/net-next/c/09f78b851ea3 - [net-next,15/16] tipc: add host-endian copy of user subscription to struct tipc_subscription https://git.kernel.org/netdev/net-next/c/429189acac53 - [net-next,16/16] tipc: remove some unnecessary warnings https://git.kernel.org/netdev/net-next/c/5c8349503d00
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html