1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

500 Commits

Author SHA1 Message Date
claudio
ddbc7ef40e Handle IMSG_SESSION_* messages immediatly when received and do not put
them on the per peer imsg queue. This is mainly for IMSG_SESSION_DOWN.
Delaying the session down can race against IMSG_SESSION_ADD which is
handled immediatly and as a result an establised connection may be
removed in the RDE because of it.
The various graceful restart imsgs need similar treatment for similar
reasons. In the end when a session is reset/closed the RDE needs to
stop all work and flush the per peer imsg queue.
With this only update and route refresh messages are handled via the
imsg queue.
OK tb@
2022-08-26 14:10:52 +00:00
claudio
47bbf013c3 More kroute_nexthop cleanup. Mainly use direct assignment instead of
memcpy(). Additionally replace a bzero() with memset() and remove to
superfluous bzero calls.
OK tb@
2022-08-10 14:17:01 +00:00
deraadt
57baab2a53 whitespace found during a read-thru; ok claudio 2022-07-28 13:11:48 +00:00
claudio
b74974d393 Remove F_DOWN, it is no longer used and reshuffle the other flags a bit
to group them a bit better.
OK tb@
2022-07-28 10:41:18 +00:00
claudio
6135bd9daa There is no need to track both F_BGPD and F_KERNEL anymore.
Remove F_KERNEL and replace the checks using the F_BGPD flag.
Also do not convert the priority in kr_tofull() instead provide
kr_priority() which does this and is used by the bgpctl imsg
commands. Also in dispatch_rtmsg_addr() convert to RTP_MINE if
the priority is equal to the configured priority.
OK tb@
2022-07-27 17:23:17 +00:00
claudio
b369529143 Refactor and rename bgpd_filternexthop() to bgpd_oknexthop()
Simplify the logic and adjust kroute_match() which makes the code
easier to understand.
OK tb@
2022-07-23 10:24:00 +00:00
claudio
aae7fbb021 Revert previous commit. The RTP_MINE checks on struct kroute_full are
not correct because kr_tofull() replaces RTP_MINE with the real priority.
Noticed because of incorrect nexthop selection.
2022-07-22 17:26:58 +00:00
claudio
df2875e41e Retire the F_KERNEL flag, it got superseded by route priority and RTP_MINE.
Only problem is when route(8) is used to modify/delete a bgpd owned route.
Exact behaviour for that is still a bit unclear but F_KERNEL does not help
in this case either. In the kr_fib_delete/change remove F_BGPD_INSERTED
in that case as a first step.
OK tb@
2022-07-22 11:17:48 +00:00
claudio
8bf72ef002 Cleanup and fix the network code.
- introduce network_free() to properly free a network struct including
  the possible rtlabel reference.
- change expand_networks() and the reload code to not only expand the
  main network config but also the network configs inside L3VPN sections.
- adjust reload logic to properly match any kind of network struct.
  Up until now rtlabel and priority network statememnts were not correctly
  reloaded.
OK tb@
2022-07-20 12:43:27 +00:00
claudio
5014683f69 Implement send side of RFC7911 ADD-PATH
This allows to send out more then one path per perfix to a neighbor that
supports add-path receive. OpenBGPD supports a few different modes to
select which paths to send:
  - all:	send all valid paths (the ones with a * in bgpctl output)
  - best:	send out only the single best path
  - ecmp:	send out paths that evaluate the same up and including
                the nexthop metric
  - as-wide-best: send out paths that evaluete the same up but not including
		  the nexthop metric
Currently ecmp and as-wide-best are the same. On top of this best, ecmp
and as-wide-best allow to include extra paths (e.g. best plus 2) and
for the multipath modes there is also a maximum (e.g. ecmp plus 2 max 4)

OK tb@
2022-07-11 17:08:21 +00:00
claudio
b1dddf4043 Introduce a decision metric (dmetric) that classifies the relation of
this prefix with respect to its previous one.

Currently the plan is to distinguish the best prefix (only one), ecmp
prefixes (currently the same as as-wide-multipath), as-wide-multipath
prefixes, valid prefixes and invalid prefixes.
This information will be used to implement add-path send but also for
ecmp support in bgpd.
OK tb@
2022-07-07 12:16:04 +00:00
claudio
59f47b925b Only have one version of send_rtmsg() which uses struct kroute_full().
Code uses struct sockaddr_storage to have enough space for ROUNDUP() in
all cases. Makes the code mostly nicer.
OK tb@
2022-06-30 20:33:14 +00:00
claudio
1114d9c29b Add support for RFC 9234 - Route Leak Prevention and Detection Using Roles
With this it is possible to send a role in the OPEN message and if that
was successful the RDE will add the new OTC attribute if necessary.
OK tb@
2022-06-27 13:26:51 +00:00
claudio
0195298dc6 Move struct kif from bgpd.h to kroute.c
The only user of struct kif was the session engine for the 'depend on'
feature. Switch the imsg exchange to a new struct session_dependon and
rename the IMSG as well.
OK tb@
2022-06-23 13:09:03 +00:00
claudio
f3f29c73d6 Replace struct kroute_node and kroute6_node with direct versions of
struct kroute and kroute6.

Rename knexthop_node to knexthop as well. Mostly mechanical but fix
at least one log format string to have the correct order of arguments.

OK tb@
2022-06-23 07:43:37 +00:00
claudio
450cf1be90 Move struct kroute and kroute6 to kroute.c and out of bgpd.h
OK tb@
2022-06-22 15:24:58 +00:00
claudio
703f44cfb3 Use struct kroute_full in bgpd_filternexthop() so this code becomes a lot
simpler.

OK tb@
2022-06-22 14:56:11 +00:00
claudio
0dee3f9de5 Use struct kroute_full instead of a union of struct kroute & kroute6.
struct kroute_full is address family independent and so more portable.
Also struct kroute and struct kroute6 will be kroute.c internal soon.
OK tb@
2022-06-22 14:48:51 +00:00
claudio
13bcf54fb3 Implement a applymask() function that works on bgpd_addr structs.
Use this function in kroute so that kroute_find and kroute6_find can switch
to use struct bgpd_addr as argument.
OK tb@
2022-06-19 10:30:09 +00:00
claudio
fa3a38bb16 Remove prefixlen2mask() uasge outside of util.c. Instead use inet4applymask().
Using inet4applymask() makes the code similar to the IPv6 version.
Also switch kroute{,6}_match() to use a struct bgpd_addr * as argument.
OK tb@
2022-06-16 15:33:05 +00:00
claudio
93662c4e0b Do not use defines from pfkeyv2.h in portable code.
Instead define our own algorithm enums for the IPsec code.
OK tb@ sthen@
2022-06-15 14:09:30 +00:00
claudio
25bccacef1 Rename F_BGPD_INSERTED to F_BGPD and use F_BGPD_INSERTED as a flag that
indicates that the route was successfully added to the FIB.

Filter out dynamic routes, like it is already done for ARP and ND routes) and
kill F_DYNAMIC.

Also remove the protect_lo() bits. Adding dummy kroute entries does no longer
prevent bad routes to hit the FIB. Also loopback IPs are checked in a few
other places to prevent bad routes to be installed into the FIB.

