Skip to content

Commit

Permalink
tipc: Remove prototype code for supporting inter-cluster routing
Browse files Browse the repository at this point in the history
Eliminates routines and data structures that were intended to allow
TIPC to route messages to other clusters. Currently, TIPC supports only
networks consisting of a single cluster within a single zone, so this
code is unnecessary.

Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Allan Stephens authored and David S. Miller committed Jan 1, 2011
1 parent 08c80e9 commit 51a8e4d
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 548 deletions.
5 changes: 0 additions & 5 deletions include/linux/tipc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ struct tipc_link_create {
struct tipc_media_addr peer_addr;
char bearer_name[TIPC_MAX_BEARER_NAME];
};

struct tipc_route_info {
__u32 dest;
__u32 router;
};
#endif

/*
Expand Down
15 changes: 0 additions & 15 deletions net/tipc/addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@
#ifndef _TIPC_ADDR_H
#define _TIPC_ADDR_H

static inline u32 own_node(void)
{
return tipc_node(tipc_own_addr);
}

static inline u32 own_cluster(void)
{
return tipc_cluster(tipc_own_addr);
}

static inline u32 own_zone(void)
{
return tipc_zone(tipc_own_addr);
}

static inline int in_own_cluster(u32 addr)
{
return !((addr ^ tipc_own_addr) >> 12);
Expand Down
279 changes: 1 addition & 278 deletions net/tipc/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
#include "cluster.h"
#include "link.h"

static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
u32 lower, u32 upper);

struct tipc_node **tipc_local_nodes = NULL;
struct tipc_node_map tipc_cltr_bcast_nodes = {0,{0,}};

Expand All @@ -65,8 +62,7 @@ struct cluster *tipc_cltr_create(u32 addr)
return NULL;
}

if (in_own_cluster(addr))
tipc_local_nodes = c_ptr->nodes;
tipc_local_nodes = c_ptr->nodes;
c_ptr->highest_node = 0;

tipc_net.clusters[1] = c_ptr;
Expand Down Expand Up @@ -100,278 +96,6 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr)
c_ptr->highest_node = n_num;
}

/**
* tipc_cltr_select_router - select router to a cluster
*
* Uses deterministic and fair algorithm.
*/

u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref)
{
u32 n_num;
u32 ulim = c_ptr->highest_node;
u32 mask;
u32 tstart;

assert(!in_own_cluster(c_ptr->addr));
if (!ulim)
return 0;

/* Start entry must be random */
mask = tipc_max_nodes;
while (mask > ulim)
mask >>= 1;
tstart = ref & mask;
n_num = tstart;

/* Lookup upwards with wrap-around */
do {
if (tipc_node_is_up(c_ptr->nodes[n_num]))
break;
} while (++n_num <= ulim);
if (n_num > ulim) {
n_num = 1;
do {
if (tipc_node_is_up(c_ptr->nodes[n_num]))
break;
} while (++n_num < tstart);
if (n_num == tstart)
return 0;
}
assert(n_num <= ulim);
return tipc_node_select_router(c_ptr->nodes[n_num], ref);
}

/**
* tipc_cltr_select_node - select destination node within a remote cluster
*
* Uses deterministic and fair algorithm.
*/

struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector)
{
u32 n_num;
u32 mask = tipc_max_nodes;
u32 start_entry;

assert(!in_own_cluster(c_ptr->addr));
if (!c_ptr->highest_node)
return NULL;

/* Start entry must be random */
while (mask > c_ptr->highest_node) {
mask >>= 1;
}
start_entry = (selector & mask) ? selector & mask : 1u;
assert(start_entry <= c_ptr->highest_node);

/* Lookup upwards with wrap-around */
for (n_num = start_entry; n_num <= c_ptr->highest_node; n_num++) {
if (tipc_node_has_active_links(c_ptr->nodes[n_num]))
return c_ptr->nodes[n_num];
}
for (n_num = 1; n_num < start_entry; n_num++) {
if (tipc_node_has_active_links(c_ptr->nodes[n_num]))
return c_ptr->nodes[n_num];
}
return NULL;
}

/*
* Routing table management: See description in node.c
*/

static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest)
{
u32 size = INT_H_SIZE + data_size;
struct sk_buff *buf = tipc_buf_acquire(size);
struct tipc_msg *msg;

if (buf) {
msg = buf_msg(buf);
memset((char *)msg, 0, size);
tipc_msg_init(msg, ROUTE_DISTRIBUTOR, 0, INT_H_SIZE, dest);
}
return buf;
}

void tipc_cltr_bcast_new_route(struct cluster *c_ptr, u32 dest,
u32 lower, u32 upper)
{
struct sk_buff *buf = tipc_cltr_prepare_routing_msg(0, c_ptr->addr);
struct tipc_msg *msg;

if (buf) {
msg = buf_msg(buf);
msg_set_remote_node(msg, dest);
msg_set_type(msg, ROUTE_ADDITION);
tipc_cltr_multicast(c_ptr, buf, lower, upper);
} else {
warn("Memory squeeze: broadcast of new route failed\n");
}
}

void tipc_cltr_bcast_lost_route(struct cluster *c_ptr, u32 dest,
u32 lower, u32 upper)
{
struct sk_buff *buf = tipc_cltr_prepare_routing_msg(0, c_ptr->addr);
struct tipc_msg *msg;

if (buf) {
msg = buf_msg(buf);
msg_set_remote_node(msg, dest);
msg_set_type(msg, ROUTE_REMOVAL);
tipc_cltr_multicast(c_ptr, buf, lower, upper);
} else {
warn("Memory squeeze: broadcast of lost route failed\n");
}
}

