diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-10-07 09:54:44 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-12-27 11:13:06 -0500 |
commit | 6c349210101352103d9055636845155bc801ae9b (patch) | |
tree | 530ca1ca9b5fa3bb8092b80a6f875e3a14c5f977 /net/tipc/bearer.c | |
parent | a31abe8daee5dd618aecb1484dbe9bf68c5c8a4a (diff) |
tipc: Streamline media registration error checking
Simplifies error handling performed during media registration, since
TIPC no longer supports the dynamic addition of new media types that
are potentially error-prone. These simplifications include the following:
1) No longer check for premature registration of a new media type.
2) No longer check for negative link priority values (which was pointless
since such values are unsigned, and could cause a compiler warning).
3) No longer generate a warning describing the exact cause of any
registration failure (just warns that overall registration failed).
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r-- | net/tipc/bearer.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 9012a3695b8a..f908b804a968 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -106,48 +106,27 @@ int tipc_register_media(struct media *m_ptr) | |||
106 | 106 | ||
107 | write_lock_bh(&tipc_net_lock); | 107 | write_lock_bh(&tipc_net_lock); |
108 | 108 | ||
109 | if (tipc_mode != TIPC_NET_MODE) { | 109 | if (!media_name_valid(m_ptr->name)) |
110 | warn("Media <%s> rejected, not in networked mode yet\n", | ||
111 | m_ptr->name); | ||
112 | goto exit; | 110 | goto exit; |
113 | } | 111 | if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) |
114 | if (!media_name_valid(m_ptr->name)) { | ||
115 | warn("Media <%s> rejected, illegal name\n", m_ptr->name); | ||
116 | goto exit; | 112 | goto exit; |
117 | } | 113 | if (m_ptr->priority > TIPC_MAX_LINK_PRI) |
118 | if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) { | ||
119 | warn("Media <%s> rejected, illegal broadcast address\n", | ||
120 | m_ptr->name); | ||
121 | goto exit; | ||
122 | } | ||
123 | if ((m_ptr->priority < TIPC_MIN_LINK_PRI) || | ||
124 | (m_ptr->priority > TIPC_MAX_LINK_PRI)) { | ||
125 | warn("Media <%s> rejected, illegal priority (%u)\n", | ||
126 | m_ptr->name, m_ptr->priority); | ||
127 | goto exit; | 114 | goto exit; |
128 | } | ||
129 | if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || | 115 | if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) || |
130 | (m_ptr->tolerance > TIPC_MAX_LINK_TOL)) { | 116 | (m_ptr->tolerance > TIPC_MAX_LINK_TOL)) |
131 | warn("Media <%s> rejected, illegal tolerance (%u)\n", | ||
132 | m_ptr->name, m_ptr->tolerance); | ||
133 | goto exit; | 117 | goto exit; |
134 | } | 118 | if (media_count >= MAX_MEDIA) |
135 | |||
136 | if (media_count >= MAX_MEDIA) { | ||
137 | warn("Media <%s> rejected, media limit reached (%u)\n", | ||
138 | m_ptr->name, MAX_MEDIA); | ||
139 | goto exit; | 119 | goto exit; |
140 | } | 120 | if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) |
141 | if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) { | ||
142 | warn("Media <%s> rejected, already registered\n", m_ptr->name); | ||
143 | goto exit; | 121 | goto exit; |
144 | } | ||
145 | 122 | ||
146 | media_list[media_count] = m_ptr; | 123 | media_list[media_count] = m_ptr; |
147 | media_count++; | 124 | media_count++; |
148 | res = 0; | 125 | res = 0; |
149 | exit: | 126 | exit: |
150 | write_unlock_bh(&tipc_net_lock); | 127 | write_unlock_bh(&tipc_net_lock); |
128 | if (res) | ||
129 | warn("Media <%s> registration error\n", m_ptr->name); | ||
151 | return res; | 130 | return res; |
152 | } | 131 | } |
153 | 132 | ||