OK tb@
2022-06-15 10:10:03 +00:00
claudio
6ec75fbe5b Remove the rdomain / rtableid passed to some kroute functions.
kr_nexthop_add() and kr_nexthop_delete() only operate on the main table
so just pass in the right rdomain id.
kr_shutdown() and kr_dispatch_msg() don't really need the rdomain passed.
The was done for kif_remove(), since that function needs to remove connected
routes from the rdomain table. Connected routes can only exists in the
interfaces rdomain so just use kif->k.rdomain. If such routes exist that
table exists as well. If the table does not exists there are also no
connected routes to track.
OK tb@
2022-06-09 16:45:19 +00:00
claudio
86d19526ef Retire F_RTLABEL it was not used for anything.
Also cleanup some redundant if statements.
OK tb@
2022-06-07 15:57:47 +00:00
claudio
859a85633d Rework how fib_priority is handled.
Instead of passing it around all the time put the fib_priority into the
kroute state. It is only needed in send_rtmsg() in the end.
Additionally insert F_BGP_INSERTED routes with a special RTP_MINE priority.
This makes changing the fib_priority at runtime simpler because there
is no need to alter the kroute table anymore.
OK tb@ deraadt@
2022-06-05 12:43:13 +00:00
claudio
bd0e176e4a Implement a max communities filter match
When max-communities X is set on a filterrule the filter will match when
more than X communities are present in the path. In other words
max-communities 0 means no communities are allowed and max-communities 3
limits it up to 3 communities.
There is max-communities, max-ext-communities and max-large-communities
for each of the 3 community attributes. These three max checks can be used
together.
OK tb@ job@
2022-05-31 09:45:33 +00:00
claudio
f8162053bb Fix non-transitive extended community handling.
First of all the detection logic was totally wrong. Then filter out
non-transitive extended communities when received from an ebgp peer.
Also cleanup the type handling of ext-communities. Mainly to not have
to handle the transitive vs non-transitive versions the type is masked
with EXT_COMMUNITY_VALUE before doing the switch case for the various
types.
With this my test using ext-communities works.
OK tb@
2022-05-25 16:03:34 +00:00
deraadt
30afc53046 whitespaces found when I went checking for something else 2022-05-23 13:40:11 +00:00
claudio
39a6ffb4d4 Rename F_CTL_ACTIVE and F_PREF_ACTIVE to the more correct
F_CTL_BEST and F_PREF_BEST. This is used to mark the one
best path in bgpctl. When ECMP support is added then more
then one path can be active.
OK tb@
2022-03-21 10:15:34 +00:00
claudio
f07bac2a4d Remove the labelid from struct kroute_full. It was never really used.
The label is passed as a string in kroute_full.
Ok tb@
2022-03-03 11:19:41 +00:00
claudio
3c0011160b Make it possible to bind and connect to non-default ports. This is mainly
for testing. Using alternate ports does not work for session using ipsec.
OK tb@ deraadt@
2022-02-23 11:20:35 +00:00
claudio
39386878d9 Switch from u_intX_t types to stdint.h uintX_t. Mostly mechanical with
a few reindents.
OK florian@ tb@
2022-02-06 09:51:19 +00:00
claudio
fc51cb501d Implement roa-set data expiry. Every prefix in a roa-set can specify an
optional expires timestamp. The rtr process is walking the roa-set every
5min and removes every prefix that is expired.
With this stale RPKI data will slowly disapear and not linger around.
OK job@
2021-09-01 12:39:52 +00:00
claudio
29b527fbce Implement reception of multiple paths per BGP session. This is one
side of RFC7911 and the send portion will follow.

The path-id is extracted from the NLRI encoding an put into struct
prefix.  To do this the prefix_by_peer() function gets a path-id
argument.  If a session is not path-id enabled this argument will
be always 0. If a session is path-id enabled the value is taken
from the NLRI and can be anything, including 0. The value has no
meaning in itself. Still to make sure the decision process is able
to break a tie the path-id is checked as the last step (this is not
part of the RFC but required).

OK benno@
2021-08-09 08:15:34 +00:00
claudio
10f8f55d81 Add the needed MRT dump defines for RFC8050 support. This will be used
to dump add-path enabled systems because the NLRI format changes based
on the add-path capability and there is no way to know which format is
in use so new message types had to be added.
Also extend the ctl_show_rib structure to include the path_id.
OK benno@
2021-07-27 07:32:08 +00:00
claudio
75ddeeb961 Implement RFC 7313 enhanced route refresh. It is off by default and
can be enabled with 'announce enhanced refresh yes'
Similar to graceful restart this allows to mark routes as stale, refresh
them and the flush out routes that are still stale. Enhanced route refresh
uses a begin of rr and a end of rr message to signal the various stages.
A future enhancement would be the addition of a timeout in case the EoRR
message is not sent in reasonable time.
OK denis@ job@
2021-06-17 16:05:25 +00:00
claudio
63c2de87d6 bgpd(8) will soon support ADD-PATH (RFC7911) and enhanced route refresh
(RFC7313). This is the frist step toward this.

