Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
b2da2b35
Commit
b2da2b35
authored
Apr 25, 2003
by
Stephen Hemminger
Committed by
Hideaki Yoshifuji
Apr 25, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BRIDGE]: Use list macros for ports.
parent
32003a7d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
77 deletions
+35
-77
net/bridge/br_forward.c
net/bridge/br_forward.c
+1
-4
net/bridge/br_if.c
net/bridge/br_if.c
+20
-28
net/bridge/br_private.h
net/bridge/br_private.h
+2
-2
net/bridge/br_stp.c
net/bridge/br_stp.c
+5
-18
net/bridge/br_stp_if.c
net/bridge/br_stp_if.c
+5
-17
net/bridge/br_stp_timer.c
net/bridge/br_stp_timer.c
+2
-8
No files found.
net/bridge/br_forward.c
View file @
b2da2b35
...
...
@@ -115,8 +115,7 @@ static void br_flood(struct net_bridge *br, struct sk_buff *skb, int clone,
prev
=
NULL
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
should_deliver
(
p
,
skb
))
{
if
(
prev
!=
NULL
)
{
struct
sk_buff
*
skb2
;
...
...
@@ -132,8 +131,6 @@ static void br_flood(struct net_bridge *br, struct sk_buff *skb, int clone,
prev
=
p
;
}
p
=
p
->
next
;
}
if
(
prev
!=
NULL
)
{
...
...
net/bridge/br_if.c
View file @
b2da2b35
...
...
@@ -39,42 +39,31 @@ static int br_initial_port_cost(struct net_device *dev)
}
/* called under BR_NETPROTO_LOCK and bridge lock */
static
int
__br_del_if
(
struct
net_bridge
*
br
,
struct
net_device
*
dev
)
static
void
del_nbp
(
struct
net_bridge_port
*
p
)
{
struct
net_bridge_port
*
p
;
struct
net_bridge_port
**
pptr
;
if
((
p
=
dev
->
br_port
)
==
NULL
)
return
-
EINVAL
;
struct
net_device
*
dev
=
p
->
dev
;
br_stp_disable_port
(
p
);
dev_set_promiscuity
(
dev
,
-
1
);
dev
->
br_port
=
NULL
;
pptr
=
&
br
->
port_list
;
while
(
*
pptr
!=
NULL
)
{
if
(
*
pptr
==
p
)
{
*
pptr
=
p
->
next
;
break
;
}
pptr
=
&
((
*
pptr
)
->
next
);
}
list_del
(
&
p
->
list
);
br_fdb_delete_by_port
(
br
,
p
);
br_fdb_delete_by_port
(
p
->
br
,
p
);
kfree
(
p
);
dev_put
(
dev
);
return
0
;
}
static
void
del_ifs
(
struct
net_bridge
*
br
)
{
struct
list_head
*
p
,
*
n
;
br_write_lock_bh
(
BR_NETPROTO_LOCK
);
write_lock
(
&
br
->
lock
);
while
(
br
->
port_list
!=
NULL
)
__br_del_if
(
br
,
br
->
port_list
->
dev
);
list_for_each_safe
(
p
,
n
,
&
br
->
port_list
)
{
del_nbp
(
list_entry
(
p
,
struct
net_bridge_port
,
list
));
}
write_unlock
(
&
br
->
lock
);
br_write_unlock_bh
(
BR_NETPROTO_LOCK
);
}
...
...
@@ -99,6 +88,7 @@ static struct net_bridge *new_nb(const char *name)
br_dev_setup
(
dev
);
br
->
lock
=
RW_LOCK_UNLOCKED
;
INIT_LIST_HEAD
(
&
br
->
port_list
);
br
->
hash_lock
=
RW_LOCK_UNLOCKED
;
br
->
bridge_id
.
prio
[
0
]
=
0x80
;
...
...
@@ -155,8 +145,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, struct net_device
br_init_port
(
p
);
p
->
state
=
BR_STATE_DISABLED
;
p
->
next
=
br
->
port_list
;
br
->
port_list
=
p
;
list_add
(
&
p
->
list
,
&
br
->
port_list
);
return
p
;
}
...
...
@@ -238,12 +227,17 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
int
br_del_if
(
struct
net_bridge
*
br
,
struct
net_device
*
dev
)
{
int
retval
;
struct
net_bridge_port
*
p
;
int
retval
=
0
;
br_write_lock_bh
(
BR_NETPROTO_LOCK
);
write_lock
(
&
br
->
lock
);
retval
=
__br_del_if
(
br
,
dev
);
if
((
p
=
dev
->
br_port
)
==
NULL
||
p
->
br
!=
br
)
retval
=
-
EINVAL
;
else
{
del_nbp
(
p
);
br_stp_recalculate_bridge_id
(
br
);
}
write_unlock
(
&
br
->
lock
);
br_write_unlock_bh
(
BR_NETPROTO_LOCK
);
...
...
@@ -270,10 +264,8 @@ void br_get_port_ifindices(struct net_bridge *br, int *ifindices)
struct
net_bridge_port
*
p
;
read_lock
(
&
br
->
lock
);
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
ifindices
[
p
->
port_no
]
=
p
->
dev
->
ifindex
;
p
=
p
->
next
;
}
read_unlock
(
&
br
->
lock
);
}
...
...
net/bridge/br_private.h
View file @
b2da2b35
...
...
@@ -55,9 +55,9 @@ struct net_bridge_fdb_entry
struct
net_bridge_port
{
struct
net_bridge_port
*
next
;
struct
net_bridge
*
br
;
struct
net_device
*
dev
;
struct
list_head
list
;
int
port_no
;
/* STP */
...
...
@@ -80,7 +80,7 @@ struct net_bridge_port
struct
net_bridge
{
rwlock_t
lock
;
struct
net_bridge_port
*
port_list
;
struct
list_head
port_list
;
struct
net_device
dev
;
struct
net_device_stats
statistics
;
rwlock_t
hash_lock
;
...
...
net/bridge/br_stp.c
View file @
b2da2b35
...
...
@@ -40,12 +40,9 @@ struct net_bridge_port *br_get_port(struct net_bridge *br, int port_no)
{
struct
net_bridge_port
*
p
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
port_no
==
port_no
)
return
p
;
p
=
p
->
next
;
}
return
NULL
;
...
...
@@ -109,12 +106,10 @@ static void br_root_selection(struct net_bridge *br)
root_port
=
0
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
br_should_become_root_port
(
p
,
root_port
))
root_port
=
p
->
port_no
;
p
=
p
->
next
;
}
br
->
root_port
=
root_port
;
...
...
@@ -241,13 +236,11 @@ static void br_designated_port_selection(struct net_bridge *br)
{
struct
net_bridge_port
*
p
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
&&
br_should_become_designated_port
(
p
))
br_become_designated_port
(
p
);
p
=
p
->
next
;
}
}
...
...
@@ -313,13 +306,10 @@ void br_config_bpdu_generation(struct net_bridge *br)
{
struct
net_bridge_port
*
p
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
&&
br_is_designated_port
(
p
))
br_transmit_config
(
p
);
p
=
p
->
next
;
}
}
...
...
@@ -391,8 +381,7 @@ void br_port_state_selection(struct net_bridge *br)
{
struct
net_bridge_port
*
p
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
)
{
if
(
p
->
port_no
==
br
->
root_port
)
{
p
->
config_pending
=
0
;
...
...
@@ -407,8 +396,6 @@ void br_port_state_selection(struct net_bridge *br)
br_make_blocking
(
p
);
}
}
p
=
p
->
next
;
}
}
...
...
net/bridge/br_stp_if.c
View file @
b2da2b35
...
...
@@ -53,12 +53,9 @@ void br_stp_enable_bridge(struct net_bridge *br)
br_timer_set
(
&
br
->
hello_timer
,
jiffies
);
br_config_bpdu_generation
(
br
);
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
dev
->
flags
&
IFF_UP
)
br_stp_enable_port
(
p
);
p
=
p
->
next
;
}
br_timer_set
(
&
br
->
gc_timer
,
jiffies
);
...
...
@@ -78,12 +75,9 @@ void br_stp_disable_bridge(struct net_bridge *br)
br_timer_clear
(
&
br
->
gc_timer
);
br_fdb_cleanup
(
br
);
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
)
br_stp_disable_port
(
p
);
p
=
p
->
next
;
}
write_unlock
(
&
br
->
lock
);
...
...
@@ -135,15 +129,13 @@ static void br_stp_change_bridge_id(struct net_bridge *br, unsigned char *addr)
memcpy
(
br
->
bridge_id
.
addr
,
addr
,
ETH_ALEN
);
memcpy
(
br
->
dev
.
dev_addr
,
addr
,
ETH_ALEN
);
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
!
memcmp
(
p
->
designated_bridge
.
addr
,
oldaddr
,
ETH_ALEN
))
memcpy
(
p
->
designated_bridge
.
addr
,
addr
,
ETH_ALEN
);
if
(
!
memcmp
(
p
->
designated_root
.
addr
,
oldaddr
,
ETH_ALEN
))
memcpy
(
p
->
designated_root
.
addr
,
addr
,
ETH_ALEN
);
p
=
p
->
next
;
}
br_configuration_update
(
br
);
...
...
@@ -162,13 +154,11 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br)
addr
=
br_mac_zero
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
addr
==
br_mac_zero
||
memcmp
(
p
->
dev
->
dev_addr
,
addr
,
ETH_ALEN
)
<
0
)
addr
=
p
->
dev
->
dev_addr
;
p
=
p
->
next
;
}
if
(
memcmp
(
br
->
bridge_id
.
addr
,
addr
,
ETH_ALEN
))
...
...
@@ -183,15 +173,13 @@ void br_stp_set_bridge_priority(struct net_bridge *br, int newprio)
wasroot
=
br_is_root_bridge
(
br
);
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
&&
br_is_designated_port
(
p
))
{
p
->
designated_bridge
.
prio
[
0
]
=
(
newprio
>>
8
)
&
0xFF
;
p
->
designated_bridge
.
prio
[
1
]
=
newprio
&
0xFF
;
}
p
=
p
->
next
;
}
br
->
bridge_id
.
prio
[
0
]
=
(
newprio
>>
8
)
&
0xFF
;
...
...
net/bridge/br_stp_timer.c
View file @
b2da2b35
...
...
@@ -32,13 +32,10 @@ static int br_is_designated_for_some_port(struct net_bridge *br)
{
struct
net_bridge_port
*
p
;
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
&&
!
memcmp
(
&
p
->
designated_bridge
,
&
br
->
bridge_id
,
8
))
return
1
;
p
=
p
->
next
;
}
return
0
;
...
...
@@ -162,12 +159,9 @@ static void br_check_timers(struct net_bridge *br)
br_topology_change_timer_expired
(
br
);
}
p
=
br
->
port_list
;
while
(
p
!=
NULL
)
{
list_for_each_entry
(
p
,
&
br
->
port_list
,
list
)
{
if
(
p
->
state
!=
BR_STATE_DISABLED
)
br_check_port_timers
(
p
);
p
=
p
->
next
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment