Skip to content

Commit

Permalink
Merge branch 'tipc-de-generealize-topology-server'
Browse files Browse the repository at this point in the history
Jon Maloy says:

====================
tipc: de-generealize topology server

The topology server is partially based on a template that is much
more generic than what we need. This results in a code that is
unnecessarily hard to follow and keeping bug free.

We now take the consequence of the fact that we only have one such
server in TIPC, - with no prospects for introducing any more, and
adapt the code to the specialized task is really is doing.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 16, 2018
2 parents 35ed663 + 026321c commit 65bd449
Show file tree
Hide file tree
Showing 10 changed files with 862 additions and 1,119 deletions.
2 changes: 1 addition & 1 deletion net/tipc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tipc-y += addr.o bcast.o bearer.o \
core.o link.o discover.o msg.o \
name_distr.o subscr.o monitor.o name_table.o net.o \
netlink.o netlink_compat.o node.o socket.o eth_media.o \
server.o socket.o group.o
topsrv.o socket.o group.o

tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
Expand Down
6 changes: 3 additions & 3 deletions net/tipc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct tipc_bearer;
struct tipc_bc_base;
struct tipc_link;
struct tipc_name_table;
struct tipc_server;
struct tipc_topsrv;
struct tipc_monitor;

#define TIPC_MOD_VER "2.0.0"
Expand Down Expand Up @@ -112,7 +112,7 @@ struct tipc_net {
struct list_head dist_queue;

/* Topology subscription server */
struct tipc_server *topsrv;
struct tipc_topsrv *topsrv;
atomic_t subscription_count;
};

Expand All @@ -131,7 +131,7 @@ static inline struct list_head *tipc_nodes(struct net *net)
return &tipc_net(net)->node_list;
}

static inline struct tipc_server *tipc_topsrv(struct net *net)
static inline struct tipc_topsrv *tipc_topsrv(struct net *net)
{
return tipc_net(net)->topsrv;
}
Expand Down
2 changes: 1 addition & 1 deletion net/tipc/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "addr.h"
#include "group.h"
#include "bcast.h"
#include "server.h"
#include "topsrv.h"
#include "msg.h"
#include "socket.h"
#include "node.h"
Expand Down
73 changes: 40 additions & 33 deletions net/tipc/name_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,

/* Any subscriptions waiting for notification? */
list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
tipc_subscrp_report_overlap(s, publ->lower, publ->upper,
TIPC_PUBLISHED, publ->ref,
publ->node, publ->scope,
created_subseq);
tipc_sub_report_overlap(s, publ->lower, publ->upper,
TIPC_PUBLISHED, publ->ref,
publ->node, publ->scope,
created_subseq);
}
return publ;
}
Expand Down Expand Up @@ -397,10 +397,9 @@ static struct publication *tipc_nameseq_remove_publ(struct net *net,

/* Notify any waiting subscriptions */
list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
tipc_subscrp_report_overlap(s, publ->lower, publ->upper,
TIPC_WITHDRAWN, publ->ref,
publ->node, publ->scope,
removed_subseq);
tipc_sub_report_overlap(s, publ->lower, publ->upper,
TIPC_WITHDRAWN, publ->ref, publ->node,
publ->scope, removed_subseq);
}