It adds the capability parsers for the two no capabilities, extends the
capability struct and adds the capability negotiation bits.
The route refresh message parser and generator are extended to support
the BoRR and EoRR message. Also add the new NOTIFICATION type and subtype
for the route refresh message.
2021-05-27 08:27:48 +00:00
claudio
05ebbbf6ca Introduce 'rde evaluate all' a mode to work around path hiding in IXP
route-server environments.

By default only the best path is sent to peers and if that path is filtered
then the path is hidden for that peer. On route-servers this is sometimes
not desried. For this 'rde evaluate all' will cause the evaluation process
to fall back to alternate routes and will redistribute the first non-filtered
path to the peer. This is very similar to per-peer RIBs but accomplishes
the same effect without the massive increase in memory usage. Compared to
the default mode this requires more CPU resources but it is probably less
than what per-peer RIBs would require.

'rde evaluate all' can be set and reset globally, on groups and on idividual
neighbors. It is not limited to route-server configs but route loops are
possible if not properly used.

OK benno@
2021-03-02 09:45:07 +00:00
claudio
bd9df44e20 Add RTR support to OpenBGPD. Add basic support for the protocol.
The RTR client runs in a new process where the protocol handling is done
and when new data is available all sources are merged into one ROA set
which is then loaded into the RDE. The roa-set from the config is also
handled by the new RTR engine.
Tested by and ok job@
2021-02-16 08:29:16 +00:00
claudio
aa528464aa RFC6472 discourages the use of AS_SET segements in ASPATH attributes.
The main reason is that AS_SET does not play nice with RPKI ROA.

Introduce a per neighbor and global config option
    'reject as-set yes' and 'reject as-set no'
If set to yes received UPDATES with AS_SET segements are rejected.
This is done the same way other ASPATH soft-errors are handled. The UPDATE
is marked invalid and all prefixes are treated as withdraws.
`bgpctl show rib in error` can be used to show prefixes that where denied
and treated as withdraws because of errors.

By default this feature is off.

OK benno@
2021-01-25 09:15:23 +00:00
claudio
3038d3d15e Change struct bgpd_addr VPN encoding. Instead of including two almost
equal versions put the RD and lable stack right into struct bgpd_addr.
For non-VPN addresses these extra fields are ignored. Since VPN and non-VPN
addresses encode the prefix in the same way now some code can be simplified.
In most cases a fallthrough or reuse of encoding functions is now possible.
It should also reduce the size of struct bgpd_addr a bit.
OK denis@
2021-01-18 12:15:36 +00:00
claudio
5624d0296b Use log_sockaddr() in log_addr() to print a struct bgpd_addr. This way
IPv6 scoped addresses will print correctly.
OK tb@ florian@
2021-01-04 13:40:32 +00:00
claudio
7ff9bf356d Implement IMSG_CTL_SHOW_SET to get information about roa-set, as-sets and
prefix-sets loaded into the RDE. For now only the number of prefixes or
asnumbers are shown plus the time since the last change was done to the table.
OK benno@
2020-12-30 07:29:56 +00:00
claudio
6aa533f452 In preparation for RTR support change the representation of the roa-set
in the parent to a simple RB tree based on struct roa. With this overlapping
ROAs (same prefix & source-as but different maxlen) are now merged in the RDE
when the lookup trie is constructed.
OK benno@
2020-12-29 15:30:34 +00:00
claudio
ab9b1ccdd3 BGP uses KEEPALIVE packets and the HOLD timer to detect stalled sessions.
The problem is that this timer only looks at the receive side of the TCP
session. If for some reason the send side stalls the system fully depends
on the remote BGP peer to reset the session. As seen in an ever growing
OutQ and as a result important changes can get stalled and cause routing
troubles.

