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
18d35651
Commit
18d35651
authored
Feb 15, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement handling of ifindex changes.
parent
ec7577da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
12 deletions
+41
-12
network.c
network.c
+41
-12
No files found.
network.c
View file @
18d35651
...
@@ -31,6 +31,7 @@ THE SOFTWARE.
...
@@ -31,6 +31,7 @@ THE SOFTWARE.
#include "neighbour.h"
#include "neighbour.h"
#include "message.h"
#include "message.h"
#include "route.h"
#include "route.h"
#include "filter.h"
struct
network
nets
[
MAXNETS
];
struct
network
nets
[
MAXNETS
];
int
numnets
=
0
;
int
numnets
=
0
;
...
@@ -139,16 +140,31 @@ update_jitter(struct network *net, int urgent)
...
@@ -139,16 +140,31 @@ update_jitter(struct network *net, int urgent)
return
(
interval
/
2
+
random
()
%
interval
);
return
(
interval
/
2
+
random
()
%
interval
);
}
}
static
int
network_up
(
struct
network
*
net
,
int
up
)
{
if
(
up
==
net
->
up
)
return
0
;
net
->
up
=
up
;
if
(
!
up
)
flush_network_routes
(
net
);
return
1
;
}
void
void
check_networks
(
void
)
check_networks
(
void
)
{
{
int
i
,
rc
,
changed
=
0
;
int
i
,
rc
,
ifindex
,
changed
=
0
,
ifindex_
changed
=
0
;
unsigned
char
ipv4
[
4
];
unsigned
char
ipv4
[
4
];
for
(
i
=
0
;
i
<
numnets
;
i
++
)
{
for
(
i
=
0
;
i
<
numnets
;
i
++
)
{
rc
=
kernel_interface_ipv4
(
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
,
ipv4
);
rc
=
kernel_interface_ipv4
(
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
,
ipv4
);
if
(
rc
>
0
)
{
if
(
rc
>
0
)
{
if
(
!
nets
[
i
].
ipv4
||
memcmp
(
ipv4
,
nets
[
i
].
ipv4
,
4
)
!=
0
)
{
if
(
!
nets
[
i
].
ipv4
||
memcmp
(
ipv4
,
nets
[
i
].
ipv4
,
4
)
!=
0
)
{
debugf
(
"Noticed IPv4 change for %s.
\n
"
,
nets
[
i
].
ifname
);
if
(
!
nets
[
i
].
ipv4
)
if
(
!
nets
[
i
].
ipv4
)
nets
[
i
].
ipv4
=
malloc
(
4
);
nets
[
i
].
ipv4
=
malloc
(
4
);
if
(
nets
[
i
].
ipv4
)
if
(
nets
[
i
].
ipv4
)
...
@@ -156,26 +172,39 @@ check_networks(void)
...
@@ -156,26 +172,39 @@ check_networks(void)
changed
=
1
;
changed
=
1
;
}
}
}
else
{
}
else
{
debugf
(
"Noticed IPv4 change for %s.
\n
"
,
nets
[
i
].
ifname
);
if
(
nets
[
i
].
ipv4
)
{
if
(
nets
[
i
].
ipv4
)
{
free
(
nets
[
i
].
ipv4
);
free
(
nets
[
i
].
ipv4
);
nets
[
i
].
ipv4
=
NULL
;
nets
[
i
].
ipv4
=
NULL
;
changed
=
1
;
changed
=
1
;
}
}
}
}
rc
=
kernel_interface_operational
(
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
ifindex
=
if_nametoindex
(
nets
[
i
].
ifname
);
if
(
ifindex
!=
nets
[
i
].
ifindex
)
{
debugf
(
"Noticed ifindex change for %s.
\n
"
,
nets
[
i
].
ifname
);
network_up
(
&
nets
[
i
],
0
);
nets
[
i
].
ifindex
=
ifindex
;
changed
=
1
;
ifindex_changed
=
1
;
}
if
(
nets
[
i
].
ifindex
>
0
)
rc
=
kernel_interface_operational
(
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
else
rc
=
0
;
if
((
rc
>
0
)
!=
nets
[
i
].
up
)
{
if
((
rc
>
0
)
!=
nets
[
i
].
up
)
{
debugf
(
"Noticed status change for %s.
\n
"
,
nets
[
i
].
ifname
);
debugf
(
"Noticed status change for %s.
\n
"
,
nets
[
i
].
ifname
);
nets
[
i
].
up
=
(
rc
>
0
);
network_up
(
&
nets
[
i
],
rc
>
0
);
if
(
rc
>
0
)
{
if
(
rc
>
0
)
send_self_update
(
&
nets
[
i
],
0
);
send_request
(
&
nets
[
i
],
NULL
,
0
,
0
,
0
,
0
);
send_request
(
&
nets
[
i
],
NULL
,
0
,
0
,
0
,
0
);
}
else
{
changed
=
1
;
flush_network_routes
(
&
nets
[
i
]);
}
}
if
(
changed
)
{
if
(
nets
[
i
].
up
)
send_update
(
&
nets
[
i
],
0
,
NULL
,
0
);
}
}
}
}
if
(
changed
)
send_update
(
NULL
,
0
,
NULL
,
0
);
if
(
ifindex_changed
)
renumber_filters
();
}
}
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