aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Liden <per.liden@nospam.ericsson.com>2006-01-13 16:22:22 -0500
committerPer Liden <per.liden@ericsson.com>2006-01-17 18:45:15 -0500
commit16cb4b333c9e7a00ce3b1d74ec0c9b4c2e956910 (patch)
treef7684c0b2c205719c4807f25626af2a08fe6a277
parent5f7c3ff6a2e227418d363069ff89cf9d7f01fbc1 (diff)
[TIPC] Updated link priority macros
Added macros for min/default/max link priority in tipc_config.h. Also renamed TIPC_NUM_LINK_PRI to TIPC_MEDIA_LINK_PRI since that is a more accurate description of what it is used for. Signed-off-by: Per Liden <per.liden@ericsson.com>
-rw-r--r--include/linux/tipc_config.h7
-rw-r--r--net/tipc/bcast.c4
-rw-r--r--net/tipc/bearer.c19
-rw-r--r--net/tipc/eth_media.c6
-rw-r--r--net/tipc/link.c3
5 files changed, 25 insertions, 14 deletions
diff --git a/include/linux/tipc_config.h b/include/linux/tipc_config.h
index a52c8c64a5a3..33a653913d94 100644
--- a/include/linux/tipc_config.h
+++ b/include/linux/tipc_config.h
@@ -168,10 +168,13 @@
168#define TIPC_MAX_LINK_NAME 60 /* format = Z.C.N:interface-Z.C.N:interface */ 168#define TIPC_MAX_LINK_NAME 60 /* format = Z.C.N:interface-Z.C.N:interface */
169 169
170/* 170/*
171 * Link priority limits (range from 0 to # priorities - 1) 171 * Link priority limits (min, default, max, media default)
172 */ 172 */
173 173
174#define TIPC_NUM_LINK_PRI 32 174#define TIPC_MIN_LINK_PRI 0
175#define TIPC_DEF_LINK_PRI 10
176#define TIPC_MAX_LINK_PRI 31
177#define TIPC_MEDIA_LINK_PRI (TIPC_MAX_LINK_PRI + 1)
175 178
176/* 179/*
177 * Link tolerance limits (min, default, max), in ms 180 * Link tolerance limits (min, default, max), in ms
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 9713d622efb8..af9743a52d6c 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -82,7 +82,7 @@ struct bcbearer {
82 struct bearer bearer; 82 struct bearer bearer;
83 struct media media; 83 struct media media;
84 struct bcbearer_pair bpairs[MAX_BEARERS]; 84 struct bcbearer_pair bpairs[MAX_BEARERS];
85 struct bcbearer_pair bpairs_temp[TIPC_NUM_LINK_PRI]; 85 struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1];
86}; 86};
87 87
88/** 88/**
@@ -630,7 +630,7 @@ void bcbearer_sort(void)
630 bp_curr = bcbearer->bpairs; 630 bp_curr = bcbearer->bpairs;
631 memset(bcbearer->bpairs, 0, sizeof(bcbearer->bpairs)); 631 memset(bcbearer->bpairs, 0, sizeof(bcbearer->bpairs));
632 632
633 for (pri = (TIPC_NUM_LINK_PRI - 1); pri >= 0; pri--) { 633 for (pri = TIPC_MAX_LINK_PRI; pri >= 0; pri--) {
634 634
635 if (!bp_temp[pri].primary) 635 if (!bp_temp[pri].primary)
636 continue; 636 continue;
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 3dd19fdc5a2c..02b6cf6ab7a4 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -119,7 +119,8 @@ int tipc_register_media(u32 media_type,
119 warn("Media registration error: no broadcast address supplied\n"); 119 warn("Media registration error: no broadcast address supplied\n");
120 goto exit; 120 goto exit;
121 } 121 }
122 if (bearer_priority >= TIPC_NUM_LINK_PRI) { 122 if ((bearer_priority < TIPC_MIN_LINK_PRI) &&
123 (bearer_priority > TIPC_MAX_LINK_PRI)) {
123 warn("Media registration error: priority %u\n", bearer_priority); 124 warn("Media registration error: priority %u\n", bearer_priority);
124 goto exit; 125 goto exit;
125 } 126 }
@@ -476,10 +477,15 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
476 477
477 if (tipc_mode != TIPC_NET_MODE) 478 if (tipc_mode != TIPC_NET_MODE)
478 return -ENOPROTOOPT; 479 return -ENOPROTOOPT;
480
479 if (!bearer_name_validate(name, &b_name) || 481 if (!bearer_name_validate(name, &b_name) ||
480 !addr_domain_valid(bcast_scope) || 482 !addr_domain_valid(bcast_scope) ||
481 !in_scope(bcast_scope, tipc_own_addr) || 483 !in_scope(bcast_scope, tipc_own_addr))
482 (priority > TIPC_NUM_LINK_PRI)) 484 return -EINVAL;
485
486 if ((priority < TIPC_MIN_LINK_PRI ||
487 priority > TIPC_MAX_LINK_PRI) &&
488 (priority != TIPC_MEDIA_LINK_PRI))
483 return -EINVAL; 489 return -EINVAL;
484 490
485 write_lock_bh(&net_lock); 491 write_lock_bh(&net_lock);
@@ -491,7 +497,8 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
491 warn("No media <%s>\n", b_name.media_name); 497 warn("No media <%s>\n", b_name.media_name);
492 goto failed; 498 goto failed;
493 } 499 }
494 if (priority == TIPC_NUM_LINK_PRI) 500
501 if (priority == TIPC_MEDIA_LINK_PRI)
495 priority = m_ptr->priority; 502 priority = m_ptr->priority;
496 503
497restart: 504restart:
@@ -547,8 +554,8 @@ restart:
547 } 554 }
548 b_ptr->publ.lock = SPIN_LOCK_UNLOCKED; 555 b_ptr->publ.lock = SPIN_LOCK_UNLOCKED;
549 write_unlock_bh(&net_lock); 556 write_unlock_bh(&net_lock);
550 info("Enabled bearer <%s>, discovery domain %s\n", 557 info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
551 name, addr_string_fill(addr_string, bcast_scope)); 558 name, addr_string_fill(addr_string, bcast_scope), priority);
552 return 0; 559 return 0;
553failed: 560failed:
554 write_unlock_bh(&net_lock); 561 write_unlock_bh(&net_lock);
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index 34d0462db3aa..2ab6c16280e6 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -42,9 +42,9 @@
42 42
43#define MAX_ETH_BEARERS 2 43#define MAX_ETH_BEARERS 2
44#define TIPC_PROTOCOL 0x88ca 44#define TIPC_PROTOCOL 0x88ca
45#define ETH_LINK_PRIORITY 10 45#define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI
46#define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL 46#define ETH_LINK_TOLERANCE TIPC_DEF_LINK_TOL
47 47#define ETH_LINK_WINDOW TIPC_DEF_LINK_WIN
48 48
49/** 49/**
50 * struct eth_bearer - Ethernet bearer data structure 50 * struct eth_bearer - Ethernet bearer data structure
@@ -260,7 +260,7 @@ int eth_media_start(void)
260 res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth", 260 res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
261 enable_bearer, disable_bearer, send_msg, 261 enable_bearer, disable_bearer, send_msg,
262 eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY, 262 eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY,
263 ETH_LINK_TOLERANCE, TIPC_DEF_LINK_WIN); 263 ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
264 if (res) 264 if (res)
265 return res; 265 return res;
266 266
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 7265f4be4766..d1e1ae66464a 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -2812,7 +2812,8 @@ struct sk_buff *link_cmd_config(const void *req_tlv_area, int req_tlv_space,
2812 } 2812 }
2813 break; 2813 break;
2814 case TIPC_CMD_SET_LINK_PRI: 2814 case TIPC_CMD_SET_LINK_PRI:
2815 if (new_value < TIPC_NUM_LINK_PRI) { 2815 if ((new_value >= TIPC_MIN_LINK_PRI) &&
2816 (new_value <= TIPC_MAX_LINK_PRI)) {
2816 l_ptr->priority = new_value; 2817 l_ptr->priority = new_value;
2817 link_send_proto_msg(l_ptr, STATE_MSG, 2818 link_send_proto_msg(l_ptr, STATE_MSG,
2818 0, 0, 0, new_value, 0); 2819 0, 0, 0, new_value, 0);