This change introduces a SEND HOLD timer. The timer is reset whenever the
session engine was able to write data to the TCP socket. If the send hold
timer expires bgpd was not able to send any data to that neighbor for at
least 90 seconds and therefor the session is forcefully closed with a hold
timer expired notification.

The send hold timer acts as a last resort to detect faulty peers. On an
idle session it can take a long time until this timer triggers but the
main goal here is to reset a stuck session at some point which did not
happen before.

With and OK job@
2020-12-23 13:20:47 +00:00
claudio
4bd1306696 Kill bgpd_process, nothing uses it anymore. Instead pass the process
type directly to log init. One less common in bgpd.
OK benno@
2020-11-05 11:52:59 +00:00
claudio
23676e2aa2 Refactor the filterset handling of nexthops. Instead of depending on
bgpd_process and changing the behaviour that way add a new filterset
type ACTION_SET_NEXTHOP_REF which is used when the nexthop reference
of the union is used. Adjust the RDE to convert ACTION_SET_NEXTHOP to
ACTION_SET_NEXTHOP_REF when receiving the filtersets.
OK benno@
2020-11-05 11:51:13 +00:00
deraadt
a78f83ce72 In bgpctl argument parser, re-arrange 'reason' parsing ('nei action [reason]')
to be more generic,  then change 'reload' to take take a '[reason]' also,
which will be logged by bgpd.
ok kn claudio
2020-05-10 13:38:46 +00:00
claudio
589de3c25c Store local-address by address family. This allows to configure both
an IPv4 and IPv6 local-address on a group and the neighbors bind to the
right local-address. Also implement 'no local-address' to reset a previously
set local address back to zero. This should help with IBGP and multihop
session config and hopefully reduce repetition in bgpd configs.
OK sthen@ benno@
2020-04-23 16:13:11 +00:00
claudio
dcd4a44d9f Rename copy_filterset() to filterset_copy() and move it to rde_filter.c
where functions like filterset_move() live. Also initialize the dest
TAILQ in filterset_copy() as it is done in filterset_move().
OK benno@ phessler@
2020-02-14 13:54:31 +00:00
claudio
be6ced5ee5 Move the code to figure out the alternate IP address (IPv6 addr for IPv4
sessions and vice versa) from the RDE to the SE. The SE is the right place
for this since there getsockname(2) fetches the local address and so the
alternate one can be fetched there as well.
With this the route pledge is no longer needed in the RDE and the pledge
is now just "stdio recvfd".
OK benno@
2020-02-12 10:33:56 +00:00
claudio
c84ce86d3e Implement 'max-prefix NUM out' to limit the number of announced prefixes.
This is an easy safety switch to not leak full tables to upstreams and
peers. If the limit is hit a Cease notification is sent and the session
is closed.
This implements most of https://tools.ietf.org/html/draft-sa-idr-maxprefix-00
OK job@
2020-01-24 05:44:05 +00:00
claudio
ef86330c9b Add some additional cease error subcodes as defined by iana.
OK denis@ deraadt@
2020-01-21 11:10:24 +00:00
claudio
03e83acf80 Convert the lastchange of a prefix from time(NULL) to getmonotime() which
uses CLOCK_MONOTONIC. Convert the control messages to return the relative
age of the prefix instead of the absolute age. Adjust the mrt dump code
to stil dump the route age in seconds since epoch as defined in the RFC.
With this all times in bgpd are now based on CLOCK_MONOTONIC.
OK denis@
2020-01-09 11:55:25 +00:00
claudio
1f00d07f2c Convert last_updown and last_read from time(3) to use getmonotime()
which returns clock_gettime(2) with CLOCK_MONOTONIC. While doing that
introduce last_write for symetry.
OK denis@
2020-01-09 11:51:18 +00:00
claudio
0c92f44581 struct ctl_show_rib does not need aspath_len since this information is
known through the imsg lenght.
OK benno@
2019-11-27 01:21:54 +00:00
claudio
63ce983fd6 For portable kr_init() returns an fd of -1 which now would end up in an
immediate exit of bgpd. Instead pass the fd via pointer arg.
OK benno@
2019-10-01 08:57:47 +00:00
claudio
5fefd1125a Implement F_SHORTER in the prefix lookup code for bgpctl. F_SHORTER will
match all prefixes that have a shorter prefixlen than the one in the request.
It will print all routes which cover the specified prefix.
OK job@ sthen@
2019-09-27 10:33:06 +00:00
claudio
e8068d4187 Improve RIB reload behaviour. Especially when the rtable changes or the
route evaluation is modified. In both cases the softreconfig code will
now walk the RIB and ensure that everything is in proper sync.
Additionally remove 'route-collector yes|no' from the bgpd config, instead
use 'rde rib Loc-RIB no evaluate' with the benefit that you can alter
the setting now during runtime.
Tested and OK benno@
2019-08-07 10:26:41 +00:00
claudio
965dc109d3 Cleanup config reload in the RDE. Use the bgpd_conf struct to store sets
and l3vpns instead of temporary globals. Also rework rde_reload_done to
free filters and sets earlier. The soft-reconfiguration process no longer
needs the previous filters / sets to do its work since there is a full
Adj-RIB-Out.
OK benno@
2019-08-05 08:46:55 +00:00
claudio
5d2d03040f Clean up RIB related kroute code. Introduce a way to flush a FIB table
from the RDE. Make sure that all nexthops don't get removed in the FIB
when a FIB table is removed. This should only happen for the main FIB.
Remove F_RIB_HASNOFIB which is just confusing since there is already
F_RIB_NOFIB and F_RIB_NOFIBSYNC.
OK benno@
2019-07-23 06:26:44 +00:00
claudio
e8beb5b5e2 When allocating socketpair() increase their send and receive buffers to
4 times the read size. This helps to increase the efficency of poll()
since now most of the time the read and write call can operate on full
buffers.
OK benno@ phessler@
2019-07-19 07:40:41 +00:00
claudio
9bd88f7ac2 Adjust peer id allocation a bit. Use defines for the various special
values and intervals. Mostly the same with the exception that peerself
is now id 1 and the first peer has id 2 -- was 0 and 1 before.
OK kn@, benno@
2019-06-22 05:36:40 +00:00
claudio
9909f9ada7 A bit more KNF no binary change 2019-06-17 21:17:04 +00:00
claudio
af4f8eadc6 Cleanup, remove some unneded spaces add some other where needed.
No binary change according to clang
2019-06-17 13:35:42 +00:00
claudio
e7adcfea80 Completley rewrite the community matching and handling code. All community
attributes are put into a new data structure when parsing the UPDATE.
The filter code can quickly lookup and modify this data structure.
When creating an UPDATE the data is put back into wire format.
Setups using a lot of communities benefit a lot from this.
Input and OK benno@
2019-06-17 11:02:19 +00:00
claudio
7876190c7f Switch the peer TAILQ to a RB tree indexed by the peer id. This way
getpeerbyid() gets a lot quicker at finding the peer when many peers
are configured. In my test case the difference is around 20% runtime.
OK denis@
2019-05-27 09:14:32 +00:00
claudio
aa3d0fcdd5 Add F_CTL_NEIGHBORS a flag only used in bgpctl's mrt parsing code.
OK sthen@ benno@
2019-05-23 14:10:05 +00:00
claudio
c2bef38b5c Rework the TCP md5sig and IKE handling. Move the pfkey socket to the parent
process in this process. The refreshing of the keys is done whenever the
session state is changes to state IDLE or ACTIVE. This should behave better
when reloading configs with auth changes.
OK benno@
2019-05-08 12:41:55 +00:00
claudio
a8289ec999 Adjust some comments that were misleading. Those flags are used by bgpd
but only on the request side of a bgpctl call.
2019-05-03 15:25:47 +00:00
claudio
724e7ad158 Bump SET_NAME_LEN to 128 since arouteserver produces names that are more
than 64 chars long.
2019-05-03 15:20:29 +00:00
claudio
0521032199 Extend maximum message size of the shutdown communication to 255 bytes.
See also draft-snijders-idr-rfc8203bis-01.
OK job@
2019-04-25 12:12:16 +00:00
claudio
82fc623792 Move the struct peer into bgpd_config and switch it to a TAILQ instead of
the hand-rolled list. This changes the way peers are reloaded since now
both parent and session engine are now merging the lists.
OK denis@
2019-03-31 16:57:38 +00:00
claudio
e8d21d8a5f Do a better job at cleaning up the config on shutdown. Remove bits that
were missed before (e.g. network related objects). This helps to detect
memory leaks.
Start using new_config() and free_config() in all places where bgpd_config
structure are used. This way the struct is properly initialised and cleaned
up. Introduce copy_config() to only copy the values into the other struct
leaving the pointers as they were.
Looks good to benno@
2019-03-07 07:42:36 +00:00
claudio
a27d9e3389 Convert the remote and local addresses in struct peer to be bgpd_addrs
instead of sockaddr_storage. This again helps protability and simplifies
some code. sa2addr now takes an optional pointer to return the port of
the sockaddr.
OK benno@
2019-02-27 04:31:56 +00:00
claudio
0e6216fd67 Add support for '*', local-as and neighbor-as for ext-community matching
and setting. This allows rules like:
    ext-community * * # delete any ext-community
    ext-community ovs * # delete any ext-community of specified type
    ext-community rt 1.2.3.4:*
