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
3a055e6d
Commit
3a055e6d
authored
Mar 17, 2009
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace net->up and net->wired by a bitfield net->flags.
parent
f7e96e07
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
35 deletions
+52
-35
babel.c
babel.c
+9
-9
message.c
message.c
+15
-14
neighbour.c
neighbour.c
+3
-3
network.c
network.c
+15
-7
network.h
network.h
+10
-2
No files found.
babel.c
View file @
3a055e6d
...
...
@@ -501,7 +501,7 @@ main(int argc, char **argv)
/* Make some noise so that others notice us */
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
/* Apply jitter before we send the first message. */
usleep
(
roughly
(
10000
));
...
...
@@ -528,7 +528,7 @@ main(int argc, char **argv)
timeval_min_sec
(
&
tv
,
kernel_dump_time
);
timeval_min
(
&
tv
,
&
resend_time
);
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
timeval_min
(
&
tv
,
&
net
->
flush_timeout
);
timeval_min
(
&
tv
,
&
net
->
hello_timeout
);
...
...
@@ -587,7 +587,7 @@ main(int argc, char **argv)
}
}
else
{
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
if
(
net
->
ifindex
==
sin6
.
sin6_scope_id
)
{
parse_packet
((
unsigned
char
*
)
&
sin6
.
sin6_addr
,
net
,
...
...
@@ -676,7 +676,7 @@ main(int argc, char **argv)
}
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
if
(
timeval_compare
(
&
now
,
&
net
->
hello_timeout
)
>=
0
)
send_hello
(
net
);
...
...
@@ -699,7 +699,7 @@ main(int argc, char **argv)
}
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
if
(
net
->
flush_timeout
.
tv_sec
!=
0
)
{
if
(
timeval_compare
(
&
now
,
&
net
->
flush_timeout
)
>=
0
)
...
...
@@ -726,7 +726,7 @@ main(int argc, char **argv)
}
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
send_wildcard_retraction
(
net
);
/* Make sure that we expire quickly from our neighbours'
...
...
@@ -737,7 +737,7 @@ main(int argc, char **argv)
gettime
(
&
now
);
}
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
/* Make sure they got it. */
send_wildcard_retraction
(
net
);
...
...
@@ -798,7 +798,7 @@ main(int argc, char **argv)
fail:
FOR_ALL_NETS
(
net
)
{
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
continue
;
network_up
(
net
,
0
);
}
...
...
@@ -935,7 +935,7 @@ dump_tables(FILE *out)
neigh
->
reach
,
neighbour_rxcost
(
neigh
),
neigh
->
txcost
,
ne
igh
->
network
->
up
?
""
:
" (down)"
);
ne
t_up
(
neigh
->
network
)
?
""
:
" (down)"
);
}
for
(
i
=
0
;
i
<
numxroutes
;
i
++
)
{
fprintf
(
out
,
"%s metric %d (exported)
\n
"
,
...
...
message.c
View file @
3a055e6d
...
...
@@ -631,7 +631,7 @@ send_hello_noupdate(struct network *net, unsigned interval)
net
->
hello_seqno
=
seqno_plus
(
net
->
hello_seqno
,
1
);
delay_jitter
(
&
net
->
hello_timeout
,
net
->
hello_interval
);
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
debugf
(
"Sending hello %d (%d) to %s.
\n
"
,
...
...
@@ -667,7 +667,7 @@ flush_unicast(int dofree)
if
(
unicast_buffered
==
0
)
goto
done
;
if
(
!
unicast_neighbour
->
network
->
up
)
if
(
!
net_up
(
unicast_neighbour
->
network
)
)
goto
done
;
/* Preserve ordering of messages */
...
...
@@ -716,7 +716,7 @@ really_send_update(struct network *net,
const
unsigned
char
*
real_prefix
;
unsigned
short
flags
=
0
;
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
add_metric
=
output_filter
(
id
,
prefix
,
plen
,
net
->
ifindex
);
...
...
@@ -845,7 +845,7 @@ flushupdates(struct network *net)
net
->
update_bufsize
=
0
;
net
->
num_buffered_updates
=
0
;
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
goto
done
;
debugf
(
" (flushing %d buffered updates on %s (%d))
\n
"
,
...
...
@@ -894,7 +894,8 @@ flushupdates(struct network *net)
if
(
metric
<
INFINITY
)
satisfy_request
(
route
->
src
->
prefix
,
route
->
src
->
plen
,
seqno
,
route
->
src
->
id
,
net
);
if
(
split_horizon
&&
net
->
wired
&&
route
->
neigh
->
network
==
net
)
if
(
split_horizon
&&
(
net
->
flags
&
NET_WIRED
)
&&
route
->
neigh
->
network
==
net
)
continue
;
really_send_update
(
net
,
route
->
src
->
id
,
route
->
src
->
prefix
,
...
...
@@ -979,7 +980,7 @@ send_update(struct network *net, int urgent,
return
;
}
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
selfonly
=
...
...
@@ -1035,7 +1036,7 @@ send_wildcard_retraction(struct network *net)
return
;
}
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
start_message
(
net
,
MESSAGE_UPDATE
,
10
);
...
...
@@ -1066,7 +1067,7 @@ send_self_update(struct network *net)
if
(
net
==
NULL
)
{
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
if
(
!
n
->
up
)
if
(
!
n
et_up
(
n
)
)
continue
;
send_self_update
(
n
);
}
...
...
@@ -1090,7 +1091,7 @@ send_ihu(struct neighbour *neigh, struct network *net)
if
(
neigh
==
NULL
&&
net
==
NULL
)
{
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
if
(
n
->
up
)
if
(
n
et_up
(
n
)
)
continue
;
send_ihu
(
NULL
,
n
);
}
...
...
@@ -1111,7 +1112,7 @@ send_ihu(struct neighbour *neigh, struct network *net)
return
;
net
=
neigh
->
network
;
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
rxcost
=
neighbour_rxcost
(
neigh
);
...
...
@@ -1178,7 +1179,7 @@ send_request(struct network *net,
if
(
net
==
NULL
)
{
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
if
(
n
->
up
)
if
(
n
et_up
(
n
)
)
continue
;
send_request
(
n
,
prefix
,
plen
);
}
...
...
@@ -1188,7 +1189,7 @@ send_request(struct network *net,
/* make sure any buffered updates go out before this request. */
flushupdates
(
net
);
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
debugf
(
"sending request to %s for %s.
\n
"
,
...
...
@@ -1250,14 +1251,14 @@ send_multihop_request(struct network *net,
if
(
net
==
NULL
)
{
struct
network
*
n
;
FOR_ALL_NETS
(
n
)
{
if
(
!
n
->
up
)
if
(
!
n
et_up
(
n
)
)
continue
;
send_multihop_request
(
n
,
prefix
,
plen
,
seqno
,
id
,
hop_count
);
}
return
;
}
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
;
debugf
(
"Sending request (%d) on %s for %s.
\n
"
,
...
...
neighbour.c
View file @
3a055e6d
...
...
@@ -273,7 +273,7 @@ neighbour_rxcost(struct neighbour *neigh)
if
((
reach
&
0xFFF0
)
==
0
||
delay
>=
180000
)
{
return
INFINITY
;
}
else
if
(
neigh
->
network
->
wired
)
{
}
else
if
(
(
neigh
->
network
->
flags
&
NET_WIRED
)
)
{
/* To lose one hello is a misfortune, to lose two is carelessness. */
if
((
reach
&
0xC000
)
==
0xC000
)
return
neigh
->
network
->
cost
;
...
...
@@ -303,7 +303,7 @@ neighbour_cost(struct neighbour *neigh)
{
unsigned
a
,
b
;
if
(
!
ne
igh
->
network
->
up
)
if
(
!
ne
t_up
(
neigh
->
network
)
)
return
INFINITY
;
a
=
neighbour_txcost
(
neigh
);
...
...
@@ -315,7 +315,7 @@ neighbour_cost(struct neighbour *neigh)
if
(
b
>=
INFINITY
)
return
INFINITY
;
if
(
neigh
->
network
->
wired
||
(
a
<=
256
&&
b
<=
256
))
{
if
(
(
neigh
->
network
->
flags
&
NET_WIRED
)
||
(
a
<=
256
&&
b
<=
256
))
{
return
a
;
}
else
{
/* a = 256/alpha, b = 256/beta, where alpha and beta are the expected
...
...
network.c
View file @
3a055e6d
...
...
@@ -105,7 +105,7 @@ update_hello_interval(struct network *net)
net
->
hello_interval
=
idle_hello_interval
;
rc
=
1
;
}
}
else
if
(
net
->
wired
)
{
}
else
if
(
(
net
->
flags
&
NET_WIRED
)
)
{
if
(
net
->
hello_interval
!=
wired_hello_interval
)
{
net
->
hello_interval
=
wired_hello_interval
;
rc
=
1
;
...
...
@@ -190,10 +190,13 @@ network_up(struct network *net, int up)
int
mtu
,
rc
,
wired
;
struct
ipv6_mreq
mreq
;
if
(
up
==
net
->
up
)
if
(
(
!!
up
)
==
net_up
(
net
)
)
return
0
;
net
->
up
=
up
;
if
(
up
)
net
->
flags
|=
NET_UP
;
else
net
->
flags
&=
~
NET_UP
;
if
(
up
)
{
unsigned
char
ll
[
32
][
16
];
...
...
@@ -256,8 +259,13 @@ network_up(struct network *net, int up)
}
}
net
->
wired
=
wired
;
net
->
cost
=
wired
?
96
:
256
;
if
(
wired
)
{
net
->
flags
|=
NET_WIRED
;
net
->
cost
=
96
;
}
else
{
net
->
flags
&=
~
NET_WIRED
;
net
->
cost
=
256
;
}
update_hello_interval
(
net
);
memset
(
&
mreq
,
0
,
sizeof
(
mreq
));
...
...
@@ -334,7 +342,7 @@ network_ll_address(struct network *net, const unsigned char *address)
{
int
i
;
if
(
!
net
->
up
)
if
(
!
net
_up
(
net
)
)
return
0
;
for
(
i
=
0
;
i
<
net
->
numll
;
i
++
)
...
...
@@ -364,7 +372,7 @@ check_networks(void)
rc
=
kernel_interface_operational
(
net
->
ifname
,
net
->
ifindex
);
else
rc
=
0
;
if
((
rc
>
0
)
!=
net
->
up
)
{
if
((
rc
>
0
)
!=
net
_up
(
net
)
)
{
debugf
(
"Noticed status change for %s.
\n
"
,
net
->
ifname
);
network_up
(
net
,
rc
>
0
);
}
...
...
network.h
View file @
3a055e6d
...
...
@@ -32,12 +32,14 @@ struct network_conf {
struct
network_conf
*
next
;
};
#define NET_UP (1 << 0)
#define NET_WIRED (1<<1)
struct
network
{
struct
network
*
next
;
struct
network_conf
*
conf
;
char
up
;
char
wired
;
unsigned
int
ifindex
;
unsigned
short
flags
;
unsigned
short
cost
;
struct
timeval
hello_timeout
;
struct
timeval
self_update_timeout
;
...
...
@@ -74,6 +76,12 @@ extern int numnets;
#define FOR_ALL_NETS(_net) for(_net = networks; _net; _net = _net->next)
static
inline
int
net_up
(
struct
network
*
net
)
{
return
!!
(
net
->
flags
&
NET_UP
);
}
struct
network
*
add_network
(
char
*
ifname
,
struct
network_conf
*
conf
);
int
network_idle
(
struct
network
*
net
);
int
update_hello_interval
(
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