Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
65d7fe71
Commit
65d7fe71
authored
Jul 18, 2012
by
Tomasz Wlostowski
Committed by
Alessandro Rubini
Jul 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/[wrsw_rtud,rtu_stat]: dump age information
parent
162dcc46
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
11 deletions
+26
-11
rtu_stat.c
userspace/tools/rtu_stat.c
+9
-3
rtu.h
userspace/wrsw_rtud/rtu.h
+1
-0
rtu_fd.c
userspace/wrsw_rtud/rtu_fd.c
+14
-8
rtud_exports.c
userspace/wrsw_rtud/rtud_exports.c
+1
-0
rtud_exports.h
userspace/wrsw_rtud/rtud_exports.h
+1
-0
No files found.
userspace/tools/rtu_stat.c
View file @
65d7fe71
...
...
@@ -113,15 +113,21 @@ main()
printf
(
"RTU Filtering Database Dump: %d rules
\n
"
,
n_entries
);
printf
(
"
\n
"
);
printf
(
"MAC Dst.ports Type
\n
"
);
printf
(
"----------------------------------------------------------
\n
"
);
printf
(
"MAC Dst.ports Type
Age [s]
\n
"
);
printf
(
"----------------------------------------------------------
------------------------
\n
"
);
for
(
i
=
0
;
i
<
n_entries
;
i
++
)
printf
(
"%-25s %-22s %s (hash %03x:%x)
\n
"
,
{
printf
(
"%-25s %-22s %s (hash %03x:%x) "
,
mac_to_string
(
fd_list
[
i
].
mac
),
decode_ports
(
fd_list
[
i
].
dpm
),
fd_list
[
i
].
dynamic
?
"DYNAMIC"
:
"STATIC "
,
fd_list
[
i
].
hash
,
fd_list
[
i
].
bucket
);
if
(
fd_list
[
i
].
dynamic
)
printf
(
"%d
\n
"
,
fd_list
[
i
].
age
);
else
printf
(
"-
\n
"
);
}
printf
(
"
\n
"
);
}
userspace/wrsw_rtud/rtu.h
View file @
65d7fe71
...
...
@@ -143,6 +143,7 @@ struct filtering_entry {
int
prio_override_dst
;
// priority override (force per-MAC priority)
int
dynamic
;
int
age
;
};
/**
...
...
userspace/wrsw_rtud/rtu_fd.c
View file @
65d7fe71
...
...
@@ -212,7 +212,7 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
/* Case 1: entry already present in the hashtable */
if
(
htab_search
(
mac
,
fid
,
&
ent
))
{
TRACE
(
TRACE_INFO
,
"Entry for mac %s already found."
,
mac_to_string
(
mac
));
TRACE
_DBG
(
TRACE_INFO
,
"Entry for mac %s already found."
,
mac_to_string
(
mac
));
mask_dst
=
ent
->
port_mask_dst
|
port_mask
;
mask_src
=
ent
->
port_mask_src
|
vlan_tab
[
vid
].
port_mask
;
...
...
@@ -226,14 +226,13 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
}
else
{
int
n_buckets
;
TRACE
(
TRACE_INFO
,
"Creating new entry for mac %s."
,
mac_to_string
(
mac
));
eaddr
.
hash
=
rtu_hash
(
mac
,
fid
);
n_buckets
=
htab_count_buckets
(
eaddr
);
if
(
n_buckets
==
RTU_BUCKETS
)
{
TRACE
(
TRACE_ERROR
,
"Hash %03x has no buckets left."
,
eaddr
.
hash
);
return
-
1
;
return
-
ENOMEM
;
}
eaddr
.
bucket
=
n_buckets
;
...
...
@@ -241,7 +240,7 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
ent
=
&
rtu_htab
[
eaddr
.
hash
][
eaddr
.
bucket
];
ent
->
addr
=
eaddr
;
TRACE
(
TRACE_INFO
,
"
Mac
%s : hash %03x:%d."
,
mac_to_string
(
mac
),
eaddr
.
hash
,
eaddr
.
bucket
);
TRACE
(
TRACE_INFO
,
"
Created new entry for MAC
%s : hash %03x:%d."
,
mac_to_string
(
mac
),
eaddr
.
hash
,
eaddr
.
bucket
);
ent
->
valid
=
1
;
ent
->
fid
=
fid
;
...
...
@@ -451,15 +450,20 @@ static void rtu_fd_age_update(void)
hash
=
bit_cnt
>>
2
;
// 4 buckets per hash
bucket
=
bit_cnt
&
0x03
;
// last 2 bits
rtu_htab
[
hash
][
bucket
].
last_access_t
=
t
;
if
(
!
rtu_htab
[
hash
][
bucket
].
dynamic
)
continue
;
TRACE
(
TRACE_INFO
,
"Updated htab entry age: mac = %s, hash = %
d, bucket = %d
\n
,
t = %d"
,
"Updated htab entry age: mac = %s, hash = %
03x:%d, delta_
t = %d"
,
mac_to_string
(
rtu_htab
[
hash
][
bucket
].
mac
),
hash
,
bucket
,
t
t
-
rtu_htab
[
hash
][
bucket
].
last_access_t
);
rtu_htab
[
hash
][
bucket
].
age
=
t
-
rtu_htab
[
hash
][
bucket
].
last_access_t
;
rtu_htab
[
hash
][
bucket
].
last_access_t
=
t
;
}
}
}
...
...
@@ -529,6 +533,8 @@ static void delete_htab_entry(struct rtu_addr addr)
{
int
i
,
n_buckets
=
htab_count_buckets
(
addr
);
TRACE
(
TRACE_INFO
,
"Deleted entry for MAC %s : hash %03x:%d."
,
mac_to_string
(
rtu_htab
[
addr
.
hash
][
addr
.
bucket
].
mac
),
addr
.
hash
,
addr
.
bucket
);
memset
(
&
rtu_htab
[
addr
.
hash
][
addr
.
bucket
],
0
,
sizeof
(
struct
filtering_entry
));
if
(
addr
.
bucket
<
n_buckets
-
1
)
...
...
userspace/wrsw_rtud/rtud_exports.c
View file @
65d7fe71
...
...
@@ -67,6 +67,7 @@ int rtudexp_get_fd_list(const struct minipc_pd *pd,
list
->
list
[
i
].
dynamic
=
ent
->
dynamic
;
list
->
list
[
i
].
hash
=
ent
->
addr
.
hash
;
list
->
list
[
i
].
bucket
=
ent
->
addr
.
bucket
;
list
->
list
[
i
].
age
=
ent
->
age
;
}
list
->
num_rules
=
i
;
...
...
userspace/wrsw_rtud/rtud_exports.h
View file @
65d7fe71
...
...
@@ -41,6 +41,7 @@ typedef struct
int
dynamic
;
uint16_t
hash
;
int
bucket
;
int
age
;
}
rtudexp_fd_entry_t
;
typedef
struct
{
...
...
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