and
    ext-community rt 65001:local-as
    ext-community rt local-as:11111

Note: Sometimes the type of the ext-community is underspecified when using
wildchars or expands.  So 'ext-community rt *' or 'ext-community soo *' will
match for any of the 3 possible types (2-byte AS, 4-byte AS and IP address).
If local-as/neighbor-as is used as an expand of as-number like
    ext-community rt local-as:11111
then bgpd will default to the 4-byte AS type to encode the community.

OK benno@
2019-02-26 10:49:15 +00:00
claudio
3eaf128596 Media and link states are highly OS dependent, to make porting easier
export the interface info in a way that does not need OS specific functions
to print it. Link state and media are now strings that are set by bgpd.
bgpctl can just print them. Move get_linkstate and get_media_descr to
kroute.c where all other system specific stuff is.
OK sthen@
2019-02-21 11:17:22 +00:00
claudio
83d69b6641 Convert some (u_)int64_t to (unsigned) long long. Makes portability a bit
nicer since it requires less casts.
sigh deraadt@
2019-02-19 09:13:23 +00:00
claudio
bc757dda55 Use (unsigned) long long instead of (u_)int64_t since that drops the
need to do casts for printf.
2019-02-18 12:35:08 +00:00
claudio
0e065d82a6 Move get_mpe_config() to kroute.c so that config.c does not depend on
system specific code.
2019-02-18 09:58:19 +00:00
claudio
255fe563d1 Do not depend on the length field of struct sockaddr instead pass the
length to the various functions needing it. Helps portability.
OK benno@
2019-02-18 09:43:57 +00:00
claudio
9954ce9bfb Move the depend on state calculation from session.c to kroute.c. This
helps making the code more portable.
OK sthen@
2019-02-15 11:38:06 +00:00
claudio
b673e165e9 mrt_timeout should just return -1 when there is no timeout set instead
of some strange maximum.  The poll loop in bgpd.c already limits the
maximum wait time so there is no need to double it.
While there switch to using time_t for the calculation.
OK phessler@
2019-02-14 13:13:33 +00:00
claudio
e69ae25e0c Revert part of last commit, this stuff is unrelated. 2019-02-14 10:38:04 +00:00
claudio
cd645aca81 Use -1 instead of the less portable INFTIM for the poll timeout.
Result is the same.
2019-02-14 10:34:54 +00:00
claudio
4e0c4e977d The definition of VPNs in bgpd was never super elegant. The 'depend on
mpeX' config was a bit redundant. Also to make it more flexible (e.g. having
more than one mpeX interface per rdomain the syntax was changed.

