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
fd642a3f
Commit
fd642a3f
authored
Feb 15, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move parts of the network initialisation code to check_networks.
parent
e77bf5ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
25 deletions
+37
-25
babel.c
babel.c
+2
-1
network.c
network.c
+34
-22
network.h
network.h
+1
-2
No files found.
babel.c
View file @
fd642a3f
...
...
@@ -406,7 +406,7 @@ main(int argc, char **argv)
}
debugf
(
"Adding %s network %s (%d).
\n
"
,
rc
?
"wireless"
:
"wired"
,
*
arg
,
ifindex
);
vrc
=
add_network
(
*
arg
,
ifindex
,
mtu
,
!
rc
,
rc
?
256
:
128
);
vrc
=
add_network
(
*
arg
,
!
rc
,
rc
?
256
:
128
);
if
(
vrc
==
NULL
)
goto
fail
;
SHIFT
();
...
...
@@ -419,6 +419,7 @@ main(int argc, char **argv)
}
init_signals
();
check_networks
();
check_xroutes
();
kernel_routes_changed
=
0
;
kernel_dump_time
=
now
.
tv_sec
+
20
+
random
()
%
20
;
...
...
network.c
View file @
fd642a3f
...
...
@@ -37,40 +37,23 @@ struct network nets[MAXNETS];
int
numnets
=
0
;
struct
network
*
add_network
(
char
*
ifname
,
int
ifindex
,
int
mtu
,
int
wired
,
unsigned
int
cost
)
add_network
(
char
*
ifname
,
int
wired
,
unsigned
int
cost
)
{
void
*
p
;
unsigned
char
ipv4
[
4
];
int
rc
;
if
(
numnets
>=
MAXNETS
)
{
fprintf
(
stderr
,
"Too many networks.
\n
"
);
return
NULL
;
}
memset
(
nets
+
numnets
,
0
,
sizeof
(
struct
network
));
nets
[
numnets
].
up
=
(
kernel_interface_operational
(
ifname
,
ifindex
)
>
0
)
;
nets
[
numnets
].
ifindex
=
ifindex
;
nets
[
numnets
].
up
=
0
;
nets
[
numnets
].
ifindex
=
0
;
nets
[
numnets
].
ipv4
=
NULL
;
rc
=
kernel_interface_ipv4
(
ifname
,
ifindex
,
ipv4
);
if
(
rc
>=
0
)
{
nets
[
numnets
].
ipv4
=
malloc
(
4
);
if
(
nets
[
numnets
].
ipv4
)
memcpy
(
nets
[
numnets
].
ipv4
,
ipv4
,
4
);
}
nets
[
numnets
].
wired
=
wired
;
nets
[
numnets
].
cost
=
cost
;
nets
[
numnets
].
activity_time
=
now
.
tv_sec
;
update_hello_interval
(
&
nets
[
numnets
]);
nets
[
numnets
].
bufsize
=
mtu
-
sizeof
(
packet_header
);
nets
[
numnets
].
bufsize
=
0
;
strncpy
(
nets
[
numnets
].
ifname
,
ifname
,
IF_NAMESIZE
);
p
=
malloc
(
nets
[
numnets
].
bufsize
);
if
(
p
==
NULL
)
{
perror
(
"malloc"
);
return
NULL
;
}
nets
[
numnets
].
sendbuf
=
p
;
nets
[
numnets
].
sendbuf
=
NULL
;
nets
[
numnets
].
buffered
=
0
;
nets
[
numnets
].
bucket_time
=
now
.
tv_sec
;
nets
[
numnets
].
bucket
=
0
;
...
...
@@ -143,11 +126,40 @@ update_jitter(struct network *net, int urgent)
static
int
network_up
(
struct
network
*
net
,
int
up
)
{
int
mtu
;
if
(
up
==
net
->
up
)
return
0
;
net
->
up
=
up
;
if
(
up
)
{
mtu
=
kernel_interface_mtu
(
net
->
ifname
,
net
->
ifindex
);
if
(
mtu
<
0
)
{
fprintf
(
stderr
,
"Warning: couldn't get MTU of interface %s (%d).
\n
"
,
net
->
ifname
,
net
->
ifindex
);
mtu
=
1280
;
}
/* 40 for IPv6 header, 8 for UDP header, 12 for good luck. */
mtu
-=
60
;
if
(
net
->
sendbuf
)
free
(
net
->
sendbuf
);
net
->
bufsize
=
mtu
-
sizeof
(
packet_header
);
net
->
sendbuf
=
malloc
(
net
->
bufsize
);
if
(
net
->
sendbuf
==
NULL
)
{
fprintf
(
stderr
,
"Couldn't allocate sendbuf.
\n
"
);
net
->
bufsize
=
0
;
return
network_up
(
net
,
0
);
}
update_hello_interval
(
net
);
}
else
{
net
->
buffered
=
0
;
net
->
bufsize
=
0
;
free
(
net
->
sendbuf
);
net
->
sendbuf
=
NULL
;
}
if
(
!
up
)
flush_network_routes
(
net
);
...
...
network.h
View file @
fd642a3f
...
...
@@ -47,8 +47,7 @@ struct network {
extern
struct
network
nets
[
MAXNETS
];
extern
int
numnets
;
struct
network
*
add_network
(
char
*
ifname
,
int
ifindex
,
int
mtu
,
int
wired
,
unsigned
int
cost
);
struct
network
*
add_network
(
char
*
ifname
,
int
wired
,
unsigned
int
cost
);
int
network_idle
(
struct
network
*
net
);
int
update_hello_interval
(
struct
network
*
net
);
unsigned
int
jitter
(
struct
network
*
net
);
...
...
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