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
2a831496
Commit
2a831496
authored
Feb 16, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split checking for IPv4, move it around.
parent
2382d0c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
20 deletions
+36
-20
network.c
network.c
+36
-20
No files found.
network.c
View file @
2a831496
...
...
@@ -127,6 +127,37 @@ update_jitter(struct network *net, int urgent)
return
(
interval
/
2
+
random
()
%
interval
);
}
static
int
check_network_ipv4
(
struct
network
*
net
)
{
unsigned
char
ipv4
[
4
];
int
rc
;
if
(
net
->
ifindex
>
0
)
rc
=
kernel_interface_ipv4
(
net
->
ifname
,
net
->
ifindex
,
ipv4
);
else
rc
=
0
;
if
(
rc
>
0
)
{
if
(
!
net
->
ipv4
||
memcmp
(
ipv4
,
net
->
ipv4
,
4
)
!=
0
)
{
debugf
(
"Noticed IPv4 change for %s.
\n
"
,
net
->
ifname
);
if
(
!
net
->
ipv4
)
net
->
ipv4
=
malloc
(
4
);
if
(
net
->
ipv4
)
memcpy
(
net
->
ipv4
,
ipv4
,
4
);
return
1
;
}
}
else
{
debugf
(
"Noticed IPv4 change for %s.
\n
"
,
net
->
ifname
);
if
(
net
->
ipv4
)
{
free
(
net
->
ipv4
);
net
->
ipv4
=
NULL
;
return
1
;
}
}
return
0
;
}
int
network_up
(
struct
network
*
net
,
int
up
)
{
...
...
@@ -220,6 +251,8 @@ network_up(struct network *net, int up)
}
}
check_network_ipv4
(
net
);
if
(
!
up
)
flush_network_routes
(
net
);
...
...
@@ -230,28 +263,8 @@ void
check_networks
(
void
)
{
int
i
,
rc
,
ifindex
,
changed
=
0
,
ifindex_changed
=
0
;
unsigned
char
ipv4
[
4
];
for
(
i
=
0
;
i
<
numnets
;
i
++
)
{
rc
=
kernel_interface_ipv4
(
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
,
ipv4
);
if
(
rc
>
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
)
nets
[
i
].
ipv4
=
malloc
(
4
);
if
(
nets
[
i
].
ipv4
)
memcpy
(
nets
[
i
].
ipv4
,
ipv4
,
4
);
changed
=
1
;
}
}
else
{
debugf
(
"Noticed IPv4 change for %s.
\n
"
,
nets
[
i
].
ifname
);
if
(
nets
[
i
].
ipv4
)
{
free
(
nets
[
i
].
ipv4
);
nets
[
i
].
ipv4
=
NULL
;
changed
=
1
;
}
}
ifindex
=
if_nametoindex
(
nets
[
i
].
ifname
);
if
(
ifindex
!=
nets
[
i
].
ifindex
)
{
debugf
(
"Noticed ifindex change for %s.
\n
"
,
nets
[
i
].
ifname
);
...
...
@@ -272,8 +285,11 @@ check_networks(void)
send_request
(
&
nets
[
i
],
NULL
,
0
,
0
,
0
,
0
);
changed
=
1
;
}
check_network_ipv4
(
&
nets
[
i
]);
}
if
(
changed
)
send_update
(
NULL
,
0
,
NULL
,
0
);
...
...
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