To make this possible especially the network distribution logic had to be
adjusted and cleaned up. This should in general make network statements
well defined and conflicts between 'network A.B.C.D/N' and e.g. 'network static'
are handled in a well defined way ('network A.B.C.D/N' has preference).

With and OK dlg@, OK denis@
2019-02-11 15:44:25 +00:00
claudio
d7a2dcd7be Implement as-override, a feature where the neighbor AS is replaced by the
local AS in AS paths. This is sometimes needed in bigger transport networks
where private AS numbers are used in multiple locations.
The implementation is done using a filterset which modifies the AS path -
somewhat inspired by the set attribute code. Setting as-override yes will add
    match from <neighbor> set { as-override }
to the start of the filter rules. Since this is filters the Adj-RIB-In still
holds the original path and so reloads changing the setting just work.
With and OK markus@
2019-02-04 18:53:10 +00:00
claudio
514180ac49 Support group descriptions in control messages that accept a neighbor
description. With this it is possible to show rib a group of peers, to show
or signal a group of peers all at once.
OK sthen@ benno@
2019-01-20 23:27:48 +00:00
claudio
9c622b1135 Don't store the mpe information in struct ktable but instead pass the
ifindex from the RDE over. This will allow to import prefixes to multiple
mpe interfaces in one rdomain.
OK dlg@
2019-01-18 23:30:45 +00:00
denis
290f96fa7b add support for IPv6 VPN routes
The kernel bits are missing as of now. With input from claudio@ and kn@