void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest)
{
struct sk_buff *buf;
struct tipc_msg *msg;
u32 highest = c_ptr->highest_node;
u32 n_num;
int send = 0;

if (in_own_cluster(c_ptr->addr))
return;
assert(in_own_cluster(dest));
highest = c_ptr->highest_node;
buf = tipc_cltr_prepare_routing_msg(highest + 1, c_ptr->addr);
if (buf) {
msg = buf_msg(buf);
msg_set_remote_node(msg, c_ptr->addr);
msg_set_type(msg, EXT_ROUTING_TABLE);
for (n_num = 1; n_num <= highest; n_num++) {
if (c_ptr->nodes[n_num] &&
tipc_node_has_active_links(c_ptr->nodes[n_num])) {
send = 1;
msg_set_dataoctet(msg, n_num);
}
}
if (send)
tipc_link_send(buf, dest, dest);
else
buf_discard(buf);
} else {
warn("Memory squeeze: broadcast of external route failed\n");
}
}

void tipc_cltr_recv_routing_table(struct sk_buff *buf)
{
struct tipc_msg *msg = buf_msg(buf);
struct cluster *c_ptr;
struct tipc_node *n_ptr;
unchar *node_table;
u32 table_size;
u32 router;
u32 rem_node = msg_remote_node(msg);
u32 z_num;
u32 c_num;
u32 n_num;

c_ptr = tipc_cltr_find(rem_node);
if (!c_ptr) {
c_ptr = tipc_cltr_create(rem_node);
if (!c_ptr) {
buf_discard(buf);
return;
}
}

node_table = buf->data + msg_hdr_sz(msg);
table_size = msg_size(msg) - msg_hdr_sz(msg);
router = msg_prevnode(msg);
z_num = tipc_zone(rem_node);
c_num = tipc_cluster(rem_node);

switch (msg_type(msg)) {
case EXT_ROUTING_TABLE:
for (n_num = 1; n_num < table_size; n_num++) {
if (node_table[n_num]) {
u32 addr = tipc_addr(z_num, c_num, n_num);
n_ptr = c_ptr->nodes[n_num];
if (!n_ptr) {
n_ptr = tipc_node_create(addr);
}
if (n_ptr)
tipc_node_add_router(n_ptr, router);
}
}
break;
case SLAVE_ROUTING_TABLE:
assert(in_own_cluster(c_ptr->addr));
break;
case ROUTE_ADDITION:
assert(!in_own_cluster(c_ptr->addr));
n_ptr = c_ptr->nodes[tipc_node(rem_node)];
if (!n_ptr)
n_ptr = tipc_node_create(rem_node);
if (n_ptr)
tipc_node_add_router(n_ptr, router);
break;
case ROUTE_REMOVAL:
assert(!in_own_cluster(c_ptr->addr));
n_ptr = c_ptr->nodes[tipc_node(rem_node)];
if (n_ptr)
tipc_node_remove_router(n_ptr, router);
break;
default:
assert(!"Illegal routing manager message received\n");
}
buf_discard(buf);
}

void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router)
{
u32 n_num;

if (in_own_cluster(c_ptr->addr))
return;

for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) {
if (c_ptr->nodes[n_num]) {
tipc_node_remove_router(c_ptr->nodes[n_num], router);
}
}
}

/**
* tipc_cltr_multicast - multicast message to local nodes
*/

static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
u32 lower, u32 upper)
{
struct sk_buff *buf_copy;
struct tipc_node *n_ptr;
u32 n_num;
u32 tstop;

assert(lower <= upper);
assert((lower >= 1) && (lower <= tipc_max_nodes));
assert((upper >= 1) && (upper <= tipc_max_nodes));
assert(in_own_cluster(c_ptr->addr));

tstop = c_ptr->highest_node;
if (tstop > upper)
tstop = upper;
for (n_num = lower; n_num <= tstop; n_num++) {
n_ptr = c_ptr->nodes[n_num];
if (n_ptr && tipc_node_has_active_links(n_ptr)) {
buf_copy = skb_copy(buf, GFP_ATOMIC);
if (buf_copy == NULL)
break;
msg_set_destnode(buf_msg(buf_copy), n_ptr->addr);
tipc_link_send(buf_copy, n_ptr->addr, n_ptr->addr);
}
}
buf_discard(buf);
}

/**
* tipc_cltr_broadcast - broadcast message to all nodes within cluster
*/
Expand All @@ -385,7 +109,6 @@ void tipc_cltr_broadcast(struct sk_buff *buf)

if (tipc_mode == TIPC_NET_MODE) {
c_ptr = tipc_cltr_find(tipc_own_addr);
assert(in_own_cluster(c_ptr->addr)); /* For now */

/* Send to nodes */
for (n_num = 1; n_num <= c_ptr->highest_node; n_num++) {
Expand Down
8 changes: 0 additions & 8 deletions net/tipc/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,12 @@ struct cluster {
extern struct tipc_node **tipc_local_nodes;
extern struct tipc_node_map tipc_cltr_bcast_nodes;

void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router);
void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest);
struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector);
u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref);
void tipc_cltr_recv_routing_table(struct sk_buff *buf);
struct cluster *tipc_cltr_create(u32 addr);
void tipc_cltr_delete(struct cluster *c_ptr);
void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr);
void tipc_cltr_broadcast(struct sk_buff *buf);
int tipc_cltr_init(void);

void tipc_cltr_bcast_new_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi);
void tipc_cltr_bcast_lost_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi);

static inline struct cluster *tipc_cltr_find(u32 addr)
{
if (!in_own_cluster(addr))
Expand Down
Loading

0 comments on commit 51a8e4d

Please sign in to comment.