return publ;
Expand All @@ -412,33 +411,37 @@ static struct publication *tipc_nameseq_remove_publ(struct net *net,
* sequence overlapping with the requested sequence
*/
static void tipc_nameseq_subscribe(struct name_seq *nseq,
struct tipc_subscription *s,
bool status)
struct tipc_subscription *sub)
{
struct sub_seq *sseq = nseq->sseqs;
struct tipc_name_seq ns;
struct tipc_subscr *s = &sub->evt.s;
bool no_status;

tipc_subscrp_convert_seq(&s->evt.s.seq, s->swap, &ns);
ns.type = tipc_sub_read(s, seq.type);
ns.lower = tipc_sub_read(s, seq.lower);
ns.upper = tipc_sub_read(s, seq.upper);
no_status = tipc_sub_read(s, filter) & TIPC_SUB_NO_STATUS;

tipc_subscrp_get(s);
list_add(&s->nameseq_list, &nseq->subscriptions);
tipc_sub_get(sub);
list_add(&sub->nameseq_list, &nseq->subscriptions);

if (!status || !sseq)
if (no_status || !sseq)
return;

while (sseq != &nseq->sseqs[nseq->first_free]) {
if (tipc_subscrp_check_overlap(&ns, sseq->lower, sseq->upper)) {
if (tipc_sub_check_overlap(&ns, sseq->lower, sseq->upper)) {
struct publication *crs;
struct name_info *info = sseq->info;
int must_report = 1;

list_for_each_entry(crs, &info->zone_list, zone_list) {
tipc_subscrp_report_overlap(s, sseq->lower,
sseq->upper,
TIPC_PUBLISHED,
crs->ref, crs->node,
crs->scope,
must_report);
tipc_sub_report_overlap(sub, sseq->lower,
sseq->upper,
TIPC_PUBLISHED,
crs->ref, crs->node,
crs->scope,
must_report);
must_report = 0;
}
}
Expand Down Expand Up @@ -808,24 +811,27 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
/**
* tipc_nametbl_subscribe - add a subscription object to the name table
*/
void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status)
void tipc_nametbl_subscribe(struct tipc_subscription *sub)
{
struct tipc_net *tn = net_generic(s->net, tipc_net_id);
u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap);
struct tipc_net *tn = tipc_net(sub->net);
struct tipc_subscr *s = &sub->evt.s;
u32 type = tipc_sub_read(s, seq.type);
int index = hash(type);
struct name_seq *seq;
struct tipc_name_seq ns;

spin_lock_bh(&tn->nametbl_lock);
seq = nametbl_find_seq(s->net, type);
seq = nametbl_find_seq(sub->net, type);
if (!seq)
seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
if (seq) {
spin_lock_bh(&seq->lock);
tipc_nameseq_subscribe(seq, s, status);
tipc_nameseq_subscribe(seq, sub);
spin_unlock_bh(&seq->lock);
} else {
tipc_subscrp_convert_seq(&s->evt.s.seq, s->swap, &ns);
ns.type = tipc_sub_read(s, seq.type);
ns.lower = tipc_sub_read(s, seq.lower);
ns.upper = tipc_sub_read(s, seq.upper);
pr_warn("Failed to create subscription for {%u,%u,%u}\n",
ns.type, ns.lower, ns.upper);
}
Expand All @@ -835,18 +841,19 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status)
/**
* tipc_nametbl_unsubscribe - remove a subscription object from name table
*/
void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
void tipc_nametbl_unsubscribe(struct tipc_subscription *sub)
{
struct tipc_net *tn = net_generic(s->net, tipc_net_id);
struct tipc_subscr *s = &sub->evt.s;
struct tipc_net *tn = tipc_net(sub->net);
struct name_seq *seq;
u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap);
u32 type = tipc_sub_read(s, seq.type);

spin_lock_bh(&tn->nametbl_lock);
seq = nametbl_find_seq(s->net, type);
seq = nametbl_find_seq(sub->net, type);
if (seq != NULL) {
spin_lock_bh(&seq->lock);
list_del_init(&s->nameseq_list);
tipc_subscrp_put(s);
list_del_init(&sub->nameseq_list);
tipc_sub_put(sub);
if (!seq->first_free && list_empty(&seq->subscriptions)) {
hlist_del_init_rcu(&seq->ns_list);
kfree(seq->sseqs);
Expand Down
2 changes: 1 addition & 1 deletion net/tipc/name_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
u32 lower, u32 node, u32 ref,
u32 key);
void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status);
void tipc_nametbl_subscribe(struct tipc_subscription *s);
void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
int tipc_nametbl_init(struct net *net);
void tipc_nametbl_stop(struct net *net);
Expand Down
Loading

0 comments on commit 65bd449

Please sign in to comment.