OK claudio@
2018-12-30 13:53:07 +00:00
remi
1adf61599b Check if a control socket or address is already in use befor using it.
If it is used abort startup or let a reload fail.
Sockets are now not unlinked anymore on regular shutdown.

This helps a lot when one tries to do a config check without -n.

Inputs and OK claudio@
2018-12-27 20:23:24 +00:00
claudio
fb02cdf09d bgpctl can cause bgpd to do a lot of work (e.g. dumping all of the RIB)
but then bgpctl can quickly exit and bgpd still has to do all the work.
Instead introduce a terminate imsg to stop such long running commands if
bgpctl closes the connection before the run is over.
OK benno@, sthen@, deraadt@
2018-12-22 16:12:40 +00:00
claudio
36e003c6a4 Fold ext-communities into filter_community so that bgpd can match
multiple ext-communities at the same time as well. Additionally this fixes
parsing some of the ext-community types. Now all communities are handled
by one common struct.
OK benno@ plus some input from denis@
2018-12-19 15:26:42 +00:00
claudio
a34ea9280a Refactor aspath code a bit. Move cached source_as (for origin validation)
into struct aspath and pass that struct to aspath_match().
OK denis@
2018-12-11 09:02:14 +00:00
claudio
42bf6edf08 Implement a simple ruleset optimizer. All it does is merge filter rules that
only differ in the filter sets. Since this is still rather common it is able
to reduce the number of rules by 5% on an autogenerated config.
OK job@
2018-12-06 12:38:00 +00:00
claudio
dd87f852ec Start reworking community handling. Merge standard communities and large
communities into one filter_community struct and allow it that more then
one community can be used in filter rules (currently up to 3).
Also rework the code handling bgpctl show rib commands. The special IMSG
types for the various filters are gone and the code is in general simpler.
OK job@, phessler@
2018-11-28 08:32:26 +00:00
claudio
30deac26de Remove an unneeded union wrapping the skipsteps pointer.
OK phessler@
2018-11-14 14:03:36 +00:00
denis
acea95bd80 fix error message when querying a non-existent table
OK claudio@
2018-11-10 11:19:01 +00:00
claudio
006eafffd0 Graceful BGP Session Shutdown is a real RFC, add it to the list.
OK job@, benno@
2018-11-04 14:34:00 +00:00
claudio
e1484d6488 Remove tail queues which link peer, aspath and prefix together. These
lists are no longer needed and make it possible to share rde_aspath between
peers & prefixes. Instead of the lists the rde_aspath is now reference counted.
With this struct prefix is now the central place where everything is connected
to making the RIB a bit easier to handle.
With input and OK denis@
2018-10-31 14:50:07 +00:00