Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
ffc3c5db
Commit
ffc3c5db
authored
Jul 03, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect against duplicate neighbours.
parent
1a5b6ae8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
neighbour.c
neighbour.c
+27
-0
No files found.
neighbour.c
View file @
ffc3c5db
...
...
@@ -48,6 +48,17 @@ find_neighbour(const unsigned char *address, struct network *net)
return
NULL
;
}
struct
neighbour
*
find_neighbour_by_id
(
const
unsigned
char
*
id
,
struct
network
*
net
)
{
struct
neighbour
*
neigh
;
FOR_ALL_NEIGHBOURS
(
neigh
)
{
if
(
memcmp
(
id
,
neigh
->
id
,
16
)
==
0
&&
neigh
->
network
==
net
)
return
neigh
;
}
return
NULL
;
}
void
flush_neighbour
(
struct
neighbour
*
neigh
)
{
...
...
@@ -84,6 +95,22 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
neigh
=
NULL
;
}
}
neigh
=
find_neighbour_by_id
(
id
,
net
);
if
(
neigh
)
{
if
((
neigh
->
reach
&
0xE000
)
==
0
)
{
/* The other neighbour is probably obsolete. */
flush_neighbour
(
neigh
);
neigh
=
NULL
;
}
else
{
fprintf
(
stderr
,
"Duplicate neighbour %s (%s and %s)!
\n
"
,
format_address
(
id
),
format_address
(
neigh
->
address
),
format_address
(
address
));
return
NULL
;
}
}
debugf
(
"Creating neighbour %s (%s).
\n
"
,
format_address
(
id
),
format_address
(
address
));
...
...
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