~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to net/bridge/br_stp_if.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
 
22
22
/* Port id is composed of priority and port number.
23
 
 * NB: least significant bits of priority are dropped to
 
23
 * NB: some bits of priority are dropped to
24
24
 *     make room for more ports.
25
25
 */
26
26
static inline port_id br_make_port_id(__u8 priority, __u16 port_no)
29
29
                | (port_no & ((1<<BR_PORT_BITS)-1));
30
30
}
31
31
 
 
32
#define BR_MAX_PORT_PRIORITY ((u16)~0 >> BR_PORT_BITS)
 
33
 
32
34
/* called under bridge lock */
33
35
void br_init_port(struct net_bridge_port *p)
34
36
{
204
206
static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1];
205
207
 
206
208
/* called under bridge lock */
207
 
void br_stp_recalculate_bridge_id(struct net_bridge *br)
 
209
bool br_stp_recalculate_bridge_id(struct net_bridge *br)
208
210
{
209
211
        const unsigned char *br_mac_zero =
210
212
                        (const unsigned char *)br_mac_zero_aligned;
213
215
 
214
216
        /* user has chosen a value so keep it */
215
217
        if (br->flags & BR_SET_MAC_ADDR)
216
 
                return;
 
218
                return false;
217
219
 
218
220
        list_for_each_entry(p, &br->port_list, list) {
219
221
                if (addr == br_mac_zero ||
222
224
 
223
225
        }
224
226
 
225
 
        if (compare_ether_addr(br->bridge_id.addr, addr))
226
 
                br_stp_change_bridge_id(br, addr);
 
227
        if (compare_ether_addr(br->bridge_id.addr, addr) == 0)
 
228
                return false;   /* no change */
 
229
 
 
230
        br_stp_change_bridge_id(br, addr);
 
231
        return true;
227
232
}
228
233
 
229
234
/* called under bridge lock */
252
257
}
253
258
 
254
259
/* called under bridge lock */
255
 
void br_stp_set_port_priority(struct net_bridge_port *p, u8 newprio)
 
260
int br_stp_set_port_priority(struct net_bridge_port *p, unsigned long newprio)
256
261
{
257
 
        port_id new_port_id = br_make_port_id(newprio, p->port_no);
258
 
 
 
262
        port_id new_port_id;
 
263
 
 
264
        if (newprio > BR_MAX_PORT_PRIORITY)
 
265
                return -ERANGE;
 
266
 
 
267
        new_port_id = br_make_port_id(newprio, p->port_no);
259
268
        if (br_is_designated_port(p))
260
269
                p->designated_port = new_port_id;
261
270
 
266
275
                br_become_designated_port(p);
267
276
                br_port_state_selection(p->br);
268
277
        }
 
278
 
 
279
        return 0;
269
280
}
270
281
 
271
282
/* called under bridge lock */
272
 
void br_stp_set_path_cost(struct net_bridge_port *p, u32 path_cost)
 
283
int br_stp_set_path_cost(struct net_bridge_port *p, unsigned long path_cost)
273
284
{
 
285
        if (path_cost < BR_MIN_PATH_COST ||
 
286
            path_cost > BR_MAX_PATH_COST)
 
287
                return -ERANGE;
 
288
 
274
289
        p->path_cost = path_cost;
275
290
        br_configuration_update(p->br);
276
291
        br_port_state_selection(p->br);
 
292
        return 0;
277
293
}
278
294
 
279
295
ssize_t br_show_bridge_id(char *buf, const struct bridge_id *id)