Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
labs
BIRD Internet Routing Daemon
Commits
830ba75e
Commit
830ba75e
authored
Dec 07, 2017
by
Ondřej Zajíček
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
1e8721e2
' into int-new
parents
46434a3c
1e8721e2
Pipeline
#27779
failed with stages
in 5 minutes and 52 seconds
Changes
15
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
676 additions
and
184 deletions
+676
-184
doc/bird.sgml
doc/bird.sgml
+84
-12
filter/filter.c
filter/filter.c
+2
-1
filter/filter.h
filter/filter.h
+1
-0
nest/config.Y
nest/config.Y
+6
-6
nest/proto.c
nest/proto.c
+50
-11
nest/protocol.h
nest/protocol.h
+10
-8
nest/route.h
nest/route.h
+2
-1
proto/babel/packets.c
proto/babel/packets.c
+16
-7
proto/bgp/bgp.c
proto/bgp/bgp.c
+32
-12
proto/bgp/bgp.h
proto/bgp/bgp.h
+1
-1
proto/bgp/packets.c
proto/bgp/packets.c
+46
-12
proto/radv/config.Y
proto/radv/config.Y
+43
-6
proto/radv/packets.c
proto/radv/packets.c
+79
-18
proto/radv/radv.c
proto/radv/radv.c
+266
-79
proto/radv/radv.h
proto/radv/radv.h
+38
-10
No files found.
doc/bird.sgml
View file @
830ba75e
...
...
@@ -1941,7 +1941,7 @@ protocol bfd [<name>] {
computation.
<tag>password "<M>text</M>"</tag>
Specifies a password used for authentication. See <ref id="
dsc
-pass"
Specifies a password used for authentication. See <ref id="
proto
-pass"
name="password"> common option for detailed description. Note that
password option <cf/algorithm/ is not available in BFD protocol. The
algorithm is selected by <cf/authentication/ option for all passwords.
...
...
@@ -3560,7 +3560,8 @@ time intervals or as an answer to a request) advertisement packets to connected
networks. These packets contain basic information about a local network (e.g. a
list of network prefixes), which allows network hosts to autoconfigure network
addresses and choose a default route. BIRD implements router behavior as defined
in <rfc id="4861"> and also the DNS extensions from <rfc id="6106">.
in <rfc id="4861">, router preferences and specific routes (<rfc id="4191">),
and DNS extensions (<rfc id="6106">).
<sect1>Configuration
<label id="radv-config">
...
...
@@ -3597,7 +3598,7 @@ definitions, prefix definitions and DNS definitions:
definitions may also be interface-specific when used inside interface
options. By default, interface uses both global and interface-specific
options, but that can be changed by <cf/rdnss local/ option.
dsc-iface
<tag><label id="radv-dnssl">dnssl { <m/options/ }</tag>
DNSSL definitions allow to specify a list of advertised DNS search
domains together with their options. Like <cf/rdnss/ above, multiple
...
...
@@ -3622,6 +3623,18 @@ dsc-iface
default router. <cf/preferred lifetime/ and <cf/valid lifetime/ could
also be configured as <cf/sensitive/ for a prefix, which would cause
autoconfigured IPs to be deprecated or even removed.
<tag><label id="radv-propagate-routes">propagate routes <m/switch/</tag>
This option controls propagation of more specific routes, as defined in
<rfc id="4191">. If enabled, all routes exported to the RAdv protocol,
with the exception of the trigger prefix, are added to advertisments as
additional options. The lifetime and preference of advertised routes can
be set individually by <cf/ra_lifetime/ and <cf/ra_preference/ route
attributes, or per interface by <cf/route lifetime/ and
<cf/route preference/ options. Default: disabled.
Note that the RFC discourages from sending more than 17 routes and
recommends the routes to be configured manually.
</descrip>
<p>Interface specific options:
...
...
@@ -3668,21 +3681,45 @@ dsc-iface
hosts. Valid values are 0-255, 0 means unspecified. Default: 64
<tag><label id="radv-iface-default-lifetime">default lifetime <m/expr/ [sensitive <m/switch/]</tag>
This option specifies the time (in seconds) how long (
after
the receipt
This option specifies the time (in seconds) how long (
since
the receipt
of RA) hosts may use the router as a default router. 0 means do not use
as a default router. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
Default: 3 * <cf/max ra interval/, <cf/sensitive/ yes.
<tag><label id="radv-iface-linger-time">linger time <m/expr/</tag>
When a prefix disappears, it is advertised for some time with 0
lifetime, to inform clients the prefix is no longer usable. This option
sets the time for how long it is advertised (in seconds). Maximum is
3600, 0 means disabled. Default: 300.
<tag><label id="radv-iface-default-preference-low">default preference low|medium|high</tag>
<tag><label id="radv-iface-default-preference">default preference low|medium|high</tag>
This option specifies the Default Router Preference value to advertise
to hosts. Default: medium.
<tag><label id="radv-iface-route-lifetime">route lifetime <m/expr/ [sensitive <m/switch/]</tag>
This option specifies the default value of advertised lifetime for
specific routes; i.e., the time (in seconds) for how long (since the
receipt of RA) hosts should consider these routes valid. A special value
0xffffffff represents infinity. The lifetime can be overriden on a per
route basis by the <ref id="rta-ra-lifetime" name="ra_lifetime"> route
attribute. Default: 3 * <cf/max ra interval/, <cf/sensitive/ no.
For the <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
If <cf/sensitive/ is enabled, even the routes with the <cf/ra_lifetime/
attribute become sensitive to the trigger.
<tag><label id="radv-iface-route-preference">route preference low|medium|high</tag>
This option specifies the default value of advertised route preference
for specific routes. The value can be overriden on a per route basis by
the <ref id="rta-ra-preference" name="ra_preference"> route attribute.
Default: medium.
<tag><label id="radv-prefix-linger-time">prefix linger time <m/expr/</tag>
When a prefix or a route disappears, it is advertised for some time with
zero lifetime, to inform clients it is no longer valid. This option
specifies the time (in seconds) for how long prefixes are advertised
that way. Default: 3 * <cf/max ra interval/.
<tag><label id="radv-route-linger-time">route linger time <m/expr/</tag>
When a prefix or a route disappears, it is advertised for some time with
zero lifetime, to inform clients it is no longer valid. This option
specifies the time (in seconds) for how long routes are advertised
that way. Default: 3 * <cf/max ra interval/.
<tag><label id="radv-iface-rdnss-local">rdnss local <m/switch/</tag>
Use only local (interface-specific) RDNSS definitions for this
interface. Otherwise, both global and local definitions are used. Could
...
...
@@ -3729,7 +3766,6 @@ dsc-iface
<cf/sensitive/ no.
</descrip>
<p>RDNSS specific options:
<descrip>
...
...
@@ -3762,12 +3798,48 @@ dsc-iface
RDNSS <cf/lifetime/ option above. Default: 3 * <cf/max ra interval/.
</descrip>
<sect1>Attributes
<label id="radv-attr">
<p>RAdv defines two route attributes:
<descrip>
<tag><label id="rta-ra-preference">enum ra_preference/</tag>
The preference of the route. The value can be <it/RA_PREF_LOW/,
<it/RA_PREF_MEDIUM/ or <it/RA_PREF_HIGH/. If the attribute is not set,
the <ref id="radv-iface-route-preference" name="route preference">
option is used.
<tag><label id="rta-ra-lifetime">int ra_lifetime/</tag>
The advertised lifetime of the route, in seconds. The special value of
0xffffffff represents infinity. If the attribute is not set, the
<ref id="radv-iface-route-lifetime" name="route lifetime">
option is used.
</descrip>
<sect1>Example
<label id="radv-exam">
<p><code>
table radv_routes; # Manually configured routes go here
protocol static {
table radv_routes;
route 2001:0DB8:4000::/48 unreachable;
route 2001:0DB8:4010::/48 unreachable;
route 2001:0DB8:4020::/48 unreachable {
ra_preference = RA_PREF_HIGH;
ra_lifetime = 3600;
};
}
protocol radv {
propagate routes yes; # Propagate the routes from the radv_routes table
table radv_routes;
export all;
interface "eth2" {
max ra interval 5; # Fast failover with more routers
managed yes; # Using DHCPv6 on eth2
...
...
filter/filter.c
View file @
830ba75e
...
...
@@ -1089,7 +1089,8 @@ interpret(struct f_inst *what)
switch
(
what
->
aux
&
EAF_TYPE_MASK
)
{
case
EAF_TYPE_INT
:
if
(
v1
.
type
!=
T_INT
)
// Enums are also ints, so allow them in.
if
(
v1
.
type
!=
T_INT
&&
(
v1
.
type
<
T_ENUM_LO
||
v1
.
type
>
T_ENUM_HI
))
runtime
(
"Setting int attribute to non-int value"
);
l
->
attrs
[
0
].
u
.
data
=
v1
.
val
.
i
;
break
;
...
...
filter/filter.h
View file @
830ba75e
...
...
@@ -147,6 +147,7 @@ void val_format(struct f_val v, buffer *buf);
#define T_ENUM_RTD 0x34
#define T_ENUM_ROA 0x35
#define T_ENUM_NETTYPE 0x36
#define T_ENUM_RA_PREFERENCE 0x37
/* new enums go here */
#define T_ENUM_EMPTY 0x3f
/* Special hack for atomic_aggr */
...
...
nest/config.Y
View file @
830ba75e
...
...
@@ -756,12 +756,12 @@ echo_size:
}
;
CF_CLI(DISABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Disable protocol]])
{ proto_apply_cmd($2, proto_cmd_disable, 1,
0
); } ;
CF_CLI(ENABLE, proto_patt, <protocol> | \"<pattern>\" | all, [[Enable protocol]])
{ proto_apply_cmd($2, proto_cmd_enable, 1,
0
); } ;
CF_CLI(RESTART, proto_patt, <protocol> | \"<pattern>\" | all, [[Restart protocol]])
{ proto_apply_cmd($2, proto_cmd_restart, 1,
0
); } ;
CF_CLI(DISABLE, proto_patt
opttext
,
(
<protocol> | \"<pattern>\" | all
) [message]
, [[Disable protocol]])
{ proto_apply_cmd($2, proto_cmd_disable, 1,
(uintptr_t) $3
); } ;
CF_CLI(ENABLE, proto_patt
opttext
,
(
<protocol> | \"<pattern>\" | all
) [message]
, [[Enable protocol]])
{ proto_apply_cmd($2, proto_cmd_enable, 1,
(uintptr_t) $3
); } ;
CF_CLI(RESTART, proto_patt
opttext
,
(
<protocol> | \"<pattern>\" | all
) [message]
, [[Restart protocol]])
{ proto_apply_cmd($2, proto_cmd_restart, 1,
(uintptr_t) $3
); } ;
CF_CLI(RELOAD, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol]])
{ proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ;
CF_CLI(RELOAD IN, proto_patt, <protocol> | \"<pattern>\" | all, [[Reload protocol (just imported routes)]])
...
...
nest/proto.c
View file @
830ba75e
...
...
@@ -980,6 +980,7 @@ proto_rethink_goal(struct proto *p)
proto_remove_channels
(
p
);
rem_node
(
&
p
->
n
);
rfree
(
p
->
event
);
mb_free
(
p
->
message
);
mb_free
(
p
);
if
(
!
nc
)
return
;
...
...
@@ -1334,6 +1335,39 @@ proto_schedule_down(struct proto *p, byte restart, byte code)
tm_start_max
(
proto_shutdown_timer
,
restart
?
250
MS
:
0
);
}
/**
* proto_set_message - set administrative message to protocol
* @p: protocol
* @msg: message
* @len: message length (-1 for NULL-terminated string)
*
* The function sets administrative message (string) related to protocol state
* change. It is called by the nest code for manual enable/disable/restart
* commands all routes to the protocol, and by protocol-specific code when the
* protocol state change is initiated by the protocol. Using NULL message clears
* the last message. The message string may be either NULL-terminated or with an
* explicit length.
*/
void
proto_set_message
(
struct
proto
*
p
,
char
*
msg
,
int
len
)
{
mb_free
(
p
->
message
);
p
->
message
=
NULL
;
if
(
!
msg
||
!
len
)
return
;
if
(
len
<
0
)
len
=
strlen
(
msg
);
if
(
!
len
)
return
;
p
->
message
=
mb_alloc
(
proto_pool
,
len
+
1
);
memcpy
(
p
->
message
,
msg
,
len
);
p
->
message
[
len
]
=
0
;
}
static
const
char
*
channel_limit_name
(
struct
channel_limit
*
l
)
...
...
@@ -1622,7 +1656,7 @@ channel_show_info(struct channel *c)
}
void
proto_cmd_show
(
struct
proto
*
p
,
uint
verbose
,
int
cnt
)
proto_cmd_show
(
struct
proto
*
p
,
uint
ptr_t
verbose
,
int
cnt
)
{
byte
buf
[
256
],
tbuf
[
TM_DATETIME_BUFFER_SIZE
];
...
...
@@ -1646,6 +1680,8 @@ proto_cmd_show(struct proto *p, uint verbose, int cnt)
{
if
(
p
->
cf
->
dsc
)
cli_msg
(
-
1006
,
" Description: %s"
,
p
->
cf
->
dsc
);
if
(
p
->
message
)
cli_msg
(
-
1006
,
" Message: %s"
,
p
->
message
);
if
(
p
->
cf
->
router_id
)
cli_msg
(
-
1006
,
" Router ID: %R"
,
p
->
cf
->
router_id
);
if
(
p
->
vrf
)
...
...
@@ -1665,7 +1701,7 @@ proto_cmd_show(struct proto *p, uint verbose, int cnt)
}
void
proto_cmd_disable
(
struct
proto
*
p
,
uint
arg
UNUSED
,
int
cnt
UNUSED
)
proto_cmd_disable
(
struct
proto
*
p
,
uint
ptr_t
arg
,
int
cnt
UNUSED
)
{
if
(
p
->
disabled
)
{
...
...
@@ -1676,12 +1712,13 @@ proto_cmd_disable(struct proto *p, uint arg UNUSED, int cnt UNUSED)
log
(
L_INFO
"Disabling protocol %s"
,
p
->
name
);
p
->
disabled
=
1
;
p
->
down_code
=
PDC_CMD_DISABLE
;
proto_set_message
(
p
,
(
char
*
)
arg
,
-
1
);
proto_rethink_goal
(
p
);
cli_msg
(
-
9
,
"%s: disabled"
,
p
->
name
);
}
void
proto_cmd_enable
(
struct
proto
*
p
,
uint
arg
UNUSED
,
int
cnt
UNUSED
)
proto_cmd_enable
(
struct
proto
*
p
,
uint
ptr_t
arg
,
int
cnt
UNUSED
)
{
if
(
!
p
->
disabled
)
{
...
...
@@ -1691,12 +1728,13 @@ proto_cmd_enable(struct proto *p, uint arg UNUSED, int cnt UNUSED)
log
(
L_INFO
"Enabling protocol %s"
,
p
->
name
);
p
->
disabled
=
0
;
proto_set_message
(
p
,
(
char
*
)
arg
,
-
1
);
proto_rethink_goal
(
p
);
cli_msg
(
-
11
,
"%s: enabled"
,
p
->
name
);
}
void
proto_cmd_restart
(
struct
proto
*
p
,
uint
arg
UNUSED
,
int
cnt
UNUSED
)
proto_cmd_restart
(
struct
proto
*
p
,
uint
ptr_t
arg
,
int
cnt
UNUSED
)
{
if
(
p
->
disabled
)
{
...
...
@@ -1707,6 +1745,7 @@ proto_cmd_restart(struct proto *p, uint arg UNUSED, int cnt UNUSED)
log
(
L_INFO
"Restarting protocol %s"
,
p
->
name
);
p
->
disabled
=
1
;
p
->
down_code
=
PDC_CMD_RESTART
;
proto_set_message
(
p
,
(
char
*
)
arg
,
-
1
);
proto_rethink_goal
(
p
);
p
->
disabled
=
0
;
proto_rethink_goal
(
p
);
...
...
@@ -1714,7 +1753,7 @@ proto_cmd_restart(struct proto *p, uint arg UNUSED, int cnt UNUSED)
}
void
proto_cmd_reload
(
struct
proto
*
p
,
uint
dir
,
int
cnt
UNUSED
)
proto_cmd_reload
(
struct
proto
*
p
,
uint
ptr_t
dir
,
int
cnt
UNUSED
)
{
struct
channel
*
c
;
...
...
@@ -1753,19 +1792,19 @@ proto_cmd_reload(struct proto *p, uint dir, int cnt UNUSED)
}
void
proto_cmd_debug
(
struct
proto
*
p
,
uint
mask
,
int
cnt
UNUSED
)
proto_cmd_debug
(
struct
proto
*
p
,
uint
ptr_t
mask
,
int
cnt
UNUSED
)
{
p
->
debug
=
mask
;
}
void
proto_cmd_mrtdump
(
struct
proto
*
p
,
uint
mask
,
int
cnt
UNUSED
)
proto_cmd_mrtdump
(
struct
proto
*
p
,
uint
ptr_t
mask
,
int
cnt
UNUSED
)
{
p
->
mrtdump
=
mask
;
}
static
void
proto_apply_cmd_symbol
(
struct
symbol
*
s
,
void
(
*
cmd
)(
struct
proto
*
,
uint
,
int
),
uint
arg
)
proto_apply_cmd_symbol
(
struct
symbol
*
s
,
void
(
*
cmd
)(
struct
proto
*
,
uint
ptr_t
,
int
),
uint
ptr_t
arg
)
{
if
(
s
->
class
!=
SYM_PROTO
)
{
...
...
@@ -1778,7 +1817,7 @@ proto_apply_cmd_symbol(struct symbol *s, void (* cmd)(struct proto *, uint, int)
}
static
void
proto_apply_cmd_patt
(
char
*
patt
,
void
(
*
cmd
)(
struct
proto
*
,
uint
,
int
),
uint
arg
)
proto_apply_cmd_patt
(
char
*
patt
,
void
(
*
cmd
)(
struct
proto
*
,
uint
ptr_t
,
int
),
uint
ptr_t
arg
)
{
struct
proto
*
p
;
int
cnt
=
0
;
...
...
@@ -1794,8 +1833,8 @@ proto_apply_cmd_patt(char *patt, void (* cmd)(struct proto *, uint, int), uint a
}
void
proto_apply_cmd
(
struct
proto_spec
ps
,
void
(
*
cmd
)(
struct
proto
*
,
uint
,
int
),
int
restricted
,
uint
arg
)
proto_apply_cmd
(
struct
proto_spec
ps
,
void
(
*
cmd
)(
struct
proto
*
,
uint
ptr_t
,
int
),
int
restricted
,
uint
ptr_t
arg
)
{
if
(
restricted
&&
cli_access_restricted
())
return
;
...
...
nest/protocol.h
View file @
830ba75e
...
...
@@ -162,6 +162,7 @@ struct proto {
u32
hash_key
;
/* Random key used for hashing of neighbors */
btime
last_state_change
;
/* Time of last state transition */
char
*
last_state_name_announced
;
/* Last state name we've announced to the user */
char
*
message
;
/* State-change message, allocated from proto_pool */
/*
* General protocol hooks:
...
...
@@ -238,6 +239,7 @@ struct proto_spec {
void
*
proto_new
(
struct
proto_config
*
);
void
*
proto_config_new
(
struct
protocol
*
,
int
class
);
void
proto_copy_config
(
struct
proto_config
*
dest
,
struct
proto_config
*
src
);
void
proto_set_message
(
struct
proto
*
p
,
char
*
msg
,
int
len
);
void
graceful_restart_recovery
(
void
);
void
graceful_restart_init
(
void
);
...
...
@@ -250,15 +252,15 @@ void channel_graceful_restart_unlock(struct channel *c);
void
channel_show_limit
(
struct
channel_limit
*
l
,
const
char
*
dsc
);
void
channel_show_info
(
struct
channel
*
c
);
void
proto_cmd_show
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_disable
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_enable
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_restart
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_reload
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_debug
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_mrtdump
(
struct
proto
*
,
uint
,
int
);
void
proto_cmd_show
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_disable
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_enable
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_restart
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_reload
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_debug
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_cmd_mrtdump
(
struct
proto
*
,
uint
ptr_t
,
int
);
void
proto_apply_cmd
(
struct
proto_spec
ps
,
void
(
*
cmd
)(
struct
proto
*
,
uint
,
int
),
int
restricted
,
uint
arg
);
void
proto_apply_cmd
(
struct
proto_spec
ps
,
void
(
*
cmd
)(
struct
proto
*
,
uint
ptr_t
,
int
),
int
restricted
,
uint
ptr_t
arg
);
struct
proto
*
proto_get_named
(
struct
symbol
*
,
struct
protocol
*
);
#define CMD_RELOAD 0
...
...
nest/route.h
View file @
830ba75e
...
...
@@ -470,7 +470,8 @@ typedef struct eattr {
#define EAP_OSPF 3
/* OSPF */
#define EAP_KRT 4
/* Kernel route attributes */
#define EAP_BABEL 5
/* Babel attributes */
#define EAP_MAX 6
#define EAP_RADV 6
/* Router advertisment attributes */
#define EAP_MAX 7
#define EA_CODE(proto,id) (((proto) << 8) | (id))
#define EA_PROTO(ea) ((ea) >> 8)
...
...
proto/babel/packets.c
View file @
830ba75e
...
...
@@ -42,7 +42,7 @@ struct babel_tlv_ack {
struct
babel_tlv_hello
{
u8
type
;
u8
length
;
u16
reserved
;
u16
flags
;
u16
seqno
;
u16
interval
;
}
PACKED
;
...
...
@@ -106,8 +106,12 @@ struct babel_tlv_seqno_request {
}
PACKED
;
#define BABEL_FLAG_DEF_PREFIX 0x80
#define BABEL_FLAG_ROUTER_ID 0x40
/* Hello flags */
#define BABEL_HF_UNICAST 0x8000
/* Update flags */
#define BABEL_UF_DEF_PREFIX 0x80
#define BABEL_UF_ROUTER_ID 0x40
struct
babel_parse_state
{
...
...
@@ -343,6 +347,11 @@ babel_read_hello(struct babel_tlv *hdr, union babel_msg *m,
struct
babel_tlv_hello
*
tlv
=
(
void
*
)
hdr
;
struct
babel_msg_hello
*
msg
=
&
m
->
hello
;
/* We currently don't support unicast Hello */
u16
flags
=
get_u16
(
&
tlv
->
flags
);
if
(
flags
&
BABEL_HF_UNICAST
)
return
PARSE_IGNORE
;
msg
->
type
=
BABEL_TLV_HELLO
;
msg
->
seqno
=
get_u16
(
&
tlv
->
seqno
);
msg
->
interval
=
get_time16
(
&
tlv
->
interval
);
...
...
@@ -606,7 +615,7 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m,
ip4_addr
prefix4
=
get_ip4
(
buf
);
net_fill_ip4
(
&
msg
->
net
,
prefix4
,
tlv
->
plen
);
if
(
tlv
->
flags
&
BABEL_F
LAG
_DEF_PREFIX
)
if
(
tlv
->
flags
&
BABEL_
U
F_DEF_PREFIX
)
{
put_ip4
(
state
->
def_ip4_prefix
,
prefix4
);
state
->
def_ip4_prefix_seen
=
1
;
...
...
@@ -631,13 +640,13 @@ babel_read_update(struct babel_tlv *hdr, union babel_msg *m,
ip6_addr
prefix6
=
get_ip6
(
buf
);
net_fill_ip6
(
&
msg
->
net
,
prefix6
,
tlv
->
plen
);
if
(
tlv
->
flags
&
BABEL_F
LAG
_DEF_PREFIX
)
if
(
tlv
->
flags
&
BABEL_
U
F_DEF_PREFIX
)
{
put_ip6
(
state
->
def_ip6_prefix
,
prefix6
);
state
->
def_ip6_prefix_seen
=
1
;
}
if
(
tlv
->
flags
&
BABEL_F
LAG
_ROUTER_ID
)
if
(
tlv
->
flags
&
BABEL_
U
F_ROUTER_ID
)
{
state
->
router_id
=
((
u64
)
_I2
(
prefix6
))
<<
32
|
_I3
(
prefix6
);
state
->
router_id_seen
=
1
;
...
...
@@ -750,7 +759,7 @@ babel_write_update(struct babel_tlv *hdr, union babel_msg *m,
else
{
put_ip6_px
(
tlv
->
addr
,
&
msg
->
net
);
tlv
->
flags
|=
BABEL_F
LAG
_DEF_PREFIX
;
tlv
->
flags
|=
BABEL_
U
F_DEF_PREFIX
;
put_ip6
(
state
->
def_ip6_prefix
,
net6_prefix
(
&
msg
->
net
));
state
->
def_ip6_pxlen
=
tlv
->
plen
;
...
...
proto/bgp/bgp.c
View file @
830ba75e
...
...
@@ -403,7 +403,7 @@ bgp_update_startup_delay(struct bgp_proto *p)
}
static
void
bgp_graceful_close_conn
(
struct
bgp_conn
*
conn
,
uint
subcode
)
bgp_graceful_close_conn
(
struct
bgp_conn
*
conn
,
uint
subcode
,
byte
*
data
,
uint
len
)
{
switch
(
conn
->
state
)
{
...
...
@@ -419,7 +419,7 @@ bgp_graceful_close_conn(struct bgp_conn *conn, uint subcode)
case
BS_OPENSENT
:
case
BS_OPENCONFIRM
:
case
BS_ESTABLISHED
:
bgp_error
(
conn
,
6
,
subcode
,
NULL
,
0
);
bgp_error
(
conn
,
6
,
subcode
,
data
,
len
);
return
;
default:
...
...
@@ -459,11 +459,11 @@ bgp_decision(void *vp)
}
void
bgp_stop
(
struct
bgp_proto
*
p
,
uint
subcode
)
bgp_stop
(
struct
bgp_proto
*
p
,
uint
subcode
,
byte
*
data
,
uint
len
)
{
proto_notify_state
(
&
p
->
p
,
PS_STOP
);
bgp_graceful_close_conn
(
&
p
->
outgoing_conn
,
subcode
);
bgp_graceful_close_conn
(
&
p
->
incoming_conn
,
subcode
);
bgp_graceful_close_conn
(
&
p
->
outgoing_conn
,
subcode
,
data
,
len
);
bgp_graceful_close_conn
(
&
p
->
incoming_conn
,
subcode
,
data
,
len
);
ev_schedule
(
p
->
event
);
}
...
...
@@ -606,7 +606,7 @@ bgp_conn_leave_established_state(struct bgp_proto *p)
// bgp_free_bucket_table(p);
if
(
p
->
p
.
proto_state
==
PS_UP
)
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
void
...
...
@@ -725,7 +725,7 @@ bgp_graceful_restart_timeout(timer *t)
struct
bgp_proto
*
p
=
t
->
data
;
BGP_TRACE
(
D_EVENTS
,
"Neighbor graceful restart timeout"
);
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
...
...
@@ -1125,7 +1125,7 @@ bgp_neigh_notify(neighbor *n)
BGP_TRACE
(
D_EVENTS
,
"Neighbor lost"
);
bgp_store_error
(
p
,
NULL
,
BE_MISC
,
BEM_NEIGHBOR_LOST
);
/* Perhaps also run bgp_update_startup_delay(p)? */
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
}
else
if
(
p
->
cf
->
check_link
&&
!
(
n
->
iface
->
flags
&
IF_LINK_UP
))
...
...
@@ -1136,7 +1136,7 @@ bgp_neigh_notify(neighbor *n)
bgp_store_error
(
p
,
NULL
,
BE_MISC
,
BEM_LINK_DOWN
);
if
(
ps
==
PS_UP
)
bgp_update_startup_delay
(
p
);
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
}
else
...
...
@@ -1161,7 +1161,7 @@ bgp_bfd_notify(struct bfd_request *req)
bgp_store_error
(
p
,
NULL
,
BE_MISC
,
BEM_BFD_DOWN
);
if
(
ps
==
PS_UP
)
bgp_update_startup_delay
(
p
);
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
}
...
...
@@ -1349,6 +1349,10 @@ bgp_shutdown(struct proto *P)
struct
bgp_proto
*
p
=
(
struct
bgp_proto
*
)
P
;
uint
subcode
=
0
;
char
*
message
=
NULL
;
byte
*
data
=
NULL
;
uint
len
=
0
;
BGP_TRACE
(
D_EVENTS
,
"Shutdown requested"
);
switch
(
P
->
down_code
)
...
...
@@ -1365,10 +1369,12 @@ bgp_shutdown(struct proto *P)
case
PDC_CMD_DISABLE
:
case
PDC_CMD_SHUTDOWN
:
subcode
=
2
;
// Errcode 6, 2 - administrative shutdown
message
=
P
->
message
;
break
;
case
PDC_CMD_RESTART
:
subcode
=
4
;
// Errcode 6, 4 - administrative reset
message
=
P
->
message
;
break
;
case
PDC_RX_LIMIT_HIT
:
...
...
@@ -1393,8 +1399,22 @@ bgp_shutdown(struct proto *P)
bgp_store_error
(
p
,
NULL
,
BE_MAN_DOWN
,
0
);
p
->
startup_delay
=
0
;
/* RFC 8203 - shutdown communication */
if
(
message
)
{
uint
msg_len
=
strlen
(
message
);
msg_len
=
MIN
(
msg_len
,
128
);
/* Buffer will be freed automatically by protocol shutdown */
data
=
mb_alloc
(
p
->
p
.
pool
,
msg_len
+
1
);
len
=
msg_len
+
1
;
data
[
0
]
=
msg_len
;
memcpy
(
data
+
1
,
message
,
msg_len
);
}
done:
bgp_stop
(
p
,
subcode
);
bgp_stop
(
p
,
subcode
,
data
,
len
);
return
p
->
p
.
proto_state
;
}
...
...
@@ -1785,7 +1805,7 @@ bgp_error(struct bgp_conn *c, uint code, uint subcode, byte *data, int len)
if
(
code
!=
6
)
{
bgp_update_startup_delay
(
p
);
bgp_stop
(
p
,
0
);
bgp_stop
(
p
,
0
,
NULL
,
0
);
}
}
...
...
proto/bgp/bgp.h
View file @
830ba75e
...
...
@@ -437,7 +437,7 @@ void bgp_graceful_restart_done(struct bgp_channel *c);
void
bgp_refresh_begin
(
struct
bgp_channel
*
c
);
void
bgp_refresh_end
(
struct
bgp_channel
*
c
);
void
bgp_store_error
(
struct
bgp_proto
*
p
,
struct
bgp_conn
*
c
,
u8
class
,
u32
code
);
void
bgp_stop
(
struct
bgp_proto
*
p
,
u
nsigned
subcode
);
void
bgp_stop
(
struct
bgp_proto
*
p
,
u
int
subcode
,
byte
*
data
,
uint
len
);
struct
rte_source
*
bgp_find_source
(
struct
bgp_proto
*
p
,
u32
path_id
);
struct
rte_source
*
bgp_get_source
(
struct
bgp_proto
*
p
,
u32
path_id
);
...
...
proto/bgp/packets.c
View file @
830ba75e
...
...
@@ -2678,38 +2678,72 @@ bgp_error_dsc(uint code, uint subcode)
return
buff
;
}
/* RFC 8203 - shutdown communication message */
static
int
bgp_handle_message
(
struct
bgp_proto
*
p
,
byte
*
data
,
uint
len
,
byte
**
bp
)
{
byte
*
msg
=
data
+
1
;
uint
msg_len
=
data
[
0
];
uint
i
;
/* Handle zero length message */
if
(
msg_len
==
0
)
return
1
;