bird-2.0.8/0000775000175000017500000000000014025754401011357 5ustar feelafeelabird-2.0.8/ChangeLog0000664000175000017500000326025714025754401013150 0ustar feelafeelacommit 82f19ba95e421f00a8e99a866a2b8d9bbdba6cdc Author: Ondrej Zajicek (work) Date: Thu Mar 18 20:18:38 2021 +0100 NEWS and version update commit f1ffe6a23144a4b13f020194f23055ac8c20dea6 Author: Ondrej Zajicek (work) Date: Thu Mar 18 15:54:44 2021 +0100 Add new BGP tests commit 5a6e8380f89deb4fff21805a7879658d2352471a Author: Ondrej Zajicek (work) Date: Thu Mar 18 15:44:04 2021 +0100 BGP: Do not show statistics BGP statistics code was preliminary and i wanted to replace it by separate 'show X stats' command. The patch hides the preliminary output in 'show protocols all' so it is not part of the released version. commit 454ae3044598466ca7c50c12c6882d84ea545afa Author: Ondrej Zajicek (work) Date: Wed Mar 17 17:24:00 2021 +0100 RPKI: Improve error handling of DNS resolver commit 0a3db4c68040473ab45b974a7f9256c277c5d31c Author: Ondrej Zajicek (work) Date: Wed Mar 17 15:56:12 2021 +0100 Minor fixes for restricted builds commit 2f981534902302cbd13cdb12d4f0c6e9a255687a Author: Ondrej Zajicek (work) Date: Tue Mar 16 20:10:00 2021 +0100 Pipe: Propagate debug flags from protocol to channels Pipe channels are kind-of implicit, so setting protocol debug flags should also set pipe debug flags. commit ae9ae864d3fec20a74ce2567536e186ce178d032 Author: Ondrej Zajicek (work) Date: Tue Mar 16 16:34:42 2021 +0100 OSPFv3: Update neighbor authentication state from Hello packets In OSPFv3, only Hello and DBDes packets contain flags specifying whether RFC 7166 authentication trailer is used. Other packets are processed based on stored authentication state in neighbor structure. Update this state with each received Hello to handle authentication change from reconfigurations. Thanks to Joakim Tjernlund and Kenth Eriksson for the bugreport. commit 94abefc00bb22b93493831798391d5d5b21f9d4c Author: Ondrej Zajicek (work) Date: Mon Mar 15 18:35:23 2021 +0100 Filter: Update 'gw' to handle IPv6 link-local addresses When a link-local address is set, use the existing iface for scope. Thanks to Marcel Krüger for the bugreport. commit 0d1a11cca3136828808b8e73f4d5e547cc787fb8 Author: Ondrej Zajicek (work) Date: Mon Mar 15 17:51:33 2021 +0100 Doc: Document automatic RPKI reload commit 6489a2450e0ab4aa63c25ac2f9be354fdbd711d2 Author: Ondrej Zajicek (work) Date: Mon Mar 15 16:16:32 2021 +0100 Doc: Document channel debug options commit 7be3af7fa662958782d2e23989d79cc2c652b6bf Author: Ondrej Zajicek (work) Date: Fri Mar 12 15:35:56 2021 +0100 Rate-limit scheduling of work-events In general, events are code handling some some condition, which is scheduled when such condition happened and executed independently from I/O loop. Work-events are a subgroup of events that are scheduled repeatedly until some (often significant) work is done (e.g. feeding routes to protocol). All scheduled events are executed during each I/O loop iteration. Separate work-events from regular events to a separate queue and rate limit their execution to a fixed number per I/O loop iteration. That should prevent excess latency when many work-events are scheduled at one time (e.g. simultaneous reload of many BGP sessions). commit 9cf3d533110313d55b60d47c134f1b7050d6be78 Author: Ondrej Zajicek (work) Date: Wed Mar 10 15:07:19 2021 +0100 Static: Implement reload hook commit 211fe69c984c657095930d2831f46896197ec65b Author: Ondrej Zajicek (work) Date: Mon Mar 8 20:45:22 2021 +0100 Nest: No automatic ROA reload on non-reloadable channels commit d3782c72b9243f4609e61edf5f29e6adeaa41e9c Author: Ondrej Zajicek (work) Date: Fri Feb 12 05:05:18 2021 +0100 Nest: Add option to control automatic RPKI reload Also, no automatic reload for BGP channels without import/export table. commit 77ce849ecf0f89455eeabefbe520c6b4888837b0 Author: Ondrej Zajicek (work) Date: Wed Feb 10 17:29:14 2021 +0100 Tests: Add missing mockup function to tests commit 714238716ef36f1dfc5721055e2ec4affd42ebfa Author: Vincent Bernat Date: Wed Feb 10 16:53:57 2021 +0100 BGP: Add support for BGP hostname capability This is an implementation of draft-walton-bgp-hostname-capability-02. It is implemented since quite some time for FRR and in datacenter, this gives a nice output to avoid using IP addresses. It is disabled by default. The hostname is retrieved from uname(2) and can be overriden with "hostname" option. The domain name is never set nor displayed. Minor changes by committer. commit 00b85905b9f5081eb2fce0ed79542085278e9f42 Author: Ondrej Zajicek (work) Date: Wed Feb 10 03:09:57 2021 +0100 Nest: Automatic channel reloads based on RPKI changes If there are roa_check() calls in channel filters, then the channel subscribes to ROA table notifications, which are sent when ROA tables are updated (subject to settle time) and trigger channel reload or refeed. commit d06a875b042b608e61b2d5a2bb594641d3e1322f Author: Ondrej Zajicek (work) Date: Sun Feb 7 19:21:42 2021 +0100 Filter: Recursive filter iteration code Add macros for recursive filter iteration that allows to examine all instructions reachable from a filter. commit 5d414309ec5a01024d4de4c4f9521f8daa5c06ff Author: Ondrej Zajicek (work) Date: Fri Jan 22 04:34:15 2021 +0100 MRT: Fix MP-BGP next hops Flag signalling that MP-BGP mode should be used got reset after first batch of routes, so remaining routes were processed without that, leading to missing MP_REACH_NLRI attribute. Thanks to Piotr Wydrych for the bugreport. commit df83f626973fda1e67769d295c47d4d246e4c1c4 Author: Ondrej Zajicek (work) Date: Thu Jan 14 01:51:09 2021 +0100 Netlink: Ignore dead routes With net.ipv4.conf.XXX.ignore_routes_with_linkdown sysctl, a user can ensure the kernel does not use a route whose target interface is down. Such route is marked with a 'dead' / RTNH_F_DEAD flag. Ignore these routes or multipath nexthops during scan. Thanks to Vincent Bernat for the original patch. commit a40ddf5c616465a93287e4ac41a98d04b4fb2b37 Author: Ondrej Zajicek (work) Date: Tue Jan 12 15:43:54 2021 +0100 Build: Fix tags generation commit d774f6d721b0e52ed800c4b9a3a482c8ce9dd074 Author: Ondrej Zajicek (work) Date: Tue Jan 12 15:37:01 2021 +0100 MRT: Fix IPv6 table dumps Add fake MP_REACH_NLRI attribute with BGP next hop when encoding MRT table dumps for IPv6 routes. That is necessary to encode next hop as NEXT_HOP attribute is not used for MP-BGP. Thanks to Santiago Aggio for the bugreport. commit 910adaa08bbd416288797505399ab47f990817e6 Author: Ondrej Zajicek (work) Date: Sun Jan 10 15:29:02 2021 +0100 BFD: Dispatch sessions also by interface index Direct BFD sessions needs to be dispatched not only by IP addresses, but also by interfaces, in order to avoid collisions between neighbors with the same IPv6 link-local addresses. Extend BFD session hash_ip key by interface index to handle that. Use 0 for multihop sessions. Thanks to Sebastian Hahn for the original patch. commit 17663b6a7c505226cfe9ccc0671611075a3dff57 Author: Ondrej Zajicek (work) Date: Thu Jan 7 05:56:34 2021 +0100 RPKI: Remove port (and SSH username) from 'Cache server' output line It was mixed-up if hostname is IPv6 address, and reporting separate values (like port) on separate lines fits better into key-value style of 'show protocols all' output. Also, the patch simplifies transport identification formatting (although it is unused now). Thanks to Alarig Le Lay for the suggestion. commit 2a8cc7259e236773f1b8423ef63305a5b8bfd652 Author: Ondrej Zajicek (work) Date: Thu Jan 7 01:56:00 2021 +0100 Kernel: Do not check templates So one can define kernel protocol template without channels. For other protocols, it is either irrelevant or already done. Thanks to Clemens Schrimpe for the bugreport. commit a141959f0729b2381a90aaa9b7ed0e41a5f9513e Author: Ondrej Zajicek (work) Date: Thu Jan 7 01:20:56 2021 +0100 Doc: Describe per-nexthop static route options Also remove description of (no longer supported) per-route 'bfd' option, and add examples of IPv6 routes with link-local nexthops. commit 7a1f4baac11cbfad82a2d09a130b3ae7bb48e9bd Author: Ondrej Zajicek (work) Date: Wed Jan 6 14:51:49 2021 +0100 Nest: remove last_tx_filter_change No longer needed after redesign of export handling. commit 4155104c90bc2f3fb680e8041e079ceb3d80a3b1 Author: Ondrej Zajicek (work) Date: Wed Jan 6 14:44:23 2021 +0100 BGP: Deprecate 'missing lladdr' option The option is not implemented since transition to 2.0 and no plan to add it. Also remove some deprecated RTS_* valus from documentation. Thanks to Sébastien Parisot for notification. commit 21f9acd2a01306af01f19914105985a8a0f9bcba Author: Ondrej Zajicek (work) Date: Wed Jan 6 05:25:59 2021 +0100 Kernel: Fix handling of krt_realm with ECMP routes For ECMP routes, RTA_FLOW attribute must be set per-nexthop, not per-route. Our corresponding krt_realm attribute is per-route. Thanks to Mikhail Petrov for the bugreport. commit 455c13dc9971ae4aa701135b5c1709d61477bdec Author: James Lu Date: Tue Dec 29 02:23:54 2020 +0100 Nest: Read Babel metric as IGP metric (Minor syntactic changes by committer) commit ea3c6c1a15ce9b93f583f96919c70f7a2fd34e98 Author: Ondrej Zajicek (work) Date: Mon Dec 28 21:19:27 2020 +0100 Static: Fix handling of 'net' attribute in per-route filters We need to define 'net' field temporarily as it may be accessed by per-route filters. Thanks to Damian Zaremba for the bugreport. commit 9e2635505a08e3453eef487360e49b4b70987ceb Author: Ondrej Zajicek (work) Date: Mon Dec 28 15:23:28 2020 +0100 Filter: Fix return on top-level Broken detection of top-level case caused crash when return was called from top-of-stack position. It should behave as reject/accept. Thanks to Damian Zaremba for the bugreport. commit 61dae32b29cc57b9884a1c13e5d630096e157a38 Author: Ondrej Zajicek (work) Date: Mon Dec 7 22:19:40 2020 +0100 Nest: Per-channel debug flags The patch add support for per-channel debug flags, currently just 'states', 'routes', and 'filters'. Flag 'states' is used for channel state changes, remaining two for routes passed through the channel. The per-protocol debug flags 'routes'/'filters' still enable reporting of routes for all channels, to keep existing behavior. The patch causes minor changes in some log messages. commit 8cc5bb09e344038a1f8dff96946e05ec80607c93 Author: Ondrej Zajicek (work) Date: Wed Dec 2 05:02:26 2020 +0100 Filter: Add 'weight' route attribute Add 'weight' route attribute that allows to get and set ECMP weight of nexthops. Similar to 'gw' attribute, it is limited to the first nexthop, but it is useful for handling BGP multipath, where an ECMP route is merged from multiple regular routes. commit 246586771296d1c42a012c06bdc75b36a7ce0b4f Author: Ondrej Zajicek (work) Date: Wed Nov 25 15:44:00 2020 +0100 BGP: Zero the newly allocated bucket structure This fixes an issue with dirty node passed to add_tail(). Thanks to Andreas Rammhold for the initial patch. commit 62d57b9bdf82cc978f889f0118c8aa19ae999a3d Author: Ondrej Zajicek (work) Date: Wed Nov 25 15:15:13 2020 +0100 Log: Fix locking during log reconfiguration The log subsystem should be locked earlier, as default_log_list() may internally manipulate with the current_log_list (if it is also a default log list). commit 0ef082c51e5d905e9137e1484036b9d9b32e9a75 Author: Ondrej Zajicek (work) Date: Wed Nov 25 15:04:34 2020 +0100 Log: Reinitialize the static logging structures The static logging structures are reused, we need to reinitialize them otherwise add_tail() would fail in debug build. Reinitializing these structures should be fine as the list they belong to is being reinitialized on entry to the very same function. Thanks to Andreas Rammhold and Mikael Magnusson for patches. commit 30b846826905b4da76f59a212a31928bd55e9783 Author: Ondrej Zajicek (work) Date: Tue Nov 24 04:09:11 2020 +0100 Minor cleanups with cfg_allocz() Also fixes some more failed asserts due to add_tail(). commit 1678bc07467e6d977fc2f6bf830274ca92e0a6e5 Author: Ondrej Zajicek (work) Date: Tue Nov 24 03:42:23 2020 +0100 Fix some failed asserts due to add_tail() When config structures are copied due to template application, we need to reset list node structure before calling add_tail(). Thanks to Mikael Magnusson for patches. commit c9ae81656f97bcc55910e80b6f00d3ee9383d848 Author: Ondrej Zajicek (work) Date: Tue Nov 24 03:21:44 2020 +0100 Some minor sl_allocz() cleanups commit db2d29073acfd4086fca18ba43a5ed6baccaa8ad Author: Toke Høiland-Jørgensen Date: Tue Nov 24 02:32:13 2020 +0100 lib/slab: introduce sl_allocz() function and use it in Babel The babel protocol code was initialising objects returned from the slab allocator by assigning to each of the struct members individually, but wasn't touching the NODE member while doing so. This leads to warnings on debug builds since commit: baac7009063d ("List expensive check.") To fix this, introduce an sl_allocz() variant of the slab allocator which will zero out the memory before returning it, and switch all the babel call sites to use this version. The overhead for doing this should be negligible for small objects, and in the case of babel, the largest object being allocated was being zeroed anyway, so we can drop the memset in babel_read_tlv(). commit 3347aaafec5b269637604d1ea5f5969797beadea Author: Ondrej Zajicek (work) Date: Thu Nov 19 16:38:39 2020 +0100 Static: Support for multiple routes with the same network Add support for proper handling of multiple routes with the same network to the static protocol. Routes are distinguished by internal index, which is assigned automatically (sequentially for routes within each network). Having different route preference or igp_metric attribute is optional. commit df65d519d6a5a7511cc893d2be55399b38b838be Author: Nigel Kukard Date: Wed Nov 18 18:00:12 2020 +0100 Doc: Added example of static routes with BGP large communities commit 00ddd18b02a4a4db973adecf6ef63a350c909cbd Author: Ondrej Zajicek (work) Date: Wed Nov 18 17:37:29 2020 +0100 OSPFv3: Fix intra-area-prefix-LSA origination on DR When a new link-LSA is originated, we need to notify intra-area-prefix-LSA handling, like when a new link-LSA is received. Otherwise a new network prefix added to a DR is not propagated immediately. Thanks to Bala Sajja for the bugreport. commit 6ea8a46ccb540701dfe747566e6a5b7bc318db01 Author: Ondrej Zajicek (work) Date: Sun Nov 15 16:28:13 2020 +0100 Doc: Fix typo Thanks to Hexhu for the bugreport. commit b962967e20f186f797c163f69c673b0ee4ef3b2b Author: Ondrej Zajicek (work) Date: Sun Nov 15 16:01:19 2020 +0100 Nest: Fix crash in receive limit handling in import table Logging as a result of triggered receive limit in import table code accesset rte->net, which was not filed yet. Thanks to Pier Carlo Chiodi for the bugreport. commit 4a42e7e92520e7d07e585d542ef54e1de302fb1d Author: Ondrej Zajicek (work) Date: Thu Nov 12 04:50:45 2020 +0100 BFD: Update documentation about per-session options commit 3b56bf8849283977f2f4fa7b8f3dc62fdd8d7587 Author: Ondrej Zajicek (work) Date: Thu Nov 12 04:02:38 2020 +0100 BFD: Better handling of BFD options in BGP configs Merge multiple BFD option blocks in BGP configs instead of using the last one. That is necessary for proper handling of templates when BFD options are used both in a BGP template and in a BGP protocol derived from that template. commit 99ad208dd73d357156672a53f48b77dcf6515c30 Author: Ondrej Zajicek (work) Date: Thu Nov 12 02:37:42 2020 +0100 BFD: Fix superfluous reconfiguration of sessions commit 9d3fc3062b236f51b2c72a4c2c7b068f1946261d Author: Ondrej Zajicek (work) Date: Sun Nov 8 15:33:22 2020 +0100 BFD: Allow per-request session options BFD session options are configured per interface in BFD protocol. This patch allows to specify them also per-request in protocols requesting sessions (currently limited to BGP). commit fc1e3211b109400c0e96f889829c9f5145ac7226 Author: Ondrej Zajicek (work) Date: Sun Oct 11 00:53:19 2020 +0200 RPKI: Add 'ignore max length' option Add 'ignore max length' option to RPKI protocol, which ignores received max length in ROA records and instead uses max value (32 or 128). This may be useful for implementing loose RPKI check for blackholes. commit 6c11dbcf28faa145cfb7310310a2a261fd4dd1f2 Author: Ondrej Zajicek (work) Date: Mon Oct 5 14:52:55 2020 +0200 Doc: Fix missing semicolons Thanks to Marco Gartmann for the bugreport. commit 14ce8904e7b9f6ceeaf2587faeab200cd67401d9 Author: Ondrej Zajicek (work) Date: Mon Oct 5 14:45:01 2020 +0200 Doc: Fix typo Thanks to Sergey Kulikov for the bugreport. commit 600eb695b1a273f8b3fd4f2c524d8eeef25483aa Author: Maria Matejka Date: Mon Aug 31 15:41:39 2020 +0200 OSPF: Fixed a debug assert commit dc8d9dec4a3484f358d2117328fe860e8e7b16bb Author: Ondrej Zajicek (work) Date: Wed Aug 12 19:42:44 2020 +0200 OSPF: Skip out-of-state packets earlier Sometimes multicast OSPF packet is received when neighbor adjacency is not established. Such packet should be ignored earlier in packet processing as otherwise it causes strange error messages when OSPFv3 authentication is enabled. commit c0e1f534c95f5f395fda62b01ea1c245323e3aed Author: Ondrej Zajicek (work) Date: Thu Jul 16 15:02:10 2020 +0200 Nest: Keep route ordering during route updates Put new non-best routes to the end of list instead of the second position. Put updated routes to their old position. Position is changed just by best route selection. commit c26c6bc2d78a2fe76f27dcc9fbb5afc95c3a7626 Author: Ondrej Zajicek (work) Date: Thu May 14 03:48:17 2020 +0200 Show info from multiple protocols when protocol is not specified Most commands like 'show ospf neighbors' fail when protocol is not specified and there are multiple instances of given protocol type. This is annoying in BIRD 2, as many protocols have IPv4 and IPv6 instances. The patch changes that by showing output from all protocol instances of appropriate type. Note that the patch also removes terminating cli_msg() call from these commands and moves it to the common iterating code. commit a948cf9a5c338518773e6c98e895c829c469f56b Author: Kazuki Yamaguchi Date: Sun Jun 28 15:37:01 2020 +0200 Filter: Improve handling of sets in BGP path masks Compare the content of PM_ASN_SET in path masks. A reconfiguration was not properly triggering a reload of affected protocols when the members of a set in a path mask change. Also, update the printing code to so that it can display sets in a path mask. commit 4ef0a966392672d04a567c25758462fe3bbb0fb4 Author: Kazuki Yamaguchi Date: Sun Jun 28 15:33:26 2020 +0200 Filter: Fix comparison of BGP path mask Add a missing return statement. Path masks with the same length were all considered the same. Comparing two with different length would cause out-of-bounds memory access. commit 82937b465b3a50bdcb00eff0b7aa6acb3fc21772 Author: Ondrej Zajicek (work) Date: Wed Jun 10 13:27:14 2020 +0200 OSPF: Fix bad header length test Thanks to Slava Aseev for the thorough bugreport. commit 71e08edd942557ec333902bb45c57794f7a66bf8 Author: Kenth Eriksson Date: Wed Jun 3 23:05:29 2020 +0200 Doc: Add 'ptp address' to OSPF doc overview commit 63451c19611b5972769ed519bd7eb6c1b995a8a0 Author: Ondrej Zajicek (work) Date: Wed Jun 3 16:15:29 2020 +0200 Test: Fix unit test mockups commit f1b5f179dbd8aaef5eca4936b557e753e377d818 Author: Kazuki Yamaguchi Date: Wed Jun 3 15:18:02 2020 +0200 Netlink: Fix parsing of MPLS multipath routes Add support for RTA_MULTIPATH attribute parsing for AF_MPLS routes. BIRD is capable of installing a multipath route into kernel on Linux, but it would not be seen because parsing fails. This made BIRD attempt to install the same route repeatedly. (The patch minorly updated by committer) commit 19f8f173202d6f5cbf97ca2a9f66fcea6b9bb44f Author: Kazuki Yamaguchi Date: Wed Jun 3 15:05:35 2020 +0200 RPKI: Fix unnecessary reconnection on reconfiguration Compare the new timing parameters with the old configuration, not with the temporary state of the current connection. The timing values in struct rpki_cache is updated by a version 1 End Of Data PDU, unless this behavior is suppressed by the configuration explicitly by the "keep" keyword. Consequently, every reconfiguration of BIRD triggers a reconnection even if it is not necessary. commit fae5448134dfec004be818d18ff1583cc61e5549 Author: Ondrej Zajicek (work) Date: Sun May 31 13:21:55 2020 +0200 Log: Do not open logfiles when parse-and-exit option is active This is a quick workaround for an issue where configured logfiles are opened/created during parsing of a config file even when parse-and-exit option is active. We should later refactor the logging code to avoid opening log during parsing altogether. commit eee8af4db2d36a5017eac4447075cac3346e8b23 Author: Maria Matejka Date: Tue Jun 2 16:58:06 2020 +0200 OSPF: setting list node to zero before enlisting commit 4e8f8afc68cc7ba09ca42d989e47dbfcb17d2772 Author: Ondrej Zajicek (work) Date: Tue May 26 23:43:13 2020 +0200 Babel: Set onlink flag for IPv4 routes with unreachable next hop If the next hop of a route is not a reachable address, the route should be installed as onlink. This enables a configuration common in mesh networks where the mesh interface is assigned a /32 and babel handles the routing by installing onlink routes. Thanks to Toke Hoiland-Jorgensen for the patch. commit c1632ad0f39f7221d649a9e469cacc38105528e2 Author: Ondrej Zajicek (work) Date: Tue May 26 18:21:43 2020 +0200 OSPF: Fix handling of unnumbered PtPs This issue has a long history. In 2012, we changed data field for unnumbered PtP links from iface id (specified by RFC) to IP address based on reports of bugs in Quagga that required it, and we used out-of-band information to distinquish unnumberred PtPs with the same local IP address. Then with OSPF graceful restart implementation, we found that we can no longer use out-of-band information, and we need to use only LSAdb info for routing table calculation, but i forgot to finish handling of this case, so multiple unnumbered PtPs with the same local IP addresses were broken. Considering that even recent Mikrotik RouterOS has broken next hop calculation that depends on IP address in PtP link data field, we cannot just switch back to the iface id for unnumbered PtP links. The patch makes two changes: First, it goes back to use out-of-band (position) info for distinguishing local interfaces in SPF when graceful restart is not enabled, while still uses LSAdb-only approach for SPF calculation when graceful restart is enabled. Second, it adds OSPF interface option 'ptp address', which controls whether IP address or iface id is used in data field. It is enabled by default except for unnumbered PtP links with enabled graceful restart. Thanks to Kenth Eriksson for the bugreport and Joakim Tjernlund for suggestions. commit 1ca7665fa4a9858a6d4c591ccff5b61e5e6aed13 Author: Ondrej Zajicek (work) Date: Tue May 19 02:50:47 2020 +0200 Nest: Allow key id 0 There is nothing in RFCs specifying that id 0 is not allowed. Some implementations does not support it, while some other use key id 0 by default. We allow it but start with key id 1 by default. Thanks to Kenth Eriksson for the bugreport. commit b729e731f99aa6ece085597091618ed559a9f656 Author: Ondrej Zajicek (work) Date: Mon May 18 22:16:37 2020 +0200 RIP: Triggered RIP (demand circuit) documentation commit ec430a7feefd3b32ee39c641a48c44528d0eab25 Author: Ondrej Zajicek (work) Date: Mon May 18 16:25:08 2020 +0200 Nest: Implement BGP path mask loop operator Implement regex-like '+' operator in BGP path masks to match previous path mask item multiple times. This is useful as ASNs may appear multiple times in paths due to path prepending for traffic engineering purposes. commit 5fc8407177fd34f2d57441a8ff9a068f4162fbfb Author: Ondrej Zajicek (work) Date: Tue May 12 03:46:47 2020 +0200 RIP: Fix handling of passive mode for demand circuit interfaces commit b8bbbbaf569799ab8faff0ee185528b6a2129154 Author: Ondrej Zajicek (work) Date: Mon May 11 04:29:36 2020 +0200 Nest: Fix neighbor handling for colliding ranges Resolve neighbors using longest prefix match. Although interface ranges should not generally collide, it may happen for unnumbered links. Thanks to Kenth Eriksson for the bugreport. commit f7c34aa227693194e53ca0435dba52c2a839bae8 Author: Ondrej Zajicek (work) Date: Tue May 5 02:20:30 2020 +0200 Tests: Activate BGP-int test commit e6785c469b418785568c33241157d17107afd55c Author: Matous Holinka Date: Wed Apr 29 16:15:17 2020 +0200 Tests: Change unsupported Ubuntu 19.04 for supported version 19.10 commit 82bfee76f0adfd50d51833343c63ba9e2afcb60e Author: Ondrej Zajicek (work) Date: Wed Apr 29 15:07:33 2020 +0200 Filter: Remove quitbird command No need for this debug filter command and it can be abused from CLI. commit b12442c985f2bd8c9fd47ca63151724962fabdc2 Author: Maria Matejka Date: Fri May 1 15:41:42 2020 +0200 Fixed a harmless warning in production build commit 048eb2ddf1ee9587d9fa30cbb3f87d6f650a2133 Merge: 17de3a02 59238768 Author: Maria Matejka Date: Fri May 1 15:34:17 2020 +0200 Merge remote-tracking branch 'origin/mq-static-analysis' commit 59238768b3b05fa134348d2232b42537d0403994 Author: Maria Matejka Date: Mon Aug 19 14:43:14 2019 +0200 Slab: Init node in slab head to NULLs. commit ea259d6201973eb0f764cbb2bb6549b6ac79b316 Author: Maria Matejka Date: Sat Aug 17 16:09:29 2019 +0200 Timer: Adding missing initializer. commit 0c3b8ffe25f43e59dfe8b1aeb219ff1cb4c6aa2b Author: Maria Matejka Date: Sat Aug 17 15:03:09 2019 +0200 Lexer: strtoul shall never set endptr to NULL; it should be an error commit cdde3550dc188f493daf82ef9d9acf8b85d9d722 Author: Maria Matejka Date: Sat Aug 17 14:57:41 2019 +0200 Unix socket: Path length check directly before copying the path. This is not needed as the string is always short enough, anyway it may be needed in future and one strlen during BIRD start is cheap enough. commit 9ac13d7af25d6b26866bf4f4a4fab371925fb1df Author: Maria Matejka Date: Mon Aug 19 14:36:51 2019 +0200 Lists: Replaced replace_node() by update_node() which is the only use of that function. commit e26a5195dd6c62e6f4b80d13b6ecd5f40ee68546 Author: Maria Matejka Date: Sat Aug 17 14:03:47 2019 +0200 Lists: fix a stupid sanitizer bug commit 3bb10b4d31d68a8139e284c27f7eb6fca897721d Author: Maria Matejka Date: Sat Aug 17 14:18:41 2019 +0200 Uninitialized list nodes fixes commit 258be56539a3d4b47fe779f9658ca3d88761878d Author: Maria Matejka Date: Sat Aug 17 13:36:36 2019 +0200 Nest: Added const to ea_show just to declare that this shouldn't really change anything commit a7d9b8f116d00194e94c7505cbc8ed7f8784eeab Author: Maria Matejka Date: Sat Aug 17 10:28:55 2019 +0200 OSPF: Zero-initialization of a temporary neighbor commit 0fa8bf91cd474e393ded85b329fde30ba35f6a26 Author: Maria Matejka Date: Sat Aug 17 10:20:46 2019 +0200 Nest: Several assumptions to tame the static analyzer commit bbe49ae569534d0cf7ff226d19e729dcc764e606 Author: Maria Matejka Date: Sat Aug 17 08:59:06 2019 +0200 Nest: Assumption in rt-show for not-so-intuitive invariant. commit a08853a26989d343c507a41257dedcdea3befd73 Author: Maria Matejka Date: Sat Aug 17 08:54:08 2019 +0200 Static scanner and expensive debugging setup fix commit 5f60d14edeb48824d28e6393e7eb1aa50d5f2cd1 Author: Maria Matejka Date: Fri Aug 16 21:22:56 2019 +0200 RPKI: fixed rare va_list leak commit b7482209065a03c3186d74e5e4129539ce7a3ce4 Author: Maria Matejka Date: Fri Aug 16 21:15:49 2019 +0200 Static check: Don't report dead code commit 9e64ac4b7c23aa3b8b9149794c05305315cf31e5 Author: Maria Matejka Date: Fri Aug 16 14:04:53 2019 +0200 OSPF: Adding a note about a static analyzer result. commit dccee408262262ab9a63403141b74a0d937284bc Author: Maria Matejka Date: Fri Aug 16 12:47:13 2019 +0200 OSPF: variable-length array of size 0 replaced by alloca()'d pointer NULL pointer is safer than a random pointer onto stack if this function gets changed and eventually broken. commit baac7009063d94799821422ecc63ea2af41561ea Author: Maria Matejka Date: Wed Aug 14 16:23:58 2019 +0200 List expensive check. commit a0d0a71a1828cce725c3132f8c243bf0c537786f Author: Maria Matejka Date: Wed Aug 14 16:22:39 2019 +0200 Expensive check declaration Intended to be run at every operation with complex data structures to check their consistency and validity. commit a1b61a271af40a9d6ef0837424ab2c98d29f1575 Author: Maria Matejka Date: Wed Aug 14 12:29:04 2019 +0200 IPv6 address parser: fail on incomplete addresses commit d65a926a67749f8e8ffb6df9b3e2e123669b0656 Author: Maria Matejka Date: Wed Aug 14 11:49:20 2019 +0200 Filter: Don't alloc varargs array if its length would be zero commit 30ba7c1661a13d665ae0aaa4e40cb5ed24023450 Author: Maria Matejka Date: Wed Aug 14 11:31:03 2019 +0200 Filter: Removed forgotten dead code commit bf9486bf20ee16af71e338ee690fc36805d98fe5 Author: Maria Matejka Date: Mon Apr 27 22:33:10 2020 +0200 Non-null function argument declaration commit 17de3a023f7bde293892b41bfafe5740c8553fc8 Author: Ondrej Zajicek (work) Date: Wed Apr 29 02:50:29 2020 +0200 BGP: Fix handling of strange IPv6 link-local-only next hops There are three common ways how to encode IPv6 link-local-only next hops: (:: ll), (ll), and (ll ll). We use the first one but we should accept all three. The patch fixes handling of the last one. Thanks to Sebastian Hahn for the bugreport. commit 8029ae527edde4d47a51b55efdbdea546296c5ef Author: Maria Matejka Date: Thu Aug 1 14:25:01 2019 +0200 More assertion categories commit d607205486d7ea11f2cbf3dcc3d5e7e6b53f1d0f Author: Maria Matejka Date: Wed Aug 14 10:28:23 2019 +0200 Not calling memcpy with n=0. commit 124d860f648f4c1c080e77b5f070b97d094f5285 Author: Maria Matejka Date: Wed Aug 14 11:06:49 2019 +0200 Filter: fixed omitted overflow check in EC constructor commit 59a86cbc7c5d5640b16ca9d8a99be979b11a4c68 Author: Maria Matejka Date: Wed Aug 14 10:14:15 2019 +0200 Makefile rule for static analyzer commit b465604eb13fc57ebe240556ebf0d4469690c906 Author: Ondrej Zajicek (work) Date: Tue Apr 28 14:58:43 2020 +0200 Tests: Activate BGP-auth test commit 716e11a58437498c09ffdb321b0de4e28a7383d8 Author: Ondrej Zajicek (work) Date: Tue Apr 28 03:52:47 2020 +0200 Tests: Activate OSPF-VRF test commit 3c838ad9fdc553c658ee2fbb466ab8ab4cd14805 Author: Ondrej Zajicek (work) Date: Wed Apr 22 16:03:37 2020 +0200 Tests: Activate BGP test commit a6548d5b5be1d0186dfab43b76790803f8c8625e Author: Nasato Goto Date: Wed Apr 15 03:46:53 2020 +0200 BGP: Fix handling of 16bit-only ASN translation The bug generated invalid AGGREGATOR attribute during translation of 32bit ASN to 16bit-only BGP peer. The patch fixes that. commit fd9f0c0640fd02a26b96b4f9d3cbbffbb6544a84 Author: Maria Matejka Date: Wed Apr 8 22:25:15 2020 +0200 Configuration strings are constant. This is merely a const propagation. There was no problem in there. commit a109056145a6bc8a6b498ecb6e309ebc143c8b3c Author: Ondrej Zajicek (work) Date: Sat Mar 28 17:17:51 2020 +0100 Doc: Update prefix set comment commit 2928c5bcc7c3caaeb6de34a84ca63de9a12e1f1a Author: Maria Matejka Date: Sun Apr 5 01:12:06 2020 +0200 Fletcher16 test fixed to work at bigendian architectures. To be honest, it was wrong in concept, anyway it accidentally worked. commit c9d11e6230c49cdfd1f17829be0e877aba05e90b Author: Ondrej Zajicek (work) Date: Thu Mar 26 04:53:23 2020 +0100 Filter: Remove mixed address tests and fix formatting commit 27550028907fd135051a43dda0abe76e9118b7e9 Author: Ondrej Zajicek (work) Date: Thu Mar 26 03:57:48 2020 +0100 Filter: Optimize IPv4 prefix sets Use separate IPv4 and IPv6 implementation of prefix sets. Just this change makes IPv4 prefix sets 60% smaller and 50% faster. commit d516c68ad838351fa5e20e3e10bd3fb2b3157618 Author: Ondrej Zajicek (work) Date: Sat Mar 14 17:04:49 2020 +0100 RIP: Improvements to demand circuit mode Restart iface after changing demand circuit mode during reconfiguration. Fix next_regular interval reset during reconfiguration. Send flushing response when iface goes down. commit dc042d87cb68e44b49e9f4f153db444afaa00fba Author: Maria Matejka Date: Mon Jan 27 17:42:11 2020 +0100 Perf: changed route update pattern to be more like common protocols commit e2630a494ebc90bee97729ebe92a1bb9fd8bb611 Author: Ondrej Zajicek (work) Date: Thu Mar 5 23:51:28 2020 +0100 Netlink: Handle interfaces with missing broadcast addresses commit 1ad98965c5eacd5c5f468beac146dfd0d63c83f2 Author: Ondrej Zajicek (work) Date: Thu Mar 5 22:01:30 2020 +0100 Tests: Enforce cleanup before running a test commit ead531ffefdad0f6b5d654330d0e4aba94757569 Author: Ondrej Zajicek (work) Date: Thu Mar 5 17:39:52 2020 +0100 Tests: Activate OSPF tests commit e6746da6de45bcacc42010cea828129eae38ba67 Author: Ondrej Zajicek (work) Date: Tue Mar 3 19:04:05 2020 +0100 Flowspec: Fix tests Missing dst no longer generates error. commit 78e4a123bb937bb45f7eaebb0ea475095443bfd0 Author: Ondrej Zajicek (work) Date: Tue Mar 3 17:45:16 2020 +0100 BGP: Handle flowspec rules without dst part The RFC 5575 does not explicitly reject flowspec rules without dst part, it just requires dst part in validation procedure for feasibility, which we do not implement anyway. Thus flow without dst prefix is syntactically valid, but unfeasible (if feasibilty testing is done). Thanks to Alex D. for the bugreport. commit 757cab18d6427d9246618ce48c158f2b05183838 Author: Ondrej Zajicek (work) Date: Thu Feb 27 16:16:48 2020 +0100 BGP: Support for MD5SIG together with remote range When dynamic BGP with remote range is configured, MD5SIG needs to use newer socket option (TCP_MD5SIG_EXT) to specify remote addres range for listening socket. Thanks to Adam Kułagowski for the suggestion. commit 22c3cf955dbbb65aa29e322efa70dabb749f0232 Author: Ondrej Zajicek (work) Date: Fri Feb 21 02:35:50 2020 +0100 RIP: Demand circuit support (RFC 2091) commit 3343088a7164a54b1e6c6cf9648d8036a61e9827 Author: Ondrej Zajicek (work) Date: Fri Feb 14 22:37:07 2020 +0100 RIP: Fix crash when interface is removed Recent changes in neighbor code caused RIP to access neighbor field which is NULL during interface/neighbor removal and caused crash when debug messages are enabled. Use correct field to get iface from neighbor. commit ab089f4fb5e1ac762a9c95ed4638e2477803678e Author: Maria Matejka Date: Tue Feb 4 10:34:46 2020 +0100 Conf: Better error message when reading iproute2 config Reported by: Martin Weinelt commit 027a3e66f786be8863784aefb043097b41090896 Author: Maria Matejka Date: Tue Feb 4 10:15:35 2020 +0100 RPKI: Allow build without libSSH commit 4bbc10614f3431c37e6352f5a6ea5c693c31021e Author: Maria Matejka Date: Tue Feb 4 10:11:16 2020 +0100 Added missing extern Thanks to Robert Scheck who reported it and Toke Høiland-Jørgensen who suggested this patch. commit 7f9adafc109d576d5249c25ef284606dbac4adfa Author: Ondrej Zajicek (work) Date: Tue Jan 28 18:07:25 2020 +0100 BFD: Option to specify which class of BFD sessions are accepted Allows to configure IPv4/IPv6-only or direct/multihop-only BFD protocol instances. commit 9f2670277cc0d56d3364d4784348056174175aba Author: Ondrej Zajicek (work) Date: Thu Jan 9 02:59:59 2020 +0100 OSPF: Fix bad initialization of tx_hdrlen field Function ifa_tx_hdrlen() uses fields autype and passwords, so it must be called after these are set. Thanks to Kenth Eriksson for the bugreport. commit 7d767c5a3d001a6a1a5c3e800553202fd492190c Author: Ondrej Zajicek (work) Date: Tue Jan 7 18:35:03 2020 +0100 KRT: Improve syncer code to avoid using temporary data in rtable The old code stored route verdicts and temporary routes directly in rtable. The new code do not store received routes (it immediately compares them with exported routes and resolves conflicts) and uses internal bitmap to keep track of which routes were received and which needs to be reinstalled. By not putting 'invalid' temporary routes to rtable, we keep rtable in consistent state, therefore scan no longer needs to be atomic operation and could be splitted to multiple events. commit ef8c45749c82e246d477ea4d7f749668a9c7e9ee Author: Ondrej Zajicek (work) Date: Tue Jan 7 01:24:30 2020 +0100 Filter: Fix typecheck for AND/OR. Do not apply dynamic type check for second argument of AND/OR, as it is not evaluated immediately like regular argument would be. Thanks to Mikael for the bugreport. commit cc75b3e1dc4a7440479d6f4d73e7e1b9ba65332f Author: Ondrej Zajicek (work) Date: Thu Dec 19 16:34:35 2019 +0100 KRT: Remove KRF_SYNC_ERROR flag This info is now stored in an internal bmap. Unfortunately, net.flags is still needed for temporary kernel data. commit 90a9c97e38e3769b400b434723516213eccb3ab0 Author: Ondrej Zajicek (work) Date: Tue Dec 17 16:30:29 2019 +0100 KRT: Fix removal of KRF_INSTALLED Use route id from net->routes to check export_map. Route received from sysdep KRT code does not have proper id. commit 3dabf7b8d09c3188ea41b7e2f763397946943778 Author: Ondrej Zajicek (work) Date: Tue Dec 17 00:01:53 2019 +0100 Test: Improve filter_test Initial parsing of test.conf must be done directly in filter_test main, while reconfiguration is handled as a regular test. Also fix several minor issues in test code. commit 3232d1718636eb7617fedc7b27378cd1d8f8691d Author: Ondrej Zajicek (work) Date: Mon Dec 16 18:05:56 2019 +0100 Doc: Fix documentation of BGP gateway option Thanks to Nico Schottelius for the bugreport. commit c132acae362b6106c2eecbef2d8c163acde84035 Author: Ondrej Zajicek (work) Date: Mon Dec 16 02:40:28 2019 +0100 KRT: Remove KRF_INSTALLED flag The same information is stored in export_map of kernel protocol. commit d3aa4f2aeddf7f546b3c0c9bd5fc7958ecb3814a Author: Maria Matejka Date: Thu Dec 12 15:42:29 2019 +0100 Filter: fix filter comparison test commit dfb3eb771683ae4cc5ae43a990352578ab20f0fa Author: Ondrej Zajicek (work) Date: Tue Dec 10 18:53:16 2019 +0100 Filter: Fix function comparison Check the SYM_FLAG_SAME in new symbols. The old code checked that in old symbols (f2). commit 4ab54f1aefd6a3ecc5e2340cbc15d492444daff5 Author: Ondrej Zajicek (work) Date: Tue Dec 10 18:18:02 2019 +0100 Nest: Fix bitmap cleanup Channel currently does not have independent pool and uses protocol pool, which is freed when protocol changes state to down, while channel is still in flushing. Move some some cleanup code to channel_do_flush() so it is done before freeing of protocol pool. commit ff2ca10cba9c5a3be690ec1a77a068e23395ef20 Author: Ondrej Zajicek (work) Date: Mon Dec 9 04:23:01 2019 +0100 Filter: Add support for src/dst accessors for Flowspec and SADR commit 21d09632a524c0d2a7f44a51f877370ad07b983c Author: Ondrej Zajicek (work) Date: Tue Dec 3 18:05:41 2019 +0100 BGP: Add some statistics Add some statistic counters to BGP consistent with BGP MIB (RFC 4273), including persistent 'FSM established transitions'. commit 92249894b333f7785e62b2f629dca1bbe6597c2f Author: Matous Holinka Date: Tue Nov 26 19:33:01 2019 +0100 CI: Add more build tests Add more Docker images with distributions (CentOS 8, Debian 10, Fedora 27-31, OpenSUSE 15.0 & 15.1, and Ubuntu 18.04 & 19.04). Fix some issues with older ones. commit 0adfa0ec076196275a3cf034ba3ce82ffbcd2fbd Author: Ondrej Zajicek (work) Date: Mon Nov 11 00:24:07 2019 +0100 CI: Cleanup of job templates Env templates were used for separate IPv4/IPv6 build, that is no longer needed. commit 6a314d26cbcc0e75c872d6c222f93661049466b7 Author: Ondrej Zajicek (work) Date: Sun Nov 10 22:58:23 2019 +0100 CI: Update new netlab location commit 148bd9ee92c55ba23be2d60a278dfa7ad0005971 Author: Ondrej Zajicek (work) Date: Sun Nov 10 03:43:30 2019 +0100 CI: Minor update commit faa43a755eba5194c50fae20dddc0e3837fe5dc5 Author: Ondrej Zajicek (work) Date: Sun Nov 10 03:02:58 2019 +0100 Apply relevant changes from branch mh-test-gitlab commit 5176455f1a4506e9397e23895e1de525c3c190c9 Author: Ondrej Zajicek (work) Date: Fri Nov 1 00:13:59 2019 +0100 Gitlab test commit 5ea39eaa96625ec8274703b1eb2c8f59042a8a32 Author: Ondrej Zajicek (work) Date: Mon Sep 9 02:55:32 2019 +0200 Nest: Use bitmaps to keep track of exported routes Use a hierarchical bitmap in a routing table to assign ids to routes, and then use bitmaps (indexed by route id) in channels to keep track whether routes were exported. This avoids unreliable and inefficient re-evaluation of filters for old routes in order to determine whether they were exported. commit af02b83b888c693c292960072195f0e1caf1d2a1 Author: Ondrej Zajicek (work) Date: Mon Sep 9 02:43:39 2019 +0200 Lib: Basic and hierarchical bitmaps Basic bitmap is obvious. Hierarchical bitmap is structure of several bitmaps, where higher levels are conjunctions of intervals on level below, allowing for efficient lookup of first unset bit. commit d033e6327d1e63f5d212981fca785b5086491905 Author: Ondrej Zajicek (work) Date: Tue Nov 26 16:43:09 2019 +0100 CLI: Fix continuation lines after final one Continuation lines may use short form (with space instead of message number), but this should not be done when previous line is final. Thanks to Kenth Eriksson for the bugreport and analysis. commit 0f88200247cc61175c7a1d98a3e935aedce93f3b Author: Ondrej Zajicek (work) Date: Mon Nov 18 17:44:34 2019 +0100 BGP: Fix processing of IPv6 Flowspec During NLRI parsing of IPv6 Flowspec, dst prefix was not properly extracted from NLRI, therefore a received flow was stored in a different position in flowspec routing table, and was not reachable by command 'show route '. Add proper prefix part accessors to flowspec code and use them from BGP NLRI parsing code. Thanks to Alex D. for the bugreport. commit 53401bef63013dfee01b65d071ffbd88e457539f Author: Ondrej Zajicek Date: Tue Nov 12 18:13:21 2019 +0100 Netlink: Handle IPv4 routes with IPv6 nexthops Accept RTA_VIA attribute in all cases. The old code always used RTA_GATEWAY for IPv4 / IPv6 and RTA_VIA for MPLS. The new code uses RTA_VIA in cases where AF of network and AF of nexthop differs. commit 0b228fca04c8a9a81af6a4973877ceba9aede3f0 Author: Ondrej Zajicek (work) Date: Sun Nov 10 02:06:07 2019 +0100 BGP: Add option to enforce first AS in AS_PATH This is optional check described in RFC 4271. Although this can be also done by filters, it is widely implemented option in BGP implementations. Thanks to Eugene Bogomazov for the original patch. commit becda5638a8ff8b056ec04b5e156e86b168cb9ef Author: Ondrej Zajicek (work) Date: Tue Nov 5 16:29:47 2019 +0100 Doc: Minor fix commit d54a69ac7f0a29846cd9dbc697d1d369f51988bb Author: Ondrej Zajicek (work) Date: Tue Nov 5 16:00:25 2019 +0100 Doc: Add documentation for BGP option 'allow as sets' commit 10c4cd9677555e88a4ac8c95784aa281655e3326 Author: Ondrej Zajicek (work) Date: Tue Nov 5 15:14:57 2019 +0100 Filter: Add type info for more instructions commit 87512e97516160ec980e9d0621522ada405438fe Author: Ondrej Zajicek (work) Date: Tue Nov 5 15:13:57 2019 +0100 Filter: Improve typecheck error messages commit c00c20a79941b2bbed9e957134259763dcbb29f0 Author: Ondrej Zajicek (work) Date: Wed Oct 23 22:56:23 2019 +0200 Filter: Better constant promotion We use constant promotion from IPv4 to Router-ID values, as they have same literals. Instead of ad-hoc code in filter instructions, add constant promotion code to parse-time typecheck code. commit 26194bd684b2926740a74ebdfe73e6afc3c145b6 Author: Ondrej Zajicek (work) Date: Wed Oct 23 22:53:23 2019 +0200 Filter: Improved parse-time typechecks commit 6fbcd8914aa2b0e0f50c6f20a15cd6eb1ba44497 Author: Ondrej Zajicek Date: Tue Oct 22 19:19:36 2019 +0200 Filter: Parse-time typechecks Most expressions can be type-validated in parse time. It is not strong enough to eliminate runtime checks, but at least one gets errors immediately during reconfigure. commit a52476c9be41e8d33e4a22e3dc733240ce791b42 Author: Ondrej Zajicek (work) Date: Mon Nov 4 22:07:03 2019 +0100 BGP: Add option to reject AS_SETs There is a pending draft to make them obsolete commit 0edf0c8cd919a8b3fbf5bc036f27ea0b4ed0b91a Author: Ondrej Zajicek (work) Date: Sun Nov 3 20:26:54 2019 +0100 Support for address family constants We already had them defined on BGP level, but they are more general. commit 08c4c9a30b7ed61be39ddc71aebd69a0fea6a55a Author: Ondrej Zajicek (work) Date: Sun Nov 3 20:25:42 2019 +0100 Nest: Fix bug in export table For regular channels do not compare src in export table, as we want to keep here only the best (exported) route per network. commit be7c1aef429092bb90167a7f1b5c33b74a8030c2 Author: Ondrej Zajicek (work) Date: Sat Oct 26 01:28:38 2019 +0200 BGP: RFC 8654 got released commit 498d8145c0984acf6b39d7e312950315571e7030 Author: Ondrej Zajicek (work) Date: Fri Oct 25 13:28:51 2019 +0200 Nest: Fix primary flag in show route The route is changed by rte_make_tmp_attrs(), so we need to compare net->routes to the original one. Thanks to Kenth Eriksson for the bugreport. commit ec331acf48535211fb5b50c87e74bf1c8370283a Author: Ondrej Zajicek (work) Date: Thu Oct 24 17:47:45 2019 +0200 BGP: Fix handling of transitive extended communities Transitive extended communities should be removed on external sessions, the old code them in all cases. Thanks to Jean-Daniel Pauget for the original patch. commit 5ce881be82d6698c32e36add9ed6e1643150c3f3 Author: Ondrej Zajicek Date: Tue Oct 22 16:20:38 2019 +0200 Accept uppercase letters in iproute2 names Names read from texfiles in /etc/iproute2/* are normalized by replacing non-alphanumeric chars with underscore. The patch fixes handling of uppercase letters, which were handled as non-alphanumberic. Thanks to Igor Gavrilov for the bugreport. commit f9eb9b4cab65b850c61738dd56632bae0e7329ca Author: Fabrice Fontaine Date: Sat Oct 19 12:50:27 2019 +0200 Nest: Fix build without protocols (CHECK keyword added by commiter) commit 4e23b499696da81acf0ed5ad181573b94ccdb9a3 Author: Ondrej Zajicek (work) Date: Sat Oct 19 03:37:43 2019 +0200 RPKI: Fix handling of IPv6 cache addresses The old code used just sizeof(struct sockaddr) bytes of IP address. commit b000a94275d7bb81868b9d6ad7582e5a3939532a Author: Ondrej Zajicek (work) Date: Fri Oct 11 00:18:38 2019 +0200 NEWS and version update commit 6c9cda6f924ec400e6e55ed009bfaf7a7fd9819d Author: Ondrej Zajicek (work) Date: Thu Oct 10 23:33:40 2019 +0200 BGP: Fix reconfiguration with import table Change of some options requires route refresh, but when import table is active, channel reload is done from it instead of doing full route refresh. So in this case we request it internally. commit eeb2c61653cb8a912a1c92ad3b98932245c2c202 Author: Ondrej Zajicek (work) Date: Thu Oct 10 22:43:41 2019 +0200 Doc: Minor documentation fixes Thanks to Christoph for the bugreport. commit 843b10c8b0c28ed3bea9a37b166500aabf5e930f Author: Ondrej Zajicek (work) Date: Thu Oct 10 15:25:36 2019 +0200 Nest: Handle non-MPLS on MPLS case in recursive route update When non-MPLS recursive route resolves to MPLS underlying route, then it should get MPLS labels from the the underlying route. commit 9eace84342bc879abf371a84f8af3bd697e1c0a2 Author: Ondrej Zajicek (work) Date: Thu Oct 10 15:06:32 2019 +0200 Nest: Handle PtP links in recursive route update Underlying (IGP) route may lead to PtP link, in this case it does not need gateway. Which is different than direct route without gateway. When recursive (BGP) route uses PtP route, it should not use recursive next hop as immediate next hop, while for direct routes it should. commit cb2b6e0494e685fc4cce52a1d449ffd69bec351e Author: Ondrej Zajicek (work) Date: Thu Oct 10 14:01:16 2019 +0200 Nest: Fix recursive route update Missing cleanup can lead to dangling pointer to old next hops. commit 09ee846d9275b4cb0b77f7e458aba6a71b111c52 Author: Ondrej Zajicek (work) Date: Sat Sep 28 14:17:20 2019 +0200 BGP: AIGP metric support (RFC 7311) commit 759b204be33fa8485c9e28038ee029a49e2e9d3f Author: Ondrej Zajicek (work) Date: Tue Oct 1 17:01:29 2019 +0200 Lib: Support for 64-bit numbers in bvsnprintf() Use 'l' for s64/u64 instead of for long/ulong, as that is much more useful. Also make number() correct with regard to signed/unsigned typecasts. commit cc95b4594ac924b40325a4f1adcae5312179db40 Author: Maria Matejka Date: Mon Sep 30 13:54:14 2019 +0200 Build: Pass -g to cc called as linker to explicitly keep debug info commit d6eea6caee187dc5f6d8ed585a59031039a5c523 Author: Maria Matejka Date: Mon Sep 23 15:41:55 2019 +0200 Testing measures times commit 368f70604f347e310ca70828bfdd2504fd116064 Author: Maria Matejka Date: Wed Sep 25 16:37:16 2019 +0200 LTO: debug info also kept with the final binary commit 6dda6931d1d8f99d944d85770e235bfe75db0eb6 Author: Maria Matejka Date: Wed Aug 21 17:35:27 2019 +0200 Perf: allow testing with cached route attributes. commit 15a758378716a0af1d198c55d56a66da4ef08c93 Author: Ondrej Zajicek Date: Tue Oct 8 14:20:25 2019 +0200 Doc: Fix duplicated lines Thanks to elados93 for the patch. commit c41a914d6e9be91cda40c7e7c05a8b4f2b515089 Author: Maria Matejka Date: Mon Sep 30 13:53:24 2019 +0200 Testing: Don't call vsnprintf with NULL format commit 24493e9169d3058958ab3ec4d2b02c5753954981 Author: Maria Matejka Date: Fri Oct 4 12:20:02 2019 +0200 Fixed undefined behavior on signals. The C11 specification allows only sig_atomic_t and _Atomic variable access. All other accesses to global variables are undefined behavior. Using int was probably OK on x86 and x86_64; yet there were some reports from other architectures (especially some MIPS) that in rare cases, after issuing SIGHUP, BIRD did strange things. commit 4821251ebb13c05e8752f6f54b8e5ad6d87fecaa Author: Ondrej Zajicek (work) Date: Mon Sep 30 19:10:14 2019 +0200 BFD: Fix reconfiguration of neighbors The bfd_reconfigure_neighbors() returned after first reconfigured neighbor instead of continuing with the next one. Thanks to Winston Chen for the bugreport and a patch. commit ca2dacfcee92d8cfecff74dd020c2d16202b0d5c Author: Ondrej Zajicek (work) Date: Tue Sep 24 17:12:15 2019 +0200 Nest: Fix bug in export table Exported route may be in modified state, we need to get cached one for rte_same() and rta_clone() to work properly. commit ea0917bcba86d354f9c8516a4f114c38d04f890b Author: Ondrej Zajicek (work) Date: Tue Sep 24 00:18:48 2019 +0200 Filter: Fix eval command commit 9c79022153c6ef3a6c35b2db8be6b259104e67f3 Author: Ondrej Zajicek (work) Date: Sun Sep 22 23:32:22 2019 +0200 Nest: Fix help for 'graceful restart' command Multi-worded commands are not automatically added to top-level help output. Thanks to Christoph for the bugreport. commit 3f477ccb03ed99cf6754baaca179fcf791bcda55 Author: Maria Matejka Date: Fri Sep 20 10:16:51 2019 +0200 Filters: Function body comparison result now used. Function bodies were compared in post-parse time, yet the result was not used and the functions were incorrectly considered the same as before. Now the result is used to reload affected protocols. commit eb1e43a9af9e1905b754f1f191d228e2676ce181 Author: Ondrej Zajicek (work) Date: Tue Sep 17 14:45:14 2019 +0200 BGP: Fix setup with multiple dynamic BGP ranges Based on a patch from Liam Nattrass, thanks. commit 5235c3f78da15826b0654ba68dc7a897faa42c98 Author: Ondrej Zajicek (work) Date: Tue Sep 10 17:34:41 2019 +0200 NEWS and version update commit 532471967e6d92ae7a480367cc6d935cca75c7b2 Author: Ondrej Zajicek (work) Date: Tue Sep 10 17:28:06 2019 +0200 Doc: Update BGP mask documentation commit 452e90ba72f57c44b44f9940ac951d2fde417583 Author: Ondrej Zajicek (work) Date: Tue Sep 10 13:45:18 2019 +0200 Filter: Fix crash with 'where' filters and function calls The old 'where' code computed size value incorrectly, which leads to invalid instruction lines and filter errors or crashes. commit 1127887a8b111dab18c592f1f3f575920f38bfe3 Author: Ondrej Zajicek (work) Date: Mon Sep 9 13:17:30 2019 +0200 BGP: Fix handling of bgp_aggregator atttribute The attribute should not be modifiable by filters as we do not support its type. commit 8388f5a7e14108a1458fea35bfbb5a453e2c563c Author: Ondrej Zajicek (work) Date: Mon Sep 9 03:13:35 2019 +0200 BGP: Fix bugs in handling of shutdown messages There is an improper check for valid message size, which may lead to stack overflow and buffer leaks to log when a large message is received. Thanks to Daniel McCarney for bugreport and analysis. commit 56d8b1e7f6252158caf0ecd3147376b858b16d97 Author: Ondrej Zajicek (work) Date: Thu Aug 29 20:58:16 2019 +0200 OSPF: Fix 'show ospf lsadb' cmd without proto arg It crashed when used without protocol argument. Thanks to Alexander for the bugreport. commit 32a254050d3da57ca6d7627aa606a8dce11907ee Author: Maria Matejka Date: Mon Aug 26 21:53:56 2019 +0200 Channel refeed with import table splitting between routes for one prefix commit 5ab3447de18235de566eb5116c0aec24050f5f85 Author: Ondrej Zajicek (work) Date: Wed Aug 21 17:30:00 2019 +0200 Sysdep: Drop supplementary groups when dropping GID We forgot to do that. Oops. commit 4fa0e472cf3e8c61a3f67e91d201dbc12ea94221 Author: Ondrej Zajicek (work) Date: Wed Aug 21 17:16:08 2019 +0200 BGP: Use reallocation for capability structure Instead of having large stack buffer for max amount of AFI/SAFI pairs. The old code is not correct w.r.t. extendeded option length, as more AFI/SAFI pairs may fit into the capability option. commit 524d2538537b2530bf031daa1d5c8e4653f92c5c Author: Ondrej Zajicek (work) Date: Tue Aug 20 19:12:59 2019 +0200 BGP: Implement extended optional parameters length Extends BGP options/capabilities data length to 16bit, to avoid issues with too many capabilities. See draft-ietf-idr-ext-opt-param-07 commit a297a4f044bcc7c38549710a720bc1f97df9ba65 Author: Ondrej Zajicek (work) Date: Tue Aug 13 18:57:40 2019 +0200 Nest: Fix crash in route reload when some channels are not up. Only channels that are up can be reloaded. commit b7d7599ce3576f28310af18b403fed49a0840b67 Author: Ondrej Zajicek (work) Date: Tue Aug 13 18:22:07 2019 +0200 BGP: implement Adj-RIB-Out The patch implements optional internal export table to a channel and hooks it to BGP so it can be used as Adj-RIB-Out. When enabled, all exported (post-filtered) routes are stored there. An export table can be examined using e.g. 'show route export table bgp1.ipv4'. commit dfe63ed84d42178a53b01071c64f23250e74d6d9 Author: Maria Matejka Date: Tue Aug 13 16:45:27 2019 +0200 Filter: Fixing empty block and never-executed-statement bug commit 70a4320bdd44122d7a93bc71c77a9d684b3c9adc Author: Ondrej Zajicek (work) Date: Mon Aug 12 00:41:36 2019 +0200 RAdv: Allow solicited RAs to be sent as unicast Add option to send solicited router advertisements as unicast directly to soliciting nodes instead of as multicast to all-nodes group. commit 9f3e09832081bc029dc98ae6dda49ee86d138fde Author: Ondrej Zajicek (work) Date: Tue Aug 6 18:54:19 2019 +0200 Filter: Allow to use set constants / expressions in path masks Allow to not only use set literals in path masks, but also existing set constants or set expressions. commit ef113c6f725349a2ab52f3cbef18403f82c84134 Author: Ondrej Zajicek (work) Date: Tue Aug 6 16:58:13 2019 +0200 Filter: Allow to use sets in path masks commit e2b530aa729f9c5973e498b45dd6f55ab669d1ac Author: Ondrej Zajicek (work) Date: Tue Aug 6 15:29:06 2019 +0200 BGP: Improve reconfiguration Several BGP channel options (including 'next hop self') could be reconfigured without session reset, with just route refeed/refresh. The patch improves reconfiguration code to do it that way. commit f6a6a77640a9749c79a91300d130ba6b5941d408 Author: Ondrej Zajicek (work) Date: Tue Aug 6 15:09:42 2019 +0200 BGP: Fix 'deterministic med' to work with 'merge paths' The 'deterministic med' option is implemented by suppressing other than best-in-group routes (grouped by ASN) from best route selection. This interferes with 'merge paths' as supressed routes are no longer mergable with best route. This is fixed by suppressing only those routes that are not mergable with best-in-group route. commit 8c42205e35e24537122a4c821bd3128d698abf1b Author: Ondrej Zajicek (work) Date: Tue Aug 6 14:53:02 2019 +0200 Configure: CFLAGS update - add -flto only to default CFLAGS - add -fno-strict-aliasing, -fno-strict-overflow always - remove -Wno-implicit-fallthrough commit cc02da816fb062c93b4f0d61b0cfa02b673a5e00 Author: Ondrej Zajicek Date: Thu Aug 1 14:49:03 2019 +0200 Show LDFLAGS in configure commit 3ffb0c4f25eff926989867b4a7f604f54d68281b Author: Ondrej Zajicek Date: Thu Aug 1 14:45:23 2019 +0200 Enable more threads for flto commit de41d24a3d67c98d7330551bcf7549c007b89ae8 Author: Ondrej Zajicek Date: Thu Aug 1 14:27:20 2019 +0200 Fix output of CFLAGS in configure script commit 543875e080969876c33d365474589899c1f960e3 Author: Ondrej Zajicek (work) Date: Wed Jul 31 23:35:29 2019 +0200 NEWS and version update commit 96e4d0960c2b1bb01dc90ebfe341af8e4284090a Author: Ondrej Zajicek (work) Date: Wed Jul 31 19:45:29 2019 +0200 Change 'graceful down' command to 'graceful restart' and update docs The command initiating planned graceful restart including bird shutdown should be called 'graceful restart' instead of 'graceful down', as the later should be reserved for graceful shutdown in style of RFC 8326. commit 8c703ecf73d7ccbd5e767858ba47a5f3ad0bc439 Author: Ondrej Zajicek (work) Date: Tue Jul 30 19:21:06 2019 +0200 Doc: Update documentation about VRFs and BFD commit 2de1e2062eba66893a36f5a84f922c880ab6c351 Author: Maria Matejka Date: Tue Jul 30 14:28:40 2019 +0200 Conf: Fixed symbol redefinition commit 48addc88be27c46d83805ec2854bf1b5e0f0ddb3 Author: Maria Matejka Date: Tue Jul 30 12:11:49 2019 +0200 Log: Fixed race condition in reconfigure while BFD is running commit 3b62417c356796a35229ce07238abf98fb569ccb Author: Vincent Bernat Date: Mon Jul 29 15:42:30 2019 +0200 RPKI: Fix allocation of hostname when using an IPv6 address commit 00284f0ed67370c7c697adf20b08840482ea18ea Author: Ondrej Zajicek (work) Date: Thu Jul 25 14:24:16 2019 +0200 BFD: Fix formatting of 'show bfd sessions' The formatting was broken due to longer date in 'since' column. commit cec40a74679821513e627f93b924067a404f6475 Merge: 18f70a62 8263690e Author: Ondrej Zajicek (work) Date: Wed Jul 24 15:38:32 2019 +0200 Merge remote-tracking branch 'origin/mq-filter-stack' commit 18f70a6229f586d5e4f387075be42d7a1ef5d269 Author: Ondrej Zajicek (work) Date: Wed Jul 24 15:08:03 2019 +0200 Nest: VRF of protocol can be explicitly specified as 'default' Protocol can have specified VRF, in such case it is restricted to a set of ifaces associated with the VRF, otherwise it can use all interfaces. The patch allows to specify VRF as 'default', in which case it is restricted to a set of iface not associated with any VRF. commit 048c2f0e8cc1451b1fa48e915e0bb5e124aa9d26 Author: Ondrej Zajicek (work) Date: Tue Jul 23 17:02:41 2019 +0200 OSPF: Fix formatting of 'show ospf neighbors' The formatting was broken when too short router-id was used. commit 15b0a9229431dc75425c229b2f94e680db49d594 Author: Ondrej Zajicek (work) Date: Tue Jul 23 01:52:18 2019 +0200 RPKI: Fix reconfiguration when ssh parameters are undefined commit d843c274781bf9d30bfba93229b9f02a88f26fe2 Author: Ondrej Zajicek (work) Date: Thu Jul 18 02:39:35 2019 +0200 Lib: Improve printf() tests Includes patch from Maximilian Eschenbacher commit 39edf4abcafda429f33f98c31ae11bf6a27ab18e Author: Ondrej Zajicek (work) Date: Thu Jul 18 01:57:26 2019 +0200 Lib: Fix print of 64-bit router id Mismatched types to printf(). The old code coincidentally worked on amd64 due to its calling conventions. Thanks to Maximilian Eschenbacher for the bugreport. commit cf7ff99513728e4e405508e5ccd7522289d4ec82 Author: Ondrej Zajicek (work) Date: Wed Jul 17 16:20:35 2019 +0200 BFD: Support for VRFs Allow multiple BFD instances in separate VRFs, dispatch BFD requests according to VRFs. Thanks to Alexander Zubkov for notice and patches. commit 2eaf65ec607b68748744fa8e0d596cf1f3ba117a Author: Ondrej Zajicek (work) Date: Mon Jul 15 18:16:55 2019 +0200 Netlink: Fix parsing of multipath routes with MPLS labels commit 8235c4747dcc92de2ea991f78cdf9c6b8fa7f522 Author: Ondrej Zajicek (work) Date: Mon Jul 15 16:23:18 2019 +0200 Netlink: Use route replace for IPv4 Use route replace netlink op instead of delete+add netlink ops for kernel IPv4 route replace. This avoids some packetloss during route replace. Still use the old behavior for IPv6, as some kernel bugs are hidden in IPv6 ECMP handling. commit 8263690e754a83b8f3c58bd0080a1628d6cba556 Merge: efd7c87b 1aec7112 Author: Maria Matejka Date: Mon Jul 15 16:07:16 2019 +0200 Merge remote-tracking branch 'origin/master' into mq-filter-stack commit efd7c87b5bcd476ba74ffe9f369e2f6fe978cbb1 Author: Maria Matejka Date: Mon Jul 15 15:43:47 2019 +0200 Filter: further split of print & die to FI_PRINT, FI_FLUSH and FI_DIE commit 3782454e8dead1184e698fa84f7491182b54454e Author: Maria Matejka Date: Mon Jul 15 15:23:35 2019 +0200 Filter: Simpler filter context allocation commit f634adc7dcf8cfc2a8ea8a61fe2f85d8aadf5a75 Author: Maria Matejka Date: Mon Jul 15 15:17:04 2019 +0200 Filter: FID_MEMBER debug string is a C constant string commit c0999a149c223fa9c622552a314c767e6a640bf6 Author: Maria Matejka Date: Mon Jul 15 15:12:18 2019 +0200 Filter: Converted FI_PRINT and FI_PATHMASK_CONSTRUCT to VARARG commit c29d73a06a8052f653e85f6472c663f70f6706cc Author: Maria Matejka Date: Mon Jul 15 15:06:52 2019 +0200 Filter: fixed excessive stack allocation in functions with args but no local vars commit 0da06b7103a5601fb7c224ab82a6d3799cb55308 Author: Maria Matejka Date: Mon Jul 15 13:19:01 2019 +0200 Filter: lots of documentation commit 1b9db6d4a7d8ab9f3ada5d21f8f05c3c8bf3c2e2 Author: Maria Matejka Date: Mon Jul 15 12:03:47 2019 +0200 Filter: Don't write out when re-evaluating filter for internal purposes. commit 547be53b8cefc6d346cf13dcedb3e527c3472b06 Author: Maria Matejka Date: Mon Jul 15 12:03:13 2019 +0200 Filter: Don't fail badly when trying to access non-existent route in config time commit 1aec7112f7314c3e9a4d8b9440dd85a782295310 Author: Ondrej Zajicek (work) Date: Wed Jul 10 18:25:36 2019 +0200 OSPF: Fix handling of NSSA option flags Per RFC 3101, N-bit signalling NSSA support should be used only in Hello packets, not in DBDES packets. BIRD since 2.0.4 verifies N-bit in neighbor structure, which is learned from DBDES packets, therefore NSSA-LSAs are not propagated to proper implementations of RFC 3101. This patch fixes that. Both removing the check and removing N-bit from DBDES packet. This will fix compatibility issues with proper implementations, but causes compatibility issues with BIRD 2.0.4. commit bfa15a642f8e262af5c18ba5898597a20bdf4e2f Author: Ondrej Zajicek (work) Date: Wed Jul 10 16:46:31 2019 +0200 Filter: Minor cleanups commit b2a4feeb4c877ff56d9b2ebd8119225c53ea40db Merge: eac9250f 422a9334 Author: Maria Matejka Date: Wed Jul 10 11:27:08 2019 +0200 Merge branch 'master' into mq-filter-stack commit 422a9334294dd9a5b13abd8563a3dc7233e64b13 Author: Maria Matejka Date: Wed Jul 10 11:12:41 2019 +0200 Debug: growing message format buffer This led in corner cases to undefined buffer content and garbage output. commit deb84d79896cca3ac10ff9f853604f845c9420a7 Author: Ondrej Zajicek (work) Date: Tue Jul 9 15:57:46 2019 +0200 OSPF: Minor fix in graceful restart Most LSA origination is blocked in ospf_update_topology(), this fix blocks LSA origination from ospf_rt_spf(). commit e840cb9cd54162efca72137f53fddbb0e490d6fe Author: Vincent Bernat Date: Tue Jul 9 15:25:40 2019 +0200 Doc: Fix typo in BGP dynamic names feature description commit 74a38adb6b4b4bf2a67e7a779a7c95b0ef1b9894 Merge: 1322e205 2872ab92 Author: Maria Matejka Date: Tue Jul 9 14:53:15 2019 +0200 Merge branch 'master' of gitlab.labs.nic.cz:labs/bird commit 1322e205e2066c0da8526bed505dc699d0f5b92a Author: Maria Matejka Date: Fri Feb 8 11:19:04 2019 +0100 Test: Fixed annoying warnings (and possible obscure bugs). commit bb001af0e8022f6445ff50b7f32c9ac102cc244e Author: Maria Matejka Date: Tue Jul 9 14:34:26 2019 +0200 Test: better random u64 generator commit 2872ab927ecb94b1555f5e3c8bd33021261d0c54 Author: Ondrej Zajicek (work) Date: Tue Jul 9 03:48:02 2019 +0200 OSPF: Update DR when local priority changes When priority is reconfigured locally, we need to trigger DR election. (recommiting, was reset by the previous commit) commit 85840d4c03552a69927b666774fa39921e7b1047 Author: Ondrej Zajicek (work) Date: Tue Jul 9 03:31:54 2019 +0200 OSPF: Fix handling of external routes on graceful restart We need to flush learned external LSAs a bit later than other LSAs (after first feed after end of the graceful restart) to avoid flap of external routes. commit 05e3933c06b488e71c9c149c25aec9c733a8bd1f Author: Maria Matejka Date: Mon Jul 8 13:04:50 2019 +0200 Nest: Uninitialized variable fix Thanks to Vincent Bernat for reporting this. commit 2ce25ebbefd2eaf517361a446fe40679e78e23e9 Author: Maria Matejka Date: Mon Jul 8 13:00:13 2019 +0200 Libdmalloc macros fixed commit fa1e0ba35416561bda3708ec808d24641dd8995f Author: Ondrej Zajicek (work) Date: Thu Jul 4 13:34:42 2019 +0200 OSPF: Update DR when local priority changes When priority is reconfigured locally, we need to trigger DR election. commit eac9250fd5b10809830361b94438339b3b31b270 Merge: 8816b6cd 026bfedb Author: Maria Matejka Date: Wed Jul 3 11:09:52 2019 +0200 Merge branch 'master' into mq-filter-stack commit 8816b6cdd98d24535eece6b5e35730aac57cd9f7 Merge: c376555c 84ac62d3 Author: Maria Matejka Date: Wed Jul 3 08:44:42 2019 +0200 Merge branch 'mq-filter-stack' of gitlab.labs.nic.cz:labs/bird into mq-filter-stack commit 84ac62d3967f5294f4dc208b803a273a101744a8 Author: Maria Matejka Date: Wed Jul 3 08:13:07 2019 +0200 Filter: CLI command to dump all the linearized filters commit 0206c070ace90c48a806a74fac52ba6e6ff9858b Author: Maria Matejka Date: Wed Jul 3 01:23:49 2019 +0200 Filter: Split printing and dying commit 3265c9169dfc185ccdb787c6c83d9d8e2d0429c1 Author: Maria Matejka Date: Wed Jul 3 00:04:24 2019 +0200 Removed obsolete comment at as_path_cut() commit 78976974e711e52c3b8fa6a80b290cf2fa4f692d Author: Maria Matejka Date: Wed Jul 3 00:00:11 2019 +0200 Dynamic attributes definition split whether it is bitmask or not. commit 263fa2c4a6bf226172a6aef9a6b8198a5901c5bf Author: Maria Matejka Date: Tue Jul 2 22:57:00 2019 +0200 Filter: Dropped some more irrelevant whitespace from generated files commit 59d3a3611f05c05040cec4bf09f31c26ade0fa0a Author: Ondrej Zajicek (work) Date: Tue Jul 2 18:23:06 2019 +0200 Netlink: Handle alien routes with unsorted nexthops Nest requires that nexthops are sorted, the kernel protocol have to ensure that for alien routes. commit 84c58aabd0d7a6a3d1508de004a29fd22423fde6 Author: Maria Matejka Date: Tue Jul 2 17:59:21 2019 +0200 Filter: Nicer whitespaces in generated inst-gen.h commit 550a6488c9e2241e2979317c04d6d73752618402 Author: Maria Matejka Date: Tue Jul 2 17:39:56 2019 +0200 Filter: documentation of the M4 preprocessor commit 1187627a1dded6a3673c0d43033f431f15cd1b8f Author: Ondrej Zajicek (work) Date: Tue Jul 2 16:30:36 2019 +0200 Netlink: Do unified scan for both IPv4 and IPv6 Instead of separate scans for IPv4, IPv6 and MPLS, do one AF_UNSPEC scan. This also avoids kernel issue when kernel reported IPv4 and IPv6 routes during MPLS scan if MPLS is not active. commit c376555cecbfea83314e9f76bce5002185d3566a Author: Maria Matejka Date: Tue Jul 2 13:13:29 2019 +0200 Filter: GCC, don't complain about indentation in generated code. commit b40c0f028f37086991fefa9197708ba8c7b3d571 Author: Maria Matejka Date: Tue Jul 2 10:45:53 2019 +0200 Filter: Pre-evaluation of constant expressions commit 30667d50417f926fc948905aaab3e679b416b2e1 Author: Maria Matejka Date: Mon Jul 1 14:12:05 2019 +0200 Filter: Resolving of defined constants in config time commit 26bfe59f450c2497dabc536c3e2a604e8aa5839a Author: Maria Matejka Date: Mon Jul 1 13:13:06 2019 +0200 Filter: Moved singleton member definitions to f-inst.c commit 4212c0e7e5647e107e6e06238a417afc44fd7f75 Author: Maria Matejka Date: Mon Jul 1 12:49:02 2019 +0200 Filter: Moved f_inst allocation to separate function commit f74d19765ea3fafdff8fd3443f50a7b309babe89 Author: Maria Matejka Date: Mon Jul 1 12:07:06 2019 +0200 Filter: Getting rid of RESULT_OK. Adding RESULT_VOID. This is a preparation for filter pre-evaluation. commit 236828d06f512b44457970795e44068d9d38ad3e Author: Maria Matejka Date: Mon Jul 1 11:57:35 2019 +0200 Filter: The interpreter code now shares its diversion with constructor This is a preparation for filter pre-evaluation. commit 026bfedb332d8c0dde28c693c177fe993b5df26d Author: Maria Jan Matejka Date: Tue Jun 11 13:19:21 2019 +0000 BGP: Prefix hash is too small, increase its max size. This doesn't make any change for you until you have millions of updates waiting to be sent. Increasing the max hash size from 2^20 to 2^24. commit 9dac814ee89fe41856923a532c87ffd14dbc0f79 Author: Maria Jan Matejka Date: Tue Jun 11 09:35:25 2019 +0000 BGP: split tx explicitly If BGP has too many data to send and BIRD is slower than the link, TX is always possible until all data is sent. This patch limits maximum number of generated BGP messages in one iteration of TX hook. commit bb57d9171f2b4567f54169c8864953c4e5e18025 Author: Ondrej Zajicek (work) Date: Sun Jun 30 22:30:56 2019 +0200 Add mock-up function for unit tests They failed without it. commit 6c0f85d5de1588b6427f6f47c1be4a220799cd70 Author: Ondrej Zajicek (work) Date: Sun Jun 30 22:11:11 2019 +0200 Doc: OSPF graceful restart options commit 1a2ad348f660b150265f6df759a07de8a2b6de2f Author: Ondrej Zajicek (work) Date: Sun Jun 30 20:12:59 2019 +0200 OSPF: Support for graceful restart Implement OSPFv2 (RFC 3623) and OSPFv3 (RFC 5187) graceful restart, for both restarting and helper sides. Graceful restart is initiated by 'graceful down' command. commit 8a68316eb96be1fecf91ca395f3321aa99997ad2 Author: Ondrej Zajicek (work) Date: Tue Jun 18 16:27:21 2019 +0200 Nest: Add command to request graceful restart When 'graceful down' command is entered, protocols are shut down with regard to graceful restart. Namely Kernel protocol does not remove routes and BGP protocol does not send notification, just closes the connection. commit 63f49457dcc4216002742166dfecce751efa78d5 Author: Maria Matejka Date: Fri Jun 28 11:08:48 2019 +0200 Filter: renaming pointers for consistency The struct f_inst * is now always "what" and the union member pointer is always "whati". commit 64bb1346c71cbd2764b1e0a00dc88290bec72a5a Author: Maria Matejka Date: Thu Jun 27 15:55:48 2019 +0200 Filter: A little cleanup of M4 interpreter generator commit a8ab54d18d3af8e7dc9811ab8e3ba9a105131a25 Merge: 63e76204 2e077731 Author: Maria Matejka Date: Tue Jun 25 22:40:05 2019 +0200 Merge remote-tracking branch 'refs/remotes/origin/mq-filter-stack' into mq-filter-stack commit 63e7620462b80c9c6bbbd4f128b6816e0748d6c6 Author: Maria Matejka Date: Tue Jun 25 16:18:06 2019 +0200 Conf/Filters: Moved argument count to conf scope commit 2e0777317f373921487d80e88c376d23a842ba2c Author: Maria Matejka Date: Fri Jun 21 11:33:28 2019 +0200 Filter instructions don't confuse now v1 and res. commit a84b8b6ebb2b6825b7059e34cfaafe405ab0117e Author: Maria Matejka Date: Wed Jun 19 14:09:57 2019 +0200 Revert "Filter: Dropped the setter instructions in favor of direct result storage." This reverts commit bd91338246c1ba40358243f1bdf5a6dbd3a29f35. commit 5c864e2cfaf5ff5e8e3db3ccd746162fbc7aac5b Author: Maria Matejka Date: Thu Jun 13 14:27:58 2019 +0200 String: bstrtoul macro expanded to bstrtoul10 and 16 commit 87c82334a77dfa3fea3057fa6d4bcf8558f203a4 Author: Maria Matejka Date: Thu Jun 13 14:24:48 2019 +0200 Filter: removal of semantically insane consts in filter_commit commit bdf2e55d98636eacaac8188ee0bd000cc10d217c Author: Ondrej Zajicek (work) Date: Wed Jun 12 18:02:01 2019 +0200 Add mock-up function for unit tests They failed without it. commit 9106a750cd76d4a76c7a60294ce3a43eede166c9 Author: Ondrej Zajicek (work) Date: Wed Jun 12 16:13:21 2019 +0200 Add CLI command to test reconfiguration status Based on patch from Kenth Eriksson . commit 8a2cbb88d1657b4aee366605cb3d8ffcc5d3f90a Author: Kenth Eriksson Date: Wed Jun 12 15:03:37 2019 +0200 BIRD coding conventions Added Emacs config file describing BIRD coding conventions, as suggested by Kenth Eriksson based on existing practice. commit d35fb9d732b05f20a556e9bda798939358459975 Author: Ondrej Zajicek (work) Date: Wed Jun 12 16:35:42 2019 +0200 BGP: Fix bug introduced in one of last patches commit bd91338246c1ba40358243f1bdf5a6dbd3a29f35 Author: Maria Matejka Date: Fri May 31 17:33:41 2019 +0200 Filter: Dropped the setter instructions in favor of direct result storage. This should help filter performance a bit. commit aa6c5f4d92f225452e432991671e7bdad185506a Author: Maria Matejka Date: Thu May 30 14:42:54 2019 +0200 Filter: Just a little comments in filter structure commit 1757a6fce5bd23c44cc5b72a042644c4abb744c8 Author: Maria Matejka Date: Wed May 29 21:03:52 2019 +0200 Filter: Stacks moved to thread-local storage if available. commit 6479e403ef7398f48c0e1c0f1a71aa112938a357 Author: Jan Maria Matejka Date: Thu May 23 11:27:24 2019 +0000 Filters: If somebody doesn't like _Thread_local, don't fail for now, just be a little slower. When the parallel execution comes into place, we'll likely enforce this C11 feature. It's much simpler and also faster than pthread_[sg]etspecific(). commit 23e3b1e6652bac4a003a7eb1e074bdaf7ebb4900 Author: Jan Maria Matejka Date: Wed May 22 15:16:32 2019 +0000 Filter: Some people can't pronounce "postfixify" correctly. Let's try "linearize" instead. This is just a naming change. commit 96d757c13fe4b2e21b265275af9ac7d1e2c3f075 Author: Jan Maria Matejka Date: Tue May 21 16:33:37 2019 +0000 Filter: Store variables and function arguments on stack commit 20c6ea70ccb69f3c1d9ca46cc7941eb686f283c6 Author: Jan Maria Matejka Date: Mon May 20 17:53:10 2019 +0000 Filter: Making the filter state thread local. While having the filter code still reentrant if we really need, the compiler can now do constant propagation and address the thread local storage directly to save some computation time. commit 9eef9c648cee7179e069ea1f978d4e86cef580d3 Author: Maria Matejka Date: Fri May 17 22:18:49 2019 +0200 Lexer now returns known sym / unknown sym / keyword commit dbbe4a783b3d4e7722bcb466673f8a1d2832fc7b Author: Ondrej Zajicek (work) Date: Tue Apr 30 16:16:50 2019 +0200 Doc: Dynamic BGP commit 7ff34ca2cb86f3947bf049f73e76e6ce5d57e4a8 Author: Alexander Azimov Date: Tue Apr 30 13:55:43 2019 +0200 BGP: Compliance with RFC8203bis commit 0b1e1e1a007f860230855d0c9e8adc88969ee077 Author: Ondrej Zajicek (work) Date: Tue Apr 30 13:44:11 2019 +0200 BGP: Output Local AS number in show protocol Useful for implementation of agents implementing the SNMP-BGP MIB, which requires the local AS of a session to be specified. Thanks to Jan-Philipp Litza for the patch. commit e0835db4f137c1686c26165053ec9c0578b94009 Author: Ondrej Zajicek (work) Date: Mon Apr 8 17:05:07 2019 +0200 BGP: Dynamic BGP Support for dynamically spawning BGP protocols for incoming connections. Use 'neighbor range' to specify range of valid neighbor addresses, then incoming connections from these addresses spawn new BGP instances. commit df092aa1def0419da74f15bd20582fab4ec09207 Author: Ondrej Filip Date: Wed Apr 24 13:49:18 2019 +0200 Small type in doc. commit 6ff811976513132c831a352bd0aa0f3600252acb Author: Ondrej Zajicek (work) Date: Fri Apr 12 14:11:23 2019 +0200 OSPFv3: Fix some overlooked cases in IPv4 mode Prefixes with max length (/32) were not handled properly. Thanks to bauen1 for the bugreport. commit 4a50c8bd0310053a3dcab45c8dde0362348c0503 Author: Ondrej Zajicek (work) Date: Mon Apr 8 16:39:22 2019 +0200 BGP: Handle corner cases in event ordering When BGP connection is opened, it may happen that rx hook (with remote OPEN) is called before tx hook (for local OPEN). Therefore, we need to do internal changes (like setting local_caps) synchronously with OPENSENT transition and we need to ensure that OPEN is sent before KEEPALIVE. commit 23ee6b1cd6dc597876d91db9a015f7a633764808 Author: Ondrej Zajicek (work) Date: Wed Apr 3 15:54:50 2019 +0200 BGP: Promiscuous ASN mode Allow to specify just 'internal' or 'external' for remote neighbor instead of specific ASN. In the second case that means BGP peers with any non-local ASNs are accepted. commit a22c3e59683d0ea6c379a37f990e74a6d281ccef Author: Ondrej Zajicek (work) Date: Tue Apr 2 17:22:31 2019 +0200 BGP: Separate runtime and config usage of local/remote ip and as fields commit fe503c7c0632b385222c92b85d04526fdf36a1a3 Author: Maria Matejka Date: Sat Mar 23 13:32:14 2019 +0100 Filter: fixed error-checking bug in !~ operator commit 7078aa63ae498b55c729df4a075eb28019917e81 Author: Maria Matejka Date: Fri Mar 22 21:40:35 2019 +0100 Fixed one warning and one undefined value. commit 2ab680c6972306db71d9a8d4ee4fabf265981d30 Author: Maria Matejka Date: Wed Mar 20 16:50:58 2019 +0100 Fixed an undefined symbol bug in CLI introduced by filter refactoring commit 3a22a6e858cd703d254ab331183ccd56fe195c6b Author: Ondrej Zajicek (work) Date: Tue Mar 19 19:38:32 2019 +0100 Doc: Route attribute cleanups commit 3c3605818fb304f8de6975c56096bfafa43a8b6b Author: Ondrej Zajicek (work) Date: Tue Mar 19 17:44:50 2019 +0100 BGP: Mandatory option for channels Allow to mark channel to be mandatory, and do not allow BGP sessions if no common AFI/SAFI is established. commit 7e5f769d91319b4130f7d611dd14252806892ace Author: Ondrej Zajicek (work) Date: Fri Mar 15 20:54:01 2019 +0100 BGP: Handle case where capabilites are not used If peer does not announce capabilities at all, or when we have capabilities disabled, handle that as implicit IPv4 unicast. commit 8d65add626b34256879a3e83855af3c0fa8ce4e7 Merge: 2f02c25e 5d511948 Author: Maria Matejka Date: Mon Mar 18 12:54:40 2019 +0100 Merge branch 'master' into HEAD commit 5d511948cddee415c2f0f1103bda0468a193f2d6 Author: Maria Matejka Date: Fri Mar 15 15:07:00 2019 +0100 Build: Automatic dependency tracking for generated files commit 2f02c25e36f3946019c24dafe9b894a9e195350d Author: Maria Matejka Date: Thu Mar 7 18:02:05 2019 +0100 Perf: fixed stupid allocation bug commit d638c1794a48dec79fa0a6c118296356754a134d Author: Maria Matejka Date: Wed Mar 6 21:45:28 2019 +0100 Gitlab CI: Drop CentOS 6 test build as unsupported. If someone wants to maintain BIRD for CentOS 6, feel free to send patches. commit 875cc073b067f295cccc668008e10218f8e98dd3 Author: Ondrej Zajicek (work) Date: Thu Mar 14 17:22:22 2019 +0100 Nest: Update handling of temporary attributes The temporary atttributes are no longer removed by ea_do_prune(), but they are undefined by store_tmp_attrs() protocol hooks. This fixes several bugs where temporary attributes were removed when they should not or not removed when they should be. The flag EAF_TEMP is no longer needed and was removed. Update all protocol make_tmp_attrs() / store_tmp_attrs() hooks to use helper functions and to handle unset attributes properly. Also fix some related bugs like improper handling of empty eattr list. commit 9aa77fccebc4d84b5e1496884cd124d09893041b Author: Ondrej Zajicek (work) Date: Wed Mar 6 18:14:12 2019 +0100 OSPF: Improved handling of tmpattrs Keep track of whether OSPF tmpattrs are actually defined for given route (using flags in rte->pflags). That makes them behave more like real eattrs so a protocol can define just a subset of them or they can be undefined by filters. Do not set ospf_metric2 for other than type 2 external OSPF routes and do not set ospf_tag for non-external OSPF routes. That also fixes a bug where internal/inter-area route propagated from one OSPF instance to another is initiated with infinity ospf_metric2. Thanks to Yaroslav Dronskii for the bugreport. commit e1ac6f1e301416037725b631fd6529a805e65d51 Author: Maria Matejka Date: Wed Mar 6 15:01:10 2019 +0100 Faster filters: documentation on what is happening there commit a68442e0563f5b756f9a7323cea44a25ce048738 Author: Maria Matejka Date: Wed Feb 27 14:40:05 2019 +0100 Fixed link time optimizer check for FreeBSD commit b9deced219cfda2afe8604b24351ae10ac56f98b Author: Ondrej Zajicek (work) Date: Tue Feb 26 18:19:35 2019 +0100 NEWS and version update commit f249d0b84c840242a084966999a1d228c603b431 Author: Maria Matejka Date: Tue Feb 26 16:44:24 2019 +0100 Filters: comparison of functions and filters caching commit 0d12aa48363802e751d3b9a4afd6eb090592d7a3 Author: Maria Matejka Date: Tue Feb 26 16:11:40 2019 +0100 Build: No link time optimization when debug is enabled commit 2915e711f77d68dff756babd19af8da1677c4549 Author: Maria Matejka Date: Mon Feb 25 23:28:36 2019 +0100 Custom number parser to speed up config parsing The glibc's generic parser is slow due to its versatility. Specialized parsers for base-10 and base-16 are much faster and we don't use other bases. commit 99911873a196975f5221aad89ae5eac42e1330e0 Author: Maria Matejka Date: Mon Feb 25 17:19:47 2019 +0100 Conf: Lexer parses quoted strings in a more descriptive way commit 7c36eb3e8bd7d06f65dc7319d42b6abe782c5b89 Author: Maria Matejka Date: Fri Feb 22 12:41:51 2019 +0100 Conf: Switch for faster (and slightly bigger) lexer commit 412614c700085ac964b07ff9405403eaf02fa5b4 Author: Maria Matejka Date: Fri Feb 22 12:41:51 2019 +0100 Conf: Switch for faster (and slightly bigger) lexer commit 93af78d2d29ce11e20d46f60cfe1d3ef68052e5c Author: Ondrej Zajicek (work) Date: Fri Feb 22 02:16:39 2019 +0100 Nest: Do not compare rte.flags during rte_update() Route flags are mosty internal state of rtable, they are not significant to whether a route has changed. With the old code, all routes received as a part of enhanced route refresh are always re-announced to other peers due to change in REF_STALE. commit ad702bae0ce95ee1913327dd13a877e6bf9b320d Author: Maria Matejka Date: Wed Feb 20 22:14:28 2019 +0100 Enabled link time optimization. commit d1039926f5ee5a4e0442919474f16f3c93385cc9 Author: Maria Matejka Date: Tue Feb 19 12:34:16 2019 +0100 Filter: Interpreter merged into the common m4 generator. The config-time partial evaluation of constant expressions in filters is nearby. commit 32793ab685b047b553d6f7afc23b3245e8850e4a Author: Maria Matejka Date: Mon Feb 18 14:57:15 2019 +0100 Filter: Fixed bugs in FI_CALL and FI_SWITCH commit d348a916f57cb0ac390718295624dd9a1cf2d32a Author: Maria Matejka Date: Mon Feb 18 14:56:49 2019 +0100 Test: Added -d flag to die directly after first error. commit d4bf74816faf9955297f93f8bb6973c1f600dbe2 Author: Maria Matejka Date: Mon Feb 18 14:56:10 2019 +0100 GDB: Added more pretty printers for filters commit ea4f55e3dcd472bb6d18c030839597ffd9583462 Author: Maria Matejka Date: Fri Feb 15 23:59:44 2019 +0100 Filter: More cleanup -- customized structures also in struct f_line_item commit 0b39b1cbb70c6f37a30a3130e1c308ddd0ba36de Author: Maria Matejka Date: Fri Feb 15 13:53:17 2019 +0100 Conf: Symbol implementation converted from void pointers to union ... and consted some declarations. commit 132529ce8908661fd2baa0758c335006fb039ef0 Author: Maria Matejka Date: Wed Feb 13 12:25:30 2019 +0100 Filter: merged filter compare functions into common M4 file commit dd4d409551ae22d0a9bf4e3a6edc6fb9656911b9 Author: Maria Matejka Date: Tue Feb 12 20:37:32 2019 +0100 Filter: Merged postfixify routine commit de12cd18fb213ee9cc872fec77b789f34cfd7cc4 Author: Maria Matejka Date: Tue Feb 12 14:16:28 2019 +0100 Filter: Merged filter line item dumpers into common generated source commit b256f241459c51224a4bf428f4bc5dfa44882920 Author: Maria Matejka Date: Tue Feb 12 11:35:41 2019 +0100 Filter: auto-generating enum-to-string commit 041608129ab15b5eab6fb607c45ddd2d748295b5 Author: Maria Matejka Date: Tue Feb 12 11:31:18 2019 +0100 Filter generator: workaround for M4 claiming all the put-around code be on one line commit 5289304519918f62d099463123bf6c69a0dd497e Author: Maria Matejka Date: Mon Feb 11 17:12:48 2019 +0100 Filter data manipulation functions separated to their file commit 87bd7cd7b03f24c9d7c37a2a060ef553f26ead29 Author: Maria Matejka Date: Mon Feb 11 16:44:14 2019 +0100 Filter: split the constructors to a separate file commit 75206f266f8534367b88401be463953b7d5dc770 Author: Maria Matejka Date: Mon Feb 11 15:27:47 2019 +0100 Conf: Fixed makefiles commit 4f082dfa892e95f86ca8137410992a248110b6ef Author: Maria Matejka Date: Fri Feb 8 13:38:12 2019 +0100 Filter: merged filter instruction constructors, counting line size on instruction construct commit 0a793ebc6059f4354c62ccec62ef7c950988ca4a Author: Maria Matejka Date: Fri Feb 8 11:19:04 2019 +0100 Test: Fixed annoying warnings (and possible obscure bugs). commit 8bdb05edb2b4e1d2989ed98d67992047ad69443c Author: Maria Matejka Date: Thu Feb 7 21:25:38 2019 +0100 Filters: split the large filter.h file to smaller files. This should be revised, there are still ugly things in the filter API. commit c1e97169cd96ce39337e75cfdf6882b180341f09 Author: Maria Matejka Date: Wed Feb 6 14:41:39 2019 +0100 Filter: M4 convertors polished a bit. commit c0e958e022aac79f69e6aca2652fdb6a529e68e2 Author: Maria Matejka Date: Wed Jan 30 14:03:47 2019 +0100 Filter + Config: Fix bugs, tests and split symbols by type commit 713658798dfafabcd0a74f510c1639f6e3c9c820 Author: Maria Matejka Date: Wed Jan 23 17:08:27 2019 +0100 GDB pretty printers: f_inst and f_val. commit 9b46748d5b50d1e8c242a571e80fe1f9f33aeb73 Author: Maria Matejka Date: Mon Jan 21 09:17:54 2019 +0100 Filter: refactoring of instruction constructors commit 4c553c5a5b40c21ba67bd82455e79678b204cd07 Author: Maria Matejka Date: Thu Dec 27 14:26:11 2018 +0100 Filter refactoring: dropped the recursion from the interpreter This is a major change of how the filters are interpreted. If everything works how it should, it should not affect you unless you are hacking the filters themselves. Anyway, this change should make a huge improvement in the filter performance as previous benchmarks showed that our major problem lies in the recursion itself. There are also some changes in nest and protocols, related mostly to spreading const declarations throughout the whole BIRD and also to refactored dynamic attribute definitions. The need of these came up during the whole work and it is too difficult to split out these not-so-related changes. commit 967b88d9388b3800efed45798542cd0b41f2b903 Author: Maria Matejka Date: Thu Dec 20 16:25:54 2018 +0100 Filter refactoring: The instructions are converted to the switch body by M4 commit 8436040735b84bb185311125bfc91375f740fd86 Author: Maria Matejka Date: Thu Dec 20 16:07:59 2018 +0100 Filter refactoring: Drop the roa check specific f_inst commit ca2ee91a80aa87b7f18898c28e93ff22cebf73d7 Author: Maria Matejka Date: Thu Dec 20 15:25:04 2018 +0100 Filter refactoring: The constant f_val is simply included inside the instruction With 32 bits, size of the args is 12 bytes, the f_val is 20 bytes. With 64 bits, size of the args is 24 bytes, the f_val the same. This is not so nice on 32 bits, anyway the f_inst itself is 24 vs. 32 bytes and the overall size of filters must be 32k of instructions to get to one megabyte of RAM eaten by f_inst. Therefore it seems to be improbable for common user to get into problems with this change. commit 7f0ac73724f7383a2bcc229910414d339dbd2434 Author: Maria Matejka Date: Thu Dec 20 14:55:40 2018 +0100 Filter refactoring: Changed arguments from separate unions to an array commit 224b77d4f786ea09bb2632476a89f0976baafd64 Author: Maria Matejka Date: Thu Dec 20 14:34:35 2018 +0100 Filter refactoring: Converted condition to three-args instruction commit 8e8b1fe48cfcb92d54e15df5198e8cef9bc3dd8e Author: Maria Matejka Date: Thu Dec 20 14:29:47 2018 +0100 Filter refactoring: Some instructions eat up excessively much space. commit c577493908a9cda9008cc4043d0473b69fb2da66 Author: Maria Matejka Date: Thu Dec 20 14:05:32 2018 +0100 Filter refactoring: Expanded the short instructions with common code. This will make the further changes more straightforward. commit a8740d6c09547dd9fe445b3deb5238305c0a5959 Author: Maria Matejka Date: Tue Dec 18 17:10:05 2018 +0100 Filter refactoring: indentation fix commit fc8df41ec6cd5e6e3d53036a97dc7219dbbade5e Author: Jan Maria Matejka Date: Mon Dec 17 15:00:01 2018 +0100 Filter refactoring: The values are now saved on a custom stack. This shall help with performance. commit 7afa1438866fa94454ba133608b6877171f71d37 Author: Jan Maria Matejka Date: Mon Dec 17 13:51:11 2018 +0100 Filter refactoring: Passing the resulting struct f_val as a pointer. This also drops the multiplexing of errors with the f_val itself together with the T_RETURN f_val type flag. commit f62a369fb48be066560d6e8f0df82eef9c464ef0 Author: Jan Maria Matejka Date: Mon Dec 17 13:08:08 2018 +0100 Filter refactoring: Moved filter instruction definition to a separate file commit 25566c68109381178e0305f3e7e1464dea15b90b Author: Jan Maria Matejka Date: Mon Dec 17 12:58:01 2018 +0100 Filter refactoring: Moved the bitfield bit position formula to route.h commit aca8263926df6156322e1a1157886f1cad2486b1 Author: Jan Maria Matejka Date: Mon Dec 17 12:48:33 2018 +0100 Filter refactoring: Moved the interpret macros inside the block commit 02dcbf343d94dd548605c5efbf724f89d81d7258 Author: Jan Maria Matejka Date: Mon Dec 17 12:45:21 2018 +0100 Configure: Don't check for implicit fallthrough unless when debugging. commit a946317fab9776754192f679f38cb7789050c52d Author: Jan Maria Matejka Date: Tue Feb 27 15:39:39 2018 +0100 Filter: Converted static global variables to a filter_state struct. The static filter state was messy and blocked the planned parallel execution of filters. Anyway, this will be also slower as the state structure must be passed almost everywhere with us. commit ae294cc2d02ec02cbea11c275b64e7637ba0ea68 Author: Ondrej Zajicek (work) Date: Tue Feb 19 18:30:28 2019 +0100 HTML are no longer generated in srcdir commit 900fda4411a5346f808a575101b1260b5f73fa93 Author: Ondrej Zajicek (work) Date: Tue Feb 19 18:20:07 2019 +0100 Doc: Detect SP/OpenSP automatically commit 3a8ca7abbcf6452fa56d0c1c6ddcf7d5bd6876ed Author: Ondrej Zajicek (work) Date: Tue Feb 19 16:26:09 2019 +0100 Nest: Prevent withdraws from propagation back to source protocol (for accepted mode) Update for one of previous patches, handles the the issue for first-accepted mode of route propagation. commit bf8d7bba9ef3c6d95661f97dc71fa7a6b2cf0b87 Author: Ondrej Zajicek (work) Date: Sun Feb 17 01:54:01 2019 +0100 OSPF: Reset LSAs during area type change When area is reconfigured to a different type, we need to flush LSAs as they may not be valid (e.g. NSSA-LSA for non-NSSA area). Also, when we have have just one OSPF area and that changes type, we could restart OSPF as there is no state to keep anyway. That solves issue with different handling of external routes exported to OSPF based of main area type. commit 4a3f5b36173299d44e26dc18db4e5d103875f8c4 Author: Ondrej Zajicek (work) Date: Wed Feb 13 15:40:22 2019 +0100 OSPF: Basic support for DN-bit handling (RFC 4576) External LSAs originated by OSPF routers with VPN-PE behavior enabled are marked by DN flag and they are ignored by other OSPF routers with VPN-PE enabled. commit 1e958e52d3ef0c38e5fb5e673bcce95d1c28ac0e Author: Ondrej Zajicek (work) Date: Sat Feb 9 16:15:01 2019 +0100 OSPF: Do not originate Router-Information LSA As we do not have much usage for it yet. commit cd16538fc91778e31f8241f62ee47056f099c051 Merge: 6e8fb668 f9b97f1c Author: Ondrej Zajicek (work) Date: Sat Feb 9 15:53:16 2019 +0100 Merge remote-tracking branch 'origin/mq-opt' commit 6e8fb66859a17b295cd9246264221a75cdbe6c55 Author: Ondrej Zajicek (work) Date: Tue Feb 5 19:00:43 2019 +0100 Nest: Improve export counter handling One of previous workarounds for phantom route avoidance breaks export counters by expanding sending of spurious withdraws, which are send when we are not sure whether we have advertised that routes in the past. If not, then export counter is decreased, but it was not increased before, so it overflows under zero. The patch fixes that by sendung spurious withdraws, but not counting them on export counter. That may lead to error in the other direction, but that happens only as a race condition (i.e., in normal operation filters return proper values about old route export state). commit 52fdd1cb76be1e278799001fa57f56888062dd86 Author: Ondrej Zajicek (work) Date: Tue Feb 5 15:59:26 2019 +0100 Nest: Report preferred counters also when 'import keep filtered' is enabled Thanks to Michal Nowak for reporting the issue. commit a9b97cbcb74d918f3f606eb87a506712dccd2832 Author: Ondrej Zajicek (work) Date: Sun Feb 3 20:22:40 2019 +0100 OSPF: Send direct acknowledgements as unicast Direct acknowledgements should be send as unicast to a corresponding neighbor. Only delayed acks should be send as multicast to all/designated routers. commit 16605f2fdad730b8bb570e17192dc5f45cf15d3f Author: Ondrej Zajicek (work) Date: Sun Feb 3 17:31:27 2019 +0100 OSPF: Reject duplicate DBDES packets after dead interval Master may free last DBDES packet immediately. Slave must wait dead interval before freeing last DBDES packet and then reject duplicate DBDES packets with SeqNumberMismatch. commit 9c94583a3ded3b2792bd08d88beb10100a82d7b4 Author: Ondrej Zajicek (work) Date: Sun Feb 3 16:20:37 2019 +0100 OSPF: DD seqnum should be initialized only for first attempts After SeqNumberMismatch/BadLSReq, we should continue with the old seqnum++. The old code tries to do that by n->adj, but it was set nowhere. commit 267da8138d7f429941f2d829b44cf9bdd94a14d6 Author: Ondrej Zajicek (work) Date: Sun Feb 3 15:45:43 2019 +0100 OSPF: Reject DBDES packets with non-matching MTU As it is specified in RFC 2328. The old code just provided warning. commit e1c275d87b26f35c29ec8bfab0a3265810463574 Author: Ondrej Zajicek (work) Date: Sat Feb 2 13:28:16 2019 +0100 Nest: Reestablish preferred counters commit f9b97f1c6282be398d2c2bb896dbb453f638f720 Author: Maria Matejka Date: Fri Feb 1 14:09:01 2019 +0100 Perf: Added forgotten all-protocol options commit a8d0f2516c1ee0372edfc607832ae78632e404ca Author: Maria Matejka Date: Tue Jan 29 15:19:06 2019 +0100 Nest: FIB rehash values tweaked for better performance commit e85e37d91d0c5fca6cb7a3ea80fac582074c389d Author: Maria Matejka Date: Tue Jan 29 14:22:55 2019 +0100 Perf: Prune the table after every loop to have clean state. commit 7411b694c3ca9db4947f577f826b622ff23e570d Author: Maria Matejka Date: Thu Jan 31 15:03:43 2019 +0100 Perf: Write also BIRD version to have all the needed data in the logfile commit c65a9a05f9005d8b7369d07a3f0e99b2f205955b Author: Maria Matejka Date: Thu Jan 31 15:02:15 2019 +0100 Nest: Don't lookup net in table before filters are run. Using dummy net instead. This should help with performance on rejected routes. commit e84c81b76ff6af88041b55c4ed25c208f78d4826 Author: Ondrej Zajicek (work) Date: Wed Jan 30 17:25:21 2019 +0100 Nest: Prevent withdraws from propagation back to source protocol The earlier fix loosen conditions for not running filters on old route when deciding about route propagation to a protocol to avoid issues with ghost routes in some race conditions. Unfortunately, the fix also caused back-propagation of withdraws. For regular updates, back-propagation is prevented in import_control hooks, but these are not called on withdraws. For them, import_control hooks are called on old routes instead, changing (old, NULL) notification to (NULL, NULL), which is ignored. By not calling export processing in some cases, the withdraw is not ignored and is back-propagated. This patch fixes that by contract conditions so the earlier fix is not applied to back-propagated updates. commit ee95f281f038684a4a2613a0c54af7389afe64da Author: Ondrej Zajicek (work) Date: Sat Jan 26 21:02:35 2019 +0100 Doc: Add documentation for OSPF retransmit delay option Thanks to Igor Podlesny for notification. commit 1c730ee761b3c9b7ff12a0ad11c5b1768d1e4ada Author: Ondrej Zajicek (work) Date: Sat Jan 26 20:44:37 2019 +0100 Doc: Remove doc for already removed option commit b8a3608aa59a67364f05dbd0d0332371a200f226 Author: Ondrej Zajicek (work) Date: Sat Jan 26 19:48:16 2019 +0100 BGP: Cleanup channels when going down When going up, uncleaned old channel state may trigger unexpected conditions crashing bird. commit 5a50a98980a3554b66cedda6992ece4063a0e85a Author: Ondrej Zajicek (work) Date: Thu Jan 24 22:34:33 2019 +0100 OSPF: Opaque LSAs and Router Information LSA Add support for OSPFv2 Opaque LSAs (RFC 5250) and for Router Information LSA (RFC 7770). The second part is here mainly for testing opaque LSAs. commit 954888859969587a288501b6801ab0ddb1f94133 Author: Jan Maria Matejka Date: Fri Dec 14 16:10:19 2018 +0100 Nest: Don't make tmp_attr before preexport is called commit 3e60932a289e55e212dec1cbaf3bca44b2bbaeb8 Author: Ondrej Zajicek (work) Date: Sat Jan 5 00:38:37 2019 +0100 NEWS and version update commit d7e8f00e7e35daff9bcf96aa455ebc6f932d0882 Author: Ondrej Zajicek (work) Date: Fri Jan 4 23:49:26 2019 +0100 Unix: Remove removed option from help Also includes minor cleanup of help. commit a1ee5eb2aae1f5e78909b36c979fd689ba319bbd Author: Ondrej Zajicek (work) Date: Fri Jan 4 17:03:48 2019 +0100 BSD: Fix TCP-MD5 code on current FreeBSD kernels Current FreeBSD kernels require SA records for both directions. Thanks to Joseph Mulloy and Andrey V. Elsukov for reporting and solving the issue. commit 4d9049dc1a57ccbf0ff9fa2642282a30e875e9e1 Author: Ondrej Zajicek (work) Date: Thu Jan 3 17:11:56 2019 +0100 Doc: README and INSTALL update Minor cleanups, updates and clarifications. Also removes (incomplete and well-known) build steps from README, as they are better described in INSTALL. commit 470740f97bfa61c3c5c79d6f2d92f2014a119031 Author: Ondrej Zajicek (work) Date: Wed Jan 2 16:01:21 2019 +0100 BGP: Better dispatch of incoming connections Since v2 we have multiple listening BGP sockets, and each BGP protocol has associated one of them. Use listening socket that accepted the incoming connection as a key in the dispatch process so only BGP protocols assocaited with that listening socket can be selected. This is necesary for proper dispatch when VRFs are used. commit e16b0aef31adf7000c22430adc3ceb9fc969ae14 Author: Ondrej Zajicek (work) Date: Wed Jan 2 15:57:14 2019 +0100 BGP: Postpone setting link_addr It may happen that the LLv6 address for given iface is not defined during BGP start, so we postpone the check to the the session establishment. commit 4659b2ae45672868646900c81c963da221363b40 Author: Arthur Gautier Date: Fri Dec 28 19:38:18 2018 +0100 KRT: Fix debug messages in netlink code commit c2d29dd197cbff6c143a570576c81bee20fc06eb Author: Ondrej Zajicek (work) Date: Tue Dec 18 19:16:23 2018 +0100 IO: Workaround for broken FreeBSD behavior FreeBSD silently changes TTL to 1 when MSG_DONTROUTE is used, even when it is explicitly set to another value. That breaks TTL security sockets, including BFD which always uses TTL 255. Bad FreeBSD! commit 82b742533bdbf977ec95997fc0011a47a672bcc8 Author: Maria Matějka Date: Fri Oct 26 09:32:35 2018 +0200 Perf: Protocol to measure BIRD performance internally This protocol is highly experimental and nobody should use it in production. Anyway it may help you getting some insight into what eats so much time in filter processing. commit 78131eee64aeaf14cf418d6e5bf3f17ca602afb7 Author: Jan Maria Matejka Date: Fri Dec 14 15:50:44 2018 +0100 Debug: support for -gdwarf-4 is not available everywhere commit bda5863425854cc1c705c6f428e952bafd01d2a1 Author: Ondrej Zajicek (work) Date: Tue Dec 18 14:41:12 2018 +0100 Nest: Handle labels_orig correctly in attribute cache commit cea2e25f417866129ce7e78f1c078e993743173c Author: Ondrej Zajicek (work) Date: Mon Dec 17 17:01:08 2018 +0100 OSPF: Fix wrong LSA collisions detection In some circumstances (old LSA flushed but not acknowledged and not removed) origination of a new LSA may wrongly triggers LSA collision code. The patch fixes that. Thanks to Asbjorn Mikkelsen for the bugreport and @mdelagueronniere for the original patch. commit 1cab2b4a7cffb7ad604dcbd200267733ef079973 Author: Ondrej Zajicek (work) Date: Sun Dec 16 23:44:24 2018 +0100 BGP: Extend 'next hop keep' and 'next hop self' options Extend 'next hop keep' and 'next hop self' options to have boolean values (enabled / disabled) and also values 'ibgp'/ 'ebgp' to restrict it to routes received from IBGP / EBGP. This allows to have it enabled by default in some cases, matches features of other implementations, and allows to handle some strange cases like EBGP border router with 'next hop self' also doing IBGP route reflecting. Change default of 'next hop keep' to enabled for route servers, and 'ibgp' for route reflectors. Update documentation for these options. commit 337165959c5a556d6556fb2acbba5e7f2b1c35a5 Author: Ondrej Zajicek (work) Date: Sun Dec 16 23:39:53 2018 +0100 Nest: Fix handling of ECMP next hop flags Flag field was not copied when next hop was cached. commit cfa6ff95695bcaff0c1046c63eb4a839c7a90cb7 Author: Ondrej Zajicek (work) Date: Sun Dec 16 22:48:13 2018 +0100 Nest: fix bug in previous patches related to channel reconfiguration The patch d506263d... blocked adding channel during reconfiguration, that broke protocols which use the same functiona also during init. This patch fixes that. commit cb311b441a6bbc02e88cd4a92e19044e2e95aac2 Author: Ondrej Zajicek (work) Date: Sat Dec 15 14:01:57 2018 +0100 BGP: Better handling of non-matching AFI in nexthops commit 3a2a3c7325b34923c4ecc465700708dd13e6ad73 Author: Ondrej Zajicek (work) Date: Fri Dec 14 02:03:42 2018 +0100 Doc: Rename code documentation files back to Doc commit 1e0fccd1af54fdd4dbd79f6e7c5715478f83dea3 Author: Ondrej Zajicek (work) Date: Fri Dec 14 01:53:32 2018 +0100 Doc: Move root of code documentation to doc dir It reduces clutter in root and also avoid collision with doc dir on case-insensitive filesystems when name back to Doc. commit 532116e7e33d80a79e176f043defffbfc2b8d06e Author: Ondrej Zajicek (work) Date: Wed Dec 12 17:36:54 2018 +0100 BGP: Do not prepend ASN in export from non-RS EBGP to RS EBGP When route is exported to regular EBGP, local ASN should be prepended to AS_PATH. When route is propagated by route server (between RS-marked EBGP peers), it should not change AS_PATH. Question is what to do in other cases (from non-RS EBGP, IBGP, or locally originated to RS EBGP). In 1.6.x, we did not prepend ASN in non-RS EBGP or IBGP to RS EBGP, but we prepended in local to RS EBGP. In 2.0.x, we changed that so only RS-EBGP to RS-EBGP is not prepended. We received some negative responses (thanks to heisenbug and Alexander Zubkov), we decided to change it back. One reason is that it is simple to modify the AS_PATH by filters, but not possible to un-modify changes done by BGP itself. Also, as 1.6.x behavior was not really consistent, the final behavior is that ASN is never prepended when exported to RS EBGP, like to IBGP. Note that i do not express an opinion about whether such configurations are even reasonable. commit 6b5ad2066a8002bb0fd1dde58e6c0f1e43613aee Author: Ondrej Zajicek (work) Date: Wed Dec 12 16:54:23 2018 +0100 Doc: Document log rotation feature commit 0f40405fc94fa253b5020e6603dc9ec7a02e13e7 Author: Ondrej Zajicek (work) Date: Wed Dec 12 16:38:30 2018 +0100 Update RFC references Progdoc comments do not allow SGML tags commit 9e92f357becf405643fa8c536734cccf2ae26da2 Author: Ondrej Zajicek (work) Date: Wed Dec 12 16:04:15 2018 +0100 Doc: Document BGP import table option commit 67d8665af58a14bdc26963f8910e738886edb373 Author: Ondrej Zajicek (work) Date: Tue Dec 11 13:52:30 2018 +0100 Nest: Update statistics and rx-limit for Adj-RIB-In commit 682d3f7de0905ca2e853844734cce7ff65f7d77d Author: Ondrej Zajicek (work) Date: Thu Sep 27 22:57:55 2018 +0200 BGP: implement Adj-RIB-In The patch implements optional internal import table to a channel and hooks it to BGP so it can be used as Adj-RIB-In. When enabled, all received (pre-filtered) routes are stored there and import filters can be re-evaluated without explicit route refresh. An import table can be examined using e.g. 'show route import table bgp1.ipv4'. commit 01fd00f5ed9298ab5829403cd7a8a9ba22bcc96a Author: Ondrej Zajicek (work) Date: Tue Dec 11 18:43:58 2018 +0100 Doc: Fix typo in previous LinuxDoc change commit d506263da713673f95bc17aaedceebaaad03580d Author: Ondrej Zajicek (work) Date: Tue Dec 11 17:57:14 2018 +0100 Nest: Forbid adding channels during reconfiguration When a new channel is found during reconfiguration, do force restart of the protocol, like with any other un-reconfigurable change. The old behavior was that the new channel was added but remained in down state, even if the protocol was up, so a manual protocol restart was often necessary. In the future this should be improved such that a reconfigurable channel addition (e.g. direct) is accepted and channel is started, while an un-reconfigurable addition forces protocol restart. commit baeacdcfd3ce30b3fa89ebdd4e53c60c38c26c31 Author: Ondrej Zajicek (work) Date: Mon Dec 10 02:11:42 2018 +0100 OSPF: Fix reconfiguration of vlinks Fix crash during reconfiguration of OSPF config with vlinks. When vlink is reconfigured, a generic iface-reconfiguration code is used, which in one place supposes that it is running on a regular iface. Thanks to Cybertinus for a bugreport. commit 9a5ef043c11ad9fba00557dedcc0d7ae0d2794e9 Merge: 0e492063 265419a3 Author: Jan Maria Matejka Date: Thu Dec 6 09:55:34 2018 +0100 Merge branch 'mq-custom' into int-new commit 265419a3695b9a5c0a01d9fffc60f66fea8bee13 Author: Maria Matejka Date: Wed Nov 21 20:37:11 2018 +0100 Custom route attributes For local route marking purposes, local custom route attributes may be defined. These attributes are seamlessly stripped after export filter to every real protocol like Kernel, BGP or OSPF, they however pass through pipes. We currently allow at most 256 custom attributes. This should be much faster than currently used bgp communities for marking routes. commit 0e4920632aa30dab4fbfb0530bce5a959e7a7675 Author: Robert Scheck Date: Tue Dec 4 18:14:04 2018 +0100 Doc: Allow overriding $SGML_CATALOG_FILES using distribution specific paths commit f26bf60fb58bc975d510a9fff3adb76817ddb624 Author: Robert Scheck Date: Tue Dec 4 18:11:42 2018 +0100 Doc: Add alternative path for SGML ISO entities 8879.1986 to $SGML_CATALOG_FILES The existing paths are valid for Debian, alternative paths are necessary for Fedora and RHEL/CentOS. commit 3fda08e40532245ba69e14cdac0623a138b939f9 Author: Ondrej Zajicek (work) Date: Tue Dec 4 16:55:25 2018 +0100 Unix: Change debugging options The old behavior was that enabling debugging did many nontrivial changes in BIRD behavior. The patch changes it that these changes are generally independent. Compiling with --enable-debug now just enables compile-time debug macros, but do not automatically activate debug mode (-d) nor local mode (-l). Debug mode with output to file (-D) do not force foreground mode (-f), therefore there is no need for backgroud option (-b), which is removed. Also fixes a bug when the default log target in -D mode was stderr instead of given debug file. commit 0642fb4d456fe12e1bbeb2ffc2149433f228c02e Author: Jan Maria Matejka Date: Tue Nov 27 08:49:31 2018 +0100 Hash: mem_hash doesn't modify the memory, declared constant commit d73c4ac869048e60276c5e568450c7342bc0bc8a Author: Jan Maria Matejka Date: Thu Nov 1 12:17:49 2018 +0100 Route table max hash size raised to 2^24. This is still OK for everybody to fit into RAM and also probably enough to keep a little collision rate for full BGP table. commit 84661bf6da683d70e6e5e0e490d95abaf91b470b Author: Jan Maria Matejka Date: Tue Oct 30 15:25:32 2018 +0100 Changed IPv4 hash function to simple multiplication. commit 14375237f6901a926d59cc54870cf44ed2a61d20 Author: Jan Maria Matejka Date: Wed Feb 14 13:42:53 2018 +0100 Terminology cleanup: The import_control hook is now called preexport. Once upon a time, far far away, there were the old Bird developers discussing what direction of route flow shall be called import and export. They decided to say "import to protocol" and "export to table" when speaking about a protocol. When speaking about a table, they spoke about "importing to table" and "exporting to protocol". The latter terminology was adopted in configuration, then also the bird CLI in commit ea2ae6dd0 started to use it (in year 2009). Now it's 2018 and the terminology is the latter. Import is from protocol to table, export is from table to protocol. Anyway, there was still an import_control hook which executed right before route export. One thing is funny. There are two commits in April 1999 with just two minutes between them. The older announces the final settlement on config terminology, the newer uses the other definition. Let's see their commit messages as the git-log tool shows them (the newer first): commit 9e0e485e50ea74c4f1c5cb65bdfe6ce819c2cee2 Author: Martin Mares Date: Mon Apr 5 20:17:59 1999 +0000 Added some new protocol hooks (look at the comments for better explanation): make_tmp_attrs Convert inline attributes to ea_list store_tmp_attrs Convert ea_list to inline attributes import_control Pre-import decisions commit 5056c559c4eb253a4eee10cf35b694faec5265eb Author: Martin Mares Date: Mon Apr 5 20:15:31 1999 +0000 Changed syntax of attaching filters to protocols to hopefully the final version: EXPORT for outbound routes (i.e., those announced by BIRD to the rest of the world). IMPORT for inbound routes (i.e., those imported by BIRD from the rest of the world). where is one of: ALL pass all routes NONE drop all routes FILTER use named filter FILTER { } use explicitly defined filter For all protocols, the default is IMPORT ALL, EXPORT NONE. This includes the kernel protocol, so that you need to add EXPORT ALL to get the previous configuration of kernel syncer (as usually, see doc/bird.conf.example for a bird.conf example :)). Let's say RIP to this almost 19-years-old inconsistency. For now, if you import a route, it is always from protocol to table. If you export a route, it is always from table to protocol. And they lived happily ever after. commit e2ae08694e45b2a127c9d741e41dee4b14c2964d Author: Ondrej Zajicek (work) Date: Wed Nov 28 16:43:17 2018 +0100 Nest: Do not hard-reset interface when preferred address is changed Modify protocols to use preferred address change notification instead on depending on hard-reset of interfaces in that case, and remove hard-reset in that case. This avoids issue when e.g. IPv6 protocol restarts interface when IPv4 preferred address changed (as hard-reset is unavoidable and common for whole iface). The patch also fixes a bug when removing last address does not send preferred address change notification. commit 66934aceff0e5299719177782bcbf151f8030591 Author: Ondrej Zajicek (work) Date: Wed Nov 21 16:30:22 2018 +0100 Autoconf: Minor cleanup commit fc1b933304c325775169d5241ce1ac5ae3266680 Author: Ondrej Zajicek (work) Date: Wed Nov 21 16:00:22 2018 +0100 MRT documentation commit 863ecfc78538657e51f1ec67441aec32261aa405 Author: Ondrej Zajicek (work) Date: Tue Nov 20 17:38:19 2018 +0100 The MRT protocol The new MRT protocol is responsible for periodic RIB table dumps in the MRT format (RFC 6396). Also the existing code for BGP4MP MRT dumps is refactored and splitted between BGP to MRT protocols, will be more integrated into MRT in the future. Example: protocol mrt { table "*"; filename "%N_%F_%T.mrt"; period 60; } It is partially based on the old MRT code from Pavel Tvrdik. commit 6712e77271fb3cb4a3c48cd7b027b39c5cea00a2 Author: Ondrej Zajicek (work) Date: Wed Nov 14 17:16:05 2018 +0100 Unix: Implement log file size limit / log rotation Allow to specify log file size limit and ensure that log file is rotated to secondary name to avoid exceeding of log size limit. The patch also fixes a bug related to keeping old fds open after reconfiguration and using old fds after 'configure undo'. commit c68ba7d093e1fcf01fceb341438fc5dc95f93ac5 Author: Ondrej Zajicek (work) Date: Tue Nov 13 18:13:11 2018 +0100 Unix: Refactor tracked files We need access to resource in order to free it. commit d0b4597842ba1f65e5280529fca243ce5b5043fa Author: Ondrej Zajicek (work) Date: Sun Nov 18 01:22:09 2018 +0100 Configure: Use standard --runstatedir option Newer Autoconf defines --runstatedir option for setting directory for run-time variable data. Use it instead our old --with-runtimedir. commit f2d8e6801e88a84b1e57da72d078d7569598a5f5 Author: Ondrej Zajicek (work) Date: Mon Nov 5 22:03:21 2018 +0100 Filter: Make ifname attribute modifiable Allow to change an interface associated with a route by setting ifname attribute. It will also change the route to a direct one. commit 69b2f63d9a477ab5d083773e16ca15ed2e570144 Author: Ondrej Zajicek (work) Date: Mon Nov 5 13:56:59 2018 +0100 Nest: Fix crash in rta_show() for RPKI and Babel routes Some new route source values did not have associated string in rta_show(), which might caused crash in some cases. commit e19d08055a4614f03e51ee72617be10946ce7919 Author: Ondrej Zajicek (work) Date: Fri Oct 26 19:11:33 2018 +0200 BGP: Fix VRF for listening socket Listening socket should be bound to specified interface and VRF. Thanks to Alexander Zubkov for the bugreport. commit 0ac9cb2c1f6592290e025f61ccd0fef0dc09de46 Author: Ondrej Zajicek (work) Date: Thu Oct 25 17:22:37 2018 +0200 OSPF: Fix some trace messages Missing argument in MTU change trace message can crash bird when MTU change happens and trace messages are active. Thanks to Alexander Velkov for the bugreport. commit df50598f1c285a5e2820b7427998c6ebf86bbbec Author: Ondrej Zajicek (work) Date: Thu Oct 25 12:39:13 2018 +0200 Lib: Force output type in ip4_addr constructor Fixes type issue when u64 is pushed into it. commit 83715aa82966020100afa35f15d1ca56cadf6d10 Author: Ondrej Zajicek (work) Date: Thu Oct 25 11:26:58 2018 +0200 Filter: Add support for VPN_RD sets commit 41b83e52f7f0a0de88c220aab88a4dd31f05fce0 Author: Ondrej Zajicek (work) Date: Thu Oct 25 11:23:15 2018 +0200 Filter: Fix minor bug in accessing bgp_path Not relevant for regular BGP paths, just for BGP paths added by filters to e.g. static routes. commit 01dd78f9e924cc6d7511da1ec32c8f36d357db7a Author: Ondrej Zajicek (work) Date: Thu Oct 11 15:03:09 2018 +0200 Fix installation with --disable-client The old check assumed that @CLIENT@ does not contain birdc, which is not true in 2.0 branc. Thanks to Thomas Petazzoni for the bugreport and original patch. commit addb1bcd86885dcee559a61eb18998ae6a38b2ab Author: Ondrej Zajicek (work) Date: Thu Oct 11 14:39:13 2018 +0200 Nest: Fix 'show interfaces summary' command The command showed interfaces that were removed / in shutdown. commit 961671c0f51693aff34bf3adf5319b35275a86d3 Author: Ondrej Zajicek (work) Date: Mon Oct 1 15:55:23 2018 +0200 Lib: Add and use ev_new_init() commit 0db7a1d69c80b1089f10a268ceacb059db41ced8 Author: Ondrej Zajicek (work) Date: Mon Oct 1 15:35:43 2018 +0200 BGP: Fix bug in show protocol related to LLGR When channel is not active due to not be negotiated during sessino establishment, the LLGR timer is not allocated, so we should not show it. commit d4cebc6bbe2a55bd344383fcc27255a12d686195 Author: Jan Maria Matejka Date: Tue Sep 18 14:21:11 2018 +0200 No more warnings ... no more warnings No more warnings over me And while it is being compiled all the log is black and white Release BIRD now and then let it flee (use the melody of well-known Oh Freedom!) commit d50b0bc437f5ffd0d2c9f843217f8ed098c8d675 Author: Jan Maria Matejka Date: Tue Sep 11 16:55:41 2018 +0200 Conf: Show the line:char position where the syntax error happens commit 89b0af3978caf15e1478922a8d9d4f7e38145a61 Author: Jan Maria Matejka Date: Tue Aug 28 16:45:50 2018 +0200 Main: Add -b to force background even in debug mode commit a043f2d79488cdfbc4d97ac0bad4926d29bf9a82 Author: Ondrej Zajicek (work) Date: Fri Aug 24 18:54:27 2018 +0200 Doc: Fix description of 'description' Thanks to Clemens Schrimpe for the bugreport. commit 64c5ad58d276d8a0463aa9ad2b34f75b7d1f4108 Author: Jan Maria Matejka Date: Wed Aug 22 14:58:53 2018 +0200 Lib: recursive printf Use like this: void func(const char *msg, va_list args) { ... bvsnprintf(buf, len, "file %s, line %d: %V (foo %d, bar %d)", file, line, msg, &args, foo, bar); ... } commit 765f400f6b7ac054ddb4fcc4f5bec58f94d1bdd4 Author: Ondrej Zajicek (work) Date: Tue Aug 21 15:24:55 2018 +0200 DOC: Remove pipe mode reference Pipe mode was removed in 2.0, remove reference to it in the documentation. Thanks to Piotr Wydrych for the bugreport. commit 7ffc0a6534fb66ad27d22984e25bd0789f4404b6 Author: Jan Maria Matejka Date: Tue Aug 14 14:36:44 2018 +0200 Bison: A bit more verbose error messages in config. commit 78ca6ea8f0b8ab312b1e0ef56629a18e3efbce42 Author: Jan Maria Matejka Date: Tue Jul 17 15:39:06 2018 +0200 Make: Add option to force colors in compiler output commit 86b9e8e39a0b42407c95921ca8262b0a75cad5f2 Author: Jan Maria Matejka Date: Tue Jul 17 15:30:59 2018 +0200 M4: generate synchronization lines This also includes Bison version check. Versions before 3.0 don't support them in a reliable way and we don't promise to work with versions older than 2.4. commit 1279a83103262950ab99e8a6fe3c6cc2da8d42a8 Author: Pavel Tvrdik Date: Mon Nov 14 14:53:10 2016 +0100 sysdep/unix/main.c: Remove trailing spaces commit d33cf3f4c3a92f895e8b52fc19ed8a88f350a32b Author: Ondrej Zajicek (work) Date: Tue Aug 7 14:46:24 2018 +0200 Doc: Fix notes related to obsolete option Thanks to Julien Dessaux for the report. commit 5bd734317c05008a66eefaa14fc98a6d533cf9ef Author: Ondrej Zajicek (work) Date: Tue Jul 31 18:40:38 2018 +0200 BGP: Long-lived graceful restart The patch implements long-lived graceful restart for BGP, namely draft-uttaro-idr-bgp-persistence-03. commit 318acb0f6cb77a32aad5d7f79e06f3c5065ac702 Author: Ondrej Zajicek (work) Date: Sat Jul 28 16:54:06 2018 +0200 BSD: Use MSG_DONTROUTE for unicast packets on FreeBSD BSD systems cannot use SO_DONTROUTE, because it does not work properly with multicast packets (perhaps it tries to find iface based on multicast group address). But we can use MSG_DONTROUTE sendmsg() flag for unicast packets. Works on FreeBSD, is ignored on OpenBSD and is broken on NetBSD (i guess due to integrated routing table and ARP table). commit 0ed3129f6b0a80afea877340d940e45f1a5d3000 Author: Ondrej Zajicek (work) Date: Thu Jul 19 20:54:10 2018 +0200 RAdv: Fix crash during prefix change Thanks to Julian Schuh for the bugreport. commit 8bd718b3ba34cee95a5443f3d20d6f16c2d4c946 Author: Ondrej Zajicek (work) Date: Thu Jul 19 20:48:13 2018 +0200 OSPF: Fix crash during route removal The bug was introduced by an earler patch which removed additional eattr argument to rt_notify hook. commit 092c4930277c0f0f0dcb0c4013ff642314f90842 Author: Ondrej Zajicek (work) Date: Fri Jul 6 02:04:45 2018 +0200 Nest: Fix race condition during reconfiguration, part 2 If export filter is changed during reconfiguration and a route disappears between reconfiguration and refeed (e.g., if the route is a static route also removed during the reconfiguration), the route is not withdrawn. The issue was fixed for regular channels by an earlier patch. This patch fixes the issue for channels in RA_ACCEPTED mode (first-pass-the-filter), used by BGP with 'secondary' option. commit 7b9b0c0a0087def6a3fc11824a891be5940a257b Author: Ondrej Zajicek (work) Date: Tue Jul 3 18:08:35 2018 +0200 Cleanup some warnings commit a81e18da254ddd7cccff82feab61aa943a277805 Author: Ondrej Zajicek (work) Date: Tue Jul 3 17:52:51 2018 +0200 Nest: Fix race condition during reconfiguration If export filter is changed during reconfiguration and a route disappears between reconfiguration and refeed (e.g., if the route is a static route also removed during the reconfiguration), the route is not withdrawn. The patch fixes that by adding tx reconfiguration timestamp. commit 8e86ffce8251f4e48f61b6d8e89966d037ef8e59 Author: Ondrej Zajicek (work) Date: Sun Jul 1 01:03:16 2018 +0200 BGP: Use implicit-NULL label when announcing MPLS routes with local next-hop We currently cannot assing local labels, but we can still be LSP egress router. Therefore when we announce labeled route with local next-hop, we should announce implicit-NULL label instead of rejecting it completely. commit 93c1defdb03729ae8b41752d2155dff65964df5b Author: Ondrej Zajicek (work) Date: Sun Jul 1 00:43:24 2018 +0200 BGP: Fix parsing of MPLS withdrawals RFC 3107 was bit vague with regard to labeled withdrawals, RFC 8277 clarified that. The old code was incompatible with some implementations, namely with Juniper. Thanks to Vadim Fedorenko for the original patch. commit daf113ac66fb9dc83a904ce9bcc68e90830624d0 Author: Maria Jan Matejka Date: Fri Jun 29 17:23:27 2018 +0200 BGP: Attribute set function merged with its common counterpart commit d8e816c150ebad08ff75ef34eb459a67a09a34d0 Author: Ondrej Zajicek (work) Date: Wed Jun 27 17:08:59 2018 +0200 BSD: Fix of the previous commit commit 586c1800c447ff099d34889b23647c4733876d9b Author: Ondrej Zajicek (work) Date: Wed Jun 27 16:51:53 2018 +0200 Nest: Neighbor cache cleanups Simplify neighbor cache code, fix several minor bugs, and improve handling of ONLINK flag. commit 45f28d85818f79790968725a945063228989bae7 Author: Maria Matejka Date: Mon Apr 23 15:59:02 2018 +0200 Autotools: updated config.guess and config.sub Updated to version 63b4ce2e8c28aee6a32133e400436e4ca885215a from git://git.savannah.gnu.org/config.git Previous version was 93b5037172b15ad28952481933517f1ba93d125b commit da16b33ab98602628d66ed4f434dc6fa76f338c6 Author: Maria Matejka Date: Mon Apr 23 15:54:20 2018 +0200 Android: check for extra libs needed for build commit c2fc4c10ac81b8815c1434aa2b0945aa937df4fa Author: Maria Matejka Date: Mon Apr 23 11:29:13 2018 +0200 Doc: renamed progdoc files Doc -> progdoc to fix collision with doc/ folder on case-insensitive filesystems commit f851f0d7e30cbd1e2ba20a5bf06a584acc136828 Author: Jan Maria Matejka Date: Tue Jun 26 14:29:03 2018 +0200 Config: Dropping CF_ADDTO. commit 1771f70d7473b8c8e0c6bd47d5c35cc5fbe7eb19 Author: Jan Maria Matejka Date: Tue Jun 19 16:16:08 2018 +0200 Filter: fixed eattr cached pointer Use ACCESS_RTE to guard **f_rte, use ACCESS_EATTRS to guard **f_eattrs. Use f_rta_cow() before writing to rta or eattrs, use f_rte_cow() before writing preference (stored in rte). Do not access eattrs indirectly through (*f_rte)->attrs->eattrs, it is way too slow. The cached pointer is faster. commit 1ef23f05ee00394e6a2748f658b73c20d3ff7c45 Merge: 13c0be19 caa9d03d Author: Jan Maria Matejka Date: Tue Jun 19 14:32:16 2018 +0200 Merge branch 'int-new' into HEAD commit caa9d03d65ce827ce536d54b26988e70767e032f Author: Ondrej Zajicek (work) Date: Wed Jun 13 15:22:29 2018 +0200 Babel: Fix handling of missing IPv4 next hops In case of missing IPv4 next hop, we should skip such routes on transmit and ignore such routes on receive. Thanks to Julian Schuh for the bugreport and Toke Hoiland-Jorgensen for the original patch. commit 9c9050ff12c52762708dadda78a05108a5b533b2 Author: Ondrej Zajicek (work) Date: Wed Jun 13 14:47:37 2018 +0200 BGP: Handle missing NEXT_HOP attribute properly RFC 7606 specifies handle-as-withdraw instead of session reset. commit 13c0be19d3d2acc9c1636bbab9222aabdf27d7ac Author: Jan Maria Matejka Date: Tue May 29 12:08:12 2018 +0200 Nest: Removing separate tmpa from route propagation This is a fundamental change of an original (1999) concept of route processing inside BIRD. During import/export, there was a temporary ea_list created which was to be used instead of the another one inside the route itself. This led to some confusion, quirks, and strange filter code that handled extended route attributes. Dropping it now. The protocol interface has changed in an uniform way -- the `struct ea_list *attrs` argument has been removed from store_tmp_attrs(), import_control(), rt_notify() and get_route_info(). commit 18b4f2082c30586890596988086fbc3e15336526 Author: Ondrej Zajicek (work) Date: Tue May 29 14:23:14 2018 +0200 OSPF: Fix invalid NSSA RFC references commit ee7e2ffd265fd76dbc8c94d9c2d48da54c27ff76 Author: Jan Maria Matejka Date: Mon May 7 14:47:00 2018 +0200 Protocol: Introducing an enum protocol_class This supersedes the EAP_* constants. commit c3becfe1934da2dc2c0881a71eac8a26f810791f Author: Jan Maria Matejka Date: Wed May 2 12:34:35 2018 +0200 Filter: macro for recursive interpretation of instructions commit 0ec6b5ecd37529d57079e13748c4ecbd336332c1 Author: Jan Maria Matejka Date: Mon Apr 30 16:06:53 2018 +0200 Filter: Simple type checks converted to ARG() macro commit 478f9babed361f8df8a9c944f20bcbe116dc30aa Author: Jan Maria Matejka Date: Mon Apr 30 13:29:05 2018 +0200 Filter: Removing the third argument hack Just to make the code a bit more clean and easier to maintain. commit cff9e937fd0ed42b88be1deb5e1aa9fe301caabd Author: Jan Maria Matejka Date: Mon Apr 30 12:49:22 2018 +0200 Filter: instruction names commit 31d6939cde071ab04d1da6b3ff6fb6cd579e164a Author: Jan Maria Matejka Date: Mon Apr 30 12:39:32 2018 +0200 Filter: Instruction codes linearized commit 906092534ba8479ca76723b7dd7ee233f5a70d1e Author: Jan Maria Matejka Date: Mon Apr 30 12:20:04 2018 +0200 Macro: Added a bunch of dirty C preprocessor tricks Included are Makefile implicit rules to show the preprocessed source. When debugging something around this, it may be handy. commit feae132e0f9bdc62d2b90bf676d12241af8e794c Author: Ondrej Zajicek (work) Date: Thu May 24 14:51:05 2018 +0200 Do not initialize route metrics in import_control hook During route export, the receiving protocol often initialized route metrics to default value in its import_control hook before export filter was executed. This is inconsistent with the expectation that an export filter would process the same route as one in the routing table and it breaks setting these metrics before (e.g. for static routes directly in static protocol). The patch removes the initialization of route metrics in import_control hook, the default values are already handled in rt_notify hook called after export filters. The patch also changed the behavior of OSPF to keep metrics when a route is reannounced between OSPF instances (to be consistent with other protocols) and the behavior when both ospf_metric1 and ospf_metric2 are specified (to have more expected behavior). commit b24b781117179f301116837f0a39468343e4805b Author: Ondrej Zajicek (work) Date: Wed May 16 11:19:29 2018 +0200 Filter: Add support for src filter op to access SADR source prefix The patch allows to use 'net.src' to access SADR source prefix from filters. Thanks to Toke Hoiland-Jorgensen for the original patch for srclen. commit eaf63d314d50cba5b2cfa8f18de64a91d3131b94 Author: Ondrej Zajicek (work) Date: Thu May 3 17:07:39 2018 +0200 Better initialization of random generator Use full time precision to initialize random generator. The old code was prone to initialize it to the same values in specific circumstances (boot without RTC, multiple VMs starting at once). commit 70fab17837dbb4c5848681e4c6b9b90891891130 Author: Ondrej Zajicek (work) Date: Thu May 3 16:55:11 2018 +0200 Babel: Add option to randomize router ID When a Babel node restarts, it loses its sequence number, which can cause its routes to be rejected by peers until the state is cleared out by other nodes in the network (which can take on the order of minutes). There are two ways to fix this: Having stable storage to keep the sequence number across restarts, or picking a different router ID each time. This implements the latter, by introducing a new option that will cause BIRD to randomize a high 32 bits of router ID every time it starts up. This avoids the problem at the cost of not having stable router IDs in the network. Thanks to Toke Hoiland-Jorgensen for the patch. commit 23b079043bea5899b49a750c4616aff5b332c50d Author: Ondrej Zajicek (work) Date: Thu May 3 16:02:29 2018 +0200 Babel: Fix type of route entry router ID The router ID being assigned to routes was a uint, which discards the upper 32 bits. This also has the nice side effect of echoing the wrong router ID back to other routers. Thanks to Toke Hoiland-Jorgensen for the patch. commit 29958745c8f58cffd24e1793702524ce84545e5a Author: Jan Maria Matejka Date: Thu May 3 11:14:49 2018 +0200 Makefile: Only set git version if BIRD is build from its repository. Thanks to Toke Høiland-Jørgensen for reporting this bug. commit 823ad12191e66e243dd088a81c66e4a518563e40 Author: Jan Maria Matejka Date: Fri Apr 27 14:38:41 2018 +0200 Filter: Added missing instruction comparators. These instructions caused SIGABORTs on reconfiguration. commit 4727d1db9d83a8f1025481cbcc06a7e4c8ec9f33 Author: Ondrej Zajicek (work) Date: Wed Apr 25 15:50:57 2018 +0200 OSPF: Support of authentication trailer for OSPFv3 Implement RFC 7166, crypthographic authentication for OSPFv3 analogous to authentication used for OSPFv2. commit f3a8cf050e6181e158dcde2fe885d7bf220eedc3 Author: Ondrej Zajicek (work) Date: Thu Apr 12 16:55:56 2018 +0200 BGP: Fix extended next hop handling For IPv4 with extended next hop, we use MP-BGP format and therefore no independent NEXT_HOP attribute. Thanks to Arvin Gan for the bugreport. commit c408d807a374b521dc66c434ca0dc5987820646f Author: Ondrej Zajicek (work) Date: Tue Apr 3 17:31:45 2018 +0200 Doc: Documentation for BGP disable after cease option commit a63d20aa872364873d0fbfa03d1c3c6d9a1889eb Author: Ondrej Zajicek (work) Date: Tue Apr 3 16:53:58 2018 +0200 Doc: Documentation for BGP extended next hop feature Thanks to Arvin Gan for the bugreport. commit 157f6c2aaddbf8668e33ed6efcd874a6677fa005 Author: Ondrej Zajicek (work) Date: Sat Mar 24 01:53:03 2018 +0100 Doc: Remove some superfluous slashes commit 6807320a0f732829c475ab230857147bf4f0cc7c Author: Ondrej Filip Date: Fri Mar 23 17:24:58 2018 +0100 Autoconf replaced by autoreconf commit 4d3d34f5997128824c376a097eee60954c3611cf Author: Ondrej Filip Date: Thu Mar 22 13:30:10 2018 +0100 Date added. commit 966602602a0f24942bee3ab0492bbb9197e71aa1 Merge: 44062812 4841804f Author: Ondrej Filip Date: Thu Mar 22 13:25:58 2018 +0100 Merge branch 'int-new' of ssh://gitlab.labs.nic.cz/labs/bird into int-new commit 4841804fffd8bf669b2445ec3328b6a49eed31f9 Author: Ondrej Zajicek (work) Date: Wed Mar 21 15:17:56 2018 +0100 NEWS and version update commit a177e4dd04b29dc364d2c5505fe2c483981c6498 Author: Ondrej Zajicek (work) Date: Wed Mar 21 16:32:51 2018 +0100 Doc: Minor update commit 3b522a1e5cd034196cd0f5c0eab4d9e87f0f2a8a Author: Ondrej Zajicek (work) Date: Tue Mar 20 19:28:26 2018 +0100 Doc: Redesign default config file The old one does not work with 2.0.x. commit 89ac4dd3c433cae865d5339efe5e682d4506044d Merge: bcb4af81 8a871e89 Author: Ondrej Zajicek (work) Date: Mon Mar 19 13:29:39 2018 +0100 Merge remote-tracking branch 'birdlab-tmp/int-new' into int-new commit bcb4af81fc8ea0acf7c2fa5a6854cd3c23d92d9f Author: Ondrej Zajicek (work) Date: Sun Mar 18 13:48:47 2018 +0100 Nest: Fix table reconfiguration when nettype changes Thanks to Toke Hoiland-Jorgensen for the bugreport. commit 364d5823eac85178361bad188d89949b7e0d321c Author: Ondrej Zajicek (work) Date: Sun Mar 18 02:56:51 2018 +0100 Nest: SADR support for Direct commit 159d619caf2311b62dc0d876f22c42b5d23e86c0 Author: Ondrej Zajicek (work) Date: Sat Mar 17 22:25:06 2018 +0100 Doc: SADR documentation commit 7a8ae228f907400a33375c07b31f3e42a89834e7 Author: Ondrej Zajicek (work) Date: Sat Mar 17 17:14:02 2018 +0100 Doc: Update BGP documentation Thanks to Joshua McQuistan for the bugreport. commit 8a871e890a7198f7cbaff5c75033160ae3ad68f3 Merge: e95705f0 e8bc64e3 Author: Jan Maria Matejka Date: Wed Mar 14 12:57:16 2018 +0100 Merge branch 'master' into int-new commit e8bc64e308586b6502090da2775af84cd760ed0d Author: Jan Maria Matejka Date: Wed Feb 28 16:57:50 2018 +0100 Filter: make bgpmask literals real constructors The bgpmask literals can include expressions. This is OK but they have to be interpreted as soon as the code is run, not in the time the code is used as value. This led to strange behavior like rewriting bgpmasks when they shan't be rewritten: function mask_generator(int as) { return [= * as * =]; } function another() bgpmask m1; bgpmask m2; { m1 = mask_generator(10); m2 = mask_generator(20); if (m1 == m2) { print("strange"); # this would happen } } Moreover, sending this to CLI would cause stack overflow and knock down the whole BIRD, as soon as there is at least one route to execute the given filter on. show route filter bgpmask mmm; bgppath ppp; { ppp = +empty+; mmm = [= (ppp ~ mmm) =]; print(mmm); accept; } The magic match operator (~) inside the bgpmask literal would try to resolve mmm, which points to the same bgpmask so it would resolve itself, call the magic match operator and vice versa. After this patch, the bgpmask literal will get resolved as soon as it's assigned to mmm and it also will return a type error as bool is not convertible to ASN in BIRD. commit e95705f00c9e297cd6dde1e8fa60bee4a4d539f2 Merge: d1ba927b 74bfd2f9 Author: Jan Maria Matejka Date: Tue Mar 13 17:02:49 2018 +0100 Merge branch 'master' into int-new commit 74bfd2f97c0a95b6fb73a67d9334e54a90695c58 Author: Jan Maria Matejka Date: Tue Mar 13 12:08:37 2018 +0100 Filters: Removed FI_COMMA, not used for 19 years. This instruction was removed in the commit linked below and never used ever again. Rest in peace. commit 84c7e1943f0dbf896b1dd8d02a21120aa00463f4 Author: Pavel Machek Date: Tue Mar 2 19:49:28 1999 +0000 commit d1ba927b369c91ddb2143b686ca4c1be53e46e64 Merge: f2f5a7d9 7c601e6b Author: Jan Maria Matejka Date: Tue Mar 13 16:51:04 2018 +0100 Merge branch 'master' into int-new commit 7c601e6b7b7696b24ce5f5715fa14dbb91c71d6e Author: Jan Maria Matejka Date: Wed Nov 29 11:38:01 2017 +0100 Filter: recursion to loop It was supposed to do tail-recursion in interpret() but it didn't compile as such. Converting it to loop makes a significant filter performance improvement for flat filters. commit 5a14df395053f4094a1e3ebea98e3487cbfc0e63 Author: Maria Jan Matejka Date: Thu Oct 19 12:39:44 2017 +0200 Filter: Instruction codes named as enum The two-letter instructions were quite messy but they could be easily read from memory dumps. Now GDB (since 2012) supports pretty printing enum values and GCC checks the switch construction for missing enum values so we are converting the nice two-byte values to enums. Anyway, the enum still keeps the old two-byte values to be able to read the instruction codes even without GDB from plain memory dump. commit f2f5a7d9455f938fb14e31315a879c3be2c5d28a Author: Jan Maria Matejka Date: Tue Mar 6 16:04:56 2018 +0100 Filter: the test conf checks also a bit of BGP args Uncommented an old test. commit 0575c7db723523701d5582e2a9058cb5c46951c9 Author: Jan Maria Matejka Date: Tue Mar 6 16:03:35 2018 +0100 Config: Dropped the ipv4:netmask4 syntax for IPv4 prefixes. commit d0f47327f81a278d6adb3d0a6c235ea715798d01 Merge: 1561ee79 2d6d4b80 Author: Ondrej Zajicek (work) Date: Wed Mar 7 17:41:49 2018 +0100 Merge branch 'master' into int-new commit 2d6d4b80539be13aa53c6751fb33689b263e4010 Author: Ondrej Zajicek (work) Date: Wed Mar 7 17:35:24 2018 +0100 Babel: Fix build with restricted protocol set All keywords used in Babel config have to be declared locally. Thanks to Leo Vandewoestijne for the bugreport. commit 44062812600bd29f8edf30ebc871ff218069c5a2 Merge: 6f46465a 1561ee79 Author: Ondrej Filip Date: Tue Feb 27 06:08:03 2018 +0100 Merge branch 'int-new' of ssh://gitlab.labs.nic.cz/labs/bird into int-new commit 1561ee799cfe79d208ce9588e487da4b62a88dad Author: Ondrej Zajicek (work) Date: Tue Feb 13 19:52:22 2018 +0100 Handle properly enums for extended attributes commit d5144ea9bf01f0b19cba40ab06aa05a11d70aa3e Author: Ondrej Zajicek (work) Date: Tue Feb 13 17:00:24 2018 +0100 Add cscope Makefile target For those who prefer cscope to etags Thanks to Toke Hoiland-Jorgensen for the patch. commit 5ce7adfcf96787878d60668cf33acf7349a69c0b Author: Ondrej Zajicek (work) Date: Tue Feb 13 16:42:03 2018 +0100 Babel: Fix accidental bitwise or assignment Fix an accidental bitwise or assignment that was supposed to be a comparison. Thanks to Toke Hoiland-Jorgensen for the patch. commit 185a0a51f8aed635eecac0cfbd837dd262a8add0 Author: Ondrej Zajicek (work) Date: Tue Feb 13 16:39:36 2018 +0100 Babel: Add source-specific routing support This patch adds support for source-specific routing to the Babel protocol. It changes the protocol to support both NET_IP6 and NET_IP6_SADR channels for IPv6 addresses. If only a NET_IP6 channel is configured, source-specific updates are ignored. Otherwise, non-source-specific routes are simply treated as source-specific routes with SADR prefix 0. Thanks to Toke Hoiland-Jorgensen for the original patch. Minor changes by Ondrej Santiago Zajicek. commit be17805c0bbd37e865dc9b17b56e8e8d210c2c6c Author: Ondrej Zajicek (work) Date: Tue Feb 13 16:27:57 2018 +0100 Add support for source-specific IPv6 routes to BIRD core This patch adds support for source-specific IPv6 routes to BIRD core. This is based on Dean Luga's original patch, with the review comments addressed. SADR support is added to network address parsing in confbase.Y and to the kernel protocol on Linux. Currently there is no way to mix source-specific and non-source-specific routes (i.e., SADR tables cannot be connected to non-SADR tables). Thanks to Toke Hoiland-Jorgensen for the original patch. Minor changes by Ondrej Santiago Zajicek. commit a82f692e5844d5efdc091a796dc0e8ae8ab5a322 Author: Ondrej Zajicek (work) Date: Tue Feb 6 17:43:55 2018 +0100 Nest: Trivial whitespace cleanup commit 28b3b551222ab58456a067a9be4790824cdbb60e Author: Ondrej Zajicek (work) Date: Tue Feb 6 16:08:45 2018 +0100 KRT: Fix IPv6 route learn Internal table used for route learn was created with non-matching net type for IPv6 kernel proto. Thanks to Toke Hoiland-Jorgensen for the bugreport commit 85ad5855a02e8b185a61bbcb601f005d2e6747db Author: Ondrej Zajicek (work) Date: Mon Jan 29 12:49:37 2018 +0100 Nest: Fix corner case in recursive next hop lookup Thanks to Svenne Krap for the bugreport. commit 345e50d59ff299e466fab6d0e0d37c210d624d96 Author: Ondrej Zajicek (work) Date: Wed Jan 24 13:55:12 2018 +0100 Nest: remove duplicate function commit 75d98b6013c19598b1d3ba5e05e8f84525e8678a Merge: ace3072e d6cf9961 Author: Ondrej Zajicek (work) Date: Tue Jan 23 18:29:32 2018 +0100 Merge branch 'master' into int-new commit d6cf996151307d083c30e4ecde0f1d7449b19253 Author: Ondrej Zajicek (work) Date: Tue Jan 23 17:05:45 2018 +0100 IO: Fix socket priority On Linux, setting the ToS will also set the priority and the range of accepted values is quite limited (masked by 0x1e). Therefore, 0xc0 is translated to a priority of 0, not something we want, overriding the "7" priority which was set previously explicitely. To avoid that, just move setting priority later in the code. Thanks to Vincent Bernat for the patch. commit ace3072e09e445b2fd8554492b80bea5cc1f3411 Author: Ondrej Zajicek (work) Date: Tue Jan 23 15:12:43 2018 +0100 KRT: Fix option 'merge paths' commit e5ff7929c4d85b84496cdfc46f006b8cd1b4c0e5 Author: Ondrej Zajicek (work) Date: Tue Jan 23 14:48:07 2018 +0100 KRT: Remove useless option commit def6efa1ef98966424a73923832c6912acefc0ba Author: Ondrej Zajicek (work) Date: Tue Jan 23 14:26:18 2018 +0100 Doc: Fix example commit 8adaf730c0e2dae2debd7aa09633899e28428b11 Author: Jan Maria Matejka Date: Tue Jan 16 16:10:13 2018 +0100 Pipe: show export state commit c591810d46ae31c9e46768388878321e78e4ef94 Author: Jan Maria Matejka Date: Tue Jan 16 14:46:06 2018 +0100 Pipe: fixed template bug When pipe inherited from template, every channel config was lost. commit 63472779ad4ecdecbcfedf2d2bb40abc2f8c84b0 Author: Ondrej Zajicek (work) Date: Tue Jan 16 19:17:04 2018 +0100 BGP: Implement 'disable after cease' option The option allows to specify that some cease subcodes should disable the protocol when received. commit b94057911554e04df9b709f8354e2e220131096a Author: Ondrej Zajicek (work) Date: Tue Jan 16 16:20:01 2018 +0100 Filter: Allow silent filter execution A filter should log messages only if executed explicitly (e.g., during route export or route import). When a filter is executed for technical reasons (e.g., to establish whether a route was exported before), it should run silently. commit 6f46465af1b3d21ca67e3b4379640c008fc9d1a1 Author: Ondrej Filip Date: Tue Jan 16 14:36:46 2018 +0100 Error in version guessing commit c2febfa33294be0f457b49f5453d8066a7d88a5d Author: Ondrej Zajicek (work) Date: Tue Jan 16 14:18:57 2018 +0100 Add note to NEWS commit 68d0048b3d8d17cfa30846cfe06ea159c3c49a17 Author: Ondrej Filip Date: Tue Jan 16 10:45:03 2018 +0100 Notice about RFC 8212 added commit 3831b619661d08d935fd78656732cd2f339ff811 Author: Ondrej Zajicek (work) Date: Tue Jan 16 04:14:49 2018 +0100 BGP: Require explicit import and export policies for EBGP channels To comply with RFC 8212 requirements. commit 4db4ac7243bf54187029abda0b42cc9d29757d13 Author: Ondrej Zajicek (work) Date: Sun Jan 14 21:52:58 2018 +0100 NEWS and version update commit 4d3679613179637df5ef999073aba2d187540a57 Author: Ondrej Zajicek (work) Date: Sun Jan 14 14:30:38 2018 +0100 KRT: Fix direct routes for BSD Old way to set direct routes is to use local IP as gateway, but that does not work properly on newer FreeBSDs. Now we use sockaddr_dl containing interface index as gateway. commit 2e507a745733b0cee2ea7d302cc9d626cb2e0c80 Author: Ondrej Zajicek (work) Date: Wed Jan 10 16:17:37 2018 +0100 Use non-fatal asserts even for regular build commit 72163bd5f3ccefc1edda585f6f605c37e774a0b8 Author: Ondrej Zajicek (work) Date: Tue Jan 9 18:42:22 2018 +0100 Nest: Allow modification of channels inherited from templates Multiple definitions of same channels are forbidden, but inherited channel can be redefined. In such case channel options are merged. commit 09c1e370b3084f7acb7c3777427670a69945368a Author: Jan Maria Matejka Date: Tue Jan 9 16:46:00 2018 +0100 Moved freebsd cflags and ldflags to configure commit 94f9be80c3686284942ba73670780d27730da997 Author: Ondrej Zajicek (work) Date: Tue Jan 9 14:36:11 2018 +0100 Nest: Fix filter reconfiguration Function filter_same() must be called with arguments in proper order, otherwise it breaks the new filter, causing crash during route processing. commit 8f8671bcde738890d312ab91336f101465b3eeac Author: Ondrej Zajicek (work) Date: Wed Jan 3 15:44:05 2018 +0100 Filter: Handle undefined BGP paths as empty The same is already done for clists. Also fixes defined() to work properly for paths and clists. commit 0ff86d054efa8005c5df943acf6d2122781d3175 Author: Ondrej Zajicek (work) Date: Wed Jan 3 14:12:00 2018 +0100 ROA: Fix reconfiguration commit 9bd8cb7c3ca23524cb7d69ee503e24658ad2ee42 Merge: d493d0f1 cce6ba4d Author: Ondrej Zajicek (work) Date: Tue Jan 2 16:59:59 2018 +0100 Merge branch 'master' into int-new commit d493d0f180e3df1f33d344d8b28cc1743201210b Author: Ondrej Zajicek (work) Date: Tue Jan 2 16:57:45 2018 +0100 BGP: Fix unknown attribute handling commit e62cd033079c4bc988a467f4122c7c276c77fdde Author: Ondrej Zajicek (work) Date: Tue Jan 2 14:30:08 2018 +0100 BGP: Fix graceful restart timer Should use remote value, not local value. commit cce6ba4daa2e00d6e1881a831d05cdc51249b4a7 Author: Ondrej Zajicek (work) Date: Tue Jan 2 14:11:59 2018 +0100 Remove libhistory check According to GNU Readline developers, if we link with libreadline then there is no need to link with libhistory at all. commit 4842eeaad32aeeeb1774ec9840c6da03952425ff Author: Ondrej Zajicek (work) Date: Thu Dec 21 00:16:52 2017 +0100 Minor fix in documentation commit a63e78c31a518f4441b2f87e1947c12e1e49aba1 Author: Ondrej Zajicek (work) Date: Mon Dec 18 23:15:07 2017 +0100 Fix build without limited protocol set commit e87a95d97d18eb12d005312f27b082f0821d3923 Author: Ondrej Zajicek (work) Date: Sat Dec 16 16:31:43 2017 +0100 Minor fixes for debug mode commit 3013fc57bdc97b0031c4f4250b9bdd172f4c0f4e Author: Ondrej Zajicek (work) Date: Sat Dec 16 00:42:56 2017 +0100 Netlink: Fix memory leak commit 8396094156c2ddae279ec9c265100e28acb65a8d Author: Ondrej Zajicek (work) Date: Thu Dec 14 22:15:01 2017 +0100 Minor cleanups commit abd4367f483bc29a03cce8bcfc70a83ac5d13cdc Author: Ondrej Zajicek (work) Date: Thu Dec 14 21:52:07 2017 +0100 Minor cleanup commit c36a298c21f1aa5b4e61d2d4740811529175df09 Author: Ondrej Zajicek (work) Date: Wed Dec 13 19:18:30 2017 +0100 Use git describe for BIRD version Based on patch from Pavel Tvrdik commit d807ea087f8d60e25eaef8c10168a40ca6545c57 Author: Ondrej Zajicek (work) Date: Wed Dec 13 15:57:44 2017 +0100 BGP: Fix non-transitive ext communities commit 3e7923507b40b42c80dc621aff9d896106bae8c7 Author: Ondrej Zajicek (work) Date: Wed Dec 13 15:26:29 2017 +0100 Netlink: Use linpool instead of static buffer commit 772beb7308a53558e153223bc42742f719ff4a40 Author: Ondrej Zajicek (work) Date: Wed Dec 13 14:49:55 2017 +0100 Lib: Minor fix commit cb21c5ffa92494b1a4bf110605509de3326b6c3d Merge: 71c51aa4 1e11918c Author: Jan Maria Matejka Date: Wed Dec 13 10:29:10 2017 +0100 Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new commit 71c51aa4ab0daa3490f9a488f505eb25102c4705 Author: Jan Maria Matejka Date: Wed Dec 13 10:28:50 2017 +0100 Doc: Fixed misc sgml bugs, no content change commit 1e11918c8c56e3505193f4e6426c1a34aaae3941 Author: Ondrej Zajicek (work) Date: Tue Dec 12 19:51:36 2017 +0100 Lib: Save/restore state for linpools Also change linpool.current ptr to really point to thr current chunk. commit ac48e72bf6f9f491824e2de59a035c93aab8f81b Author: Ondrej Zajicek (work) Date: Tue Dec 12 15:56:31 2017 +0100 Fix some minor issues commit cb5df823acdc54f94b0b85094cb59ac68c83c33a Author: Ondrej Zajicek (work) Date: Tue Dec 12 15:22:01 2017 +0100 Minor CI tweak commit b5257bea853850809be7f03eb0e1dbb398c56c34 Author: Ondrej Filip Date: Tue Dec 12 10:43:56 2017 +0100 Removed '--enable-ipv6' reference. commit 66acbc8d7f80ce3c197549922b60fca093129047 Author: Ondrej Zajicek (work) Date: Tue Dec 12 00:05:49 2017 +0100 Revive FIB and kernel MPLS code commit fa5c09a2e708ed505ca140531b98e695fdaf989c Author: Ondrej Filip Date: Mon Dec 11 09:36:21 2017 +0100 Changes to be able to build 2.0.0 commit d4eada9e0f3dc1f1e22b83fc8a8361ae256592ff Author: Ondrej Zajicek (work) Date: Mon Dec 11 02:05:35 2017 +0100 NEWS and version update commit c99050cce228b214c2856c6eebefbefffccade7f Author: Ondrej Zajicek (work) Date: Mon Dec 11 01:04:15 2017 +0100 KRT: Fix bug in multipath handling commit cf3e3845c205dacf2720cdb76a9a004a816d2e6f Author: Ondrej Zajicek (work) Date: Sun Dec 10 22:47:38 2017 +0100 Doc: Documentation update commit 6b0f5f68a8ae35b05abb144cf998bf537dfa283b Author: Maria Jan Matejka Date: Mon Sep 25 13:00:05 2017 +0200 Switchoff for MPLS in kernel. commit 67a2eb9177fe0b8a6854775a4fad1f7768f6a94a Author: Ondrej Zajicek (work) Date: Sun Dec 10 13:18:36 2017 +0100 Lib: Check size of nets commit a32a7b58cebc2838de2ffd94e679d3e1ec9d493a Author: Ondrej Zajicek (work) Date: Sun Dec 10 13:16:31 2017 +0100 Lib: Fix macro/keyword collisions Old code breaks with some versions of bison commit 7fc55925beb06059759294e0e9b7bae45465395f Author: Ondrej Zajicek (work) Date: Sun Dec 10 00:55:34 2017 +0100 Several minor fixes commit ed1d853e5147376086e25f5edae9804cf242d6e0 Author: Ondrej Zajicek (work) Date: Fri Dec 8 17:31:33 2017 +0100 Filter: Remove old BGP path mask syntax from tests commit dea9886454c1c0953b5977dd8a96718be465b962 Author: Ondrej Zajicek (work) Date: Fri Dec 8 17:00:47 2017 +0100 BGP: Link check just for single-hop commit 3e52d112d714545df3cd97119824ee94c27a0606 Author: Jan Maria Matejka Date: Wed Sep 27 16:55:09 2017 +0200 Docs: Update to v2.0 commit 517d05dff17e881b880ee4fd28a72e827c10e8c3 Author: Ondrej Zajicek (work) Date: Fri Dec 8 15:59:44 2017 +0100 Enable ECMP and Link detection by default ECMP is not enabled on BSD, where it is not supported by BIRD. commit eb95b5ec1a5c3bd4e57f3a134828f8de2875cb43 Author: Ondrej Zajicek (work) Date: Fri Dec 8 15:16:47 2017 +0100 Nest: Minor formatting changes commit 49c7ef3b21e51ae7d1969baa52b4d8fd29b22eeb Author: Ondrej Zajicek (work) Date: Fri Dec 8 14:00:36 2017 +0100 BGP: Fix IPv6 MPLS/VPN multicast SAFI commit ccee67ca3b607130bf441b6060b88525b5e50ad9 Author: Ondrej Zajicek (work) Date: Fri Dec 8 02:26:17 2017 +0100 BGP: Autoconfigure BGP next hops from preferred addresses commit 830ba75e6dd369c3e64d122f0537cc85211e56e6 Merge: 46434a3c 1e8721e2 Author: Ondrej Zajicek (work) Date: Thu Dec 7 21:54:47 2017 +0100 Merge commit '1e8721e2aeccfbc3f533e8b8abc07582cee77e9a' into int-new commit 46434a3cad99260b5a659e5df874eab4615bcb36 Merge: 4ff15a75 7b2c5f3d Author: Ondrej Zajicek (work) Date: Thu Dec 7 18:35:46 2017 +0100 Merge commit '7b2c5f3d2826e3175bf31b1c36056c9efc587a2b' into int-new commit 4ff15a75c56531fa2d3858d8250dcef1af4e75b6 Merge: cd80c9b0 98bb80a2 Author: Ondrej Zajicek (work) Date: Thu Dec 7 17:41:09 2017 +0100 Merge commit '98bb80a243b58c43453e9be69d19d0350286549c' into int-new commit cd80c9b0700ef9533a19ab19d66c38a1722c4e08 Author: Ondrej Zajicek (work) Date: Thu Dec 7 14:21:38 2017 +0100 BSD: Fix in the last commit commit a6f79ca57f0b4b296f67c2d063fd85a627b611b8 Author: Ondrej Zajicek (work) Date: Tue Nov 28 17:43:20 2017 +0100 Timers: Revert temporary names and remove old timer.h commit 574b2324275d3292e98a8e329f791eb5c799f7f2 Author: Ondrej Zajicek (work) Date: Tue Nov 28 17:06:10 2017 +0100 Timers: Fix TBF and some last remains commit 3b3b0910ffb1b212b1c9ea420db6c575a3ecb71a Author: Ondrej Zajicek (work) Date: Tue Nov 28 15:11:41 2017 +0100 Babel: More changes and bugfixes Several changes and bugfixes in Babel, namely: - Exported route parameters stored directly in route table entry - Exported non-babel routes no longer stored in per-entry route list - Route update, selection and retraction simplified and fixed - Route feasibility is evalualated per update and stored with route - Unreachable route handling fixed, based on hold interval - Added 'show babel routes' command Overall, it fixes some issues with proper propagation of triggered updates, making Babel convergence after topology change almost instant. commit dbf1ed263c1c15f79fb200b4dfe3bffea231f4e4 Author: Ondrej Zajicek (work) Date: Wed Nov 8 14:35:52 2017 +0100 Babel: Fix handling of seqno requests Old behavior has several deficiencies compared to standard behavior (no triggered updates for replies, no retransmissions, ...). commit 672fb78e1272bb49cc2521176effe75e3cb22460 Author: Ondrej Zajicek (work) Date: Wed Nov 8 14:15:11 2017 +0100 Babel: Fix handling of IPv4 retractions Babel TLV parsing code rejected IPv4 retractions without next-hop, although next-hop is needed just for regular updates. commit 268dc7c8b3c45412fc8f4b0bae451e51c4c48b31 Author: Ondrej Zajicek (work) Date: Fri Oct 27 12:20:58 2017 +0200 Babel: Remove babel_proto ptr from babel_entry commit 738a57b69bdff6244cf5093ae3997290e6c11324 Author: Ondrej Zajicek (work) Date: Wed Oct 25 17:59:57 2017 +0200 Babel: Fix hello timeout for short hello intervals commit b47eaefe12d0673af2c7c7ec1a8adff982a958ca Author: Ondrej Zajicek (work) Date: Wed Oct 25 17:14:08 2017 +0200 Babel: Revamp cost computation and run route selection when cost change Also fix several minor bugs and add 'limit' option for k-out-of-j link sensing strategy. Change default from 8-of-16 to 12-of-16. Change IHU expiry factor from 1.5 to 3.5 (as in RFC 6126). commit f00221fadbb2c85c835cc5e4e69a0d3ce13d31b3 Author: Ondrej Zajicek (work) Date: Fri Oct 13 23:46:41 2017 +0200 Babel: Fix unicast seqno requests commit 38f4721092f5a835248f9f521d34990ec9883dbd Author: Ondrej Zajicek (work) Date: Fri Oct 13 19:34:34 2017 +0200 Babel: Avoid batch seqno updates commit 5ee69d11f2e859b77ff04bb4068f43082fd1794f Author: Ondrej Zajicek (work) Date: Fri Oct 13 19:33:42 2017 +0200 Babel: Fix Hello and IHU expiration commit 8b58f565e4fcd076e2d9fe008c7f2b19e264b319 Author: Ondrej Zajicek (work) Date: Fri Oct 13 12:34:08 2017 +0200 Babel: Update to new timers commit 6b5cd7c05f82e87d67c1b41296021757a3d952a0 Author: Ondrej Zajicek (work) Date: Wed Jun 21 15:38:11 2017 +0200 Sysdep: Remove old timer code commit 3e405fb188bee0bb8fcf91f574126771c8661afb Author: Ondrej Zajicek (work) Date: Wed Jun 21 14:43:49 2017 +0200 Nest: Update to new timers commit cc881bd15561224f507ed7162016114ed2b15a1e Author: Ondrej Zajicek (work) Date: Wed Jun 21 14:14:51 2017 +0200 BGP: Update to new timers commit b32d557a6eca10c1e1dc2f2ab83e201f53d134b4 Author: Ondrej Zajicek (work) Date: Tue Jun 20 18:03:06 2017 +0200 OSPF: Update to new timers Note that recurrent timers are currently limited to ~1 hour. commit ee528fbd5dc482ceece52832d4a8ea5a08251bfa Author: Ondrej Zajicek (work) Date: Tue Jun 20 15:55:39 2017 +0200 Timers: Add typecast to unit-converting macros commit 92cc1e745758893a57a2432a0e11e4cd3ad289b7 Author: Ondrej Zajicek (work) Date: Tue Jun 20 14:30:44 2017 +0200 RIP: Update to new timers commit c521b3ac324e1c97b22581a06172dcb08fd740f6 Author: Ondrej Zajicek (work) Date: Wed Jun 14 17:02:11 2017 +0200 RAdv: Update to new timers commit d59c1a295834aa5cc63aceb6769c8413fa0639fe Author: Ondrej Zajicek (work) Date: Wed Jun 14 16:32:15 2017 +0200 RPKI: Update to new timers commit 21f4f0f4b0785e30ce2af4741ffa6f2ebdd7d714 Author: Ondrej Zajicek (work) Date: Wed Jun 14 13:15:35 2017 +0200 Kernel: Update to new timers commit d3fa9e84e98d7b8c726f5e35d6a359971eb98f94 Author: Ondrej Zajicek (work) Date: Tue Jun 13 16:52:21 2017 +0200 Timers: Show sub-second times in some protocol outputs commit 212eda07c4e481e3341ede37b0877fa22bc042a4 Author: Ondrej Zajicek (work) Date: Tue Jun 13 15:55:13 2017 +0200 Timers: Fix tests after timer change commit 49fc021337eba2e9cea228e80e1f95ef21b30cd2 Author: Ondrej Zajicek (work) Date: Tue Jun 13 15:41:49 2017 +0200 Printf: Add support for microsecond times Use '%t' in bsnprintf() for microsecond times (in btime) with variable sub-second precision. commit f047271cb963c62663687d63b2f7cf8dd5edfbb7 Author: Ondrej Zajicek (work) Date: Tue Jun 6 16:47:30 2017 +0200 Timers: Parse and format functions for microsecond times Date/time output (e.g. in logs, show commands) can use %f to specify subsecond time. By default, millisecond precision is used in output. commit 025525266f6861437ca54aca2a86eb505a486baf Author: Ondrej Zajicek (work) Date: Thu Jun 1 12:33:20 2017 +0200 Timers: Replace old timers with microsecond timers The old timer interface is still kept, but implemented by new timers. The plan is to switch from the old inteface to the new interface, then clean it up. commit 28a7d3943ef915c405b3552ae06f639a86f4dc1e Author: Ondrej Zajicek (work) Date: Wed May 31 15:46:04 2017 +0200 Timers: Integrate microsecond timers to the main loop commit 534215a18fb3fb7ce5b26c9e6ec1fdb32bf22ae6 Author: Ondrej Zajicek (work) Date: Tue May 30 19:12:35 2017 +0200 Timers: Split microsecond timers from BFD code to lib commit 7c454d918682c072a6ae6ad8e0cd8d35b9edd2aa Author: Ondrej Zajicek (work) Date: Thu Dec 7 13:44:00 2017 +0100 BSD: Minor fix of penultimate commit commit abae1cc58b7c4ccf683651a6fcd51cfaecd03566 Author: Ondrej Zajicek (work) Date: Thu Dec 7 13:28:24 2017 +0100 KRT: Minor fix of last commit commit 153f02da3bce1f3f1a99295648679c71327e8319 Author: Ondrej Zajicek (work) Date: Thu Dec 7 13:06:01 2017 +0100 Nest: Maintain separate IPv4, IPv6 and LLv6 preferred addresses Also redesign preferred address selection and update protocols to use appropriate preferred address. Based on a previous work by Jan Maria Matejka. commit 1e8721e2aeccfbc3f533e8b8abc07582cee77e9a Author: Ondrej Zajicek (work) Date: Tue Nov 28 19:33:33 2017 +0100 Babel: Parse flags in Hello TLV RFC6126bis introduces a flags field for the Hello TLV, and adds a unicast flag that is used to signify that a hello was sent as unicast. This adds parsing of the flags field and ignores such unicast hellos, which preserves compatibility until we can add a proper implementation of the unicast hello mechanism. Thanks to Toke Hoiland-Jorgensen for the patch. commit 9ba4b4a63d27943586b76574b7f310ee532509a3 Author: Jan Maria Matejka Date: Thu Nov 9 15:04:05 2017 +0100 Filter test: typo fix commit 4ae3ee1200b386219673c2168eae996c6207b077 Author: Jan Maria Matejka Date: Tue Aug 22 13:47:01 2017 +0200 Babel: Interface address irrelevant for interface pattern matching. commit 289c1a7968c5a3c0a76124a89eb45de010f1c640 Author: Jan Moskyto Matejka Date: Mon Aug 21 14:14:07 2017 +0200 Iface address debug dump fix commit 2d7fb19c3c6eadfbd9b994f5c306e79b7c4ee994 Author: Ondrej Zajicek (work) Date: Tue Oct 10 16:07:54 2017 +0200 OSPF: Add option to disable OSPFv3-AF commit 2549300b54f262932dd14e6d465926627e6dc8ef Author: Ondrej Zajicek (work) Date: Mon Oct 9 21:11:53 2017 +0200 OSPF: Fix minor issue in TTL check The TTL check must be done after instance ID dispatch to avoid warnings when a physical iface is shared by multiple instances and some use TTL security and some not. commit f097f7659c7ff226a53c51673158e32fb69a6d21 Author: Ondrej Zajicek (work) Date: Mon Oct 9 20:36:14 2017 +0200 OSPF: Fix next hop calculation for PtP links in IPv4 OSPFv3-AF In such case, next hop has to be taken from Link-LSA like in broadcast case, not from neighbor source address like in other PtP cases. Also add some checks, comments and code cleanup. commit d3f4f92b0ece0ce4031087a25735e6cbf0d741e2 Author: Ondrej Zajicek (work) Date: Mon Oct 9 01:16:29 2017 +0200 OSPF: Support of address families in OSPFv3 OSPFv3-AF can handle multiple topologies of diferent address families (IPv4, IPv6, both unicast and multicast) using separate instances distinguished by instance ID ranges. commit d9573a40ecaf9758690e4482782bebaf7847ba9b Author: Ondrej Zajicek (work) Date: Tue Oct 10 15:06:39 2017 +0200 Doc: Update sgml2* tools The old ones do not work on current Debian. commit 7e8d6116df68e96ef4abd64f6b9cbe7406c5985d Author: Ondrej Zajicek (work) Date: Tue Oct 10 13:27:03 2017 +0200 Doc: Fix reference commit 18352188ed7415ddb3aa7b0d7a2fc16d57a2d5d2 Author: Michal 'vorner' Vaner Date: Tue Sep 19 17:23:31 2017 +0200 RAdv: Documentation for more specific routes commit 7c0bab3a3987b42bc699c4417c7b2e838f189158 Author: Ondrej Zajicek (work) Date: Fri Oct 6 12:22:18 2017 +0200 RAdv: Change specific route options to be per-interface And change default values of specific route options to be consistent with values of default router options. commit 2a95e63343a94243745e5d7000bb3e0cb61a4a0f Author: Michal 'vorner' Vaner Date: Thu Aug 31 15:40:23 2017 +0200 RAdv: Support for more specific routes (RFC 4191) The patch implements Default Router Preferences and More-Specific Routes (RFC 4191) for RAdv protocol, allowing to announce router preference and more specific routes in router advertisements. Routes can be exported to RAdv like to regular routing protocols. Some cleanups, bugfixes and other changes done by Ondrej Zajicek. commit 5a8b1fb047d675badc17ab24175d0db06d7cc00c Author: Michal 'vorner' Vaner Date: Tue Sep 5 15:50:00 2017 +0200 filter: Allow assigning enums into extended attributes They are internally ints, but they got refused as a wrong type. This fixes setting of the BGP origin and is also needed for RA. commit cd1d99611e445c9fe2452d05627ccfc624f35c39 Author: Ondrej Zajicek (work) Date: Tue Sep 19 19:55:37 2017 +0200 BGP: Shutdown communication (RFC 8203) The patch implements BGP Administrative Shutdown Communication (RFC 8203) allowing BGP operators to pass messages related to BGP session administrative shutdown/restart. It handles both transmit and receive of shutdown messages. Messages are logged and may be displayed by show protocol all command. Thanks to Job Snijders for the basic patch. commit 7b2c5f3d2826e3175bf31b1c36056c9efc587a2b Author: Michal 'vorner' Vaner Date: Thu Sep 14 12:31:15 2017 +0200 Docs: FIB iteration macros commit 18ea2ea759963a68a1a9f82d50aa9ed90b128df9 Author: Ondrej Zajicek (work) Date: Wed Sep 13 13:10:50 2017 +0200 Doc: Document 'empty' operator Thanks to Alexander Zubkov for the notification. commit f2dd602fef2ecf0a6598b817d71ce2ee8fadd5cc Author: Ondrej Zajicek (work) Date: Tue Sep 12 16:33:29 2017 +0200 Backport some minor changes from int-new commit 9f4908fe78cb3e5191bca721588ee1acb10876e3 Author: Ondrej Zajicek (work) Date: Tue Sep 12 15:49:36 2017 +0200 Nest: VRF support for neighbor cache and olock code Actually much simpler than expected. commit 943478b00f585725c3e7406909ee867dcfac5f87 Author: Ondrej Zajicek (work) Date: Wed Sep 6 17:38:48 2017 +0200 Basic VRF support Add basic VRF (virtual routing and forwarding) support. Protocols can be associated with VRFs, such protocols will be restricted to interfaces assigned to the VRF (as reported by Linux kernel) and will use sockets bound to the VRF. E.g., different multihop BGP instances can use diffent kernel routing tables to handle BGP TCP connections. The VRF support is preliminary, currently there are several limitations: - Recent Linux kernels (4.11) do not handle correctly sockets bound to interaces that are part of VRF, so most protocols other than multihop BGP do not work. This will be fixed by future kernel versions. - Neighbor cache ignores VRFs. Breaks config with the same prefix on local interfaces in different VRFs. Not much problem as single hop protocols do not work anyways. - Olock code ignores VRFs. Breaks config with multiple BGP peers with the same IP address in different VRFs. - Incoming BGP connections are not dispatched according to VRFs. Breaks config with multiple BGP peers with the same IP address in different VRFs. Perhaps we would need some kernel API to read VRF of incoming connection? Or probably use multiple listening sockets in int-new branch. - We should handle master VRF interface up/down events and perhaps disable associated protocols when VRF goes down. Or at least disable associated interfaces. - Also we should check if the master iface is really VRF iface and not some other kind of master iface. - BFD session request dispatch should be aware of VRFs. - Perhaps kernel protocol should read default kernel table ID from VRF iface so it is not necessary to configure it. - Perhaps we should have per-VRF default table. commit 98bb80a243b58c43453e9be69d19d0350286549c Author: Ondrej Zajicek (work) Date: Tue Sep 5 00:02:20 2017 +0200 KRT: Fix IPv6 ECMP handling with Linux 4.11+ Starting from Linux 4.11, IPv6 ECMP routes are now notified using RTA_MULTIPATH, like IPv4 ones. The patch adds support for RTA_MULTIPATH parsing for IPv6 routes. This also enables to parse ECMP alien routes correctly. Thanks to Vincent Bernat for the original patch. commit 9befc7cc4f26889077ace537019de92903139133 Author: Ondrej Zajicek (work) Date: Mon Sep 4 22:32:45 2017 +0200 BSD: Fix alignment issue Incorrect structure alignment breaks kernel routing table updates on FreeBSD/ARM (and perhaps other platforms). Thanks to Eugene Sevastyanov for the original patch. commit 96eace1ea70d7c2bc13672fbeba104d34d8ede4c Merge: 08b6a617 5c4dfe0c Author: Michal 'vorner' Vaner Date: Mon Sep 4 13:30:13 2017 +0200 Merge branch 'gitlab-ci' commit 5c4dfe0c30e5516fac73e6ed8455af2245ebc62a Author: Michal 'vorner' Vaner Date: Thu Aug 17 15:02:35 2017 +0200 Gitlab CI support Add configuration and docker definitions for tests and builds in Gitlab CI platform. Some of them currently fail, which is a known problem. commit 08b6a617e862ffc7b7460abb79fe4c198806517c Author: Ondrej Zajicek (work) Date: Tue Aug 29 19:17:35 2017 +0200 RAdv: Some style nitpicks commit ec7d6a506ecae89e5019ce7fcb380a713be28bce Author: Michal 'vorner' Vaner Date: Thu Aug 17 11:34:25 2017 +0200 RAdv: Configure how long a dead prefix is advertised commit e2d2b3ef21f082a034e79d0880d4b36428029a59 Author: Michal 'vorner' Vaner Date: Fri Aug 11 12:25:36 2017 +0200 RAdv: Buffer prefixes awhile after they disappear Keep a cache of all the relevant prefixes we send out. When a prefix appears, insert it into the cache. If it dies, keep it there for a while, marked as dead. Send out the dead prefixes with zero lifetime. commit 3ac5d1ce4c10719dd48555521a50d4a9c5eadd15 Author: Michal 'vorner' Vaner Date: Wed Aug 9 16:00:16 2017 +0200 RAdv: Extract prefix option preparation Put the prefix option preparation into a separate function. We're going to reuse that bit of code. commit e7ed9ecba77162b4c09f34354378b0e752b9078e Author: Ondrej Zajicek (work) Date: Tue Aug 22 14:03:38 2017 +0200 Client: Fix include commit 080d9e4ce25f8f14e61ba0a81d5385bf8de3e48f Author: Michal 'vorner' Vaner Date: Thu Aug 10 14:35:14 2017 +0200 Nicer log output non-primary is ugly, just omit it (and use primary in the other case). commit 5699a2036cfb32cb3a683814f83242eb21e40d02 Author: Michal 'vorner' Vaner Date: Thu Aug 10 13:06:05 2017 +0200 Less confusing log message A non-primary address isn't necessarily secondary, that's an independent flag. commit 15a4421f9cb2c077cc484e3cda94e8710a1d68f5 Author: Michal 'vorner' Vaner Date: Thu Aug 10 12:32:30 2017 +0200 Fix bird.conf example Make it syntactically correct, so it is accepted. commit 9b776458efdfae0c30b97f3670a1f4646221f072 Author: Michal 'vorner' Vaner Date: Wed Aug 9 13:39:20 2017 +0200 Gitignore: File created by autoreconf commit da390bb11c8efc70767fc4b6d00bebf558d3b00f Author: Michal 'vorner' Vaner Date: Wed Aug 9 13:35:55 2017 +0200 Drop stale TODO A TODO file last updated 5 years ago is useless. commit 69f73992477a0e29f939f9e2722f705c4ad72a38 Merge: 5a41eed2 b3fae3a8 Author: Ondrej Zajicek (work) Date: Wed Aug 9 12:46:27 2017 +0200 Merge branch 'master' into int-new commit b3fae3a81796b6deea48445402793660fade5eb6 Author: Ondrej Zajicek (work) Date: Wed Aug 9 12:41:44 2017 +0200 RAdv: Fix typo commit 1f182675c816e4708312f99dd817fb894f3a90b3 Author: Michal 'vorner' Vaner Date: Tue Aug 8 14:40:51 2017 +0200 RAdv: Style updates Adapt the naming conventions to be a bit closer to the other protocols. proto_radv -> radv_proto struct radv_proto *ra -> struct radv_proto *p struct proto *p -> struct proto *P commit 5a41eed26d1b12861ba0ecddcd7cade335d2a192 Author: Michal 'vorner' Vaner Date: Tue Aug 8 14:40:51 2017 +0200 RAdv: Style updates Adapt the naming conventions to be a bit closer to the other protocols. proto_radv -> radv_proto struct radv_proto *ra -> struct radv_proto *p struct proto *p -> struct proto *P commit 637ed49868c56c0e05467f0e0ddb6aa1231deaa4 Author: Michal 'vorner' Vaner Date: Fri Aug 4 10:52:57 2017 +0200 radv: Fix RFC reference in comments commit afd9845e2636146a66508639614a93167d5d1728 Author: Michal 'vorner' Vaner Date: Fri Aug 4 10:52:57 2017 +0200 radv: Fix RFC reference in comments commit b4a33e21ea3a8d23dee3ed23a515cc7430a38643 Author: Martin Mares Date: Tue Jul 18 23:48:25 2017 +0200 Configure: Fix a typo in checking of backtrace() commit a1f5e514ef091b82754f38f0e583af40778c7d97 Author: Ondrej Zajicek (work) Date: Tue Jul 4 23:36:21 2017 +0200 Implement onlink flag for nexthops Add proper support for per-nexthop onlink flag in routes to handle next hop addresses that are not covered by interface IP ranges. Supported by kernel and static protocols. Thanks to Vincent Bernat for the idea. commit e46128fb50e108e8cfdf6bb6e9ab040e00f5dfdc Author: Ondrej Zajicek (work) Date: Mon Jun 19 12:46:40 2017 +0200 Filters: Do not clamp EC set values to 16 bit for EC_GENERICs Thanks to Lennert Buytenhek for the patch. commit 5220cb63e34961b097d3bc274e394c0fa946d7d3 Author: Ondrej Zajicek (work) Date: Wed Jun 14 12:34:43 2017 +0200 Babel: Fix pointer arithmetic in subtlv parsing The subtlv parsing code was doing byte-based arithmetic with non-void pointers, causing it to read beyond the end of the packet. Signed-off-by: Toke Høiland-Jørgensen commit 145ebfa1df9ad252af61cce01cc0f09db45f7c9d Author: Ondrej Zajicek (work) Date: Fri Jun 9 14:33:06 2017 +0200 Babel: Parse sub-TLVs and skip TLVs with mandatory sub-TLV RFC6126bis formally introduces sub-TLVs to the Babel protocol, including mandatory sub-TLVs. This adds support for parsing sub-TLVs to the Babel protocol and skips TLVs that contain mandatory sub-TLVs, as per the spec. For details, see section 4.4 of https://tools.ietf.org/html/draft-ietf-babel-rfc6126bis-02 Thanks to Toke Høiland-Jørgensen for the patch. commit b3c6273efaa15976cc1290f00d5abde4991e184e Author: Ondrej Zajicek (work) Date: Fri Jun 9 13:00:20 2017 +0200 Babel: Implement IPv6 prefix compression on outgoing updates Previously, the Babel protocol would never use prefix compression on outgoing updates (but would parse it on incoming ones). This adds compression of IPv6 addresses of outgoing updates. The compression only works to the extent that the FIB is walked in lexicographic order; i.e. a prefix is only compressed if it shares bytes with the previous prefix in the same packet. Thanks to Toke Høiland-Jørgensen for the patch. commit 300bd0eb85d14523ea7f0a7a3a4d92184f3c4fb3 Author: Ondrej Zajicek (work) Date: Fri Jun 9 11:56:20 2017 +0200 Babel: Add documentation for dual-stack operation and options This updates the documentation for the Babel protocol to mention the fact that it now supports dual-stack operation, and adds documentation for the new next hop options. Thanks to Toke Høiland-Jørgensen for the patch. commit 4324025f981a8f545cc28ab16426ab7c2d1843cd Author: Ondrej Zajicek (work) Date: Thu Jun 8 12:18:16 2017 +0200 Babel: Add support for dual-stack IPv4/IPv6 operation This adds support for dual-stack v4/v6 operation to the Babel protocol. Routing messages will be exchanged over IPv6, but IPv4 routes can be carried in the messages being exchanged. This matches how the reference Babel implementation (babeld) works. The nexthop address for v4 can be configured per interface, and will default to the first available IPv4 address on the given interface. For symmetry, a configuration option to configure the IPv6 nexthop address is also added. Thanks to Toke Høiland-Jørgensen for the patch. commit 801fd81efea5bf51fe459d951e4be95119798b2b Merge: 77810030 33f7fbc4 Author: Ondrej Zajicek (work) Date: Wed May 31 14:12:03 2017 +0200 Merge branch 'master' into int-new commit 33f7fbc42d0490b27e33275d0fc74d3ef55683e4 Author: Ondrej Zajicek (work) Date: Wed May 31 13:31:03 2017 +0200 CLI: Fix bug in symbol handling introduced in previous patches commit 77810030d2556e3af659d354a2b3d661f58dd735 Merge: a1dc5267 4fec4306 Author: Ondrej Zajicek (work) Date: Tue May 30 14:44:37 2017 +0200 Merge branch 'master' into int-new commit 4fec43067e27c7a6c20a6ef9909bef0238984a64 Author: Ondrej Zajicek (work) Date: Tue May 30 14:43:49 2017 +0200 Workaround for older bisons commit a1dc5267602062562f9adca7acfbbc2fee3b315e Merge: 4b2aef88 b7761af3 Author: Ondrej Zajicek (work) Date: Thu May 25 23:37:50 2017 +0200 Merge branch 'master' into int-new commit b7761af34dc4ed3f1bdf874eb85d743b931b0af6 Author: Ondrej Zajicek (work) Date: Thu May 25 23:30:39 2017 +0200 Conf: Replace keyword and symbol hash table with generic hash table. The old hash table had fixed size, which makes it slow for config files with large number of symbols and symbol lookups. The new one is growing according to needs. commit 4b2aef8857a9ac23015e410930d2162d945892f0 Merge: 6aaaa635 c72b660b Author: Ondrej Zajicek (work) Date: Tue May 23 18:45:33 2017 +0200 Merge branch 'master' into int-new commit c72b660b7423b0fb687794b722884cd6e5e6c562 Author: Ondrej Zajicek (work) Date: Tue May 23 18:39:20 2017 +0200 Client: Fix isspace() calls Function isspace() expects to get *unsigned* chars (encoded as ints), not that it matters for plain ASCII. commit 6aaaa63519c88c872f15dcc639643103b563b1c6 Author: Ondrej Zajicek (work) Date: Tue May 23 17:22:53 2017 +0200 Change parser to handle numbers as unsigned Lexer always parsed numbers as unsigned, but parser handled them as signed and grammar contained many unnecessary checks for negativity. commit 0705a1c5658c2682c915007f466f55d2a8f7ec14 Author: Pavel Tvrdik Date: Thu Jun 30 15:04:49 2016 +0200 Add a hint for an invalid IP prefix bird> eval 200.210.220.0/16 Invalid IPv4 prefix 200.210.220.0/16, maybe you wanted 200.210.0.0/16 bird> eval 1000:2000::/8 Invalid IPv6 prefix 1000:2000::/8, maybe you wanted 1000::/8 commit 734e9fb8a933898cd3396786c06728bce6a754e5 Author: Ondrej Zajicek (work) Date: Tue May 23 13:12:25 2017 +0200 Minor cleanups and fixes commit bb7aa06a48f52813a019861a0e06ce9fe4d20c4b Author: Ondrej Zajicek (work) Date: Fri May 19 00:33:52 2017 +0200 Fix type mixing in flowspec formatting Variable of u64 type was passed to vararg function as uint. commit e521150b8f6bed678527da1cf96e75026b86fe4f Author: Ondrej Zajicek (work) Date: Thu May 18 14:51:36 2017 +0200 Fix VPN-RD parsing on 32-bit systems When shift count >= width of type the behavior is undefined. commit 5a9169e152779ac6f99e2eccb79a2a2f6e2c76b2 Merge: 7d5e61a6 78e4dac9 Author: Ondrej Zajicek (work) Date: Thu May 18 14:28:03 2017 +0200 Merge branch 'master' into int-new commit 78e4dac993ad018bee98e245f6e858e18cc5db8a Author: Ondrej Zajicek (work) Date: Thu May 18 14:26:57 2017 +0200 Fix some forgotten warnings commit 7d5e61a66a3d4ecd004f3aa44a3d1bd3682ccf07 Author: Ondrej Zajicek (work) Date: Thu May 18 13:29:38 2017 +0200 Fix of the previous fix Avoid empty macro argument to avoid default behavior. commit 271fa063a3e2078d7a046146ac2da3718b080cfa Author: Ondrej Zajicek (work) Date: Thu May 18 12:05:09 2017 +0200 Fix minor bug in configure script Space in action branch breaks build on some platforms. commit 9b701e69cc812260788eced3370c7e65cd0e25fe Merge: d19617f0 d6e01ff9 Author: Ondrej Zajicek (work) Date: Wed May 17 17:37:27 2017 +0200 Merge branch 'master' into int-new commit d6e01ff90024fcee259eb145f38a0f5b000e4798 Author: Ondrej Zajicek (work) Date: Wed May 17 17:30:23 2017 +0200 Fix of the previous commit commit dab6706abad3be5b8efd44fe860689df44d20e83 Author: Ondrej Zajicek (work) Date: Wed May 17 17:03:36 2017 +0200 History lib may be integrated to Readline lib commit 81edd3b3a78265b87c2ec6100dce852db5f40d2b Author: Ondrej Zajicek (work) Date: Wed May 17 16:05:07 2017 +0200 Fix build on systems with dirty headers commit d19617f06b4526bccc2fc5e5e15c43c754b99a4d Merge: 144c10fa 31874783 Author: Ondrej Zajicek (work) Date: Wed May 17 14:50:00 2017 +0200 Merge remote-tracking branch 'origin/int-new' into int-new commit 144c10fad1ed6a2520abd1c43501ce00ea2699db Merge: 1c5b4c5d a01e951d Author: Ondrej Zajicek (work) Date: Wed May 17 14:38:04 2017 +0200 Merge branch 'master' into int-new commit a01e951d0fa452fea10a9faca0fbdc9c7cacff23 Author: Ondrej Zajicek (work) Date: Wed May 17 13:17:40 2017 +0200 One more configure cleanup Simplify BIRD client library checks, add proper devel header checks and prefer dependency on just tinfo than full ncurses. commit 31874783c44dd59c355921908016f9b42d22ef02 Author: Jan Moskyto Matejka Date: Tue May 16 15:47:41 2017 +0200 Client: manipulate history only if interactive commit 05d47bd53e71480f1b276bd895f1c25088201e48 Author: Jan Moskyto Matejka Date: Tue May 16 14:31:16 2017 +0200 Linpool: default allocation size commit b880e3ffaea12c3231975157bc51b5f90a2f2433 Author: Jan Moskyto Matejka Date: Tue May 16 10:35:10 2017 +0200 Bird readline client saves its history. commit 1c5b4c5d5b937fe6bbc3a599296e40a05f022b33 Merge: fd1f355b b845ea09 Author: Ondrej Zajicek (work) Date: Tue May 16 14:18:25 2017 +0200 Merge branch 'master' into int-new commit b845ea097c285f17641d60df3dea4d3e820a1475 Author: Ondrej Zajicek (work) Date: Thu May 11 01:29:39 2017 +0200 Remove autoconf macros for time_t and alignment Replaced by constant compile-time expressions. CPU_STRUCT_ALIGN is not really correct, but is consistent with the old behavior. commit b81a73d1fbddda4c319899910d751215ff3d29ca Author: Ondrej Zajicek (work) Date: Tue May 9 18:58:22 2017 +0200 Minor autoconf cleanups Make indentation and quotation consistent in configure macros. Also remove --with-sysinclude option, which was broken for 7 years and nobody complained. Thanks to Ruben Kerkhof for source patches. commit e40542ef3a415d163a5ff5fee26c888fead79fa6 Author: Ondrej Zajicek (work) Date: Tue May 9 16:46:41 2017 +0200 Minor autoconf cleanup and documentation update commit c253ec3a9c45cfce3661f38bc2f5156d4bdd7969 Author: Ondrej Zajicek (work) Date: Tue May 9 13:44:02 2017 +0200 Some more autoconf cleanups Replace integer type width detection with C99 fixed-width types. Also remove some unused or obsolete code. Thanks to Ruben Kerkhof for the patchset. commit f8d44b01df5d93681e116ccbff39cc4618632825 Author: Jan Moskyto Matejka Date: Mon May 15 12:10:51 2017 +0200 Nest: split route show into separate file commit fd1f355b7b24f354f7d57f127911b4fd98354b34 Merge: 525a88d8 71652572 Author: Ondrej Zajicek (work) Date: Tue May 9 17:37:38 2017 +0200 Merge branch 'master' into int-new commit 71652572e35bfeea2f346b7c700a3050bf27e466 Author: Ondrej Zajicek (work) Date: Tue May 9 16:46:41 2017 +0200 Minor autoconf cleanup and documentation update commit 525a88d87930d01d4301e2723dda3dca208cd3d4 Merge: 95639d95 5d6dc930 Author: Ondrej Zajicek (work) Date: Tue May 9 14:07:14 2017 +0200 Merge branch 'master' into int-new commit 5d6dc93043a0bc77b1e0a71ea8dfe15325024b45 Author: Ondrej Zajicek (work) Date: Tue May 9 13:44:02 2017 +0200 Some more autoconf cleanups Replace integer type width detection with C99 fixed-width types. Also remove some unused or obsolete code. Thanks to Ruben Kerkhof for the patchset. commit 95639d957758cba04aeec7ef319c2de2a5ff52da Author: Ondrej Zajicek (work) Date: Wed May 3 12:56:17 2017 +0200 Device: Fix option 'primary' commit 8e25f7d229fcb6591e9cd96d3cc61767b3c8dea7 Author: Ondrej Zajicek (work) Date: Sat Apr 29 22:14:36 2017 +0200 One last update to NEWS and example commit 92a85089b887a91d0b686cd050ac59bb465c602f Author: Ondrej Zajicek (work) Date: Sat Apr 29 21:49:13 2017 +0200 NEWS and version update commit b644a490f03d27e0bd8ce5106f6205d122b16191 Author: Ondrej Zajicek (work) Date: Sat Apr 29 18:37:51 2017 +0200 BSD: Fix address scan on OpenBSD commit 1d21306785392e997099362fbc863b050fe359da Author: Ondrej Zajicek (work) Date: Sat Apr 29 00:36:35 2017 +0200 Minor fixes commit e919601aaf29615edb2a231e58a358c2c5c9d286 Merge: 5ca4bd5d 33b6c292 Author: Ondrej Zajicek (work) Date: Fri Apr 28 11:19:12 2017 +0200 Merge master into int-new commit 5ca4bd5d9018bb7572f10825e1ca431444601be7 Author: Ondrej Zajicek (work) Date: Wed Apr 26 17:13:45 2017 +0200 Flowspec: Max tcp mask length is 12 bits commit a1de692a6999106c645a7b28d4124b68f63bd6f5 Author: Ondrej Zajicek (work) Date: Wed Apr 26 14:38:19 2017 +0200 Doc: BIRD example update commit 751fb2366ce6c9ebe70fb6ef769608dd34e736e7 Author: Ondrej Zajicek (work) Date: Wed Apr 26 14:11:28 2017 +0200 Test: Fix broken test for filters commit 69fddac0525b1b0c940d778a161ed3a0a742ed6f Merge: 93a3661c b2949999 Author: Jan Moskyto Matejka Date: Wed Apr 26 12:30:22 2017 +0200 Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new commit 93a3661c15c612e1de807524649482765b2c2702 Author: Jan Moskyto Matejka Date: Wed Apr 26 12:26:14 2017 +0200 Flowspec: split net_format_flowspec into several functions commit 2af807a83f6aa120b9d0b7b68dc04e543840e2e6 Author: Jan Moskyto Matejka Date: Wed Apr 26 12:19:39 2017 +0200 Test: fixed broken test for VPN RD output commit a2fd34f81fe4259d5ef27f1684177753a03f0f90 Author: Jan Moskyto Matejka Date: Wed Apr 26 10:53:48 2017 +0200 Debug: Add a Makefile rule for assembler intermediates. The main Makefile rules directly compile to object files; this target is only for debug purposes. commit b29499996bbc1612a63a7e715bb53a8abf0940e3 Author: Ondrej Zajicek (work) Date: Tue Apr 25 19:02:31 2017 +0200 Nest: Update of show route cmd Some code cleanup, multiple bugfixes, allows to specify also channel for 'show route export'. Interesting how such apparenty simple thing like show route cmd has plenty of ugly corner cases. commit 6f535924ebbb5a08d96c4a8d0cf0984b130a0995 Author: Ondrej Zajicek (work) Date: Thu Apr 6 17:16:49 2017 +0200 Filter: Fix reconfiguration of roa_check() commit 4278abfe272de64556c4d6df19efc0c853527851 Author: Ondrej Zajicek (work) Date: Wed Apr 5 16:16:04 2017 +0200 Check validity of dest w.r.t. net_type Allow to define static roa/flow routes without dest. commit 3484cb9a654cab9bd2c2b1164528d3000a22a79e Author: Jan Moskyto Matejka Date: Tue Apr 18 13:45:50 2017 +0200 Client: separate config syntax structure for "show route for" commit 7ee07a3c3966ec787bcb7e5100c1add4abef9213 Author: Jan Moskyto Matejka Date: Wed Apr 5 15:11:10 2017 +0200 Nest: Fix route lookup commit 97e48b6a18142d1aa11e909d094812f3fff4ea61 Author: Jan Moskyto Matejka Date: Wed Apr 5 14:26:37 2017 +0200 Adding also our copy of struct rtvia. commit 54635f435a76ad0f3141b09a9c5072f6e2e8c319 Author: Jan Moskyto Matejka Date: Wed Apr 5 14:15:43 2017 +0200 Include local lwtunnel.h unless found in system commit 711d617dc106a8af34c6c8f3500f337a792f1f3d Author: Ondrej Zajicek (work) Date: Thu Mar 30 14:00:08 2017 +0200 BGP: Add support for SAFI 129 (VPN multicast) Which, in contrast to SAFI 128, does not use MPLS labels. commit ffb38dfb8b454dc23cd08836d7236a5a9c9f80c1 Author: Ondrej Zajicek (work) Date: Thu Mar 30 13:29:34 2017 +0200 Static: Support for dual-AF IGP tables When recursive routes with hybrid next hops (e.g. IPv6 route with IPv4 next hop) are allowed, we need both IPv4 and IPv6 IGP tables. commit 2faf519cf9d34f90d59081ee5f8d6976c62f4f6e Author: Jan Moskyto Matejka Date: Thu Mar 30 13:52:01 2017 +0200 Client: multitable version of show route commit bff21441dd9b8cd526680e9977f8eceb9912ca6f Author: Ondrej Zajicek (work) Date: Wed Mar 29 16:10:00 2017 +0200 Netlink: Change default kernel metric to 32 This avoids collisions with non-BIRD routes in kernel tables. commit ed6100441ec6e95797d3692925b85c627a4e8df1 Author: Ondrej Zajicek (work) Date: Wed Mar 29 15:55:39 2017 +0200 Netlink: Better handling of an error case commit 6fe11c994151344c38d1b080c3f2e1280b4b2448 Author: Ondrej Zajicek (work) Date: Wed Mar 29 15:31:04 2017 +0200 BGP: Simplify igp table options commit c49e4a65657e9abff1b94cbfdc7686efe7376a7a Author: Ondrej Zajicek (work) Date: Wed Mar 29 13:48:23 2017 +0200 BGP: Update list of supported standards commit 7074be22f1a8a42ec738fd34125e36a732f311a5 Author: Ondrej Zajicek (work) Date: Tue Mar 28 18:14:32 2017 +0200 Netlink: Fix device route delete commit 5dbeb87ec96157ca95c84d881e014614dd3164a3 Merge: 2282030b d1b8fe93 Author: Jan Moskyto Matejka Date: Tue Mar 28 17:35:57 2017 +0200 Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new commit 2282030b2a4fb07805a0cd8b82a9aab73b7586d8 Author: Jan Moskyto Matejka Date: Tue Mar 28 17:35:32 2017 +0200 Simpler format of VPN RD commit d1b8fe93f018fb272c3a423df1ab13d86c159f00 Author: Ondrej Zajicek (work) Date: Tue Mar 28 16:05:40 2017 +0200 Netlink: Fix bug in RTA_PRIORITY handling commit ef57b70fa51687865e5823c0af2df2c6de338215 Author: Ondrej Zajicek (work) Date: Sun Mar 26 19:20:15 2017 +0200 BGP: Support for routes with mixed-AF next hops Covers IPv4/VPNv4 routes with IPv6 next hop (RFC 5549), IPv6 routes with IPv4 next hop (RFC 4798) and VPNv6 routes with IPv4 next hop (RFC 4659). Unfortunately it also makes next hop hooks more messy. Each BGP channel now could have two IGP tables, one for IPv4 next hops, the other for IPv6 next hops. commit 01111fc42c461202d427260fb56807eac256e8d5 Author: Ondrej Zajicek (work) Date: Thu Mar 23 14:10:42 2017 +0100 BGP: Bugfix in VPN NLRI encoding commit 1e37e35c3ea88672c677ea7ac63fe0b9df609b0c Author: Ondrej Zajicek (work) Date: Wed Mar 22 15:00:07 2017 +0100 BGP: Support for MPLS labels and VPN SAFI Basic support for SAFI 4 and 128 (MPLS labeled IP and VPN) for IPv4 and IPv6. Should work for route reflector, but does not properly handle originating routes with next hop self. Based on patches from Jan Matejka. commit ead7b8f498ddefc0b7373cbba78f9a7ba1dddaa9 Merge: da3cf9ea 61e501da Author: Jan Moskyto Matejka Date: Wed Mar 22 14:54:00 2017 +0100 Merge branch 'nexthop-merged' into int-new commit 61e501da895553abfd2424e56470ab2b457beac4 Author: Jan Moskyto Matejka Date: Wed Mar 22 14:53:37 2017 +0100 Filter: Check whether IP is 4 or 6 commit 3c74416465d77c0e79eeaaeb988e471663484b5d Author: Jan Moskyto Matejka Date: Fri Mar 17 15:48:09 2017 +0100 Nexthop: Fixed recursive route mpls label merging commit a5d2a34497853a02692a0b8ea812f44d6820a399 Author: Ondrej Zajicek (work) Date: Tue Mar 14 17:18:50 2017 +0100 Minor cleanups BTW, 'prefices' is hypercorrection, as 'prefix' is from 'praefixum' with plural 'praefixa'. commit 7a855725f2ffde508da0c7ee01dc1bcd6e0a5d93 Author: Ondrej Zajicek (work) Date: Tue Mar 14 13:46:51 2017 +0100 Some autoconf cleanups The patch allows to use autoreconf, replaces some long obsolete constructs and does some other minor cleanups. Also, the file configure.in is renamed to configure.ac, as the old name has been deprecated for a long time. Thanks to Ruben Kerkhof for the patchset. commit 33b6c292c3e3a8972d0b9f43d156aae50db65720 Author: Ondrej Zajicek (work) Date: Tue Mar 14 12:56:47 2017 +0100 BGP: Allow to specify interface for regular sessions This may be useful if multple interfaces share the same network range. Thanks to Fritz Grimpen for the original patch. commit 27f6ba651ebb07201f7964c8f14a254267f0f26a Author: Ondrej Zajicek (work) Date: Sat Mar 11 16:21:28 2017 +0100 BGP: Fix bug in ADD_PATH When a BGP session with ADD_PATH is restarted and the neighbor do not announce ADD_PATH capability during reconnect, the accept_ra_types is still set to RA_ANY. Thanks to Lennert Buytenhek for the bugreport commit 8c9986d310c58b26c000375be00be0deb9c2e360 Author: Jan Moskyto Matejka Date: Mon Mar 13 13:50:32 2017 +0100 Filters: VPN Route Distinguishers, Prefix Type, Docs Update commit 54334b5667158d4b0af55201f327faeb80c05e0e Author: Jan Moskyto Matejka Date: Thu Mar 9 15:57:54 2017 +0100 Filter: ROA check test and mixed prefix test commit 665be7f6bdbf1fd8dbac45cef533bd4b1df35d4d Author: Ondrej Zajicek (work) Date: Wed Mar 8 16:27:18 2017 +0100 Nest: Minor fixes in show route commit 7126cadf80fce1af2bb4aa33f8bcb7c6b5ff1a47 Author: Ondrej Zajicek (work) Date: Tue Mar 7 18:42:41 2017 +0100 Static: Minor overhaul The patch fixes several bugs introduced in previous changes, simplifies the protocol by handing routes uniformly, introduces asynchronous route processing to avoid issues with separate notifications for each next-hop in ECMP routes, and makes reconfiguration faster by avoiding quadratic complexity. commit 5ffb62dd034db0beab5ef245ad7dd31aadefb2d8 Author: Ondrej Zajicek (work) Date: Tue Feb 21 14:56:14 2017 +0100 Nest: Allow iface-only neighbors commit da3cf9eae3085d43a2299bae63e6ceb3828856a5 Author: Ondrej Zajicek (work) Date: Wed Mar 8 17:37:11 2017 +0100 Update OSPF and RIP protocol names and related documentation commit 039a65d0e4f33f8432caae78cd919d2fd2052eea Author: Jan Moskyto Matejka Date: Fri Feb 24 14:05:11 2017 +0100 Nexthop: Fixed hostentry commit 1950a479c020d1972b6007d8ea0f66e3d4f8564a Author: Ondrej Zajicek (work) Date: Thu Feb 23 16:32:07 2017 +0100 BGP: Allow exchanging LOCAL_PREF with eBGP peers Adds option 'allow bgp_local_pref' to override the usual restriction of LOCAL_PREF on eBGP sessions. Thanks to Lennert Buytenhek for the patch. commit 93f50ca31757fc8e416093e0c73681e070294a3d Author: Jan Moskyto Matejka Date: Wed Feb 22 14:02:03 2017 +0100 Nest: names for nhu_state values It took too much time to analyze what's the meaning of nhu_state values so I spent less than the same amount of time documenting it. commit b2b84359abd382c1ec5a266b211276fbae7da0fc Author: Jan Moskyto Matejka Date: Wed Feb 22 12:02:28 2017 +0100 Babel post-merge fixes commit c609d039860f97f400d2cf0e9ca2b4e87b3fd1cc Merge: 62e64905 2be9218a Author: Jan Moskyto Matejka Date: Wed Feb 22 11:58:04 2017 +0100 Merge branch 'int-new' into nexthop-merged commit 2be9218a3b1dfcc8e42c8d118e95f2074d9f7a7c Author: Ondrej Zajicek (work) Date: Mon Feb 20 02:28:04 2017 +0100 BGP: Update RFC references commit 62e64905b76b88da72c522eac9276a74f60c9592 Author: Ondrej Zajicek (work) Date: Mon Feb 20 02:26:45 2017 +0100 Several minor fixes commit 4e379bde60172823452cf96e9c0b6b1737c490f0 Author: Ondrej Zajicek (work) Date: Sun Feb 19 12:02:39 2017 +0100 BGP: Update RFC references commit 9be12a7d95d668a64922f935057c0b401b58ab75 Author: Ondrej Zajicek (work) Date: Sun Feb 19 11:25:16 2017 +0100 Doc: Fix RIP example Thanks to Steve Leung for the bugreport. commit 30c734fc73648e4c43af4f45e68ac2de3d7ddea1 Author: Ondrej Zajicek (work) Date: Fri Feb 17 22:54:06 2017 +0100 Static: Fix bug in static route filter expressions During reconfiguration, old and new filter expressions in static routes are compared using i_same() function. When filter expressions contain function calls, it is necessary that old filter expressions are the second argument in i_same(), as it is internally modified by i_same(). Otherwise pointers to old (and freed) data appear in the config structure. Thanks to Lennert Buytenhek for tracking and reporting the bug. commit c259669fa33ca13b5c6ae60eb8ffa0874ddc01b2 Merge: 82f42ea0 da65a3d8 Author: Ondrej Zajicek (work) Date: Wed Feb 8 14:34:48 2017 +0100 Merge branch 'master' into int-new commit 82f42ea09176afdb67ab119258d714e8c8e54d12 Author: Ondrej Zajicek (work) Date: Tue Feb 7 15:55:51 2017 +0100 BGP: Minor cleanups commit da65a3d898fde0ce567782d86919a66e29916ed7 Author: Ondrej Zajicek (work) Date: Tue Jan 24 15:35:38 2017 +0100 Filter: Fix missing case for !~ operator Thanks to Vincent Bernat for the patch. commit d8022d26fc64121c3416abfdb4c38fcbaf81c12e Author: Ondrej Zajicek (work) Date: Tue Jan 24 02:00:35 2017 +0100 BGP: Partial support for IPv4 routes with IPv6 next hop (RFC 5549) Mostly capability signalling commit 5509e17d0c1b4e75d5911864f75ba119769e5725 Author: Ondrej Zajicek (work) Date: Sun Jan 22 16:32:42 2017 +0100 BGP: Support for AS confederations (RFC 5065) commit f6e6c3b5a5997ffc67d96785bbde76bcec072890 Author: Ondrej Zajicek (work) Date: Tue Jan 17 13:21:25 2017 +0100 Fix IP_HDRINCL usage on FreeBSD 11 FreeBSD 11 changed endianity of ip_len field from host order to network order. Also DragonFly BSD allegedly expects network order here. Thanks to Olivier Cochard-Labbé for the patch. commit f8aad5d5b7601d0500841e57bafa5796cc3156ab Author: Ondrej Zajicek (work) Date: Fri Dec 23 23:03:26 2016 +0100 Minor cleanups commit d311368bc58842552e25744a0aae9a09c42cda9f Author: Jan Moskyto Matejka Date: Tue Feb 9 14:53:29 2016 +0100 VPN4 and VPN6 literals From now on, protocol static accepts VPN4 and VPN6 addressess. With some concerns about VPN6 Route Distinguishers, I finally chose to have the same format as for VPN4 (where it is defined by RFC 4364). commit d47c3d64b2733baea756f1bb37ef09f10d7f9644 Author: Jan Moskyto Matejka Date: Tue Aug 9 14:47:51 2016 +0200 MPLS: Label stack concatenation for recursive routes commit d14f8c3c45f7e33a7e54ebc0d45bdb0295d70301 Author: Jan Moskyto Matejka Date: Fri Mar 4 12:55:50 2016 +0100 Netlink: MPLS routes in kernel Anyway, Bird is now capable to insert both MPLS routes and MPLS encap routes into kernel. It was (among others) needed to define platform-specific AF_MPLS to 28 as this constant has been assigned in the linux kernel. No support for BSD now, it may be added in the future. commit f2010f9c65ca69584c34c762fb3e5e957958478e Author: Jan Moskyto Matejka Date: Mon Jun 13 15:49:53 2016 +0200 Static: Protocol rework wrt. struct nexthop changes; MPLS label support commit 33ad6e0188b56f682a012ca1b782812c96285d51 Author: Jan Moskyto Matejka Date: Wed Mar 2 14:37:18 2016 +0100 MPLS: added net_addr_mpls variant of net_addr commit ec5e5d23faa482495c84163c4ae38d9a31bdc00f Author: Jan Moskyto Matejka Date: Fri Jun 10 14:34:41 2016 +0200 Nexthop: Support for label stack in nest commit 5b208e296fed0beddce16188478c5119df610d89 Author: Jan Moskyto Matejka Date: Tue Jun 7 11:46:07 2016 +0200 Removing (struct rta)->cast. Never used. commit 4e276a8920ed0496836f002f144943ab42f120f6 Author: Jan Moskyto Matejka Date: Fri May 6 15:48:35 2016 +0200 Merged multipath and single-path data structures. Dropped struct mpnh and mpnh_*() Now struct nexthop exists, nexthop_*(), and also included struct nexthop into struct rta. Also converted RTD_DEVICE and RTD_ROUTER to RTD_UNICAST. If it is needed to distinguish between these two cases, RTD_DEVICE is equivalent to IPA_ZERO(a->nh.gw), RTD_ROUTER is then IPA_NONZERO(a->nh.gw). From now on, we also explicitely want C99 compatible compiler. We assume that this 20-year norm should be known almost everywhere. commit 017da76b729cc36c4a3416995b06386235660f42 Author: Ondrej Zajicek (work) Date: Wed Dec 21 16:46:47 2016 +0100 NEWS and version update commit 2c33da507046c25d87741fe0ce7947985c8c7a10 Author: Jan Moskyto Matejka Date: Tue Dec 20 20:13:08 2016 +0100 Netlink: fix occasional netlink hangs on busy machines commit 256cc8ee0867d7f5314d3a3d7db5429d2bf16b4e Author: Ondrej Zajicek (work) Date: Tue Dec 20 17:39:59 2016 +0100 BGP: Report capabilities in show protocols all commit 7d95c44572d79ef15ec8b0220950b4e4374c6bc6 Author: Ondrej Zajicek (work) Date: Thu Dec 15 15:31:25 2016 +0100 OSPF: Fix ECMP external merging The variable nfa is not cleaned before each loop iteration and can have a wrong value of nfa.nhs_reuse from the previous step. Thanks to Bernardo Figueiredo for the bugreport and analysis. commit eeba61ccd5d1757fd79fcb0cd42b8dee9f941d7e Author: Ondrej Zajicek (work) Date: Tue Dec 13 20:18:11 2016 +0100 Minor cleanups commit 9e7d3a781075b39a7e0f97e63b6f313955daa661 Author: Ondrej Zajicek (work) Date: Tue Dec 13 17:34:42 2016 +0100 OSPF: Fix net-summary origination combined with stubnet option Stubnet nodes in OSPF FIB were removed during rt_sync(), but the pointer remained in top_hash_entry.nf, so net-summary LSA origination was confused, reported 'LSA ID collision' and net-summary LSAs were not originated properly. Thanks to Naveen Chowdary Yerramneni for bugreport and analysis. commit 5e8df049fbf53220735a2eeb6c751e1758869a18 Author: Ondrej Zajicek (work) Date: Sat Dec 10 00:11:26 2016 +0100 Babel: Update to integrated branch commit 2119ae74c2e3b101bb8c6f5f0413b143d9978c9c Author: Ondrej Filip Date: Wed Dec 7 20:31:12 2016 +0100 Documentation build system fix commit 5546aad260a3e569e86e2fd2b5f613202ac70be3 Author: Ondrej Zajicek (work) Date: Wed Dec 7 19:56:42 2016 +0100 NEWS and version update commit 66e5dc157af41547f3806a5980183d95ac9bfcd1 Author: Ondrej Zajicek (work) Date: Wed Dec 7 19:16:02 2016 +0100 Doc: Add MP-BGP example config file commit ac3ad139f648184d44707ab145fde3a03ef5cb6e Author: Ondrej Zajicek (work) Date: Wed Dec 7 18:28:07 2016 +0100 BGP: Add support for flowspec (RFC 5575) commit b7605d5c953902b461e5c9e87aa3dfa60ddce5bc Author: Jan Moskyto Matejka Date: Wed Dec 7 17:17:04 2016 +0100 Doc: Example simple config commit c42ecaab8d606ae1362a46210e2bc02dbf6f1476 Author: Ondrej Zajicek (work) Date: Wed Dec 7 16:27:12 2016 +0100 Tests: Fix build commit a7848dd880a902f465eecd9ed9ea64673548874a Author: Ondrej Zajicek (work) Date: Wed Dec 7 16:20:38 2016 +0100 Client: No need for birdlib functions commit 77234bbbde6bc328871af695e4450e6773adbafa Author: Ondrej Zajicek (work) Date: Wed Dec 7 15:36:15 2016 +0100 Basic flow specification support (RFC 5575) Add flow4/flow6 network and rt-table type and operations, config grammar and static protocol support. Squashed flowspec branch from Pavel Tvrdik. commit b94e5e58dbd33f4d2b9d721c51a9c8c4d8f77bea Author: Jan Moskyto Matejka Date: Wed Dec 7 15:35:35 2016 +0100 RPKI: fixed some of the extended warnings commit ad88b94bca78e010357a6c7806e1d5e01701d4a7 Merge: d15b0b0a af62c0f9 Author: Jan Moskyto Matejka Date: Wed Dec 7 15:30:46 2016 +0100 Merge branch 'int-new-rpki-squashed' (early part) into int-new commit d15b0b0a1b494c14b139d2d28706d82cd6e2f139 Author: Ondrej Zajicek (work) Date: Wed Dec 7 14:11:28 2016 +0100 BGP redesign Integrated and extensible BGP with generalized AFI handling, support for IPv4+IPv6 AFI and unicast+multicast SAFI. commit af62c0f9f1f6382fe88c8ae5e514f70c0b5b6d05 Author: Jan Moskyto Matejka Date: Wed Dec 7 14:15:35 2016 +0100 LibSSH may be switched off together with RPKI commit cdbe1defa4b783715ed29d8d253a55d3efe0b9ed Author: Jan Moskyto Matejka Date: Wed Dec 7 09:13:29 2016 +0100 SSH: Commented quirk based on undocumented behavior of LibSSH commit f7f70bed8f5fd50873f92b6e119de8864c2631a8 Author: Jan Moskyto Matejka Date: Wed Dec 7 09:12:06 2016 +0100 Make: upgrade Babel makefiles commit cd6ca9b1f6e5f71667c1fe6027cfb865f1dcebc1 Author: Pavel Tvrdik Date: Thu Jun 30 14:56:09 2016 +0200 filter/test.conf: add ROA check and operator tests commit e58f8c28d252a9979c07b478091b8d0ef40a9f22 Author: Pavel Tvrdik Date: Wed Jun 29 12:21:43 2016 +0200 Add `.maxlen' operator to all ROA prefixes in filters Example: bird> eval (1.2.0.0/16 max 20 as 1234).maxlen 20 Todo: Should be described in user docs commit 69ae5784509d51ee928c99b8b066f68a166bfe18 Author: Pavel Tvrdik Date: Wed Jun 29 12:08:28 2016 +0200 Add `.asn' operator to all ROA prefixes in filters Example: bird> eval (1.2.0.0/16 max 20 as 1234).asn 1234 Todo: Should be described in user docs commit f6e8e141df63cd86e344ca659637f23d638d47a2 Author: Pavel Tvrdik Date: Wed Jun 29 09:56:33 2016 +0200 Check table type at `show route for ...' commit 65d2a88dd2aaef7344cfa62918e3ddf4c72ca50a Author: Pavel Tvrdík Date: Thu Sep 17 17:15:30 2015 +0200 RPKI protocol with one cache server per protocol The RPKI protocol (RFC 6810) using the RTRLib (http://rpki.realmv6.org/) that is integrated inside the BIRD's code. Implemeted transports are: - unprotected transport over TCP - secure transport over SSHv2 Example configuration of bird.conf: ... roa4 table r4; roa6 table r6; protocol rpki { debug all; # Import both IPv4 and IPv6 ROAs roa4 { table r4; }; roa6 { table r6; }; # Set cache server (validator) address, # overwrite default port 323 remote "rpki-validator.realmv6.org" port 8282; # Overwrite default time intervals retry 10; # Default 600 seconds refresh 60; # Default 3600 seconds expire 600; # Default 7200 seconds } protocol rpki { debug all; # Import only IPv4 routes roa4 { table r4; }; # Set cache server address to localhost, # use default ports tcp => 323 or ssh => 22 remote 127.0.0.1; # Use SSH transport instead of unprotected transport over TCP ssh encryption { bird private key "/home/birdgeek/.ssh/id_rsa"; remote public key "/home/birdgeek/.ssh/known_hosts"; user "birdgeek"; }; } ... commit 2706747f66ab0e7a7f2b8acc6bd7fbd376647258 Author: Pavel Tvrdik Date: Thu Jun 9 10:11:39 2016 +0200 Client: Includes stdlib.h for malloc() commit 5df4073c81942ea119de90a81431bae71c87157b Author: Pavel Tvrdik Date: Wed Nov 30 10:40:57 2016 +0100 filter/test.conf: Minor changes in order of calls commit 0eb7f17d9a5f29ffa8edccf9e2698f3fd70b2f22 Author: Pavel Tvrdik Date: Wed Nov 30 11:55:33 2016 +0100 nest/a-path.c: Fix description of BS constant (block size) commit bd7958776baede8175505aa6813ffa96f3ec43fa Author: Pavel Tvrdik Date: Wed Nov 30 10:21:43 2016 +0100 conf/conf.h: Fix a description of a variable in a structure commit 1b7ddb0ea01aae0be6cb5f89259bad88b5066b1a Author: Pavel Tvrdik Date: Wed Nov 30 10:17:23 2016 +0100 conf/conf.c: Revert some includes removing commit 4abe781c27abea5f8dd0e041106ea6511c210cb7 Author: Pavel Tvrdik Date: Wed Nov 30 10:11:12 2016 +0100 Remove filter/test_bgp_filtering.conf file It was an example filtering configuration from BIRD's wiki. commit 012a0d6bf8761253c67c40ac236e27b2f6b6ce43 Author: Pavel Tvrdik Date: Wed Nov 30 10:06:37 2016 +0100 Merge test6.conf IPv6 tests into test.conf commit ed1a908e535e4333b358d83b472453a2ad6d3f51 Author: Ondrej Zajicek (work) Date: Fri Nov 25 11:51:38 2016 +0100 BGP: Fix memory leak in graceful restart code Prefix and bucket tables are initialized when entering established state but not explicitly freed when leaving it (that is handled by protocol restart). With graceful restart, BGP may enter and leave established state multiple times without hard protocol restart causing memory leak. commit c39a1cb17e396b9c94eec6af3ac26fd333adc3c6 Author: Pavel Tvrdik Date: Wed Nov 16 14:05:59 2016 +0100 filter/test.conf: Extend tests commit 0ed1e850913cb9a9b939c616b90312070c65797e Author: Pavel Tvrdik Date: Wed Nov 16 13:46:08 2016 +0100 filter/test.conf: Reorder tests Tests are sorted from trivial tests to more complex tests commit 7dea7ccb1074e83d0c5ea2f667deca1f0c938e72 Author: Pavel Tvrdik Date: Wed Nov 16 12:18:06 2016 +0100 filter/test.conf: Replace print func with assert and format commit 4b135d095860cf861ff47c24a10169faa41fe35a Author: Pavel Tvrdik Date: Wed Nov 16 12:15:43 2016 +0100 Birdtest: Add function format in grammar for stringify expression commit bb721f0d6d00bc2d7944640bfaf1cb266060d972 Author: Pavel Tvrdik Date: Wed Nov 16 12:10:34 2016 +0100 Add lp_strdup function for string duplication on linpool commit 3ec0bedc6077ebd2716f29c68155bab806aaa8d6 Author: Pavel Tvrdik Date: Wed Nov 16 11:09:55 2016 +0100 Birdtest: Remove bt_assert command from term The bt_assert function does not return any value, so it was useless to have a option in term definition. commit 45ec4ce82a3b82f27ff6c44ad11570606733775e Author: Pavel Tvrdik Date: Wed Nov 16 11:03:39 2016 +0100 Lexer: Add a quotation mark back while parsing quotes Thanks to Ondrej Zajicek for code. commit 261816b0d4f3d4549a4402b95541b82fc7f10a4b Author: Ondrej Zajicek (work) Date: Tue Nov 15 16:24:39 2016 +0100 BGP: Cluster list item should be prepended Commit 3c09af41... changed behavior of int_set_add() from prepend to append, which makes more sense for community list, but prepend must be used for cluster list. Add int_set_prepend() and use it in cluster list handling code. commit 5e3cd0e5b56e6c58cfba4d0d38fbbbed3657889d Author: Pavel Tvrdik Date: Fri Nov 11 17:43:09 2016 +0100 Birdtest: Replace BT_SUCCESS and BT_FAILURE with 1 and 0 commit fa71b268a8d15d579f50d7f4f92e2edb3b431e05 Author: Pavel Tvrdik Date: Fri Nov 11 17:03:43 2016 +0100 Birdtest: Put hard new lines for strict line width This patch ensures width of output lines from testing framework (not debug output). So output piped lined into file that has default width 80 cols is now correctly wrapped. commit fd328869cc2510808074591f7b9f1b71c6439ec3 Author: Pavel Tvrdik Date: Fri Nov 11 17:02:16 2016 +0100 birdtest: Fix no-forked mode in trie_test commit 101c5a50aa9cd46bf4b971586d78d7f9041fb656 Author: Ondrej Zajicek (work) Date: Wed Nov 9 19:08:25 2016 +0100 Filter: Add long community tests Based on Pavel Tvrdik's int-test-lc branch. commit 9b0a0ba9e671d9134b93c33ab73ccccb352acafa Author: Ondrej Zajicek (work) Date: Wed Nov 9 16:36:34 2016 +0100 Unit Testing for BIRD - Unit Testing Framework (BirdTest) - Integration of BirdTest into the BIRD build system - Tests for several BIRD modules Based on squashed Pavel Tvrdik's int-test branch, updated for current int-new branch. commit 8860e991f6650e47cfe6c1af595fe4fe92a4edfd Merge: cc5b93f7 c8cafc8e Author: Ondrej Zajicek (work) Date: Tue Nov 8 19:27:58 2016 +0100 Merge branch 'master' into int-new commit c8cafc8ebb5320ac7c6117c17e6460036f0fdf62 Author: Ondrej Zajicek (work) Date: Tue Nov 8 17:46:29 2016 +0100 Minor code cleanups commit cc5b93f72db80abd1262a0a5e1d8400ceef54385 Merge: 5de0e848 f51b1f55 Author: Ondrej Zajicek (work) Date: Tue Nov 8 17:03:31 2016 +0100 Merge tag 'v1.6.2' into int-new commit 920a86e8493fe25008f084f67f368aea9b197efd Author: Ondrej Zajicek (work) Date: Thu Nov 3 09:53:53 2016 +0100 Add missing extern commit e03dc6a984555e3c943735d50376cada2220bac8 Author: Ondrej Zajicek (work) Date: Sun Oct 30 23:51:23 2016 +0100 BFD: Authentication Implement BFD authentication (part of RFC 5880). Supports plaintext passwords and cryptographic MD5 / SHA-1 authentication. Based on former commit from Pavel Tvrdik commit 29239ba2bbee3e9ec7d17793b25936a1bfc795ca Author: Ondrej Zajicek (work) Date: Thu Oct 27 20:58:21 2016 +0200 OSPF: Use message authentication interface Based on former commit from Pavel Tvrdik commit 390601f038b69d5de3841c691f92af0fcd088454 Author: Ondrej Zajicek (work) Date: Wed Oct 26 16:07:45 2016 +0200 RIP: Use message authentication interface Based on former commit from Pavel Tvrdik commit 64385aee0cc2dfae8297f29ce6724cedf7cc4736 Author: Pavel Tvrdík Date: Thu Jan 28 17:05:15 2016 +0100 DOC: Password algorithm option commit 56cb3bedc2634a44ea41587566c2889f5b5f5b5b Author: Pavel Tvrdík Date: Tue Jan 26 16:45:13 2016 +0100 Nest: Add support for MAC algorithms in grammar commit de2a27e255b6ec834d11c005909b28a150c7c0db Author: Ondrej Zajicek (work) Date: Tue Oct 25 17:04:17 2016 +0200 Add generic message authentication interface Add generic interface for generating and verifying MACs (message authentication codes). Replace multiple HMAC implementation with a generic one. commit 7eec3988758cb4c19a0ab3bf90cab2a4914165be Author: Ondrej Zajicek (work) Date: Tue Nov 1 16:18:27 2016 +0100 BSD: Fix build on OpenBSD broken by previous commit commit 3e236955c9369475872b9b86a58502fa777b50b9 Author: Jan Moskyto Matejka Date: Fri Oct 14 15:37:04 2016 +0200 Build: switch on -Wextra, get rid of most of the warnings There are several unresolved -Wmissing-field-initializers on older versions of GCC than 5.1, all of them false positive. commit 17fe57d8dcc89aea520788914b252cf49cf060ff Author: Ondrej Zajicek (work) Date: Tue Nov 1 11:37:49 2016 +0100 Log: Fix broken syslog name BIRD passed string from configuration to openlog(), which kept it internally. After reconfiguration the old string was freed, therefore openlog had invalid copy. Thanks to Chris Caputo for the original patch. commit 3213273d8261c69a343fcd7d4c9607385dfdbb65 Author: Ondrej Filip Date: Thu Oct 27 11:08:28 2016 +0200 IANA assigned a different number to large BGP communities - changed. commit c68e8cd374f16a1d659c80f9ebe503f2dd0d4acb Author: Ondrej Zajicek (work) Date: Tue Oct 18 13:06:05 2016 +0200 Filter: Minor formatting changes in test.conf commit 3c09af416939d26c252aa1b339b52fd8f9f8e774 Author: Pavel Tvrdik Date: Thu Oct 13 16:57:21 2016 +0200 Clist: The add() function will append a new value The add() function used to prepend a new community to clist, but after this fix the add() function appends new community. commit 5fd7dacadc3cd8f91f66cb56e3a9ef81028aa102 Author: Pavel Tvrdik Date: Thu Oct 13 15:17:41 2016 +0200 Filter: Expand testing of large community sets commit 2e7fb11a6e31324151c6db98df2fe26d2d6cffab Author: Jan Moskyto Matejka Date: Wed Oct 12 14:16:34 2016 +0200 Fixed memory bloating on kernel merge paths together with export filter. Some memory was being allocated from bad linpool, not from the given one as they should. Thanks to Madhu and Justin Cattle for reporting this. commit 9df52a98e2eae28f219510d4c3d65ec43a50c394 Author: Pavel Tvrdik Date: Mon Sep 5 11:20:28 2016 +0200 Doc: Change debug to { flag1|flag2|flag3 [, ...] } style Thanks to Micah Anderson for bug report and Ondrej Zajicek for the idea! commit 9fcb9637b55d234dfedfcb54bd76ed5a9570b7a1 Author: Pavel Tvrdik Date: Mon Sep 19 16:01:29 2016 +0200 Nest: Remove trailing whitespaces commit 3d28f0145382feddcf7f66c0a20b6c5b3e0edbc9 Author: Pavel Tvrdik Date: Mon Sep 26 18:05:51 2016 +0200 Doc: Fix deprecated unescaped braces in perl script This commit should fix warning `make docs' ./sgml2html bird.sgml Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\\nameurl{ <-- HERE (.*)}{(.*)}/ at fmt_latex2e.pl line 287. commit c2564d34af9e01a828c24b0be7f269e5b036b5da Author: Pavel Tvrdik Date: Sat Oct 1 12:50:29 2016 +0200 Tree/Trie: Check the end of buffer We set buffer->pos to buffer->end in function buffer_print() when bvsnprintf() failed, so there would be uninitialized memory between the old buffer->pos and the current buffer->pos. commit 7935b9d21228dcd1eb95ebcb056b2a815e3e854b Author: Pavel Tvrdik Date: Thu Sep 29 18:08:40 2016 +0200 Doc: Add tag for links to RFCs commit 9c20a8b7ae69487397392c720a5e75087c343df1 Author: Pavel Tvrdik Date: Mon Oct 3 12:35:36 2016 +0200 Doc: Fix inline Don't make space before or after link name. commit 963929df021ae54d8ff4cd18ca228932fc89dc13 Author: Pavel Tvrdik Date: Mon Oct 3 12:04:44 2016 +0200 Doc: Do not use symlinks for files commit 70104ef4fb5f8105422d6eb811a93b68aeae709d Author: Pavel Tvrdik Date: Mon Oct 3 11:46:40 2016 +0200 Doc: Generate one-sided version This removes jumping offset for odd and even pages for binding book. commit f9bd11c337afcc3e95b459e3901a4ca28cb14b85 Author: Pavel Tvrdik Date: Mon Oct 3 11:39:56 2016 +0200 Doc: Use [table t] or [table name] commit 74d76f6c3877e4a745fb63b55486810322076153 Author: Pavel Tvrdik Date: Mon Oct 3 11:36:44 2016 +0200 Doc: Fix unnecessary special chars commit f15dc6813870565d01378265ab20e017757af220 Author: Pavel Tvrdik Date: Mon Oct 3 10:59:43 2016 +0200 Doc: Enable break lines in commit f5952c7343841fe4b7b63b7a56e95aba104f2e82 Author: Pavel Tvrdik Date: Mon Oct 3 10:32:28 2016 +0200 Doc: Daemon command-line options alphabet order commit 22558357d45c27583156f8c11412e37ce48a42e0 Author: Pavel Tvrdik Date: Mon Oct 3 10:22:24 2016 +0200 Doc: Add command-line options --version, --help commit b9864aa87193ac1a5ebbc04d24ec782a1fe9637a Author: Pavel Tvrdik Date: Mon Sep 26 18:00:59 2016 +0200 Doc: Add labels to all chapters and options commit a2df7c0303d235f4122969243e9df152a8a16dcb Author: Pavel Tvrdik Date: Thu Sep 29 14:05:25 2016 +0200 Doc: Generate clickable PDF commit 9faf72c8cc9a099b41c90ee1822e8bca22fd0596 Author: Pavel Tvrdik Date: Thu Sep 29 11:20:04 2016 +0200 Doc: Fix whitespaces commit a998836d4bd4df8820e67f51e16d81a5a8dc9e9b Author: Ondrej Zajicek (work) Date: Tue Oct 4 23:19:35 2016 +0200 Filter: fix missing separator commit a46e01eeef17a7efe876618623397f60e62afe37 Author: Ondrej Zajicek (work) Date: Tue Oct 4 12:45:39 2016 +0200 Nest: Fix signedness of large communities commit cec4a73ccb22ed412e87560e4210b6df40832aad Author: Ondrej Zajicek (work) Date: Tue Oct 4 00:31:43 2016 +0200 Doc: Documentation for large communities commit 60566c5c804070c145fafd75ef2c17efb489a1eb Author: Ondrej Zajicek (work) Date: Sat Oct 1 22:31:01 2016 +0200 Filter: large community sets Add support for lc sets to filter code. Grammar of (small) community sets has to be updated to avoid parser collisions. commit 66dbdbd993115c57acafdb776d2165d0b4a90a45 Author: Ondrej Zajicek (work) Date: Sat Oct 1 12:50:29 2016 +0200 BGP: Support for large communities Add support for large communities (draft-ietf-idr-large-community), 96bit alternative to RFC 1997 communities. Thanks to Matt Griswold for the original patch. commit f51b1f556595108d53b9f4580bfcb96bfbc85442 Author: Ondrej Zajicek (work) Date: Thu Sep 29 15:06:19 2016 +0200 NEWS and version update commit 5bf35a9aee448ce7e3493ec7b80c84c8f5f39242 Author: Pavel Tvrdik Date: Thu Sep 29 13:28:18 2016 +0200 Docs: fix BFD label BFD headline will appear in Table of Contents again. commit ccd2a3eda24230df550e9880f4340fc6341c8f52 Author: Jan Moskyto Matejka Date: Thu Sep 29 12:00:53 2016 +0200 Kernel socket missing err_hook fix Thanks to Tim Weippert for bugreport. commit 79e2293ab2abbd92bb3326a95759a4ca32d9af81 Author: Ondrej Zajicek (work) Date: Thu Sep 22 13:34:56 2016 +0200 NEWS and version update commit 768d5e1058693d2bfb7c3bcbe04306097c3246a0 Author: Pavel Tvrdik Date: Tue Sep 20 15:13:01 2016 +0200 Add !~ operator to filter grammar commit 75ac3d199d1fd5b199dd753915234b8634c272e5 Author: Ondrej Zajicek Date: Wed Sep 21 12:07:59 2016 +0200 Remove cvsignore We have gitignore commit 6e75d0d27fe85f12a22928e5729465823704281e Author: Ondrej Zajicek (work) Date: Mon Sep 19 12:29:56 2016 +0200 KRT: Add krt_scope attribute Add a new route attribute, krt_scope, to expose the Linux kernel route scope. Constants from /etc/iproute2/rt_scopes (prefixed by "ips_") are expected to be used with the attribute. Both import and export are supported. Also, the patch fixes device route export to the kernel, by setting link scope automatically. commit 292f7858e60b0dffd8c06f6818d90ccf3b34e0b2 Author: Pavel Tvrdik Date: Thu Sep 8 16:27:40 2016 +0200 Main: Improve BIRD help messages commit 6273fcf072fc5789ebabf4f1acd6fc6c9fa143ee Author: Pavel Tvrdik Date: Wed Sep 7 14:58:51 2016 +0200 Add stdlib.h to client/commands.c commit 0f5054f6850c7419933a6337a34263f565663ee3 Author: Pavel Tvrdik Date: Thu Sep 8 13:45:36 2016 +0200 BFD: Fix invalid read from pollfd array It is possible that sockets_add() are called between sockets_prepare() and sockets_fire() during poll loop in birdloop_main(), so we need to use loop->poll_fd.used instead of loop->sock_num to find the last field. commit a290da25a16b7c79d4a7a87f522b4068bca04979 Author: Pavel Tvrdik Date: Tue Sep 6 17:08:45 2016 +0200 rt-table: Fix kernel protocol export filter memory bug Kernel protocol calls rt_export_merged(), which used @rte_update_pool for temporary allocations, supposing it is called from other functions from rt-table.c that handles locking and flushing of the linpool. Therefore, linpool was not flushed properly and memory leaked. Add linpool argument to rt_export_merged() and use @krt_filter_lp when called from kernel protocol. Thanks to Justin Cattle and Alexander Frolkin for the bugreport. (Commit squashed and updated by Ondrej Zajicek) commit bc00f058154bb4a630d24d64a55b5f181d235c63 Author: Pavel Tvrdik Date: Tue Sep 6 17:18:15 2016 +0200 Filter: Prefer xmalloc/xfree to malloc/free commit 4adcb9df1bf551cc5fd1145c09af1843fdc4fe85 Author: Ondrej Zajicek (work) Date: Thu Sep 15 14:59:06 2016 +0200 KRT: Add kernel metric protocol option Kernel routes with different metrics do not clash with each other, therefore using dedicated metric value is a reliable way to avoid overwriting routes from other sources (e.g. kernel device routes). Although kernel route metric could already be set as a route attribute by filters, that is not consistent with the way how Linux kernel handles route metric - not just a route attribute, but a part of a route key. commit 2feaa6931bfe39eba696b33b0c8aac13d313b223 Author: Ondrej Zajicek (work) Date: Wed Sep 14 11:40:15 2016 +0200 KRT: Support for IPv6 ECMP Linux represents IPv6 ECMP routes as a sequence of unipath routes with the same prefix. We have to translate between our representation (one route with multipath next hop) and the Linux representation in both directions. Proper learning of alien IPv6 ECMP routes still not supported. Thanks to Mikhail Sennikovskii for the original patch. commit 84cac51a51fc29349077e8cecadf1aed11f9b824 Author: Ondrej Zajicek (work) Date: Tue Aug 30 17:17:27 2016 +0200 Nest: Keep multipath next hops sorted commit a1839f3c61af66814a8c52b9ad28e59aab4ede0e Author: Ondrej Zajicek (work) Date: Wed Aug 31 14:02:41 2016 +0200 KRT: Fix trivial error commit f9f2e280ea4fa1af19d8ce9e54abeb495694c0d5 Author: Ondrej Zajicek (work) Date: Tue Aug 30 12:43:46 2016 +0200 KRT: Forbid path merging on BSD We support ECMP routes only on Linux. Exported routes are checked in krt_capable(), but a route generated during path merging avoids this check. commit 768d013267bd2a52bab70ba6d413f49365fb31e3 Merge: 678c97f2 d107ef78 Author: Ondrej Zajicek (work) Date: Tue Aug 23 17:35:26 2016 +0200 Merge remote-tracking branch 'origin/misc-fixes' commit 678c97f21ef15c98546f41647f3244799a37db1f Author: Ondrej Zajicek (work) Date: Tue Aug 23 17:33:00 2016 +0200 Minor README update commit d107ef78df2564cba75af1a6dcc9894c4468b207 Author: Pavel Tvrdik Date: Tue Aug 16 13:02:32 2016 +0200 Whitespace fixes commit dbac8793bd88279fd8956ce42db7bd2230965948 Author: Pavel Tvrdik Date: Tue Aug 16 10:42:12 2016 +0200 Add link to INSTALL in README file commit 9b3d2464cd6dafdd3021f4513f24d19d56d42d3d Author: Pavel Tvrdik Date: Tue Aug 16 10:15:58 2016 +0200 Rewrote README file * Made structure with headlines, * reordered, * kicked out 'What is missing' part, * Updated content by home page site and user docs commit 671ddd5b05cf35b2ab7b80f1d13641c875f22e77 Author: Ondřej Surý Date: Tue Aug 16 09:25:50 2016 +0200 Add .gitignore to ignore generated files commit 33d22f0e9e79c387c492d1cf16bdb723ca1d588a Author: Ondřej Surý Date: Tue Aug 16 09:24:12 2016 +0200 whitespace fixes commit 61e6725335fbba86175ec770c1e94c5f60e76d5c Author: Ondřej Surý Date: Tue Aug 16 09:23:55 2016 +0200 Include in cf-lex.l to avoid UINTx_MAX redefinition commit 0ea2afe67150661328c93679587740fbd8928b2a Author: Pavel Tvrdik Date: Mon Aug 15 16:16:36 2016 +0200 Adds mailing list address at the top of README file commit 13a31a4001e02ea7c84d26cbeaaa9fea816736f7 Author: Ondrej Zajicek (work) Date: Wed Jul 20 15:55:45 2016 +0200 Babel: Immediately update hello interval on interface reconfigure An interface reconfiguration may change both the hello and update intervals. An update interval change is immediately put into effect, while a hello interval change is not. This also updates the hello interval immediately (if the new interval is shorter than the old one), and sends a hello to notify peers of the change. Signed-off-by: Toke Høiland-Jørgensen commit a08a81c6b40dcf07e786b67e5015fc91a44333ca Author: Ondrej Zajicek (work) Date: Wed Jul 20 15:31:25 2016 +0200 Netlink: Fix build with older headers missing IFA_FLAGS commit e37d2e3e708db78f9b8f15eb34bb266cfae7bb42 Author: Ondrej Zajicek (work) Date: Wed Jul 20 15:06:57 2016 +0200 Netlink: Ignore tentative addresses Ignore tentative IPv6 addresses and wait until finish of Duplicate Address Detection (We got notification when an address is no longer tentative) to avoid problems when protocols try to use interfaces with tentative link-local addresses. Based on patch from Jan Moskyto Matejka commit 0a21c21112eff1286a0a2a7f7afc812f8d16cfa2 Author: Ondrej Zajicek (work) Date: Tue Jul 19 15:40:57 2016 +0200 Doc: Fix password ID option description Thanks to Alexander Velkov for noticing it commit c6ed5a0f9925476714d6b351c61dbce704a4f09d Author: Ondrej Zajicek (work) Date: Tue Jul 19 14:38:36 2016 +0200 Babel: Do not maintain feasibility distance for our own routes We do not need to maintain feasibility distances for our own router ID (we ignore the updates anyway). Not doing so makes the routes be garbage collected sooner when export filters change. Signed-off-by: Toke Høiland-Jørgensen commit 0f673666017bfc9c05c9495ae53bc323b9dc6660 Author: Ondrej Zajicek (work) Date: Tue Jul 19 14:28:53 2016 +0200 Babel: Do not keep an infeasible route as selected When a route becomes infeasible it should not be kept as selected; this is forbidden by section 3.6 of the RFC and prevents subsequent updates from the same router ID from replacing it. Signed-off-by: Toke Høiland-Jørgensen commit 5d6ca220850c615126ea6820f8c05528269feec6 Author: Ondrej Zajicek (work) Date: Tue Jul 19 14:23:41 2016 +0200 Babel: Send wildcard retractions on shutdown and startup This makes BIRD send a wildcard retraction on all interfaces before shutting down and right after starting up. This helps ensure that neighbours will discard the announced routes as soon as possible, rather than only after the normal timeout procedures. Signed-off-by: Toke Høiland-Jørgensen commit ecae2f43f37df642e5098201a0472802e6a70e78 Author: Ondrej Zajicek (work) Date: Tue Jul 19 13:33:02 2016 +0200 Babel: Rework handling of retractions An update with wildcard AE and infinite metric should be treated as a global retraction of all prefixes announced by that neighbour, per section 4.4.9 of the RFC. In addition, router ID and seqno in retraction updates should be ignored. This reworks the handling of retractions and adjusts the parser to handle all this correctly. Signed-off-by: Toke Høiland-Jørgensen commit 12640c149976e1eca54d9c22c593d07a27c49d42 Author: Ondrej Zajicek (work) Date: Tue Jul 19 12:16:51 2016 +0200 Babel: Documentation updates This updates the documentation to correctly mention Babel when protocols are listed, and adds examples and route attribute documentation to the Babel section of the docs. Signed-off-by: Toke Høiland-Jørgensen commit 321ff8c4049ec6c2fa198858b4a7f1814ce05e39 Author: Ondrej Zajicek (work) Date: Tue Jul 19 11:57:20 2016 +0200 Babel: Make sure intervals do not overflow Intervals are carried as 16-bit centisecond values, but kept internally in 16-bit second values, which causes a potential for overflow. This adds some checks to make sure this does not happen. Signed-off-by: Toke Høiland-Jørgensen commit 6887f409f0766c60dd8c3d3fdf01a1d989c090a5 Author: Ondrej Filip Date: Sun Jul 17 14:54:52 2016 +0200 Prepare for longer interface names - clean up of the code. commit ea0cb652e91d871e7808e93aa15ef34fc453c4fc Author: Ondrej Zajicek (work) Date: Mon Jul 11 20:41:32 2016 +0200 BGP: Fix extended messages Change attribute length limit to handle extended (64 kB) messages. Do not mix updates and withdraws (RFC 7606). commit f0b822a831d0f0f593bbedf0a7f15b94c3ca1d43 Author: Ondrej Zajicek (work) Date: Mon Jul 11 20:22:55 2016 +0200 Log: Fix error handling of debug file open Logging is not yet initialized, we have to use fprintf() here. Thanks to Pavel Tvrdik for noticing and debugging it. commit f1f39bb9d8e2260fe181240dd8194b06bdcfb54f Author: Ondrej Zajicek (work) Date: Fri Jul 1 11:03:13 2016 +0200 Filter: Fixes reconfiguration with last_nonaggregated operator commit 5de0e848de06a9187046dbc380d9ce6a6f8b21a2 Author: Pavel Tvrdik Date: Thu Jun 30 15:00:47 2016 +0200 filter/test.conf: fixes formating commit 775a5a81958e66a69663803dd2e731e3800da9e7 Author: Ondrej Zajicek (work) Date: Wed Jun 29 14:11:03 2016 +0200 BGP: Skip empty path segments in received AS_PATH Although RFC 4271 does not forbid empty path segments, they are useless and some implementations consider them invalid. It is clarified in RFC 7606, specifying that AS_PATH with empty segment is considered malformed. commit 8f01879c5629bd714dfeec968337cfcd4dbe6a87 Author: Pavel Tvrdík Date: Tue Mar 29 10:37:31 2016 +0200 cppcheck: fix va_end() functions commit 044e123fd34a17b13d7636def38542511f9c6baf Author: Pavel Tvrdik Date: Thu Jun 9 10:11:39 2016 +0200 Client: Includes stdlib.h for malloc() commit 122deb6d5b14f46f3cfb25bf3f5726005d6a3b3e Author: Ondrej Zajicek (work) Date: Thu Jun 9 00:30:41 2016 +0200 Filters: Fixes pm_same() w.r.t. ASN ranges and ASN expressions This is necessary for proper detection of filter changes during reconfigurations. commit 18c53c456704f8f0ccbdf6eb8ba5f82cb43aeba7 Author: Pavel Tvrdik Date: Thu Apr 7 12:18:57 2016 +0200 Fix declaration of shared global variables async_* In a header file write it with extern keyword. And in one of the *.c file declare it without extern keyword. commit a0fe1944d12771d60986a352552e5f4b306e5f7f Author: Ondrej Filip Date: Wed Jun 8 16:22:44 2016 +0200 Add AS# ranges to bgpmask. commit 90dc0f08434323535f84d64e113dae84675c46b2 Author: Ondrej Filip Date: Sat Jun 4 12:38:06 2016 +0200 Small typo in documentation example, submitted by Felix Eckhofer. commit 9dbcb11cb50167e959536e5a564ee9aafae509c6 Author: Jan Moskyto Matejka Date: Mon May 30 14:28:22 2016 +0200 Unix IO: Tried to fix strange behavior after POLLHUP or POLLERR. commit 925aa14912329bafff38a9e5a3f675809ff97785 Author: Jan Moskyto Matejka Date: Tue May 17 13:19:18 2016 +0200 After-master-merge simple fixes. BSD lib/setkey.h and lib/sysio.h #include fixes. OpenBSD's flex needs -o param without space. V6ONLY for SK_IP fix. commit d6f027ef3474bbc93d06865b0031bb6aae4fc031 Author: Ondrej Zajicek (work) Date: Tue May 17 17:59:38 2016 +0200 Make: Silence echo in verbose mode commit 379f99594086a0934155bd09696938dc39d1802d Author: Ondrej Zajicek (work) Date: Tue May 17 16:19:50 2016 +0200 BSD: Fix setkey in int-new branch commit 08b3a24da5bbd1bab09d6a2400cdf7705d5e18a7 Author: Ondrej Zajicek (work) Date: Tue May 17 15:21:49 2016 +0200 IO: Minor changes in socket AF handing AF can be specified implicitly by saddr or daddr, flags SKF_V4ONLY and SKF_V6ONLY are to be removed. commit 5af7b59660be615fbbd7c20b92b71321c003c43a Merge: d39d41fb b66a9e2f Author: Jan Moskyto Matejka Date: Fri May 13 13:48:04 2016 +0200 Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new commit d39d41fbda2ec86ea2bac27308eb4fb16ecc4702 Author: Jan Moskyto Matejka Date: Fri May 13 13:46:46 2016 +0200 Hash: Fix of previous commit commit b66a9e2f3376b4cb07ef4cc318f70a9c794f407a Merge: 659f80f2 3f2c7600 Author: Ondrej Zajicek (work) Date: Thu May 12 21:47:50 2016 +0200 Merge branch 'master' into int-new commit 659f80f262a83d600d5f095fb8a03e912d3fbe64 Author: Ondrej Zajicek (work) Date: Thu May 12 21:47:29 2016 +0200 Make int-new compilable again commit 3f2c7600fa2e35b1028c755aa06092b5991e1a8e Author: Ondrej Zajicek (work) Date: Thu May 12 21:29:04 2016 +0200 We don't need bvsnprintf() in BIRD client commit 776d6b2c05fe8b14e5ec357eca24fe59c549bfa4 Merge: af678af0 54ac0bec Author: Ondrej Zajicek (work) Date: Thu May 12 18:11:12 2016 +0200 Merge remote-tracking branch 'origin/int-new' into int-new commit af678af0d5c9ef3d8afdc0789b33dd0c40b6d6e5 Merge: 286e2011 8e433d6a Author: Ondrej Zajicek (work) Date: Thu May 12 17:49:12 2016 +0200 Merge remote-tracking branch 'origin/master' into int-new commit 54ac0beceedb9b36eb58dd8599ba903c668382f6 Author: Jan Moskyto Matejka Date: Thu May 12 16:16:25 2016 +0200 Hash: fixed rta hashing wrt. structure padding commit 286e2011d22ea6914d5f2db5de3f11911a1fb663 Author: Ondrej Zajicek (work) Date: Thu May 12 16:04:47 2016 +0200 Miscellaneous minor fixes commit 8e433d6a529a883d566dc1d5a4afe0f1e2750baf Author: Pavel Tvrdik Date: Thu May 12 15:49:44 2016 +0200 Prog Doc: Complete several missing parameters commit fff7498d6a54d4bcce4bd56db7ef3fb28be35578 Author: Pavel Tvrdik Date: Thu May 12 13:37:23 2016 +0200 User Doc: Fix several typing error commit 31e9e10144a6994773a04d94903fa3bdde6de91e Author: Stijn Tintel Date: Tue May 10 16:45:35 2016 +0300 netlink: update struct msghdr The netlink code assumes an order for the members of struct msghdr. This breaks recvmsg and sendmsg with musl libc on mips64. Fix this by using designated initializers instead. Signed-off-by: Stijn Tintel commit 0c6dfe52369a59d7f3da8ee6bc7c505e3da5c064 Merge: 7a7ac656 92912f06 Author: Jan Moskyto Matejka Date: Tue May 10 14:30:49 2016 +0200 Merge branch 'int-new' into int-new-merged commit 92912f063a94bd7c743a25628ca2073380e09ef4 Merge: a8caff32 2003a184 Author: Jan Moskyto Matejka Date: Tue May 10 14:21:15 2016 +0200 Merge remote-tracking branch 'origin/rte-update' into int-new commit a8caff322f83f1303c408bbefc440aeea9e619a3 Author: Jan Moskyto Matejka Date: Wed Apr 27 14:45:14 2016 +0200 Portability: Fixed C extension error generated by CLang. sysdep/linux/netlink.c:921:10: error: fields must have a constant size: 'variable length array in structure' extension will never be supported char buf[128 + KRT_METRICS_MAX*8 + nh_bufsize(a->nexthops)]; ^ 1 error generated. commit 7152e5efbb0fade868d5f2d2c7bc10ed52b3d19d Author: Jan Moskyto Matejka Date: Tue Apr 12 11:14:54 2016 +0200 Build system reworked to one global Makefile with includes and no nesting Also removed the lib-dir merging with sysdep. Updated #include's accordingly. Fixed make doc on recent Debian together with moving generated doc into objdir. Moved Makefile.in into root dir Retired all.o and birdlib.a Linking the final binaries directly from all the .o files. commit f7a99acb4eac23223f51ce83b8081cc9695fef1e Author: Pavel Tvrdik Date: Tue May 3 09:32:49 2016 +0200 Initialize variable ifr in sk_setup() ==00:00:00:02.831 2468== Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s) ==00:00:00:02.831 2468== at 0x513BDEA: setsockopt (in /usr/lib/libc-2.23.so) ==00:00:00:02.831 2468== by 0x45C7AF: sk_setup (io.c:1216) ==00:00:00:02.831 2468== by 0x45CDFF: sk_open (io.c:1417) ==00:00:00:02.831 2468== by 0x44B562: rip_open_socket (packets.c:740) ==00:00:00:02.831 2468== by 0x4481A7: rip_iface_locked (rip.c:616) ==00:00:00:02.831 2468== by 0x4133E4: olock_run_event (locks.c:177) ==00:00:00:02.831 2468== by 0x45A6DE: ev_run (event.c:85) ==00:00:00:02.831 2468== by 0x45A7AD: ev_run_list (event.c:142) ==00:00:00:02.831 2468== by 0x45E0FC: io_loop (io.c:2066) ==00:00:00:02.831 2468== by 0x463B56: main (main.c:845) ==00:00:00:02.831 2468== Address 0xffefffd24 is on thread 1's stack ==00:00:00:02.831 2468== in frame #1, created by sk_setup (io.c:1188) ==00:00:00:02.831 2468== Uninitialised value was created by a stack allocation ==00:00:00:02.831 2468== at 0x45C6BB: sk_setup (io.c:1188) commit 1e3810f9f8e251d82a8157b39df9be196315c43e Author: Ondrej Zajicek (work) Date: Fri Apr 29 13:25:46 2016 +0200 Doc: Minor fix commit 52bae25580e6e0edae8384885818044ef89103e3 Author: Ondrej Zajicek (work) Date: Fri Apr 29 13:07:21 2016 +0200 NEWS and version update commit 937e75d8f1d203b637ba0ea050026f9af92485f3 Author: Ondrej Zajicek (work) Date: Thu Apr 28 18:01:40 2016 +0200 Add the Babel routing protocol (RFC 6126) This patch implements the IPv6 subset of the Babel routing protocol. Based on the patch from Toke Hoiland-Jorgensen, with some heavy modifications and bugfixes. Thanks to Toke Hoiland-Jorgensen for the original patch. commit a7baa09862e6b4856cd66197c6bd74c7df336b8f Author: Ondrej Zajicek (work) Date: Wed Apr 13 14:30:28 2016 +0200 BSD: Add the IPsec SA/SP database entries control Add code for manipulation with TCP-MD5 keys in the IPsec SA/SP database at FreeBSD systems. Now, BGP MD5 authentication (RFC 2385) keys are handled automatically on both Linux and FreeBSD. Based on patches from Pavel Tvrdik. commit 43fc6bb0fb720762f12124076e2241855741ceb5 Author: Ondrej Zajicek (work) Date: Mon Apr 11 00:41:10 2016 +0200 Documentation update commit e90dd656cc9126e1fbcc45fb77a10bf1baa2a1b5 Author: Ondrej Zajicek (work) Date: Fri Apr 8 15:10:57 2016 +0200 Direct: Implement check link for direct protocol When enabled, direct protocol generates routes only if the underlying link state is up. commit 2003a1840731bd57365876e48c96c5a1ea0348cb Author: Jan Moskyto Matejka Date: Fri Apr 8 13:08:03 2016 +0200 Route update: move table lookup from protocols into rte_update2(). Many protocols do almost the same when creating a rte_update request before calling rte_update2(). This commit should simplify the protocol side of the route-creation routine. commit 7a7ac656829223713f9e6bcef63d2b5a5efce7d2 Merge: 4bdf1881 06edbb67 Author: Jan Moskyto Matejka Date: Fri Apr 8 12:09:31 2016 +0200 Merge branch 'master' into int-new-channels commit f2ae2badff37c008ba8217a12f8ee6dc6a3c5a39 Author: Ondrej Zajicek (work) Date: Thu Apr 7 12:20:45 2016 +0200 Main: Add local option Add option that changes default paths for config file and control socket to the current working directory. commit 4bdf1881dc6230b742d7efcaad8eeac4ed25f445 Author: Jan Moskyto Matejka Date: Mon Apr 4 16:17:11 2016 +0200 Channelize: rt_notify arg conversion table -> channel commit 0c8c8151fc1fb0dbfcd682153f50192ea1369884 Merge: a815d62d 1a7daab1 Author: Jan Moskyto Matejka Date: Thu Apr 7 09:58:31 2016 +0200 Merge branch 'int-new-channels' of gitlab.labs.nic.cz:labs/bird into int-new-channels commit 06edbb67ed807811654e7fd8f0f9b83766430216 Author: Ondrej Zajicek (work) Date: Thu Apr 7 01:10:24 2016 +0200 Nest: Reset export route counter during graceful restart Counter exp_routes is increased during initial route feed after GR recovery, so it has to start with zero, otherwise BIRD will end with double value in exp_routes. commit bd22d7f41d37dec8f7b8b845f6a18c775e66ddfc Author: Ondrej Zajicek (work) Date: Wed Apr 6 11:57:28 2016 +0200 IO: Avoid multiple event cycles in one loop cycle. Event cycle may took too much time and trigger next timer events, so avoid cycling between timer and event cycles inside the loop cycle. commit 9e7b3ebdf9556d7464911dd39e862b1c003319b3 Author: Ondrej Zajicek (work) Date: Wed Apr 6 11:49:34 2016 +0200 IO: Replace RX priority heuristic with explicit mark In BIRD, RX has lower priority than TX with the exception of RX from control socket. The patch replaces heuristic based on socket type with explicit mark and uses it for both control socket and BGP session waiting to be established. This should avoid an issue when during heavy load, outgoing connection could connect (TX event), send open, but then failed to receive OPEN / establish in time, not sending notifications between and therefore got hold timer expired error from the neighbor immediately after it finally established the connection. commit e86cfd41d975122cc944db68383aef4028da9575 Author: Ondrej Zajicek (work) Date: Wed Mar 23 18:25:15 2016 +0100 KRT: Fix route learn scan when route changed When a kernel route changed, function krt_learn_scan() noticed that and replaced the route in internal kernel FIB, but after that, function krt_learn_prune() failed to propagate the new route to the nest, because it confused the new route with the (removed) old best route and decided that the best route did not changed. Wow, the original code (and the bug) is almost 17 years old. commit ea0a8be2ff5afb8385a69cc0df70984e0fd3a570 Author: Jan Moskyto Matejka Date: Wed Mar 30 16:21:32 2016 +0200 IO/Poll: fix mistaken variable merge The events variable is used in the short loop decision. The reasons are not much clear, keeping this to keep the former behaviour. commit 54bb032d21d25a2221877e15325e79add10278ec Author: Jan Moskyto Matejka Date: Wed Mar 23 01:45:37 2016 +0100 Birdlib: Modify lists to avoid problems with pointer aliasing rules The old linked list implementation used some wild typecasts and required GCC option -fno-strict-aliasing to work properly. This patch fixes that. However, we still keep the option due to other potential problems. (Commited by Ondrej Santiago Zajicek) commit 665b8e5283df4f64eb44d8fb434489be1474b5d4 Author: Ondrej Zajicek (work) Date: Tue Mar 22 13:35:40 2016 +0100 Birdlib: Do cleanups after remove/free To avoid byzantine behavior in case of some errors, linked lists are cleared after rem_node() and resource headers are cleared after rfree(). commit 39a6b19d6d7e420805bd75783b77bf442745bccb Author: Ondrej Zajicek (work) Date: Tue Mar 22 12:51:31 2016 +0100 OSPF: Fix bogus LSA ID collisions between received and originated LSAs After restart, LSAs locally originated by the previous instance are received from neighbors. They are installed to LSA db and flushed. If export of a route triggers origination of a new external LSA before flush of the received one is complete, the check in ospf_originate_lsa() causes origination to fail (because en->nf is NULL for the old LSA and non-NULL for the new LSA). The patch fixes this by updating the en->nf for LSAs being flushed (as is already done for empty ones). Generally, en->nf field deserves some better description in the code. Thanks to Jigar Mehta for analyzing the problem. commit 0a505706bc909b2625d308ffb2eaed3dc8398538 Author: Ondrej Zajicek (work) Date: Wed Mar 9 17:51:50 2016 +0100 Minor changes in documentation commit a459f4df16eca156cb7c6def4a758fd89c9fa504 Author: Ondrej Zajicek (work) Date: Wed Mar 9 17:37:44 2016 +0100 OSPF: Fix reading from freed memory Thanks to Pavel Tvrdik for noticing it. commit 62a4ad365760afae485ae61c5aab734012545be4 Merge: 9036bbf2 9c92f692 Author: Jan Moskyto Matejka Date: Tue Mar 22 13:23:55 2016 +0100 Merge remote-tracking branch 'origin/poll' commit 9c92f69272de3795f7289969e815d99a93d0d9b3 Author: Jan Moskyto Matejka Date: Fri Mar 18 11:44:28 2016 +0100 Unix: Substituted select -> poll also in congestion checker It does strange things when even one fd larger than FD_SETSIZE is passed to select(). commit 9036bbf2b7cc781c87f2a6b3979198f77ec6ada1 Author: Pavel Tvrdík Date: Tue Mar 15 14:55:40 2016 +0100 RIP: fix typo in configuration at rx length opt commit 79a4f74a65941603cc42680d2e61b00ec88abe97 Author: Pavel Tvrdík Date: Tue Mar 15 10:29:32 2016 +0100 BGP: Add documentaion for extended messages commit fd926ed4eea319b94bd0e09e093b90846bcb169b Author: Jan Moskyto Matejka Date: Tue Mar 15 14:57:49 2016 +0100 Poll: Prevent the improbable case of EAGAIN after POLLIN commit e1c13a5a7b86f2ba09178300bad960224658c833 Author: Jan Moskyto Matejka Date: Wed Mar 9 12:12:02 2016 +0100 Unix: Rework of select-loop to poll-loop This should lift the limit of FD_SETSIZE and allow more than 1024 fd's. FD_SETSIZE limit doesn't matter now when creating new sockets. commit 1a7daab126471374841e41de7f7e590ab22f35c8 Author: Pavel Tvrdík Date: Wed Mar 9 16:48:28 2016 +0100 cf_error(char *msg, ...) -> cf_error(const char *msg, ...) commit 43fd8fae526cbc62093a32bda572c93fa4055e98 Author: Pavel Tvrdík Date: Wed Mar 9 11:03:49 2016 +0100 nest/proto fix local_debug mode commit 062d18fdb1f48bf7e3b10907b417d4568ba8cf3f Author: Pavel Tvrdík Date: Tue Feb 2 18:14:53 2016 +0100 Fix typo commit ce95af7a5f5159033e569a7ccedce0e20bb5d913 Merge: b25509e5 e3f506f9 Author: Jan Moskyto Matejka Date: Thu Feb 25 18:25:53 2016 +0100 Merge branch 'master' of gitlab.labs.nic.cz:labs/bird commit e3f506f9b53bd8e44976df1c935c7ec417793ace Author: Ondrej Zajicek (work) Date: Thu Feb 25 18:16:59 2016 +0100 OSPF: Multicast ability is irrelevant for stub interfaces commit b25509e5128e6f2a856cd4a07bb78f3d6b7fc789 Author: Jan Moskyto Matejka Date: Wed Jan 20 15:23:17 2016 +0100 All the current pthread implementations are OK and working with us. No more need to disable pthread for specific BSD's. commit a815d62d5902fb84c28c77726dbe94fc7528bf36 Author: Jan Moskyto Matejka Date: Fri Feb 19 15:51:16 2016 +0100 Hash: typecast error fix commit 9c9cc35c0273f8bcae10fb8b546d199514b2bbc5 Author: Ondrej Zajicek (work) Date: Tue Feb 16 17:33:58 2016 +0100 Filter: Implement last_nonaggregated operator on bgp_path commit c2106b674ca632f7c0bffd7cab4b1940f74d353c Author: Ondrej Zajicek (work) Date: Thu Feb 11 21:53:55 2016 +0100 Unix: Fix bug in syslog name handling Pointer to current_log_name has to be changed even if the name is the same, because the old one will be invalid/freed after reconfiguration. commit 487c6961cb29046dbe9560262e3e742e38691b83 Author: Ondrej Zajicek (work) Date: Thu Feb 11 16:38:28 2016 +0100 BGP: Fix bug in incoming connection handling When a BGP session was established by an outgoing connection with Graceful Restart behavior negotiated, a pending incoming connection in OpenSent state, and another incoming connection was received, then the outgoing connection (and whole BGP session) was closed, but the old incoming connection was just overwritten by the new one. That later caused a crash when the hold timer from the old connection fired. commit 9a74622ca1994669cdb3bac0bb2f6df2febd2744 Author: Jan Moskyto Matejka Date: Wed Feb 10 13:26:07 2016 +0100 Updated RTA hashes to 32-bit values. ... and reworked the hashes a bit. Also added mem_hash function which just computes a hash of given memory block. commit 1bb3ecb2a5369bc1992514da3cf5ef59dca46416 Author: Pavel Tvrdík Date: Mon Feb 8 16:08:50 2016 +0100 Fix closing flushed channel Fix reading from freed memory. Free at: channel_set_state(c, CS_DOWN) Read at: WALK_LIST2_DELSAFE(c, n, x, tab->channels, table_node) ==00:00:00:00.261 24718== ==00:00:09:31.755 24718== Invalid read of size 8 ==00:00:09:31.755 24718== at 0x4061BA: rt_prune_table (rt-table.c:1688) ==00:00:09:31.755 24718== by 0x405D5E: rt_event (rt-table.c:1559) ==00:00:09:31.755 24718== by 0x45D089: ev_run (event.c:85) ==00:00:09:31.755 24718== by 0x45D158: ev_run_list (event.c:142) ==00:00:09:31.755 24718== by 0x462814: io_loop (io.c:2412) ==00:00:09:31.755 24718== by 0x468712: main (main.c:833) ==00:00:09:31.755 24718== Address 0x5601538 is 136 bytes inside a block of size 304 free'd ==00:00:09:31.755 24718== at 0x4C29D2A: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==00:00:09:31.755 24718== by 0x46FF3E: rfree (resource.c:166) ==00:00:09:31.755 24718== by 0x470309: mb_free (resource.c:415) ==00:00:09:31.755 24718== by 0x406A6B: rt_unlock_table (rt-table.c:1921) ==00:00:09:31.755 24718== by 0x40DAE3: channel_do_down (proto.c:297) ==00:00:09:31.755 24718== by 0x40DD46: channel_set_state (proto.c:359) ==00:00:09:31.755 24718== by 0x4061AD: rt_prune_table (rt-table.c:1692) ==00:00:09:31.755 24718== by 0x405D5E: rt_event (rt-table.c:1559) ==00:00:09:31.755 24718== by 0x45D089: ev_run (event.c:85) ==00:00:09:31.755 24718== by 0x45D158: ev_run_list (event.c:142) ==00:00:09:31.755 24718== by 0x462814: io_loop (io.c:2412) ==00:00:09:31.755 24718== by 0x468712: main (main.c:833) ==00:00:09:31.755 24718== Block was alloc'd at ==00:00:09:31.755 24718== at 0x4C28C10: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==00:00:09:31.755 24718== by 0x470FBC: bird_xmalloc (xmalloc.c:29) ==00:00:09:31.755 24718== by 0x4701E6: mb_alloc (resource.c:339) ==00:00:09:31.755 24718== by 0x406C29: rt_commit (rt-table.c:1977) ==00:00:09:31.755 24718== by 0x45C36D: config_do_commit (conf.c:269) ==00:00:09:31.755 24718== by 0x45C545: config_commit (conf.c:361) ==00:00:09:31.755 24718== by 0x4686F9: main (main.c:822) ==00:00:09:31.755 24718== commit 2a013bb3a01174fac3a841fd825ac4f13f3ea84d Author: Jan Moskyto Matejka Date: Mon Feb 1 10:25:31 2016 +0100 Fixed sigsegv for missing proto->rt_notify hook If rt_notify is NULL, the export must always stay DOWN. commit ade389b326ddf2caaf08d7d3be8b3a1066ea7c97 Author: Jan Moskyto Matejka Date: Mon Feb 1 09:22:18 2016 +0100 BSD: compilation error fix commit f4a60a9bc429c28cb397402331dc01a789197450 Author: Ondrej Zajicek (work) Date: Tue Jan 26 11:48:58 2016 +0100 Channels - explicit links between protocols and tables The patch adds support for channels, structures connecting protocols and tables and handling most interactions between them. The documentation is missing yet. commit 9f5782d9691f23296c4b1a68ef66630d9cc3a6cd Author: Pavel Tvrdík Date: Thu Jan 28 16:55:27 2016 +0100 Add 'GENERATE/ACCEPT FROM datetime TO datetime' to password options commit 966ca6143b8648a29e77b6328133bc3f245d50ee Author: Pavel Tvrdík Date: Wed Jan 27 12:14:46 2016 +0100 io.c: fix reads from uninitialized memory commit d82987d12e96db887033deabb6c46f07db64e1b8 Author: Pavel Tvrdík Date: Wed Jan 27 12:25:30 2016 +0100 RIP: Fix DBG output commit 74d94167631ffd1b10709460510a1e3c8fc0e904 Author: Jan Moskyto Matejka Date: Mon Jan 25 10:29:06 2016 +0100 RIPng: fixed misrejection of host routes commit 2fad92144ee2e3a818a7510554d2144e46c3a4c8 Author: Jan Moskyto Matejka Date: Thu Jan 21 15:46:33 2016 +0100 BSD: fix no-return warning commit 3f35816136f1b57067d5ce426b031e4e3583085c Author: Jan Moskyto Matejka Date: Thu Jan 21 10:59:52 2016 +0100 BSD: Explicitly dropping routes with mismatched AF's. commit 0e965f69914313857a95d03b2e6136d3e84019dd Author: Jan Moskyto Matejka Date: Wed Jan 20 15:23:17 2016 +0100 All the current pthread implementations are OK and working with us. No more need to disable pthread for specific BSD's. commit 7eb9e79648e17037f3691aafa829970efacbbbc9 Author: Pavel Tvrdík Date: Thu Jan 21 10:30:08 2016 +0100 Add condition for max_pxlen by ROA grammar commit a4caa1c0a3b6bfb9918f08dbbf856e4d3c78080a Author: Pavel Tvrdík Date: Thu Jan 21 10:24:50 2016 +0100 Use net_addr pointer for net_addr_roaX net_addr_roa6 is bigger than net_addr Thanks to Ondrej Zajicek for notice commit 259052199ba82f0f37b87416592e2e2ddbdaee5f Author: Pavel Tvrdík Date: Wed Jan 20 15:41:15 2016 +0100 Add forgotten semicolon commit 650b4189427eb5a5f96753e39c0d67f09e0ef445 Author: Pavel Tvrdík Date: Wed Jan 20 16:29:17 2016 +0100 Delete old ROA code commit 0264ccf6f4acaea5313dee2cd3bc3bdb28c74f60 Author: Pavel Tvrdík Date: Wed Jan 20 15:38:37 2016 +0100 Rewrite roa_check() for integrated BIRD Thanks to Ondrej Zajicek for his support with writing this code. commit cb1bd816db5b69acb8c6f72211d13f987a494304 Author: Pavel Tvrdík Date: Wed Jan 20 15:06:19 2016 +0100 Add ROA_* constants values to grammar of configuration Add ROA_UNKNOWN, ROA_VALID and ROA_INVALID commit 513ad0a85e57e4e0f7928fde7332778ca1c2148f Author: Pavel Tvrdík Date: Wed Jan 20 14:55:37 2016 +0100 Add ROA net_addr to grammar Example: protocol static { route 10.110.0.0/16 max 16 as 1000 blackhole; route 10.120.0.0/16 max 24 as 1000 blackhole; route 10.130.0.0/16 max 24 as 2000 blackhole; route 10.130.128.0/18 max 24 as 3000 blackhole; ... } commit 8109eb765fe92f4d47b497b3e2b24b59841c3487 Author: Jan Moskyto Matejka Date: Thu Jan 7 14:45:01 2016 +0100 BSD integration fixes commit f9d729ab682156cc658eb451b95d7cbd37dfa139 Author: Pavel Tvrdík Date: Thu Jan 14 10:03:50 2016 +0100 NET ROAx: add max_pxlen, fix format commit 9a883adf954c2f68085a398e8ab38bd54831cf52 Author: Jan Moskyto Matejka Date: Mon Jan 11 11:03:11 2016 +0100 Net address format: Do not print the -4 or -6 suffix in %I4 and %I6 commit a820ae107456a26656f29a3ed14010cf0cd87842 Author: Pavel Tvrdík Date: Tue Jan 12 11:36:28 2016 +0100 NET ROAx more small changes - Remove `u8 src` from net_add_roaX - Add `u8 max_pxlen` to net_add_roaX - Add some missing macro and functions for ROA - Remove ASN from hash function for ROA Thanks to Ondrej Santiago Zajicek commit 93e807292cff6eb3dfcd8d590dded04b965ac1a5 Author: Pavel Tvrdík Date: Tue Jan 12 11:27:38 2016 +0100 ROA change printf 'ASN: xxx' to 'ASxxx' commit 6ffa8f53931e2ae8becf8ec6ef09db88737a6a06 Author: Jan Moskyto Matejka Date: Thu Jan 7 12:02:54 2016 +0100 Hidden AF_INET* inside sysdep/ commit 5b218c3d9bf9357aed0acf535bdfc6684cc5cda4 Author: Jan Moskyto Matejka Date: Thu Jan 7 11:29:05 2016 +0100 BFD: split of v4/v6 sockets commit b9f56921865dfe816091266e990e94db3e2fdbdf Author: Pavel Tvrdík Date: Thu Jan 7 18:24:14 2016 +0100 Fix check in net_route() in debug mode commit de9b87f55863f29eb7965d8a772f8a34f195f4ac Author: Pavel Tvrdík Date: Thu Jan 7 18:17:16 2016 +0100 Add NET ROA4/6 structures commit e691d16a63ce40bc56ecbc970e8118686d4b0148 Author: Ondrej Zajicek (work) Date: Tue Dec 29 17:12:47 2015 +0100 Explicit ip4_addr / ip6_addr printf support commit 74c838a87000ca800e8b3f265340c1317989a04a Author: Ondrej Zajicek (work) Date: Tue Dec 29 15:34:48 2015 +0100 Move ID allocator to a separate file and use it also in OSPF commit 9a70c8d6c38155d8abb6d814563b9eefc134e901 Author: Jan Moskyto Matejka Date: Tue Dec 29 13:01:00 2015 +0100 Netlink: Removed forgotten if-stub (caused strange errors) commit 04632fd77f291f67753341d12d540f7dac341bd3 Author: Ondrej Zajicek (work) Date: Thu Dec 24 15:52:03 2015 +0100 Follow-up work on integration commit 70b90dde23a684c4d32aa53685f76a73ecba941d Author: Jan Moskyto Matejka Date: Tue Dec 22 09:45:09 2015 +0100 Better fix of missing AF_INET6? definition in lib/socket.h Moved the code to sysdep. commit 600998fcb1a1d155215ab32644982e9b78767e3e Author: Ondrej Zajicek (work) Date: Mon Dec 21 20:16:05 2015 +0100 Modify FIB_WALK() and FIB_ITERATE() to work with new FIB code Returned user data pointers have offset relative to fib_node. commit 67aa88336a91e635753ba42df45d7de5e191ed35 Author: Jan Moskyto Matejka Date: Mon Dec 21 18:23:08 2015 +0100 BSD wants to include sys/socket.h in lib/socket.h (AF_INET6? definitions) commit 0bf95f99e6126b481a4dcac574ada59f9ad3662b Author: Ondrej Zajicek (work) Date: Mon Dec 21 17:17:21 2015 +0100 Follow-up work on integration Contains some patches from Jan Moskyto Matejka commit 23c212e7f1e80a3c6b88b49918972bc28375bd51 Author: Ondrej Zajicek (work) Date: Mon Dec 21 03:27:41 2015 +0100 Follow-up work on integration commit e92a4b855f668e8ac685ad79c288ff182ebd110b Author: Ondrej Zajicek (work) Date: Sun Dec 20 21:43:00 2015 +0100 Filter: Fix some changes in IP<->Quad implicit conversion commit d549b83fc2f66b4c5e15e158409442993a2d62c4 Author: Ondrej Zajicek (work) Date: Sun Dec 20 19:47:36 2015 +0100 Delete ipv6 option from configure commit 0f7d5b1a889142cdcda0546d8adcc76de465ffb8 Author: Ondrej Zajicek (work) Date: Sun Dec 20 18:16:48 2015 +0100 Nest: Reimplement fib_route() and add some consts commit 29a6416276a04ca1fc2bc64ebc7ef559918d78d8 Author: Ondrej Zajicek (work) Date: Sun Dec 20 16:58:37 2015 +0100 KRT: Integration of IPv4/IPv6 in sysdep/linux commit 7fd4143eadd5af6e1ad7825d7d7506ad021bf1ad Author: Jan Moskyto Matejka Date: Fri Dec 18 11:57:38 2015 +0100 Integrated address print lengths Minor changes by Ondrej Santiago Zajicek commit 9656dce72eead158e6da3ad560720bb0addfe7e2 Author: Jan Moskyto Matejka Date: Wed Dec 16 15:30:44 2015 +0100 ROA code switchoff commit aedd3a6babbaf35becb7770f73f30b20b464393f Author: Jan Moskyto Matejka Date: Wed Dec 16 10:43:58 2015 +0100 Implemented missing prefix manipulation functions commit 5e173e9f631913f68cf38d57a69c3ce6faf60d1e Author: Jan Moskyto Matejka Date: Wed Dec 16 10:25:12 2015 +0100 Stop perusing f_prefix for non-prefix-set uses Multiple changes by Ondrej Santiago Zajicek commit d7661fbe9dea980c61daa01a11a9aa59fa7be426 Author: Jan Moskyto Matejka Date: Fri Dec 11 15:35:37 2015 +0100 Removed BITS_PER_IP_ADDRESS, MAX_PREFIX_LENGTH, BIRD_AF Explicit setting of AF_INET(6|) in IP socket creation. BFD set to listen on v6, without setting the V6ONLY flag to catch both v4 and v6 traffic. Squashing and minor changes by Ondrej Santiago Zajicek commit 9b136840d90cce887cd139054c3f0a7d8b9f57d2 Author: Jan Moskyto Matejka Date: Mon Dec 7 16:24:18 2015 +0100 Netlink and BSD: Integrating IPv4 and IPv6 Squashing and minor changes by Ondrej Santiago Zajicek commit 52e21323b6c49af9d076586241451973a7d1e7c6 Author: Ondrej Zajicek (work) Date: Wed Nov 25 15:52:58 2015 +0100 BGP: Update capability number from IANA for extended messages commit 04ae8ddaa15b72c265dc7cf038b733d235198754 Merge: d44e686e 33b4f40a Author: Ondrej Zajicek (work) Date: Wed Nov 25 14:24:35 2015 +0100 Merge branch 'master' into int-new commit 33b4f40acce02c90b4b7766c5c94ebf2d22765c6 Author: Pavel Tvrdík Date: Fri Nov 13 16:08:28 2015 +0100 MD5: Mormalize naming style commit 90f78507f4a13673ccf0ba7c786b43d9e882fca7 Merge: 8eb8e546 ad276157 Author: Ondrej Zajicek (work) Date: Tue Nov 24 15:21:11 2015 +0100 Merge branch 'master' into rip-new commit ad27615760e2795da3efe5e97c0e888281d5ca59 Author: Jan Moskyto Matejka Date: Tue Nov 10 14:59:41 2015 +0100 Netlink: attribute validation before parsing Wanted netlink attributes are defined in a table, specifying their size and neediness. Removing the long conditions that did the validation before. Also parsing IPv4 and IPv6 versions regardless on the IPV6 macro. commit e422ca0f292d08a873deacdbffbb6c6cbd79f88a Author: Ondrej Zajicek (work) Date: Tue Nov 24 13:52:26 2015 +0100 Some consts for function arguments Patch from Pavel Tvrdik commit 5126380beace4e39578f005fe115917b8e8b8ff3 Author: Ondrej Zajicek (work) Date: Tue Nov 24 13:47:28 2015 +0100 Minor changes to SHA hash functions commit 12d752ef24ab507d249a60098ec98dcf28b70036 Merge: 1e4891e4 f312a837 Author: Ondrej Zajicek (work) Date: Mon Nov 23 11:32:18 2015 +0100 Merge commit 'origin/crypto-hash^' commit 1e4891e48e7b6f022564e7409d15c3fdb65ec2ad Author: Ondrej Zajicek (work) Date: Mon Nov 23 11:13:40 2015 +0100 Nest: Fix bug in device proto If an interface address notification is received during device protocol shutdown/restart, BIRD crashed. Thanks to Wei Huang for the bugreport. commit f312a837e919c660884ceb9c50c106df1e4c0658 Author: Pavel Tvrdík Date: Fri Nov 13 16:14:36 2015 +0100 Add SHA-384/512 and HMAC-SHA-384/512 crypto hash commit 4035e0e79c609bde30a2f755eec864771ea08e21 Author: Pavel Tvrdík Date: Fri Nov 13 16:13:15 2015 +0100 Add SHA-224/256 and HMAC-SHA-224/256 crypto hash commit 5d0c36f1da83b2a2a07e043247410948d90c600e Author: Pavel Tvrdík Date: Fri Nov 13 16:11:51 2015 +0100 Add SHA1 and SHA1-HMAC crypto hash commit 75ff08022ea58fe3efa96639f080ce375e997675 Author: Pavel Tvrdík Date: Fri Nov 13 16:10:33 2015 +0100 Add get_u64() and put_u64() into lib/unaligned.h commit d44e686e9bcae5850115c0e1adfe24523dce61ee Author: Ondrej Zajicek (work) Date: Thu Nov 12 02:03:59 2015 +0100 Follow-up commit on integrated BIRD Use net_addr for interface address prefixes, support net_addr in configuration parser. commit fce764f90e8331d1adb6a85ec00136dfeae1a398 Author: Pavel Tvrdík Date: Mon Nov 9 09:14:26 2015 +0100 Fix compiling with --enable-debug option commit 9ddbfbddf87462bbf50437bdc1d44499a5c223e7 Author: Jan Moskyto Matejka Date: Tue Nov 3 14:42:41 2015 +0100 Netlink: Allow more than 256 routing tables. Since 2.6.19, the netlink API defines RTA_TABLE routing attribute to allow 32-bit routing table IDs. Using this attribute to index routing tables at Linux, instead of 8-bit rtm_table field. commit 86b4e17001fe4cca6dde7ff523346121c0ae68fe Author: Ondrej Zajicek (work) Date: Mon Nov 9 01:01:12 2015 +0100 Nest: Fixes bug in missing cleanup during table removal When a table is removed during reconfiguration, a reference was not cleared in the old configuration, which breaks undo. commit 9b9a7143c43d01f0459d40363d56e9c7690c596f Author: Ondrej Zajicek (work) Date: Mon Nov 9 00:42:02 2015 +0100 Conf: Fixes bug in symbol lookup during reconfiguration Symbol lookup by cf_find_symbol() not only did the lookup but also added new void symbols allocated from cfg_mem linpool, which gets broken when lookups are done outside of config parsing, which may lead to crashes during reconfiguration. The patch separates lookup-only cf_find_symbol() and config-modifying cf_get_symbol(), while the later is called only during parsing. Also new_config and cfg_mem global variables are NULLed outside of parsing. commit fe9f1a6dedda6bab23cbb605d1cd5db6cd3e2468 Author: Ondrej Zajicek (work) Date: Thu Nov 5 12:48:52 2015 +0100 Initial commit on integrated BIRD New data types net_addr and variants (in lib/net.h) describing network addresses (prefix/pxlen). Modifications of FIB structures to handle these data types and changing everything to use these data types instead of prefix/pxlen pairs where possible. The commit is WiP, some protocols are not yet updated (BGP, Kernel), and the code contains some temporary scaffolding. Comments are welcome. commit 3aed0a6ff7b2b811a535202fd787281d2ac33409 Author: Ondrej Zajicek (work) Date: Tue Nov 3 11:27:27 2015 +0100 IO: Fix the previous bugfix I should check it after making some trivial changes. The original patch from Alexander has it right. commit 338f85ca7721fac16394ccabd561ddb5ccaacb36 Author: Ondrej Zajicek (work) Date: Tue Nov 3 11:08:57 2015 +0100 IO: Handle fd values too big for select() If the number of sockets is too much for select(), we should at least handle it with proper error messages and reject new sockets instead of breaking the event loop. Thanks to Alexander V. Chernikov for the patch. commit 8eb8e546dc8cc647fcfa4a3a17dfa8ab36b00958 Merge: 8465dccb acb04cfd Author: Ondrej Zajicek (work) Date: Sat Oct 17 14:44:34 2015 +0200 Merge branch 'master' into rip-new commit acb04cfdc550697a7171a86ca559fd8c52841acb Author: Ondrej Zajicek (work) Date: Sat Oct 17 14:36:53 2015 +0200 Minor changes commit 8465dccb06afffed171dc1e224e4eb5f67cc3326 Author: Ondrej Zajicek (work) Date: Mon Oct 5 12:14:50 2015 +0200 Major RIP redesign The new RIP implementation fixes plenty of old bugs and also adds support for many new features: ECMP support, link state support, BFD support, configurable split horizon and more. Most options are now per-interface. commit b5e76398de1d4468b4061d9ef57dd3154b2f745e Author: Ondrej Zajicek Date: Wed Aug 19 11:16:23 2015 +0200 OSPF: Fixes some issues with link detection Thanks to Bernardo Figueiredo and Israel G. Lugo for the bugreport. commit c7b99a932cab1873042e356143ab71755920157a Author: Ondrej Zajicek Date: Tue Jul 28 15:08:21 2015 +0200 Nest: Fixes one of previous commit commit dbf4c0cb258bd92efb54f95194f664f95ba98fd9 Author: Ondrej Zajicek Date: Tue Jul 28 12:56:51 2015 +0200 Minor update to test commits commit 641172c6e5e4e291029084074f94f448d6bc69dd Author: Ondrej Zajicek Date: Tue Jul 28 12:35:12 2015 +0200 Netlink: Fixes uninitialized variable Thanks to Pavel Tvrdik for the bugfix commit 538264cf1a7690d90b2953aebff21958c2b55c44 Author: Ondrej Zajicek Date: Fri Jul 24 18:02:07 2015 +0200 Static: Support for BFD controlled static routes commit 1321e12ac460bd542d3946a0c4a4dacd71157cfa Author: Ondrej Zajicek Date: Mon Jul 20 11:12:02 2015 +0200 Static: Allows to specify attributes for static routes The patch adds suport for specifying route attributes together with static routes, e.g.: route 10.1.1.0/24 via 10.0.0.1 { krt_advmss = 1200; ospf_metric1 = 100; }; commit ffa398b8d8bac4cf6368fe700466cad4ff12fee8 Author: Ondrej Zajicek Date: Sun Jul 19 11:39:24 2015 +0200 BFD: Fixes crash after socket error Thanks to Thomas King for the bugreport. commit a8ad8fd6491d04620fe4fdebc50f0da2927f9b21 Author: Ondrej Zajicek Date: Sat Jul 18 23:15:04 2015 +0200 Simplify build messages Thanks to Christian Tacke for the original patch. commit 17661ff934a80d517284c96756357d4ed5af9a64 Author: Ondrej Zajicek Date: Sat Jul 18 19:30:35 2015 +0200 Nest: Fixes symbols in router id Thanks to Peter Hudec for noticing the problem. commit 6683d42d5b560c8805b977736b2a769ea2d9aa8b Author: Ondrej Zajicek Date: Sat Jul 18 19:05:11 2015 +0200 Documentation update commit 06e0d1b692d8a190c3f1d073c5c557d8efe78b17 Author: Ondrej Zajicek Date: Sat Jul 18 13:38:21 2015 +0200 BGP: Extended messages support Implements draft-ietf-idr-bgp-extended-messages-10, for now undocumented and with temporary private capability number. commit ab4da3423d89fb6c60a4137f19c189a8716ecab6 Author: Ondrej Zajicek Date: Sat Jul 18 13:05:05 2015 +0200 Direct: Fixes behavior for the same routes on different interfaces Thanks to Andrew (seti.kr.ua) for the bug report. commit 8d9eef17713a9b38cd42bd59c4ce76c3ef6c2fc2 Author: Ondrej Zajicek Date: Mon Jun 8 02:20:43 2015 +0200 BGP multipath support Kernel option 'merge paths' allows to merge routes exported to kernel protocol (currently BGP and static routes) to multipath routes. commit db027a41d47b8fc52b65067ccabe2024554e53ca Author: Ondrej Zajicek Date: Thu Jun 4 11:35:26 2015 +0200 Fixes subtle bug in temporary attribute handling In some cases, export filter accessed attributes of a different route. commit 78a2cc289fbe11d5b5783220e2cc61d119a78ec3 Author: Ondrej Zajicek Date: Wed Jun 3 11:58:46 2015 +0200 KRT: Fixes some minor bugs in kernel protocol commit d217ba5111a80a629e408961b902d7759c4b46f5 Author: Ondrej Zajicek Date: Sun May 31 23:25:33 2015 +0200 Moving of mulipath merging code from OSPF to nest commit ca34698ca62d979c281ed517f040619e31c3ada3 Author: Ondrej Zajicek Date: Sun May 31 11:29:53 2015 +0200 Fixes bug in pipe feeding when filtered routes are kept in table commit ae80a2de95d3d3c153ce20b90c9d8757d02cb33d Author: Pavel Tvrdík Date: Tue May 19 08:53:34 2015 +0200 unsigned [int] -> uint commit e348ef01b433e06888310c1098a05291034a856c Author: Pavel Tvrdík Date: Tue May 19 08:14:04 2015 +0200 unsgined char -> byte commit 398f92253186d70eb3f2e910c7f8dd2636ee5fa1 Author: Ondrej Filip Date: Mon Jun 1 10:41:17 2015 +0200 Typo fix by Hans van Kranenburg commit 9fe1d3ca8a6420b4bdaf15a54ab7b13be6cc07eb Author: Ondrej Zajicek Date: Fri May 22 11:12:48 2015 +0200 Fixes unnamed protocols from templates commit d0e23d42de133de706151411d8d4091d07904d29 Author: Ondrej Zajicek Date: Sun May 17 00:54:33 2015 +0200 Simplify flushing process Related to changes from previous patch. commit 86f567e13c2202fc3c3a1ce49f9a35220a50f117 Author: Ondrej Zajicek Date: Sat May 16 20:17:59 2015 +0200 Fix minor issue in pipe route propagation In some circumstances during reconfiguration, routes propagated by pipes to other tables may hang there even after the primary routes are removed. There is already a workaround for this issue in the code which removes these stale routes by flush process when source protocols are shut down. This patch is a cleaner fix and allows to simplify the flush process commit 38e835dede88158d97c3039ed22faabed79c7181 Author: Ondrej Zajicek Date: Wed May 13 13:19:26 2015 +0200 Fix in the last commit commit 9fdf9d29b6b570205c36934aab7e50539e042102 Author: Ondrej Zajicek Date: Tue May 12 16:42:22 2015 +0200 KRT: Add support for plenty of kernel route metrics Linux kernel route metrics (RTA_METRICS netlink route attribute) are represented and accessible as new route attributes: krt_mtu, krt_window, krt_rtt, krt_rttvar, krt_sstresh, krt_cwnd, krt_advmss, krt_reordering, krt_hoplimit, krt_initcwnd, krt_rto_min, krt_initrwnd, krt_quickack, krt_lock_mtu, krt_lock_window, krt_lock_rtt, krt_lock_rttvar, krt_lock_sstresh, krt_lock_cwnd, krt_lock_advmss, krt_lock_reordering, krt_lock_hoplimit, krt_lock_rto_min, krt_feature_ecn, krt_feature_allfrag commit 315f23a0470112ced04badbb117bc7854ee53e06 Author: Ondrej Zajicek Date: Sat May 9 18:50:15 2015 +0200 Add bitfield route attribute type commit 77edab640925e8d1131f0d00b41de055129ff99f Author: Ondrej Zajicek Date: Fri May 1 14:40:56 2015 +0200 OSPF: Redesign LSA checksumming New LSA checksumming code separates generic Fletcher-16 and OSPF-specific code and avoids back and forth endianity conversions, making it much more readable and also several times faster. commit 30d09eb96e8d46143d04285016a137d71a87c416 Author: Ondrej Zajicek Date: Tue Apr 28 13:45:44 2015 +0200 OSPF: Fixes validation of LSA checksums Prior to this patch, BIRD validates the OSPF LSA checksum by calculating a new checksum and comparing it with the checksum in the header. Due to the specifics of the Fletcher checksum used in OSPF, this is not necessarily correct as the checkbytes in the header may be calculated via a different means and end up with a different value that is nonetheless still correct. The documented means of validating the checksum as specified in RFC 905 B.4 is to calculate c0 and c1 from the unchanged contents of the packet, which must result in a zero value to be considered valid. Thanks to Chris Boot for the patch. commit 7069fc9e724134ddd841219f5673cc9b13c58490 Author: Ondrej Zajicek Date: Sat Apr 25 21:41:43 2015 +0200 KRT: Fixes route reload Did not really worked commit c5ff44a703e4ab810a5bd45cf9140643a50fb3ec Author: Ondrej Zajicek Date: Sat Apr 25 20:43:43 2015 +0200 KRT: Fixes learning of preferred kernel routes. When a new route was imported from kernel and chosen as preferred, then the old best route was propagated as a withdraw to the kernel protocol. Under some circumstances such withdraw propagated to the BSD kernel could remove the new alien route and thus reverting the import. commit 90097f4fb924922b416247abf291fb21f39dc8e1 Author: Ondrej Zajicek Date: Wed Apr 22 10:53:15 2015 +0200 KRT: Support for RTM_CHANGE on BSD commit deec752ef941eef4c36c21c5c5426d08e98c7a44 Author: Ondrej Zajicek Date: Mon Apr 20 12:27:00 2015 +0200 NEWS and version update commit b867a87c2fd694e6e690dc94da76754e89f03370 Author: Ondrej Zajicek Date: Sun Apr 19 00:19:56 2015 +0200 Fixes port range socket option commit ef3cac669ca0f6f2b983e33ab6d553705c35f3df Author: Ondrej Zajicek Date: Sat Apr 18 13:22:41 2015 +0200 OSPF: Fixes handling of external routes with immediate gw The bug caused that received external LSAs with locally reachable next hops were ignored. I wonder why nobody noticed it sooner. commit 304ac2e861a5ea28683489aff38ff37ff6873bb4 Author: Ondrej Zajicek Date: Sun Apr 12 10:47:17 2015 +0200 Minor fixes commit d924d5a5626397da7e71fddfb1c0fd22c2714f2c Author: Ondrej Zajicek Date: Wed Apr 1 00:01:35 2015 +0200 BGP: Fixes serious bug in TX handling Under some circumstances and heavy load, TX could be postponed until the session fails with hold timer expired. Thanks to Javor Kliachev for making the bug reproductible. commit 16a3254c4cb592e7cfa3aea744e9fd58665d6367 Author: Ondrej Zajicek Date: Tue Mar 31 23:59:40 2015 +0200 Understand IFF_MULTICAST flag on ifaces in Linux Unfortunately, some interfaces support multicast but do not have this flag set, so we use it only as a positive hint. Thanks to Clint Armstrong for noticing the problem. commit 2eadd36fa004d705a4003892d1639485eeaf8486 Author: Ondrej Zajicek Date: Sun Mar 29 21:24:47 2015 +0200 BGP: AS-wide unique router ID (RFC 6286) support RFC 6286 relaxed rules for router IDs, allowing EBGP sessions between routers with the same ID (but different ASN). commit 9aed29e605334d34d0e6a90fc172ee83d0274ad3 Author: Ondrej Zajicek Date: Sun Mar 29 18:27:13 2015 +0200 BGP: Enhanced route refresh (RFC 7313) support Also hook feed_done is renamed to feed_end. commit a5a5a41e2ee51ad6dfef0ab24e07d6d9b16a4215 Author: Ondrej Filip Date: Mon Mar 9 23:59:26 2015 +0100 Possibility to define unnamed protocols from template added. commit 509aab5debef5b4710d8983da6ef076a226fd7ea Author: Ondrej Zajicek Date: Mon Mar 2 10:58:20 2015 +0100 Fixes serious bug in BGP add-path Temporary rta is reused in BGP, while rta_lookup() breaks it. Thanks to Alexander Chernikov for analysing the problem. commit af454f9b7c3930a7900e60a7fb608b7de11852aa Author: Ondrej Zajicek Date: Mon Mar 2 09:42:44 2015 +0100 Fixes bug in debug dumps Using 'dump sockets' in IPv6 mode caused crash due to mismatched format string. Thanks to Pavel Tvrdik for noticing it. commit 8bcb5fb1e8a0718f88f99cde2f5b5a3bae5c4451 Author: Ondrej Zajicek Date: Mon Mar 2 09:41:14 2015 +0100 Implement latency tracking, internal event log and watchdog commit 4e63974471c4e2f11781cda163e0dc2ac6fb72f9 Author: Ondrej Zajicek Date: Tue Feb 24 16:19:14 2015 +0100 Add minor comment commit 9c89560e6cdf44a21b2eff8765973ed8665fa07f Author: Ondrej Zajicek Date: Sun Feb 22 20:14:14 2015 +0100 Use IP_PORTRANGE_HIGH for BFD where available commit 6cf72d7ad7cbe1eb2f5b63660be6967d29b37044 Author: Ondrej Zajicek Date: Sun Feb 22 16:08:28 2015 +0100 Rename BGP option 'start delay' to 'connect delay' Also update log message for error-triggered startup delay. commit a1beb8f3ee7a6e41dbe4bfd336b8bf5eecb46d01 Author: Ondrej Zajicek Date: Sun Feb 22 13:50:58 2015 +0100 Relax BGP neighbor parameter Permit specifying neighbor address, AS number and port independently. Add 'interface' parameter for specifying interface for link-local sessions independently. Thanks to Alexander V. Chernikov for the original patch. commit 86c3eea0f3ec74ac1024d4aba4e98c962126f387 Author: Ondrej Zajicek Date: Sat Feb 21 21:19:49 2015 +0100 Use AF_UNSPEC for RTM_GETLINK This value is specified in documentation. commit 2bbc308321894e0fd301766e8d7d78a4ec119053 Author: Ondrej Zajicek Date: Sat Feb 21 21:08:23 2015 +0100 Store protocol config size inside protocol structure Make proto_config_new() use this info instead of supplied size. Thanks to Alexander V. Chernikov for the patch. commit 374917adccb955fbb2796955166fabe46a09e096 Author: Ondrej Zajicek Date: Sat Feb 21 20:39:59 2015 +0100 Make BGP protocol instance search a separate function Thanks to Alexander V. Chernikov for the patch. commit 6264aad16f3320eceb20825c6049917e771b9364 Author: Pavel Tvrdík Date: Wed Jan 7 15:04:02 2015 +0100 Minor fixes commit 85a3639d99a39a79b65c2dbc2a136baee6ba2a2b Author: Pavel Tvrdik Date: Fri Dec 5 09:25:38 2014 +0100 Better Clang compatibility commit 7d37bf79de190c89f704bfbf0a753f328d995d5a Author: Pavel Tvrdik Date: Wed Dec 3 10:32:26 2014 +0100 Remove a comparison of unsigned expression < 0 commit e598853e681d23dd7820627eeed96bf53197eae5 Author: Pavel Tvrdik Date: Wed Dec 3 10:57:31 2014 +0100 Add const to a param msg at functions log_msg, log_rl, die, bug and debug commit 4a591d4b947e0abc0ad013ca1b75da27c6922be5 Author: Pavel Tvrdik Date: Wed Dec 3 10:10:34 2014 +0100 Replacing GNU old-style field designator extension commit 8ce9a87755372d7612375bb1a81a288f309746c8 Author: Ondrej Zajicek Date: Sat Feb 21 14:52:17 2015 +0100 Fixes minor bug in BFD. Thanks to Pavel Tvrdik for noticing it. commit 51762a45b39f906fe72db2d3d46c9890cb01bbd8 Author: Ondrej Zajicek Date: Sat Feb 21 14:05:20 2015 +0100 Allows user data attached to f_trie_node structure. Thanks to Alexander Chernikov for the patch. commit bc7f4e0e3447c579f68b43d407b64a5262f0d11e Author: Ondrej Zajicek Date: Sat Feb 21 12:42:31 2015 +0100 Bump max symbol length to 64. And move the constant to conf.h header. Thanks to Alexander Chernikov for the patch. commit ab006391305165c805f75e3a2ce20946748233c9 Author: Ondrej Zajicek Date: Sat Feb 21 12:27:05 2015 +0100 Fixes a bug in locking code. When multiple protocols have a lock for the same IP address, it crashes under some circumstances. Thanks to Matthias Schiffer for the bugreport. commit dfc7a6c6a0758a1d9a13b94708228c9844efe97e Author: Ondrej Zajicek Date: Sat Feb 21 12:24:30 2015 +0100 Fixes potential alignment bug in BGP. Thanks to Andrew (seti.kr.ua) for the bug report. commit 523f020b5f6b63096a7d5e90938baecd4beea0bd Author: Ondrej Zajicek Date: Sat Feb 21 11:46:14 2015 +0100 Link state support in BGP. Configurable fast shutdown of a BGP session when an interface loses link. commit 7730553b7eeb33d21e5597f110334ca584ad532d Merge: 0da562a7 ec2194fa Author: Ondrej Zajicek Date: Sat Feb 21 11:39:45 2015 +0100 Merge remote-tracking branch 'origin/soft-int' commit 0da562a7cb25ed2b8724248ad6f841b1831a09c3 Author: Ondrej Zajicek Date: Sat Nov 8 23:52:42 2014 +0100 Fixes error message in 'show route' cmd. Message 'Network not in table' was not reported if a network node without any routes was found in a routing table. commit ec2194fa7a20a2768ca0027b5f3c024f0a251866 Author: Ondrej Filip Date: Wed Nov 5 11:07:25 2014 +0100 Version 1.5.0pre commit dd5ef279bce002b9942ea437ef80ce3443bbe1dc Author: Ondrej Filip Date: Tue Nov 4 18:11:59 2014 +0100 Small typo fixed. commit f92e6ab364d50900bc9104af4539f6ea42b25c43 Author: Ondrej Zajicek Date: Mon Nov 3 20:35:58 2014 +0100 Changes order of iface/addr/neigh event hooks. Now the order is: Up -> iface, addr, neigh Down -> neigh, addr, iface It fixes the case when an iface appears, related static routes are activated and exported to OSPF before the iface notification and therefore forwarding addresses are not encoded in generated external LSAs. commit ac9dc669d80cbfeea3d0cdba5ec7354c804b1ae9 Author: Ondrej Zajicek Date: Mon Nov 3 20:35:25 2014 +0100 Bugfix in latest OSPF changes. commit cd3b700393144796c9dead54b6ac2fc31aaa5272 Author: Ondrej Zajicek Date: Mon Nov 3 14:53:59 2014 +0100 Bugfix to OSPF reconfiguration. commit 6f8bbaa10bbd21729d0b62a5878febcbee2c0811 Author: Ondrej Zajicek Date: Mon Nov 3 10:42:55 2014 +0100 Fininshing integrated OSPF. commit d148d0af363cdac7783c4bf79527669cdd5ddf4a Author: Ondrej Filip Date: Sat Oct 25 21:08:35 2014 +0200 Mailling list location changed. commit 88a183c6c9a2b86b52f67e87bbc8b7edd32670c6 Author: Ondrej Zajicek Date: Fri Oct 24 11:11:43 2014 +0200 Integrated IP functions. commit f8fefde318c6248ad94e7b6d60155deed9ab8eed Author: Ondrej Zajicek Date: Fri Oct 24 10:27:21 2014 +0200 Refactoring of OSPF messages. commit d26cfa0519daf1369b697b0df000c8db8b730e66 Author: Ondrej Filip Date: Thu Oct 16 18:05:54 2014 +0200 __attribute__((packed)) added. Thank to Maksim Tamarsky commit 78342404ff573e85e396f0611014b90cea9b4c0a Merge: 178a197a cfdea7b8 Author: Ondrej Zajicek Date: Tue Oct 14 17:23:34 2014 +0200 Merge remote-tracking branch 'origin/master' into soft-int commit cfdea7b85f6c520cc5a62eb907d2190db14c9900 Author: Ondrej Zajicek Date: Sun Oct 5 23:59:18 2014 +0200 NEWS and version update. commit 7aa809016e9a2e24ef914888f7413dc1f2721b17 Author: Ondrej Zajicek Date: Thu Oct 2 12:46:26 2014 +0200 Implements show route noexport option. Shows routes that would be exported to the protocol but are rejected by the export filter. commit 1123e707400984108f48ac7c1be559f7ed8d9306 Author: Ondrej Zajicek Date: Thu Oct 2 11:41:34 2014 +0200 Implements token bucket filter for rate limiting. commit dcde7ae597ccb7d81648b9ecab7c0f61c88e60f2 Author: Ondrej Zajicek Date: Thu Oct 2 11:33:55 2014 +0200 Allows to configure different remote port for BGP sessions. Thanks to João Taveira Araújo for the original patch. commit 252c7e4d0b7b45c89f69b3c4763b0c013aa5830d Author: Ondrej Zajicek Date: Thu Oct 2 11:05:55 2014 +0200 Refresh kernel protocol when interface disappears. When an interface goes down, (Linux) kernel removes routes pointing to that ifacem but does not send withdraws for them. We rescan the kernel table to ensure synchronization. Thanks to Alexander Demenshin for the bugreport. commit b2f008378a39104152b20a969942cd6c99644984 Author: Ondrej Zajicek Date: Thu Oct 2 11:02:14 2014 +0200 Allows more constants in set literals. Thanks to Michael Fincham for the bugreport. commit 0479b44373892db273f3e0365c7cbaad2eeb0d5f Author: Ondrej Zajicek Date: Thu Oct 2 10:59:34 2014 +0200 Fixes some warnings. commit 178a197afb77770d8a90765e39065679936a45d1 Author: Ondrej Zajicek Date: Mon Jul 21 21:50:56 2014 +0200 OSPF instance id option and documentation update. commit 742029eb782f19c05decbd443d245f12360d5e78 Author: Ondrej Zajicek Date: Sat Jul 19 17:28:38 2014 +0200 Whitespace cleanup in OSPF. commit a7a7372aa7c527619ee527e3b37013f9fb87d618 Author: Ondrej Zajicek Date: Fri Jul 18 18:24:12 2014 +0200 Temporary integrated OSPF commit. commit 7c00551749005ad951845eb924f76e1fd28e62a2 Author: Ondrej Filip Date: Wed Jul 9 23:46:02 2014 +0200 Version 1.4.4. commit 06c4b6ac9da204453049fa56a204474486a9c9e9 Author: Ondrej Zajicek Date: Wed Jul 9 18:42:59 2014 +0200 NEWS and version update. commit 029ec22d0acedb79e03394b60ea99bb46c479d79 Author: Ondrej Zajicek Date: Wed Jul 9 18:34:42 2014 +0200 Fixes a bug in BSD kernel interfacing code. The bug was introduced in 05476c4d04a24bdb26fa64e05ab31bc36118f34e. commit 751482899c190194b4958bc54ded428f98f565e9 Author: Ondrej Zajicek Date: Mon Jul 7 22:56:21 2014 +0200 Implements default router preference (RFC 4191) for RAdv. Thanks to Baptiste Jonglez for the patch. commit 6285793f18817091060c7257f7d4af0db010a67a Author: Ondrej Zajicek Date: Mon Jul 7 22:23:37 2014 +0200 Replaces function name in test.conf as it collided with new keyword. commit 20e8d040b09f1e01c431c686f1ced5a12ba7bc68 Author: Ondrej Zajicek Date: Mon Jun 30 11:55:22 2014 +0200 Fixes integer overflow in show memory command. Thanks to Job Snijders for the bugreport. commit 8945f73d946a9323daf8dfc1bf5b3884cf6d7664 Author: Ondrej Zajicek Date: Thu Jun 26 13:30:27 2014 +0200 Ensures that msg_controllen includes last padding. Although RFC 3542 allows both cases, Theo de Raadt thinks he knows better, and msg_controllen without last padding fails on OpenBSD. Thanks to Job Snijders for the bugreport. commit 70945cb645402a4bb1d3dc46a07928caeb954c1f Author: Ondrej Zajicek Date: Thu Jun 26 11:58:57 2014 +0200 Temporary integrated OSPF commit. commit 9d5960cfa5b4c15ddd48dbab599f864a6aa1e025 Author: Ondrej Zajicek Date: Tue Jun 10 12:16:01 2014 +0200 Fixes max include depth in documentation. Thanks to Artyom Gavrichenkov for the patch. commit 9eceab33f97724be148f9f05614d7551940e85f1 Author: Ondrej Zajicek Date: Thu May 29 23:05:03 2014 +0200 String constants could be used for string option values. Thanks to Frederik Kriewitz for the patch. commit 05476c4d04a24bdb26fa64e05ab31bc36118f34e Author: Ondrej Zajicek Date: Sun May 18 11:42:26 2014 +0200 IPv4/IPv6 integrated socket code. commit 1149aa977d906a6400f998d5f6600871584395d0 Author: Ondrej Zajicek Date: Mon May 5 11:05:12 2014 +0200 Fixes a problem with undoing of deconfiguring of protocol. Thanks to Sergey Popovich for the original patch. commit 5a3905fe905ab1cc1a58fe9e6a4284f7d5057d13 Merge: 66370eac 7d9ab86b Author: Ondrej Zajicek Date: Sun May 4 11:59:50 2014 +0200 Merge commit 'origin/master' commit 66370eac1f88ec74b3017f1c39038d7b8b776de6 Author: Ondrej Zajicek Date: Sun May 4 00:01:06 2014 +0200 Fixes BGP crash when update with some attributes and empty NLRI is received. Thanks to Charlie Allom for the bugreport. commit 7d9ab86b7ac7d1f039af92a58eb749a24811b5c9 Author: Ondrej Zajicek Date: Sun May 4 00:01:06 2014 +0200 Fixes BGP crash when update with some attributes and empty NLRI is received. commit c865cae3eb327d1e0a745352c483bc7cb00f9323 Author: Ondrej Zajicek Date: Mon Apr 28 17:31:03 2014 +0200 Fixes 'show route export' w.r.t. protocols with different RA_* types. commit 984d734944a39b70a59f74e57f0e6fc3f720dd48 Author: Ondrej Zajicek Date: Sun Apr 27 00:46:32 2014 +0200 Fixes limit verification during reconfiguration. commit 145368f5474436ad7c48fa26f5bde8108ae5ef4a Author: Ondrej Zajicek Date: Wed Apr 23 13:54:28 2014 +0200 Extends multipath support for OSPF. Fixes cases where the same network or external route are propagated by several OSPF routes and some other corner cases in next hop construction and ECMP. Allows to specify whether external routes should be merged. Thanks to Peter Christensen for the original patch. commit 4dd24f05f384ac14546d4bebbfcb0ecf9a976ec6 Merge: 1cb0f83d 6c6ebd64 Author: Ondrej Zajicek Date: Wed Apr 23 13:52:15 2014 +0200 Merge commit 'origin/master' commit 6c6ebd64c3e44a2658a7ae8729159f1653c00a89 Author: Ondrej Zajicek Date: Mon Apr 14 14:47:20 2014 +0200 NEWS and version update. commit 7c4a8007255403d046d7e909f710f0b1ed1791b1 Author: Ondrej Filip Date: Mon Apr 14 12:28:30 2014 +0200 Fixed bug in unused function. commit 859cbd75e12966b09985b2a992da5ffb250938f8 Author: Ondrej Zajicek Date: Mon Apr 14 12:50:03 2014 +0200 Fixes a bug in (mainly) IPv6 BGP. Stack variable may be used unitialized and that would lead to spurious rta_free(), which may cause crash. The bug was introduced in 1.4.1 from merging add-path branch. Thanks to Peter Andreev for reporting it and Alexander V. Chernikov for resolving it. commit 1cb0f83d291d9bb3da06067bc2ea838238d5c487 Author: Ondrej Zajicek Date: Mon Apr 7 11:48:25 2014 +0200 Fixes some asserts. commit 538fec7b1b7dd729eadf1c933e27f59080cd3576 Author: Ondrej Zajicek Date: Wed Apr 2 23:00:10 2014 +0200 NEWS and version update. commit 2750b2484f256686a38ef6b89db7e2afe9b7999a Author: Ondrej Zajicek Date: Wed Apr 2 20:09:37 2014 +0200 Fixes missing line in BFD context help. commit 864f52a5f4c47ac8dc44a8808beb7f038cbf9899 Author: Ondrej Zajicek Date: Wed Apr 2 19:58:23 2014 +0200 Fixes nasty bug in BFD. When a BFD session is removed while being scheduled for notification, the session stays in notify list and is removed twice, which leads to a strange crash after a while. commit 60442b1698563ebc5837454d89dbe4afa037882d Author: Ondrej Zajicek Date: Mon Mar 31 18:51:51 2014 +0200 NEWS and version update. commit d96ec7f6e0d26546d9a27064fd13591618258894 Author: Ondrej Zajicek Date: Mon Mar 31 18:51:16 2014 +0200 Updates BFD documentation. commit eb5ea6bdd6fa45f03425ea38b8d1b16fd5ff7469 Author: Ondrej Zajicek Date: Mon Mar 31 13:21:13 2014 +0200 Fixes build on some old systems. commit 43eb8f610f7796375419dc8d72df7a41c01c82af Author: Ondrej Zajicek Date: Mon Mar 31 12:02:20 2014 +0200 Removes conflicting definition. This function is a part of Readline interface for a long time (with a different type). commit d7c0628591b802e202903b63fce53b6a422a3db2 Author: Ondrej Zajicek Date: Mon Mar 31 00:56:44 2014 +0200 Check validity of interface definitions. Thanks to Aleksey Berezin for the bugreport. commit 0c3d9dacafdb807d2101c67610969707353f434a Author: Ondrej Zajicek Date: Tue Mar 25 14:58:00 2014 +0100 Fixes file descriptor leak when parser ends with error. Thanks to MrBr for the bugreport. commit 4e7c974d22ee5d938d8d8e7018f0a63f609d630b Author: Ondrej Zajicek Date: Mon Mar 24 19:22:19 2014 +0100 Fixes a bug in graceful restart. commit 9637c7c0acbc56bbf6fedc44d89f921386843992 Author: Ondrej Zajicek Date: Mon Mar 24 13:33:15 2014 +0100 Minor fixes in documentation. commit dad92c30c7892457335d52a09548330498567ea8 Author: Ondrej Zajicek Date: Mon Mar 24 12:56:56 2014 +0100 Reformat bird.sgml to have consistent line length. commit c980f8002e0f0578d5e715d48d65d9fb9a0c5a70 Merge: 2e84b4e8 227af309 Author: Ondrej Zajicek Date: Mon Mar 24 12:41:43 2014 +0100 Merge branch 'bgp-grace' commit 227af309e55a59f14d1a5a757f17900164bffc97 Author: Ondrej Zajicek Date: Mon Mar 24 12:32:12 2014 +0100 Fixes some minor issues in graceful restart. commit 2e84b4e82dbf8fce0fd12fb0c25d925ffd287970 Author: Ondrej Zajicek Date: Sun Mar 23 01:40:37 2014 +0100 Fixes a bug in rte_src handling. commit 6eda3f135f5bab4db456531d25bc3e5f669ec22e Author: Ondrej Zajicek Date: Sun Mar 23 01:35:33 2014 +0100 Documentation (and minor fixes) for BGP graceful restart. commit 0c791f873aeb7c1052c97db7da4fe23873d69603 Author: Ondrej Zajicek Date: Thu Mar 20 14:07:12 2014 +0100 BGP graceful restart support. Also significant core protocol state changes needed for that, global graceful restart recovery state and kernel proto support for recovery. commit d40c26594c22ad934a13061e11b373bdf81af8f9 Author: Ondrej Zajicek Date: Wed Feb 26 13:25:39 2014 +0100 Fixes issues with static protocol reconfiguration. The old static route was not removed when the nexthop changed and the new one was not viable (no neighbor). Thanks to Pierluigi Rolando for the original patch. commit 3216eb03ddddc057bb18fa4dd02b7935a604f71f Author: Ondrej Zajicek Date: Wed Feb 26 12:52:00 2014 +0100 Fixes longstanding issue with interfaces staying in IF_TMP_DOWN. Thanks to Pierluigi Rolando and others for the bugreport. commit d776540811cdf672dc113f29feef2415465589c6 Author: Ondrej Zajicek Date: Wed Feb 12 12:57:38 2014 +0100 Adds configure error message. commit 4e398e34bf140baf73fe8dceaf81078fb343f65a Author: Ondrej Zajicek Date: Fri Feb 7 13:09:55 2014 +0100 Workaround thread-unsafeness of cli_echo(). commit 9ae0f4b78c5e3619ee19969c052c863bf96be6d9 Author: Ondrej Zajicek Date: Fri Feb 7 11:46:01 2014 +0100 Fixes autoconf check for ncurses. commit 5c200e0a4d26d183e04fda43de16340521002c40 Merge: 4a5eb284 080ed4d8 Author: Ondrej Zajicek Date: Thu Feb 6 20:15:05 2014 +0100 Merge branch 'add-path' commit 4a5eb284c9d51441e09976021d1bd93c21408d46 Author: Ondrej Zajicek Date: Thu Feb 6 18:09:18 2014 +0100 Update include directive documentation. Thanks to Pierluigi Rolando for the bugreport. commit 12201fd854424628be7a00e1180ba082db7efa0b Author: Ondrej Zajicek Date: Thu Feb 6 18:00:41 2014 +0100 Fix a documentation update. commit 10c2e1e0125dfa600b1c2b6553883cccf2d025dd Author: Ondrej Zajicek Date: Thu Feb 6 17:54:25 2014 +0100 Fixes crash when state of disabled OSPF protocol is queried. Thanks to Ondrej Caletka for the bugreport. commit cba9cbf1bdb253c7727da10ff4f835d7ffbadeed Author: Ondrej Zajicek Date: Thu Feb 6 17:51:16 2014 +0100 Silence this annoying warning. commit 48e5f32db676645640f84ab3d630cce975aa6b20 Author: Ondrej Zajicek Date: Thu Feb 6 17:46:01 2014 +0100 Many changes in I/O and OSPF sockets and packet handling. I/O: - BSD: specify src addr on IP sockets by IP_HDRINCL - BSD: specify src addr on UDP sockets by IP_SENDSRCADDR - Linux: specify src addr on IP/UDP sockets by IP_PKTINFO - IPv6: specify src addr on IP/UDP sockets by IPV6_PKTINFO - Alternative SKF_BIND flag for binding to IP address - Allows IP/UDP sockets without tx_hook, on these sockets a packet is discarded when TX queue is full - Use consistently SOL_ for socket layer values. OSPF: - Packet src addr is always explicitly set - Support for secondary addresses in BSD - Dynamic RX/TX buffers - Fixes some minor buffer overruns - Interface option 'tx length' - Names for vlink pseudoifaces (vlinkX) - Vlinks use separate socket for TX - Vlinks do not use fixed associated iface - Fixes TTL for direct unicast packets - Fixes DONTROUTE for OSPF sockets - Use ifa->ifname instead of ifa->iface->name commit f48fa14214301382b2e6b134788a7506b61b664f Merge: 6601a148 300e4008 Author: Ondrej Zajicek Date: Thu Feb 6 16:47:43 2014 +0100 Merge commit 'origin/master' into socket commit 300e4008f02382b87409dabb52a317b8336de55b Author: Ondrej Filip Date: Wed Feb 5 23:32:28 2014 +0100 Fedora init script improvement suggested by alex@alex.org.uk commit e9e6fbf924630abf821aa38f99e571f706536350 Author: Ondrej Filip Date: Wed Feb 5 15:57:37 2014 +0100 Minor changes in Fedora init script. commit ec35c7c2fc24e499a86022860c38460ae4bbad39 Author: Ondrej Filip Date: Tue Jan 21 23:43:22 2014 +0100 Small doc update. commit 6601a14831cdd32fc671ebc9dc299d2be427e489 Merge: 2d0b7e24 283c7dfa Author: Ondrej Zajicek Date: Tue Dec 10 22:30:46 2013 +0100 Merge branch 'add-path' commit 2d0b7e24a52d51904faa8a8e96d68863491c110a Author: Ondrej Zajicek Date: Mon Dec 2 11:54:32 2013 +0100 Fixes problem with source address selection in BGP and BFD. commit 080ed4d8c2c1982dd0c81c62703064b620a67a01 Author: Ondrej Zajicek Date: Sun Dec 1 18:25:39 2013 +0100 Fixes bug in documentation. commit 10115b1d70552f3ec4446dfec9e62c3a16d9eae0 Author: Ondrej Zajicek Date: Sun Dec 1 18:20:09 2013 +0100 Updates add-path documentation. commit e7d2ac4401be8aaf9629e248cad6a74498a6be24 Author: Ondrej Zajicek Date: Tue Nov 26 22:37:24 2013 +0100 Finishes add-path. Fixes some bugs and uses generic hash implementation. commit 283c7dfada53a6dee6a8a17ecab492ffafd44b66 Merge: 736e143f 0bb4e37d Author: Ondrej Zajicek Date: Mon Nov 25 18:42:47 2013 +0100 Merge branch 'master' into add-path commit 0bb4e37db317a1290bad24fe430cac6569a9bd8c Author: Ondrej Filip Date: Mon Nov 25 15:16:20 2013 +0100 Release date added. commit e75520c455a1a3fd026a9633c3ad26d865165fee Author: Ondrej Zajicek Date: Mon Nov 25 13:46:29 2013 +0100 NEWS and version update. commit 90eb5e7a8bb60cb637626a3b433caf10cd8d2a03 Author: Ondrej Zajicek Date: Mon Nov 25 13:44:07 2013 +0100 Use ISO 8601 timeformats by default. commit 0c95f85ec59cc970e8f9aa2da56e25dad249bbb8 Author: Ondrej Zajicek Date: Mon Nov 25 11:06:00 2013 +0100 Fixes a reply code. commit 8137fe6d45762844248300de2a030e96042b1975 Author: Ondrej Zajicek Date: Mon Nov 25 02:03:23 2013 +0100 Allows shorthands for birdc noninteractive commands. commit e237b28a4d4b17ab50182ac110f28594967e76dc Author: Ondrej Zajicek Date: Mon Nov 25 01:21:39 2013 +0100 Changes primary addr selection on BSD to respect SIOCGIFADDR ioctl() result. Thanks to Alexander V. Chernikov for the original patch. commit 5ebc92935cb58c78286d91f0831de94cd4ae0f9e Author: Ondrej Zajicek Date: Sun Nov 24 22:22:24 2013 +0100 Last state change should track protocol state change. And not core state change, which is not much relevant (e.g. refeed in BGP). commit c72aca41e5fa55b0efa768e93b55f5c307f84025 Author: Ondrej Zajicek Date: Sun Nov 24 22:12:51 2013 +0100 OSPF ifaces on loopback should be stub. commit e4d179f2c2f213c9190ff4d05979dc33f2c5b2c7 Author: Ondrej Zajicek Date: Sun Nov 24 12:50:53 2013 +0100 Minor changes to default router ID calculation. commit f3e59178506dab9d54cf19ec701f8d9a7fe283f9 Author: Ondrej Zajicek Date: Sun Nov 24 12:37:24 2013 +0100 Enables multihop mode for IBGP by default. This is more consistent with common usage and also with the behavior of other implementations (Cisco, Juniper). Also changes the default for gw mode to be based solely on direct/multihop. commit 52e030e14666ff00a4bb0c700d2c027fbeb87d04 Author: Ondrej Zajicek Date: Sun Nov 24 00:17:02 2013 +0100 Converts filters to unsigned integers. commit 65194bd1eb2e6af217a750fa1e02b6eea66c7130 Author: Ondrej Zajicek Date: Mon Aug 15 02:12:54 2011 +0200 Removes workaround related to import of kernel device routes. Thanks to Benjamin Cama for notification. commit 204e0d5d59279c4245d4d46b86a570b043d683cf Author: Ondrej Filip Date: Sat Nov 23 18:11:55 2013 +0100 Dots added. New release will be 1.4.0. commit d0e33681540c9ad64b15f57a9d39c27658127a31 Author: Ondrej Filip Date: Sat Nov 23 13:27:47 2013 +0100 Added some other features into NEWS file commit d940a2c4d4096f761a750e2df42ab55fd27a7e80 Author: Ondrej Filip Date: Sat Nov 23 13:26:52 2013 +0100 Added a few sentences about symbol names. commit 736e143fa50607fcd88132291e96089b899af979 Merge: 094d2bdb 2b3d52aa Author: Ondrej Zajicek Date: Sat Nov 23 11:50:34 2013 +0100 Merge branch 'master' into add-path Conflicts: filter/filter.c nest/proto.c nest/rt-table.c proto/bgp/bgp.h proto/bgp/config.Y commit 2b3d52aa421ae1c31e30107beefd82fddbb42854 Author: Ondrej Zajicek Date: Sat Nov 23 01:56:16 2013 +0100 NEWS and version update. commit 77e43c8b72ff77dc7607accb09576c0baab422e0 Author: Ondrej Zajicek Date: Fri Nov 22 22:49:04 2013 +0100 Minor fixes. commit 547d3bf45dd430828d597dfb56624bdc1bd798b3 Author: Ondrej Zajicek Date: Fri Nov 22 22:42:47 2013 +0100 Allows pthreads by default on Linux and FreeBSD only. commit 41f8bf57c4d80cbec89b90b901afa9df4d2d76f1 Author: Ondrej Zajicek Date: Fri Nov 22 21:59:43 2013 +0100 Changes identifiers to avoid use of reserved ones. commit 56027b5cbd7f432d30f7fc99bcf8680c840e6163 Author: Ondrej Zajicek Date: Fri Nov 22 21:58:43 2013 +0100 Minor fix in log_commit() w.r.t. changes in BFD branch. commit 1fba34a7a1e245f08212a31a65030230da8c451d Author: Ondrej Zajicek Date: Fri Nov 22 18:45:57 2013 +0100 Adds check for buffer size in OSPF LSA flood. commit 0aeac9cb7f9887374ce0258c8653f9518529bf08 Merge: 8931425d 7c9930f9 Author: Ondrej Zajicek Date: Fri Nov 22 02:43:41 2013 +0100 Merge commit 'origin/bfd' commit 8931425d02dd8656b48142f608d3119ab6f4a96f Author: Ondrej Zajicek Date: Fri Nov 22 02:12:21 2013 +0100 Fixes problem with RIP on multiple ifaces on BSD. RIP sockets for multiple ifaces collided, because we cannot bind to a specific iface on BSD. Workarounded by SO_REUSEPORT. Thanks to Eugene M. Zheganin for the bugreport. commit 548c329cde371bceef05f86b7f904378a392d89c Author: Ondrej Zajicek Date: Fri Nov 22 01:20:32 2013 +0100 Adds rate limiting to some log messages. commit 64534ea2f4361c247d7a0d1b6b14a02e8e3d6d33 Author: Ondrej Zajicek Date: Thu Nov 21 13:17:42 2013 +0100 Fixes an issue when opposite address is mistaken for broadcast on ptp ifaces on BSDs. Thanks to Lex van Roon for the bugreport and to Alexander V. Chernikov for examining it and locating the problem. commit 7c9930f9c8feb3b08f7a9e94a08807ccbbc096f5 Author: Ondrej Zajicek Date: Thu Nov 21 11:36:49 2013 +0100 Adds a missing file. I forgot to add that to the previous commit. commit f8f2419d4c5b9028b9b3d2d893fe802f18eb239b Author: Ondrej Zajicek Date: Wed Nov 20 13:30:00 2013 +0100 Additional filter test case. commit 4d4979c67c65dceb1ae557707312b83fde4bc8a8 Author: Ondrej Zajicek Date: Wed Nov 20 13:25:33 2013 +0100 Fixes some potential issues with invalid term size in clients. commit 1ec522538fb81a56b068c087d0a842faf7aa7869 Author: Ondrej Zajicek Date: Tue Nov 19 22:33:48 2013 +0100 BFD protocol, ready for release. Supports OSPF and BGP and also statically configured sessions. commit 33be3ba713901befe2df651b869a406df8fc8ace Author: Ondrej Zajicek Date: Mon Oct 21 15:06:09 2013 +0200 Accepts a change of OSPFv3 neighbor's IP address. Thanks to Pierre Pfister for the patch. commit a15dab76f93337b07b4b03a64ac3bac26285dfd9 Author: Ondrej Zajicek Date: Mon Oct 21 14:58:32 2013 +0200 Implements 'allow local as' option. Similar to allowas-in option on other routers. commit f8cc7396cf25328b002394bbd7af679188b03370 Author: Ondrej Zajicek Date: Tue Oct 15 10:57:57 2013 +0200 Forces KRT rescan on syncer startup with multi syncer config. Thanks to Sergey Popovich for the patch. commit 1cd198cf52b3eae677159d81eacca3e0ebe24e71 Author: Ondrej Filip Date: Sat Oct 5 22:45:08 2013 +0200 Flag -f "run in foreground" added as requested by a package maintainter. commit 0e175f9f0fd872e95225355dbdeca49cd35ec0fd Author: Ondrej Zajicek Date: Sat Oct 5 20:12:28 2013 +0200 Fixes some BFD bugs and makes logging thread-safe. commit e7c2380260f20a4a3587b47df97879ef91c69774 Author: Ondrej Zajicek Date: Sat Oct 5 19:30:12 2013 +0200 Implements PID file support. Thanks to Thierry Fournier for the original patch. commit 7ccb36d3308ef57d340e663f0cabd24663f4f62a Author: Ondrej Zajicek Date: Wed Oct 2 14:57:29 2013 +0200 Implements C.len operator for clist and eclist types. Thanks to Sergey Popovich for the original patch. commit 28a10f84cbc3635e59bff348cb1715859dfacade Author: Ondrej Zajicek Date: Wed Oct 2 14:41:37 2013 +0200 Some fixes in filter code. Thanks to Sergey Popovich for original patches. commit 70c5780535fa3bd2360e8208f9273ac6d1741107 Author: Ondrej Zajicek Date: Wed Oct 2 12:10:09 2013 +0200 Minor code cleanups. Thanks to Sergey Popovich for the patch. commit b655596d1d9ad7664d12249c946ba3483b2de3f0 Author: Ondrej Zajicek Date: Wed Oct 2 11:42:46 2013 +0200 Simplifies val_in_range(). Also fixes missing type check for element ~ set. commit ec57bbf67f9e4221fb98f6769f592cedf2eb2d24 Author: Ondrej Filip Date: Mon Sep 30 14:07:34 2013 +0200 Recheck export/import/receive limits during reconfiguration. commit a5fc59587fe864e4fcfb44eb3be57231b4ca339b Author: Ondrej Zajicek Date: Thu Sep 26 22:08:21 2013 +0200 Rewrites static attribute filter code and adds ifname/ifindex attributes. Thanks to Sergey Popovich for the original ifname/ifindex patch. commit 4df2019ebfc0f77feb16b6a33dea6d5ac595f55e Author: Ondrej Zajicek Date: Thu Sep 26 17:36:30 2013 +0200 Fixes build issues without BGP. Thanks to Sergey Popovich for the patch. commit f83ce94d5e410d5e5b921121867321c19451896b Author: Ondrej Zajicek Date: Thu Sep 26 17:33:00 2013 +0200 Fixes missing unregister of kernel table handling code. And some minor fixes. Thanks to Sergey Popovich for the patch. commit f515e22924591542a909db0deb8545386aaa576e Author: Ondrej Zajicek Date: Sun Sep 22 19:15:39 2013 +0200 Allows other than IA_PEER addresses on PtP ifaces on BSD. Also fixes a potential problem with link-local dest_addrs for IA_PEER addresses. Thanks to Alexander V. Chernikov for the suggestion. commit 6a8d3f1c1ffbd964e4d11b452c73e1ea70310af3 Author: Ondrej Zajicek Date: Mon Sep 16 23:57:40 2013 +0200 BFD work in progress. Now it compiles and mostly works. commit e550a37206528be39e4751865b46720885fd64ed Author: Ondrej Filip Date: Fri Sep 13 18:55:02 2013 +0200 Fixes problem with OSPF neighbor router ID change. Thanx to Alexander V. Chernikov commit c404f4b968b69a2c5c1975d04abf7474891d5656 Author: Ondrej Filip Date: Wed Sep 11 01:15:34 2013 +0200 OSPF state machine fix - thanx to Alexander V. Chernikov commit 92f8878cbf5d8ad9e9b909a9dcbb2112de54a542 Author: Ondrej Zajicek Date: Tue Sep 10 13:03:58 2013 +0200 Fixes a bug related to multiple IPs and direct protocol. Multiple IPs in the same IP prefix confuse the direct protocol and could cause withdrawal of a valid prefix. Thanks to Dan Rimal for a bugreport. commit 2a0130f94d2304e316f0ffad8e52fce094559782 Author: Ondrej Zajicek Date: Tue Sep 10 13:01:22 2013 +0200 Fixes a bug in kernel extended attribute processing. The bug caused that krt_prefsrc attribute was not processed when a route received from a kernel protocol was exported to another kernel protocol. Thanks to Sergey Popovich for a bugreport. commit 507e182a60c3704f8a28a0450f1affc2c7c1b66a Author: Ondrej Zajicek Date: Tue Sep 10 12:58:24 2013 +0200 Fixes reconfiguration of global set variables. When global set variables were used, every reconfiguration restarted protocols that use it in filters. Thanks to Sergey Popovich for a bugreport. commit d27e127aa996d500fed21be2bbbe888cafecb830 Merge: bff9ce51 b0a8c7fc Author: Ondrej Zajicek Date: Tue Sep 10 12:54:57 2013 +0200 Merge commit 'origin/master' commit bf139664aa2ae9956b520ba4813bb6e03bf1a3e8 Author: Ondrej Zajicek Date: Tue Sep 10 12:09:36 2013 +0200 Initial BFD commit, work in progress. commit b0a8c7fc8547eef21ede33887580b5e867ee742c Author: Ondrej Filip Date: Thu Aug 15 20:26:50 2013 +0200 Wrong change commited - 'route limit' marked as obsolete. commit e628cad0ca9eb7d9bf4141e57201169c46faa661 Author: Ondrej Filip Date: Thu Aug 15 20:20:05 2013 +0200 BGP option 'route limit' is marked as obsolete. 'import limit' should be used instead. commit 6d90e57332e102e261d69a1a05dfaa19fb31d933 Author: Ondrej Filip Date: Thu Aug 15 19:54:18 2013 +0200 Typo in documentation fixed. commit 1f64a487a065cc27c52ab0d3d38b7c82926fea70 Author: Ondrej Filip Date: Thu Aug 15 13:29:33 2013 +0200 Symbol names enclosed by apostrophes can contain colons. commit bff9ce5130d16af2fd802d42bdb2bff00980c9ae Author: Ondrej Zajicek Date: Thu Aug 15 01:06:47 2013 +0200 Extends delete/filter operators to work no bgp_paths. commit 8a112d8ba2e77d79468146ec8f54b3c90b6e68e4 Author: Ondrej Zajicek Date: Tue Aug 13 23:04:06 2013 +0200 Removes strip from make install Thanks to Alexander V. Chernikov for the patch. commit b21955e05800c3ceedfe39eef605da84285296c7 Author: Ondrej Zajicek Date: Tue Aug 13 20:42:43 2013 +0200 Fixes a bug related to mixed up neighbor events in BGP. Neighbor events related to received route next hops got mixed up with sticky neighbor node for an IP of the BGP peer. If a neighbor for a next hop disappears, BGP session is shut down. commit 00192d5ab88ff9eeccbc1bc10cb534976a56963d Author: Ondrej Zajicek Date: Tue Aug 13 20:25:05 2013 +0200 Implements proper setting of 'gw' route attribute. Thanks to Sergey Popovich for the bugreport. commit f8e8fcfabeb206287065f48e800743b0aa797cc2 Author: Ondrej Zajicek Date: Mon Jul 29 13:07:15 2013 +0200 Test commit. commit fd6cbe9053c529df7eac431ff72d3c509ba91ca9 Author: Ondrej Zajicek Date: Mon Jul 29 12:52:38 2013 +0200 Test commit. commit cff430f396b006ef34e756075948dcb6b07fc427 Author: Ondrej Zajicek Date: Mon Jul 29 12:28:03 2013 +0200 Test commit. Also contains minor fixes in doc formatting. commit 50b71c1b96f99ac40e733295daeb03927777b206 Author: Ondrej Filip Date: Sun Jul 28 18:50:40 2013 +0200 Fixed small error in documantation (thanks engels@openit.de). commit 643228bc1cfb6a8f5169ee8ebfe1b75c81cc8543 Author: Ondrej Zajicek Date: Sat Jul 27 00:47:58 2013 +0200 NEWS and version update. commit f4830d8cb801c9124361bcc0c9e33f8f6005c08d Author: Ondrej Zajicek Date: Sat Jul 27 00:38:29 2013 +0200 Documentation update. commit 4ee39ff2ff78f86ce1ec79a77e22120984452549 Author: Ondrej Zajicek Date: Fri Jul 26 11:06:08 2013 +0200 Fixes initial random values for function arguments. Thanks to Javor Kliachev for the bugreport. commit 1103b32e830fbf98d9b3e32c0425b9a589773bf8 Author: Ondrej Zajicek Date: Thu Jul 25 22:33:57 2013 +0200 Allows to define constants of all filter types. commit ac5745134847c044b21c311e5ab11d92d05bacc1 Author: Ondrej Zajicek Date: Thu Jul 25 13:55:24 2013 +0200 Implements RFC 6608 Subcodes for BGP FSM Error. commit 508d936078aecc8fbbb9ca1218104599c4a3cb4a Author: Ondrej Zajicek Date: Thu Jul 25 13:15:32 2013 +0200 Implements eval command and minor CLI cleanups. Implemented eval command can be used to evaluate expressions. The patch also documents echo command and allows to use log classes instead of integer as a mask for echo. commit a0b176e3b2b50d3a30574afa927e0ee8ef65be68 Author: Ondrej Zajicek Date: Wed Jul 24 14:20:46 2013 +0200 Fixes header file name. Thanks to Fritz Grimpen for the patch. commit e1afee279993363ffb4a7005554d0774eb09b764 Author: Ondrej Zajicek Date: Wed Jul 24 14:19:37 2013 +0200 Fixes socket error hook for radv protocol. commit 9135c1f0ca6322bff9648895b5394b97761b4bcb Author: Ondrej Zajicek Date: Wed Jul 24 14:11:12 2013 +0200 Fixes bug in protocol flushing and rtable pruning. When route was propagated to another rtable through a pipe and then the pipe was reconfigured softly in such a way that any subsequent route updates are filtered, then the source protocol shutdown didn't clean up the route in the second rtable which caused stale routes and potential crashes. commit 48b15ef10fede35113af71bd0dbb0b27a5fcb8f5 Author: Ondrej Zajicek Date: Sat Jul 13 01:39:41 2013 +0200 Fixes stuck connection during BGP session shutdown. If TX buffers were full during BGP session shutdown then a protocol waited indefinitely to be able to send notification packet to close the session. commit 354496ace87341428e6005fbc073fbe57b4e6c0e Author: Ondrej Zajicek Date: Thu Jul 11 13:50:44 2013 +0200 Some fixes for TTL security. commit cc31b75a8fd7949533c12db2c3e9d67eeaf46d10 Author: Ondrej Zajicek Date: Tue Jul 9 23:27:10 2013 +0200 Implements 'bgppath ~ int set' filter op. commit c01a94663cc18f53fd741c5d44387eead9ca88af Author: Ondrej Zajicek Date: Sun Jul 7 12:11:42 2013 +0200 Implements multiple routing table support for FreeBSD and OpenBSD. Inspired by the patch from Alexander V. Chernikov. commit c6964c305b425b98aaf0492806a28b578d799d83 Author: Ondrej Zajicek Date: Sat Jun 29 22:55:41 2013 +0200 Makes krt.c much more readable. commit 6ac4f87a2d661c739e55a63577e7bccf696c7abd Author: Ondrej Zajicek Date: Wed Jun 26 14:35:39 2013 +0200 Documentation for TTL security. commit 70e212f913b6ce9d343d6c401b4f1712986a5f8c Author: Ondrej Zajicek Date: Tue Jun 25 15:33:00 2013 +0200 Implements TTL security for OSPF and RIP. Interfaces for OSPF and RIP could be configured to use (and request) TTL 255 for traffic to direct neighbors. Thanks to Simon Dickhoven for the original patch for RIPng. commit ef4a50be10c6dd0abffd957132cd146029c3d79d Author: Ondrej Zajicek Date: Mon Jun 24 16:37:30 2013 +0200 Better packet priority and traffic class handling. Implements support for IPv6 traffic class, sets higher priority for OSPF and RIP outgoing packets by default and allows to configure ToS/DS/TClass IP header field and the local priority of outgoing packets. commit fad04c750ca6906fb095f1b45958dec0ac8e210c Author: Ondrej Zajicek Date: Thu Jun 13 11:27:14 2013 +0200 Fixes problems with kernel routes multiple routing tables. Temporary dummy routes created by a kernel protocol during routing table scan get mixed with real routes propagated from another kernel protocol through a pipe. commit f623ab9875cad2d129f708e95021d3a252930000 Author: Ondrej Zajicek Date: Tue Jun 11 12:12:11 2013 +0200 Implements OSPF stub router option (RFC 3137). Also fixes OSPFv3 routing table calculcation w.r.t. errata 2078 to RFC 5340. commit 924868543c2010f3ef2cfcb7ba6bac5988ab3264 Author: Ondrej Zajicek Date: Tue May 28 10:48:14 2013 +0200 Fixes crash with vlinks. commit 9810d055628877232f811d684567e203381e10dc Author: Ondrej Zajicek Date: Tue May 28 10:44:44 2013 +0200 Fixes problems with routing table scans on some platforms. Negative bit shifts are definitely undefined oprations. commit 9c99d753fd672bd9839715ee325ef01cca993dbf Author: Ondrej Zajicek Date: Thu May 9 11:11:06 2013 +0200 Fixes a problem with BGP neighbors, link-local addresses and locking. Thanks to Fritz Grimpen for the bugfix. commit a2017200c71293d0a28a39d1f250ba38d57f6289 Author: Ondrej Zajicek Date: Mon Apr 29 22:33:50 2013 +0200 NEWS and version update. commit 572c6440432e3138ea622cfb5a4ef7580d77ef4a Author: Ondrej Zajicek Date: Mon Apr 29 22:08:05 2013 +0200 Fixes a crash when mrtdump is enabled and interface goes away. Thanks to Peter Christensen for the bugfix. commit 32622d0ea366406f3afa14bb9edb4855d6979786 Merge: efd6d12b a5e9f3d2 Author: Ondrej Zajicek Date: Tue Apr 23 02:54:13 2013 +0200 Merge branch 'birdcl' commit a5e9f3d26f887deb451a3ea086e52266c117aa0a Author: Ondrej Zajicek Date: Tue Apr 23 02:42:35 2013 +0200 Restructures birdc and birdcl to merge duplicated code. The BIRD client code is restructured that most of the code (including main function) is shared in client.c, while birdc.c and birdcl.c contain just I/O-specific callbacks. This removes all duplicated code from variant-specific files. commit d2c392d44839baaefa48f4a38060be648d3415fb Author: Ondrej Zajicek Date: Fri Apr 19 13:59:08 2013 +0200 Removes unnecessary client subdirectories and updates buildsystem. Renames some files: birdc/client.c -> birdc.c birdcl/client.c -> birdcl.c client_common.c -> common.c commit efd6d12b975441c7e1875a59dd9e0f3db7e958cb Author: Ondrej Zajicek Date: Wed Apr 17 15:09:50 2013 +0200 Adds two new default GCC options. Adds two new default GCC options related to optimizations (-fno-strict-aliasing and -fno-strict-overflow). This should fix some hyperaggressive GCC optimizations. Also updates autoconf option detection. commit 8df02847e8af29863c325b7297e3a2b2ed5f961c Author: Ondrej Zajicek Date: Wed Apr 17 13:06:40 2013 +0200 Fixes a compatibility issue in OSPFv2 PtP links. BIRD used zero netmask in hello packets on all PtP links, not just on unnumbered ones. This patch fixes it and adds option 'ptp netmask' for overriding the default behavior. Thanks to Alexander V. Chernikov for the original patch. commit cd3b02d198093abbbe671f647e4deb2470eb9cf1 Author: Ondrej Zajicek Date: Tue Apr 16 17:53:22 2013 +0200 Allows IP of loopback to be used in automatic router ID selection. Thanks to Alexander V. Chernikov for the patch. commit 8bd9b930c320f09d3b3792b5f991cf702e9d55be Author: Ondrej Zajicek Date: Tue Apr 16 17:40:44 2013 +0200 Fixes a bug in IPv6 BGP next hop processing. BGP next hop attributes with empty link-local IPv6 addresses were not handled properly. Thanks to Sergey Popovich for the bugfix. commit 48bc232f08141d26691237c3d79db587ce16932b Author: Ondrej Zajicek Date: Tue Apr 16 17:27:34 2013 +0200 Implements 'next hop keep' option for BGP. This option allows to keep the received next hop even in cases when the route is sent to an interface with a different subnet. commit 9ff5257357d9975654279db17bbc8525583ba1cc Author: Ondrej Zajicek Date: Tue Apr 16 16:22:31 2013 +0200 Better handling of global addresses as configured NBMA neighbors in OSPFv3. Configured NBMA neighbors in OSPFv3 should be link-local addresses, old behavior was to silently ignore global ones. The patch allows BIRD to accept global ones, but adds a warning and a documentation notice. Thanks to Wilco Baan Hofman for the bugreport. commit 568d9c9faeab70951d8e9bfea521e1b38a9a3d1c Author: Tomas Hlavacek Date: Sat Apr 6 22:07:32 2013 +0200 Fix birdcl async message handling Fix handling of async messafe in the bird light client. The async message may occure at the any moment so we need the client to liste for the message from server when it waits for user input. commit ce1348537455e5482a283f7a4cae734d13dcf34e Author: Tomas Hlavacek Date: Tue Mar 19 18:02:40 2013 +0100 Fix birdcl questionmark handling Fix handling of questionmark handling in the bird light client. The questionmark should display help when it is the last non-blank character on command line. Otherwise the questionmark does not have any special meaning and it could be a part of a pattern. commit 8322ecde124188a9408b54afead4666bb954e5a5 Author: Tomas Hlavacek Date: Sun Feb 24 23:47:22 2013 +0100 Add lightweight client - birdcl Restructure client/ subdir. Add two different flavors of client. The full featured birdc client code is in client/birdc/. The new light client birtcl is in client/birdcl/. Common sources of both clients are directly in client/. Rework on-line auto-completion in client/command.c to conditionally turn off ncurses-specific code. Add lightweight client without libreadline and ncurses dependencies - birdcl. The birdcl lacks support of history, on-line auto-completion and there are different implementations of "more" functionality and help on '?' press. New client operates in canonical terminal mode (apart from "more" display) and therefore all commands have to be executed by a return key including help commands (called by '?' character in the end of the line). Apart from these limitations the interaction style should be the same as for the full client - birdc. Build of birdcl is always on (independent on --enable-client parameter). commit e454916149d4efe66732fdd0388181813cab6ed0 Author: Tomas Hlavacek Date: Wed Jan 23 17:14:53 2013 +0100 Pull out independent routines from client_full.c Pull out routines for interacting with the server and interpreting internal commands which are not dependent on libreadline and ncurses libraries. This is a preparation step for a new lightweight birdc client. commit 5c2c4ea8b1e924fce433094e744c0467da55aaab Author: Tomas Hlavacek Date: Wed Jan 23 15:51:04 2013 +0100 Rename client/client.c to client_full.c Rename client/client.c to client-full.c and change the Makefile accordingly. This is a preparation step for introducing a new lightweight client which should reuse as much code as possible from the old one but it should not depend on external libraries. Signed-off-by: Tomas Hlavacek commit a9fc659b840e13323aa43e92eb8f39ceb19b5ed6 Author: Ondrej Filip Date: Tue Feb 26 14:29:53 2013 +0100 Small typos fixed. commit de41dcd13d6f9d4785c80e6234ac38f2a15f5429 Author: Ondrej Filip Date: Tue Feb 26 14:13:11 2013 +0100 Redundant lines removed. commit e667622a35722ec007137e678f4f70841562e57f Author: Ondrej Filip Date: Mon Feb 25 10:39:46 2013 +0100 Default rounting table for 'show route export/preexport/protocol' is the one related to a respective protocol. commit a9c38203bdcad92f7ac0a8a912241d2acb483f2c Author: Ondrej Filip Date: Sun Feb 24 00:43:08 2013 +0100 Allow 1 sec RIP update. commit 04ddefb357b2b8759be16633f7bb1df49b0405ea Author: Ondrej Filip Date: Fri Feb 22 07:15:27 2013 +0100 Use BIRD's ASSERT instead of assert.h commit 2bf59bf4d3e4fcaff489d3445134e5e2e2af9cf6 Author: Ondrej Filip Date: Thu Feb 21 00:44:59 2013 +0100 Hotfix to solve an issue with delaying timers reported by Aleksey Chudov. commit 9d969be5f2d867704e82bd7d6c8049623d50708f Author: Ondrej Filip Date: Thu Feb 14 23:35:51 2013 +0100 I still believe that 0 == NULL, however this patch will make Santiago happy. :-) commit 4c2abee74e64f64fba61aad6e2b66e3895820003 Author: Ondrej Filip Date: Tue Feb 12 13:15:01 2013 +0100 Allow submitting BIRD commands from UNIX shell even in restricted mode. commit 8c4da7e01ded3f06cbf873e67c5ae1cf70cf280b Author: Ondrej Filip Date: Sun Feb 10 19:17:38 2013 +0100 Symbol names enclosed by apostrophes can contain DOTs. commit 0bc3542ab6e0a96342e35ead8ff1c52f980facc2 Author: Ondrej Filip Date: Sun Feb 10 19:06:56 2013 +0100 Route limits can be disabled - this makes sense for protocol templates commit 155134f3960bc06a18c8c7d9a97181b786d77a3a Author: Ondrej Filip Date: Sun Feb 10 19:04:08 2013 +0100 A few semicolons added to decrease a number of warnings. commit c6a2fe64bed8dc67af0e868052b055aa0f45cdf2 Author: Ondrej Zajicek Date: Sat Feb 9 00:53:04 2013 +0100 Fixes handling of iface routes in static proto during reconfiguration. During reconfiguration, iface routes were installed even when iface was down. commit 36da2857bc911924a250a234f38cf58c3b21f1bc Author: Ondrej Zajicek Date: Fri Feb 8 23:58:27 2013 +0100 Implements router advertisements activated by received routes. The RAdv protocol could be configured to change its behavior based on availability of routes, e.g., do not announce router lifetime when a default route is not available. commit d214ae4fdc1e323f89efb8a80c068fef4a45758f Author: Ondrej Zajicek Date: Sat Jan 12 21:26:42 2013 +0100 Fix missing documentation for one option. commit 13d4dd138d5dc6c884ded280f9244fac707c4f32 Author: Ondrej Zajicek Date: Fri Jan 11 14:53:20 2013 +0100 NEWS update. commit b662290f40ea0fa0b1a1ba283e50e833724f2050 Author: Ondrej Zajicek Date: Thu Jan 10 13:07:33 2013 +0100 Separate import and receive limits. They have different behavior w.r.t. filtered routes that are kept. commit 79b4e12e6032faf6bb1f3feac385bd36ee53019e Author: Ondrej Zajicek Date: Thu Dec 27 12:56:23 2012 +0100 Implements interface masks for choosing router id. Router ID could be automatically determined based of subset of ifaces/addresses specified by 'router id from' option. The patch also does some minor changes related to router ID reconfiguration. Thanks to Alexander V. Chernikov for most of the work. commit a92cf57dd6ba021a495fe7268c86dc8e6aeecbb2 Author: Ondrej Zajicek Date: Wed Dec 26 12:40:48 2012 +0100 Implements undo command and optional timeout for configuration Several new configure command variants: configure undo - undo last reconfiguration configure timeout - configure with scheduled undo if not confirmed in timeout configure confirm - confirm last configuration configure check - just parse and validate config file commit 80a9cadc76101157707aecc0b482ad88ad702fc3 Author: Ondrej Zajicek Date: Tue Nov 27 02:08:04 2012 +0100 Changes static route targets drop/reject to blackhole/unreachable. To be consistent with rest of BIRD and Linux. Old names are also allowed for compatibility. commit b31774eeb01a2f63e4ce4dc83f36ffd17879593e Author: Ondrej Zajicek Date: Tue Nov 27 01:30:09 2012 +0100 Removes some nonsense. commit 3e40f3e795e39f0b92445fd5295382220077c77f Author: Ondrej Zajicek Date: Tue Nov 27 01:25:47 2012 +0100 Fixes setting of route attributes of type router id. commit c93c02088a026b83f452fbd260135ba4c8da7ecf Author: Ondrej Zajicek Date: Fri Nov 16 13:30:54 2012 +0100 NEWS and version update. commit 70577529244d6d920b75d95e797156e05141db30 Author: Ondrej Zajicek Date: Fri Nov 16 13:29:16 2012 +0100 Fixes route tracing w.r.t. kept filtered routes. commit cf3a704b6a2263aba6bb6adb4c2c9dd93b72f470 Author: Ondrej Zajicek Date: Fri Nov 16 02:34:12 2012 +0100 Updates the documentation. commit 6cadbf325bfcf25a04d869778abb443f9e1b6119 Author: Ondrej Zajicek Date: Thu Nov 15 14:08:20 2012 +0100 Change unnamed ptp link description on OSPFv2. Although it is a slight deviation from the standard, it has no ill consequences for OSPFv2 and the change fixes a compatibility issue with some broken implementations. commit 15550957957f3c790f3bec3f6b8721559ea25969 Author: Ondrej Zajicek Date: Thu Nov 15 01:29:01 2012 +0100 Changes 'rejected' to 'filtered' in one of the last patches. commit e16469bc4d182428687a5ef5f2fb4707afa15abd Author: Ondrej Filip Date: Mon Nov 12 13:48:29 2012 +0100 AS# in bgp.agreggator was a signed integer - fixed. commit 227af52fb5be09c841fbd9f86e7bb3992b981a4a Author: Ondrej Zajicek Date: Sat Nov 10 16:18:12 2012 +0100 Fixes OSPF reconfigure w.r.t. downed ifaces. commit a55a90faec5cce09cee65f484e3731207af00335 Author: Ondrej Zajicek Date: Sat Nov 10 14:54:35 2012 +0100 Peer address of stub iface should be announced in OSPF Router LSA. commit cf98be7b6743e45dde9e0458664cc0762bf08867 Author: Ondrej Zajicek Date: Sat Nov 10 14:26:13 2012 +0100 Allows rejected routes to be kept and examined. When 'import keep rejected' protocol option is activated, routes rejected by the import filter are kept in the routing table, but they are hidden and not propagated to other protocols. It is possible to examine them using 'show route rejected'. commit dd4da6f640fb581cbd7d1ca537bf382558492b8e Author: Ondrej Zajicek Date: Wed Oct 31 17:14:35 2012 +0100 Fixes another bug in OSPFv3 vlinks. commit 8249ad9b304ea88b29e3aea76ebe49bb50348aaa Author: Ondrej Zajicek Date: Mon Oct 29 20:39:03 2012 +0100 Fixes sorting in OSPF show state. commit e4404cef0be10e639566986a2f8c1906c9f37de1 Author: Ondrej Zajicek Date: Mon Oct 29 20:29:31 2012 +0100 Fixes several bugs related to OSPFv3 vlinks. commit 0343d066dab077d1391640c53198199b16bef993 Author: Ondrej Zajicek Date: Wed Aug 29 12:42:49 2012 +0200 Fixes a bug in primary IP selection. commit 8ecbaf9c70b802a1200ad37f2bfd4bc64173c5fe Author: Ondrej Zajicek Date: Thu Aug 16 13:09:26 2012 +0200 Fixes a bug with neighbor cache and overlapping IP prefixes. When there are overlapping IP prefixes and one disappears, neighbors associated with it was removed even if there is another covering IP prefix. commit 094d2bdb79e1ffa0a02761fd651aa0f0b6b0c585 Author: Ondrej Zajicek Date: Tue Aug 14 16:25:22 2012 +0200 Implements ADD-PATH extension for BGP. Allows to send and receive multiple routes for one network by one BGP session. Also contains necessary core changes to support this (routing tables accepting several routes for one network from one protocol). It needs some more cleanup before merging to the master branch. commit d760229ab897fa1bf1fd0fe7019cc2431d21a1cc Author: Ondrej Filip Date: Wed Aug 8 14:10:31 2012 +0200 DragonFly support add - thanks to john@marino.st commit 60c412b9368fd7c3b0a8df2200f02140adcb0cf3 Merge: 3fe1d9e4 94e2f1c1 Author: Ondrej Filip Date: Tue Aug 7 11:15:23 2012 +0200 Merge branch 'master' of ssh://git.nic.cz/bird commit 94e2f1c111721d6213ea65cac5c53036e38e3973 Author: Ondrej Zajicek Date: Tue Aug 7 11:06:57 2012 +0200 NEWS and version update. commit c06de722ddf36f3d6aaabfd4ae9d74a3ea72bbf9 Author: Ondrej Zajicek Date: Mon Aug 6 11:09:13 2012 +0200 Some minor fixes. commit 5400c0e7f982757418a0aeb892459b52fbbcffc3 Author: Ondrej Zajicek Date: Mon Aug 6 02:42:24 2012 +0200 Fixes BGP subcode during global shutdown. commit bbcfd5a0485a8df9568d8da0fc524e272e3e7601 Author: Ondrej Zajicek Date: Thu Jul 26 13:59:50 2012 +0200 Fixes default route in OSPF multiple area setting. commit 48cf5e84e6ed17578e4ad43c5ef54d6ff7d825c4 Author: Ondrej Zajicek Date: Tue Jul 24 20:12:14 2012 +0200 Documentation update, commit 0e224d598579626e03d3727d5901ba2d654ac521 Author: Ondrej Zajicek Date: Sun Jul 22 12:35:04 2012 +0200 RDNSS and DNSSL documentation for RAdv. commit 36415e4b1dd769458cced44525ee74d26d15f9c6 Author: Ondrej Zajicek Date: Fri Jul 20 19:56:57 2012 +0200 Allows to redefine master table. commit c4b76d7b19cf48ddbcbe913c22ef7f1e8429f5ea Author: Ondrej Zajicek Date: Wed Jul 18 19:35:30 2012 +0200 Rename sk_new() to avoid name collision with OpenSSL. commit 4be266a9831799dcc2e67e83fc83d9db43828a64 Author: Ondrej Zajicek Date: Wed Jul 18 19:29:33 2012 +0200 Implements wildcard matching in config file include. Also fixes some minor bugs in include. Thanks Kelly Cochran for suggestion and draft patch. commit abced4a91495e27fe86b142bc1967cec53bab3dc Merge: fc06fb62 76170264 Author: Ondrej Zajicek Date: Mon Jul 16 14:44:45 2012 +0200 Merge branch 'rt-accepted' Conflicts: nest/config.Y nest/rt-table.c proto/bgp/bgp.c commit 761702644397886bd3c1be10fd55c01485b7c454 Merge: 26822d8f 553e4054 Author: Ondrej Zajicek Date: Mon Jul 16 10:41:29 2012 +0200 Merge commit 'origin/rt-accepted' into rt-accepted commit 26822d8fe1376b2ffd902a3b5caa47f81a88e74e Author: Ondrej Zajicek Date: Wed Jul 4 21:31:03 2012 +0200 Finalize RA_ACCEPTED handling. commit fc06fb62443c135773ee4c05ed83925cc47b046d Author: Ondrej Zajicek Date: Sat Jul 7 10:40:00 2012 +0200 Implements RDNSS and DNSSL support for RAdv. commit 3fe1d9e4a40663b93b59f5b6f9d61af9dc6a8ae6 Merge: 72b2db8d 95127cbb Author: Ondrej Filip Date: Tue May 15 23:40:37 2012 +0200 Merge branch 'master' of ssh://git.nic.cz/bird commit 95127cbbb76e8870e029454a5313bc4b6ce69a4a Author: Ondrej Zajicek Date: Mon May 14 11:47:41 2012 +0200 Real broadcast mode for OSPFv2. commit 0ec031f7400fbacdd86b40ae1870c58715a7f108 Author: Ondrej Zajicek Date: Fri May 11 18:52:59 2012 +0200 Allows to set instance ID for OSPFv3 interfaces. commit 47c447c42e0bfa1836d951d1e6c1a2236d39dcbb Author: Ondrej Zajicek Date: Fri May 4 23:05:47 2012 +0200 Minor cleanups. commit b7f3df79054aca327654c1fb4739c4ff02e59e6e Author: Ondrej Zajicek Date: Fri May 11 12:01:27 2012 +0200 Fixes a bug in RA_ACCEPTED handling. commit 72b2db8db7534c52e928618410ec1f18787752c8 Merge: 2795700c 95616c82 Author: Ondrej Filip Date: Fri May 11 00:01:29 2012 +0200 Merge branch 'master' of ssh://git.nic.cz/bird commit 95616c820248018f4999972cad315f2da60e4960 Author: Ondrej Zajicek Date: Fri May 4 16:38:25 2012 +0200 Cleanup in sysdep KRT code, part 4. Adding some files that was accidentally removed (instead of moved) in cleanup part 2. commit 064e7be5cd4dffd564b4ea41ba6d843492a55c97 Author: Ondrej Zajicek Date: Fri May 4 00:20:23 2012 +0200 History deduplication in birdc. commit e14bd38087ed8ef1945dd0a3878cc560478145f0 Author: Ondrej Zajicek Date: Thu May 3 14:04:56 2012 +0200 Fixes flushing of device routes. commit ab188fb76d7822350724b182106a19995a73d719 Author: Ondrej Zajicek Date: Thu May 3 12:25:15 2012 +0200 Implements build options to specify socket dir and suffix. commit 2795700c3158fa52b6cf957e9d0b9ad4a27c67a5 Merge: 1f85226e bf422073 Author: Ondrej Filip Date: Wed May 2 11:10:40 2012 +0200 Merge branch 'master' of ssh://git.nic.cz/bird commit 7a2c48dafce9420a23fd57408c31eecfc20c4fe0 Author: Ondrej Zajicek Date: Mon Apr 30 22:34:06 2012 +0200 Cleanup in sysdep KRT code, part 3. Just one more renaming, old krt_set_notify() to krt_replace_rte(). commit f1aceff59bbf942bc11c2e9a4c51e381c06f2b20 Author: Ondrej Zajicek Date: Mon Apr 30 22:21:52 2012 +0200 Cleanup in sysdep KRT code, part 2. Remove support for historic Linux kernels, merge krt-iface, krt-set and krt-scan stub headers. commit 396dfa9042305f62da1f56589c4b98fac57fc2f6 Author: Ondrej Zajicek Date: Mon Apr 30 15:31:32 2012 +0200 Cleanup in sysdep KRT code, part 1. OS-dependent functions renamed to be more consistent, prepared to merge krt-set and krt-scan headers. Name changes: struct krt_if_params -> struct kif_params struct krt_if_status -> struct kif_status struct krt_set/scan_params -> struct krt_params struct krt_set/scan_status -> struct krt_status krt_if_params_same -> kif_sys_reconfigure krt_if_copy_params -> kif_sys_copy_config krt_set/scan_params_same -> krt_sys_reconfigure krt_set/scan_copy_params -> krt_sys_copy_config krt_if_scan -> kif_do_scan krt_set_notify -> krt_do_notify krt_scan_fire -> krt_do_scan krt_if_ -> kif_sys_ krt_scan_ -> krt_sys_ krt_set_ -> krt_sys_ commit 182a78957d60a4c91c1ff8d1ff0f09b1b64b70ba Author: Ondrej Zajicek Date: Sun Apr 29 01:35:52 2012 +0200 Allows some modifications of dest attribute in filters. commit bf42207332e8e502d636038f1ec44aaea6ec50e0 Author: Ondrej Zajicek Date: Sat Apr 28 13:03:48 2012 +0200 Changes keyword 'exceed' to 'action'. commit ab758e4fb205346946f2d828236bd23efc2a419e Author: Ondrej Zajicek Date: Sat Apr 28 12:59:40 2012 +0200 Some fixes in route export limits. commit d494df63ac3061accdff348511a565c021411b28 Author: Ondrej Zajicek Date: Fri Apr 27 00:04:51 2012 +0200 Some minor fixes. commit 1f85226ecb76d3803b8fe37eb0891c45a6557dcd Merge: 92f8f7e3 d9b77cc2 Author: Ondrej Filip Date: Thu Apr 26 17:03:53 2012 +0200 Merge branch 'master' of ssh://git.nic.cz/bird commit d9b77cc28115e5c1ef64c69722c9d1fd1392dcd1 Author: Ondrej Zajicek Date: Tue Apr 24 23:39:57 2012 +0200 Implements generalized export limits. And also fixes some minor bugs in limits. commit 3589546af4baa4d349409a318f8c9658dd11b3cc Merge: 7d0a31de cca97066 Author: Ondrej Zajicek Date: Tue Apr 24 23:37:01 2012 +0200 Merge commit 'origin/master' commit 92f8f7e3a3a5a42768c18c1f3d4d8f9f98150c61 Author: Ondrej Filip Date: Tue Apr 24 16:31:17 2012 +0200 Small bug in detection of class-A networks. commit cca970666a90af02eaeb6848bbfc3d5a2222fa21 Author: Ondrej Filip Date: Sun Apr 22 14:03:07 2012 +0200 Small typo in programmer's documentation. commit 7d0a31deed92971e274aa0314e12619f93c850c9 Author: Ondrej Zajicek Date: Sat Apr 21 21:05:36 2012 +0200 Fixes in generalized import limits. commit 334a0ed24d015e106558cc9eeef301c6f0d21aec Author: Ondrej Zajicek Date: Fri Apr 20 21:04:55 2012 +0200 Fixes missing device attributes when exporting routes to kernel. Thanks to Howden Nick for the bugreport. commit 9b2b502be521b58a736f7b78644e89ee01b4418b Author: Ondrej Zajicek Date: Fri Apr 20 21:04:55 2012 +0200 Fixes missing device attributes when exporting routes to kernel. Thanks to Howden Nick for the bugreport. commit f93e6f338e59e02b0cddea85e7d367948d9cf3f2 Author: Ondrej Filip Date: Thu Apr 19 17:14:16 2012 +0200 Small clean up in debug texts commit 553e4054609e7aa8dcb92849c92a6fea73354f0e Author: Ondrej Filip Date: Thu Apr 19 17:12:13 2012 +0200 Small clean up in debug texts commit ebecb6f6a11bb418dd054cf12a2673ca0d9eac37 Author: Ondrej Zajicek Date: Sun Apr 15 15:28:29 2012 +0200 Implements generalized import hooks. Thanks to Alexander V. Chernikov for the original patch. commit 3e17e380598b9a512bb369f51a4cf55da269f608 Merge: 00a09f3c ae8b3001 Author: Ondrej Zajicek Date: Sun Apr 15 15:17:03 2012 +0200 Merge branch 'master' into rt-accepted commit ae8b300164a975597f9b6caea0b205af2e4db30b Merge: d360f129 ed7c4b0c Author: Ondrej Zajicek Date: Sun Apr 15 15:15:05 2012 +0200 Merge commit 'origin/master' commit d360f129e393298ff3e5309ec06a3baf170784fb Author: Ondrej Zajicek Date: Sun Apr 15 15:13:12 2012 +0200 Fix static protocol w.r.t. some recent changes in protocol ahooks. commit 00a09f3c367e79297f827b52ec5f16842db1ac4e Author: Ondrej Zajicek Date: Sun Apr 15 15:07:58 2012 +0200 Implement RA_ACCEPTED mode of route propagation. commit ed7c4b0cd530126b9a794f817f5d1d93556a1bce Author: Ondrej Filip Date: Mon Apr 9 14:19:28 2012 +0200 Small bugfix in error message related to reconfiguration. commit bf2abe2f515d7b7aaed5fb4f37af82169adcd2f2 Merge: fb829de6 c0adf7e9 Author: Ondrej Zajicek Date: Fri Mar 30 11:04:12 2012 +0200 Merge branch 'soon' Conflicts: nest/proto.c nest/rt-table.c commit fb829de69052755a31d76d73e17525d050e5ff4d Author: Ondrej Zajicek Date: Wed Mar 28 18:40:04 2012 +0200 Fixes responsiveness for protocol shutdown. When a protocol went down, all its routes were flushed in one step, that may block BIRD for too much time. The patch fixes that by limiting maximum number of routes flushed in one step. commit cb3cf95859d81c711337738f004675f43c8bbb0e Merge: c9df01d3 16fc65ac Author: Ondrej Zajicek Date: Sun Mar 25 20:59:13 2012 +0200 Merge commit 'origin/master' commit c9df01d3215379c0463dd2a3b0c9b1700d6e2ac3 Author: Ondrej Zajicek Date: Sun Mar 25 19:44:14 2012 +0200 Fixes several minor bugs in kernel syncer. commit 9ba2798c65c02254ec000ab03a76fbbaae1ddc97 Author: Ondrej Zajicek Date: Fri Mar 23 01:17:02 2012 +0100 Adds krt_metric linux route attribute. commit 72aed1a00ba9e18116d6fd907f7e1a36d0a0a583 Author: Ondrej Zajicek Date: Fri Mar 23 00:26:26 2012 +0100 Adds krt_source route attribute. Thanks Jeremie Dimino for the original patch. commit 16fc65acc536d3788efe4c0554a2f52699fedc7f Author: Ondrej Filip Date: Thu Mar 22 14:52:40 2012 +0100 Minor correction commit 89647357af0d8507652f257f1e8f5679fe9a7078 Author: Ondrej Zajicek Date: Thu Mar 22 12:29:02 2012 +0100 NEWS and version update. commit c47d037ecb5b9c835700b152eed7589409a2e42f Author: Ondrej Zajicek Date: Thu Mar 22 11:46:38 2012 +0100 Some minor changes to CLI. commit df27911880bffb88c1eae90e36c755a3ed3d77ad Author: Ondrej Zajicek Date: Mon Mar 19 13:00:00 2012 +0100 Fixes problem with dirname(). Thanks Henrique de Moraes Holschuh for the original patch. commit af582c4811175d9a27ed5d08a4f6d5eaa69ecec7 Author: Ondrej Zajicek Date: Sun Mar 18 17:32:30 2012 +0100 Route Origin Authorization basics. - ROA tables, which are used as a basic part for RPKI. - Commands for examining and modifying ROA tables. - Filter operators based on ROA tables consistent with RFC 6483. commit fd087589f80a435a42cedb87b917c71363b11860 Author: Ondrej Zajicek Date: Fri Mar 16 13:01:12 2012 +0100 Fixes broken vlinks in OSPF. commit 0f808c066f3b5b190de951db042a34a1eb957a16 Author: Ondrej Zajicek Date: Fri Mar 16 12:47:12 2012 +0100 Adds filtering to 'show symbols' command. Thanks Alexander V. Chernikov for the original patch. commit 20ab192beca749166e19118e987b53b5e131d0cf Author: Ondrej Zajicek Date: Fri Mar 16 12:12:26 2012 +0100 Adds filtering to 'show ospf lsadb' command. Thanks Alexander V. Chernikov for the original patch. commit 0888a737b045b48106edbd28ba3cd62fcc8c191e Author: Ondrej Zajicek Date: Thu Mar 15 20:42:29 2012 +0100 Extends set operations in filters. Allows add/filter/delete clist on clist (set algebra on clists). Allows number ~ bgppath match. commit 9f1500f50a0196f912eeb97e77ccf6873e186c29 Author: Ondrej Zajicek Date: Thu Mar 15 13:45:55 2012 +0100 Adds warning for mismatch MTU in OSPF packets. Thanks Alexander V. Chernikov for the original patch. commit 2f9955b5d508698b04ff41e5e38097acdac416b9 Author: Ondrej Zajicek Date: Thu Mar 15 13:12:00 2012 +0100 Fixes TTL for multicast OSPF packets. Thanks Alexander V. Chernikov for the suggestion. commit 8796a8a56edbcd420de724a58947c7aedadf04de Author: Ondrej Zajicek Date: Thu Mar 15 12:50:49 2012 +0100 Fixes name for unnamed filters. Thanks to Alexander V. Chernikov for the suggestion. commit 7d837aa014a78bce2b329cc9f56e8dc799d456e8 Author: Ondrej Zajicek Date: Thu Mar 15 12:43:47 2012 +0100 Fixes documentation - default pipe mode. Thanks to Benjamin Cama for the bugreport. commit e2bf812f3dc84981eac045b617261987c25b5e90 Author: Ondrej Zajicek Date: Thu Mar 15 12:38:08 2012 +0100 Fixes RIPng compatibility. Also probably breaks compatibility with older BIRDs, but RIPng not really worked here. Thanks to Goesta Smekal for the original patch. commit f761503760fba2d4124cc3352f5260c31fac526d Author: Ondrej Zajicek Date: Thu Mar 15 12:23:49 2012 +0100 Fixes RIPng socket and neighbor handling. RIPng did not really work because of link-local addresses. Thanks to Roman Hoog Antink for some notes. commit 117e3c4bbfd4b7f1b2cae6ef9e5cb603fe33307a Author: Ondrej Zajicek Date: Thu Mar 15 12:18:26 2012 +0100 Fixes a bug in pair set intervals. Pair intervals in form (a,b)..(c,d) were mishanded. Thanks to Alexander Shikoff for the bugreport. commit c0adf7e9fc0bb920175a639c6f56ed7b4190f3e4 Author: Ondrej Zajicek Date: Thu Mar 15 11:58:08 2012 +0100 Better support for multitable protocols. The nest-protocol interaction is changed to better handle multitable protocols. Multitable protocols now declare that by 'multitable' field, which tells nest that a protocol handles things related to proto-rtable interaction (table locking, announce hook adding, reconfiguration of filters) itself. Filters and stats are moved to announce hooks, a protocol could have different filters and stats to different tables. The patch is based on one from Alexander V. Chernikov, thanks. commit 46c1a583a5c1ea81e8d8f372bd7f614506a63938 Author: Ondrej Zajicek Date: Fri Feb 3 11:50:51 2012 +0100 Fixes a bug causing crash during soft reconfiguration of export to kernel proto. commit 39c028e9e9e3acf840051f4271fadd4939fde2af Author: Ondrej Zajicek Date: Tue Jan 24 11:31:00 2012 +0100 Assign default protocol preference via proto_config_new(). The patch from Alexander V. Chernikov. commit 09686693d35bd71187847c95c0967d4125215b97 Author: Ondrej Zajicek Date: Mon Jan 23 03:15:12 2012 +0100 Implements handling of BSD iface arrival/departure notifications. Thanks to Alexander V. Chernikov for original patch. commit 732a0a257d180a95a02587203555b8552b6128ac Author: Ondrej Zajicek Date: Mon Jan 23 01:26:40 2012 +0100 Fixes problems with creating/removing/renaming ifaces on BSD. commit 5c78e0e386d4c770b646cab4a8adc3c87987f50f Author: Ondrej Zajicek Date: Sun Jan 22 11:03:30 2012 +0100 Some more verbose warnings. commit bc092571171d00de8b429fec8ba70c39240d7e91 Author: Ondrej Zajicek Date: Sat Jan 21 22:56:16 2012 +0100 Fixes another minor bug in iface scan. Iface flags are not updated in some cases. commit b573755df426156c22d2a4c65e3f502284820166 Author: Ondrej Zajicek Date: Sat Jan 21 22:41:31 2012 +0100 Fixes a bug in BSD iface scan. if_update() should be called always, because periodic iface scan code removes all not-updated ifaces. commit 544f2e1b36fb9473132f77d9c0f6e97d1495bb24 Author: Ondrej Zajicek Date: Fri Jan 20 18:16:35 2012 +0100 NEWS and version update. commit 3ce17142791b2e1a7f0b8e512b5b74224600056c Author: Ondrej Zajicek Date: Fri Jan 20 16:20:03 2012 +0100 Fixes a new bug in BGP route ordering. commit 2c5ca47ad4d18cae162c2ddf85af2dedb89f00a5 Author: Ondrej Filip Date: Tue Jan 10 13:44:06 2012 +0100 New version 1.3.5 commit 4b3a8ff8c6e34f0486b82a10706f1ee0b688048e Author: root Date: Mon Jan 9 16:57:45 2012 +0100 Extend buffer for netlink messages. commit 2c67a564b368bee94f387ba988e8a2e9a76a04ce Author: Ondrej Zajicek Date: Mon Jan 9 03:32:34 2012 +0100 NEWS and version update. commit 8cf8f820fe66af1755e360ea1c5179483766131d Author: Ondrej Zajicek Date: Mon Jan 9 03:20:52 2012 +0100 Show interface for link-local gw in static protocol. commit d7f469c15c1fd8315061f85b87a19946c3ea4700 Author: Ondrej Zajicek Date: Mon Jan 9 02:40:57 2012 +0100 Some minor fixes. commit 3f58437405f8e37e9c14d83274a6b82ffd9583f8 Author: Ondrej Zajicek Date: Sun Jan 8 16:28:33 2012 +0100 Fix for IPv6 addresses on non-multiaccess ifaces on BSD. Thanks Matthias Schiffer for the patch. commit 53ffbff39f054e1302fb296327b9bb1b4f88226c Author: Ondrej Zajicek Date: Sun Jan 8 15:28:27 2012 +0100 Implements support for link-local addresses in BGP. Thanks Matthias Schiffer for the original patch. commit eb1451a3a0c45a4cc62dd0f1f3c3157ec38e2f8e Author: Ondrej Zajicek Date: Sun Jan 8 15:27:04 2012 +0100 Better support for link-local addresses in IO code. commit a03ede64936d0aee1a760a19dc6194b2fdc9c692 Author: Ondrej Zajicek Date: Tue Jan 3 00:42:25 2012 +0100 Fixes a tricky bug in route filtering. Route attributes was used after rta was freed during copy-on-write in filter code. This causes some random crashes, esp. with multipath routes. commit 69a8259c5e438f949bd58b1a2f8e1d12a49f9216 Author: Ondrej Zajicek Date: Sun Jan 1 12:02:20 2012 +0100 Allows sticky link-local neighbors. Allows using NEF_STICKY neighbors with link-local addresses. This is used for static route nexthops, they can be specified like fe80::1%eth0 . commit c32c3f88f0c8788118ed3701c11a5aea2aaf9356 Author: Ondrej Zajicek Date: Thu Dec 22 13:44:43 2011 +0100 Fixes parsing larger numbers on 64bit platforms. commit be4cd99a3688cef19f66e1c8b8e0506ffc1e13fc Author: Ondrej Zajicek Date: Thu Dec 22 13:20:29 2011 +0100 Implements deterministic MED handling. Thanks to Alexander V. Chernikov for many suggestions. commit cf7f0645316f5df0984467cf7001f5466254eaf3 Author: Ondrej Zajicek Date: Mon Dec 12 00:24:15 2011 +0100 Fixes problem with sticky neighbors and iface address changes. Thanks Matthias Schiffer for the bugreport and the original patch. commit 2779d50a24dc1b7c6b4cf83a17af817c02462855 Author: Ondrej Zajicek Date: Thu Nov 17 21:12:23 2011 +0100 Fixes RAdv proto w.r.t. templates. Thanks Alexander V. Chernikov for this. commit 60fd666b796dfa8ba12b44338754ca73b76da2e8 Author: Ondrej Zajicek Date: Thu Nov 10 09:22:20 2011 +0100 Fixes missing header. commit a7f23f581f5e3efe92ec97dfca7d01c66f31ab04 Author: Ondrej Zajicek Date: Mon Nov 7 00:31:23 2011 +0100 Implements protocol templates. Based on the patch from Alexander V. Chernikov. Extended to support almost all protocols. Uses 'protocol bgp NAME from TEMPLATE { ... }' syntax. commit 74add5df17c386bd109ebea7b1dac04d1651ae51 Author: Ondrej Zajicek Date: Thu Oct 27 13:21:24 2011 +0200 Fixes seqnum generation. Thanks Mohammad Amin Shoaie for notification. commit 78e33c29bbbc6f4dd308cd8ef589ce543c3d8d6e Author: Ondrej Zajicek Date: Wed Oct 26 20:06:36 2011 +0200 Some minor fixes in parser. commit 14a8f396e1d8fc5787041eace8ab026fe5a0896c Author: Ondrej Zajicek Date: Wed Oct 26 13:55:24 2011 +0200 Fixes sockets for IPv4 RIP. Thanks Roman Hoog Antink for a suggestion. commit 00a124e3fc218aa39c634bbda244789f2ea0cd3d Author: Ondrej Zajicek Date: Mon Oct 10 02:33:11 2011 +0200 NEWS and version update. commit 9b7fdfc84a516ede415cd1941e5ff1d6312e83ff Author: Ondrej Zajicek Date: Mon Oct 10 01:01:58 2011 +0200 Fixes for include. commit 1cb97af419ee5bff45049f4d3a85acadbb5b1cb9 Author: Ondrej Zajicek Date: Sun Oct 9 17:01:01 2011 +0200 Extend the error message. commit 9491f9f593c1195039cecd1bb2a502363b58c66d Author: Ondrej Zajicek Date: Thu Oct 6 23:01:23 2011 +0200 Use reserved address blocks for documentation (RFC 5737). commit 32f95476a8d60508ca9d24fe20b09899b72de9d7 Author: Ondrej Zajicek Date: Thu Oct 6 22:48:49 2011 +0200 Signal problems with route installation to kernel tables. commit 35c875f0d1eb7c72e0b0ab8a90eb32cbcbfdac02 Author: Ondrej Zajicek Date: Sat Oct 1 09:57:49 2011 +0200 Fixes some error messages and the NSSA gw lookup. Thanks to Alexander V. Chernikov for the patch. commit 736fd7303cb05e910507edaa9310178a23dbcf1e Author: Ondrej Zajicek Date: Tue Sep 27 13:49:32 2011 +0200 Fixes a bug with multiple function arguments. commit bf6d91dc4edf3d08f0de41f71503159b1713fc9a Author: Ondrej Zajicek Date: Sat Sep 24 11:06:42 2011 +0200 Use undefined scope for undefined IPv6 addresses. commit 4116db182d8d80d26902a8b33f82664bb5770066 Author: Ondrej Zajicek Date: Sat Sep 24 02:21:52 2011 +0200 Implements static recursive routes. commit 4271f2b77ed3862a2356475dc18b0cf5c1086364 Author: Ondrej Filip Date: Sun Sep 18 13:52:50 2011 +0200 Fixed problem during 'configure' with EC commit 55b58d8c1f51942c487cc268bd9e2ca214913377 Author: Ondrej Filip Date: Mon Sep 12 12:13:53 2011 +0200 Removed some completed jobs. commit 1e69379e70da3486a601cab7a41ccf7a5825101d Author: Ondrej Filip Date: Sun Sep 11 21:43:24 2011 +0200 NEWS file updated. commit 48ec367aabaaa5328f4072d237001e245a7363df Author: Ondrej Filip Date: Sun Sep 11 21:21:47 2011 +0200 Configuration can include other files. commit a98995273bd8788cf525f44479026d5ce6b7dd52 Author: Ondrej Zajicek Date: Sun Sep 4 13:23:26 2011 +0200 NEWS and version update. commit cb2b586f00f5e7ef9a902b028fc5bfe117890457 Author: Ondrej Zajicek Date: Sun Sep 4 10:39:10 2011 +0200 NetBSD compile fix. commit 51947659abbf9af861aa7dec36fd1c845fb617ab Author: Ondrej Zajicek Date: Sun Sep 4 00:56:02 2011 +0200 Minor changes in BGP protocol info. Shows neighbor IP and ASN even if protocol is down. commit 6c4df70373fa640a7f068d4e1b563621b67c0d2b Author: Ondrej Zajicek Date: Sat Sep 3 21:59:40 2011 +0200 Fixes possible buffer overflow when printing BGP attributes. Thanks to Alexander V. Chernikov for the patch. commit 2918e61046388821c3d4411c602dc5b28ad59329 Author: Ondrej Zajicek Date: Sat Sep 3 21:31:26 2011 +0200 Fixes for OSPF NSSA handling. commit b1b19433602f2a2ff58cfe2c1858ff883eee7b20 Author: Ondrej Zajicek Date: Tue Aug 16 23:05:35 2011 +0200 The generalized TTL security mechanism (RFC 5082) support. Thanks to Alexander V. Chernikov for the patch. commit a52d52fa91ffcbcea58326fc2de476ce5644256f Author: Ondrej Zajicek Date: Mon Aug 15 20:54:58 2011 +0200 Fixes some missing tabs. They unintentionally disappeared in 1.3.2. commit a209d5d8e1bea2b37a7cddebe1f275da4ebde4e3 Author: Ondrej Zajicek Date: Mon Aug 15 02:06:56 2011 +0200 A minor fix in BSD. commit 8815d846bf77e4231f36b64d8e4ac9a3ec2d1504 Author: Ondrej Zajicek Date: Sun Aug 14 15:53:47 2011 +0200 BGP Extended communities documentation. commit 42a0c05408c4151442e6a0ec1c6889acbcfe9c17 Author: Ondrej Zajicek Date: Fri Aug 12 21:03:43 2011 +0200 BGP Extended communities. commit bde872bba745e5596bdb066df6ef323b7cabcfdd Author: Ondrej Zajicek Date: Mon Aug 8 10:57:54 2011 +0200 The documentation update. commit ed317862c2958303cf541fe63f4ea26d00918a9a Author: Ondrej Zajicek Date: Mon Aug 8 01:45:31 2011 +0200 OSPF NSSA support, inter-area LSA translation. commit aca0e79faa391a2841134dac78a499dfdca68bd9 Author: root Date: Fri Jul 29 14:52:28 2011 +0200 Handles missing macro. commit 14272097df989808790673521f643053f898aa8c Author: Ondrej Zajicek Date: Thu Jul 28 13:50:02 2011 +0200 Fixes crash on BSD. commit 4160a9dd9416ee5afd215750bdd6c6e7a4e7ed1f Author: Ondrej Zajicek Date: Fri Jul 22 20:00:24 2011 +0200 OSPF NSSA translator election. commit 41b612c31be05409e69e7365db82b3d1aefc4ca3 Author: Ondrej Zajicek Date: Wed Jul 20 23:40:20 2011 +0200 OSPF NSSA support, part one. commit 9008579b97239564e1dcac855cf726fa9ab7dabd Author: Ondrej Zajicek Date: Wed Jul 20 23:46:03 2011 +0200 Fixes broken multi-area OSPF. commit c49490f8c096ef1379f08e7d70cc24f0c28b80ef Author: Ondrej Zajicek Date: Fri Jul 8 08:58:50 2011 +0200 NEWS and version update. commit beeda6af44e72e3a20fcd2837b231a04354790fa Author: Ondrej Zajicek Date: Thu Jul 7 17:43:39 2011 +0200 Removes timers for stub interfaces. Also fixes some minor bugs. commit 7d4e923603fdb43b6f017e5ef78e37d0891c699c Author: Ondrej Zajicek Date: Wed Jul 6 03:10:02 2011 +0200 Do not open sockets for stub interfaces. commit f796945f04d8be4e71cdf48d919c2035c0a2551d Author: Ondrej Zajicek Date: Sun Jul 3 23:24:38 2011 +0200 Fixes LSA checksum computation for larger LSAs. commit fdf16eb65872b3bee02fb9e25c80ea32cf59f8e9 Author: Ondrej Zajicek Date: Sun Jul 3 19:43:30 2011 +0200 Prints full community lists during 'show route all'. commit 6370d6f61b30b2390727eee8136e0e575dff609f Author: Ondrej Zajicek Date: Sun Jun 26 22:25:09 2011 +0200 Fix route types in rta_show(). commit e08d2ff08e4cff4bec38878e084fee7666caaaf2 Author: Ondrej Zajicek Date: Sun Jun 26 17:09:24 2011 +0200 Adds filter clist operation. commit 35f8c731ea29bd534c74b2d0de089d5683ebcd8d Author: Ondrej Zajicek Date: Sat Jun 25 14:51:16 2011 +0200 Fixes output of BGP timers in 'show protocols all'. commit d8b5a786d27eed72106f88f893c521e67f1bef06 Author: Ondrej Zajicek Date: Sat Jun 25 11:35:54 2011 +0200 IPV6_CHECKSUM should not be used on ICMPv6 sockets. commit 23fd464447c4d0f0efe7b61ca3128bbb1bc1c21c Author: Ondrej Zajicek Date: Mon Jun 20 20:35:59 2011 +0200 Fixes a bug related to protocol enabling and reconfigure. When a protocol was enabled interactively (but disabled in the config file), then reconfigure in some cases forgets to disable it. commit ae85e28cf410cefe4f6e1cdf92510fbf9cea7ae0 Author: Ondrej Zajicek Date: Mon Jun 20 07:37:55 2011 +0200 Fixes a bug in OSPF causing DoS by an invalid packet. commit 61c96d724464ee067e589b72ca9d10a2f7692901 Author: Ondrej Zajicek Date: Tue May 31 17:27:46 2011 +0200 Fixes bug that causes crash with strange BGP updates. commit 5e9bdac28ec95172b0c31641507f6a2fcd2e95fb Author: Ondrej Zajicek Date: Sat May 21 22:48:08 2011 +0200 Fixes a bug with setting preference during show route cmd. If show route cmd was used with a filter that changed preference, BIRD crashed. commit 1155c79209b6a670d0e1f85b2603363ba1132ae0 Author: Ondrej Zajicek Date: Thu May 19 01:20:00 2011 +0200 Fixes compatibility with Mikrotik. commit b54ad333b3c8b486b059f6c0e1afc8c35b64ebea Author: Ondrej Zajicek Date: Mon May 16 12:39:55 2011 +0200 Documentation update. commit e8b89a610443f32b901801668cbae634e13f3e68 Author: Ondrej Zajicek Date: Sun May 15 16:29:44 2011 +0200 Update and document the privilege restriction. commit 1bc2695744c729804af32d48ce68854cba4de8f7 Author: Ondrej Zajicek Date: Tue May 10 02:42:17 2011 +0200 Allows run with restricted privileges. Adds option -u and -g to specify user and group. When different user (than root) is specified, linux capabilities CAP_NET_* are kept. commit 46bb7e0d176a4dc0a47bb406988f92fb29cceaf4 Merge: b8cc390e b7c48981 Author: Ondrej Zajicek Date: Fri May 6 22:09:44 2011 +0200 Merge commit 'origin/master' commit b8cc390e7ed724a9ad605453227d1e4686f3a11b Author: Ondrej Zajicek Date: Fri May 6 22:00:54 2011 +0200 Fixes several problems in filter syntax. - Fixes several conflicts in the grammar. - Fixes a bug in (a..b, c) pair patterns. - Makes pair patterns orthogonal. - Allows term expressions in pair patterns without additional ( ). - Allows several comma separated values in switch cases. commit b7c48981069f25c01c552519e10aec4ebab1f031 Author: Ondrej Filip Date: Thu May 5 14:14:20 2011 +0200 Compilation was failing without OSPF or RIP protocol - FIXED. commit 409e8a6e21d3df0919fd2e131ba9a58222baee50 Author: Ondrej Zajicek Date: Mon May 2 02:06:03 2011 +0200 NEWS and version update. commit a506476acd4baa212f542b257eb5abba733ba4c5 Author: Ondrej Zajicek Date: Sun May 1 17:16:05 2011 +0200 There may be more IP address records with the same IP. commit 5964569c23829ec93fcf671a2582be01c8aebecf Merge: acc93efd d600909d Author: Ondrej Zajicek Date: Fri Apr 29 19:03:19 2011 +0200 Merge commit 'origin/master' commit acc93efd4c754cc995ee8edf52ce0bc45511062e Author: Ondrej Zajicek Date: Thu Apr 28 00:31:37 2011 +0200 Use constants from /etc/iproute2/rt_* files. commit 73272f04af40484b72451f541a986da996b0da58 Author: Ondrej Zajicek Date: Fri Apr 22 16:13:27 2011 +0200 Adds BGP option related to MED handling. Adds option 'med metric' allows to compare MEDs between routes received from different neighbors. commit d600909da9ef0a4b25052c1bf2de83d4e7628b0e Author: Ondrej Filip Date: Wed Apr 13 13:19:37 2011 +0200 Fixed bug FICORA #503685. commit 71ca77169d5d3e67459e46841b8bdb95accd8c2a Author: Ondrej Zajicek Date: Wed Apr 13 12:32:27 2011 +0200 Adds support for several Linux kernel route attributes. commit 4aef102be1e29d3450e53a20a6b2f96d50527139 Author: Ondrej Zajicek Date: Thu Apr 7 11:31:56 2011 +0200 Fixes KRT sync in BSD. When buffer is too small (because of change between sysctls()), needed is *not* changed. commit 489c308a75b121f286cc8637ead8b2bf7bf896ec Author: Ondrej Zajicek Date: Tue Apr 5 11:41:18 2011 +0200 Minor fixes. commit bf27abd6d4a20448f5b4c80e9aa9258dc8670f62 Merge: 4ef09506 a5b84ab5 Author: Ondrej Zajicek Date: Fri Apr 1 13:56:42 2011 +0200 Merge commit 'origin/master' commit 4ef0950603ffbd515d97359015585b4a7512bc75 Author: Ondrej Zajicek Date: Fri Apr 1 13:54:39 2011 +0200 Fixes a problem with BGP protocols and implicit router IDs. commit d93a43a57d37b7cc5506a823a081d21f515c3820 Author: Ondrej Zajicek Date: Fri Apr 1 12:21:18 2011 +0200 Fix leaked debug message. commit a5b84ab540ff3131938b38ebc82ed8e3ce46f261 Author: Ondrej 'Feela' Filip Date: Thu Mar 31 10:30:58 2011 +0200 NEWS updated. commit eb3786e4ea46ce1abc4ca211346369b36dc17dd7 Author: Ondrej Zajicek Date: Wed Mar 30 02:00:56 2011 +0200 NEWS and version update. (and minor changes in documentation) commit 06fb60c4af38d529d20b662748243b3f4a693c60 Author: Ondrej Zajicek Date: Wed Mar 30 01:09:18 2011 +0200 Fixes some problems in BGP error handling. commit 83696b3913c9f52a3d53db073e1ba0641b60ab07 Author: Ondrej Zajicek Date: Tue Mar 29 02:44:39 2011 +0200 Hide 6to4 route warnings. commit ab164971891c64126097eedca11d2f5586f1d8e7 Author: Ondrej Zajicek Date: Tue Mar 29 01:41:46 2011 +0200 Fixes a nasty bug in OSPF. Sending malformed network prefixes in LSAs causes OSPF to crash just after the LSA is propagated to the other routers. commit 52a43ae3b76f86b697537bc3ad8afdb3b421cf2c Author: Ondrej Zajicek Date: Mon Mar 28 22:46:18 2011 +0200 Minor changes in addresses. Mainly changes IA_UNNUMBERED to IA_PEER and adds IA_HOST. Also do not show broadcast addr in show interfaces. Nobody cares for that. commit c454872f4e81e69a8e9950289ab810fcac3fc922 Author: Ondrej Filip Date: Sun Mar 27 23:27:37 2011 +0200 Avoid using stack. commit 4e712ec3b7cb4678607b2a48a2feaa0658333ab2 Author: Ondrej Filip Date: Sat Mar 26 15:21:35 2011 +0100 Added CZ.NIC copyright. commit 86c038ccae2149645058d4288ff8efb498013522 Author: Ondrej Filip Date: Sat Mar 26 14:38:00 2011 +0100 Documentation about previous commit added. commit 4fc36f394ec0988a18decb2d1916e3cebef18d22 Author: Ondrej Filip Date: Sat Mar 26 14:18:56 2011 +0100 This adds (*,x) functionality. commit d0e9b36d30176a9e18cad6151b20746e1588cdc8 Author: Ondrej Zajicek Date: Wed Mar 23 17:15:11 2011 +0100 Added header file. commit 0aa88530ad3c58a6bdab886cabd9b2a4278486e8 Author: Ondrej Zajicek Date: Wed Mar 23 13:40:46 2011 +0100 Convert && and || to shortcut boolean operators. commit 26d92bb8921ac4e022cdc88bde8fc7bc617f8766 Author: Ondrej Zajicek Date: Wed Mar 23 12:49:53 2011 +0100 A hack to distinguish if..else from else: in case. The old BIRD grammar needs two lookaheads to distinguish if..else from else: in case, which caused the parser to fail on some combinations of both expressions. This patch replaces two tokens 'else' ':' by one token 'else:' to fix that. commit 6bcef22580010aec695fb2b559c7b33ee00261b0 Author: Ondrej Zajicek Date: Sat Mar 19 12:13:59 2011 +0100 Documentation for the router advertisement protocol. commit 8e48831a970a784a979446813191628790d477f1 Author: Ondrej Zajicek Date: Thu Mar 17 15:53:36 2011 +0100 Vastly improved OSPF reconfiguration. Now it can handle a change in iface pattern structure. It can add, remove and reconfigure interfaces, vlinks and areas. commit 93e868c730dc0b1825b2a685e0b066c051b1cb07 Author: Ondrej Zajicek Date: Sun Mar 13 11:33:50 2011 +0100 Implements Router Advertisement protocol. commit 9d67ffb0b4cdfbbf88779ce2b44ba810d1ba85d3 Author: Ondrej Zajicek Date: Sat Jan 8 19:34:12 2011 +0100 Fixes scope for sticky neighbors. commit d32a071da9655c2d05038e721bcf020498263c1e Author: Ondrej Zajicek Date: Sat Jan 8 11:31:12 2011 +0100 Some cleanups in krt_read_ifinfo(). commit dad7ee70c1711b2cbdfd86c615736fe12c0d126a Author: Ondrej Zajicek Date: Sat Jan 8 11:22:38 2011 +0100 Fixes interface names on BSD systems. commit e7b4948cbd3e4cacf4fe0f774b44d1f74029ea6d Author: Ondrej Zajicek Date: Tue Dec 28 01:43:07 2010 +0100 A simplification of the next-hop calculation. Thanks to Joakim Tjernlund for the idea. commit 919f5411c48f509a49400a1293e670f5d5d2bcf1 Author: Ondrej Zajicek Date: Fri Dec 24 18:08:07 2010 +0100 Implements Point-to-MultiPoint interface type for OSPF. commit 39847cda73d8e8536300b74d90d01b6e2f233ef7 Author: Ondrej Zajicek Date: Thu Dec 23 12:24:40 2010 +0100 Add some comments. commit f0160f0e06be883528e5e29edfd509efa14d0c78 Author: Ondrej Zajicek Date: Thu Dec 23 10:25:22 2010 +0100 Fixes a minor memory wasting. commit 8cab377d92b62c028ee7aab49049b7cb6cd53ab9 Author: Ondrej Zajicek Date: Wed Dec 22 23:33:40 2010 +0100 Remove unnecessary check. commit 154e2aeded13f46666a69b7a7241149c43ebc01f Author: Ondrej Zajicek Date: Mon Dec 13 11:17:11 2010 +0100 Fixes string handling in birdc. commit e91f6960bae16314e9429719c2c2321edb484a44 Author: Ondrej Zajicek Date: Tue Dec 7 23:36:48 2010 +0100 Documentation update (multipath). commit 32b4972834352d641f7d2c08a27c18b0babd3790 Author: Ondrej Zajicek Date: Tue Dec 7 23:36:11 2010 +0100 Multipath support for linux kernel protocol. commit 57c574d82a44d10143aba7aaea6d1384d850c079 Author: Ondrej Zajicek Date: Tue Dec 7 23:35:39 2010 +0100 Multipath support for OSPF commit 9852f81064a38d35ff1bd5cc9fab7fc33926c83c Author: Ondrej Zajicek Date: Tue Dec 7 23:34:36 2010 +0100 Multipath support for static protocol. commit 7e95c05d889f22be44aef5051eb07d35a4a8f579 Author: Ondrej Zajicek Date: Tue Dec 7 23:33:55 2010 +0100 Core multipath support. commit 01427d3f2b69a4ae1b616b380d4911a132ec450f Author: Ondrej Zajicek Date: Fri Nov 19 18:03:27 2010 +0100 Remove some runaway debug messages and typos. commit 391931d45686a807d322878d4b3d5c9634e2dbca Author: Ondrej Zajicek Date: Fri Nov 19 13:46:21 2010 +0100 Minor finalizations of link state checks. commit 79f561a173c9ceb824d64aa32d82e43ba62acebc Author: Ondrej Zajicek Date: Sat Nov 13 14:19:55 2010 +0100 Fixes a typo (in OSPF_MAX_PKT_SIZE value). And updates a comment. commit d9e7e1b13d69fa50d1979576c418c579f05463c6 Author: Ondrej Zajicek Date: Sat Nov 13 14:19:23 2010 +0100 Adds support for iface link detection to OSPF. commit fe181e7c63843ad65401cc1e400ae1ac3187122f Author: Ondrej Zajicek Date: Thu Nov 11 12:24:27 2010 +0100 Adds support for iface link check to static protocol. commit f25cb0ef9f6341648513e793a3162b32fc250d2b Author: Ondrej Zajicek Date: Thu Nov 11 10:03:02 2010 +0100 Implements link state detection. Also changes some symbol names (IFF_ADMIN_DOWN -> IFF_SHUTDOWN, IFF_LINK_UP -> IFF_ADMIN_UP). commit 5cdf264f937687aff194574f5fe2badb087337b8 Author: Ondrej Zajicek Date: Wed Nov 10 16:43:11 2010 +0100 Fixes a bug related to implicit backbone on ABR. commit c4443085a198c26a478463429477e7e8a599fa07 Author: Ondrej Zajicek Date: Thu Nov 4 17:25:48 2010 +0100 OSPF tx buffers should have the same size as rx buffers. We should be able to send everything we received. commit d5356072ac18d5b0eb12f14afca6bfbea702dda2 Author: Ondrej Zajicek Date: Thu Nov 4 17:22:43 2010 +0100 Fixes a bug in LSA update of large LSAs. commit d3209d939d4d0d8801432f212edd4302a7d03633 Author: Ondrej Zajicek Date: Wed Nov 3 10:04:46 2010 +0100 Fixes a bug in OSPF. commit fcf5a4f4b3e1a984f65d873e7a5a8c830b1ad9bf Author: Ondrej Zajicek Date: Wed Nov 3 10:02:24 2010 +0100 Change default for BGP IPv6 socket to V6ONLY. Also add a new option 'dual' for the old behavior. commit 5adc02a6f87bda06094ce36eb699884c03760bf5 Author: Ondrej Zajicek Date: Fri Oct 22 11:25:47 2010 +0200 Documentation update. commit ed76033c847939877e4fbfadf06898521aafb740 Author: Ondrej Zajicek Date: Fri Oct 22 08:35:19 2010 +0200 Fixes some typos. commit 938b191b9282b138cbdd30dfc11b78c0467d6380 Author: Ondrej Zajicek Date: Sat Oct 9 01:00:53 2010 +0200 Fixes error handling in ASN expressions. commit 112d71a73f30d26891eda4374bf0f2ab31c5c048 Author: Ondrej Zajicek Date: Fri Oct 8 14:25:53 2010 +0200 Fixes syntactic priority of '.' . Dot in expressions like net.len definitely should have the highhest priority. commit b2b7bbfc690a7ad6a61a8cdf4abe87345057fb2e Author: Ondrej Zajicek Date: Mon Oct 4 19:55:11 2010 +0200 Fixes scope of filter symbols. commit 0d1b3c4c0e3261d1d4261e9aeb9975a01d0ff2f9 Author: Ondrej Zajicek Date: Mon Sep 20 13:01:01 2010 +0200 Changes print-like filter commands to use a log instead of a stderr. And extends the log subsystem to better handle that. commit 2dec1e3471385ea191862c8fe85d76a8e47410de Author: Ondrej Zajicek Date: Wed Sep 15 02:01:23 2010 +0200 Fixes a bug in pair sets. commit a58022a64ee8aa2fc46816020723dfbf4bfd08d9 Author: Ondrej Zajicek Date: Sat Sep 11 20:14:53 2010 +0200 Fixes a bug in community set delete. commit 4ca93a50675489a6a5ef9369c24806cc3cbff45e Author: Ondrej Zajicek Date: Wed Sep 8 12:08:38 2010 +0200 Fixes a one byte buffer overflow. commit 948c865fac85f91dd7463195b190d8f133e0f741 Author: Ondrej Zajicek Date: Fri Sep 3 17:15:02 2010 +0200 Fixes a crash in RIP during reconfigure. commit 3cb6c83f1a2eb563e459ce34d0f4850cc9dd4776 Author: Ondrej Zajicek Date: Fri Sep 3 16:32:00 2010 +0200 Fixes a memory leak in RIP. commit faf58cec4d0c0d3c1fddee6faf2f57a1362477bb Author: Ondrej Zajicek Date: Sun Aug 22 14:43:53 2010 +0200 Fixes a bug in NBMA on an iface with multiple IP addresses. commit ac4a1eedfc515e041877d48fd5f64ee4e3b30532 Author: Ondrej Zajicek Date: Fri Aug 13 14:30:36 2010 +0200 Change default for handling missing link-local addresses on route servers. commit dcc71a7fb7e507acc2e0b417e6c9d1940448908e Author: Ondrej Zajicek Date: Thu Aug 12 10:22:40 2010 +0200 Supports unique local unicast addresses. commit 0ef69b1c4a255360e1fa76dffd7a0cb97ea1e9dc Author: Ondrej Filip Date: Mon Aug 9 14:09:53 2010 +0200 Typo in doc. commit 265d06dcbc138c7373ec7b341fcd628eb87e4c4b Author: Ondrej Zajicek Date: Wed Aug 4 15:27:11 2010 +0200 Fixes IPv6 build. commit 373d3dbe8dfbce21af72618c0f912dd0e23a6f3c Author: Ondrej Zajicek Date: Wed Aug 4 13:53:52 2010 +0200 Fixes build on Sparc. commit 946dc15c928d9a48cdcc857bc80f4fabf9a4e2bf Author: Ondrej Filip Date: Tue Aug 3 17:35:34 2010 +0200 Documentation update and improvement of tests related to expressions in sets. commit e0e8c04a83bbe24cdcf3836ca171ce60db299b1f Author: Ondrej Filip Date: Tue Aug 3 15:23:30 2010 +0200 Small typo in documentation. commit edaec901e12c2f0756ab44f7493e999145d7dff9 Author: Ondrej Filip Date: Tue Aug 3 15:22:29 2010 +0200 Even set of number can be made by expressions. commit 4733b49ed6ec11669061e15680417961d13c7a61 Author: Ondrej Filip Date: Tue Aug 3 15:14:26 2010 +0200 Syntax of sets improved. commit 2c9033afd5ce5e99255d248fb065e94534405da7 Author: Ondrej Zajicek Date: Tue Aug 3 08:26:47 2010 +0200 Do not allow interdependent recursive routes. commit f428631cd6f48c5155bd1b7724e9bb8a545fda12 Author: Ondrej Zajicek Date: Tue Aug 3 01:12:43 2010 +0200 Ignore warning when BGP peer is unreachable. commit b74f45f8a05444dca16f0995c7d201ea592ce299 Author: Ondrej Zajicek Date: Tue Aug 3 00:59:13 2010 +0200 Documentation update. commit ba5e5940aa1f11128c76a3964823bda22e47ab04 Author: Ondrej Zajicek Date: Mon Aug 2 13:11:53 2010 +0200 Adds igp_metric attribute. commit d395fe48553062413a85fd04cda0752f933e70c6 Author: Ondrej Zajicek Date: Sat Jul 31 11:37:30 2010 +0200 Fixes bug in OSPF ext-LSA origination. commit d1e146f2f8da303af7bbe0cec363cc15c58c37fd Author: Ondrej Zajicek Date: Sat Jul 31 01:04:32 2010 +0200 Implements IGP metric comparison for BGP routes. commit ac3ac49a71d4b290cfb28aecafc8ac4a69df7a64 Author: Ondrej Zajicek Date: Wed Jul 28 13:13:34 2010 +0200 Adds route resolvability test. commit 1b180121a90ef98f3adce1a355d48d64c6fc3c4f Author: Ondrej Zajicek Date: Wed Jul 28 11:45:35 2010 +0200 Use link-local addresses in recursive next hops for IPv6 BGP. commit c477f48916d74c2db6156145851f9536ae0a0a6c Author: Ondrej Zajicek Date: Tue Jul 27 18:20:12 2010 +0200 Hostcache should use trie to filter relevant route changes. commit 7f0d245a5e6d2d789e1fce4b5388ea69aba3b428 Author: Ondrej Zajicek Date: Tue Jul 27 17:17:11 2010 +0200 Minor changes in prefix trie. commit f2b76f2c45bb8e7c1f13f6d4924e10f0c6b12778 Author: Ondrej Zajicek Date: Mon Jul 26 16:39:27 2010 +0200 For hostentry cache, replace FIB with a hash table using (IP, dep table) as a key. commit 852b7062e33b9886eb869fac8b9354497c49b126 Author: Ondrej Zajicek Date: Thu Jul 22 15:09:35 2010 +0200 Fixes a buffer overflow in TX code of IPv6 BGP. commit 7873e9828ff7ba7203fd30ffa7d50859d583d4ca Author: Ondrej Zajicek Date: Wed Jul 14 19:03:23 2010 +0200 Fixes the documentation. commit 087cecd0e2db0ec1e630fde67ec560578264bf32 Author: Ondrej Zajicek Date: Tue Jul 13 12:48:23 2010 +0200 Adds some options and documentation related to recursive next hops. commit f038f0a6385d7b81f57254e3c9bf84021a6b040d Author: Ondrej Zajicek Date: Mon Jul 12 21:39:10 2010 +0200 Fixes missing check in reconfiguration. commit 9be9a264137cdd881f339c37d1a1918527924254 Author: Ondrej Zajicek Date: Mon Jul 12 17:39:39 2010 +0200 Implements proper multihop BGP. Also does some incompatible changes to config file syntax, like removing 'via IP' from multihop option. commit cfe34a316e35a209fcd814ccf3523c262e8d4b0a Author: Ondrej Zajicek Date: Mon Jul 5 17:50:19 2010 +0200 Implements hostcache and recursive next hops. Hostcache is a structure for monitoring changes in a routing table that is used for routes with dynamic/recursive next hops. This is needed for proper iBGP next hop handling. commit 824de84d48eff6cbd0c550309fbd0bbf7740cb14 Author: Ondrej Zajicek Date: Wed Jun 2 22:25:39 2010 +0200 Do not start with huge OSPF FIBs. Most OSPF instances don't need 64k FIB fields. This change halves resident memory usage on small OSPF networks. commit acb60628f53ba1fc29d1a554683acdb03f961c6f Author: Ondrej Zajicek Date: Wed Jun 2 22:20:40 2010 +0200 Implements command that shows memory usage. commit 4461b8979143bd13024663622c419646a1db0c85 Author: Ondrej Filip Date: Wed Jun 2 12:11:20 2010 +0200 Minor bug that appears only in debug mode. commit 9ef239946b7298a679a9b155606257738bb52347 Author: Ondrej Zajicek Date: Mon May 31 20:41:40 2010 +0200 NEWS and version update. commit a34b09349e809a6d8f696fb0897c0bfdc3b66159 Author: Ondrej Zajicek Date: Mon May 31 11:35:29 2010 +0200 Disable BGP protocol when cannot open listening socket. commit 9b061f7ea5933f70c200bb3b3a7be5a2e472e805 Author: Ondrej Zajicek Date: Fri May 28 11:16:39 2010 +0200 Minor fixes. commit 691057f03310e712428e19214ae48462d0f258e1 Author: Ondrej Zajicek Date: Wed May 26 16:09:22 2010 +0200 Support loopback/dummy addresses. commit e0a62ad0f8be198bf8afb1f6900f138dfe12d4fb Author: Ondrej Zajicek Date: Wed May 26 12:32:30 2010 +0200 Fixes a bug in duplicit configured stubnets. If there was the same configured stubnet on local and remote router, the remote route always won regardless of its cost. commit 52572e94ec75728c114f47db37aaf220c1af29d6 Author: Ondrej Zajicek Date: Sun May 23 12:34:09 2010 +0200 Check for OSPF seqnum wraparound and handle it. commit ba5c0057ed01fb006b7a6fb1bd8c21f0c9ae12be Author: Ondrej Zajicek Date: Sat May 22 22:47:24 2010 +0200 Extends pair set syntax, matching and deleting against clist. Expressions like (123,*) can be used in pair set literals, clists can be matched against pair sets (community ~ pairset) and pair sets can be used to specify items to delete from clists (community.delete(pairset)). commit 6d04ef8987f6f5483d353d393ef66dae4b887f30 Author: Ondrej Zajicek Date: Fri May 21 16:40:09 2010 +0200 Comment update. commit 87a9abeac976180ade1c7619545e610d743994b5 Author: Ondrej Zajicek Date: Fri May 21 15:17:49 2010 +0200 Fixes interface scan on Linux 2.4.x in IPv6 mode. commit 002b6423188abdd62c5a494069fd299b96863a79 Author: Ondrej Zajicek Date: Fri May 21 11:51:39 2010 +0200 Fixes bug on Linux 2.4.x - kernel sync does not work until restart of kernel protocol. Which was, actually, a bug in timers - on older kernel, monotonic timer is missing and the other implementation started with now == 0, which collides with usage 0 as a special value in timer->expires field. commit c1cefd7bea79201c58c7c0fa8e192be3cc5ed771 Author: Ondrej Zajicek Date: Sun May 16 11:03:59 2010 +0200 Do not remove old static route if it is in new config with different gw. commit 7ff5803becec14da870d3997d78e3963fa5ec6e6 Author: Ondrej Zajicek Date: Sun May 16 10:27:20 2010 +0200 Do not originate summary or external LSA if it already here and not changed. commit 475977242ac5bb9ff8826c2dd8c9a1a180320de2 Author: Ondrej Zajicek Date: Fri May 14 16:54:39 2010 +0200 Handle EPIPE as a common connection close event. commit 0267f49fb2e44525aa2777bcb9900c4bb2db41e1 Author: Ondrej Zajicek Date: Fri May 14 15:24:53 2010 +0200 Do not add community if it is already in clist. commit ee7408c2be2cd514ba6eefc5589e57a6056198dc Author: Ondrej Zajicek Date: Fri May 7 15:54:27 2010 +0200 Fixes a bug in LSA flooding. LSAs are sometimes prematurely removed from LS retransmission lists. commit 54818e9beb6bfcbcb5dcc2b175dca9d174012e6c Author: Ondrej Zajicek Date: Mon May 3 00:10:48 2010 +0200 A minor bugfix in OSPF ext-LSA processing. commit 506fa1a73eab0c6426f68cd7784c6712898b88f3 Author: Ondrej Zajicek Date: Sun May 2 22:41:40 2010 +0200 Merge several fixes suggested by Joakim Tjernlund. commit 6384c7d7aa85d1e593eca30cda48f6677b023cb0 Author: Ondrej Zajicek Date: Sun May 2 19:58:34 2010 +0200 OSPF: most of summary LSA orig./flush logic rewritten. Fixes many bugs in the old code and makes it much cleaner. commit ba321706578de8402d50214a9e79a65835cdd821 Author: Ondrej Zajicek Date: Wed Apr 28 00:39:57 2010 +0200 Better support for /31 networks. commit 48b0814ace2d05f9fef093d9f309bfa186a6f365 Author: Ondrej Zajicek Date: Tue Apr 27 18:29:01 2010 +0200 A fix in OSPFv3 next_hop calculation. commit 96599c957baa9c82bde91d610ce4f519aead05e9 Merge: ba130172 9d1ee138 Author: Ondrej Filip Date: Tue Apr 27 11:28:44 2010 +0200 Merge branch 'master' of ssh://git.nic.cz/projects/bird/GIT/bird commit ba130172549ef2313f713e048083432f74e7d03d Author: Ondrej Filip Date: Tue Apr 27 11:27:54 2010 +0200 Avoid warning if not compiled with pipes. commit 9d1ee1388771a3caa6c23163571a80457adfab2c Author: Ondrej Zajicek Date: Mon Apr 26 19:08:57 2010 +0200 Neighbors on OSPF broadcast networks should be identified by IP address, not RID. Allows simple support for multiple interfaces to the same network. commit 4e5fb4b60c59db3248fd12db2bc6f0424d798122 Author: Ondrej Zajicek Date: Sun Apr 25 20:12:34 2010 +0200 Skip LSA host<->network endianity conversions on big endians. commit c1b51598d49ff737b926bd8ad2e308a5a15ce3a2 Author: Ondrej Zajicek Date: Sun Apr 25 19:13:49 2010 +0200 Implements changes in checksum alg suggested by Joakim Tjernlund. commit 0ea8fb4abe5acad0b8f470bbdc5cc929b6a58ced Author: Ondrej Zajicek Date: Sat Apr 24 15:18:21 2010 +0200 Fixes and enhancements in 'show ospf state' command. Now it shows a distance, option to change showing reachable/all network nodes and better handling of AS-external LSAs in multiple areas. The command 'show ospf topology' was changed to not show stubnets in both OSPFv2 and OSPFv3 (previously it displayed stubnets in OSPFv2). commit 1d44ddf20f3ecef864d4bd20355251839fcd10ee Merge: 3b89a232 6bc414d6 Author: Ondrej Zajicek Date: Wed Apr 21 21:52:10 2010 +0200 Merge commit 'origin/master' into new commit 3b89a2327ba385abf2a8321a5a900faba3765612 Author: Ondrej Zajicek Date: Wed Apr 21 21:50:38 2010 +0200 Fixes several problems in OSPF vlink implementation. commit 6bc414d619e1d8710990e89e5085d18e2d5c544c Author: Ondrej Filip Date: Mon Apr 19 16:10:20 2010 +0200 It seems that prefixes /31 and /127 are valid and used in this strange world. commit 607d991424006c083be63878b6a606e76679e1ce Author: Ondrej Zajicek Date: Wed Apr 14 15:35:08 2010 +0200 Fixes build on newer Linux systems. commit dcc6049444f5e12e0d0fcc4cfbb244c08b4c20b0 Author: Ondrej Zajicek Date: Wed Apr 14 14:46:21 2010 +0200 Fixes IPv6 build on older systems. commit 6e8067609673afef9eb9e786f4e43a73a3b544f0 Author: Ondrej Zajicek Date: Sun Apr 11 12:22:47 2010 +0200 Fixes next hop calculation on NBMA and parallel PTP links. commit 7969ea3b41db05294c78a5e0ec0bd3c29ae8c549 Author: Ondrej Zajicek Date: Sun Apr 11 10:19:54 2010 +0200 Fixes a bug in OSPF on NBMA interfaces. A very tricky bug. OSPF on NBMA interfaces probably never really worked. When a packet was sent to multiple destinations, the checksum was calculated multiple times from a packet with already filled checksum field (from previous calculation). Therefore, many packets were sent with an invalid checksum. commit d759c1a6f834cd8a8a7c264d159b9ceb246aec2a Author: Ondrej Zajicek Date: Fri Apr 9 17:42:39 2010 +0200 NEWS and version update. commit de14a7c7aa9225cbc9f837fac9e332a99a99ed69 Author: Ondrej Zajicek Date: Fri Apr 9 00:56:47 2010 +0200 Ignore routes with next-hop 127.0.0.1 on BSD. commit a9f380fe83187a95ead715e516696024e73f3fb7 Author: Ondrej Zajicek Date: Thu Apr 8 18:41:17 2010 +0200 On BSD, consider unmarked non-device routes as alien. commit 6b5a8649a48d7616efbc798095eee2c10563b4e6 Author: Ondrej Zajicek Date: Thu Apr 8 17:56:56 2010 +0200 Do not export empty community list attribute in BGP. commit 0277cc0baf1439a779f4c3ed8b2a77f29f5cfed7 Author: Ondrej Zajicek Date: Thu Apr 8 17:47:14 2010 +0200 Revert "Fixes behavior of defined() on bgp_community attribute." This reverts commit 74e9331fe0892c4c96b4c4d7db3f14bb7e9d928e. commit 646b24d93249199ee59fdecd685532212b506bda Author: Ondrej Zajicek Date: Wed Apr 7 23:15:56 2010 +0200 Minor changes. commit 44d4ab7a960cf143c43d1645f2985cc9d74e3077 Author: Ondrej Zajicek Date: Wed Apr 7 11:00:36 2010 +0200 Configurable syslog name. Also fixes a bug in syslog initialization. commit b8113a5e92cb19a0910041d5708f4eafeb713b54 Author: Ondrej Zajicek Date: Wed Apr 7 00:19:23 2010 +0200 Implements BGP 'show protocols' info details. commit c429d4a4ba2cc8778634461e8adea33e0f0ae022 Author: Ondrej Zajicek Date: Sun Apr 4 15:41:31 2010 +0200 Restrict export of device routes to the kernel protocol. In usual configuration, such export is already restricted with the aid of the direct protocol but there are some races that can circumvent it. This makes it harder to break kernel device routes. Also adds an option to disable this restriction. commit d2d2b5d2ae43f608d03304d280367b658650138b Author: Ondrej Zajicek Date: Sat Apr 3 12:03:52 2010 +0200 Ignore some kernel messages. commit 44aa101cd0716daf1b9f0d9ca5ec1814386c1e0d Author: Ondrej Zajicek Date: Sat Apr 3 11:42:18 2010 +0200 Fixes related to routes with link-local gw on BSD. commit 46a82e9c2c04c432775c7db5ab5d5cc0301b2a94 Author: Ondrej Zajicek Date: Sat Apr 3 10:45:21 2010 +0200 Fixes missing header. commit e60d55becdd9b2eeb36ac16daedae2ab54d05b0c Author: Ondrej Zajicek Date: Fri Apr 2 19:03:18 2010 +0200 Fixes OSPFv3 route generation for local stub networks. commit e7b09e4ab99fc850480480bbb577ffa36a6c5cd7 Author: Ondrej Zajicek Date: Fri Apr 2 16:11:46 2010 +0200 Use SO_BINDTODEVICE also in Linux/IPv6. commit 97ab4c34986139b2419c563a3de7ddfe41727d07 Author: Ondrej Zajicek Date: Fri Apr 2 11:36:38 2010 +0200 Fixes link-local addresses on BSD. commit bed417288e989c48a1362bb1177f436a2e2f9f4f Author: Ondrej Zajicek Date: Fri Apr 2 11:31:20 2010 +0200 Minor fixes to previous patches. commit 126683feeda03ffb5a4ce23611e59a4598382d49 Author: Ondrej Zajicek Date: Mon Mar 29 19:29:03 2010 +0200 Filter language updates; new route attributes and datatype. - Adds bgp_originator_id and bgp_cluster_list route attributes. - Adds dotted quad filter datatype (for router IDs, used by bgp_originator_id and ospf_router_id route attributes). - Fixes pair ~ pair set matching. - Documentation updates. commit eb0f129fcedcecbee85403095abad8f59b82683c Merge: b1c030b0 48cff379 Author: Ondrej Zajicek Date: Fri Mar 26 18:53:31 2010 +0100 Merge branch 'socket2' into new commit 48cff379a718998cd984d60fb6f8b48cb961c0f1 Author: Ondrej Zajicek Date: Fri Mar 26 16:21:29 2010 +0100 Added some comments. commit af157fa3dbe2bba0674eb7634efd3ade6c89d604 Author: Ondrej Zajicek Date: Fri Mar 26 14:48:01 2010 +0100 Disable multiple OSPF pseudointerfaces on BSD. commit b1c030b0ba59eed6da5271ed592d6b93ed088518 Author: Ondrej Zajicek Date: Wed Mar 24 16:39:18 2010 +0100 Adds autoconf test for -Wno-pointer-sign compliler option. commit 4d9a0d1f02134235bf686caf49af44232590c456 Author: Ondrej Zajicek Date: Wed Mar 24 10:39:14 2010 +0100 Update lastmod in 'ignored' case only for RIP routes. commit 885b3d6127ae2c5c4f17d9dba95ffe67bdf7a688 Author: Ondrej Zajicek Date: Fri Mar 19 19:23:34 2010 +0100 Fixes LLS compatibility. commit 5d53b80770b4927b5a8205ee0e57f80454b0abf5 Author: Ondrej Zajicek Date: Fri Mar 19 18:46:56 2010 +0100 Allow iface pattern matching code to match peer address on ptp links. commit aa4612480424ad2fede0cd4ae4c7a893f61c6c0f Author: Ondrej Zajicek Date: Fri Mar 19 09:41:18 2010 +0100 Clear local variables in filters and functions. Fixes crash when used uninitialized variables. This problem was surprisingly tricky to fix. commit 74e9331fe0892c4c96b4c4d7db3f14bb7e9d928e Author: Ondrej Zajicek Date: Thu Mar 18 00:10:35 2010 +0100 Fixes behavior of defined() on bgp_community attribute. commit 1528d30aebc462a13861d7cdb827e74556f3aa91 Author: Ondrej Zajicek Date: Wed Mar 17 23:17:55 2010 +0100 Fixes unterminated string for atomic_aggr attribute formatting. commit 97e46d28fff1aa27d7d15e113cc3a52ae20934c7 Author: Ondrej Zajicek Date: Wed Mar 17 12:19:22 2010 +0100 Adds check for no protocol and some minor CLI fixes. - Adds check to deny config file with no specified protocol to prevent loading of empty config file. - Moves CLI init before config parse to receive immediate error message when cannot open control socket. - Fixes socket name path check and other error handling in CLI init. commit 4e3bfd9006ba3033a814a392f9bf4bbca060c8a9 Merge: e8da1bd0 cda2dfb7 Author: Ondrej Zajicek Date: Mon Mar 15 00:39:45 2010 +0100 Merge commit 'origin/master' into new commit e8da1bd0b5f83991d37bc7e8364101c3faa78b3b Author: Ondrej Zajicek Date: Mon Mar 15 00:34:44 2010 +0100 Fixes missing cases in filters. commit 0aad2b9292f8e5ff32d048378faf80d2d0bfbb80 Author: Ondrej Zajicek Date: Sun Mar 14 16:36:59 2010 +0100 Temporary OSPF commit - sockets. commit 54305181f6ee3af57dd3d15d53ea2e851b36ed23 Merge: e7b76b97 afa9f66c Author: Ondrej Zajicek Date: Thu Mar 11 18:55:59 2010 +0100 Merge branch 'new' into socket2 commit e7b76b976084006e430543f4b872f624326dbfe6 Author: Ondrej Zajicek Date: Thu Mar 11 18:07:24 2010 +0100 Temoporary OSPF commit - socket changes. commit afa9f66c27e2f96b92059131def53cc7b2497705 Author: Ondrej Zajicek Date: Wed Mar 10 01:04:09 2010 +0100 Adds support for PTP links on BSD. commit cda2dfb7a9e03543eaf407ee26e5046fc589ef29 Author: Ondrej Filip Date: Mon Mar 8 00:05:37 2010 +0100 Arnold from DE-CIX suggested to have this formulation more precise. commit 53434e44a95fe9334f4bdf5e0da987929addffb1 Author: Ondrej Zajicek Date: Sat Feb 27 16:00:07 2010 +0100 Better flushing of interfaces. When device protocol goes down, interfaces should be flushed asynchronously (in the same way like routes from protocols are flushed), when protocol goes to DOWN/HUNGRY. This fixes the problem with static routes staying in kernel routing table after BIRD shutdown. commit 3075824dbd4bb654e98614dfd9992ceec0428beb Author: Ondrej Zajicek Date: Fri Feb 26 14:09:24 2010 +0100 Comparing cluster list length should be later in bgp_rte_better(). commit 212ff335828fbe28311fcbae6154cf2495a44d0e Author: Ondrej Zajicek Date: Fri Feb 26 13:55:22 2010 +0100 Fixes signedness in format route attributes. commit ff2857b03db854f99902766ad842aaa5fa29ec3c Author: Ondrej Zajicek Date: Fri Feb 26 10:55:58 2010 +0100 Many changes in (mainly) kernel syncers. - BSD kernel syncer is now self-conscious and can learn alien routes - important bugfix in BSD kernel syncer (crash after protocol restart) - many minor changes and bugfixes in kernel syncers and neighbor cache - direct protocol does not generate host and link local routes - min_scope check is removed, all routes have SCOPE_UNIVERSE by default - also fixes some remaining compiler warnings commit e81b440f6878605edd19ed62441648ac71260881 Author: Ondrej Zajicek Date: Sun Feb 21 14:34:53 2010 +0100 Fix configure to enable warnings and fix most of them. commit 9e43ccf07b96597ef098955a07383d826938cd2d Merge: e285bd23 89534cda Author: Ondrej Zajicek Date: Sun Feb 21 10:15:49 2010 +0100 Merge commit 'origin/master' into new commit e285bd236e9cd42e3f92db3a35b5ec2d307c7a48 Author: Ondrej Zajicek Date: Sun Feb 21 10:14:41 2010 +0100 Fixes installation (missing /usr/local/var/run). commit e0a45fb42163a6bfdeeee44bd0a6a7461552e10f Author: Ondrej Zajicek Date: Sun Feb 21 09:57:26 2010 +0100 Restricted read-only CLI. Also adds support for executing commands using birdc . commit 89534cdae500cc82d9081088be90013e4121542d Author: Ondrej Filip Date: Sat Feb 20 21:14:02 2010 +0100 'rr client id' is not expression but ID (like router id). commit a68066538fde600941ea43c40d777e14cfac0ee7 Author: Ondrej Filip Date: Sat Feb 20 21:09:40 2010 +0100 Minor typos in configuration example. commit e304fd4bcf5813b581a39078a25a5cf6916b9f29 Author: Ondrej Zajicek Date: Sat Feb 20 00:03:31 2010 +0100 Implements pattern match for 'show protocols' command. And generally consolidates protocol commands. commit dfd48621d1a54f2beb461fe3847fc4b2a535675e Author: Ondrej Zajicek Date: Wed Feb 17 21:53:07 2010 +0100 Replaces the algorithm for building balanced trees. Changes the time complexity of the algorithm from O(n^2) to O(n*log(n)). This speeds up loading of huge DEC-IX config from 128 s to 15 s. It also makes the code significantly simpler. commit 14f6aca48037a0653e6bcfa27a4da48e8f962198 Author: Ondrej Zajicek Date: Wed Feb 17 11:29:48 2010 +0100 Changes right recursion to left in the grammar of the case expression. commit dca75fd7c207f0bfc627cb6b74a484da3b27e05f Author: Ondrej Zajicek Date: Sat Feb 13 12:26:26 2010 +0100 Removes phantom protocol from the pipe design. It seems that by adding one pipe-specific exception to route announcement code and by adding one argument to rt_notify() callback i could completely eliminate the need for the phantom protocol instance and therefore make the code more straightforward. It will also fix some minor bugs (like ignoring debug flag changes from the command line). commit 9db74169be76f658df2207d1ec99eac48fa36f5f Author: Ondrej Zajicek Date: Sat Feb 13 10:44:46 2010 +0100 Fixes protocol statistics for pipes. commit c83876265eeae3591bfe90375503728e633cb807 Author: Ondrej Zajicek Date: Thu Feb 11 22:27:06 2010 +0100 Fixes a tricky bug in the pipe protocol. When uncofiguring the pipe and the peer table, the peer table was unlocked when pipe protocol state changed to down/flushing and not to down/hungry. This leads to the removal of the peer table before the routes from the pipe were flushed. The fix leads to adding some pipe-specific hacks to the nest, but this seems inevitable. commit a2ea1bac601ca79946e2a215dac9427c526cedab Author: Ondrej Zajicek Date: Thu Feb 11 21:19:20 2010 +0100 Moves errno.h include. commit 2af25a971a28ccac05d2385669e8b103c0328f7d Author: Ondrej Zajicek Date: Thu Feb 11 11:12:58 2010 +0100 Fixes a crash caused by missing error hook on BGP listening socket. Error happened when too many BGP connections arrived in one moment (ECONNABORTED). commit 353729f513aa6a1f9e7f66083a0f9d2117fe2be5 Author: Ondrej Zajicek Date: Thu Feb 11 10:23:35 2010 +0100 Temporary OSPF commit - socket changes. commit fa5a99c766dde2a4ac3d44596ff5396a0efd1cc8 Author: Ondrej Filip Date: Wed Feb 10 23:09:23 2010 +0100 NEWS version update. commit 75f8861898d53f43cb23dbba9c776bce223c18c8 Author: Ondrej Zajicek Date: Wed Feb 10 16:18:17 2010 +0100 NEWS and version update. commit fae9be7782a161bdf93c83884d62941a34cbe518 Merge: 7d196668 0efd6462 Author: Ondrej Zajicek Date: Wed Feb 10 14:59:26 2010 +0100 Merge commit 'origin/master' into new commit 7d1966689f3f748d8bfa36eef64ced6a750ecb47 Author: Ondrej Zajicek Date: Wed Feb 10 14:57:16 2010 +0100 RTF_CLONING is removed in FreeBSD 8. commit 0efd646278987df023586d85817a848c2bb39a1d Author: Ondrej Filip Date: Wed Feb 10 12:30:14 2010 +0100 Define symbols as text between ''. commit c27b2449d1f57e780974ed13fbd572a48e2a3602 Author: Ondrej Zajicek Date: Mon Feb 8 16:01:03 2010 +0100 Shows source (Router ID) for OSPF routes and adds such attribute. A sad thing is that we does not have a 'router_id' filter type, so it must be given as decimal number in filters. commit 5a56f27cd00c2cad661aed9b54696699e800883c Author: Ondrej Zajicek Date: Mon Feb 8 12:42:09 2010 +0100 Adds asterisk to the primary route in 'show route' cmd. And also fixes a minor bug. commit aa80826e4af4e6e0a6de5604ab5ce7991f2a8b4e Author: Ondrej Zajicek Date: Sun Feb 7 09:49:34 2010 +0100 Unnumbered OSPF interfaces should be always in the point-to-point mode. commit 76b53a4e207696c535a45f4358a8e047ca936e45 Author: Ondrej Zajicek Date: Sat Feb 6 22:57:51 2010 +0100 Adds some log messages related to configure. Also fixes a bug in the previous patch. commit ebae4770c949de41c64c9efbeaaef44adfb25790 Author: Ondrej Zajicek Date: Sat Feb 6 19:19:09 2010 +0100 Modifies configure to just reload protocols when filters change. Before this change, protocols were restarted in that case. commit c37e78510f2ac4d9bb4c44eddf33352eda72fd0f Author: Ondrej Zajicek Date: Wed Feb 3 00:19:24 2010 +0100 Makes date/time formats configurable. commit 44f26560ec9f108039e6736d6de929f899bf20ea Author: Ondrej Zajicek Date: Tue Feb 2 10:14:21 2010 +0100 Workaround for some broken BGP implementations that skip initial KEEPALIVE. commit 5f47c4c11ed8da3415c4c8c247bf52ab6a48255d Author: Ondrej Zajicek Date: Tue Feb 2 00:03:46 2010 +0100 Changes right-recursion to left-recursion in a filter grammar. Because we don't want to have a limit on a function/filter length. commit 1a7a4e59a22f903a0be791f229e86ab881593851 Merge: 41677025 1960d203 Author: Ondrej Zajicek Date: Thu Jan 28 16:00:16 2010 +0100 Merge commit 'origin/master' into new commit 41677025ee67fcccd34493f9b205037dd68811c9 Author: Ondrej Zajicek Date: Thu Jan 28 15:59:18 2010 +0100 Changes 'ignore communities' to 'interpret communities'. commit 1960d20350c5191b089f0a233d99969a0ff23ef6 Author: Ondrej Filip Date: Wed Jan 27 23:45:36 2010 +0100 Priority for '||' and '&&' fixed. commit 7515dafc006f8b71bc15aa7ed9749c7d4fb00153 Author: Ondrej Filip Date: Wed Jan 27 22:26:45 2010 +0100 Allow multiple || and && statements. commit 6cb8f742f1adf99881334b8ae21c398d98571aa1 Author: Ondrej Zajicek Date: Wed Jan 27 17:22:57 2010 +0100 Better handling of well-known communities. Process well-known communities before the export filter (old behavior is to process these attributes after, which does not allow to send route with such community) and just for routes received from other BGP protocols. Also fixes a bug in next_hop check. commit a3062085827db3115961eacd9d945ac202728174 Author: Ondrej Zajicek Date: Wed Jan 13 14:53:33 2010 +0100 Comment update. commit 974363c172e026b00be5f78ec585dda1e402b6f6 Merge: 99f5fc14 844e0f65 Author: Ondrej Zajicek Date: Fri Jan 8 22:20:09 2010 +0100 Merge commit 'origin/master' into new commit 99f5fc14cd457f71973bc2264566284049ccfb2c Author: Ondrej Zajicek Date: Fri Jan 8 22:19:41 2010 +0100 A partial vlink fix. commit 844e0f65dbab98f71f2a5631277a720613d4d7a5 Merge: 3242ab43 fc33143f Author: Ondrej Filip Date: Fri Jan 8 21:19:03 2010 +0100 Merge branch 'master' of ssh://git.nic.cz/projects/bird/GIT/bird commit 3242ab437f47f34d6734726003d647d0f493a163 Author: Ondrej Filip Date: Fri Jan 8 21:06:06 2010 +0100 Typo in documentation. commit fc33143f02642cc775a704dec37446e0b4343a43 Author: Ondrej Zajicek Date: Fri Jan 8 17:22:51 2010 +0100 A fix for broken multi-area OSPF commit 0741e68750fdda754790b6de7739e06310bdf723 Author: Ondrej Zajicek Date: Fri Jan 8 10:21:51 2010 +0100 Socket table update. commit 538dd2e486c3cc95ffebbdf73c934ddc71d70e09 Author: Ondrej Filip Date: Fri Jan 8 01:14:34 2010 +0100 Cryptographic auth can be used also on virtual links. commit 5f47fd85e341d94e2cbf46801cc14be06fb65dd8 Author: Ondrej Filip Date: Fri Jan 8 01:13:58 2010 +0100 Small typo. commit 6901fd0685f75ad5e95ea252039eec9e8926cd6a Author: Ondrej Filip Date: Thu Jan 7 23:42:11 2010 +0100 More information about vlinks. commit 18722dc98c57af6bfa2d9b967417b65db263e5ca Author: Ondrej Filip Date: Thu Jan 7 23:03:19 2010 +0100 Bugfix in DBG call. commit 3127b81755de4a09475df71072964e292c6994a7 Author: Ondrej Filip Date: Thu Jan 7 22:54:39 2010 +0100 Be a little bit more verbose on virtual links. commit cf0858c2174c6bf0a4f63b914d06a2342c433b09 Author: Ondrej Zajicek Date: Thu Jan 7 22:43:06 2010 +0100 A fix of a previous fix. commit ba39197c11db085c4bc062e45fd9c74f42b41ca0 Author: Ondrej Zajicek Date: Thu Jan 7 22:22:10 2010 +0100 Fixes vlinks for OSPFv2. commit 29bfbae7936beb401d944daf0f0106aa8a92ef50 Author: Ondrej Zajicek Date: Thu Jan 7 16:24:36 2010 +0100 Debugging change leaked to repository. commit 3034b384dd9e6c78e686a294b1f80775fdb3e392 Author: Ondrej Zajicek Date: Thu Jan 7 11:46:11 2010 +0100 A minor fix in OSPF. commit 861f223a531be17d2e3e7abc0246be3057b809a0 Author: Ondrej Zajicek Date: Wed Jan 6 23:20:43 2010 +0100 BSD compatibility fix. commit 0c75411bec2f4e37bfdb4c7162631a22898052c1 Author: Ondrej Zajicek Date: Wed Jan 6 16:57:20 2010 +0100 NEWS, version and documentation update. commit cf31112f0d7618464097f71228f84bd534f1bc0f Author: Ondrej Zajicek Date: Sun Jan 3 12:17:52 2010 +0100 Implements MRTdump feature. commit 610bb3cff05f6d5b09c77724bc97295b809d15e2 Author: Ondrej Zajicek Date: Tue Dec 22 10:49:39 2009 +0100 Show command cleanups. commit 0ad19261bf551ef49a1565e21e384ec749ec16d4 Merge: c4ae5385 67b24e7c Author: Ondrej Zajicek Date: Tue Dec 22 01:34:01 2009 +0100 Merge commit 'origin/master' into new commit 67b24e7c1991de345dcb14173943a28d499f6f85 Author: Ondrej Filip Date: Mon Dec 21 16:29:23 2009 +0100 Wrong switch name in configuration example. commit c4ae53858be1bce6798f31ee2fb46775a607085f Author: Ondrej Zajicek Date: Mon Dec 21 11:53:58 2009 +0100 Change default mode of pipes to transparent. Opaque pipes are obsolete and should disappear in the future. commit fbcb7d5faf419057ccbe2340f3714f8885495c51 Author: Ondrej Zajicek Date: Mon Dec 21 11:50:42 2009 +0100 Change default LOCAL_PREF attribute to 100 (suggested value by RFC 4277). commit ba9a122142a3d42137c129fabaef097702d44801 Merge: 0225ea4e c4199e30 Author: Ondrej Zajicek Date: Sun Dec 20 22:57:44 2009 +0100 Merge branch 'ospf3' into new commit c4199e30313c88c0911060a5b5f3cc181ceedb37 Merge: f2d7da74 ea7ada38 Author: Ondrej Zajicek Date: Sun Dec 20 22:56:09 2009 +0100 Merge branch 'dev' into ospf3 commit 053dc3d81fe6470966bc35a852e791de0c00ee68 Author: Ondrej 'Feela' Filip Date: Sun Dec 20 16:18:22 2009 +0100 Typo corrected. commit ea7ada3809ed672bd9d2f9e5742f42b238cc5389 Author: Ondrej Zajicek Date: Sun Dec 20 14:59:12 2009 +0100 Fixes a new bug in the pipe protocol soft reconfiguration. Also updates route reload for pipes. commit 1a5178587ff63234d1b323fca965acb4a42cb9e2 Author: Ondrej Zajicek Date: Sun Dec 20 12:13:15 2009 +0100 Fixes unnecessary pipe restart during configure. commit 6877ff73a61d1924bc8940f7b646f52f7b34eca0 Author: Ondrej Zajicek Date: Sat Dec 19 18:45:46 2009 +0100 NEWS and version update. commit 0225ea4eddb44bd9dd4f112e512325cbf80134d3 Merge: 43c1cecc f2d7da74 Author: Ondrej Zajicek Date: Tue Dec 15 00:32:13 2009 +0100 Merge branch 'ospf3' into new commit f2d7da742bd683b8eaecb1be8e3b04618171c796 Author: Ondrej Zajicek Date: Tue Dec 15 00:30:07 2009 +0100 Fixes export of routes with link-local gw. commit 43c1ceccb9caf8c4f63f191346c2f33889b4ad22 Author: Ondrej Zajicek Date: Mon Dec 14 23:31:25 2009 +0100 Remove bgp_as4_support variable. commit 13a7395704deeeff2d86910d8bcf9a6f32a7b207 Author: Ondrej Zajicek Date: Mon Dec 14 23:08:48 2009 +0100 Minor doc update. commit f75747073e45c3129568c4936c2f34fa618db41e Author: Ondrej Zajicek Date: Mon Dec 14 21:17:15 2009 +0100 Implements route reload for OSPF. commit 63542845dfb6d2277f93f77ad9ca3ad8bbaddd09 Merge: 34a877cc 8a7fb885 Author: Ondrej Zajicek Date: Mon Dec 14 20:37:32 2009 +0100 Merge branch 'dev' into ospf3 Conflicts: proto/ospf/lsreq.c proto/ospf/lsupd.c proto/ospf/rt.c commit 34a877ccac25d38172716d3d2488449c870cad0b Author: Ondrej Zajicek Date: Mon Dec 14 17:29:33 2009 +0100 Minor updates. commit 8a7fb8858fa87bce6f2f15ee2bbb77704b5fff4e Author: Ondrej Zajicek Date: Mon Dec 14 01:32:37 2009 +0100 Finishes 'route reload' feature. commit 28008482a97c0ac70e648759fe37bad0633ed9f7 Author: Ondrej Zajicek Date: Sat Dec 12 01:35:51 2009 +0100 Minor fixes in OSPF. commit 8a70a13e7e79afa6818b10cf64d4f1ae4cf89e4b Author: Ondrej Zajicek Date: Fri Dec 11 01:20:53 2009 +0100 Implements protocol-specific Router ID for OSPF. And fixes one minor bug. commit be2d38b7e977c1f72ed9cd52f8e3e85130c0aaa1 Author: Ondrej Zajicek Date: Fri Dec 11 00:31:56 2009 +0100 Temporary OSPFv3 commit. commit 9807690b413f3a1d29d064761cc99ed5261cfb58 Author: Ondrej Zajicek Date: Sun Dec 6 22:05:50 2009 +0100 Fixes link-back check. commit b76aeb823446616b746b52b5c8152f4c5a73b242 Author: Ondrej Zajicek Date: Fri Dec 4 22:20:13 2009 +0100 Fixes next hop handling. commit 98955023926734c7ecf79f9b8d004baff5225a78 Author: Ondrej Zajicek Date: Thu Dec 3 23:20:02 2009 +0100 Fixes OSPFv2 build. commit bb3c7c6d22c48cd78b4c5b77a78ff1b92adca053 Author: Ondrej Zajicek Date: Thu Dec 3 18:56:39 2009 +0100 Fixes some log messages. commit 69fbf9a25190e0149dcc31e830e952c586fe2024 Author: Ondrej Zajicek Date: Thu Dec 3 18:25:14 2009 +0100 Minor fix in LSA update. commit a421ec33cb9029899122d0ab63bab0fa268348d2 Author: Ondrej Zajicek Date: Wed Dec 2 22:22:40 2009 +0100 Fixes silly bug. commit 11361a101517c2c87e3d35d2c63cacb3ddb97724 Author: Ondrej Zajicek Date: Wed Dec 2 22:19:47 2009 +0100 Implements route re-feed. This can be used to re-feed routes to protocol after soft change in export filters. commit 11787b8473ae1685d43dad809592fabc64eb8f46 Author: Ondrej Zajicek Date: Wed Dec 2 17:26:16 2009 +0100 Fixes some problems in pipes. For transparent pipes, loop detection works correctly now. Pipes are now more symmetric - in both directions filtering is done in do_rte_announce(). commit e8b29bdc8dc34d4a0358458907a5d8ac29011d28 Author: Ondrej Zajicek Date: Wed Dec 2 14:33:34 2009 +0100 Fixes one missing log message. commit 4b84bd4554b2a9331055bfd8d02a0bab0d10df92 Author: Ondrej Zajicek Date: Sun Nov 29 10:29:33 2009 +0100 Fixes some crashes in OSPFv2. commit e4a810b0ce3d7904e87a210c44c36eda7cba7a3e Author: Ondrej Zajicek Date: Sun Nov 29 10:09:25 2009 +0100 Temporary commit. commit a6250a7d1013442ad4feb0d67128a707f2c6880b Author: Ondrej Zajicek Date: Thu Nov 26 23:23:29 2009 +0100 Fix -p option. commit bf47fe4b2e40ccfcfe6af2d86548d06cdf9739c5 Author: Ondrej Zajicek Date: Thu Nov 26 20:47:59 2009 +0100 Implements BGP route refresh. commit 5e6f568115511e2bcf43c60dfdcbd7a35cb04b93 Merge: 069bfcb5 1f8be1e4 Author: Ondrej Zajicek Date: Tue Nov 24 17:19:23 2009 +0100 Merge commit 'origin/master' into dev commit 069bfcb53cef012c063a27e5af93d620be2917bd Author: Ondrej Zajicek Date: Tue Nov 24 17:15:20 2009 +0100 Fixes serious bug in core related to route filtering. If protocol announces a route, route is accepted by import filter to routing table, and later it announces replacement of that route that is rejected by import filter, old route remains in routing table. commit 717e4c4d8173a8dbae2956f1703ff6d4365a9d34 Author: Ondrej Zajicek Date: Fri Nov 20 09:29:29 2009 +0100 Fixes in the documentation. commit 1f8be1e46f666e79072cc5f800c2dba91788368b Author: Ondrej Filip Date: Thu Nov 19 23:15:58 2009 +0100 Added word 'IPv6' to underline, that this problem was not IPv4 related. commit 6a72a276f6a677a8adec9566867023d76ac7da7e Author: Ondrej Zajicek Date: Thu Nov 19 12:53:55 2009 +0100 New version. commit a4644ed6ab32c098b755bdac03498634b2794409 Author: Ondrej Zajicek Date: Thu Nov 19 11:44:17 2009 +0100 Implement option to exit after config file parsing. commit 3f9b7bfe9ff050430a5886b22a5ab11b5f253048 Author: Ondrej Zajicek Date: Wed Nov 18 20:32:36 2009 +0100 Implements option that controls IPv6 BGP next hops when lladdr is missing. commit 62aa96caa28180f76c8aff0c49dd21128e396153 Author: Ondrej Zajicek Date: Tue Nov 17 15:50:29 2009 +0100 Adds some documentation to the description option. commit e04555c04545278cfe3aeae85d707b1d78e5abeb Author: Ondrej Zajicek Date: Tue Nov 17 15:45:05 2009 +0100 Implement description field of protocol. commit d0e2d6d1e05455cf1ec4e71135edaa659fe96dac Author: Ondrej Zajicek Date: Tue Nov 17 14:17:23 2009 +0100 Show both IPv6 next hop addresses in BGP. commit 3228c72cc030f409914134440a7e55bbcfc9ff6a Author: Ondrej Zajicek Date: Tue Nov 17 11:41:29 2009 +0100 Implements RFC 5004 - prefer older external routes. commit cbf8b08d622695f360bcdd80d61eb4add967749e Author: Ondrej Zajicek Date: Tue Nov 17 10:31:33 2009 +0100 Temporary OSPFv3 devel commit commit 2eece54a04d95f534b935ccac4c3959b25516bd5 Author: Ondrej Zajicek Date: Sun Nov 15 14:24:20 2009 +0100 Fixes bug related to reconfiguration with bgp_path first/last operators. commit 653b4015f137d9590147f8774ec686031696f81c Author: Ondrej Zajicek Date: Fri Nov 13 14:54:43 2009 +0100 After shutdown, BIRD should have exit code 0. commit d3f36e5978e85a926c497e2aa2cbdf319776ebb5 Author: Ondrej Zajicek Date: Fri Nov 13 14:43:29 2009 +0100 Fixes BIRD socket unlink. commit 4ac7c8341c660db654821ed2dc0273645dc19645 Author: Ondrej Zajicek Date: Mon Nov 9 23:22:53 2009 +0100 Use IPv6 checksums in OSPFv3. commit 3f22fa9e74c8643d3e4f7e3a7b4f2aa992ad09f5 Merge: a6bc04d5 b7c0e93e Author: Ondrej Zajicek Date: Mon Nov 9 22:54:39 2009 +0100 Merge branch 'dev' into ospf3 commit b7c0e93ebd40cdc4f6e89067a3e5f7293263c7f9 Merge: 7965e17d f1f1e899 Author: Ondrej Zajicek Date: Mon Nov 2 16:27:17 2009 +0100 Merge commit 'origin/master' into dev commit 7965e17d67e8e2e68d96a8471f4828c0dc0d0b21 Author: Ondrej Zajicek Date: Mon Nov 2 16:25:05 2009 +0100 Fixes build in Debian GNU/kFreeBSD. commit f1f1e899b708e0e2ebaba46444fad650648ccb93 Author: Ondrej 'Feela' Filip Date: Mon Nov 2 15:59:01 2009 +0100 Version 1.1.5 commit a6bc04d59130c49a1dbfadffa4285b11e2ff4939 Author: Ondrej Zajicek Date: Thu Oct 29 23:57:42 2009 +0100 Implements better checks on incoming packets and LSAs in OSPF. commit 9d4d38d1a5d67f5485d2b2fa439c879583dfdcb0 Author: Ondrej Zajicek Date: Wed Oct 28 22:39:24 2009 +0100 Fixes some problems related to link-local routes in KRT interface. commit b5332824ea4108d62cb559205391fd2c530348e4 Author: Ondrej Zajicek Date: Wed Oct 28 20:33:08 2009 +0100 New version. commit e6ff7a08e4e7808e1175c3c3bc830d93c0454b19 Author: Ondrej Zajicek Date: Tue Oct 27 22:25:36 2009 +0100 Replaces local endianity testing macro with the common one. That makes it easier to integrate BIRD to crosscompiling buildsystems. commit 9727681a38d3a7c474892e167c0e5a4e0cfac844 Author: Ondrej Zajicek Date: Sun Oct 25 20:02:28 2009 +0100 Implements proper handling of summary/external LSA IDs. commit bff74c7aa3ce4d407cb18b48c9df7b670c3c7a3d Author: Ondrej Zajicek Date: Tue Oct 20 19:04:28 2009 +0200 Allows importing 'onlink' routes. commit 988992446d3aaaef9c19902d94cd1908a963fd80 Author: Ondrej Zajicek Date: Thu Oct 15 11:57:25 2009 +0200 Implement command to show LSA db. commit b66abe8ef986698caccd08b38a991330f0791075 Author: Ondrej Zajicek Date: Thu Oct 15 00:28:04 2009 +0200 Reimplements 'show ospf state' for OSPFv3 and fixes some bugs. commit 4cdd078453d585ac97a183ea1f3951d85f1b8784 Author: Ondrej Zajicek Date: Mon Oct 12 23:31:42 2009 +0200 Implements protocol-specific router id and updates documentation. commit 52b9b2a1786140c38af03de570b0cc96c835c1d3 Author: Ondrej Zajicek Date: Mon Oct 12 20:44:58 2009 +0200 Rename as_path_get_last/as_path_get_first to be consistent. commit ea89da381fc682155e7d08d6ad3d4ac8aa5fe115 Author: Ondrej Zajicek Date: Sun Oct 11 18:56:16 2009 +0200 Workaround for stupid callback scheduler. There is no reak callback scheduler and previous behavior causes bad things during hard congestion (like BGP hold timeouts). Smart callback scheduler is still missing, but main loop was changed such that it first processes all tx callbacks (which are fast enough) (but max 4* per socket) + rx callbacks for CLI, and in the second phase it processes one rx callback per socket up to four sockets (as rx callback can be slow when there are too many protocols, because route redistribution is done synchronously inside rx callback). If there is event callback ready, second phase is skipped in 90% of iterations (to speed up CLI during congestion). commit 7ea5b00f42bd3d1fdafb0be349e3ebbcdf3ea466 Author: Ondrej Zajicek Date: Thu Oct 8 15:23:24 2009 +0100 First and last accessors to as_paths. commit d82fc18d75e4ebf615657cb5d98f000c728b13e4 Author: Ondrej Zajicek Date: Wed Oct 7 21:10:29 2009 +0100 Implement proper LSA ID generation. commit 43c7a1ffa07dda2a9f37c046e1cd9a75242db2b7 Author: Ondrej Zajicek Date: Wed Sep 30 18:48:38 2009 +0200 New version. commit aa7088fe2646e53b5168f7ea4e5bd098f891951c Author: Ondrej Zajicek Date: Wed Sep 30 16:34:47 2009 +0200 Fixes one previous commit. commit a5bf5f781cf921bd1e092b7f9ae6ccdbf7424428 Author: Ondrej Zajicek Date: Thu Sep 24 23:14:44 2009 +0200 Show bad peer AS number in log in decimal. commit be6e39ebbf7ed107abde6fc1a18e8827ca47a7c1 Author: Ondrej Zajicek Date: Thu Sep 24 22:12:11 2009 +0200 Passive option. commit 2d507e64b7d7029906aac30dbea317795b5339de Author: Ondrej Zajicek Date: Thu Sep 24 19:08:14 2009 +0200 Do not allow gateway routes with NULL iface. commit 54fe0d9230be440d9f627ff7f94a202e6117e1b9 Author: Ondrej Zajicek Date: Fri Sep 18 13:59:04 2009 +0200 Fixes setting of IP addresses to route attributes (NEXT_HOP). commit db96fccb31bc0436ec182ff825f592d6c16dc930 Author: Ondrej Zajicek Date: Fri Sep 18 01:11:09 2009 +0200 Fixes bug in filter rta copy-on-write. Filters should try to copy-on-write just cached rtas. commit 46eb80d5d50a2b284cae19444149d57d857a8e02 Author: Ondrej Zajicek Date: Thu Sep 17 17:52:36 2009 +0200 Fixes headers for uintptr_t (and build on NetBSD). commit f4c6ca8c9c7ca7c0d481e6059396beed6adc768d Author: Ondrej Zajicek Date: Thu Sep 17 13:35:37 2009 +0200 Fixes preference bounds. commit 0781e9c62cd34175eb4e3bc61ffe785d08538727 Author: Ondrej Zajicek Date: Thu Sep 17 12:40:02 2009 +0200 Fixes preference in transparent pipes. commit 9f0ba7b1c7a0754c473b8ab202f572c9c8363285 Author: Ondrej Zajicek Date: Thu Sep 17 12:18:03 2009 +0200 Implements proper RID handling in OSPFv3. commit 5eb4d0180ed92cee31d962fbc4d0175a7e1d5933 Author: Ondrej Filip Date: Fri Sep 11 12:20:30 2009 +0200 New release 1.1.3 commit c15e569065e80f91b4c9c77b86640aac72aa0a47 Author: Ondrej Zajicek Date: Tue Sep 8 17:06:47 2009 +0200 Make endianity swapping simpler. commit be862406627da3bd1facea9309b3f32e67422eab Author: Ondrej Zajicek Date: Tue Sep 8 13:45:02 2009 +0200 Temporary OSPFv3 development commit. Finally, it is working. commit 29bcd04e75a4d145bee500b8aef79052974b1981 Author: Ondrej Filip Date: Sun Sep 6 21:26:46 2009 +0200 Update of config.sub & config.guess commit daeeb8e982a3463f4a866e805b64f214d9f44160 Author: Ondrej Zajicek Date: Fri Sep 4 11:24:08 2009 +0200 Clear memory allocated by ralloc(). This also fixes bug that timer->recurrent was not cleared in tm_new() and unexpected recurrence of startup timer in BGP confused state machine and caused crash. commit f9c799a00e705b1420b214628c2bb2a30bf491d9 Author: Ondrej Zajicek Date: Fri Sep 4 11:06:51 2009 +0200 Temporary OSPFv3 development commit (changing multicast support). commit d2ceaf4ec82837239a35ace00399ce3aa845849e Author: Ondrej Zajicek Date: Fri Aug 28 13:45:43 2009 +0200 Temporary OSPFv3 development commit commit 05198c12f48c9d4a65ee6d1d4117bd8067a71131 Author: Ondrej Zajicek Date: Thu Aug 27 19:01:04 2009 +0200 Some cleanups. commit 061ab802a67cfc336785f6daeecdcbd4910734ed Author: Ondrej Zajicek Date: Thu Aug 27 18:25:46 2009 +0200 Temporary OSPFv3 development commit commit 949bd34e81ee99370decdabefa51c9c11ffe915b Author: Ondrej Zajicek Date: Tue Aug 25 19:01:37 2009 +0200 Fixes bug related to AS2->AS4 conversion. commit b49e6f5a65d437cb7e7bdefe8397e0f550496012 Author: Ondrej Zajicek Date: Tue Aug 25 16:42:14 2009 +0200 Temporary OSPFv3 development commit commit a0c405501fa6a0df8472f1598256e725cec753fd Author: Ondrej Filip Date: Sun Aug 23 23:04:59 2009 +0200 Version 1.1.2 commit d2f8d0a509d96d752c86f8807e7f6644467e5af5 Author: Ondrej Filip Date: Sun Aug 23 23:03:31 2009 +0200 Version 1.1.2 commit 2ef58837dcb7b78edc193bc9ef1da316bba86998 Merge: 86975e58 5516a66d Author: Ondrej Zajicek Date: Fri Aug 21 09:46:49 2009 +0200 Merge commit 'origin/master' into dev commit 86975e584eeabbc4f3111f2d100f05ca00579d31 Author: Ondrej Zajicek Date: Fri Aug 21 09:43:31 2009 +0200 Allow more kernel routing tables in IPv6. commit fee78355b480294f28c3c6814953297dca92d4a0 Author: Ondrej Zajicek Date: Fri Aug 21 09:31:35 2009 +0200 Fixes bug in eattr binary search. commit c3226991a061415fa83b757cbff678111c586e58 Author: Ondrej Zajicek Date: Fri Aug 21 09:27:52 2009 +0200 Temporary OSPFv3 development commit commit 5516a66d492497ba8776212defb3117ed1dbfbf8 Author: Ondrej Filip Date: Sun Aug 16 22:41:07 2009 +0200 Ondrej Zajicek add to the team. commit 87d7fd9725ded186f6fa331d68a1e9df5d1982cf Author: Ondrej Filip Date: Sun Aug 16 22:36:41 2009 +0200 Bugfix - each protocol can be compiled separately. commit c5be5a163c2a7b640cb3d0942de44ec87de0f25b Author: Ondrej Zajicek Date: Wed Aug 12 10:26:42 2009 +0200 NEWS and version update. commit 9c46ad8e2fba592d28d19757d39bc090fc5b0d47 Author: Ondrej Zajicek Date: Wed Aug 12 10:16:32 2009 +0200 Count number of lines (and not messages) in 'more'. commit c0973621bc1e06cb6176dc2dfd97bec637861edd Author: Ondrej Zajicek Date: Tue Aug 11 15:49:56 2009 +0200 Fixes another bug in rte_recalculate(). Previous bugfix revealed another hidden bug here. commit ac07aacd2cdb5cf69a3bfdbc0e078cb0ae96c0db Author: Ondrej Zajicek Date: Tue Aug 11 11:03:37 2009 +0200 Replace assert with log. Although it is true unless there is a bug in BIRD, this assert is not needed (code below does not require that assumption), so we should not crash. commit 024e633c16cf21ae94d7e023e057e59080f92175 Author: Ondrej Zajicek Date: Tue Aug 11 10:54:50 2009 +0200 Fixes bug that caused losing of some routes. When update changes preferred route in such a way that it ceased to be preferred, the new route was linked to wrong place and lost. commit e75d3c74a8f665a6e7dc0cc743a68e980e7c10da Author: Ondrej Zajicek Date: Mon Aug 10 14:36:30 2009 +0200 Flex does not need the output of Bison. commit ea9097eaad7dfccd5a88480d748781d947b25cc8 Author: Ondrej Zajicek Date: Mon Aug 10 14:13:28 2009 +0200 Fixes parallel runs of Bison. Previous version of Makefile executed Bison two times (in parallel), because of two specified targets. I am not sure wheter this is the best fix. Previon commit f2cfc509960741bd587cf92f7d154d06fbb2c9a4 Author: Ondrej Zajicek Date: Mon Aug 10 13:59:56 2009 +0200 Compilation and dependency generation should be serialized. commit 581b59907ca5b79b44cc0654e57c34ab77883a96 Author: Ondrej Zajicek Date: Mon Aug 10 13:57:08 2009 +0200 Clean files generated by Bison and Flex. commit 5b1f877e6edfb3b541d444ae5b1ffd025dd9fbd6 Author: Ondrej Zajicek Date: Mon Aug 10 12:04:25 2009 +0200 Fixes typo in Makefile commit b92c8e30191dd757c76239076eda82d0065f2348 Merge: 54d70d3e 71a9574a Author: Ondrej Zajicek Date: Mon Aug 10 10:16:00 2009 +0200 Merge branch 'master' into dev commit 71a9574a515613cded23b20f260a88784bcd4286 Author: Ondrej Filip Date: Sun Aug 9 19:43:42 2009 +0200 Makefile changed to make it work with 'make -jN' where N>1 commit 0ac39033c7470f7301bb108f8e777c7ce6af273f Author: Ondrej Filip Date: Sun Aug 9 19:43:15 2009 +0200 Missing dependency added. commit 0d328932be54a6756c6b43b0cd6d8d314a5b7fe2 Author: Ondrej Filip Date: Thu Jul 30 18:39:41 2009 +0200 Symbols PASSWORDS and BROADCAST not declared for OSPF commit 54d70d3ebb20c36f483cde9d7d5b877772d4884e Author: Ondrej Zajicek Date: Thu Jul 23 22:21:17 2009 +0200 Fixes compiler warning in OFFSETOF(). commit 3aab39f589c352e30e9db92346b579dd561482b3 Author: Ondrej Zajicek Date: Thu Jul 23 16:51:28 2009 +0200 Use %R in OSPF when appropriate. commit 2f6483cd312ffd7ef055099ce801fb8f437d9abe Author: Ondrej Zajicek Date: Thu Jul 23 16:06:25 2009 +0200 Adds %R printf directive for Router ID. commit f0333f44a5a4bec9f3978a90cf7eda1b0a2ec151 Author: Ondrej Zajicek Date: Wed Jul 15 01:47:29 2009 +0200 Implements 'more' feature to birdc. Also does some code restructuring. commit 6baef17ecf1ed994cfc8038bc610e8b7ff88506a Author: Ondrej Zajicek Date: Tue Jul 14 14:18:54 2009 +0200 Fixes bug in CLI TX buffer management. commit 70670bf317a612a1700ffbd0dbc8d92614e0caf2 Author: Ondrej Zajicek Date: Thu Jul 9 15:42:39 2009 +0200 Fixed bug related to reconfiguration of BGP with MD5 passwords. commit dd7b4a13848f5a92b403a563e8e27a3cbdfc937f Merge: d1abbeac bffd4c0b Author: Ondrej Zajicek Date: Mon Jul 6 23:10:33 2009 +0200 Merge branch 'master' into dev commit d1abbeacfb5a099418f53b583625ac97b1c62059 Author: Ondrej Zajicek Date: Mon Jul 6 19:07:01 2009 +0200 Fixes memory alignment problems on Sparc64. Not quite standard construction, i should add some autoconf macro. Not tested yet. commit 2389c46fe314867f99bbdfa1f6c9ff92d433d754 Author: Ondrej Zajicek Date: Sun Jul 5 21:18:55 2009 +0200 Another pile of ipa_from_u32() calls. commit b082c1bfcc53b10012a427aa3b4b8281fe2f496c Author: Ondrej Zajicek Date: Sun Jul 5 20:26:51 2009 +0200 Fixes OSPF on big-endians. Hmm, #ifdef is not very typo-safe. commit f9bdcad4694cf80690982dfc58d28f91216c8bd0 Author: Ondrej Zajicek Date: Sun Jul 5 19:01:54 2009 +0200 Fixes type mismatch in OSPF printf statements. Mixing ip_addr and u32 does bad things on Ultrasparc. Although both have the same size. Fascinating. It was not catched by compiler because of varargs. commit bffd4c0b3900b28cfa84131752d44277866cb413 Author: Ondrej Filip Date: Sun Jun 28 10:03:24 2009 +0200 Small typos. commit f1684ae6c05a52e1757c709dfbbedb5fc8ae1e07 Author: Ondrej Filip Date: Sun Jun 28 09:43:29 2009 +0200 New release 1.1.0! commit ef86b8465ff7d8e81038f37103594eb9c66d9c58 Author: Ondrej Filip Date: Sat Jun 27 18:56:26 2009 +0200 Unused file removed. commit 2d785e8d6a646a878c970583aa54a15209fa0e6e Author: Ondrej Zajicek Date: Fri Jun 26 13:33:41 2009 +0200 Fixes bug on TCP passive socket binding on BSD. BGP on BSD was bound to random port. I am surprised that nobody noticed it already. commit 5004d02cb9df1f3ee231632a8e89929f4eb4f088 Merge: 1876e18d 99355da1 Author: Ondrej Zajicek Date: Fri Jun 26 01:06:12 2009 +0200 Merge branch 'master' into dev commit 1876e18d32fa4b21888aae2c984b1b61338c3e60 Author: Ondrej Zajicek Date: Thu Jun 25 15:44:43 2009 +0200 Minor bugfix. commit 200ede8226a4173b2405bcd1c98cf20604c33545 Author: Ondrej Zajicek Date: Thu Jun 25 14:42:25 2009 +0200 NEWS and version update. commit d72cdff411d0bf4ddecaea5d0fc6d4341b4cb3f1 Author: Ondrej Zajicek Date: Tue Jun 23 11:08:30 2009 +0200 Replace 'bind' option with 'listen' option. To be consistent with other daemons. commit da95a7a7dad6ebf572adfb448dfc1a5c8400e6ab Author: Ondrej Zajicek Date: Tue Jun 23 11:00:38 2009 +0200 Fixes bug in ORIGIN check. commit 29c430f8569b90e1962d92a26f96fad7e72d27ec Author: Ondrej Zajicek Date: Tue Jun 23 10:50:57 2009 +0200 Changes handling of AS_PATH_CONFED_* segments in AS_PATH. Although standard says that if we receive AS_PATH_CONFED_* (and we are not a part of a confederation) segment, we should drop session, nobody does that and it is unwise to do that. Now we drop session just in case that peer ASN is in AS_PATH_CONFED_* segment (to detect peer that considers BIRD as a part of its confederation). commit 4323099da9e6e8d53072595009731da9b39e9f19 Author: Ondrej Zajicek Date: Sat Jun 20 00:59:32 2009 +0200 Fixes bug in scheduling of callback by main loop. If other side of a socket is sending data faster than BIRD is processing, BIRD does not schedule any other callbacks (events, timers, rx/tx callbacks). commit 2757985709f0a132427d4f440ec913b6a0064f80 Author: Ondrej Zajicek Date: Sat Jun 20 00:40:21 2009 +0200 Documentation update commit bf1aec970e9ac0600266fe7a045847a62f18ac3b Author: Ondrej Zajicek Date: Fri Jun 19 23:49:34 2009 +0200 Adds support for soft reconfiguration. commit 789772ed4586213d6a7fbb867b9296a01ce1b9c0 Author: Ondrej Zajicek Date: Thu Jun 18 19:20:07 2009 +0200 Implements option that changes BGP listening socket parametres. commit 1b3b3e34ecbc281a13d4ca0b99e891ee9c4d5cac Author: Ondrej Zajicek Date: Thu Jun 18 14:32:44 2009 +0200 Minor bugfixes. commit 6f5603badc12dbbf440e8f85b1165cc8f5d671c7 Author: Ondrej Zajicek Date: Thu Jun 11 20:51:13 2009 +0200 Documentation update. commit 386752028143e78d0a617216d86f95af4024346d Author: Ondrej Zajicek Date: Thu Jun 11 17:25:38 2009 +0200 Implements an option that allows to change a set of stub networks. commit 3d15dcdb1cc91c694aa9319b86bb37510d7ed12b Author: Ondrej Zajicek Date: Wed Jun 10 23:45:08 2009 +0200 Changes OSPF to generate stub networks for non-primary addresses. Also does some reorganization in RT LSA announcement. commit b99d378698641b9821e4b708a90761aeb9bf6cc4 Author: Ondrej Zajicek Date: Sun Jun 7 00:38:38 2009 +0200 Minor BGP changes related to error wait time. commit 723826267101cfbb918125f0f270166cd309229d Author: Ondrej Zajicek Date: Sat Jun 6 18:56:33 2009 +0200 Fixes bug related to startup delay change. commit dd91e467657b2dba84df308d0dc74d268bbfa228 Author: Ondrej Zajicek Date: Sat Jun 6 18:16:22 2009 +0200 Differentiate between error delay and connect/reconnect delay. The difference is here to reject incoming connections in the first case. commit 2a04b045e480bbf75229f0177abbd7f84d3b7089 Author: Ondrej Zajicek Date: Thu Jun 4 13:38:18 2009 +0200 Adds route limit documentation. commit 72b28a041df18f0da2e6a85360d6935c6a2db471 Author: Ondrej Zajicek Date: Thu Jun 4 13:31:09 2009 +0200 Implements import route limits. commit 925fe2d3de0e12c644f91f94d13bf388aeda9b57 Author: Ondrej Zajicek Date: Thu Jun 4 01:22:56 2009 +0200 Implements route statistics and fixes some minor bugs. commit 99355da18f8598e93d0e55167582da9687eae082 Author: Ondrej Filip Date: Tue Jun 2 12:01:24 2009 +0200 Inlude DESTDIR in install to make life of packagers easier. commit 26978ec419217fccfbb8901033703ede886e78b7 Author: Ondrej Filip Date: Tue Jun 2 11:36:07 2009 +0200 Clean also ipv6 bird.ctl commit de8f238fdb85bdba8ce4b5988584403cf5dbcd1e Author: Ondrej Filip Date: Tue Jun 2 11:00:12 2009 +0200 Error in test fixed. commit dc16584ac2be1c097acbf8a0b2f6d412214f2a01 Author: Ondrej Filip Date: Tue Jun 2 00:28:08 2009 +0200 Small change to make BIRD's IPv6 packaging easier commit c07c65d6d079eaf4525f03f5d126d51caa2595d6 Author: Ondrej Zajicek Date: Mon Jun 1 23:18:45 2009 +0200 Escaped debbuging message removed. commit 92a72a4cbdd010f69e8d054019770e55a47637e0 Author: Ondrej Zajicek Date: Mon Jun 1 19:32:41 2009 +0200 Adds support for dynamic pair and bgp mask expressions. commit f429d4348275030a9f488046c4021aa377ad1a79 Author: Ondrej Zajicek Date: Mon Jun 1 16:20:48 2009 +0200 Removes some remnant of '|' bgp path separator. commit f98e2915794e8641f0704b22cbd9b574514f5b23 Author: Ondrej Zajicek Date: Mon Jun 1 14:07:13 2009 +0200 The pipe cleanup. commit 2d45e09f58c4ce857e10c241cf0e89b51b9ec49c Author: Ondrej Zajicek Date: Mon Jun 1 12:10:10 2009 +0200 Adds opaque/transparent pipe mode selection. commit 23ac9e9a9eefe13918ee7f21a1d0f271a44d9efd Author: Ondrej Zajicek Date: Sun May 31 15:24:27 2009 +0200 Changes pipes to transfer all routes between routing table, not just optimal routes. commit 23e563d86b412632644bdc4a886b0b7fb60e5175 Author: Ondrej Zajicek Date: Sat May 30 00:35:35 2009 +0200 Fixes buggy prefix ~ prefix matching. commit 9be1086d2970633fb5af2a1faaae16d5a1cf48ea Author: Ondrej Filip Date: Fri May 29 23:08:28 2009 +0200 New type variable 'V' defined in filters. This type is checked only for name, never for value in function filter_same() commit 43de796b8a10f561d8b3ef64a86e5ce70de01eb5 Author: Ondrej Filip Date: Fri May 29 23:04:54 2009 +0200 Function pm_path_compare() checked just length of the bgpmasks commit d59405ec6652e95f4825492c7322536bb7044db0 Author: Ondrej Filip Date: Fri May 29 23:02:36 2009 +0200 Typo in warning fixed. commit 874b868544c3a6ba45ace062091cc3aee007b719 Author: Ondrej Zajicek Date: Fri May 29 22:49:30 2009 +0200 Implements primary address selection base on 'primary' option. commit 51f4469f03759642870a45634d9b53054e3deb92 Author: Ondrej Zajicek Date: Fri May 29 17:36:37 2009 +0200 Fixes problems with rewriting of kernel device routes. commit 6f68f066b63e992321ec1873a15c233f567b9aca Author: Ondrej Zajicek Date: Fri May 29 13:32:24 2009 +0200 Add 'primary' configuration option. commit 7c3d06b087946cbea4affa4a814e72b7a3556833 Merge: f571473e 4c2507da Author: Ondrej Zajicek Date: Thu May 28 13:58:51 2009 +0200 Merge branch 'dev' into ospf commit a6c9f0648db56175ee9e077e2ca631b678552835 Author: Ondrej Filip Date: Thu May 28 13:37:04 2009 +0200 Missing boolean comparison added. commit 4c2507da687cdad1b9d147c1655e5ac46aaaa511 Author: Ondrej Filip Date: Tue May 26 10:43:59 2009 +0200 Warning for BSD system and TCP-MD5. commit 0c8c86c825f9cebf4c1d9f8d9cd57b2fad84d35b Author: Ondrej Zajicek Date: Mon May 25 01:41:20 2009 +0200 Adds INSTALL file. commit f571473ef3f78f6e38558d306d4d16ce7797e26c Author: Ondrej Zajicek Date: Sun May 24 17:55:33 2009 +0200 Hello packets on PTP networks should have zero netmask. This also ensures that misconfigured routers (one side ptp and one side broadcast) do not make adjacency. commit 8cc598a5205dbe46f5f249fa4f2de0586438965d Author: Ondrej Zajicek Date: Sun May 24 17:51:27 2009 +0200 Ignore Hello packets from different IP network (than primary). commit 050ceb867fbb96395c6f7d3207acbb5fe57b8d1c Author: Ondrej Zajicek Date: Fri May 22 18:41:52 2009 +0200 Update versions. commit 0c51083e97a4288219b29e82be65f399d085adee Author: Ondrej Zajicek Date: Fri May 22 18:08:54 2009 +0200 NEWS update. commit ea2ae6dd0ae3f5dd8cd41c1e5a1170a163027725 Author: Ondrej Zajicek Date: Fri May 22 17:12:15 2009 +0200 Change import/preimport to export/preexport to be consistent with filters. commit d72a0ac2396471ffb2b3a580ee986f950e4d23ae Author: Ondrej Zajicek Date: Fri May 22 15:16:53 2009 +0200 Fixes serious bug in route attribute handing. ea_same() sometimes returns true for different route attributes, which caused that hash table in BGP does not work correctly and some routes were sent with different attributes. commit 80f0d6764aa2c54eabdc1b41321a46e8cbcce2b9 Author: Ondrej Zajicek Date: Fri May 22 13:37:07 2009 +0200 Fixes type mismatch on BSD systems. commit d0c64519e798132b73ae5769b9246acb77b4c5aa Author: Ondrej Zajicek Date: Fri May 22 01:13:07 2009 +0200 Ugly hack for finding readline on NetBSD commit 8de11deb9107b0bcfc7bf3922ee7edff3dbcd73a Author: Ondrej Zajicek Date: Fri May 22 00:26:30 2009 +0200 Better checks for M4 in configure. commit 6c84554b671fce473fe333ab3d8b548a0768882b Merge: f434d191 4d176e14 Author: Ondrej Zajicek Date: Thu May 21 09:26:59 2009 +0200 Merge branch 'master' into dev commit f434d19174cb2d3054a00248ca609aa87bf8c263 Author: Ondrej Zajicek Date: Wed May 13 22:04:44 2009 +0200 Documentation updates commit 4d176e14509c71823a539b3c8b6103e254296d4f Author: Ondrej Filip Date: Mon May 11 02:01:11 2009 +0200 'show route protocol

' added to CLI. commit ef9c9ab9b64a6f3b5154e5340ffdcd1d211ec4c5 Author: Ondrej Filip Date: Mon May 11 01:32:49 2009 +0200 OpenBSD port related changes. commit dd8d2acd3c4ed7d7eb56ca9dbb7c9a6d43e2a869 Author: Ondrej Filip Date: Sun May 10 19:23:05 2009 +0200 Fixed bug in cli help. commit e755986a342b9a35cb7dd52e055066b1168aef12 Author: Ondrej Zajicek Date: Sun May 10 13:15:17 2009 +0200 Fixes in documentation. commit 19e10907c197ef123fafdd8a2783f9eb5f4a6f72 Author: Ondrej Zajicek Date: Fri May 8 14:37:06 2009 +0200 Fixes communication on netlink sockets Independent sessions on netlink sockets mixed state in some common variables. commit 20e94fb85b7097b57089e3912475ac881fd5528d Author: Ondrej Zajicek Date: Wed May 6 22:02:45 2009 +0200 A change in OSPF and RIP interface patterns. Allows to add more interface patterns to one common 'options' section like: interface "eth3", "eth4" { options common to eth3 and eth4 }; Also removes undocumented and unnecessary ability to specify more interface patterns with different 'options' sections: interface "eth3" { options ... }, "eth4" { options ... }; commit 10ab65a8c9eb846655feacd22c29747743a65328 Author: Ondrej Zajicek Date: Wed May 6 15:18:52 2009 +0200 Fixes one recently introduced IPv6 BGP compatibility problem. commit 2b70f0742e808053f87315433a2a64c749c3ec1d Author: Ondrej Filip Date: Mon May 4 18:17:46 2009 +0200 Linux specific TCP-MD5 handling moved to sysdep/linux/sysio.h FreeBSD coded added. BSD cannot set BGP passwords itself. This has to be done by external command. commit 1bc4b2cc840eb3f48c7e245528ef79c2b0ba50e7 Author: Ondrej Filip Date: Mon May 4 17:49:56 2009 +0200 Syntax error fix for systems without CONFIG_SELF_CONSCIOUS (KRT_ALLOW_LEARN) commit b7a735ea9d14ceb5c31712fbe122b54f0d7ec6e7 Author: Ondrej Zajicek Date: Wed Apr 29 22:17:40 2009 +0200 Allow 'third party' BGP updates for originated routes. commit 4827b69ff43661f4f34d437999b0edaac76f7355 Author: Ondrej Zajicek Date: Wed Apr 29 18:58:24 2009 +0200 Fixes BGP IPv6 link local next hop handling. When sending 'third party' BGP update, Bird used bogus link local addresses instead of addresses it received before. commit ad440a570b37e8674ef35f3a18df48f0eb2579eb Author: Ondrej Zajicek Date: Tue Apr 28 18:11:56 2009 +0200 Fixes handling of 'next hop self' and 'source address' configuration options. commit a6ee026693a9c24c71dcf846abd32508782e0249 Author: Ondrej Filip Date: Tue Apr 28 11:56:33 2009 +0200 Typo in gendist script. commit f8fbda6fb0c30fdc6e5182679e7bf1eb2fb9c8e9 Author: Ondrej Filip Date: Tue Apr 28 11:53:12 2009 +0200 Small formatting typo in documentation. commit 73841442d916490fa6a9b5967dbb1f797ca3dac1 Author: Ondrej Filip Date: Tue Apr 28 10:20:50 2009 +0200 Gendist script adapted to git. commit 11e0568f8b7a51584c7d0fa60368050dfba17193 Author: Ondrej Zajicek Date: Tue Apr 28 09:46:59 2009 +0200 NEWS and version update commit 64cf11f544257cae443d899111be1299b1ec0684 Author: Ondrej Zajicek Date: Thu Apr 23 23:15:07 2009 +0200 Fixes BGPv6 bug - missing endianity conversion. Also removes code skipping SNPAs (obsoleted by newer RFCs, should be ignored). commit f307842ad85396f8186fa049d551b6cde9925484 Author: Ondrej Zajicek Date: Thu Apr 23 14:44:02 2009 +0200 Fixes BGPv6 bug - mandatory attributes weren't validated; commit 8f0c887a52fb19cee14725f66d435cebf2010390 Author: Ondrej Zajicek Date: Thu Apr 23 14:16:05 2009 +0200 Fixe bug in BGPv6 that causes to send invalid network withdraws. commit b9539e78d8ebfa9e13d7b61ec9278b76abefdac3 Author: Ondrej Zajicek Date: Thu Apr 23 12:36:24 2009 +0200 Fixes bug in BGPv6 causing crash by checking missing attributes. commit e366625c0ef21d02caf2dab1935862ace1e10fed Author: Ondrej Zajicek Date: Fri Apr 17 18:43:11 2009 +0200 Fixes mixed-up messages on netlink socket Under specific circumstances there might be two mixed-up netlink sessions (one for scan, the other for route change request). This patch separates netlink scans and requests to two fds (and seq counters). This should fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=428865 commit c8a6b9a3d199444fd45879dd5cc5ececd9624822 Author: Ondrej Zajicek Date: Fri Apr 17 01:48:36 2009 +0200 Rewrite of buggy AS path matching. Old AS path maching supposes thath AS number appears only once in AS path, but that is not true. It also contains some bugs related to AS path sets. New code does not use any assumptions about semantic structure of AS path. It is asymptotically slower than the old code, but on real paths it is not significant. It also allows '?' for matching one arbitrary AS number. commit 024c310b537abc3ddbac3054de71fd759d422824 Author: Ondrej Zajicek Date: Wed Apr 8 20:15:01 2009 +0200 Fixes broken cryptographic authentication in OSPF Cryptographic authentication in OSPF is defective by design - there might be several packets independently sent to the network (for example HELLO, LSUPD and LSACK) where they might be reordered and that causes crypt. sequence number error. That can be workarounded by not incresing sequence number too often. Now we update it only when last packet was sent before at least one second. This can constitute a risk of replay attacks, but RFC supposes something similar (like time in seconds used as CSN). commit b722fe7ebdf7e11f097ed0a85302769de2ac10fb Author: Ondrej Zajicek Date: Mon Apr 6 16:53:06 2009 +0200 Fixes bug in OSPF packet retransmission. If a DBDES packet from a master to a slave is lost, then the old code does not retransmit it and instead send a next one with the same sequence number. That leads to silent desynchronization of LSA databases. commit 8298d780be5a5b00c31c10a37a5f3a1353d6e234 Author: Ondrej Zajicek Date: Mon Apr 6 16:17:47 2009 +0200 Better OSPF packet tracing log messages. Replaces old OSPF packet tracing messages with uniform messages with packet dumps. commit bcb81251b4e37b96743aa1cdf790f30ef41a465e Author: Ondrej Zajicek Date: Tue Mar 31 21:30:58 2009 +0200 Documentation update commit c60cdd8c3926a1b3d9156327e8aae64986084ff4 Author: Ondrej Zajicek Date: Tue Mar 31 21:17:00 2009 +0200 Cleanup changes commit b1a597e0c3821c791a41278454e74261cf1b95fb Author: Ondrej Zajicek Date: Tue Mar 31 12:55:57 2009 +0200 Reimplementation of prefix sets. Prefix sets were broken beyond any repair and have to be reimplemented. They are reimplemented using a trie with bitmasks in nodes. There is also change in the interpretation of minus prefix pattern, but the old interpretation was already inconsistent with the documentation and broken. There is also some bugfixes in filter code related to set variables. commit 1733d080c9f60de69e843f22e138f27240a8176c Author: Ondrej Zajicek Date: Wed Mar 25 19:15:26 2009 +0100 Minor text updates. commit 40b65f947aed065c03c5f2d5c66c6c794a5aadda Author: Ondrej Zajicek Date: Wed Mar 25 19:05:52 2009 +0100 Fixes bug in pipe route filtering. Routes comming through pipe from primary to secondary table were filtered by both EXPORT and IMPORT filters, but they should be only filtered by EXPORT filters. commit 4d7d0cb137b700a17751b5a565539357304f9080 Author: Ondrej Zajicek Date: Wed Mar 25 18:29:17 2009 +0100 Fixes minor bug in pipe. Missing macro leads to not calling some of protocol's callbacks. commit 3d574679b8cceb1362bb973e7dfe9981fc93b79b Author: Ondrej Zajicek Date: Fri Mar 20 12:58:21 2009 +0100 Fix bugs related to kernel table synchronization. KRF_INSTALLED flag was not cleared during reconfiguration that lead to not removing routes during reconfigure when export rules changed. We also should not try to remove routes we didi not installed, on Linux this leads to warnings (as kernel checks route source field and do not allow to remove non-bird routes) but we should not rely on it. commit 48d79d521cc13f11eafa129a4216512403b83115 Author: Ondrej Zajicek Date: Wed Mar 18 20:30:21 2009 +0100 Better handling of AS4 optional attribute errors AS4 optional attribute errors were handled by session drop (according to BGP RFC). This patch implements error handling according to new BGP AS4 draft (*) - ignoring invalid AS4 optional attributes. (*) http://www.ietf.org/internet-drafts/draft-chen-rfc4893bis-02.txt commit eb875dbbe1afaceaf3645384f2a35c98b4c5b5f6 Author: Ondrej Zajicek Date: Sat Mar 14 22:18:49 2009 +0100 Documentation fixes. commit ad586334d51a0aef9de868e9586198e402576599 Author: Ondrej Zajicek Date: Sat Mar 14 14:01:39 2009 +0100 Path related documentation update commit cf1860349182503523975fb8084d514407a75fb4 Author: Ondrej Zajicek Date: Sat Mar 14 12:43:10 2009 +0100 New syntax for bgp_path commit f16ad72ed76c398f081b97b09d56f4b199822464 Author: Ondrej Zajicek Date: Fri Mar 13 14:19:03 2009 +0100 Update NEWS commit e8ba557c7f66aaf02dd24f554fba8b3607c2b3d5 Author: Ondrej Zajicek Date: Fri Mar 13 12:49:44 2009 +0100 Update capability handshake options Add 'capabilities' option, change default behavior to advertise ipv4, add some checks and ignore incoming capabilities when capabilities are disabled. commit e3299ab14877de6ce688050e550c44cd4e85b212 Author: Ondrej Zajicek Date: Thu Mar 5 11:52:47 2009 +0100 Added Cisco and Quagga capability workaround option. commit 82a79586e5810af2f0338cb4c5982e085b5c5292 Author: Ondrej Zajicek Date: Fri Feb 27 15:24:46 2009 +0100 Better handling of too long attributes This patch extends the length for attributes from 1024 to 2048 (because both AS_PATH and AS4_PATH attributes take 2+4 B per AS). If there is not enough space for attributes, Bird skips that route group. Old behavior (skipping remaining attributes) leads to skipping required attributes and session drop. commit cb5303927188de9504a6e18aedec299956a22b6f Author: Ondrej Zajicek Date: Thu Feb 26 14:23:54 2009 +0100 Rate limit for most abundant log messages commit a9dc5e1ef2fd08c53bceb54690f6dac83ddf0c81 Author: Ondrej Zajicek Date: Wed Feb 25 16:28:21 2009 +0100 Fixes another bug in packet retransmissions. When slave was in full state, it didn't retransmit lost packets. That leads to OSPF connection locked in states loading-full. commit 82ba9032be9cf1210ffffd01245b99ce5d9b6b1b Author: Ondrej Zajicek Date: Sat Feb 21 22:46:50 2009 +0100 Fixes crash during some expressions Bird crashed when 'bgp_path.len' was used for routes that does not came from BGP. commit cd17c651a60c30837b683f8ca6e07139dc57d882 Author: Ondrej Zajicek Date: Sat Feb 21 17:47:56 2009 +0100 Add format for BGP_AGGREGATOR attribute commit 25cb9f1d0165df5e86956021cc3e6ee87730ef3b Author: Ondrej Zajicek Date: Sat Feb 21 16:20:45 2009 +0100 Fix bug in empty bgp mask handling commit e312bb4014d5b4ccc706c737f4362ac6ca1046ee Author: Ondrej Zajicek Date: Thu Feb 12 21:53:44 2009 +0100 Documentation update commit d901db3fb72860d4669793bfb1af3a9aa7a27b91 Author: Ondrej Zajicek Date: Thu Feb 12 19:46:51 2009 +0100 Fixes bug in packet retransmissions. When packet was lost during dbdes exchange, slave did not retransmit it. That leads to OSPF connection locked in states exchange-exstart. commit b807ef9a15db2a5db14f68011923975dfc472f49 Author: Ondrej Zajicek Date: Thu Feb 12 13:43:06 2009 +0100 Fixes bug in protocol state machine Scheduling flush must be done before resource pool freeing as it frees some allocated list nodes from a global list. commit 80ac7dc18145baa04a05eee3a69d325087cb9472 Author: Ondrej Zajicek Date: Thu Feb 12 13:41:34 2009 +0100 Do not use ? for client-side help when in new BGP path syntax commit f9491630390da4de138961354433635729668b7d Author: Ondrej Zajicek Date: Tue Jan 27 17:35:00 2009 +0100 New syntax for bgp_path commit 11ec0f1a5171c556dec09e90c20af12f45a6d902 Author: Ondrej Zajicek Date: Fri Jan 16 12:49:51 2009 +0100 Fixes compilation on older systems. Older kernel headers (the ones in Debian Sarge) does not have __kernel_sockaddr_storage . commit e3c460bc9034b30743dd861ddbdbc026cd2997b5 Author: Ondrej Zajicek Date: Fri Jan 16 12:08:07 2009 +0100 Fixes some past config grammar update that caused password related regression. commit 3b108f18e8c151d9c570fd418fc822c1e9ad5e79 Author: Ondrej Zajicek Date: Fri Jan 16 10:58:52 2009 +0100 One null-pointer dereference bugfix hidden in whitespace changes commit 0dd7ccc7669834495c637f5055f2cd783367f8f9 Author: Ondrej Zajicek Date: Tue Jan 13 19:25:27 2009 +0100 Fix typo. commit 0844b65d13d7a5928d425e9adaf28de63550a542 Author: Ondrej Zajicek Date: Tue Jan 13 19:15:49 2009 +0100 Fix OSPF protocol error recovery behavior. When OSPF neighbor state drops down to EXSTART, clear LSA request and retransmit lists, as specified by RFC. I hope that this will prevent oscillations between EXSTART and LOADING states, which sometimes happened. It also contains related fix from Yury Shevchuk that properly resets DB summary list iterator. commit f15cb99c79034fbd98d90b104bd6267e6c2fec81 Author: Ondrej Zajicek Date: Mon Jan 12 23:42:51 2009 +0100 Add check detecting packet overwrite in TX buffer. commit 02a9eeeb8547b3f0940a0295df8a78ce2181ec30 Author: Ondrej Zajicek Date: Mon Jan 12 14:40:21 2009 +0100 Slist update commit 23d6702952841184d364a5520dbe6be7a1a5d14b Author: Ondrej Zajicek Date: Sun Jan 11 12:14:27 2009 +0100 Some fixes and update of OSPF debug messages commit 0e9617e400d54f6f5119a24e7380b7719c2fc3dd Author: Ondrej Zajicek Date: Sun Jan 11 10:51:54 2009 +0100 Move check for NULL before usage of variable. commit f20907adf60960f63b797f4423b4790e8591e99c Author: Ondrej Zajicek Date: Sun Jan 11 10:47:41 2009 +0100 Fixes bug in OSPF Checksum was not recalculated when LSA was changed and packets with bad checksum were sent. commit 330aecead80140b0016d6de56dad1d193be774c8 Author: Ondrej Zajicek Date: Thu Dec 25 17:49:57 2008 +0100 Bugfix in interpret Missing cases in filter code interpret leads to crash when bgp_next_hop attr was queried. commit 083c43e22efb5353a258827a9e6f2f995cfe822d Author: Ondrej Zajicek Date: Thu Dec 25 11:55:27 2008 +0100 fixes some 64-bit related bugs. Filter code used 'aux' integer field of 'symbol' struct to store ptr to next symbol and both 'aux2' and 'def' fields for value. Changed to just 'def' for value and 'aux2' for ptr to next symbol. Also another minor bugfix. commit 165a62272720071ca5e9ed1badfddc78b7a7af10 Author: Ondrej Zajicek Date: Wed Dec 24 17:24:41 2008 +0100 Adds support for fallback to capabilityless BGP connect When capability related error is received, next connect will be without capabilities. Also cease error subcodes descriptions (according to [RFC4486]) are added. commit 591211557f4106ed9e877fa9b80eb56ffb99fef3 Author: Ondrej Zajicek Date: Wed Dec 24 12:18:10 2008 +0100 Fixes bug related to reconfiguration of BGP. BGP keeps its copy of configuration ptr and didn't update it during reconfiguration. But old configuration is freed during reconfiguration. That leads to unnecessary reset of BGP connection during reconfiguration (old conf is corrupted and therefore different) and possibly other strange behavior. commit 11b32d911715cbfb3ce4c87685b1388e4b0de1c4 Author: Ondrej Zajicek Date: Fri Dec 19 01:34:39 2008 +0100 Major changes to BGP Fixes two race conditions causing crash of Bird, several unhandled cases during BGP initialization, and some other bugs. Also changes handling of startup delay to be more useful and implement reporting of last error in 'show protocols' command. commit b933281ed5efb9ad9375c3ea41ee2412b9f89c15 Author: Ondrej Zajicek Date: Thu Dec 18 23:26:08 2008 +0100 Fixes nasty bug in event processing. WALK_LIST_DELSAFE (in ev_run_list) is not safe with regard to deletion of next node. When some events are rescheduled during event execution, it may lead to deletion of next node and some events are skipped. Such skipped nodes remain in temporary list on stack and the last of them contains 'next' pointer to stack area. When this event is later scheduled, it damages stack area trying to remove it from the list, which leads to random crashes with funny backtraces :-) . commit 35164c501722f07beef21178b19090fa9d1930cd Author: Ondrej Zajicek Date: Fri Dec 12 17:48:03 2008 +0100 rx_hook may be cleaned in some callback so we check it before executing sk_read(). commit d6a836f8d673a117fd19136d24e98fa9bbc4b27e Author: Ondrej Zajicek Date: Mon Dec 8 12:24:55 2008 +0100 Fixes core state machine. The core state machine was broken - it didn't free resources in START -> DOWN transition and might freed resources after UP -> STOP transition before protocol turned down. It leads to deadlock on olock acquisition when lock was not freed during previous stop. The current behavior is that resources, allocated during DOWN -> * transition, are freed in * -> DOWN transition, and flushing (scheduled in UP -> *) just counteract feeding (scheduled in * -> UP). Protocol fell down when both flushing is done (if needed) and protocol reports DOWN. BTW, is thera a reason why neighbour cache item acquired by protocol is not tracked by resource mechanism? commit fbde6c39084637c2f3f4d31261a44dbf367958d1 Author: Ondrej Zajicek Date: Sat Nov 22 01:12:22 2008 +0100 Fixes race condition leading to memory corruption and crash. When protocol started, feeding was scheduled. If protocol got down before feeding was executed, then function responsible for connecting protocol to kernel routing tables was called after the function responsible for disconnecting, then resource pool of protocol was freed, but freed linked list structures remains in the list. commit 35f983f88912eadb1e0b25d800693256cbee33ce Author: Ondrej Zajicek Date: Fri Nov 21 18:17:03 2008 +0100 Fixes segfault with multiple routing tables. commit 661ec5db7fa047d883997d0b2cbdd71659f80777 Author: Ondrej Zajicek Date: Fri Nov 21 13:05:12 2008 +0100 I am not sure whether this is proper fix for a problem that birdc shows only parts of larger outputs (for example 'show route all'). It seems that birdc reads (from bird) and writes (to stdout) everything but during execution of some readline code some already written output disappeared (although it is fflush()ed and tcdrain()ed). As birdc reads from stdin when select said there are some data, O_NONBLOCK for stdin is unnecessary and when it is removed, i didn't notified this problem. commit eac21b46f7cf0f704c976f2ffdb289837ad100cc Author: Ondrej Zajicek Date: Fri Nov 21 13:01:05 2008 +0100 This is bug, isn't it? commit e00115904ff7c1854957117d52a6db484050965b Author: Ondrej Zajicek Date: Fri Nov 21 12:59:03 2008 +0100 birdc died during terminal resize because of unhandled EINTR in select loop. commit 44711e0ca2658da080e04ce7e208a78c9b20e927 Author: Ondrej Zajicek Date: Sun Nov 16 22:16:04 2008 +0100 Fix some bugs in filter interpret. commit ebacaf6f7b4418dd283fd3e39b84e48e331a6a66 Author: Ondrej Zajicek Date: Sun Nov 16 11:35:30 2008 +0100 Fix bug in AS path matching commit 258d0ad4ca550895a1ef20fc478c0160be5374f2 Author: Ondrej Zajicek Date: Fri Nov 14 23:03:15 2008 +0100 Fixes feeding of new protocol, only preferred routes are announced. commit 3f670371cfeef155256a8a77ac5581accee13b05 Author: Ondrej Zajicek Date: Fri Nov 14 21:13:56 2008 +0100 OSPF routes appeared with random value of ospf_tag attribute. This patch fixes it. commit e29fa06ece1bf9f9a47f224db797df940556136e Author: Ondrej Zajicek Date: Fri Nov 14 14:50:37 2008 +0100 New read-only route attribute 'proto' added. It returns a string representing a name of the protocol that originated the route. Strings can be compared using = or matched using ~. Routes can be filtered, for example: show route where proto ~ "bgp1*" commit aebe06b40ce730a88cc8a3121be1944b3ddf5765 Author: Ondrej Zajicek Date: Sat Nov 8 23:33:22 2008 +0100 Proper format functions for ORIGINATOR_ID, CLUSTER_LIST commit b21f68b4cd4794c84e5f0eb2c34204c87ccf0e9a Author: Ondrej Zajicek Date: Sat Nov 8 17:24:23 2008 +0100 Fix bugs in OSPF MD5 authentication. First bug is that default values for MD5 password ID changed during reconfigure, Second bug is that BIRD chooses password in first-fit manner, but RFC says that it should use the one with the latest generate-from. It also modifies the syntax for multiple passwords. Now it is possible to just add more 'password' statements to the interface section and it is not needed to use 'passwords' section. Old syntax can be used too. commit 08cca48a149bd6d5210659daf220b6dae87a43b3 Author: Ondrej Zajicek Date: Thu Nov 6 19:13:55 2008 +0100 Uprava configure commit fd91ae3325adfdc83f95a284caa746c000ad7e30 Author: Ondrej Zajicek Date: Wed Nov 5 22:36:49 2008 +0100 Fix problem with local time changes. commit 1389f3699fc643dac6fd4d2f19fb59da3624a2fa Author: Ondrej Zajicek Date: Wed Nov 5 21:39:04 2008 +0100 Fixes bugs in IPv6 code caused by recent commits. commit baa9ef18c62612bd91a8362ef20427046105c113 Author: Ondrej Zajicek Date: Tue Nov 4 14:52:47 2008 +0100 These warnings are so abundant (because char * / byte * mix) that they are completely useless. commit 6c8102e3a8bf8ae4c15d383f0bd31294dd2ef76e Author: Ondrej Zajicek Date: Tue Nov 4 14:51:45 2008 +0100 Ignore messages related to wireless extensions. commit a39b165e45fbfea053fd0237e0d5a3ebdcf40f78 Author: Ondrej Zajicek Date: Sat Nov 1 16:58:40 2008 +0100 Multihop BGP was completely broken, because listening socket has always ttl 1. commit a92fe607173b52cf28256f00399953c623788c35 Author: Ondrej Zajicek Date: Sat Nov 1 12:55:43 2008 +0100 Implementation of route server. commit e16466b379be2b94c84b351a69e63b6de5be9dc5 Author: Ondrej Zajicek Date: Wed Oct 29 14:16:34 2008 +0100 Fix race condition that breaks BGP connections after reconfigure. RFC says that only connections in OpenConfirm and Established state should participate in connection collision detection. The current implementation leads to race condition when both sides are trying to connect at the almost same time, then both sides receive OPEN message by different connections at the almost same time and close the other connection. Both connections are closed and the both sides end in start/idle or start/active state. commit f0ad56f4414fef2781339cfa41704f7bf4c61ad2 Author: Ondrej Zajicek Date: Tue Oct 28 16:10:42 2008 +0100 Fixes some sloppiness of commit a3b70dc499b64f41aa776b5b4afee5c7bfb8dfa6. commit a98fbf0f12b5e83e25afa0f585ca6a4d4ac5f6bf Merge: a3b70dc4 1567edea Author: Ondrej Zajicek Date: Mon Oct 27 00:20:22 2008 +0100 Merge branch 'dev' into out commit a3b70dc499b64f41aa776b5b4afee5c7bfb8dfa6 Author: Ondrej Zajicek Date: Mon Oct 27 00:03:30 2008 +0100 Two new informative CLI commands for OSPF. Two new CLI commands for OSPF giving nice informative (and still machine parsable) representation of OSPF network graph (based on datas from the LSA database). The first command (show ospf topology) shows routers, networks and stub networks, The second command (show ospf state) shows also external routes and area-external networks and routers propagated by given area boundary router. commit 68fa95cfec78f1bfe790949bf747d578ad583ec2 Author: Ondrej Zajicek Date: Sun Oct 26 23:55:38 2008 +0100 Check of socket name length commit 52586ccdf17cd9f34f767718d97f8a258da5efdb Author: Ondrej Zajicek Date: Sun Oct 26 23:53:05 2008 +0100 Missing newline. commit a97122a3caff40bf35e6019a9b60d5e5ef35a84f Author: Ondrej Zajicek Date: Sun Oct 26 23:43:13 2008 +0100 Bugfix in LSA origination for PTP OSPF links. The code generating LSAs for PTP OSPF links is buggy. The old behavior is that it generates PTP link if there is a full/ptp neighbor and stub link if there isn't. According to RFC 2328, the correct behavior is to generate stub link in both cases (in the first case together with PTP link). And because of buggy detection of unnumbered networks, for numbered networks the code creates stub links with 0.0.0.0/32. commit 4c94a6c7e78fb75a9952d891db9d47605f8a26e1 Author: Ondrej Zajicek Date: Sun Oct 26 23:23:09 2008 +0100 Do not repeat 'Invalid broadcast address' error message. 'Invalid broadcast address' error is reported only once for an interface and not during every interface scan. commit d7f3b306495327e76aa9ae381c6c7575104e0e24 Author: Ondrej Zajicek Date: Sun Oct 26 23:20:50 2008 +0100 Ignore unknown netlink events. Bird sometimes reported 'bird: nl_parse_link: Malformed message received'. The cause is that bird asynchronously received netlink packet from wireless driver about some wireless event on its link layer. In that case bird shouldn't complain. commit 1567edea8d3da7da08092eef15bb3bd4544c6464 Author: Ondrej Zajicek Date: Sun Oct 26 23:09:46 2008 +0100 Bugfix for routing table breaking bug. Here is a patch fixing a bug that causes breakage of a local routing table during shutdown of Bird. The problem was caused by shutdown of 'device' protocol before shutdown of 'kernel' protocol. When 'device' protocol went down, the route (with local network prefix) From different protocol (BGP or OSPF) became preferred and installed to the kernel routing table. Such routes were broken (like 192.168.1.0/24 via 192.168.1.2). I think it is also the cause of problem reported by Martin Kraus. The patch disables updating of kernel routing table during shutdown of Bird. I am not sure whether this is the best way to fix it, I would prefer to forbid 'kernel' protocol to overwrite routes with 'proto kernel'. The patch also fixes a problem that during shutdown sometimes routes created by Bird remained in the kernel routing table. commit b6bf284a905412cfe107b4967e55649e6194187e Author: Ondrej Zajicek Date: Sun Oct 26 22:59:21 2008 +0100 Bugfixes in MULIT_EXIT_DISC attribute handling. - Old MED handling was completely different from behavior specified in RFCs - for example they havn't been propagated to neighboring areas. - Update tie-breaking according to RFC 4271. - Change default value for 'default bgp_med' configuration option according to RFC 4271. commit 4819c3e17ac22c6810ee80261ac3bffb5127e39d Author: Ondrej Zajicek Date: Sun Oct 26 22:54:23 2008 +0100 Bugfix in LOCAL_PREF attribute handling. commit 1adc17b4b57267e301fcd67309494bbbddbfa718 Author: Ondrej Zajicek Date: Sun Oct 26 22:52:21 2008 +0100 Update of a documentation - new options for AS4, MD5 auth and route reflection. commit ba5ed6f3e4eb4b2899cdad08e2edb99063bfbcee Author: Ondrej Zajicek Date: Sun Oct 26 22:48:02 2008 +0100 Implementation of an option for disabling AS4 support per BGP instance. commit 4847a894bf7d4852325c3f1ea4bb4890054a1f66 Author: Ondrej Zajicek Date: Sun Oct 26 22:45:09 2008 +0100 Implementation of route reflection for BGP commit d51aa2819005a03e4cfb6f62333be6ccadfb3c06 Author: Ondrej Zajicek Date: Sun Oct 26 22:42:39 2008 +0100 Implementation of MD5 authentication of BGP sessions. commit 11cb620266035ffbe17b21c4a174380cb8b6a521 Author: Ondrej Zajicek Date: Sun Oct 26 22:36:08 2008 +0100 Implementation of 4B ASN support for BGP commit 44cb1449edec6a80e063981a955e8025ee87ea65 Author: Martin Mares Date: Sun Oct 26 14:14:37 2008 +0100 The top-level Makefile is a generated file, so remove it from the repo. commit c94d56cb04b15dc32f54e8e39b877a92d7bda8c5 Author: Martin Mares Date: Sun Oct 26 14:11:06 2008 +0100 Updated version number in the README. commit 226cb2bc3ff573c4c027d525a96aa2b10a28b817 Author: Ondrej Filip Date: Mon Aug 25 12:51:06 2008 +0000 Expand ospf dump information. commit 97c6fa02e089e3fb057185fe5937297afc5a11ec Author: Ondrej Filip Date: Mon Aug 25 12:06:20 2008 +0000 Previous patch reverted. :-( commit 73e53eb555a58846c4d2db6464d41d1761a60169 Author: Ondrej Filip Date: Mon Aug 25 12:00:55 2008 +0000 Endianity problem in debug message fix. commit 030e3a79cb9376fa85597fdb8243299cd843ca3a Author: Ondrej Filip Date: Mon Aug 25 11:57:46 2008 +0000 Buffer overflow fix. commit 057021df0d699f9c21368ab0fa51fe821cc9a544 Author: Martin Mares Date: Mon Aug 25 11:19:49 2008 +0000 Fix behavior of ipa_opposite(). It was giving wrong results on /30 networks. commit 6c36c4b66be5c67a8d5cfa9578aa5a85ebebab6d Author: Martin Mares Date: Mon Aug 25 11:14:14 2008 +0000 Updated config.{guess,sub} to a recent version. Patch from the Debian package. commit 3c3271d9fce8cdd614f1d1b24bcebb3599aad930 Author: Ondrej Filip Date: Sun Aug 24 23:24:14 2008 +0000 Close fd of config file after reconfiguration. commit 85ae398a61184d8f7a353eacaa6aefd3422dfd71 Author: Ondrej Filip Date: Sun Aug 24 23:20:46 2008 +0000 The source address configuration in BGP added. commit a456788bce7f9d1e54b19ffbfd35b8fa889c4b47 Author: Ondrej Filip Date: Wed Jun 20 12:32:39 2007 +0000 New version of flex needs argument separated. commit 8411a37e7dc72a5fd2e4fb68d1c557dc89253973 Author: Martin Mares Date: Wed Jun 20 07:33:26 2007 +0000 Detach from the TTY properly. commit 4b1cf69e765b19ebc0cb988be08910c156c76376 Author: Ondrej Filip Date: Wed Mar 16 16:09:28 2005 +0000 Again back to regina.gin.cz. commit c81b4ec36105ff036a7e2423936ab5773011fed1 Author: Ondrej Filip Date: Wed Mar 16 16:08:40 2005 +0000 Yes, we will go for 1.0.12 commit f39e3bfdbff318b3a889f42acfb589e9dfd34c2f Author: Ondrej Filip Date: Tue Mar 15 23:42:41 2005 +0000 Small bugfix in tracing. commit 94c42054ea65d10477afc76f221e3ac345a431eb Author: Ondrej Filip Date: Tue Mar 15 22:06:36 2005 +0000 Added new parametr 'rx buffer '. BIRD is able to receive very large packets (if configured). commit e6ea2e375e4c547ca1b6fc9c313c2b7940acbd77 Author: Ondrej Filip Date: Tue Mar 15 20:51:33 2005 +0000 Maximal packet size in virtual links is 576. commit e300066d5f66b8bd1d5561d63c10a8fbdce3ba8e Author: Ondrej Filip Date: Mon Mar 14 11:24:56 2005 +0000 OSPF can accept larger packets than MTU. commit 427e59939bc72c79f1566167b337927b14cb1715 Author: Ondrej Filip Date: Mon Mar 14 11:07:10 2005 +0000 Look for large packets. commit a2d5b405d41c212993e47d47607df3b708254c97 Author: Ondrej Filip Date: Mon Mar 14 10:59:52 2005 +0000 Bugfix in external routes calculation. commit f735de0290ce9a8f119f3d72bdde5a16dafe27ad Author: Ondrej Filip Date: Mon Feb 21 14:06:22 2005 +0000 Small typos in documentation. commit 129e912924b7726166b9ff5925a9dff84ee511f9 Author: Ondrej Filip Date: Mon Feb 21 10:22:57 2005 +0000 Ftp server change. commit 89478fe3ab6d07b824adbd4c8ed997ccaca5c7b4 Author: Ondrej Filip Date: Mon Feb 21 10:04:37 2005 +0000 Change of ftp servers. commit 39fc85b4c63582b56c4f96de49d0c6aad03c4086 Author: Ondrej Filip Date: Sun Feb 20 19:03:34 2005 +0000 Unused code deleted. commit 63ca37f3139505a1881bf2c343f18d4ed8e22ce4 Author: Ondrej Filip Date: Sun Feb 20 18:56:06 2005 +0000 Cleanup - all unused variables deleted. commit efc9e1b78b9332a0a8dfce31f1ef8efc82edc63d Author: Ondrej Filip Date: Sun Feb 20 17:04:00 2005 +0000 Some tasks are fulfilled. :-) commit 52d61a84989cc40140e7e8b5fc294ac48d4e0245 Author: Ondrej Filip Date: Sun Feb 20 16:54:09 2005 +0000 Intelligent reconfiguration should work again. commit dafaef9ba9e7b46b9ff42b2cb75954a86f920951 Author: Ondrej Filip Date: Sun Feb 20 16:53:06 2005 +0000 Originate default route into stub areas. commit 028a4cfc02f425de34323082d800a39b7bbc51de Author: Ondrej Filip Date: Sun Feb 20 04:28:55 2005 +0000 Let's go for 1.0.11. commit d8c7d9e8846f025e42227c64e992a3a52ca7dfb4 Author: Ondrej Filip Date: Sun Feb 20 04:27:56 2005 +0000 Since now I can also use 'dead interval', not just 'dead counter'. commit 7de7470a2a6c649ce4d4ce52146e84e6638ebf58 Author: Ondrej Filip Date: Sun Feb 20 03:37:47 2005 +0000 Bugfix - count courrectly next hop on single hop virtual link. commit 6eb4b73fe829cf5da56d8990c33e5c7edaa19d77 Author: Ondrej Filip Date: Sun Feb 20 03:30:44 2005 +0000 Time of neighbor's dead was not shown correctly. commit 5506c82ce6123f70220f2d84ff21269bb832bfac Author: Ondrej Filip Date: Fri Feb 18 19:36:32 2005 +0000 Bugfix in previous bugfix. commit 60e04f041303fdafd0abf0dec003a9745345c68a Author: Ondrej Filip Date: Fri Feb 18 18:51:42 2005 +0000 Minor bugfix: Summary LSA for aggregated area was always propagated with metric = 1. Now it's metric of most distant component. commit 27a1e3ac35bd3f6a9b5161eafb5b8178162a37f8 Author: Ondrej Filip Date: Tue Feb 15 16:17:42 2005 +0000 Minor bugfixes in routing table calsulation. commit 8ffc753441cd58acf46783de335062ed9af7a12e Author: Ondrej Filip Date: Tue Feb 15 06:32:31 2005 +0000 Minor changes to keep gcc happy. commit c025b85273178bc7c129bf54e420a91c775a9340 Author: Ondrej Filip Date: Mon Feb 14 23:15:04 2005 +0000 Real write is only in sk_maybe_write. Previous change partially reverted. Thank you MJ. commit 2eef9e887ad82976476ea81aa3a25d97c3956b87 Author: Ondrej Filip Date: Mon Feb 14 21:34:46 2005 +0000 Be more verbose in log. commit 7c49f715593ad7bbe0a4fb86284e2023f7b65bc1 Author: Ondrej Filip Date: Mon Feb 14 21:28:51 2005 +0000 Added s->err_hook wrapper that empties socket. commit 030d3b387edae4a30fb524ed839be020b7b8df8e Author: Ondrej Filip Date: Mon Feb 14 11:58:46 2005 +0000 Small changed to reduce the number of warnings. commit b181f444a6538b03a02296f02928e3c131b251a6 Author: Ondrej Filip Date: Mon Feb 14 11:54:16 2005 +0000 Small changes to reduce number of warnings. commit 75c1c585197f2b4a1b0295d36fe16a4869c21914 Author: Ondrej Filip Date: Mon Feb 14 11:37:40 2005 +0000 Yes, I'd like to go to 1.0.10 commit 5d3f555234d7144272e3081665411d098280d5ad Author: Ondrej Filip Date: Sun Feb 13 23:36:31 2005 +0000 Many bugfixes in routing table calculation and summary LSA origination. commit 0d3effcf8ca3784c36ce6229343ddfd754e405dc Author: Ondrej Filip Date: Sat Feb 12 22:27:55 2005 +0000 Time added in password management. commit 89ba9a18068dc83557e03c58bf280f4dc203271d Author: Ondrej Filip Date: Sat Feb 12 22:22:18 2005 +0000 Bugfix in inter-area route calculation and summary LSA origination. Bugfix of some debugging commands. commit bae7c43ff35482807654519253b1daa0a6518951 Author: Ondrej Filip Date: Sat Feb 12 22:19:46 2005 +0000 Bugfix in password acceptance commit 9912fa51c8dabbbdf068d271ee7bddfb4a8526ef Author: Ondrej Filip Date: Sat Feb 12 22:18:48 2005 +0000 Bugfix - cost of interface can be larger than 0xffff commit 4991756863538cc5168cc5f10b2599c84eafd8bf Author: Ondrej Filip Date: Wed Sep 15 19:33:01 2004 +0000 Dont check netmask field on PTP links. commit 8910351c76af983411e09e04aff86ea5d9940cf1 Author: Ondrej Filip Date: Wed Sep 8 16:06:07 2004 +0000 sort from GNU coreutils 5.2.1 doesn't accept the +- syntax anymore. Hopefully the -k syntax is supported by all other sort versions commit c6dce04bed40959b331a5b79aadd11c3b34d4af5 Author: Ondrej Filip Date: Wed Sep 8 16:04:02 2004 +0000 Bugfix. commit 27e3e5e0c95b068111bf00d7dceb473dc77a93f2 Author: Martin Mares Date: Thu Aug 19 09:15:36 2004 +0000 Do not forget to propagate LDFLAGS from configure. Allows static linking, among other things. commit 7715f9d9edb2cd5a230424881b1d5ec4e842738a Author: Ondrej Filip Date: Tue Aug 10 17:47:32 2004 +0000 Bugfix in config.y commit 56e2a4b776b0d013f71bff9fbf8550442c11df91 Author: Ondrej Filip Date: Thu Aug 5 18:06:30 2004 +0000 Bugfix in OSPF - BIRD sometimes failed during rt calculation with VLINKs. commit 6236beab1ec5ba61487c418119e01a933e1cacee Author: Ondrej Filip Date: Mon Aug 2 22:38:43 2004 +0000 Some more TODOs for OSPF. commit 8d94a524b637dbb1513c23daefa8411dcdc9a054 Author: Ondrej Filip Date: Fri Jul 16 08:27:11 2004 +0000 Added handling of STUB bool. commit 73089070e6e5c94ffac2da4c9e267ae9bcda2164 Author: Ondrej Filip Date: Fri Jul 16 08:01:32 2004 +0000 Typo. commit 002ecc063845243613eb1ff40c3aa2a46c7013a1 Author: Ondrej Filip Date: Fri Jul 16 07:22:43 2004 +0000 Bugfix - bird needed double ';' after rfc1583compat. commit 4e9742bb597225d7cefc0ee08270f76db29b65f1 Author: Ondrej Filip Date: Thu Jul 15 19:46:52 2004 +0000 Added note about *BSD. commit 6b68de07d9a4f1ad122e46dc40c6cdfd8b06ae4b Author: Ondrej Filip Date: Thu Jul 15 17:58:07 2004 +0000 News update to 1.0.9. commit 004cf4fc0ced85dba570173f372c51b1bf71dafe Author: Ondrej Filip Date: Thu Jul 15 17:28:13 2004 +0000 Minor bugfix to compile bird in IPv6. commit b37bb5ce03aed03d8b1bb0346f3277a93ff76da4 Author: Ondrej Filip Date: Thu Jul 15 16:48:12 2004 +0000 Minor bugfix - add interface routes. commit 28e8d862b7952419e6050230cf154d244a5bae51 Author: Ondrej Filip Date: Thu Jul 15 16:42:06 2004 +0000 Minor bugfix in calculation of external routes. commit 86c84d76b706e77ec5977a3c9e300b0fca9f6b10 Author: Ondrej Filip Date: Thu Jul 15 16:37:52 2004 +0000 Huge OSPF database redesign. Since now, all LSAs of all areas are in single database. This avoids duplication of external LSAs and fixes bug in external LSA distribution. commit 777acf91bb0d8ca0f33f367ae5fa00f46dde5a9a Author: Ondrej Filip Date: Wed Jul 14 21:47:39 2004 +0000 Everything is tested and works. I thins it's right time to go to 1.0.9. commit 3b16080c97a2d89c90f7df7a8fda0401ec9abe42 Author: Ondrej Filip Date: Wed Jul 14 21:46:20 2004 +0000 Multiple OSPF areas can be attached. Origination of summary LSA works. Routing table calculation works. Virtual links works. Well, I hope, OSPF is fully compatible with RFC2328!!!! commit a417ad13a117d2458702cbec4aa418ba99981611 Author: Ondrej Filip Date: Tue Jul 13 23:42:14 2004 +0000 Send hello just after interface is up. This makes the adjacency forming faster. Minor code clean up. commit 897999c22a85499e4e8a476e27469201645012fb Author: Ondrej Filip Date: Tue Jul 13 23:31:37 2004 +0000 Send hello as soon as possible after the interface is up. This helps to faster establish the adjacency. commit 490767adfce6207012f54f004babcb2aef7f33f8 Author: Ondrej Filip Date: Tue Jul 13 22:10:14 2004 +0000 Add more reasonable options to LSAs. (But it seems, that it's ignored.) commit fe1489e6c13a405b0c76c36213af4017dd4ea2ec Author: Ondrej Filip Date: Tue Jul 13 22:04:57 2004 +0000 Bugfix: Router was unable to advertise AS external routes. commit 62eee82321a9a0451eea9b41a478444ceb87ecb0 Author: Ondrej Filip Date: Tue Jul 13 21:27:33 2004 +0000 Default tick = 1. The today's CPU is fast enough. commit 35fdf4b6a2c3d8ad11be3a7d2525d653237fa3bf Author: Ondrej Filip Date: Tue Jul 13 21:22:32 2004 +0000 Don't inform us about every ospf_age() commit 16c2d48d8fe10521fd493886cf245c75d843fc69 Author: Ondrej Filip Date: Tue Jul 13 20:53:56 2004 +0000 Bugfix - RIP now updates routes with worse metric. commit bc956fcab678f591137cba2a0ebe80c0812437db Author: Ondrej Filip Date: Tue Jul 13 14:46:14 2004 +0000 MD5 authentication in OSPF works. :-) commit 32d3228d864cb6af8c679a7742f4b0a71c2facc0 Author: Ondrej Filip Date: Tue Jul 13 13:52:54 2004 +0000 Bugfix in simple authentification. commit 12dd8dc8779c13889a6860b769df7e0d68e7764c Author: Ondrej Filip Date: Tue Jul 13 12:21:24 2004 +0000 Bugfix - nasty bug in router LSA origination - Router did not describe all interfaces. commit 621ccdfe5acd2889956ec0f8e96b812acd09f168 Author: Ondrej Filip Date: Tue Jul 13 11:58:50 2004 +0000 Bugfix - options bits were not included in LSAs Bugfix - E bit was not unset on stub areas. commit 9baece57d308d9e0d8eaab9d068471e1884817b8 Author: Ondrej Filip Date: Thu Jul 8 16:56:49 2004 +0000 Syntax bugfix. commit 69b27ed6fd7794d36852764319e4dad19d4b6f87 Author: Ondrej Filip Date: Thu Jul 1 15:01:44 2004 +0000 Length calculation bugfix. commit 02ad2737fd24573d870a5009a624c9b3c49aa176 Author: Ondrej Filip Date: Thu Jul 1 15:01:26 2004 +0000 Password WALK_LIST bugfix. commit bc4ea680cea9eca46cd2c5f41db91c3014f90167 Author: Ondrej Filip Date: Thu Jul 1 15:01:04 2004 +0000 Hello reading bugfix. commit ea357b8b6de387a55930a3fc831b8ccbcef24582 Author: Ondrej Filip Date: Sat Jun 26 22:52:39 2004 +0000 Update of the documentation. (passwords and md5). Option for md5 auth in config. commit 3e2bd0f17aab3d2bd460d5f7aef4d3bc152ea1ab Author: Ondrej Filip Date: Sat Jun 26 20:15:34 2004 +0000 Md5 authentification added (unsested). Packet receiving clean up. commit 5236fb03afecd3d7a6ec6e96712c79a31be32132 Author: Ondrej Filip Date: Sat Jun 26 20:11:14 2004 +0000 Password management redesigned (untested). commit 98ac61766d81d9f20c4a7c7e12859c3b82b24f4c Author: Ondrej Filip Date: Fri Jun 25 16:39:53 2004 +0000 A lot of changes: - metric is 3 byte long now - summary lsa originating - more OSPF areas possible - virtual links - better E1/E2 routes handling - some bug fixes.. I have to do: - md5 auth (last mandatory item from rfc2328) - !!!!DEBUG!!!!! (mainly virtual link system has probably a lot of bugs) - 2328 appendig E commit 5ed68e46d781f8a14d3ef3ffd7fe3afc4a62260e Author: Ondrej Filip Date: Wed Jun 23 23:59:48 2004 +0000 Small typo changes. commit 973cf09c3b311691d063a00f52be7e9b8bdec376 Author: Ondrej Filip Date: Wed Jun 23 21:36:55 2004 +0000 Hotfix to problem with metric change reported by Luca. commit 3fe5f8990764b33cc0245317e90fbbcd0cde84de Author: Ondrej Filip Date: Wed Jun 23 21:34:26 2004 +0000 P->magic used just in LOCAL_DEBUG mode commit 09e4117cc19dd94efbdad6edde9bc7d715a58a9a Author: Ondrej Filip Date: Fri Jun 18 12:54:53 2004 +0000 sk_write bugfix for BSD. commit b4d8a0c280d34e6164a88d0e2f9ebf16fd5a1d68 Author: Ondrej Filip Date: Wed Jun 16 23:01:49 2004 +0000 Some cisco routers send shorter ospf messages in larger packets. Well it's strange, but, actually it's correct. commit 1a61882d370e6aef99ebc11d6bbc4e9dc48c6b95 Author: Ondrej Filip Date: Fri Jun 11 09:36:50 2004 +0000 Better routing table calculation. We are ready to work with multiple OSPF areas. commit b1f7229ad7d0b10fcc1fde6645c8b8ebbb3644a6 Author: Ondrej Filip Date: Fri Jun 11 09:34:48 2004 +0000 Better adjacency building, some minor bugfixes. commit 9a4b87905d727a518af04c16b8d7b603404098b7 Author: Ondrej Filip Date: Fri Jun 11 09:06:08 2004 +0000 Deleted RTS_OSPF_BOUNDARY commit 8bf684eca2de6ffd9ba797cad485e36db0b9548f Author: Ondrej Filip Date: Fri Jun 11 09:05:06 2004 +0000 RTS_OSPF_BONDARY is nonsense, RTS_OSPF_IA must have smaller id than RTS_OSPF_EXT commit 7df86c25fc6c871795265faebe02bf4dcecdd190 Author: Ondrej Filip Date: Wed Jun 9 12:39:49 2004 +0000 Better checking of configuration. commit b7e9c74cba36ed6932dbc30a4b9b0b9f9a06dba5 Author: Ondrej Filip Date: Mon Jun 7 16:51:23 2004 +0000 Used parameter can be marked as unused. :-) Thanx MJ. commit e02652a7d2e1f9bb599dbf9fa5862f03f4188efa Author: Ondrej Filip Date: Mon Jun 7 16:42:48 2004 +0000 Bugfix in RT calculation. commit 6721e2862bf69d3af7dd643cd9f442b76e134d5b Author: Ondrej Filip Date: Mon Jun 7 14:38:35 2004 +0000 Build and run both IPv4 and IPv6. commit ff61673427370c71d0a5f2d0d838f00ff46bbda1 Author: Ondrej Filip Date: Mon Jun 7 14:37:29 2004 +0000 Delete automate*cache. commit bf1b1b605b26202466f58b0572db5918acf8cf22 Author: Ondrej Filip Date: Mon Jun 7 13:07:12 2004 +0000 Let's go for release. commit 541cbe97633281b273ade8045b77834a5b6a1db4 Author: Ondrej Filip Date: Mon Jun 7 12:52:32 2004 +0000 It was too verbose. commit c90ac711bc5d1989dcb093088c74d062b43e9914 Author: Ondrej Filip Date: Mon Jun 7 10:42:24 2004 +0000 Cleanup in show route import

. commit 282997f21e6d40c840433128b198a19e9fdf41fb Author: Ondrej Filip Date: Mon Jun 7 10:00:29 2004 +0000 Some new warnings eliminated. commit 19d9e3033661b49cd4e4771166c45db2f1f24805 Author: Ondrej Filip Date: Mon Jun 7 09:52:15 2004 +0000 Marked unused parameters as unused. commit fb257e43fc23f9e0455444ef67c4be0dae22a713 Author: Ondrej Filip Date: Mon Jun 7 09:09:14 2004 +0000 Deleted some unused code. commit 5e3436d20ffdd95a164ffcb82f584fad76fb94e7 Author: Ondrej Filip Date: Sun Jun 6 19:53:52 2004 +0000 Cleanup in packet.c. Deleted unused parameters. commit d5d9693ce90c190ca7358b4ac71b9d034603a3ae Author: Ondrej Filip Date: Sun Jun 6 18:45:08 2004 +0000 Deleted unused parameters. commit e677d04aeb19e26da30e6a3ae94ad6e183d7af8e Author: Ondrej Filip Date: Sun Jun 6 17:20:16 2004 +0000 RPM is now able to build IPv4 and IPv6 bird. commit 41c8976e29bbf2986b063d1a8c5c8b386fae500e Author: Ondrej Filip Date: Sun Jun 6 17:05:25 2004 +0000 Test old instance of BIRD. commit cd09226078471cf9a2db4e755fbd5f6f137137c9 Author: Ondrej Filip Date: Sun Jun 6 17:03:56 2004 +0000 Be sure, that ospf_area is aged before routing table calculation. commit 933bfdde2a0bc4e31e74a3f9e03174b0287c03fb Author: Ondrej Filip Date: Sun Jun 6 16:14:57 2004 +0000 Keep al lSAs invalidated. commit 54a2178fd4c16189e7e0140c0a885b2cd6d2025e Author: Ondrej Filip Date: Sun Jun 6 16:05:14 2004 +0000 TODO updated. commit b8f17cf1923ff5894b6689479f7fb7d008b8ce44 Author: Ondrej Filip Date: Sun Jun 6 16:00:09 2004 +0000 Small cleanup, indentation and preparation for multiple areas routing table calculation. commit d631698ec8a63270f7ca9bc069508d1313a08f92 Author: Ondrej Filip Date: Sun Jun 6 14:27:11 2004 +0000 Indentation. commit d8d553cadfecab2a2f3d8a69624b5a743bd97ce3 Author: Ondrej Filip Date: Sun Jun 6 14:25:55 2004 +0000 This warning is stupid. commit 2e10a170fe70e405b5d6cb2cb53cd9a15de25b73 Author: Ondrej Filip Date: Sun Jun 6 09:37:54 2004 +0000 Indentation. commit 66261211a9c9abd5e1591f0875d16da1e3975fcb Author: Ondrej Filip Date: Sun Jun 6 09:13:37 2004 +0000 Struct area_net changed. commit b9ed99f738c10c0576a9ab8a70b028a92d0d74a7 Author: Ondrej Filip Date: Sun Jun 6 08:55:33 2004 +0000 Cleanup in iface.c commit a5918961f3a62c55857f811f712f861fa3d35d4f Author: Ondrej Filip Date: Sun Jun 6 08:12:42 2004 +0000 Be more verbose in troubles. commit 66004c91a89479abd3df89404afff62c5d60d4c3 Author: Ondrej Filip Date: Sat Jun 5 15:02:52 2004 +0000 Set size of the buffers. (Thanx MJ.) commit 9831e5916f6956377739f948869d377b091f5c92 Author: Martin Mares Date: Sat Jun 5 09:58:23 2004 +0000 Staticized lots of local functions. commit 598b984d1f04ea71fc04bc89f390f230a3960680 Author: Martin Mares Date: Sat Jun 5 09:58:06 2004 +0000 One less unused variable. commit 2f6de49f8c4d9c7ebd12554d386037e5b063beda Author: Martin Mares Date: Sat Jun 5 09:57:49 2004 +0000 Better prototypes. commit 54c411f6afeafb88649c565d252ab0245266eeee Author: Martin Mares Date: Sat Jun 5 09:57:35 2004 +0000 Add more warnings if --enable-warnings is turned on. (probably requires gcc-3.0 or newer, but I hope it's OK) commit 189dab54a211d2d92148d2aae7130df3a080e7c8 Author: Martin Mares Date: Sat Jun 5 09:29:38 2004 +0000 `defaut' should be `default'. commit 1512813e95a7edd2fad2834221dc1cb79aab6406 Author: Martin Mares Date: Sat Jun 5 09:28:17 2004 +0000 ... and a whole bunch of unused parameters and variables in ospf. commit c91fc9b6064e988e7526ecedd6b9e25f0204c4b7 Author: Martin Mares Date: Sat Jun 5 09:27:49 2004 +0000 ... and in rip (there are even unused functions!). commit 662faa4afc4d2f29bb884d0c7ad0aca9fc7de7c9 Author: Martin Mares Date: Sat Jun 5 09:27:35 2004 +0000 ... in pipe. commit e21423bab8a7cfc1cf5d13ab77ebebfae8ce156e Author: Martin Mares Date: Sat Jun 5 09:27:17 2004 +0000 ... in BGP. commit fab37e81971a08b550c6d63ff11f0bf34f0a9aa2 Author: Martin Mares Date: Sat Jun 5 09:27:02 2004 +0000 One more in the library. commit 6ecd20605c62e91069ecd014374836d8392ae948 Author: Martin Mares Date: Sat Jun 5 09:26:55 2004 +0000 ... and in the filter. commit d7390312d4e322e0dac3fefddd6033cb255933a4 Author: Martin Mares Date: Sat Jun 5 09:26:48 2004 +0000 Unused parameters in the client. commit 6578a60493f9dbf83d6485ac99635094bef2af7d Author: Martin Mares Date: Sat Jun 5 09:11:07 2004 +0000 Marked unused parameters in sysdep code as such. commit 7c103b1ee17a274fa062fcf4b14234b48db8123a Author: Martin Mares Date: Sat Jun 5 09:10:56 2004 +0000 Marked unused parameters in core code as such. commit e98bc2ea9b957287e78bc51e3293fc48a49c26b2 Author: Martin Mares Date: Sat Jun 5 09:05:12 2004 +0000 Renamed log() to log_msg(), but still keeping the old name as a macro. This is done to avoid clashes with gcc-3.3 which has built-in logarithms :) commit 5da8f82feb14512725e09664f6db96f03e3ece8f Author: Martin Mares Date: Sat Jun 5 09:01:12 2004 +0000 A better comment. commit c33d4cad9fbfb0b2a4b3ee699943d9955bcd9e3e Author: Martin Mares Date: Sat Jun 5 08:59:17 2004 +0000 Moved the tests for socket existence here. BTW, where do you exactly set the new buffer sizes? commit 4da25acb0ab964826f133025493a9b80d8bef509 Author: Martin Mares Date: Sat Jun 5 08:56:43 2004 +0000 Cleaned up sk_reallocate() and friends. Also, removed the `if (s)' test, because I believe that as the whole socket interface doesn't accent NULL pointers, sk_reallocate() shouldn't be the only exception. commit c6bdc78befaf5ae9e5e3c58a8df1301d5cafd4e7 Author: Ondrej Filip Date: Fri Jun 4 21:19:47 2004 +0000 Be more verbose. commit 6f3203fabf30b0e5ca7d41b4550efbc5df0b421a Author: Ondrej Filip Date: Fri Jun 4 21:05:43 2004 +0000 cleanup in lsupd.c, indenting, "struct proto" removed... commit 9b7de4c4d13a5701aac446627672e65fce9e1a9d Author: Ondrej Filip Date: Fri Jun 4 20:41:02 2004 +0000 'struct proto' removed Finally, I found the bug reported by Andreas Steinmetz. FIXED. commit 54467ed46b31e29215e50d32b0a757998de29793 Author: Ondrej Filip Date: Fri Jun 4 19:53:36 2004 +0000 Useless logs removed. commit 551e30886d7ed156d3fe98cc9562ffa2c22e4ce3 Author: Ondrej Filip Date: Fri Jun 4 19:21:19 2004 +0000 Bugfix in last patch. commit e7ef86a58cc5393ba764606b0ee6d760e6164f0c Author: Ondrej Filip Date: Fri Jun 4 18:51:29 2004 +0000 OSPF is ready for changing MTU. commit f158bb710b8be65b626f54399c8a5db8df9bd7b6 Author: Ondrej Filip Date: Fri Jun 4 18:24:15 2004 +0000 no comment commit 12bed559ffaccc7093188722899e4ac85521777e Author: Ondrej Filip Date: Fri Jun 4 17:49:25 2004 +0000 dbdes indent an minor changes. commit 85305e5d8f7137dc5ce4572d72e80ad186792b37 Author: Ondrej Filip Date: Fri Jun 4 17:32:38 2004 +0000 typo in README commit 874654076a9e3d2c36a248b3d3a4066dff76276b Author: Ondrej Filip Date: Fri Jun 4 17:31:03 2004 +0000 better log() usage. commit 27f49a2c3c2a86b4822ff1980d751666ed8cee97 Author: Ondrej Filip Date: Fri Jun 4 17:28:41 2004 +0000 lsreq.c indented and small 'struct proto' changes. commit 77539c4471d4b3f19347d2efc99680f815e1c78a Author: Ondrej Filip Date: Fri Jun 4 17:12:27 2004 +0000 hello.* reindented, code cleanup. commit 8e15e048f2e14dcdd9915860feace487e4ae07d5 Author: Ondrej Filip Date: Fri Jun 4 17:05:24 2004 +0000 Deleted useles "struct proto" sending. commit 7a03e29d5c7ff07c907ed0d4c4f1c226eba5941d Author: Ondrej Filip Date: Fri Jun 4 16:56:54 2004 +0000 Better log() usage. commit fb9bf6888c75adb88e5a8818161b89b207cf1f9f Author: Ondrej Filip Date: Fri Jun 4 16:55:53 2004 +0000 Indented. No other change. commit c76ba51a5fc7d61e18213f99d9c09502af0bc192 Author: Ondrej Filip Date: Fri Jun 4 16:30:04 2004 +0000 lsack.c cleaned. Better names for functions and DIRECT acks can be sent in one packet now. commit 28de5133ecdcb5b45dc251123047164fbb940e50 Author: Ondrej Filip Date: Fri Jun 4 15:45:35 2004 +0000 ackd_timer_hook moded to neighbor.c commit d03e8ce00b8fea374bbc06a4eb5254e911557e83 Author: Ondrej Filip Date: Fri Jun 4 15:26:46 2004 +0000 Fatal bug found. Sometimes BIRD did not originate router LSA. FIXED. :-) commit b90f9c526e553f1c30b9b177fc72c382ab333fc7 Author: Ondrej Filip Date: Fri Jun 4 14:23:58 2004 +0000 Initialize iterator on the right place. commit 18b40a40726bf6ec03e496a068faa8d173c27dd8 Author: Ondrej Filip Date: Fri Jun 4 14:23:21 2004 +0000 This can happen now. commit f9fdabe4f68685e6244e88524b2526958c56e44d Author: Ondrej Filip Date: Fri Jun 4 14:22:30 2004 +0000 Small reversing of previous patch. commit 3df1e80464ce5e6cea1b9a9500d1adbfe59cd564 Author: Ondrej Filip Date: Fri Jun 4 14:21:08 2004 +0000 Don't repeat "Sheduling rt calc....." commit d6c28f3ada7d2da8e762a1ed8e4fb70dfce2ca6f Author: Ondrej Filip Date: Fri Jun 4 14:03:30 2004 +0000 Code and comments cleanup. commit 39e517d47c6070dd81bb7d6f57358ea98e462f03 Author: Ondrej Filip Date: Fri Jun 4 12:53:10 2004 +0000 hello.c and hello.h cleaned up. No design changes. commit 591656cdd5b13a4626dfb26e45dd02690cdb450c Author: Ondrej Filip Date: Thu Jun 3 08:18:49 2004 +0000 Added source addr for multicast socket. commit 7d72aadb8acfac16e9b637e6ebb5ce288ebf1d77 Author: Ondrej Filip Date: Thu Jun 3 08:18:14 2004 +0000 CONFIG_SKIP_MC_BIND added. BSD hates it, Linux needs it. commit cb4dd4e2f78f806438bfb8163b783ac7b2f43b2d Author: Ondrej Filip Date: Wed Jun 2 15:14:49 2004 +0000 Deleted useless rfree. (Socked was freed by cli_free()) commit 9b133458891724da2fd22f2a16ae19376e225ca0 Author: Ondrej Filip Date: Wed Jun 2 09:14:03 2004 +0000 Hotfix for router's parent without nexthop. It will probably work perfect, but I need to eliminate such situation. commit f9625e9acabbdc5834f528e6fe1b87b8f4ce4968 Author: Ondrej Filip Date: Tue Jun 1 14:06:25 2004 +0000 Bugfix in external routes calculation. commit 7048461df113b335b9cfc56c517bc5802ef7b6c8 Author: Ondrej Filip Date: Tue Jun 1 13:58:39 2004 +0000 Code clean up. commit e8bf6c0766dba95c4b7ebb8b29dad31392f212b7 Author: Ondrej Filip Date: Tue Jun 1 13:44:53 2004 +0000 Easier cleanup of an interface. commit c9f6cf8a05aba6a79bfb57120ca48adcf8e3949d Author: Ondrej Filip Date: Tue Jun 1 13:29:08 2004 +0000 Don't free socket's resources. commit 035f6acbfec1e06a207217ae81153b67ced995f3 Author: Ondrej Filip Date: Tue Jun 1 13:12:10 2004 +0000 Patch from Andreas Steinmetz commit 8281ff201e1eebe35cb8e7716565361bed77a6cd Author: Ondrej Filip Date: Tue Jun 1 12:57:13 2004 +0000 Reverting last patch. commit 77772dbc6555dfb9aa76c812bcd1792ab503cbe1 Author: Ondrej Filip Date: Tue Jun 1 10:55:10 2004 +0000 Caching loopback interface. commit a8bb459a3f8769501726ef25e696ea127014383f Author: Ondrej Filip Date: Tue Jun 1 10:53:30 2004 +0000 log->DBG commit 1554cc02826794007c113bc336ed574bb771343f Author: Ondrej Filip Date: Tue Jun 1 10:45:28 2004 +0000 Minor changes caused by MJ's comment. commit b613b9928bdb1df3bd541d318d7f9c1bf492dfbc Author: Ondrej Filip Date: Tue Jun 1 10:32:02 2004 +0000 #ifdef CONFIG_UNIX_DONTROUTE added. commit 7fdd338c3600aa4e7a0ae3d5ce270b5a1f8ccc0c Author: Ondrej Filip Date: Tue Jun 1 10:28:25 2004 +0000 ALIGN -> BIRD_ALIGN commit 22122d4d4c43c2c64a37aae597b4d439a6bfa268 Author: Ondrej Filip Date: Tue Jun 1 10:10:09 2004 +0000 Now, only one AC_OUTPUT is used. commit 402a9fa78a9849dbbefcbea81cd9cf7c8ab87c22 Author: Ondrej Filip Date: Tue Jun 1 09:10:11 2004 +0000 Useles log()s deleted. commit e85bd57a0e106c7ae3fc44dccf9bac89e2f9939e Author: Ondrej Filip Date: Tue Jun 1 09:07:16 2004 +0000 bzero has 2 arguments. commit b88a1d4040df6bcd49eefe1c2c1ba8fa66ad0d43 Author: Ondrej Filip Date: Tue Jun 1 08:59:47 2004 +0000 memset -> bzero commit fa643be1cc6973923a46ac52a20ccec2ec5e3f18 Author: Martin Mares Date: Mon May 31 22:24:42 2004 +0000 Updated the distribution script. commit bb68ad2fd34dc6ab8723ae1c9c37f9dc19ed85ea Author: Martin Mares Date: Mon May 31 22:22:21 2004 +0000 Documented the pxlen parameter. commit 3810eccf6bc5af413d883fd298d59e0d7bdb96ea Author: Martin Mares Date: Mon May 31 22:16:54 2004 +0000 Added a simple utility for converting CVS log messages to a reasonable changelog format. commit ea0ac8f69aec4eff8109eb3d74cc0ca5a330fa58 Author: Martin Mares Date: Mon May 31 22:00:18 2004 +0000 Move CLI socket to the newly created CLI's pool. (thanks to Andreas for the original idea) commit 38a608c55af7654f23c9a16129ab6211aac3b7ab Author: Martin Mares Date: Mon May 31 21:48:19 2004 +0000 Rewritten the I/O loop. All socket operations are now safe, meaning that you can delete the socket from anywhere in the hooks and nothing should break. Also, the receive/transmit buffers are now regular xmalloc()'ed buffers, not separate resources which would need shuffling around between pools. sk_close() is gone, use rfree() instead. commit 206f59dfa8e59e32f4aef12dacb0804581b9f602 Author: Martin Mares Date: Mon May 31 21:02:09 2004 +0000 Added UNUSED. commit 6a57bb311018570b6ee7beccafd2075108e346cb Author: Martin Mares Date: Mon May 31 20:57:38 2004 +0000 Killed a couple of unused variables. We really should compile with warnings enabled. commit d83faf8dc441259183d87c6669e76e4addc61b21 Author: Martin Mares Date: Mon May 31 20:53:22 2004 +0000 static declarations don't belong to includes. (And most of them were redundant anyway.) commit 7deffd845a0f2bfe4cebbb01e0505314af32693a Author: Martin Mares Date: Mon May 31 20:51:45 2004 +0000 Need for tcdrain(). commit 9f387e11a319ea55104c6e8362f9820bf1b00097 Author: Martin Mares Date: Mon May 31 20:49:11 2004 +0000 Make the check for work with recent libc's. commit 0757bcb728c8bd56fa03ea296862d62e05f6ba09 Author: Martin Mares Date: Mon May 31 20:35:19 2004 +0000 One space more. commit 2cc37815ae1f194c5a0c51e5761377caea9cc164 Author: Martin Mares Date: Mon May 31 18:47:19 2004 +0000 Added rmove() (by Andreas, tweaked by me). commit 0077aab4f9041e4d05d2d6916edfb0e15738cb37 Author: Martin Mares Date: Mon May 31 18:16:42 2004 +0000 The code was broken for external /29 to /32 routes. Assuming that you have one machine publishing a route to 10.1.1.3/32 and another one publishing a route to 10.1.1.4/32. If the first machine went down the route to 10.1.1.4/32 was wrongly killed by the old code, leading either to missing routes or worse to bug()s like "Router parent does not have next hop" or just segfaults. The patch fixes this but in the long term a redesign is required here. Note that the patch doesn't worse the situation, instead it prevents the problems stated. The redesign is required to handle multiple routes to small subnets properly. (by Andreas) Feela, I think that this is at least a good temporary fix, but it's of course up to you to decide. commit 4ef3dccfa112faddf79fed76a539353b705702b5 Author: Martin Mares Date: Mon May 31 18:13:14 2004 +0000 The OSPF authentication type was sent in host byte order instead of of network byte order thus breaking interoperability with other routing daemons on litte endian machines. The patch fixes this but note that this breaks compatability with older bird installations using OSPF and password authentication (Andreas) commit 3cb96cd343196baabf847f5d670711162e66e298 Author: Martin Mares Date: Mon May 31 18:11:16 2004 +0000 The initial sequence number for RIP md5 authentication was always zero. Bad as when bird e.g. was running for two weeks and then restarted it would take another two weeks until the peers of this router would accept data again from this router, as the sequence number would be too low. Changed to use the the current system time as the starting sequence number which is a more sane start value. (by Andreas, cleaned up by me) commit 277a34eff195fe39a63db59731f5f2c8d54abdb2 Author: Martin Mares Date: Mon May 31 18:08:50 2004 +0000 Small correction to va_start/va_end in cli_printf (va_end was missing). (Andreas) commit 5f2a6a9ff324d846c86ffafb60ae5a4c01d06313 Author: Martin Mares Date: Mon May 31 17:55:30 2004 +0000 Fix handling on full pipe to client in bird. Prevent packet overflows for even only medium sized route table output. Fix a strange garbled output problem in the client. The latter seems to be caused by some library doing tcflush while there is still command output pending. So the best fix here is to do fflush and then tcdrain. Note that this problem occurs only under certain load situations and is not too easy to reproduce. (by Andreas) commit a4ffe2739d1a3efb45f209b63b2b6faa558e43a9 Author: Martin Mares Date: Mon May 31 17:53:02 2004 +0000 Bird's control socket should be in /var/run and the convention for --localstatedir is /var. The control socket pathname creation is thus corrected here. (Andreas) commit 03e3d184b2d8fac4c82408b1ac1738cb7af5680e Author: Martin Mares Date: Mon May 31 17:44:39 2004 +0000 Fix bison input for current build tools, otherwise bison or the compiler will abort the build. (by Andreas) commit 4a02013767ab05b9cf7567c09e5fad59c9bd1c10 Author: Martin Mares Date: Mon May 31 17:42:38 2004 +0000 Make RIP nolisten mode actually work. The socket is required for sending, the received data has to be discarded instead. (patch by Andreas Steinmetz modified by me) commit 1bd897dd33a49bd03f661e84687f8bba25af2983 Author: Ondrej Filip Date: Mon May 31 17:27:21 2004 +0000 Changed of comments. commit 10af3676ea4268452776acd7b06a95c72d71f2e0 Author: Ondrej Filip Date: Mon May 31 17:16:47 2004 +0000 Grrr, committing too fast. #include "alloca.h" -> #include "lib/alloca.h" commit 7dbd4fd332bb614db858944da86b29c86d9b1d81 Author: Ondrej Filip Date: Mon May 31 17:13:58 2004 +0000 alloca.h added commit 0e6eef620d4b838fc558711cd2d5572ec7a576c2 Author: Ondrej Filip Date: Mon May 31 17:07:05 2004 +0000 Use #include "alloca.h" commit c222500d8e098f0504405724b56676a2efc0861f Author: Ondrej Filip Date: Mon May 31 17:00:22 2004 +0000 Previous change was mistake. commit 6f18235aad187ed9e2afbb166b34c5cc3765b430 Author: Ondrej Filip Date: Mon May 31 16:42:12 2004 +0000 Useless include deleted. commit f54fa9e15dce42b8c80b7ea95ab2653cc5be4e4e Author: Martin Mares Date: Mon May 31 16:10:01 2004 +0000 Updated copyright notices. Also testing whether syncmail works. commit 73219ecfecbf2851e1a3b6c4a1084b2eaa6d159c Author: Ondrej Filip Date: Mon May 31 15:13:56 2004 +0000 Delete autom4te.cache in 'make distclean'. commit 6de62923120c1dba8461aed8aed95eff433fcf4a Author: Ondrej Filip Date: Mon May 31 15:08:29 2004 +0000 Better readline checking. commit 012279f395a7cb87a3085b6c4674777da7ee9661 Author: Ondrej Filip Date: Mon May 31 13:59:03 2004 +0000 Some include added. commit d93fb7e6b9a1d2964bc926ca9ed7ab11f5003c1d Author: Ondrej Filip Date: Mon May 31 13:58:38 2004 +0000 #ifndef ALIGN - it is defined on *BSD commit a60277b9997a891fdc5d62e07ac96885c009f531 Author: Ondrej Filip Date: Mon May 31 13:35:06 2004 +0000 Added RTD_NONE /* Just for internal use */ commit 0c745adc8003ac816be15e2246fa4685e127d120 Author: Ondrej Filip Date: Mon May 31 13:34:20 2004 +0000 #ifdef ALLOCA_H commit bd62eeca27aba7da34a65a8f039d1b011115ddca Author: Ondrej Filip Date: Mon May 31 13:32:58 2004 +0000 Small change to compile client on FreeBSD. commit b1a1fabac70201e9b05aeb9fd6af703f0fbffdb4 Author: Ondrej Filip Date: Mon May 31 13:25:00 2004 +0000 *BSD port added. (Tested on FreeBSD and NetBSD) commit 781aa475aaa7503d4a86f0d4b8771cd027d30c04 Author: Ondrej Filip Date: Mon May 31 13:22:49 2004 +0000 Minor bug fix in neighbor state machine. commit de259a41e3175d4080d5a33a39f0279308a25b56 Author: Ondrej Filip Date: Mon May 31 10:38:44 2004 +0000 Minor bug in configuration. commit 7cb37e6fd2d9fb5723d6f680d0e064e4ba9c6091 Author: Ondrej Filip Date: Mon May 31 10:26:18 2004 +0000 Added some more test (alloca.h, sa_len) etc. Add AC_OUTPUT before AC_OUTPUT_COMMANDS commit caeb02ea19b8b3b04bc9705d5270954bfc21cab6 Author: Ondrej Filip Date: Wed May 19 12:30:58 2004 +0000 Bug in DBDES receiving fixed. commit 502ded521508a402910b2bf8f23f2e34f79f91cb Author: Martin Mares Date: Sat Dec 6 16:41:11 2003 +0000 Fix reporting of RIP socket errors. Thanks to Eric Leblond for the patch. commit 37299f1e442f5ca23fd9124d9645096c5a6f7536 Author: Ondrej Filip Date: Tue Sep 30 17:05:55 2003 +0000 OSPF was not able to be built stand-alone. commit 00bd27a1cc8eee6df626a7441cc548e82bf42c4c Author: Ondrej Filip Date: Sun Sep 14 13:41:24 2003 +0000 Endianity problem fixed. Thanx to Sörös József commit 35a86ceb4082d8d31e6949f8d454eaa28c498a86 Author: Ondrej Filip Date: Wed Sep 3 17:31:23 2003 +0000 This prevents infinite loop when bird has more that 60 neighbors. Thanks to Rani Assaf commit bf135bcb1feca7b9ee35342c239ed3a66415d854 Author: Ondrej Filip Date: Mon Sep 1 08:46:07 2003 +0000 Prepared for release 1.0.8. commit c11007bc423188872d37e277fe4637094a40d90f Author: Ondrej Filip Date: Tue Aug 26 10:41:02 2003 +0000 Endian-related bug fixes sent by Krzysztof Szuster commit 1d1a3c1c2a72ef91b785f5ed08ca5ab3f001b14e Author: Ondrej Filip Date: Sat Aug 23 10:47:46 2003 +0000 Minor OSPF changes for faster startup. commit baa5dd6ccc14eb6bc43fad37a2bfe88ad190c0fa Author: Ondrej Filip Date: Sat Aug 23 10:42:41 2003 +0000 Many spelling mistakes fixed. Thanks you Harry Moyes. commit c197d44e1790ab1738cf9e438c2c91bd74e9b94e Author: Martin Mares Date: Wed Aug 13 22:07:55 2003 +0000 This probably IS the memory leak we're looking for. Alien routes weren't correctly disposed of. commit 13b75bacf7221eb655dcbed54e3c3605bea5169e Author: Martin Mares Date: Wed Aug 13 20:04:39 2003 +0000 protocol->import_control() could potentially call rte_cow() as well. AFAIK it doesn't happen in any of our protocol, but better be sure. commit 2adab6ae9cc586871a8854e51452839cb1dd1db0 Author: Martin Mares Date: Wed Aug 13 19:31:22 2003 +0000 This was a potential memory leak, but not the one Feela observed. This one could happen when an import filter of some protocol modified the rte (so that it would be rte_cow()ed) and later rejected it. commit b77834b3f41e551adc045d23f387533d428349ae Author: Martin Mares Date: Sun Apr 6 21:36:35 2003 +0000 Slept for a year :-) commit c153ee91373438095ae6ec18e2dfb9f334d2dfe6 Author: Martin Mares Date: Sun Apr 6 19:52:22 2003 +0000 Nobody is perfect. Me twice :) commit 8edd56bded8ffc7fabbce690133892de6dcd5f62 Author: Martin Mares Date: Sun Apr 6 19:49:17 2003 +0000 Oops, forgot to change some paths. commit d02b7a738eb94d031b106319f3af259717c80fe0 Author: Martin Mares Date: Sun Apr 6 19:49:02 2003 +0000 More news. commit f2c642e0e5c266f8b955cfa5aec785c3f96c5ed5 Author: Martin Mares Date: Sun Apr 6 19:46:42 2003 +0000 We're 1.0.6 now. commit 0e41e34a231198498289e367b93b3e9b99d5eb2e Author: Martin Mares Date: Sun Apr 6 19:45:55 2003 +0000 Avoid problems with copying a directory to itself. commit f240a133b32db88c98ad5a7f9d72fdb909311af6 Author: Martin Mares Date: Sun Apr 6 19:42:28 2003 +0000 Releasing version 1.0.6. commit 9c7631235ac174ebd33a3e04e07211b3ae8501f6 Author: Martin Mares Date: Sun Apr 6 19:35:50 2003 +0000 Updated the documentation building tools to work with a recent linuxdoc-tools package. Note that this is (and always was) a terrible hack and we really should replace it with something reasonable which wouldn't need changing every time linuxdoc-tools evolve. I also needed to include a patched version of LinuxDocTools.pm, because the original one explicitly refused to work with a non-linuxdoc DTD. The authors of linuxdoc recommend to use sgmltools-lite in such cases, but it would mean rewritting our formatting rules to the DSSSL language which I don't dare to speak about here :) commit a9aa5887f3b9b43d9a3a5617ef9176da936ce35f Author: Martin Mares Date: Sun Apr 6 18:55:37 2003 +0000 Added release history. commit 8cf76fa8536e52a5c90d500ac1d74f49d87e905d Author: Martin Mares Date: Sun Apr 6 18:38:01 2003 +0000 Bug fixes to authentication code by Eric Leblond . commit d85e1f0e2f389d273ff14e89faced390b76d842b Author: Martin Mares Date: Thu Feb 27 10:48:30 2003 +0000 Prefix comparison bug (hopefully) fixed. commit 6ea8ca1469a9c9150a4e0be9f8e6ab025eee990a Author: Martin Mares Date: Sun Feb 23 10:22:04 2003 +0000 Updated a comment. commit abf06173a3d84559dd26d2a78a1e5df9656a4d80 Author: Martin Mares Date: Sat Feb 22 23:06:32 2003 +0000 Current Linux kernels don't remember rtm_protocol for IPv6 routes and supply RTPROT_BOOT instead. Work around that. commit 11d4474c17e76e9811dcb32f555fa1c6f3684fab Author: Martin Mares Date: Sat Feb 22 22:47:45 2003 +0000 Better selection of link-local NLRI addresses, at least for our own address. Need to do it better for the other neighbors -- the current solution works only if they use the standard 64+64 global addresses and the interface identifier in lower 64 bits is the same as for the link-scope addresses. commit 7b7a7b43a6915efbe9180f07cd1284a39efacf02 Author: Martin Mares Date: Sat Feb 22 22:39:06 2003 +0000 There can be multiple primary addresses with different scopes and only the highest scope one has IA_PRIMARY set, so report the remaining ones as "Unselected". commit 8001948b43c9367e86473630f58527249d7da04f Author: Martin Mares Date: Sat Feb 22 22:38:15 2003 +0000 Report link-scope addresses as well. commit 8c92bf6a0ddc21f2fa19c195a73d43837f60fc23 Author: Martin Mares Date: Sat Feb 22 10:40:35 2003 +0000 Temporary fix for BGP protocol capability announcement for IPv6 mode. commit 60a72ed49b36aea732d3584527040a7b3b0e72e0 Author: Martin Mares Date: Sat Feb 22 10:25:22 2003 +0000 Fixed length check miscalculation in IPv6 receive path. commit 47f18ac39a313cf213b43320557239c5d0855a11 Author: Martin Mares Date: Wed Nov 13 08:47:19 2002 +0000 ABS should be a macro. commit 7d875e094bbbb9d4b234e31fe08f31510ac1d7d0 Author: Martin Mares Date: Wed Nov 13 08:47:06 2002 +0000 Added missing includes. commit de10a974f2e2e8a11b6a6852cd770c1096e1c25d Author: Martin Mares Date: Wed Nov 13 08:46:12 2002 +0000 Added missing semicolons. commit 59b96d7b4d8a055aa77917099b358cfc7b5e0731 Author: Martin Mares Date: Wed Nov 13 08:45:24 2002 +0000 Don't use obsolete functions which are no longer declared in the header. commit a19cd811000902facceff5a30facf7dba9cb2095 Author: Martin Mares Date: Wed Nov 13 08:30:56 2002 +0000 Added missing #include and wondering how could it ever compile. commit 19bd5c8e2c0fd47ff27668b8c45acc79f4d703b4 Author: Pavel Machek Date: Sat Sep 21 13:57:48 2002 +0000 Password does not need to be null-terminated, do not print garbage in such case. Thanks to silvio@big.net. commit 4ca0d0847e015bbecf6db3cec8f3ce57c2d8035c Author: Ondrej Filip Date: Wed Apr 3 15:41:05 2002 +0000 Small typo fixed. commit 53a50af50427e2fedc4bbfeca7a5934a798a3827 Author: Martin Mares Date: Sun Mar 10 12:32:12 2002 +0000 Applied Pavel's fix for broadcast/multicast mode. commit e59e310e6435c6c72b585c6f4b5e6c9bbd006553 Author: Ondrej Filip Date: Mon Mar 4 15:54:39 2002 +0000 Age LSA DB after LSA origination and before routing table calculation. commit 025b0e856a85dcae755e97922febc190145ba89c Author: Ondrej Filip Date: Mon Mar 4 15:52:40 2002 +0000 New trace added. commit b78696282de32a202a9bed304f8edf044833f36f Author: Ondrej Filip Date: Fri Dec 7 17:34:09 2001 +0000 Bugfix in router importation. commit 30c34a10797c2773a0b99e71b22f111ee2a7f980 Author: Ondrej Filip Date: Fri Dec 7 17:10:49 2001 +0000 Small bugfix in RIP documentation. commit 8e32493c56a49f10a6949985d5b0bb4dbcbe204d Author: Ondrej Filip Date: Tue Aug 21 17:00:15 2001 +0000 Removed some useless (hope!) code in next hop calculation. commit 68db89a2ce35a96aef827f4e86c5dfd82842f9d7 Author: Ondrej Filip Date: Tue Aug 21 16:44:57 2001 +0000 Finally, next hop problem fixed. commit 37da55168cdb0f562266eff4b821f6e576d93931 Author: Ondrej Filip Date: Tue Aug 21 15:03:42 2001 +0000 Useless trace. commit e8ab16803065894497dd306c941b0815fac5b25a Author: Ondrej Filip Date: Tue Aug 21 15:00:29 2001 +0000 Hope, bug in next hop calculation for stub routes fixed. commit e43ae6330eaf349eafe6820465c85266eef80e07 Author: Martin Mares Date: Sun Aug 19 11:15:24 2001 +0000 Fix %I format strings. commit 30b773041c37d10649a16d5f28af00a25871aac7 Author: Martin Mares Date: Sun Aug 19 11:11:44 2001 +0000 IP address formatting now uses the same rules as formatting of strings with two exceptions: o Any non-zero field width is automatically replaced by standard IP address width. This hides dependences on IPv4/IPv6. o %#I generates hexadecimal form of the address. Therefore |%I| generates unpadded format, |%1I| full size flush-right, and |%-1I| full size flush-left format. commit 16319aebd30da5161bed95d72094250228a7f61c Author: Ondrej Filip Date: Sun Aug 12 00:09:47 2001 +0000 Dokumented switch network. commit c926eee72471d8127ff833548b0ce1f8cb6de276 Author: Ondrej Filip Date: Sun Aug 12 00:04:42 2001 +0000 Area networks added into configuration. commit b2bdb4065667f466575b831f4a3166bd309d9d14 Author: Ondrej Filip Date: Sat Aug 11 16:22:29 2001 +0000 Changed definition of stub area. commit 85062e8a600cc7896b8bcaf3960bb782aa9f2ff0 Author: Ondrej Filip Date: Sat Aug 11 14:40:51 2001 +0000 Bugfix in B-bit setting in router LSA. commit 78e2c6ccf16b41bc19a4cd69f959c8ae47e68b9d Author: Ondrej Filip Date: Sat Aug 11 14:01:54 2001 +0000 I will not originate the same lsa before MINLSINTERVAL. commit 5fc7c5c51344a8cc1fae2cc9077c2c331c1e419a Author: Martin Mares Date: Fri Aug 3 08:44:51 2001 +0000 Don't loop forever when trying to skip an out-sequence netlink reply. commit 24c00cb11915edb8c13dbc21f245a73fc34689ed Author: Ondrej Filip Date: Tue Jun 12 21:10:30 2001 +0000 Install route into main routing table just if it's necessary. commit c48b33292b6d39cdacd642565907c0d5b90adc68 Author: Ondrej Filip Date: Sat Jun 9 15:13:38 2001 +0000 Yes, 1.0.5 released. commit 87c450dffcbcc76270c95b4c923838445cd6816b Author: Ondrej Filip Date: Sat Jun 9 14:56:01 2001 +0000 Added comments. commit e9d3c3aaea24724c285027154bd9f5ddef8394e0 Author: Ondrej Filip Date: Sat Jun 9 14:55:10 2001 +0000 Bug in next-hop calculation fixed. (For dual connected neighbors.) commit ea31425a6191f0b3e181f8a1c7368fc4dfca24b4 Author: Ondrej Filip Date: Mon Apr 9 19:15:03 2001 +0000 Patch from David Rohleder thanx. commit 01b776e117d21ccfef996fd91c014c6e14a458a7 Author: Martin Mares Date: Tue Mar 6 13:40:39 2001 +0000 Fixed vs. problems. commit 27e993fb4ecc310a83da3a74b21b15c32c207a09 Author: Martin Mares Date: Tue Feb 20 09:49:19 2001 +0000 Fixed duplicity in log category numbering. Thanks to Zheng Yuan for spotting this. commit 4d04187465fdeb3fb755b4d01ec640bbe0e36eb9 Author: Martin Mares Date: Fri Jan 19 20:30:08 2001 +0000 Added paper for my talk about BIRD at SLT 2001. commit 0766e962e9a9539ceccd23090e5bb8e1301fce8c Author: Martin Mares Date: Wed Jan 17 08:32:28 2001 +0000 Bug fix from Zheng Yuan . commit a2d01907c5b24bab78cc055fa23354597bd44a03 Author: Martin Mares Date: Mon Jan 15 09:24:16 2001 +0000 Added an explanatory comment. commit 8c6ce98b9d9b5c4970e902cf667c1ffb64f04a62 Author: Martin Mares Date: Mon Jan 8 11:13:01 2001 +0000 Fixed infinite recursion in password_same. Pavel, please check. commit 32749f493fdaea31f70d8586597febacd2c511d9 Author: Ondrej Filip Date: Thu Dec 14 01:04:51 2000 +0000 Hmm, nasty bug, LSUPD was not well flooded via PTP interfaces. :-( commit 501c5bb03fabd3d5721cfd8c82298f729d79e7a3 Author: Ondrej Filip Date: Tue Nov 21 23:47:51 2000 +0000 Small bugfix in ext routes calculation. commit a5096a1bdebe217eb0d04a95489562ac132f4552 Author: Ondrej Filip Date: Wed Nov 8 22:46:54 2000 +0000 Yet another nasty bugfix of iface_patts_equal(). commit 0639f7263a9a73cce6948cad23cd2d4858d36c5b Author: Ondrej Filip Date: Wed Nov 8 17:06:35 2000 +0000 Bugfix in iface_patts_equal. When both patterns were NULL strcmp it sigfaulted. commit 482bbc7396268fce66e8ecb59f248bc51229cdc9 Author: Ondrej Filip Date: Sat Sep 9 19:21:01 2000 +0000 Minor rpm changes to make RedHat happy. commit 52fa3e386948b13b928ff9be778a7de62a00ceb3 Author: Ondrej Filip Date: Mon Sep 4 21:21:34 2000 +0000 Fixed many bugs in rt calculation and interface adding. Now it seems to be OK, I'm going to advertise 1.0.4. commit b02e40111ea8d97bf1c3bfa25970ee0d828cd7bc Author: Ondrej Filip Date: Mon Sep 4 19:42:17 2000 +0000 I allocate struct ifa before unlocking. So route exported to OSPF are correct. I work also with interfaces that have some problems with socket opening. I declare them as stub. commit fdb19982020abeddf2d9eb73efae92ae2cc58d93 Author: Ondrej Filip Date: Sun Sep 3 22:18:40 2000 +0000 Serious bug in ext lsa origination found. Going for 1.0.4. commit f02e4258b9bb7f823ddfbfb88284c868502b1433 Author: Ondrej Filip Date: Sun Sep 3 18:27:21 2000 +0000 Some misspells. commit 43dff480efcc85bf32327b07c3c53c9c68cb3941 Author: Ondrej Filip Date: Sun Sep 3 18:13:00 2000 +0000 Version 1.0.3. commit 19e930a9bbcc2dfdb87c8ada1a54ac4563a0cad6 Author: Ondrej Filip Date: Sun Sep 3 17:53:12 2000 +0000 Version 1.0.3 released. commit f82e9bc3744f9ff5aa05d08a18fd03e46fb08b6f Author: Ondrej Filip Date: Sun Sep 3 16:21:14 2000 +0000 Another atrey->atrey.karlin.mff.cuni.cz commit 1e972b5524ff1ad28f4013632253a851c3559fc9 Author: Ondrej Filip Date: Sun Sep 3 16:16:33 2000 +0000 Log some unusual situation. commit 76460860ece8ce43a42da7cb2342e57f553b646c Author: Ondrej Filip Date: Sun Sep 3 06:54:35 2000 +0000 Small bugfix. (Use atrey.karlin.... instead of atrey.) commit e3bc10fdc49266db827af4e4062e639862037eb6 Author: Ondrej Filip Date: Sat Sep 2 08:54:40 2000 +0000 Added stub interface. (Interface which is propagated to OSPF but it does not sends nor listens packets.) I added some new options, please look at it and look into doc if it's OK. commit 5ddec4e6cfef8e5867d7440693894517f955e96f Author: Ondrej Filip Date: Sat Sep 2 07:58:05 2000 +0000 Reconfigure poll interval. commit 7cedbf217e8ce8a8669f31b1ee38e5f9ccb4eefd Author: Ondrej Filip Date: Sat Sep 2 00:15:07 2000 +0000 Reconfiguration for new options. commit e7e2878b744f415df9fcef291da67975da4dfc29 Author: Ondrej Filip Date: Sat Sep 2 00:14:46 2000 +0000 More examples. commit a190e7200bf37ba834c776a28583bf897b4377f5 Author: Ondrej Filip Date: Sat Sep 2 00:03:36 2000 +0000 Added hellos on NBMA networks. (I don't violate RFC now.) commit 94e2bbcc72f69edbcb3ce66ffa52998f374243c5 Author: Ondrej Filip Date: Mon Aug 28 14:32:11 2000 +0000 Better ospf metric explanation. commit 5a063efeea11a80e865e9fa4b5e13c4ca8514b51 Author: Ondrej Filip Date: Mon Aug 28 13:51:13 2000 +0000 Bugfix in ext lsa importing. commit 8b6b49239f409571486ae9589bcd57f706421517 Author: Ondrej Filip Date: Fri Aug 25 12:26:03 2000 +0000 Minor bug. It does not work on non RH systems. Thanx to Craig Bourne commit 6cf7e97abe05ee8943f8a2d300e1c46038b95df1 Author: Ondrej Filip Date: Thu Aug 24 20:08:00 2000 +0000 Added files for RPM building. commit a24e3157628ade4c0c0c380094bec898b630b2ee Author: Ondrej Filip Date: Wed Aug 23 06:51:26 2000 +0000 Released as version 1.0.2. commit 9e2920824e13739a9169153f0164e6a4fe4adc1d Author: Ondrej Filip Date: Fri Aug 18 16:47:27 2000 +0000 Typo. commit f321a61f77262d33dd43d50136c8116ebf8139c6 Author: Ondrej Filip Date: Fri Aug 18 16:44:37 2000 +0000 Fixed bug in nex hop calculation of external routes. commit 88aa2af7effa3752d033ccab5e18fb1303603585 Author: Ondrej Filip Date: Fri Aug 18 16:36:54 2000 +0000 Just formatting. commit 28a6e1aa0ee17cee6aaad67d7433cb8038062582 Author: Ondrej Filip Date: Thu Aug 17 19:42:52 2000 +0000 Stupid bug in next hop calculation of external routes. commit 1eec76077814fbe06879026809759dd5f5b8655f Author: Ondrej Filip Date: Wed Aug 16 20:18:19 2000 +0000 Typo in rte_better. commit 059fc1e94abcd658e9340313ffd080c5829ba8ef Author: Ondrej Filip Date: Wed Aug 16 19:37:04 2000 +0000 My calculation of external routes violated rfc. :-( commit d6a7e2fb8590660c00e984ff41d2e668d2ead69b Author: Ondrej Filip Date: Wed Aug 16 19:03:06 2000 +0000 Bug in rte_better. commit e7894eceded6ea1f757829a8845863c57660c9dd Author: Martin Mares Date: Mon Jun 26 20:02:30 2000 +0000 Added slides for our presentation, but don't export them to the distribution tarball -- they are in Czech and therefore of no use to almost anybody :( commit 2084109a3734227f0dcc21f3c8915a983ad9d586 Author: Martin Mares Date: Wed Jun 21 22:11:29 2000 +0000 Include CVS ChangeLog in the distribution commit fc12a680b1102ae1b620180417ef8b0272b11bed Author: Martin Mares Date: Wed Jun 21 22:08:46 2000 +0000 Released as version 1.0.1. commit ad3907559c196ee39906d527ea4f3372beb6e6c5 Author: Pavel Machek Date: Wed Jun 21 19:40:46 2000 +0000 RIP bugfix commit 2836ce3951bbdda62c3dddd509669127f46e776d Author: Martin Mares Date: Wed Jun 21 09:58:09 2000 +0000 Check broadcast address sanity before believing it. commit bcbdcbb6ae7256e01165220bb3b2d5b72850f665 Author: Martin Mares Date: Tue Jun 20 07:49:08 2000 +0000 Don't accept incoming connections when the neighbor is not up. commit f9eb8f7e066970d56a814128fd49170348a7fbd8 Author: Martin Mares Date: Mon Jun 19 23:50:02 2000 +0000 If compiled with --enable-debug, don't even try to log to syslog unless the user forces it in the config file. commit 972fdb45323b75af254cfe6c912c52d3596a230a Author: Ondrej Filip Date: Mon Jun 19 15:12:50 2000 +0000 Routing table calculation clean up. commit ca00d4a13a7207da1ea3acf1f0e38ddc27669a4d Author: Martin Mares Date: Sun Jun 18 19:49:32 2000 +0000 Fix numbering of routing tables in IPv6 version. commit 4daf03e5138dea8e5c409ab20a07f35667caa89e Author: Martin Mares Date: Fri Jun 16 23:12:47 2000 +0000 Use our own SUN_LEN if libc doesn't provide it. commit 365211d5886ec59a543e9fbc2151d6218561c18c Author: Ondrej Filip Date: Tue Jun 13 19:03:41 2000 +0000 Bugfix in logging. commit dd44b2ce90950033c5c5419db67a1d53fb177f71 Author: Martin Mares Date: Fri Jun 9 07:52:57 2000 +0000 bird-1.0.0 has been released. commit 5ddf4a58f9c4173acefa1df92ccd3da90230a863 Author: Martin Mares Date: Fri Jun 9 07:32:57 2000 +0000 During initialization, log to both syslog and stderr. When a configuration file has been read and it doesn't specify any logging, log to syslog only (if syslog is not available, then stderr). commit 0b3bf4b1d898b4e438fe4959a63fc16211baff12 Author: Martin Mares Date: Fri Jun 9 07:30:22 2000 +0000 Use SUN_LEN() for length of UNIX domain addresses. This should fix problems with connection to clients on libc5 machines. commit 0e376168c570507c8cb64b143eff0049442e201e Author: Martin Mares Date: Fri Jun 9 06:54:01 2000 +0000 Shut up an uninitialized variable warning. commit 1aa2a9c8351d6121124831f503306ff6869bbf39 Author: Martin Mares Date: Fri Jun 9 06:49:43 2000 +0000 Added a `What is missing' section. commit 4386360bd9f71b159497ac3b671b4e3d117a6b73 Author: Martin Mares Date: Fri Jun 9 06:46:58 2000 +0000 Before building distribution tarballs, make distclean first. commit 2d176ac5d22b08c25ac277821e3daef3a6f2ae23 Author: Martin Mares Date: Fri Jun 9 06:45:48 2000 +0000 Released as 1.0.0, but marked it as a BETA version. commit 99955b54be850fad280a556ca80dc21374d2c5b7 Author: Martin Mares Date: Fri Jun 9 06:31:43 2000 +0000 Proper building and installation of documentation in the Makefiles. commit a012cbb16f3d73ca7ffafe6f7933de7369e2ee48 Author: Ondrej Filip Date: Thu Jun 8 19:16:21 2000 +0000 Nasty bug in LSA refreshing. I didn't refesh my own copy! :-( commit 135857e5777a4f1762fa6d948bb9d6b72e101c91 Author: Ondrej Filip Date: Thu Jun 8 19:14:08 2000 +0000 Acknoledge your own premature aged LSA. commit 054a352475437d924e473c95b5d3ad01ae4ab161 Author: Ondrej Filip Date: Thu Jun 8 19:02:31 2000 +0000 Don't send dbdes before rtlsa origination. commit 4bb18dd2daa1e13ab4f9aaff2ddc4875c4776559 Author: Pavel Machek Date: Thu Jun 8 16:57:41 2000 +0000 Fix i_same for 'c' instruction. commit 89e7de98e455071c5ff3796765fb6fd6860a63c6 Author: Martin Mares Date: Thu Jun 8 15:44:52 2000 +0000 Updated distribution README. commit d4f72db31a512eafbb8aff4e5c1226fa59879382 Author: Martin Mares Date: Thu Jun 8 15:22:06 2000 +0000 When distcleaning, clean up doc as well. commit 96264d4d2f22c652f6cef84ff6226352e1457cce Author: Pavel Machek Date: Thu Jun 8 14:06:20 2000 +0000 Final version of documentation (famous last words) commit 66701947c43d34f89be59fe9845efd7c65f64454 Author: Martin Mares Date: Thu Jun 8 12:56:59 2000 +0000 Fixes. commit 6567e6cf5081542dfeb2c1f2493873c4fabb012f Author: Martin Mares Date: Thu Jun 8 12:42:34 2000 +0000 Missing parameters... commit 1632f1fe32b9f13bf7746586bcbad70ffafe4697 Author: Pavel Machek Date: Thu Jun 8 12:38:16 2000 +0000 More spellchecking and typographic changes. commit 725270cb1da0672128675924844531e56c6ea64e Author: Martin Mares Date: Thu Jun 8 12:37:21 2000 +0000 Fixes for the programmer's manual. commit 8d56febe64769c19a06c2c0f3ff121d25eceaa5b Author: Ondrej Filip Date: Thu Jun 8 12:04:57 2000 +0000 HASH_DEF_ORDER back to 6. commit 2a56bb3bd66a9b52dd6c2e2626630b4eaa79d04b Author: Martin Mares Date: Thu Jun 8 11:05:19 2000 +0000 Set margins. commit 5a64ac70361e9dacfe155492cd52ae88eedcd75c Author: Ondrej Filip Date: Thu Jun 8 11:00:15 2000 +0000 Introduction to configuration of OSPF. commit c62d1c19a924668ccf5315ca8882ea041581e3bf Author: Martin Mares Date: Thu Jun 8 10:48:51 2000 +0000 ... as well there. commit 49569a8b53b7494b19344f5fc9cd659f68477ba4 Author: Martin Mares Date: Thu Jun 8 10:48:35 2000 +0000 Oops! Configuration compiles now. commit a460184532f36f75bc9727886faf07c2bde2d7f5 Author: Pavel Machek Date: Thu Jun 8 10:30:55 2000 +0000 Tiny fixes. commit 86598d87be6b572d3ca9731a72bc820889f5265c Author: Martin Mares Date: Thu Jun 8 10:27:01 2000 +0000 Updated. commit a5a947d4d8f86dd1180d76f0803402383df0dcab Author: Pavel Machek Date: Thu Jun 8 10:26:19 2000 +0000 Fixing error messages. commit ca77641d0787be514cae6a622e26e6a58af11d12 Author: Pavel Machek Date: Thu Jun 8 10:25:56 2000 +0000 Use `switch' for `disabled'. commit ec423cc725d4b097e596dbadd84f3dea40deb0b8 Author: Martin Mares Date: Thu Jun 8 10:25:02 2000 +0000 Updated CLI helps. commit 5a203dac615369806dc6eee0418ea39c597bea41 Author: Pavel Machek Date: Thu Jun 8 10:24:42 2000 +0000 Docs updates. commit b178d92a0ba1dc198f05dc8252c826e9bd62c5cf Author: Pavel Machek Date: Thu Jun 8 08:24:32 2000 +0000 Better messages commit 099c017fca667bbb59cff65be2ac58c82f8fb3a8 Author: Ondrej Filip Date: Thu Jun 8 02:28:04 2000 +0000 Still some endianity bugs. commit 59ba3342968fdd2a016b192559a64439281e25bf Author: Ondrej Filip Date: Thu Jun 8 02:04:45 2000 +0000 I forgot some endianity operations. commit 423230f2f1080c6a4f6d05b6d7705cfaee500f48 Author: Ondrej Filip Date: Thu Jun 8 01:49:19 2000 +0000 Ehm, my (B)DR election was based on router id, but RFC says ip! commit 17e29574bcf0e03e3243a48e784b0248925cc5b4 Author: Ondrej Filip Date: Wed Jun 7 23:48:33 2000 +0000 Better algoritmus of LSA aging. commit 25a3f3da7a2312e5ae21ada2aeccc412e2d1d867 Author: Ondrej Filip Date: Wed Jun 7 23:34:43 2000 +0000 I mark all LSA as in distance INFINITY in process of aging. I don't have to WALK twice through it. commit 1186369bbd45ab901eccc313708cc20f9dbf0f42 Author: Ondrej Filip Date: Wed Jun 7 23:23:37 2000 +0000 Doc. commit 37c3e558ab31a5e6088cef063dcd1e267238be74 Author: Ondrej Filip Date: Wed Jun 7 23:05:32 2000 +0000 Simple explanation, how LSA are kept in database. commit 87f0d22ef84826f6dc6d0a1ae7ba8020b6e52573 Author: Ondrej Filip Date: Wed Jun 7 22:57:59 2000 +0000 Minor change. commit c2553b1b3e1ff61e24b9435b897ef942abcec006 Author: Ondrej Filip Date: Wed Jun 7 22:56:52 2000 +0000 Minor changes. commit eee9cefd8c13184e45878ce8e2ef12fcdece3ded Author: Ondrej Filip Date: Wed Jun 7 22:53:51 2000 +0000 Doc commit e9ab0b4212dc0939d782c991c86c362e09eb279f Author: Ondrej Filip Date: Wed Jun 7 22:31:47 2000 +0000 Doc in lsalib.c + related minor changes. commit d5e4b51865c9532a9b886e942d30bb64dc87a675 Author: Ondrej Filip Date: Wed Jun 7 22:10:46 2000 +0000 Doc commit 351feeb51472602c83ec847f1feba10d68a5d57b Author: Ondrej Filip Date: Wed Jun 7 21:56:32 2000 +0000 Doc. commit b4af36e0d8eeb6a032b2ce2464aae76a04117827 Author: Ondrej Filip Date: Wed Jun 7 21:50:16 2000 +0000 Removed some FIXMEs simply deleting them. commit 7ab3ff6a287d6adc8f1d371d9da1504de502c8a6 Author: Ondrej Filip Date: Wed Jun 7 21:46:22 2000 +0000 Doc in neighbor.c and some tiny changes related to. commit cadbb827f99fc24da9227dce545aa1185bab7916 Author: Ondrej Filip Date: Wed Jun 7 21:12:00 2000 +0000 A copyright change. commit 6f58dc64c9084aca66850b88d907cecf9b00c88d Author: Ondrej Filip Date: Wed Jun 7 20:50:08 2000 +0000 Doc commit 89755a86237c786878a2d0c5e527559c8a4c0b6d Author: Ondrej Filip Date: Wed Jun 7 20:30:27 2000 +0000 Introdution into OSPF. commit 64722c9852a8ea4bdc7db0304351850a8106300e Author: Pavel Machek Date: Wed Jun 7 15:27:16 2000 +0000 Added brief description of client features. Grammar really is not good place to write help from, so please check this. commit 3e82b32d3637a3a3d2eb935dc7036b32bc3fecd4 Author: Pavel Machek Date: Wed Jun 7 14:45:55 2000 +0000 Progdocs updates commit 074a166d9441a2b03931751dbc181e0d462a9d7c Author: Pavel Machek Date: Wed Jun 7 14:39:34 2000 +0000 Better explanation for if/case, and RFC pointers for rip. Still searching for RIPv2 rfc number! commit 8dcf2544996af34f3c3d71116844352427787324 Author: Pavel Machek Date: Wed Jun 7 14:16:11 2000 +0000 Even better documentation of filters. commit 7aa99d22bcabb48cfc737055942715d8efd47f6b Author: Martin Mares Date: Wed Jun 7 14:12:44 2000 +0000 Updated. commit f06a219a2445bc9ff86071fdbb9b97e51b412c31 Author: Ondrej Filip Date: Wed Jun 7 14:12:13 2000 +0000 Better explanation of OSPF attributes. But it's still not perfect. commit 4e8ec66698e0e644f56c18b3f58393d9f5ae49a7 Author: Martin Mares Date: Wed Jun 7 14:08:14 2000 +0000 Spelling. commit 07f29765a58ee72fc79d74b28dbfead24e0b5baf Author: Pavel Machek Date: Wed Jun 7 14:06:37 2000 +0000 RIPv6 now works. commit 76c7efec63ffd2431ce5f6bd2299763f741ac37c Author: Ondrej Filip Date: Wed Jun 7 14:01:18 2000 +0000 Better example for OSPF configuration. commit 907503adb6d0b0763ff92266e2fbc522d77f5476 Author: Pavel Machek Date: Wed Jun 7 14:00:17 2000 +0000 Comment fix. commit 18b4d6bf278485f86ae5b636f3155fb36735ff1e Author: Pavel Machek Date: Wed Jun 7 13:58:49 2000 +0000 rip ipv6 bugfix commit 3ca3e999ecf00cc6ab8a52a73a7ead26e83a75b7 Author: Martin Mares Date: Wed Jun 7 13:54:24 2000 +0000 Spelling and style corrections to the OSPF section. commit 771ae456a5ff0e12379047b737da31b0be4059ea Author: Pavel Machek Date: Wed Jun 7 13:54:06 2000 +0000 Better progdocs for filters commit fa6c2405e2bab551245e1af7ed19b550b8bbef79 Author: Ondrej Filip Date: Wed Jun 7 13:46:13 2000 +0000 Now I can change cost of interface without OSPF restart. commit 6316555eea2b9b232a622fdb9aceaa4de1e23f59 Author: Martin Mares Date: Wed Jun 7 13:32:10 2000 +0000 Minor tagging fixes in OSPF docs. commit 25696edb03e08f562d1993ae38ec9ae43942347d Author: Pavel Machek Date: Wed Jun 7 13:30:02 2000 +0000 Full list of possible values in attributes, better operators description. commit 088bc8add198b27456269ca7e536d6bc77ca285b Author: Ondrej Filip Date: Wed Jun 7 13:28:54 2000 +0000 Bugfix in <>. commit 58f7d004fddd2cccdb019be59b6cc7a8abe50510 Author: Martin Mares Date: Wed Jun 7 13:25:53 2000 +0000 Fixes to the progdoc. commit 38203d789a872077ec174a63a448568725e4715f Author: Ondrej Filip Date: Wed Jun 7 13:19:48 2000 +0000 Originate rt lsa before sending first dbdes. commit 0c69604c8d0c9618e6cc94c98da993439d90dde6 Author: Pavel Machek Date: Wed Jun 7 13:15:48 2000 +0000 SGML syntax fix. commit 8fd12e6b27e713b0b7b24f3f7d9efd57038b1be6 Author: Ondrej Filip Date: Wed Jun 7 12:35:43 2000 +0000 OSPF user documentation added. commit 2e9b24211a523c754b9437d6b742d6df304d8aeb Author: Martin Mares Date: Wed Jun 7 12:29:08 2000 +0000 Spelling fixes to progdoc. commit e403aa89e50471eb6f2838117887b1207627ae3a Author: Martin Mares Date: Wed Jun 7 12:27:30 2000 +0000 Updated TODO file. commit cf0fca30353a9966c793647f7c9d10b0b56678a9 Author: Martin Mares Date: Wed Jun 7 12:27:18 2000 +0000 Added `progspell' target which runs ispell on the progdoc SGML file with all function, variable and structure names removed. commit 1ae494a7e1fb7dde3ffc4e5dd7df31a1bf8dd6bf Author: Martin Mares Date: Wed Jun 7 11:55:36 2000 +0000 Avoid SEGV's in tracing. commit 8cd5c52fcb7d429f41601f7be114168cb2371072 Author: Ondrej Filip Date: Wed Jun 7 01:19:16 2000 +0000 Removed useless trace. commit 3df89cefc19d08f621afac0ff485dba3591a39a0 Author: Ondrej Filip Date: Wed Jun 7 01:18:36 2000 +0000 #define SIZE_OF_IP_HEADER commit bd457b8d2162034e03ac2bb62484d8b238fd556f Author: Ondrej Filip Date: Wed Jun 7 01:03:53 2000 +0000 Some minor changes: Typo: transit delay!=transmit delay Zero checks etc. commit edc34dc9121c188f7794d404fb112c8b162e968a Author: Ondrej Filip Date: Wed Jun 7 00:56:11 2000 +0000 Reconfiguration hook. It will survive many timer and constat changes. commit 1532a244da43b25fb78b7b3a67a344fa4ac542d4 Author: Pavel Machek Date: Tue Jun 6 20:54:05 2000 +0000 mj's fixes to rip documentation. commit a7c9f7c065907e310ce1954821f2a8fc61c0261b Author: Pavel Machek Date: Tue Jun 6 20:35:59 2000 +0000 Batch of mj's corrections (config + filters) commit a63a9ce609864e6ba3e76a1c47fd6423b532dec1 Author: Ondrej Filip Date: Tue Jun 6 12:50:02 2000 +0000 Better dumping neighbors' states on PTP interface. commit a00c7a18f561bf46533dac46ee56227ebdf1be08 Author: Martin Mares Date: Tue Jun 6 11:58:25 2000 +0000 Typos in Static section. commit 02357f960e6a2946add25652c009fa8dfe847f68 Author: Pavel Machek Date: Tue Jun 6 11:53:22 2000 +0000 Merged mj's changes, up-to "import filter". commit 41ad16e2d5dc03f6620b94f8e531373788e11db9 Author: Ondrej Filip Date: Tue Jun 6 11:50:48 2000 +0000 Added IP protocols. commit a852c139dc90febae40be055050ed30490d823b8 Author: Pavel Machek Date: Tue Jun 6 11:05:12 2000 +0000 Don't let example overflow, and new chapter for "about routing tables". commit ee4880c82fcefe61cccb8ec729905a2b19706d33 Author: Ondrej Filip Date: Tue Jun 6 02:54:41 2000 +0000 Some '\n' deleted. commit 064b1d893243bc187980f53292414583ff3b4630 Author: Ondrej Filip Date: Tue Jun 6 02:50:49 2000 +0000 Tracing. commit bd37f45c10be697403e59c957273d172b3d3ed8e Author: Ondrej Filip Date: Tue Jun 6 02:43:32 2000 +0000 Deleted some debug() commit abcbfd0400eeb514c63376b50d3948581c20ca4c Author: Ondrej Filip Date: Tue Jun 6 02:34:57 2000 +0000 Tracing. commit 531a48d8c5c168329640ccb21cd062dbb7b6f5a2 Author: Ondrej Filip Date: Tue Jun 6 02:32:14 2000 +0000 Tracing in LS ack. commit 992705f65a9feb04ed0e918d06ad283928aca13a Author: Ondrej Filip Date: Tue Jun 6 02:27:08 2000 +0000 Tracing in topology commit d3995c498d92d7ce54fb2fcb6904e4e41f7588dc Author: Ondrej Filip Date: Tue Jun 6 02:16:39 2000 +0000 Tracing in LSUPD. commit f14032efdd87bca5c2839be01ffe66797976c7bc Author: Ondrej Filip Date: Tue Jun 6 02:09:58 2000 +0000 First part of tracing. commit 51cff78b2571e24963d3a81694f854605eb75eac Author: Ondrej Filip Date: Tue Jun 6 01:46:32 2000 +0000 Allocate OSPF areas before interfaces. commit c1824c4d4c7753246ba26d27c7a3b7be3006d46b Author: Ondrej Filip Date: Tue Jun 6 01:23:03 2000 +0000 Simple autentication added. commit fef1badfcfb0519cca10f3561e5cb79ef9f9e969 Author: Ondrej Filip Date: Tue Jun 6 01:00:34 2000 +0000 All die() renamed to bug(). commit 80787d418bd028f59e34ffb08c1c221992fe3b41 Author: Ondrej Filip Date: Tue Jun 6 00:52:35 2000 +0000 Dummy reconfigure added. commit f8f1e1f110c3ff1aec03a9fa918257cf4d29e916 Author: Ondrej Filip Date: Tue Jun 6 00:46:00 2000 +0000 Interface locks added. commit 7d68e18b414bbdef9a5472006e8674a3d74e5a00 Author: Ondrej Filip Date: Tue Jun 6 00:21:06 2000 +0000 Added NBMA into examples. commit b131e163c292aac09dc7f73924de0fad6547743d Author: Ondrej Filip Date: Tue Jun 6 00:16:31 2000 +0000 Some useles variable deleted. commit 3301b9d1c57b4e76d32f1244e3da33012e70d20d Author: Ondrej Filip Date: Tue Jun 6 00:16:03 2000 +0000 Some useless variable deleted. commit eb436e16fd85340d3403a033ee86f973428a2f08 Author: Ondrej Filip Date: Tue Jun 6 00:08:27 2000 +0000 NBMA networks seems to work, but this should be better. :-) commit e5b5d18c1c8b33e76e954c0696e056fc11701631 Author: Ondrej Filip Date: Mon Jun 5 23:44:26 2000 +0000 NBMA networks should work now. commit 5c18880e35f668d33a993be5b2854547a08d9199 Author: Martin Mares Date: Mon Jun 5 21:26:11 2000 +0000 Avoid sentence containing a colon to start new doc subsection. commit ab698fc57c9898790964df7f9f59329e1f8930ba Author: Ondrej Filip Date: Mon Jun 5 21:09:03 2000 +0000 Added example of OSPF configuration. commit a13eaf219acf5b90af09b914a2182e23d5812aee Author: Martin Mares Date: Mon Jun 5 21:02:57 2000 +0000 Define element which initializes different formatting for the programmer's guide (\raggedbottom etc.). Also, omit "\usepackage{t1enc}", so that bullets work now. commit 854128a5ed540f230933cdc2c787e94d2658647b Author: Martin Mares Date: Mon Jun 5 21:01:58 2000 +0000 Don't print empty synopses of functions. commit 3b580a23ad32e8445c419932d6f7715cdc2a0687 Author: Ondrej Filip Date: Mon Jun 5 20:57:53 2000 +0000 Bugfix in NET LSA flushing. Configuration now works! :-) Better "show ospf" Some minor bugfixes. commit f1aa23d4b3949ccd7c86f9a4e87eda63149b5f6d Author: Martin Mares Date: Mon Jun 5 20:24:42 2000 +0000 Minor tweaks of spacing. commit 4bb9ce56bbf42ac09fc8293d8419835b6f178e83 Author: Ondrej Filip Date: Mon Jun 5 19:45:06 2000 +0000 Reset inactim timer if you receive any packet from neighbor. commit 496c819f26f67593797f0b861e153399c1d63a86 Author: Ondrej Filip Date: Mon Jun 5 19:35:48 2000 +0000 Removed some FIXMEs by deleting them. commit 3585d400e03a4e43def868b492df440ae52a29bb Author: Ondrej Filip Date: Mon Jun 5 19:31:55 2000 +0000 Don't info about DR and BDR on non-MA networks. commit 2debcb9eb0d76362003726ca8b0f5f43ee275dee Author: Martin Mares Date: Mon Jun 5 19:17:37 2000 +0000 Move TeX trickery for typesetting of function descriptions to where it belongs. commit fdb0c540a82d9732d4d1d36c83e186f36d756d08 Author: Ondrej Filip Date: Mon Jun 5 19:12:22 2000 +0000 PTP link in RTLSA was not announced correctly. commit 1605f043aa65b2434eb29d994f622bd79d0f2be7 Author: Martin Mares Date: Mon Jun 5 19:08:27 2000 +0000 Avoid using style combinations such as italic typewriter font. commit 8441f179253777b3e4bf3461ac847b33ddb098a4 Author: Martin Mares Date: Mon Jun 5 18:40:25 2000 +0000 Unless a filter specifies otherwise, all external routes have type 2 metric 10000. commit f8032bbdb150221e84f0bd7de825cf3e9f15aa66 Author: Martin Mares Date: Mon Jun 5 18:32:51 2000 +0000 Simplified the grammar and fixed several minor bugs (e.g., `INTERFACE "eth0" };' was a valid entry). commit 44fc1888cf284d863c897b861942612acf36f52f Author: Ondrej Filip Date: Mon Jun 5 18:09:49 2000 +0000 First calculate checksum and then send refreshed LSA! commit aba5e89f9310bb33c7362b02108e640983ad0819 Author: Ondrej Filip Date: Mon Jun 5 18:09:15 2000 +0000 Better checksum checking. commit 4c5f93d76bd0636407a185c175fe73411ae79a32 Author: Pavel Machek Date: Mon Jun 5 17:13:36 2000 +0000 Better documentation. There are functions whose description is good when reading source but whose documentation does not belong to progdocs. commit 22080a8640f268247a4cf74c9e76f958a05c4b69 Author: Pavel Machek Date: Mon Jun 5 16:42:54 2000 +0000 Make rip example fit on page. commit 8798c811762f463b662108643d7c4c869deb7f98 Author: Pavel Machek Date: Mon Jun 5 16:36:16 2000 +0000 Docs updates: make prog.dvi do not overflow in .dvi include filter documentation in the system commit eb2c99a132c87c5560edc77909edfab2df44f0a2 Author: Ondrej Filip Date: Mon Jun 5 16:32:29 2000 +0000 Yet another change, now flushing of net lsa seems to be perfect. :-) commit b458ce83d7cdc507aa18e5fed2ab206847bc317e Author: Martin Mares Date: Mon Jun 5 16:19:27 2000 +0000 Print out function synopsis as a part of the declaration. Also, reverted my previous hack for `&' and replaced it by just disabling the `& -> &' conversions. commit 2a5d7caa951d37c50d52ebef8ef269fa587dec5e Author: Ondrej Filip Date: Mon Jun 5 16:13:50 2000 +0000 I calculated next hop of parent instead of actual LSA. :-( commit 07b7100292fb87169ad5f18285927c39697f6998 Author: Ondrej Filip Date: Mon Jun 5 15:44:11 2000 +0000 Don;t send packet over downed interface. commit 8b79c4ccd597b90222f57eb3dfadeb24f39db7bd Author: Pavel Machek Date: Mon Jun 5 15:41:44 2000 +0000 Add safety check. commit 98da26a0a0ee9dd8f7030dcaf6f733adf8b8ad2c Author: Pavel Machek Date: Mon Jun 5 15:41:29 2000 +0000 Better error messages commit 49222deffff154ad7c287efd4a6847cc545cda6b Author: Ondrej Filip Date: Mon Jun 5 15:06:26 2000 +0000 Bug in comment. It didn't compile. commit b093c328f5b352e3d059cb14cceed1e4daa1b9dc Author: Pavel Machek Date: Mon Jun 5 12:52:57 2000 +0000 Updates to both programmers and users doc commit 73275d855dcc8a184bc19f3750c8775a59111260 Author: Martin Mares Date: Mon Jun 5 12:49:04 2000 +0000 Documented all the sysdeps (only briefly, I admit). Except for Filters, RIP and OSPF, the progdocs are complete. commit 525fa2c1f0e955455bed3fdb397aceb1e6e69a57 Author: Martin Mares Date: Mon Jun 5 12:19:12 2000 +0000 Documented sockets, events and timers. commit 10304bed435034cf8432b1c6262f7e7f0d84d49c Author: Martin Mares Date: Mon Jun 5 11:46:40 2000 +0000 Split random number functions off io.c, so that they can be documented separately. commit 5cc1e1f805934952f38ceb2ca6947c6d2e704937 Author: Martin Mares Date: Mon Jun 5 11:41:41 2000 +0000 Documented memory resources. commit 9238b06a2c6faac8b16e990821c91affde4072c4 Author: Martin Mares Date: Mon Jun 5 10:01:09 2000 +0000 Spelling. commit 42b3daa09cda8a4b80661177d3bf74b9258b0b88 Author: Martin Mares Date: Mon Jun 5 09:51:24 2000 +0000 Description of protocol module moved to where it belongs. If documentation of standard modules is stored in their source, such auxilliary files should be as well. commit ac272c0067cc7f04e74f0418bc0c9ce63a657175 Author: Ondrej Filip Date: Mon Jun 5 05:06:53 2000 +0000 Bug in LSA origination. commit dc2548d2ccc45722f0dcaa861dd3b45a397d2cac Author: Ondrej Filip Date: Mon Jun 5 05:06:22 2000 +0000 Premature age LSA if you're NOT dr. commit 88048fb3c970842a16c65b1566ba817871a04eb5 Author: Ondrej Filip Date: Mon Jun 5 03:46:19 2000 +0000 Small patch to better hash type=2 LSAs. commit 273fd2c16475d3d1275a4fe17443c3ba2b93fbc4 Author: Ondrej Filip Date: Mon Jun 5 02:23:20 2000 +0000 Many bugfixes (I don't remember all of them): Added link ID calculation for external routes with same prefix but different mask. Bugfix in NET lsa origination. Bugfix in NET hashing. Bugfix in LSA installing. commit 2d37d36c676e16b92ac38a60d3c269efeeaf07ac Author: Martin Mares Date: Sun Jun 4 20:06:42 2000 +0000 Updated the TODO list with our last-minute stuff. Moved the rest to "Various ideas". commit e24ddd9bef7e3d3490a8ee7667cd25069b40fe81 Author: Martin Mares Date: Sun Jun 4 20:00:35 2000 +0000 Don't set precedence and TTL for the dummy socket. commit 13e9bac33fc99e71efddf1790ce1e7dfdc09dfa8 Author: Martin Mares Date: Sun Jun 4 19:57:04 2000 +0000 One more newline less... :) commit df49d4e14b7c24f8ca958870fd1e9ddc84df1f1b Author: Martin Mares Date: Sun Jun 4 19:56:06 2000 +0000 Removed lots of trailing newlines in log messages. Please note that the only calls which don't add newlines automatically (i.e., don't print a full line of output) are debug() and DBG(). commit 201187c55837587d8f88775cd957d9c8e423c254 Author: Martin Mares Date: Sun Jun 4 19:55:11 2000 +0000 debug -> DBG commit bf3eb98eb829adc8bee4a210cfcefe29ba0524a1 Author: Martin Mares Date: Sun Jun 4 19:30:55 2000 +0000 Use nested scopes properly. Updated according to cf_define_symbol() changes. The rest of code doesn't need changing since it doesn't use nesting. commit 04dc62a0116941d2f1510216539ae8c11c5f1cb3 Author: Martin Mares Date: Sun Jun 4 19:30:13 2000 +0000 Nested scopes could never have worked. My fault I wrote such a buggy code, Pavel's fault that he's never tested shadowing of declarations in the filters. cf_define_symbol() has been modified to check the scope of the symbol it's given and it if it's an already defined symbol, but in a different scope, a copy is created in the current scope and redefined to the new meaning, the consequence being that it cf_define_symbol() now returns the new symbol you need to use when assigning aux and aux2. commit dab66519160042f1fb62a285e3a947233ce74e70 Author: Ondrej Filip Date: Sun Jun 4 19:21:23 2000 +0000 Install newer lsa even if nothing in its body change. commit 67cc9135bfd515149ecca62f32026cd6e2a390b0 Author: Ondrej Filip Date: Sun Jun 4 19:20:28 2000 +0000 Many bugs in ext lsa origination. commit ce8f0c083a5f46e001dff759e924910c415cfb48 Author: Ondrej Filip Date: Sun Jun 4 19:19:36 2000 +0000 Schedule RT calcualtion if you delete LSA by premature aging. commit f7667ba1c4c7a35266ae5018b059a14a01f7f907 Author: Martin Mares Date: Sun Jun 4 18:46:30 2000 +0000 When cloning a rte and replacing its rta, remember to free the old one so that we don't leak memory. Thanks go to the resource tracking system for quickly discovering the source of leakages. commit 7722938d63d206ebc0e1da732009e1e9f2cd9d72 Author: Martin Mares Date: Sun Jun 4 18:34:39 2000 +0000 Added library progdocs. commit 102e3e0e0277e7b123c7c1ae3635c4a8fb55c900 Author: Ondrej Filip Date: Sun Jun 4 17:51:52 2000 +0000 Just to be sure, that rt calculation cannot start beforeorigination of rt LSA. commit 83e50ffc472c8869d58a7d1da27846bd727a8cfd Author: Ondrej Filip Date: Sun Jun 4 17:33:15 2000 +0000 Bug in debugging. commit 71f7d043a6f03b5d5cd0701bb679b914b1bf47d1 Author: Ondrej Filip Date: Sun Jun 4 17:10:52 2000 +0000 :-) No bison does not have any comment to my code. :-) commit 54e55169da71a6e6e2d8f9fbc0123297301217d7 Author: Martin Mares Date: Sun Jun 4 17:06:18 2000 +0000 BGP documented. commit 3560cf8e0b68ce0cac5a9af2aadbc09d4f529e7c Author: Ondrej Filip Date: Sun Jun 4 16:36:57 2000 +0000 Clean up. commit e7811248685520ceff362b8bc7f090067ca42114 Author: Ondrej Filip Date: Sun Jun 4 16:17:39 2000 +0000 Another clean up. commit 47f8e0c2169bba2dd209f1c7ed89f1d605d36b3e Author: Martin Mares Date: Sun Jun 4 16:16:08 2000 +0000 Document. commit 3b31c538333156770ddb74a7a27f271784745144 Author: Martin Mares Date: Sun Jun 4 16:15:37 2000 +0000 Documented all the trivial protocols. commit 2a863dd6e18a43fe3de5b1f3651e816f6fc27bb1 Author: Ondrej Filip Date: Sun Jun 4 16:12:01 2000 +0000 Small change to make bison happy. commit 58f9453776dff92b4ee4c81f6ca3601b6ee9f041 Author: Martin Mares Date: Sun Jun 4 15:22:20 2000 +0000 Moved parser docs to cf-lex.l, so that the parser compiles. commit cdb898cfd40fe866a1835689814113075b7b5a67 Author: Martin Mares Date: Sat Jun 3 18:23:27 2000 +0000 Minor changes to the progdocs. commit 06607335ef73bc0ffeb377a420e6438b531a4ea7 Author: Martin Mares Date: Sat Jun 3 18:23:00 2000 +0000 Documentation. commit 899fc0abfe8400425860d0e9e4d6cc7fd338978c Author: Martin Mares Date: Sat Jun 3 18:22:43 2000 +0000 `|' now works as it should. commit 2e130b5cadb970b7f4f743e69cd459b5b42cf208 Author: Martin Mares Date: Sat Jun 3 17:02:30 2000 +0000 Recognize `|xxxx|' as verbatim text and typeset it using . commit c0b2f6463fd7464ce6fe4d9dc67f37e61bface11 Author: Martin Mares Date: Sat Jun 3 16:56:00 2000 +0000 cf_symbol_class_name now recognizes SYM_IPA. commit 3d675cdbe7287d3024d041ce4e28dacf7ca527cc Author: Martin Mares Date: Sat Jun 3 14:40:39 2000 +0000 More documentation. commit aaaff77605879ffd80f8980f06ea66329e9aaea8 Author: Ondrej Filip Date: Sat Jun 3 09:50:31 2000 +0000 More conf. items defined. commit a789d814ddd8473fdb85bedb02014f6cb6435373 Author: Ondrej Filip Date: Sat Jun 3 08:42:04 2000 +0000 Multiple items in area {} :-) commit 89d6782dd1a7775a292db3b2b622c8a48dbd757c Author: Ondrej Filip Date: Sat Jun 3 01:29:00 2000 +0000 interface {} added. commit b36a0a799c751864f65bc3384df301448b54f3bf Author: Ondrej Filip Date: Fri Jun 2 19:55:55 2000 +0000 area {} added to config. commit 7e602d5ea74206236373230a4620736370b3cc9c Author: Martin Mares Date: Fri Jun 2 17:42:21 2000 +0000 Killed several bugs in kernel-doc. The most painful one was that it was unable to recognize structure markers `&'. commit a7ed3e557fd1f8c4e56fef9a5238091181c01186 Author: Martin Mares Date: Fri Jun 2 17:41:43 2000 +0000 New TODO list. commit ddbcb927f255ef4720e87b7f14339add37e705ce Author: Martin Mares Date: Fri Jun 2 17:24:11 2000 +0000 Documented protocol hooks. commit 371adba6deb0add48fd4d03d40d4e098590689fc Author: Martin Mares Date: Fri Jun 2 17:23:53 2000 +0000 Use for chapters, for sections and for subsections. commit 6cba2d5eeb522cbf6f1cc28c38fc2c445f41d1e6 Author: Martin Mares Date: Fri Jun 2 17:22:43 2000 +0000 Typographical enhancements. Now, the documentation is typeset using a modified book style. Please look at this version and tell me your opinion. Especially I don't feel happy about the spacing and (not) indenting of paragraphs. Also, I've removed things like "fax" and "letter" from the LaTeX mapping file. commit 3fa5722defc340571a6518d5556b1e354f05ce18 Author: Ondrej Filip Date: Fri Jun 2 15:05:41 2000 +0000 First option into config added. :-) commit 62924172aef9cf5308fd21d3ad5f6572b977c268 Author: Ondrej Filip Date: Fri Jun 2 13:52:50 2000 +0000 Flush LSA when receive aged one. commit 3c6269b8fec71fa22d5b087cae0e9ef86ff2b351 Author: Martin Mares Date: Fri Jun 2 13:42:36 2000 +0000 Added documentation on protocols. Protocol hooks deserve an extra chapter (to come soon). commit e4ba0ec1977e9925ec67f9442067e5ff7cb36111 Author: Ondrej Filip Date: Fri Jun 2 13:27:34 2000 +0000 Bugfix in receiving of aged LSA. commit 9a8f20fc0fda1cf910fe8ca21e850ab1524c4355 Author: Martin Mares Date: Fri Jun 2 12:41:25 2000 +0000 Better description of the route distribution process. commit 2eac33f774a2075cff3d28f7fdb36e0482e48f35 Author: Ondrej Filip Date: Fri Jun 2 12:34:28 2000 +0000 Better LSA Aging. commit 3ce8c61000da58261750af2b6e60dbf2fca2abcf Author: Martin Mares Date: Fri Jun 2 12:29:55 2000 +0000 Documentation on routing tables and route attributes. commit 566a0eede7094519df07418116beeb7f3f976c7a Author: Martin Mares Date: Fri Jun 2 12:29:24 2000 +0000 Removed rta_find() since nobody uses it and it's more convenient to use ea_find() directly. commit ece612e12808325b1b7eb24d060a42343549238f Author: Ondrej Filip Date: Fri Jun 2 11:24:38 2000 +0000 sh interface "iface" dumpped all. commit 7a5582ac0045b80274de3183eca9b71eb52f2e6b Author: Ondrej Filip Date: Fri Jun 2 11:00:14 2000 +0000 Better dumping, if I get strange lsack. commit 3488634cba08aeda19a733f7c76aef7a54a4e0ec Author: Ondrej Filip Date: Fri Jun 2 10:21:02 2000 +0000 Handle "show ospf *" even if protocol is down. commit a489f0ce8ba44df0894a2bd102660fed1bed5ac6 Author: Ondrej Filip Date: Fri Jun 2 09:57:22 2000 +0000 Silly bug in sh interface. Now I test ALL interfaces. :-) commit 489f800b45d6d2d1a1fc9b371a015563cea9722d Author: Ondrej Filip Date: Fri Jun 2 09:53:26 2000 +0000 Speedup loading process. commit 75317ab8e522b5dceb87b204e09d8ad919ac8558 Author: Martin Mares Date: Fri Jun 2 09:51:26 2000 +0000 Spelling fixes. commit f8e2d916b6cbe42131bfefbc5a2cd0ddfaf8131b Author: Martin Mares Date: Fri Jun 2 09:46:35 2000 +0000 Minor fixes. commit 92e8be8c898932bf959e722acfbb33d154b8fcc4 Author: Ondrej Filip Date: Fri Jun 2 09:42:24 2000 +0000 Bugfix in lsreq receiving. commit cd4fecb66affe468928abd87cadef4ff9a991d0b Author: Martin Mares Date: Fri Jun 2 09:35:17 2000 +0000 Made it *compile* !!! commit 64ba9f7bcc4bb3b53c0cab303c230855a1443a42 Author: Pavel Machek Date: Fri Jun 2 08:01:12 2000 +0000 Do not try to divide by zero. commit 326e33f521f7796cbdde4a36a67bb4c7ffd25c1b Author: Pavel Machek Date: Fri Jun 2 07:59:26 2000 +0000 Results of complete reading of documentation. commit c4f0f0140863c743b1d63c3bc94cb8e85417a4ad Author: Ondrej Filip Date: Thu Jun 1 17:52:21 2000 +0000 Added show ospf interface. show ospf neighbors now knows "". commit 58740ed4c587a230bf1406eca52cbc84bcb1c5c3 Author: Martin Mares Date: Thu Jun 1 17:12:19 2000 +0000 Documentation. commit 658d272bb635b5efeeed883dec5af9dddf12397f Author: Martin Mares Date: Thu Jun 1 17:11:10 2000 +0000 Better handling of parameterless functions. commit 725774926676352d2a065cbeb95a81b95bfcfa3e Author: Ondrej Filip Date: Thu Jun 1 16:45:10 2000 +0000 Some other reply codes allocated. commit 4ab4e9778f35f8a123ee6bbc2387b9870859b707 Author: Ondrej Filip Date: Thu Jun 1 16:26:59 2000 +0000 show ospf implemented. commit cf318e3cd3206ad6a459a01e29e8494a100a67eb Author: Martin Mares Date: Thu Jun 1 16:17:29 2000 +0000 Removed comments about workings of the old neighbor cache which are (1) obsolete and (2) replaced by the progdoc. commit 1f495723c355b66383ab391fdba84aae7e9226eb Author: Martin Mares Date: Thu Jun 1 16:16:49 2000 +0000 Documented. commit ce4aca093a267da3dcd07b25f4390d393fd3c259 Author: Martin Mares Date: Thu Jun 1 16:16:18 2000 +0000 FIB documentation. I've changed the init callback type to a typedef to work around a bug in kernel-doc I'm too lazy to hunt now. commit a783e259d8d710208280126177487cc790418515 Author: Ondrej Filip Date: Thu Jun 1 15:53:06 2000 +0000 Cisco-like "show ospf neighbors" implemented. commit b594ad238692738352cd8827d71038a356b0d5a5 Author: Martin Mares Date: Thu Jun 1 15:13:23 2000 +0000 tm_format_reltime() works with both past and future timestamps. commit c23f40b1458e448ec9e7c974a2c486f2eccff871 Author: Martin Mares Date: Thu Jun 1 15:04:25 2000 +0000 Use instead of . commit a9aa4c1ebb5ccdb2c6c7672267ad32670261a10b Author: Martin Mares Date: Thu Jun 1 13:13:49 2000 +0000 Inactive sticky neighbors have no scope. commit 23df5e4cf3b0ff10e7484fc5ca40cb5ea638078b Author: Martin Mares Date: Thu Jun 1 13:00:39 2000 +0000 Print route tag in hexadecimal and omit it if it's zero. commit bc00185e5a2d51d965465f117722fd4189437d24 Author: Martin Mares Date: Thu Jun 1 13:00:19 2000 +0000 Updated to new neighbor cache. commit 491cd43b777e46a301ae2a8f5400acaeb28b8ca5 Author: Martin Mares Date: Thu Jun 1 12:59:50 2000 +0000 Updated RIP to new neighbor cache semantics. When presented with next hop equal to a local address, just ignore the route (as it is usually just an external route exported by us echoed by some RIP peer), when given an invalid next hop, moan to the log. commit 4a91150175268d49a1c17131838e5afad925788b Author: Martin Mares Date: Thu Jun 1 12:58:41 2000 +0000 Updated for new scope handling. Also, provide proper address scopes in struct ifa. commit 0f32f2a65a086561fdfd31d4efdea839ec9ce573 Author: Martin Mares Date: Thu Jun 1 12:58:04 2000 +0000 Modified the neighbor cache to remember local addresses as well. neighbor->scope now contains proper address scope which is zero (SCOPE_HOST) for local addresses, higher (SCOPE_LINK, ..., SCOPE_UNIVERSE) for remote ones. commit 56ca7acd3afd0df7928b3adfe4a8db8b29b89fb2 Author: Martin Mares Date: Thu Jun 1 12:55:26 2000 +0000 BGP: RFC 2842 has replaced the cap-draft. commit df968040f6b0f9eb83aa9c9eb4b4d6dcee6a384a Author: Ondrej Filip Date: Thu Jun 1 12:17:08 2000 +0000 Print tag unsigned rather then signed. commit c52c7e764576fed027defa0c06a056f89912787a Author: Ondrej Filip Date: Thu Jun 1 12:08:14 2000 +0000 Calculate checksum when reflooding (after min ls_refresh). commit 5f4aee76a2e26a6947f47273d510edc524716a45 Author: Pavel Machek Date: Thu Jun 1 08:43:29 2000 +0000 Added && and ||. commit 1877dab21715eb23addb3391afbd8dbf571f833d Author: Pavel Machek Date: Thu Jun 1 08:34:30 2000 +0000 Allow case net { 62.0.0.0/8+: 10.0.0.0/8+: else: reject; } commit 1895e81e0532f732f501036402bbdd1825885cfd Author: Pavel Machek Date: Thu Jun 1 08:32:49 2000 +0000 Allow matching on enums: if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then { print "Failed in test"; quitbird; } commit 42542c56c23174bfaefb1b949b90ed72afbea8fd Author: Ondrej Filip Date: Thu Jun 1 00:32:08 2000 +0000 Cleanup. commit d27d0efe17a197ae41e25bc56526d5fc4ac4a93e Author: Ondrej Filip Date: Thu Jun 1 00:22:48 2000 +0000 Very stuping bug. (I took me 4 hours to find it!) I just wrote "=!" instead of "!=". :-((((((( commit 2983460bc0adabe357ba839972ea8d09c97c32a4 Author: Martin Mares Date: Wed May 31 22:39:06 2000 +0000 Both `help' command and the `unknown command' error message now tell the user to press `?' if he wants help. commit 2f5e5ff9d6e91e7a3e478b316d6b2d23003ad80e Author: Martin Mares Date: Wed May 31 22:28:36 2000 +0000 Before configuration file is read, log to _both_ syslog and stderr. commit c184d9d0bdded559fb9d19accd17b88963e46669 Author: Pavel Machek Date: Wed May 31 21:51:04 2000 +0000 Documentation update commit 0b1cad81623e85f1f1b9ef3652cdc389641496e5 Author: Pavel Machek Date: Wed May 31 21:50:13 2000 +0000 Complain when filter does not end in accept nor reject. commit b5958826cc5fc75b5f99c51559d1ffedea5884b4 Author: Ondrej Filip Date: Wed May 31 18:55:57 2000 +0000 Ehm, some other "down" steps. commit 3f6953a103b9a846625a0d51e30b6dc59eedc7f0 Author: Ondrej Filip Date: Wed May 31 18:45:16 2000 +0000 Some bugs in cleanup after iface down. commit 489b21555e59d39d1c26dd3051f077c6f0a07c85 Author: Ondrej Filip Date: Wed May 31 18:36:51 2000 +0000 Why does not work "sk_close(sk);rfree(sk);"? commit 46962be628c1bd1d9c2badeea181ff6f87f0cb29 Author: Ondrej Filip Date: Wed May 31 18:31:53 2000 +0000 Better debugging. Safe neigh_list deleting. commit 3728267827e83bc095956b16256feae9e28adce7 Author: Ondrej Filip Date: Wed May 31 18:21:42 2000 +0000 And finally, Premature aging works. :-) commit 31ee3d5f214666a4b2da328dc894a5a9089acc87 Author: Ondrej Filip Date: Wed May 31 15:51:39 2000 +0000 Another step to make premature aging better. commit a9eeefd63ab7886bc2a5b8f0f7a2d1ec69a9c831 Author: Ondrej Filip Date: Wed May 31 15:28:13 2000 +0000 Warning destroyed. :-) commit 82364f4db8fff969932989bfcc5be89c73b15174 Author: Ondrej Filip Date: Wed May 31 15:24:29 2000 +0000 Flood my LSA (if exists) after old one is flushed. commit 0822995cb31b596d1fe9e8bb67f7e9d1c184694e Author: Ondrej Filip Date: Wed May 31 15:04:45 2000 +0000 Set E2 metric for internal routes to LSINFINITY. commit 9a04d0307e85913554122a2dd0397486b5ef702c Author: Ondrej Filip Date: Wed May 31 14:52:22 2000 +0000 Delete _all_ ext routes from unreachable neighbor. commit 528932368ac5c5ffe6ee3412fc8e9e1cb9cbd7db Author: Ondrej Filip Date: Wed May 31 14:43:42 2000 +0000 Stuping bug in net LSA origination. Now, I should survive loss of my only neighbor. commit 1c1f1b6c0a9012aaf0d3b94275895cb87b5ff695 Author: Martin Mares Date: Wed May 31 14:27:49 2000 +0000 This should be enough from the SGMLtools distribution to make the SGMLtools happy. The only symlink you need now is dist/birddoc -> dist/sgmltool. I'm convinced it could be avoided by renaming the directory instead, but I'd rather avoid it due to CVS pecularities. commit 1885aa8ce33e6617d45dbc2f5ee2852bf5f72e88 Author: Martin Mares Date: Wed May 31 14:25:27 2000 +0000 Clean LaTeX .aux and .toc files as well. commit fcdddff5f3f5c9f2a15377a9dd08f105a3b696a0 Author: Martin Mares Date: Wed May 31 14:24:21 2000 +0000 Formatting of progdoc works in both HTML and LaTeX. The LaTeX output still has somewhat weird spacing, but it will be hopefully easy to fix. commit d1660fd3f38c29739ff36c86c6010d65fb90c608 Author: Ondrej Filip Date: Wed May 31 14:21:56 2000 +0000 Sort cleanup in aging. commit 70a383198ae08bed395f2a083c1bea5b37447705 Author: Ondrej Filip Date: Wed May 31 14:06:33 2000 +0000 LSArt origination and routing table calculation is now not doing so often. Instead of calculation I just schedule it latter. commit aa185265f1cb310c053edb1a3bde28b4dab94964 Author: Martin Mares Date: Wed May 31 13:54:00 2000 +0000 Updated headings and copyrights. commit 38cf78a97a1541cf80a5b10c08ab25d564654516 Author: Martin Mares Date: Wed May 31 13:30:58 2000 +0000 Added the introduction chapter of progdoc. commit 3caca73fd9c05121b9748793df5f1378af3a8ce5 Author: Martin Mares Date: Wed May 31 13:30:29 2000 +0000 Spelling check and update of LocalWords. commit fc741dab27913b9c5f9a97642158b5011a9c4700 Author: Ondrej Filip Date: Wed May 31 13:20:25 2000 +0000 Handle better next hop in external LSA. commit e0bbb7b7ef1aabbf037190225ebac11f7812ae84 Author: Ondrej Filip Date: Wed May 31 12:52:12 2000 +0000 Very ancient bug in (B)DR election, I didn't fill correctly my own IP. commit a7a3a0a383a9dadcd93d876e7d9b43f870f20941 Author: Ondrej Filip Date: Wed May 31 12:07:09 2000 +0000 Added tagging of external LSA. commit fec5bec0b5f0e114a635c99a731e922ce735ff81 Author: Martin Mares Date: Wed May 31 11:36:21 2000 +0000 Make documentation targets available from the top-level makefile as well, but not with separate object tree yet. commit 46527a939e97a8a0d6d023ad7853e5e9a2df1ea9 Author: Martin Mares Date: Wed May 31 11:35:47 2000 +0000 Modified the Makefile to work in the source tree. From now, you can just `make userdocs' in doc, no need to use ugly scripts. Also, `make progdocs' builds the programmer's documentation in HTML, LaTeX version to come later. commit fcb5f4a725c9edecca7d4646c633e42f66ab53b6 Author: Martin Mares Date: Wed May 31 11:30:18 2000 +0000 Updated all the Doc files to new format. commit 6be13de762cebc9fc5f977e0e3423a9e2ae23a95 Author: Martin Mares Date: Wed May 31 11:29:56 2000 +0000 New progdoc script generating SGML output. commit c9c3611734cfb8265586ad8447483cbba9727617 Author: Martin Mares Date: Wed May 31 11:29:22 2000 +0000 Added new output format `bird' which creates birddoc SGML. commit 3fc259549595c952befbe589764ae0bc1ae82728 Author: Martin Mares Date: Wed May 31 11:28:52 2000 +0000 Added tags for markup of programmer's documentation. commit c92795e934758a32472ebc5766ff0f61b1c1409c Author: Martin Mares Date: Wed May 31 11:28:07 2000 +0000 Moved old TeX documents to old/ to make them not interfere with doc building. commit a2a3ced83eea3919639adafbdacb7ec11011f9cb Author: Martin Mares Date: Wed May 31 10:07:27 2000 +0000 Added Pipe documentation. commit 0884f492232bb81366c04982bf4935307d273c26 Author: Ondrej Filip Date: Tue May 30 23:29:23 2000 +0000 Ehm, in had this in code: "break; i--;" :-( commit 3b0b2cb61f4e9c3bfbb4770b941c5aba56d9e70e Author: Martin Mares Date: Tue May 30 22:48:14 2000 +0000 IPv6: Absolutize link-scope addresses of incoming packets. IPv6 socket interface is hopefully right now. commit cfa6ab0593a02c3d4d0d959c771f72430f1adf67 Author: Martin Mares Date: Tue May 30 22:47:33 2000 +0000 Added ipa_absolutize() which converts link-scope addresses to global scope ones according to prefix assigned to the corresponding interface. commit 69a20d2effb651e475b8ab8b04ee1a04a76db07f Author: Martin Mares Date: Tue May 30 21:46:21 2000 +0000 Recognize `!'. commit 5919c66e8fdd87ee7e5c5a1e0ce01893e0ce103d Author: Martin Mares Date: Tue May 30 21:25:32 2000 +0000 Route attributes for OSPF. commit 2cec475b8fbaa6cb0865ceacd900ffb678818330 Author: Martin Mares Date: Tue May 30 21:24:53 2000 +0000 Removed several unused local variables. commit 2f71123158973d770eee1dea64b46a4774bcf9a5 Author: Martin Mares Date: Tue May 30 21:24:15 2000 +0000 Killed bug in merging of dynamic attributes. commit caab3bb374d2671982d068c0fb0aa6217691d5bd Author: Martin Mares Date: Tue May 30 21:23:49 2000 +0000 Better formatting of protocol status. commit 36032dedc619a39d45d6abe79d27110a98751ba9 Author: Pavel Machek Date: Tue May 30 19:20:02 2000 +0000 Added section about client. commit 3e8645560624ac70ccc6d5f96fabcdae0a87cf4d Author: Ondrej Filip Date: Tue May 30 18:21:51 2000 +0000 Added \n in debug. commit 7e1c7efae2762752ef897bfa215b299127412b66 Author: Ondrej Filip Date: Tue May 30 17:57:06 2000 +0000 Stupig bug in debugging. commit 3dd8f983b649c83f50d44ca2093ab1f931eaba4d Author: Ondrej Filip Date: Tue May 30 17:51:22 2000 +0000 You can decide if add LSA into lsrth during flood_lsa(). commit 3d410fdfa1a6fc20952cf94b39ebff197a3c065a Author: Ondrej Filip Date: Tue May 30 17:49:25 2000 +0000 Reflood your old lsa. commit 13b02be25a41d7a505f7a888f948220a15edcf8a Author: Ondrej Filip Date: Tue May 30 17:00:17 2000 +0000 Don't run rt calculation twice. commit b477a9a855f75486c2e03bb7b68faba7923bc511 Author: Ondrej Filip Date: Tue May 30 16:49:48 2000 +0000 Don't send empty LS upd. (And better debugging.) commit e1e31816c4e6931465936afa39f5773cf4591b35 Author: Ondrej Filip Date: Tue May 30 16:48:42 2000 +0000 Aging delta changed. (Ehm, aging is very dirty I'll have to change it.) commit 1b128de364e5a1931c1cc61b04c1e44960007025 Author: Ondrej Filip Date: Tue May 30 16:13:59 2000 +0000 Better shutdown. commit 935ceabea43714e4abae7ecaac0f072e8a4ecb15 Author: Ondrej Filip Date: Tue May 30 16:08:29 2000 +0000 Don't send empty LS update. commit a548a7e167d50587aac4549d32924c95dc329e99 Author: Ondrej Filip Date: Tue May 30 15:05:47 2000 +0000 Bug in direct ack (via update). commit 4513280611d6c4e3409bf75139a9bd844843d462 Author: Ondrej Filip Date: Tue May 30 15:04:52 2000 +0000 Bug in socket closing. commit ef6f26b417060f9ac6c26224469b909a0c3aa933 Author: Ondrej Filip Date: Tue May 30 15:01:51 2000 +0000 Bug in lsa comparision. commit 2aa476a535c878a412bb732eae16d97848f07ff3 Author: Ondrej Filip Date: Tue May 30 13:39:06 2000 +0000 Yeah, the endianity bug found. commit 76e2514328a71abd1ed37b9b32421d2ab924b4c0 Author: Ondrej Filip Date: Tue May 30 13:25:47 2000 +0000 Better dumping. commit 7b099bf9a73b4a81f74d90fa8f413c9ebd85f384 Author: Pavel Machek Date: Tue May 30 11:50:17 2000 +0000 Recovering after change linuxdoc->birddoc commit 068b41272e8fbb81882a187dcef6d5f3d4e43ed2 Author: Pavel Machek Date: Tue May 30 11:27:42 2000 +0000 Don't say too bad things about our concurence. commit e9df1bb64786b24a230686310aeb4850b93fa5bb Author: Pavel Machek Date: Tue May 30 11:23:47 2000 +0000 Small change in working to make it obvious we are free software. commit 1cb10462c33731817f61ffbdd2e42c538baf0e0f Author: Pavel Machek Date: Tue May 30 11:22:12 2000 +0000 Date removed. commit f3b33928ce43794d499dc0e1fbbeb623572042d1 Author: Pavel Machek Date: Tue May 30 11:15:19 2000 +0000 Tried to change garbagetime -> garbage time to be more consistent. commit 24e1e2005b0728bfc404f248efb7d17b34cb0910 Author: Pavel Machek Date: Tue May 30 11:09:09 2000 +0000 Another testbed for filters. commit 04c3a83c60253d5c71500194a19160538c0da034 Author: Ondrej Filip Date: Tue May 30 11:07:31 2000 +0000 Better inicialisation. commit 0dc4431cde1eeb06d9b4d7dbf18242919ce2811a Author: Pavel Machek Date: Tue May 30 11:07:22 2000 +0000 Access to all attributes we should be able to access seems to work. commit 5970fcda8c4eb2cfe69c04d50429855c7c57bb6d Author: Ondrej Filip Date: Tue May 30 10:53:48 2000 +0000 Some exchange between init() and start(). commit 26c09e1d25abff7fb88959dc6fbaa7ae5eb295ad Author: Pavel Machek Date: Tue May 30 10:42:39 2000 +0000 Added read-only access to all required fields in rta. commit 2d6627a7a5e52f8314520f9aefd82040e24849cb Author: Pavel Machek Date: Tue May 30 10:42:00 2000 +0000 Fixed bug in RIP docs. commit 73232f6b18222d73b38eae58e2c4c90062202709 Author: Ondrej Filip Date: Tue May 30 10:36:57 2000 +0000 Better rt dumping. commit 2bdb5e0083b6f24d29d74bb5e62cd13d724ba54f Author: Pavel Machek Date: Tue May 30 10:23:04 2000 +0000 Cleaning static attributes commit 05dbc97b13534eb886945d1f291aaba34238c99c Author: Ondrej Filip Date: Tue May 30 10:20:14 2000 +0000 Bug in rt_notify. commit fe613ecded2fca875a146e1c07713f131e85f7ff Author: Pavel Machek Date: Tue May 30 10:13:32 2000 +0000 Access to few more attributes is needed. commit f7876c36602015dbf6d7aa3d73fda5ad1c2f6c5a Author: Pavel Machek Date: Tue May 30 10:13:15 2000 +0000 More todo in documentation. commit 298f2530ec05ee86c52f2fbce306ac186a3f6dd8 Author: Pavel Machek Date: Tue May 30 10:13:02 2000 +0000 Moved description of filters to programmers docs. commit 9e85a5e6f26866a255577ff10786c12a64cba624 Author: Martin Mares Date: Mon May 29 22:16:04 2000 +0000 Delay user input whereever appropriate. commit 4761efdb43aa128fa0326963d88debe8fb942c84 Author: Martin Mares Date: Mon May 29 22:10:18 2000 +0000 Tracing of CLI connections/commands can be now controlled by `debug commands ' in the configuration. Level 0 means no tracing, 1 means connections only, 2 includes all commands. commit 26eee1c33ac90ccbc5753afac06d34980fade2b8 Author: Martin Mares Date: Mon May 29 22:09:29 2000 +0000 Updated TODO. commit 7294f68b3b3474183434ae05b43a344f1bfce6db Author: Martin Mares Date: Mon May 29 22:08:04 2000 +0000 `path metric' and `disable after error' are switches, not numeric clauses. commit e67af42805c16093bb720a1bd04ad8932e86e49e Author: Martin Mares Date: Mon May 29 21:58:35 2000 +0000 Support --version and --help. commit 5459fac61f3a645c636bdf32c140f4d7083034d2 Author: Martin Mares Date: Mon May 29 21:03:27 2000 +0000 Added BGP documentation. commit 56ab03c71f35c6c360b58b88f9e524c97714fdf6 Author: Martin Mares Date: Mon May 29 13:47:18 2000 +0000 Added introduction to BGP. commit 0e4789c2c3a8f217f01a4e472c8dd45db609c34b Author: Martin Mares Date: Mon May 29 13:13:58 2000 +0000 Added Kernel protocol documentation. commit d9d41c60426ab1896bc689cd2a26c51f49e27e3a Author: Martin Mares Date: Mon May 29 12:46:27 2000 +0000 Capitalize properly in Install section. BTW, what about configure options and similar things? commit 4f88ac47c671af2221061b793fa495a78994e44a Author: Pavel Machek Date: Mon May 29 12:23:49 2000 +0000 Reduce number of chapters -- having subchapter for 2 lines of code looks ugly in output. commit 0e694e041a99860454fe0a74eb83133d89896d62 Author: Martin Mares Date: Mon May 29 12:18:30 2000 +0000 Minor fixes as requested by Pavel. commit 440439e3cc2ce7a9e6b36e6801f37c42cce1a729 Author: Pavel Machek Date: Mon May 29 12:05:56 2000 +0000 Really short installation section added. commit 04a22949d7f63d6979642e41ded0f61d7a477980 Author: Martin Mares Date: Mon May 29 12:05:21 2000 +0000 Renamed the DTD from linuxdoc to birddoc. Pavel, please check whether it builds in your environment as well. commit 897cd7aa559033aae99281e569a5153a22a952f9 Author: Martin Mares Date: Mon May 29 12:03:28 2000 +0000 Tried to write a better introduction. commit 9d8934891405348ad925d8421b673ea979f256eb Author: Pavel Machek Date: Mon May 29 11:53:24 2000 +0000 Docs updates. commit 79a2b697e3c94a787d72db4ed85b78928d3240c2 Author: Martin Mares Date: Mon May 29 11:30:25 2000 +0000 Added description of Static, Device and Direct protocols. commit 98627595fb4223991d60f809bbeac98cf34aabfb Author: Pavel Machek Date: Mon May 29 11:22:43 2000 +0000 Better description of how route is selected. commit d247d261e55bec7fadfef89c39ca3257816af771 Author: Pavel Machek Date: Mon May 29 11:22:30 2000 +0000 Info about client. (Mj, if you tell me that's trivial, what about you writing it?) commit 2f647f3f9f51effbb63aee5bb2c45d054b7922e4 Author: Pavel Machek Date: Mon May 29 11:13:51 2000 +0000 Added "what is router" to introduction. commit 1b55b1a3640da3ec2b032dcea3f4f7cbdff82303 Author: Martin Mares Date: Mon May 29 10:32:37 2000 +0000 Spelling fixes. Added skeleton for subchapters on all the protocols. Each subchapter should contain: Introduction (brief intro to the protocol, where should it be used, references to the relevant standards) Configuration Attributes Example Added a more detailed description of RIP attributes. commit e9d6b1d19fc35e611aa5a6020c0b531dee96d77d Author: Ondrej Filip Date: Sun May 28 20:11:56 2000 +0000 Kosmetic change in debugging. commit f7c0525edcffc6c85d0e526c4c9741b06fc521d2 Author: Ondrej Filip Date: Sun May 28 19:16:04 2000 +0000 get_route_info() added. commit d150c6379c03a9df98ff5dd53a6442a10713b571 Author: Pavel Machek Date: Sun May 28 19:11:08 2000 +0000 Documentation update. commit cdc25e8db7bfb38a9aca71abc5c202c25f4b0732 Author: Ondrej Filip Date: Sun May 28 19:07:39 2000 +0000 To find out a type of route (external, inter/intra area) commit 4414d9a57a0dae3da0e0e0d924bf8cab89070716 Author: Ondrej Filip Date: Sun May 28 18:49:33 2000 +0000 get_status() implemented. commit d5f029df482e596ccdbac341f605f6f809229db1 Author: Ondrej Filip Date: Sun May 28 18:34:20 2000 +0000 Just added some debug(). commit 4bd28fb68e6e691aee87cec41f219224e2dd69dc Author: Ondrej Filip Date: Sat May 27 15:36:02 2000 +0000 Better shutdown. (Flush my own router LSA and send 1WAY to every neighbor.) Ext LSA originating and flushing added. commit e8085abaa76c32bb325e378dfe2851bc98602c1e Author: Ondrej Filip Date: Sat May 27 14:17:35 2000 +0000 Originating of external LSA. commit 2d5b999236c20d293006af0b4d94af7ae04dd2a7 Author: Ondrej Filip Date: Fri May 26 19:04:18 2000 +0000 Import control implemented. commit 216fd83c4b213ea3774d2c536ae089ea1e81b443 Author: Pavel Machek Date: Thu May 25 16:28:08 2000 +0000 Spell checking. commit 9b24a6fb94049691075dfcdc00e2a0ae244c2325 Author: Pavel Machek Date: Thu May 25 16:17:54 2000 +0000 Text version generated from lynx looks as ugly as hell, sgml is much better at generating nice output. Unfortunately, sgml output contains a^ha highlight some printers do not like. commit d26524fa0c06f6716d5e226b18d7d4770924c6d4 Author: Pavel Machek Date: Thu May 25 15:28:24 2000 +0000 Add section about routing tables. commit ad9074e9ba2f2c1fa7e681b5f79f9049e5c640f8 Author: Pavel Machek Date: Thu May 25 15:20:40 2000 +0000 Cleaned up warnings. commit 69477cad708235f2ab79796dc62c06d3c879111c Author: Pavel Machek Date: Thu May 25 15:11:13 2000 +0000 Add section about utility functions in filters commit 4a5bb2bf1bbbb7d2bba7776af481a13a58ec39ae Author: Pavel Machek Date: Thu May 25 15:01:08 2000 +0000 Description of types needed for BGP. commit 9a09a64bb4160a5bb79cdf91bd95b7f77966f62e Author: Pavel Machek Date: Thu May 25 14:58:38 2000 +0000 Use ? in path matching to avoid /* trap. commit ba1dda495ad29cd86260533828ce38c7d327f045 Author: Pavel Machek Date: Thu May 25 14:50:46 2000 +0000 SGML correctness fix. commit 0e5373fd823d174d0cdd7820fc94cdbe4b0db5a3 Author: Pavel Machek Date: Thu May 25 12:33:42 2000 +0000 Some more documentation, plus minor fixes. commit 72282e2a1b52552eadd61a86659119db8478427d Author: Pavel Machek Date: Thu May 25 12:33:15 2000 +0000 Fixed comment not to be misleading. commit 416e3ee4b07d9ed30ada45eee736d877efe139db Author: Martin Mares Date: Sat May 20 11:00:14 2000 +0000 Get Linux version from , not `uname -r`. commit 2eca3b3a9ce8ea405f81cb1dbf55b79d3b2d3c18 Author: Martin Mares Date: Fri May 19 19:49:33 2000 +0000 Routing table garbage collector gets really called. commit 0ba8a6147d2a6ca4611c9e87e6b9d640d94966b4 Author: Martin Mares Date: Fri May 19 19:40:12 2000 +0000 Fixed a very nasty bug in FIB iterators. commit d2a7c0e9b2b51287cca6bf9f9ef513cbe29d4dbd Author: Martin Mares Date: Fri May 19 18:05:19 2000 +0000 Don't print trace messages about null updates. commit 3ced9b349daeb64357136311e436401c246d7777 Author: Martin Mares Date: Fri May 19 18:05:01 2000 +0000 Fixed freeing of non-embedded extended attributes. commit 075898dea7ee73b49462af3d3ab0269fd46afcc4 Author: Martin Mares Date: Fri May 19 18:03:53 2000 +0000 No more problems when protocols gets disabled during feeding. commit dc6405d27e1ecedf6289039c7b3ed94c50683b2d Author: Martin Mares Date: Fri May 19 17:21:42 2000 +0000 Latest changes by Pavel have removed the error messages printed after unsuccessful socket open, but replaced them by segmentatio fault! Grrrrrrrrr. commit e66e6c2119e9de2f8012e587eafe752723706265 Author: Pavel Machek Date: Fri May 19 16:57:40 2000 +0000 If community list is not defined, act as it is empty. commit 9511a483b1b735d8bf9f671d494b363da5719ecc Author: Pavel Machek Date: Fri May 19 16:44:25 2000 +0000 Less error messages in case sk_open fails. commit eb4097e4e47db23403c4050b43ea5136ffbe4b41 Author: Pavel Machek Date: Fri May 19 16:22:53 2000 +0000 Added name of protocol to messages being logged. commit af0b25d20d1476d81696fb0241a815fb45168f53 Author: Pavel Machek Date: Fri May 19 15:59:21 2000 +0000 More updates. commit 242352b7a7f1b181b6e42dc77b998005d3f07c78 Author: Pavel Machek Date: Fri May 19 14:13:49 2000 +0000 Improve docs of log statment, improve markup. commit 8af8a87375f3a609583866a5f50487baebe38e2e Author: Pavel Machek Date: Fri May 19 14:05:55 2000 +0000 Descriptive lists rendered better in TeX. commit a0dd1c74334fa22588f9d1c8cb73013f1940b974 Author: Pavel Machek Date: Fri May 19 13:58:39 2000 +0000 Some spellchecking, and use right tags for right things. commit 5e88d7302599b7ac521624c77adf0b3c72601670 Author: Martin Mares Date: Fri May 19 11:01:41 2000 +0000 BGP now reports originating AS and origin type in get_route_info(). commit f49528a3dfa034415527824cbbd0762f3829f0cd Author: Martin Mares Date: Fri May 19 11:01:06 2000 +0000 Added as_path_get_first(). commit f7ad556f2017075abaef659bf018a0ce215b13b3 Author: Martin Mares Date: Fri May 19 11:00:47 2000 +0000 Commented out the `inserting entry which is already there' message since it's pretty normal: during feeding of the protocol, a new route can appear which will be announced normally and then repeated by the feeding process. commit 76dfda9e74580b6c07206b7afbbdafeea36ad08f Author: Martin Mares Date: Fri May 19 10:59:47 2000 +0000 Fixed a buglet in asynchronous feeding and increased maximum number of routes allowed per feeding phase. commit ac5d801217b4b85a5f716ace25f7f9ac48dfee0f Author: Martin Mares Date: Fri May 19 10:46:26 2000 +0000 Asynchronous feeding of protocols. commit 0850ce22d76c80c4f6a10fd0139d4cc903716bfa Author: Ondrej Filip Date: Wed May 17 21:20:47 2000 +0000 Smal debug bugfix. commit 6d5e703dc9ac387d72005f3b5da82e80275d5fc6 Author: Pavel Machek Date: Wed May 17 20:23:05 2000 +0000 Minor cleaning commit 00c1f79a79281c16beec132d945db480daca958d Author: Ondrej Filip Date: Wed May 17 20:01:25 2000 +0000 rte_same implemented. commit bbd76b421a1975560084e50669db9cacd61d2b58 Author: Ondrej Filip Date: Wed May 17 19:27:51 2000 +0000 rte_better implemented. commit 9f0d45d634ac38d54ed92c5726fbaed65850e15f Author: Pavel Machek Date: Wed May 17 12:14:05 2000 +0000 Finished cleanng up mess: multiplication reinstalled. commit 4ee2178935b1f4cdd465e290c13f6580901cec8d Author: Ondrej Filip Date: Wed May 17 00:28:45 2000 +0000 Don't die, if you receive strange LSA. commit 7f6b3cf247c0df8d10e9ed29a5ff6a6af5e1cf8f Author: Ondrej Filip Date: Wed May 17 00:28:11 2000 +0000 Typo in comment. commit 18a0c0bb763d918f3a06bfeb2be2b1051a7f4629 Author: Ondrej Filip Date: Tue May 16 23:59:38 2000 +0000 Downing of interface should work. commit 8fb0c2c298fbfa133cf783a1547bc3b1c84fe466 Author: Ondrej Filip Date: Tue May 16 23:24:50 2000 +0000 Calculation of external routes finally works. commit 31834faaf3ab055242e3a9998a37029b56f54d8a Author: Ondrej Filip Date: Tue May 16 22:43:30 2000 +0000 Ehmm, removed 'if(1 || ...' so I can test the second part . commit b1c9d871614874092e397ae505799be82284713d Author: Martin Mares Date: Tue May 16 22:37:53 2000 +0000 Fixed the horrible mess Pavel has created with his last commit. commit 508c36ab7981a8e50d1235c2c443491e4b04aa01 Author: Ondrej Filip Date: Tue May 16 22:34:49 2000 +0000 Routing table calculation for ext LSAs having next-hop=!0.0.0.0 commit a96a979d5b2b3a7ef02d878e9598d3268cb4c8a7 Author: Pavel Machek Date: Tue May 16 18:50:51 2000 +0000 Line numbers for runtime errors (what's wrong with cvs? I could not commit this from home) commit 7581b81bd7a77b5baebbd43833c00574d543c62e Author: Pavel Machek Date: Tue May 16 18:47:06 2000 +0000 More additions to documentation and spellchecking. commit e5a47266d0d6b8614c5199ea513de029b35552b0 Author: Martin Mares Date: Tue May 16 15:08:52 2000 +0000 Turned off LOCAL_DEBUG. commit e79671a72ccd392debcce1cdc05e46747eaf37e2 Author: Martin Mares Date: Tue May 16 15:08:43 2000 +0000 Fixed incorrect error message about router ID syntax. commit 5b846de6a6361b3c8aac84438e7b332c972f2a08 Author: Pavel Machek Date: Tue May 16 15:05:05 2000 +0000 Interface dummy is too strange for me... but psst, that's secret. commit be77b6890c5f6b956553c0432554e5912a30528f Author: Martin Mares Date: Tue May 16 15:02:33 2000 +0000 Poisoning: take there... commit d6796e7b546bd0a28b85666a95eda039eabc5c5f Author: Pavel Machek Date: Tue May 16 15:02:27 2000 +0000 Don't segfault when someone adds passwords. commit 2f2663bdb735ca155c32b0e12da814e62bbf9e9d Author: Pavel Machek Date: Tue May 16 15:00:15 2000 +0000 Password same now actually works commit 898fdd85dc4568816ac0436c1b012f2fb35ef3e4 Author: Pavel Machek Date: Tue May 16 14:58:06 2000 +0000 Rip should now reconfigure itself only if needed. commit 60de3356ab9b1996a84e3ba2865176a078b6d0ca Author: Pavel Machek Date: Tue May 16 14:24:33 2000 +0000 Resolved shift/reduce conflict commit e2f4f275646d21de363c32ff3c8fb4f492f07c04 Author: Martin Mares Date: Tue May 16 13:53:44 2000 +0000 Oops, the poison was too deadly... commit b8e60d3562277762ec372424482b22c024e657d6 Author: Martin Mares Date: Tue May 16 13:51:31 2000 +0000 Added poisoning of free'd objects when we're debugging. commit df9f0fb30a7046872eff21624a315d5fd56e938f Author: Martin Mares Date: Tue May 16 13:43:26 2000 +0000 Don't log state changes if nothing user-visible has changed. commit f990fc61e0dd13ae90c9bbff811736dfd52988b0 Author: Martin Mares Date: Tue May 16 13:36:38 2000 +0000 When in persist mode, don't delete routes from kernel tables even if they cease to exist in our routing tables due to protocols having shut down. commit c5a06f65ee20328b8d0f2276287e223e4fd4a595 Author: Pavel Machek Date: Mon May 15 12:27:45 2000 +0000 Allow other operations than +. commit f4ab23174688920e44bb4cae6e8b4f280a066e28 Author: Martin Mares Date: Mon May 15 12:19:28 2000 +0000 bgp_get_status: If protocol is down, don't print BGP state. commit cbfd671f114a96095f021662ad1cf0eaa6d089c1 Author: Pavel Machek Date: Mon May 15 12:19:26 2000 +0000 Allow accessing defined symbols. commit cc590a11a7a285463dff89d0bd677d0762dd8e45 Author: Martin Mares Date: Mon May 15 12:15:18 2000 +0000 Changed syntax of expressions. Each `expr' can be now either a numeric literal or a symbol or parenthesised filter expression. commit 6be662d917822e9a23b0abd613e170c1d42bfdbe Author: Pavel Machek Date: Mon May 15 12:07:09 2000 +0000 Use new eval mechanism for testing filters. commit e3f2d5fce3e339bb34f14d7b2569c1bd43b741ba Author: Martin Mares Date: Mon May 15 11:48:23 2000 +0000 Cleanup of configuration. o Use `expr' instead of `NUM' and `ipa' instead of `IPA', so that defined symbols work everywhere. o `define' now accepts both numbers and IP addresses. o Renamed `ipa' in filters to `fipa'. Pavel, please update filters to accept define'd symbols as well. commit 3b1c523d79763b22e0fe06862ff349fd94e816b1 Author: Martin Mares Date: Mon May 15 10:53:56 2000 +0000 Got rid of startup functions and filters_postconfig(). By the way, how do you expect pointers to fit in an int? commit 1c20608e02109ef0839e0168d100c75f0cc65fd9 Author: Martin Mares Date: Mon May 15 10:49:38 2000 +0000 Added f_eval_int() and EVAL configuration command. commit 9449c91ab2eb962b17989125c712f805f82a092b Author: Martin Mares Date: Sat May 13 11:42:42 2000 +0000 Added `show route for ' which looks up route leading to given network. commit 56d6c530eba46dde7280d6743fea7e750f2d5635 Author: Martin Mares Date: Sat May 13 11:42:06 2000 +0000 Added fib_route() which does (although very slow) lookup of longest-match routing in a FIB. commit d3abfbc68d7f921b2547b39a6baa9bee6c89b78d Author: Martin Mares Date: Sat May 13 11:41:26 2000 +0000 Added prefix_or_ipa. commit 758458be054ebdf4cd77620faf214f2b491a49dc Author: Martin Mares Date: Sat May 13 11:17:49 2000 +0000 Unified parsing of prefixes. Had to rename `prefix' in filters to `fprefix'. commit 02bd064ab76f163313261dad5c273cb376be2a75 Author: Martin Mares Date: Sat May 13 11:02:02 2000 +0000 Adapted to new rt_notify semantics. commit e4bfafa1008918cf904ede023feb18fa4cb7d524 Author: Martin Mares Date: Sat May 13 11:01:41 2000 +0000 Manual enable/disable works right. commit 08f0290a1ebf94624c4eb4cbcb10e2b35a846432 Author: Martin Mares Date: Sat May 13 11:00:37 2000 +0000 Changed semantics of the rt_update hook. The attribute list we pass now contains all attributes, not just the temporary ones. This avoids having to merge the lists inside protocols or doing searches on both of them. Also, do filtering of routes properly. (I'd like to avoid it, but it's needed at least in the krt protocol.) commit bfd7117846271a5e54271ee5248addd7e10ad021 Author: Pavel Machek Date: Fri May 12 10:57:36 2000 +0000 Documentation fixes suggested by mj commit 7e681ef3603862829c3bbf6b5c81c69c34faeb81 Author: Ondrej Filip Date: Fri May 12 00:22:43 2000 +0000 Calculation of external routes works. :-) commit be2bb403414b2d8cd608b710a29992b2c8a4c8b0 Author: Ondrej Filip Date: Thu May 11 22:02:53 2000 +0000 Minor changes. commit 5da1f935374b2e0435b67cc4d867369d522e62ff Author: Ondrej Filip Date: Thu May 11 22:00:55 2000 +0000 Bugfix in flooding. (bad size) Better debugging. More robust in receiving. commit c8d1f3feb2e2ca12aee76b1ce907dfff31c1012b Author: Ondrej Filip Date: Thu May 11 22:00:16 2000 +0000 Better debugging. More robust. commit 7a42e6ce899ceec7329212b9ceca4f15387fc280 Author: Ondrej Filip Date: Thu May 11 17:14:57 2000 +0000 Bugfix in network LSA originating. commit 67edcf392f74e1c79ea521d583df7ca365caea0b Author: Martin Mares Date: Thu May 11 16:55:26 2000 +0000 Updated README, generating the first alpha release. commit 0e5aa966cca94152363b2d8e9c1b316c04d90adb Author: Martin Mares Date: Thu May 11 16:30:56 2000 +0000 Multicast problems should be gone, although the fix is Linux only and we'll need to figure out something better when working on new ports. commit 28323d9ddbdcfa35c6dec139da4eefca584b143e Author: Martin Mares Date: Thu May 11 15:05:13 2000 +0000 Several minor RIP changes (Pavel, please check as usually): o Use FIB_ITERATE_INIT instead of calling the function fit_init() which is explictly marked as private in route.h. o When printing trace messages, don't spit out protocol name twice. o Some messages are a bit more verbose. o Added a bunch of FIXME's. o When running in broadcast mode, don't forget to bind the local end of the socket to the same broadcast address, so that we don't get the broadcasts looped back via different interface. I'm just going to look up the same problem for multicasts. commit 109c2f6cf350069c12abb7d182da6458ff56c1c7 Author: Martin Mares Date: Thu May 11 12:30:06 2000 +0000 If a broadcast address is missing, go fake one. commit 2138d3b4d84058338ad4010eff8da62afa6531ab Author: Martin Mares Date: Thu May 11 12:20:07 2000 +0000 Use correct flags for the LOCAL_PREF attribute. When an invalid attribute is found, copy the entire attribute to the data section of the NOTIFICATION message. commit 6e06e6eef098859da95ff56a8ee9b4c75467901a Author: Pavel Machek Date: Thu May 11 12:00:35 2000 +0000 Critical files from linuxdoc1 distribution checked in. commit 0e7a720a1c8119912c00edf893702857c0d39d04 Author: Pavel Machek Date: Thu May 11 11:54:03 2000 +0000 Use instead of in bird.sgml, fix url references. commit 7692aad10c22a58a6f83d82fc0b11db94cc777f9 Author: Pavel Machek Date: Thu May 11 10:47:33 2000 +0000 Don't include Rules: they are not needed and break stand-alone make of documentation. commit ec21aecfddde3be2b061850a050108265dfbf194 Author: Pavel Machek Date: Thu May 11 10:33:18 2000 +0000 Fixed nasty segfault in rip. commit 10f5c47d2e3d9fdeb2dd4ade1d09a1e06b53a7f6 Author: Pavel Machek Date: Thu May 11 09:41:16 2000 +0000 Some more paranoia into rip_insert and rip_delete commit 94d1a6c9dc9ac578cb88428462ab41f113ca4e23 Author: Pavel Machek Date: Thu May 11 09:36:55 2000 +0000 Unused variable killed. commit 394920a09c6163d2b98896802526c79c82f52d20 Author: Ondrej Filip Date: Wed May 10 23:42:37 2000 +0000 Test better lsa size. commit 31dca4353460b7a8bfb272e63ceac46deb3a6944 Author: Ondrej Filip Date: Wed May 10 23:42:13 2000 +0000 Be more verbose. commit 74ac7cdb1afe1e23a130b290f4a366268073f62c Author: Ondrej Filip Date: Wed May 10 23:41:52 2000 +0000 Bugfix in (B)DR election. commit ff73f1d63d2d1e49737ea2471dc5cb92e9591847 Author: Ondrej Filip Date: Wed May 10 23:41:18 2000 +0000 More robust tests in packet receiving. commit 13741548a6a75479577ea991bad1e38a4fba6320 Author: Ondrej Filip Date: Wed May 10 15:04:21 2000 +0000 Some better lsa checking added. commit a9c41c854802d1a8d44e666548423589022111c8 Author: Ondrej Filip Date: Wed May 10 14:29:00 2000 +0000 Out dump deleted. commit 2a41c8d9fcd2907a531c7306e174f51218486d57 Author: Pavel Machek Date: Wed May 10 13:42:50 2000 +0000 use password_same utility function commit 45a48e2de21cbf1a48c6f478ed068e48f20f918b Author: Pavel Machek Date: Wed May 10 13:42:46 2000 +0000 password_same utility function commit a3f657ac764ff38a5829f27a0dccbf6220043a1a Author: Ondrej Filip Date: Wed May 10 13:35:49 2000 +0000 Ever test possibility of forming of adjacency. commit 3e474192745e7e92d27cad7ffa16a8395e884cf2 Author: Pavel Machek Date: Wed May 10 13:23:21 2000 +0000 Inlined metric and mode into struct rip_interface to make reconfig work. reconfigure is conservative but should work. commit 30aa02d70df2275d2289d9b736d879b9951bcaee Author: Pavel Machek Date: Wed May 10 13:05:39 2000 +0000 rip_reconfigure done right commit b8524e9be4f1d15f4cd2cd365d7842eff8d5a499 Author: Pavel Machek Date: Wed May 10 12:48:06 2000 +0000 ipa_same does not exist. commit 0bff946c0a29469b669939813e5a2861c1f010fb Author: Pavel Machek Date: Wed May 10 12:46:47 2000 +0000 Nicer messages from rip. commit 6f3849774ffe35e445e33ba03f041c1a84ba35f1 Author: Pavel Machek Date: Wed May 10 12:38:05 2000 +0000 Use ea_get_int instead of ea_find. commit c7e46aae66861ce282e9b1a0140fa422763094ce Author: Ondrej Filip Date: Wed May 10 12:37:43 2000 +0000 Destroying of neighbor moved from 'hello' to 'neighbor' and improved. commit 7f5f44bb9248f05f397617f3874feef26bbb0b0b Author: Pavel Machek Date: Wed May 10 12:32:45 2000 +0000 Reconfigure hook copied from bgp. commit 84a1305437ddd893771c43d1a9bff32260a56789 Author: Pavel Machek Date: Wed May 10 12:26:09 2000 +0000 Send first udpate sooner. commit 14758d87c48e9d829f58ace0736b0c5b3c7dc6ae Author: Pavel Machek Date: Wed May 10 12:23:06 2000 +0000 Only announce change to main routing table if it is better than current. commit 353f3261385267fd07b634284989a760fc37b79d Author: Ondrej Filip Date: Wed May 10 12:22:00 2000 +0000 Better dumping. commit 5e50f0a0289517e64e026cb27e886d49e6044aca Author: Pavel Machek Date: Wed May 10 11:57:56 2000 +0000 Don't touch used memory. commit e8bd039da8de22de85bd135617b4a8ce9c979585 Author: Ondrej Filip Date: Wed May 10 11:52:39 2000 +0000 Bugfix in ip_addr endianity. commit be3b6dc574c26ab3292fb2ceb94809242bea3d79 Author: Pavel Machek Date: Wed May 10 11:48:34 2000 +0000 Killed unused variable. commit 28950169e7ac82ceb9a6d72fe2789714b4073eb2 Author: Ondrej Filip Date: Wed May 10 11:48:21 2000 +0000 Bug in (B)DR election fixed. commit d9f89e011498ec54006a026d9e0dd963db663ab0 Author: Pavel Machek Date: Wed May 10 11:40:30 2000 +0000 You can now say "mode multicast". commit 65a9c57175b60048d5501b2c951d5e46b3909fcb Author: Ondrej Filip Date: Wed May 10 11:22:08 2000 +0000 Change u32 to ip_addr in ext lsa. commit aa1e082c6779505e9ca24ba9f9d6cdfd4c647b06 Author: Ondrej Filip Date: Wed May 10 10:47:17 2000 +0000 Calculation of external routes. commit 4bfe4e8551722533cc99c776b3b70818ef59bf24 Author: Pavel Machek Date: Wed May 10 06:56:42 2000 +0000 Fix segfaults by using new ea_get_int. commit c0100454cf37833d23fdb9d24412de659f683c12 Author: Pavel Machek Date: Wed May 10 06:54:40 2000 +0000 Added more convient interface for ea_find. What is special about int default;? Compiler chokes on that! commit fe95ab68164f0c9f18e65f7965ac4d93b24bef97 Author: Ondrej Filip Date: Tue May 9 21:52:58 2000 +0000 FIXME's removed by deleting them. :-) commit 32fa4a5a461eb1af4146d9985663d90fcddd9697 Author: Ondrej Filip Date: Tue May 9 21:06:48 2000 +0000 Premature aging of self-originated LSA received in flooding. commit 3b8b1bd03709d2fa2eab8ec81321717e3b58dcaf Author: Ondrej Filip Date: Tue May 9 19:38:34 2000 +0000 Better dumping. commit a3ae6246c29ecceefc1e867c7b5f73a5b3c857c9 Author: Ondrej Filip Date: Tue May 9 19:38:16 2000 +0000 Bugfix in lsrt slist adding. commit b224ca32cfb5268db4984b5a640ab8a73852059b Author: Ondrej Filip Date: Tue May 9 19:36:32 2000 +0000 Flushing of old LSAs added. commit 850fda2518d6e91ca8e126ff91adad62fd507276 Author: Ondrej Filip Date: Tue May 9 18:35:57 2000 +0000 Backup seen is not called so often. commit cd22a62b3ce3aa4cf8985337657ec9750176aa49 Author: Ondrej Filip Date: Tue May 9 18:20:39 2000 +0000 Don't send flushed LSAs. commit 9669362f0577dbda0d7b9495d0c2fec11fa866f1 Author: Ondrej Filip Date: Tue May 9 18:17:34 2000 +0000 Many bugfixes. (I added one entry twice to slist.) Debug cleanup. Retransmiting of unacknolegded LSAs commit 5f743d969739d6dca12b51561baac3131e160429 Author: Ondrej Filip Date: Tue May 9 13:56:47 2000 +0000 Many bugfixes. Actually, how could this ever work? :-) commit 5d608eba1636e307624300fdd47b9024be92d39a Author: Ondrej Filip Date: Tue May 9 12:31:38 2000 +0000 Bug fix in sending updates. commit 0e1b949be7f71d038e871dac159b424e76978bff Author: Ondrej Filip Date: Tue May 9 12:18:41 2000 +0000 Bugfix in testing of possibility of adjacency. commit 432996f40fceb58cd5ee5026eb4f7018ef6af1ef Author: Ondrej Filip Date: Tue May 9 12:03:57 2000 +0000 Better dumping. commit 54ac9d2e03c6ae44b4e183c9bcf963196218c477 Author: Ondrej Filip Date: Tue May 9 12:02:48 2000 +0000 Bugfix in hello. commit 4057093fa40248c5b607039481576a6c5e4e902b Author: Ondrej Filip Date: Tue May 9 11:52:44 2000 +0000 Small cleanup. commit 551d44438275e9ebc9e7590814f413ac7d0cccd6 Author: Ondrej Filip Date: Tue May 9 11:29:52 2000 +0000 Sorry, it didn't compile. :-( commit b29c620f90d429b868038984a5427470f00aebac Author: Ondrej Filip Date: Tue May 9 11:27:31 2000 +0000 Another bugfix in neighbor state machine. commit 279a3b76d193944431a992a1ac43543fe15ab903 Author: Ondrej Filip Date: Tue May 9 10:47:10 2000 +0000 Small bug in neighbor state machine. commit fafe44b651f68d0a588cac94ddada8a1270adb97 Author: Ondrej Filip Date: Tue May 9 00:03:08 2000 +0000 Just added declaration of AS Ext routes calculation. commit 43e75f38e7b8716efb3729ee56fd4a879e03c1dc Author: Ondrej Filip Date: Mon May 8 23:46:31 2000 +0000 Do not stop lsrr_timer in FULL state. Use it for retransmition. commit ed4a53c6a5685d04fe2b0cceda83860324f4892c Author: Ondrej Filip Date: Mon May 8 22:50:37 2000 +0000 Some changes in debugging. commit 9bacea42112216e604bd55e3027e019e131304dd Author: Ondrej Filip Date: Mon May 8 22:49:58 2000 +0000 Fixed some FIXME's by deleting them. :-) commit 8a3049f6f139622c6976502d931c746449a1fe48 Author: Ondrej Filip Date: Mon May 8 22:42:56 2000 +0000 Useless '\n' in log() commit eae4fcf2539703d0dbd47e29ab24be29e0ddc2ff Author: Ondrej Filip Date: Mon May 8 22:40:55 2000 +0000 Stopping RXMT timer when going to lower state than EXSTART. commit d8033f2238922f3c63c247e924f1e31659d821ef Author: Martin Mares Date: Mon May 8 22:37:16 2000 +0000 Generated first public alpha release. Unless you object, I'll announce it today (9.5.) at noon. commit 8aecbf160adb15eef3f66d750745928f66f8a310 Author: Martin Mares Date: Mon May 8 22:33:50 2000 +0000 New example config. commit c976342828d5de3d16b59d623f4f7fb03f52acc9 Author: Martin Mares Date: Mon May 8 22:33:38 2000 +0000 Implemented debugging function rlookup() which you can call from gdb to see what resource does the address given as a parameter belong to. commit 0521e4f68490d5ef5cc6ba6b2b4e4edf7cf6aa1a Author: Martin Mares Date: Mon May 8 22:33:02 2000 +0000 rt_prune: Don't kill routes from protocols in FS_FEEDING state. If debugging, call fib_check() on the table's fib. commit c09d1e8df2d5d1ebfb4ce3dfbe93347a83acd99d Author: Martin Mares Date: Mon May 8 22:32:17 2000 +0000 KEEPALIVE TIME ought to set keepalive time, not connect retry time :) commit 5ff0a270cb411d423a78ed13604a5f2b25d4b289 Author: Martin Mares Date: Mon May 8 22:31:58 2000 +0000 In non-debug mode, set default logging to syslog only, not stderr. commit 4524331a3d758106f4ffa6a54a60aeae45341789 Author: Martin Mares Date: Mon May 8 22:31:34 2000 +0000 Fixed type in daemonization code. commit fc0ca2d8e1ab6a71a81f5f12c04f02d670d22348 Author: Ondrej Filip Date: Mon May 8 22:28:42 2000 +0000 Typo in debug. commit a6fdf9c6ac58e2d95d84c58102af8d5f3a70958a Author: Ondrej Filip Date: Mon May 8 22:27:25 2000 +0000 Grrr, useless debug. commit 5ee479aac9e488e15245905c598e778eb787dfe1 Author: Ondrej Filip Date: Mon May 8 22:26:11 2000 +0000 Small typo. commit 0ebb8b64f384d57889271389abe9b8926dde7af8 Author: Ondrej Filip Date: Mon May 8 22:24:22 2000 +0000 Bugfix in new neighbor allocation. commit 77fbd315dfa2dd6b8252cf13386d8b8480234bcc Author: Ondrej Filip Date: Mon May 8 22:10:10 2000 +0000 Better debug output. commit b57a45b81a74c091bbc71966a7c6aacebaf34e57 Author: Ondrej Filip Date: Mon May 8 22:03:29 2000 +0000 Next hop calculation improved. (I ignored stub networks advertised by my neighbors. commit 158b99c912ef5c5cef22fd3e343341cbb52eb105 Author: Ondrej Filip Date: Mon May 8 22:02:45 2000 +0000 Better logging. (%d->%I) commit 8abbde02d46830168b79a1df6c18c3ffaea49b9e Author: Martin Mares Date: Mon May 8 19:11:49 2000 +0000 Several simplifications of the fib iterators. commit 0bcba21e893efb9853a68b04674e4bde9da5a1b8 Author: Martin Mares Date: Mon May 8 19:10:36 2000 +0000 When not debugging, daemonize automatically. commit 33a368ad594822239bfbaa2eab50c76171e09b9e Author: Martin Mares Date: Mon May 8 14:58:00 2000 +0000 Implemented `show route count' which is `show route stats' with exception that it doesn't print the routes themselves. commit 0c3588bf5e43936ea0f1e630dea500912b598c60 Author: Martin Mares Date: Mon May 8 14:53:22 2000 +0000 Don't crash when the socket gets closed between updates. Also, this time not only update `remains', but update it right :) commit 6b5ab87581ba496ad0a9c12ef66f1372e1459685 Author: Martin Mares Date: Mon May 8 14:51:57 2000 +0000 Added `--disable-memcheck' switch which avoids linking of efence/dmalloc, so that we can run in debugging mode with large routing tables. commit e48dae3ed70daf52ad93c4fdc73270ab1510661f Author: Martin Mares Date: Mon May 8 14:51:26 2000 +0000 Stop feeding the protocol if it suddenly shuts down. commit 9ff8f334edec974b16497e1e74172977e0fff221 Author: Martin Mares Date: Mon May 8 14:32:19 2000 +0000 Update `remains' counter correctly. commit d69e5ff2ad8b552c22770e4c85bd7c5afafe2816 Author: Martin Mares Date: Mon May 8 14:29:30 2000 +0000 Use PATH_CONTROL_SOCKET instead of tacking on "bird.ctl" manually. commit cd44b466515578583d46dcb1a0abdae6e658a166 Author: Martin Mares Date: Mon May 8 14:24:19 2000 +0000 Forgot to add a spiky comment :) commit f9254d2349c7e2e3c110f7850e402d1c11624940 Author: Martin Mares Date: Mon May 8 14:19:47 2000 +0000 Autoconf is *evil*. The sysconfdir and similar variables are unusable in C includes as they contain substitutions specific to make. Worked around by creating sysconf/paths.h which is created from the Makefile instead of by the configure script. commit 0bf7386b33fecac40be43f8db5b0ba0356123fd2 Author: Martin Mares Date: Mon May 8 14:18:33 2000 +0000 Updated TODO. commit c0760ab0fc880778f23c71a7874aa38f90e28925 Author: Martin Mares Date: Mon May 8 13:56:11 2000 +0000 Debugging compilation is no longer default. This means that the configuration file is expected in $prefix/etc etc. Use --enable-debug to request debugging. commit d8508f70b0325cd283bc1551c455cdc3aab011fe Author: Martin Mares Date: Mon May 8 13:54:59 2000 +0000 `make install' now works. commit 93d6bf38a6c07b8281e11280d5cdbb721d19f7c8 Author: Martin Mares Date: Mon May 8 13:26:30 2000 +0000 The bgp_list is gone. Incomming connections are now handled in a much more straightforward manner by scanning the active configuration for matching protocols. commit 5d86aefb6c4a8e298ee79dc9cbf7c07196d56b5b Author: Martin Mares Date: Mon May 8 13:12:14 2000 +0000 Really free attributes. commit 818ff1e2b7b8eb8e707608e76ead94e5c6bd442c Author: Martin Mares Date: Mon May 8 12:38:00 2000 +0000 When reporting a bug(), call abort() instead of exit(), so that we can analyse the core. commit c304392e65a3d6554e97bce00146fe5f2bcb64b1 Author: Martin Mares Date: Mon May 8 12:37:39 2000 +0000 Some less socket error messages. commit 507eea4c8b4c52a5ddf232bc180a7a42cf29f074 Author: Martin Mares Date: Mon May 8 12:37:24 2000 +0000 Don't generate corrupted packets when sending only route deletes. commit 9cbf43eb8a7e0186144e95d7b244e0c69b0e9189 Author: Martin Mares Date: Mon May 8 12:09:10 2000 +0000 Don't report refused connections. commit b6c9d8eb2e255b65f29efd1acfd35a4277b3bf14 Author: Martin Mares Date: Mon May 8 12:05:55 2000 +0000 Removed the `async' switch which was used for debugging only anyway. Don't moan when netlink reports lost packets. commit d0126f0bf0098104cd99fedd61a4bdbe7f7b3f1f Author: Martin Mares Date: Mon May 8 11:40:30 2000 +0000 bugs_in_attr_cache_hashing--; commit 79681f4a19d0eca6e40d919a387099f5646f29bc Author: Martin Mares Date: Mon May 8 11:04:22 2000 +0000 Link the instance to the global BGP list as soon as possible. commit 94e935d8a2e02f18e3731624720e8f84be5e9f15 Author: Martin Mares Date: Mon May 8 11:02:53 2000 +0000 Incoming buffer must be at least 8KB long. commit 916c8c0abacfd5ba93353fec9dba84a81845c95e Author: Martin Mares Date: Mon May 8 10:40:00 2000 +0000 Use preferences properly. commit 1151401e2b8b4434bbd1419ff33a48f2848d600d Author: Martin Mares Date: Mon May 8 10:38:51 2000 +0000 Don't crash when reporting deleted routes. Set preferences correctly. commit 92ef4fa719058af80a9dbb39e3d2fbd9314e8a1a Author: Martin Mares Date: Mon May 8 10:38:25 2000 +0000 Preference is a configurable parameter. commit 0117d004945afdfb6cc9a62db4561cd4eddee24a Author: Martin Mares Date: Mon May 8 10:37:45 2000 +0000 Fixed `show route primary'. commit 18c031fae8945409b0ff1139d88092ba19ec2780 Author: Martin Mares Date: Mon May 8 10:13:59 2000 +0000 Debugged printing and pruning of neighbor cache entries. commit 0d3070824da904bd0f3f576b353b738bfa15a53a Author: Martin Mares Date: Sun May 7 11:32:34 2000 +0000 Don't count networks with no routes (they are not displayed at all and will be removed during the next garbage collection pass). commit 23693958aa95edf5baaeaa5baa55725dc4895681 Author: Martin Mares Date: Sun May 7 11:28:59 2000 +0000 Implemented `show route <...> stats'. commit 6998bb9ee345a0e8b558fc87133f1c2a442b7096 Author: Martin Mares Date: Sun May 7 11:28:34 2000 +0000 Squashed one bug in fib_rehash(). No more routes disappearing as if struct by a lightning :) commit 891cec854f84674317fa152b71254fc52d893826 Author: Martin Mares Date: Sun May 7 11:27:23 2000 +0000 Killed one more reference to RTS_RIP_EXT. commit acfce55c8637988954543c60597cd2f1525ba6ec Author: Martin Mares Date: Sun May 7 10:41:45 2000 +0000 Setup of incoming connection is now a separate function. commit ce1da96ee7efc9310f138e4234495557cdef59e2 Author: Martin Mares Date: Sat May 6 22:57:39 2000 +0000 Added commands `show route protocol

' and `show route import

' which show the routing table as exported to the protocol given resp. as returned from its import control hook. To get handling of filtered extended attributes right (even in the old `show route where ' command), the get_route_info hook gets an attribute list and all protocol specific rte attributes are contained there as temporary ones. Updated RIP to do that. Added ea_append() which joins two ea_list's. commit 84f070020500de40e69e6d00df9d41ecc90a3b23 Author: Martin Mares Date: Sat May 6 21:46:09 2000 +0000 IPv6 support compiles on both glibc 2.0 and 2.1. commit 498c33395f99743206088770c441222c76493378 Author: Martin Mares Date: Sat May 6 21:42:19 2000 +0000 Cosmetic fixes. commit 0b7610985cd44435ab40dd2e78646f400db908c5 Author: Martin Mares Date: Sat May 6 21:31:41 2000 +0000 Fixed silly bug in previous commit. commit 67be5b23cd80646c2aa5a9c6a3d373ceecb275b6 Author: Martin Mares Date: Sat May 6 21:21:19 2000 +0000 When rte_update is called for an identical route, don't announce anything. Please implement the rte_same hook in your protocols. It should just compare your metrics stored directly in rte, the rest is done by the core. commit ab1129c1bdea41ff06fd21390cde5667d07f6e65 Author: Martin Mares Date: Fri May 5 17:17:42 2000 +0000 Added skeleton Doc files for the whole developer's documentation. commit b177724896b75159dbc8e203ac0e5a134229ae90 Author: Martin Mares Date: Fri May 5 17:15:56 2000 +0000 Connected the `doc' subtree to global makefiles. All documentation is built in obj/doc (resp. doc/ if you do a stand-alone build). Use `make docs' to make the whole documentation or `make userdocs' resp. `make progdocs' for user manual resp. developer's guide. commit c7d7794bb9a71be58d06c6c9ea67943d3e33a566 Author: Martin Mares Date: Fri May 5 17:14:44 2000 +0000 Added a tool for processing of developer documentation. Everything is controlled by Doc files in source directories (see the corresponding programmer's manual entry for the format and look at Doc and lib/Doc for an example). Currently it generates HTML indices and calls kernel-doc to generate per-section HTML files. commit 249d238c14cafa812db02ea3090b34c58b183cf6 Author: Pavel Machek Date: Fri May 5 09:39:08 2000 +0000 First attempt at documenting configuration. commit beaf86e13c6b9595bc979b5ed9669e3e43f793cd Author: Martin Mares Date: Thu May 4 21:23:10 2000 +0000 Removed RTS_RIP_EXT. commit 9a220cabbc28a4e54f814aa5d596696a15e6544d Author: Martin Mares Date: Thu May 4 20:52:28 2000 +0000 #ifdef out lots of debugging information. The long resource/routing table dump printed upon startup is gone now and if you wish to see it, just send bird SIGUSR1 or use the `debug' commands. commit b3acb10632ce9fa492a92ced1e533f0bf5edee21 Author: Martin Mares Date: Thu May 4 20:49:45 2000 +0000 Updated. commit 2a149b18cca3b20063be398e8098dfa8e1e2705d Author: Martin Mares Date: Thu May 4 20:38:44 2000 +0000 Unused variables in IPv6 code. commit 93a786cb034fdd18b8131a16a6ea3d1cd9bd00de Author: Martin Mares Date: Thu May 4 20:30:36 2000 +0000 Removed a lot of unused variables. Please try compiling your code with --enable-warnings to see them. (The unused parameter warnings are usually bogus, the unused variable ones are very useful, but gcc is unable to control them separately.) commit c817b9916f1134f687ba53220d607e6e193cf651 Author: Martin Mares Date: Thu May 4 20:18:46 2000 +0000 Added --enable-ipv6 which tells configure to select the right configuration for IPv6 automatically. Added --enable-warnings which turns off some more warnings. Default protocol list now depends on --enable-ipv6. commit 9b63e3a58afe17b98eb7722e352984574846c22c Author: Pavel Machek Date: Thu May 4 20:08:34 2000 +0000 Spelling fixes. commit cf3d6470d7c8d401b162516ed7446c1d3866d5d3 Author: Martin Mares Date: Thu May 4 20:02:56 2000 +0000 IPv6 BGP support finished. Also simplified the BGP stuff a bit. commit 6db8c5a63b341d0913afa44457a93a8e83529fb2 Author: Martin Mares Date: Thu May 4 20:02:19 2000 +0000 pxlen works even in IPv6 mode. commit 5dc4b0aae20ef7e6b862af29a3135e018147ce97 Author: Pavel Machek Date: Thu May 4 10:03:53 2000 +0000 Display examples more nicely commit 1d9622e10ddc3baf2cd4f81bc2fa95593b4d3e85 Author: Martin Mares Date: Thu May 4 09:08:28 2000 +0000 Switched off LOCAL_DEBUG. commit 1c1da87b271ee3db0045f31612d99894531ada54 Author: Martin Mares Date: Thu May 4 09:03:31 2000 +0000 Receive-only IPv6 BGP. commit d345cda5a1cea03a09e5a37c999e88c5177c8a9e Author: Ondrej Filip Date: Thu May 4 01:23:03 2000 +0000 Bugfix in Network lsa originating Bugfix in ntohlsab() and htonlsab() For calculating of rt I use my own fib. I delete routes! ;-) commit 9e48d717cf681dcc3cfaaee4358b5c6fa3aa409e Author: Ondrej Filip Date: Wed May 3 22:36:12 2000 +0000 Test for "flushing" added. commit a02c6c184b513fe1886c86533e696045e960515b Author: Ondrej Filip Date: Wed May 3 22:23:41 2000 +0000 Cleanup of code. Some arguments of functions were useless. commit ad5453b540b3c9d7430dcff9a3674d9db8ab999c Author: Ondrej Filip Date: Wed May 3 22:12:33 2000 +0000 Testing if I can flush LSA from database. commit 9bc1808a27b35499d2438d731ade6d2cba8aa355 Author: Ondrej Filip Date: Wed May 3 00:08:48 2000 +0000 Better rt and net originating. commit 0bf2f2039e1fc95fe0fa3ee231711212f1f2b128 Author: Ondrej Filip Date: Tue May 2 23:09:44 2000 +0000 Originating of network LSA. commit 92bbd812e332c9948d737e95526c571ff371d394 Author: Ondrej Filip Date: Tue May 2 22:34:35 2000 +0000 OSPF added to default protocols. commit 249fdef7a10ce507bd224ad9be48a86f09d8f21c Author: Ondrej Filip Date: Tue May 2 22:31:48 2000 +0000 Adding InfTransDelay for outgoing lsa. commit c45f48fba5a0904f9c3512c3b42c38183fef348b Author: Ondrej Filip Date: Tue May 2 22:19:41 2000 +0000 Aging of lsa database added. commit a92847e78fabd637938f324c78d5eb41538a5692 Author: Ondrej Filip Date: Tue May 2 19:27:57 2000 +0000 Route calculation for stub networks. commit 53943a002265d8e2b6a887eaa497a01840675693 Author: Martin Mares Date: Tue May 2 16:10:04 2000 +0000 Defined format specifier `%M' which behaves as `%m', but takes the error code as an argument. Use it in socket hooks where we really shouldn't rely on errno containing the right value or even existing. commit 85368cd4b7244535f6ce56a27f6d22ddfa2bf4e6 Author: Martin Mares Date: Tue May 2 16:07:41 2000 +0000 Full protocol tracing. commit 85a291ff3055f0b10ffc199138c67305f5b3fc98 Author: Martin Mares Date: Tue May 2 15:21:51 2000 +0000 IPv6 address classification fixes. commit d1a74339d4edb717fbe98d412bd5e4ad03bb20a2 Author: Martin Mares Date: Tue May 2 12:51:39 2000 +0000 Handle redistribution of unknown attributes correctly. commit 85195f1a53eb350cd32ecba69c208dbece6fb776 Author: Ondrej Filip Date: Sun Apr 30 22:14:31 2000 +0000 Many small changes and bug fixes. Routing table calculation works. I'm waiting for rt lookup to add stub networks. commit 2337ade7546254eb48a22a1e195cc7999e684d21 Author: Pavel Machek Date: Sun Apr 30 18:47:48 2000 +0000 Moved documentation to top of file, where it belongs. commit c6c56264361e102691fe42134ab585f631f83898 Author: Ondrej Filip Date: Sun Apr 30 11:31:05 2000 +0000 Sync with nest's rt table and some minor improvements. commit e80e9d0da5d737b7f6e65358067f62a6ac85f4fe Author: Ondrej Filip Date: Sun Apr 30 09:32:41 2000 +0000 RT calculation strongly simplified. Now, I don't need any memory allocation. :-) commit 8c62d6e3b631d58f46d87c36826cb29f8dadeb15 Author: Pavel Machek Date: Sat Apr 29 17:48:38 2000 +0000 Minor documentation update. commit 468f2347fc0ea3e0eb6513ccd0433d0b48f2c739 Author: Ondrej Filip Date: Sat Apr 29 15:57:14 2000 +0000 Calculating of nexts hop(s) added. commit 9c1a55deeeb5aa5cd2f18b109fabb50947c308ab Author: Pavel Machek Date: Sat Apr 29 15:45:30 2000 +0000 IpV6 now actually compiles. Mj, could you provide example of static config for ipv6 that is _not_ rejected by checks? I tried this and got rejected. route 62:168::/32 via 62:169::; route 1:2::/32 via 1:3::; commit 46cdc7e20faaf922431a157bcb0f82a45b7aa2d2 Author: Martin Mares Date: Fri Apr 28 15:15:36 2000 +0000 Updated TODO. commit cea636640005c9ee9b628ce07a2d467c132941fe Author: Martin Mares Date: Fri Apr 28 15:13:29 2000 +0000 The `bgp_origin' attribute is now an enum. commit a412f01ea84709b9af0113acc5aa2ce3dad1d292 Author: Martin Mares Date: Fri Apr 28 15:12:03 2000 +0000 Include CF_HDR section in keywords.h as well, so that protocol symbols can be used in definition of ENUM's. commit 2edb31b097018be00f29cb7647432c4c2c8b99ba Author: Martin Mares Date: Fri Apr 28 15:11:10 2000 +0000 Split CF_HDR section to CF_HDR (only includes) and CF_DEFINES (defines, C declarations etc.). commit decc99fbbdba3394a5c611e2914b4d74aa6742a9 Author: Pavel Machek Date: Fri Apr 28 10:15:57 2000 +0000 Killed fixme: I already fixed it. commit a769a180d77b88fbfc77cae3e895a320007f6e30 Author: Pavel Machek Date: Fri Apr 28 10:14:59 2000 +0000 Provide rip_get_attr, how do I test it? commit 6c0a7174af459d62a52e97d15da29528169a68f9 Author: Pavel Machek Date: Fri Apr 28 09:55:52 2000 +0000 Add sample documentation to rip. commit e83b42deb4405729d9f53448bdbcea05e7d15e8f Author: Pavel Machek Date: Fri Apr 28 09:55:36 2000 +0000 Include proto/rip/rip.c in documentation system. commit ff95080f9272c4a0123ab05dff608a43cf3c15b7 Author: Pavel Machek Date: Fri Apr 28 09:48:28 2000 +0000 Cleanup of dead code + example documentation for two functions. commit 602b1445e3bfa24b1ce9cd1d148e4aa5cb742cf4 Author: Pavel Machek Date: Fri Apr 28 09:48:01 2000 +0000 Documentation-generating tool taken from linux-2.3.99-pre6, and makefile to actually use it. commit f94557dec5714f8415aa9e74615b5c821f45808f Author: Martin Mares Date: Thu Apr 27 22:40:19 2000 +0000 Some more fixes for attributeless UPDATEs. commit f75e3bbc01f2b711d1a2479eddd9ea35f8cfff47 Author: Martin Mares Date: Thu Apr 27 22:35:08 2000 +0000 Fixed a couple of nasty CLI bugs which were triggered on long or multi-part outputs. It took a whole evening to hunt them down, but now the CLI seems to work fine. Now I run three BGP connections with several thousand routes! commit 54896cbdba42a2ccd83c7f23c8ba14bed37a8b73 Author: Martin Mares Date: Thu Apr 27 22:31:11 2000 +0000 Path attribute can be missing if we process a packet with empty NLRI section. commit 8f6accb5bb26d534576e086894c107387f67906a Author: Martin Mares Date: Thu Apr 27 22:28:49 2000 +0000 Event handlers no longer return re-queue flag. Instead of using it, just call ev_schedule() on the same handler which should work perfectly now. commit 987de54578ce4053d737c64ea924a32f46a441a7 Author: Martin Mares Date: Thu Apr 27 19:44:27 2000 +0000 Fixed stupid bug in as_path_format(). commit 9165888ad24bdefed6a705219c767558d5091cec Author: Martin Mares Date: Thu Apr 27 19:41:10 2000 +0000 Handle connect errors correctly. commit 2add26dfa9c1da1e7fd6248de593c60cf0eba9ca Author: Ondrej Filip Date: Wed Apr 26 20:16:36 2000 +0000 Stub networks done. commit 5904a51266d82482392bad5d6d17a3be54c65596 Author: Ondrej Filip Date: Wed Apr 26 14:03:56 2000 +0000 Nets are used before routers. commit 5db9bae28676d743f53636d74997c85039d09278 Author: Martin Mares Date: Wed Apr 26 13:26:31 2000 +0000 IBGP fixes. commit e1ddd9937759bc22b7241e48400d17840a101d9d Author: Martin Mares Date: Wed Apr 26 13:26:11 2000 +0000 Changed handling of incoming connections, so that we can send data from the send hook without worrying about existence of socket buffers. Also, don't forget to copy peer addresses. commit dfa9a53a66e5747ddbeedfa0a47fa2ca9fc93b99 Author: Ondrej Filip Date: Wed Apr 26 12:54:23 2000 +0000 Routing table calculation. Dijkstra done. commit 0cadd5f531a82578ea6323f730cf8204b755895f Author: Martin Mares Date: Wed Apr 26 12:33:37 2000 +0000 Removed several FIXME's. commit dbf3939a53192c093f9f367edb15bf613126e347 Author: Martin Mares Date: Wed Apr 26 12:32:07 2000 +0000 Better formatting of router ID's. commit ebd3720f8335cecd671382c23fe61f03b7e2acaa Author: Martin Mares Date: Wed Apr 26 12:30:41 2000 +0000 Fixed several bugs in protocol state machine. Reconfigurations and restarts of BGP seem to work now. commit c010f4cb3771536fc62e534549e22c725285bbd2 Author: Pavel Machek Date: Wed Apr 26 11:33:03 2000 +0000 Use right address for ripv6. commit 7f704c06d86c58985e964e05df57d14b92e0cd05 Author: Pavel Machek Date: Wed Apr 26 11:07:57 2000 +0000 Cleanup in preparation for ipv6. commit b0c9c21c2926921843bbbade72e65831280906a8 Author: Pavel Machek Date: Wed Apr 26 09:38:07 2000 +0000 Small cleanup. commit 98347659463cb68cbd751148e19c62cfb109a32b Author: Pavel Machek Date: Wed Apr 26 09:37:07 2000 +0000 Whitespace changes. commit 2e5a8735f4be2c2514ae3a67960ea4ac3f06e364 Author: Pavel Machek Date: Wed Apr 26 09:36:47 2000 +0000 filter_same should now work with path masks. commit f71bded6e97a3eeb4dc58458d042cbe1af631380 Author: Pavel Machek Date: Wed Apr 26 09:30:12 2000 +0000 Bugfix in i_same (comparing of paths still does not work). commit 7a86a8b08db03f002a672d1e8a6481ad52114d1e Author: Pavel Machek Date: Wed Apr 26 08:03:50 2000 +0000 Added code for testing filters. commit 471bd6c30bb0d172699ea7af8f8b9356c8fe48b3 Author: Pavel Machek Date: Wed Apr 26 07:47:47 2000 +0000 Marked place where new enums belong. commit 94d9dfa47a14609e7057f26614b4094dddc8439d Author: Pavel Machek Date: Wed Apr 26 07:31:45 2000 +0000 Startup renamed to __startup: it is internal function and mj already uses word startup in other context. commit 6fd766c17eedf4897e2dff712f0e06bb84dd3d8a Author: Martin Mares Date: Tue Apr 25 23:08:31 2000 +0000 Implemented automatic restart after error with all the timers needed. commit 8573314326a36cc8c9aa1755e7ad6c51617015c8 Author: Martin Mares Date: Tue Apr 25 23:08:03 2000 +0000 Avoid printing of error messages on Cease notifications. commit 00c0c18aea40dd39efc275e24ad9d5e12a873a32 Author: Martin Mares Date: Tue Apr 25 23:07:47 2000 +0000 Allow sk_close(NULL). commit b3155b3399d84bb2dae8441171aa73236d790048 Author: Martin Mares Date: Tue Apr 25 22:01:19 2000 +0000 Randomize timers properly. commit 42532f084640645cfde9af7c0aa69a36b1de91ad Author: Martin Mares Date: Tue Apr 25 21:58:17 2000 +0000 Support dynamic reconfiguration. commit 41b26cfb552a4a441490779344326ff85819252b Author: Martin Mares Date: Tue Apr 25 21:56:46 2000 +0000 Don't forget to set filter pointers in struct proto when reconfiguring. commit 99f70c78e11f99f73a142ffcb8b65bd142c0a36c Author: Martin Mares Date: Tue Apr 25 21:31:15 2000 +0000 Use the same attribute names as in filters. commit 684c25d98fbfd7cc9275f401d8d451135615af8d Author: Martin Mares Date: Tue Apr 25 21:21:52 2000 +0000 When sending BGP attributes, re-create the flags, so that attributes added by filters which get the flags wrong are fixed automagically. commit efcece2da3054d9a0e5b5d2233549b3323428023 Author: Martin Mares Date: Tue Apr 25 21:13:25 2000 +0000 Better reporting of both local and remote errors. commit a47a01083b6ff9196f39136d68ed32ac70b31d15 Author: Martin Mares Date: Tue Apr 25 13:32:17 2000 +0000 Real parsing of BGP OPEN options including capability negotiation. commit 8b258e4e659cd8bacf0f7e3997d30b43561ac3e6 Author: Martin Mares Date: Fri Apr 21 13:01:28 2000 +0000 LOCAL_PREF is now always present and exported over all ibgp connections [draft] Allow setting of address of the local end of the TCP connection. Several bug fixes. commit 2a9e064d7b41ae6e944dd9fbcb18b89e8fda0dba Author: Martin Mares Date: Fri Apr 21 12:25:35 2000 +0000 If no NLRI's are present in an UPDATE message, parse the attributes, but don't check presence of mandatory attributes. [draft-09] commit f380aa60faa41872b78155f899518b25933d18b9 Author: Martin Mares Date: Thu Apr 20 23:05:41 2000 +0000 IPv6 compiles with glibc 2.1. commit f33c6c66020da3b10b27fba5585d20702b173c6f Author: Martin Mares Date: Thu Apr 20 22:55:32 2000 +0000 Use xmalloc() instead of malloc(). commit 7787ace61ae41060e599ce52e8f0017750d350da Author: Martin Mares Date: Thu Apr 20 22:54:22 2000 +0000 Synced to draft-ietf-idr-bgp4-09. commit 9bc6ab404190db53c9c9dbc183f6fc6fa3e704fb Author: Martin Mares Date: Thu Apr 20 22:34:50 2000 +0000 Fixed reporting of unknown options. commit 7d6eebae3b87cac2d09fd5201b603d4fd969fe06 Author: Pavel Machek Date: Thu Apr 20 10:25:51 2000 +0000 Create syntax sugar for add/delete/prepend, so xyzzy.prepend(123) is possible. That means that milestone 3 was reached. commit 77f37ae0994774f6402499e0a79287d85afa6edf Author: Pavel Machek Date: Thu Apr 20 10:24:41 2000 +0000 Test new syntax of add() and delete(). commit 5f532adde20300ecab63d3e521fb0dfbfb33df2b Author: Martin Mares Date: Wed Apr 19 13:54:35 2000 +0000 Temporarily ignore unknown options. commit f381cdce5225c0652bf9182ac40a1a54436c9692 Author: Martin Mares Date: Wed Apr 19 13:54:17 2000 +0000 The ATOMIC_AGGREGATE parameter is optional transitive. commit e0d6a7bda446d96dc3d56f65afed1872f20407cb Author: Martin Mares Date: Wed Apr 19 13:28:56 2000 +0000 Delay fetching of router ID. commit 035044b1d946c50efd4b59a8869198a0300c8151 Author: Martin Mares Date: Wed Apr 19 12:51:14 2000 +0000 Select the right source address and don't check port numbers. commit 85c92555efcd67d2671a8aef1bf7c3f4acc2b21d Author: Ondrej Filip Date: Tue Apr 18 22:11:05 2000 +0000 Grr, another patch to make it compile. commit 740d16d972d8e2accdb7a2f92048de302c9e966c Author: Ondrej Filip Date: Tue Apr 18 22:07:58 2000 +0000 Another ack bugfix. (Bad test for MIN_LS_ARRIVAL.) commit 84228eee273e2a689f4479d9a91f6b0a32c19b44 Author: Ondrej Filip Date: Tue Apr 18 21:40:11 2000 +0000 LS ack bugfix. (I didn't remove LSA from LSret hash.) commit 19fc4c763e745d56c8d80d04d6813766c1cfa04a Author: Ondrej Filip Date: Tue Apr 18 21:13:56 2000 +0000 LS ack. commit 26116eac93b51c503f5448d9f583847a51bef68d Author: Ondrej Filip Date: Tue Apr 18 20:34:19 2000 +0000 Better LS Ack dumping. commit 48f5a61f694faceb7cdc41e291f0da9411000c45 Author: Ondrej Filip Date: Tue Apr 18 19:56:43 2000 +0000 Bugfix in neighbor dumping. commit 9eada7ca03c6c4111e759b0910a1a654a7f3216e Author: Ondrej Filip Date: Tue Apr 18 19:44:16 2000 +0000 Fixed the serious bug in LSack. Oh, I'm an idiot. I sent LSACK, but in header was LSUPD. :-( commit 9eea604769662479891020b5a0fb282faa6dc36f Author: Ondrej Filip Date: Tue Apr 18 19:31:42 2000 +0000 Multicast open socket for (B)DR bugfix. commit 79f036ef6e9b2204528a41079c59a3a9ae9d50f5 Author: Ondrej Filip Date: Tue Apr 18 19:22:49 2000 +0000 Dump changes. commit 4472402551a1cc8d760a4e980fdcd7a417e0796a Author: Ondrej Filip Date: Tue Apr 18 18:29:50 2000 +0000 Many %u changer into %I. commit 89929e9daad0df36a289e7ae7d70dbc648c3b6b3 Author: Ondrej Filip Date: Tue Apr 18 18:21:10 2000 +0000 Many %u changed into %I and dump cleanup. commit 1508ee8b537aceba98d3af619ba0cded4d2fce9d Author: Ondrej Filip Date: Tue Apr 18 18:01:26 2000 +0000 Iface chstate run only if something really change. commit dd100e40c60811324b450ef7c078f0e992b2ded6 Author: Ondrej Filip Date: Tue Apr 18 17:58:16 2000 +0000 Better dumping in neighbor chstate. commit 8914e37dc028c89488d07556a511d8b49d38856f Author: Ondrej Filip Date: Tue Apr 18 17:54:06 2000 +0000 Better chstate dumping. commit 284c43ff66e8b5879945d2c4e1a285354bd38ddf Author: Ondrej Filip Date: Tue Apr 18 17:36:46 2000 +0000 Sending of ACK disabled, since I'll find bug. commit 023f5e86eba76a79dd90d5a4546ae8b200ccf023 Author: Ondrej Filip Date: Tue Apr 18 17:00:56 2000 +0000 Another LSack update. It's still NOT correct and it surely kills gated or Cyclades OSPF implementation. :-) commit 67315ef64e3655c65cfab032d637fe29d3cf91b2 Author: Ondrej Filip Date: Tue Apr 18 01:06:16 2000 +0000 Some lsack work. There is something very worng. :-( It locked my network. commit 2a0925948de20bd391d2c27a08ffdf2b4350e5c3 Author: Ondrej Filip Date: Mon Apr 17 21:10:40 2000 +0000 Listening on AllDRouters for DR and BACKUP added. commit 38130b863ffcab6b45484e4e5f1eca1dd933bb1a Author: Ondrej Filip Date: Mon Apr 17 20:42:42 2000 +0000 Small change in LSA originating. commit 52276996063bc4a0fbcb642f5075df1cde7ce684 Author: Pavel Machek Date: Mon Apr 17 16:51:28 2000 +0000 Few bugs removed from sgml, makefile added. commit f9b8bcca4eb1fdd8067a66a845b585af61335e3c Author: Pavel Machek Date: Mon Apr 17 16:49:05 2000 +0000 Bird.html will now be autogenerated. commit d37f899ba4e88b56a824fd44e7d81455c099bcba Author: Pavel Machek Date: Mon Apr 17 16:48:22 2000 +0000 First version of sgml documentation commit 0150e5211adabcbde55a76506f0f1a5901214b52 Author: Pavel Machek Date: Mon Apr 17 14:12:02 2000 +0000 Cleaned up mess with types in e,a and e,S. Dynamic attributes should now work. commit 74a7da482b1a537aaa97b4b5d6f6815887150f26 Author: Martin Mares Date: Mon Apr 17 13:41:50 2000 +0000 Adding of dynamic attributes is hopefully correct now. commit 8f10985e1ef77c7d44c8912cf92f99e5c4502cbd Author: Martin Mares Date: Mon Apr 17 13:14:48 2000 +0000 Added BGP to the default list of protocols we build. commit bd2d8190dd79645174beeef1a306c8df53db3b60 Author: Martin Mares Date: Mon Apr 17 13:13:08 2000 +0000 Honor standard communities (no_export, no_advertise, no_export_subconfed) when exporting routes. commit 56a2bed46bf7713cd773b0fd0c097bcfc6345cc1 Author: Martin Mares Date: Mon Apr 17 12:46:07 2000 +0000 Don't import/export MED and LOCAL_PREF on external links. Added real comparison of BGP routes (inspired by the Cisco one). Default local preference and default MED are now settable. Defined filter keywords for all BGP attributes we know. commit 3bbc4ad6ad63d55b1d7845b53865963db79c2e16 Author: Pavel Machek Date: Mon Apr 17 12:40:38 2000 +0000 Special hack for atomic_aggr. commit 708711c37306d6bc3a83935a4d4065814d9c4215 Author: Pavel Machek Date: Mon Apr 17 12:38:24 2000 +0000 Community lists can be now accessed as dynamical attributes. Mj: please create such dynamic atribute for bgp. commit 913ce95b083b2d61e498c63fce3e8f2d5b974cfb Author: Pavel Machek Date: Mon Apr 17 11:52:32 2000 +0000 EAF_ORIGINATED done right. commit 700bbe60fb941534937ad11ca71968224889fa87 Author: Martin Mares Date: Mon Apr 17 11:49:41 2000 +0000 The previous fix for spacing was (a) totally out of context, (b) wrong. Please *read* the code when trying to change it. Also killed a couple of type clashes. commit 2bd2de0188f6a0c1c9482cfc15e35c2b1b81c81a Author: Pavel Machek Date: Mon Apr 17 11:49:21 2000 +0000 pair ~ community list matching works. commit 5a2455886db55ae2d1eb8934c7686b4f6586f83c Author: Pavel Machek Date: Mon Apr 17 11:42:34 2000 +0000 Put space between entries so they are separated. FIXME: should use format as in filters. commit 4444ed2b26ae07dabbcc3e511798e2d7df3a2846 Author: Pavel Machek Date: Mon Apr 17 11:42:08 2000 +0000 It is good idea to separate entries in list _somehow_. Adding/deleting to community lists from filters now works. commit 991c36b509ad5bb96b4a28d0ec53813628e393a4 Author: Pavel Machek Date: Mon Apr 17 11:37:05 2000 +0000 Use EAF_ORIGINATED as mj wanted. mj: check this! commit 9c400ec9dd0ee74f1f350ead87dcd7366dbab7b1 Author: Pavel Machek Date: Mon Apr 17 11:34:38 2000 +0000 Int sets moved to core. It is now possible to have variable of type clist. commit e3558ab14ee60c8c9792bc3ed54d9f0c3eaa8ea8 Author: Martin Mares Date: Mon Apr 17 11:25:15 2000 +0000 Normalize community sets when exporting. Set PARTIAL bits correctly. commit 51a183af78a330cca46f12dcbff79bb045c4c854 Author: Martin Mares Date: Mon Apr 17 11:23:05 2000 +0000 Define EAF_ORIGINATED and propagate it properly when merging attribute lists. commit 4b03f64b341db7b73eedc00bc5321fedf349a236 Author: Martin Mares Date: Mon Apr 17 11:22:24 2000 +0000 Aesthetical tweaks (asterisk spells `asterisk' etc.) commit 159fa4cea9fb8f36db8335755248e0fac81fb050 Author: Pavel Machek Date: Mon Apr 17 11:20:00 2000 +0000 Finish moving of path matching. Use int_set_print from core for printing community lists. commit 2a40efa5e6252eb5a5dbe5e82dcd9c67ad7838a9 Author: Pavel Machek Date: Mon Apr 17 11:11:33 2000 +0000 as_path_match moved to a-path.c commit 684c6f5a0e134426159be7dbd514271aea9f4d3d Author: Pavel Machek Date: Mon Apr 17 11:06:39 2000 +0000 Path_getlen moved to nest and length was made callable from filters. commit ecd25633bdc3e491a0eca44c63c158eeff388f13 Author: Pavel Machek Date: Mon Apr 17 10:54:01 2000 +0000 Use printing routine from nest/ instead of our own. commit 4b641bab521c4fbabf931c3eac7704e8e2cab298 Author: Pavel Machek Date: Mon Apr 17 10:50:03 2000 +0000 Path matching now actually works, including / * 1 2 3 * /. commit e399b6f6ad91e6f94081dfe694740451100c7a7f Author: Pavel Machek Date: Mon Apr 17 10:42:28 2000 +0000 Path and path matching seem to work, now. commit 1ed2fe960929081065e75a7fb4322f28a76c508b Author: Martin Mares Date: Mon Apr 17 10:19:15 2000 +0000 Send and receive communities. commit c6add07fa6ca8366fbdcfcd9bc2872c129378366 Author: Martin Mares Date: Mon Apr 17 10:18:55 2000 +0000 Printing of AS paths and community sets. commit afc54517db6946e9cfb62bbdc855954316152c62 Author: Pavel Machek Date: Mon Apr 17 10:16:47 2000 +0000 Prepend and creation of empty path should work, but it has strange syntax for now. commit f421cfdd80cfce7d1ec4759c603e47071eb028f8 Author: Martin Mares Date: Mon Apr 17 09:37:31 2000 +0000 Sending of update messages works! commit c0668f36967ce651e452a476b786b7604038a556 Author: Martin Mares Date: Mon Apr 17 07:53:29 2000 +0000 Created nest/a-path.c and a-set.c which should contain general operations on AS paths and community sets. Moved as_path_prepend() there. Pavel, please move the other functions as well. commit ebff007f08965d83dba5840ee02171d09ac2598d Author: Ondrej Filip Date: Wed Apr 12 15:37:52 2000 +0000 LSack receiving bugfix. commit 4bf41ac8b1d7edb4754c579b714d1c71dc421b4e Author: Ondrej Filip Date: Wed Apr 12 15:20:13 2000 +0000 LS Ack receiving done. commit 58313b24c8e31f02f242b7d090b54aab8295ce04 Author: Ondrej Filip Date: Wed Apr 12 14:49:20 2000 +0000 Stupid "+1"-bug fixed. commit c8f685cb9d88e447d6057f92bcbb1e0df441ca35 Author: Martin Mares Date: Wed Apr 12 14:14:47 2000 +0000 Made last Pavel's changes compile. commit 0a40e97328180576577da26a5ce8933f616d84f1 Author: Pavel Machek Date: Wed Apr 12 14:12:37 2000 +0000 as_path_prepend is usable outside bgp. commit c2b28c99103a643dd29ad48152999d6dac7722fe Author: Martin Mares Date: Wed Apr 12 14:09:26 2000 +0000 Real bucket lists. commit a2d157463accf02e2db9fd3dd174b7e46dae8938 Author: Pavel Machek Date: Wed Apr 12 14:05:37 2000 +0000 One less shift/reduce conflict. commit ac7a2145ccd5cfc54788b0218cc253e3b1721b76 Author: Pavel Machek Date: Wed Apr 12 14:02:04 2000 +0000 f_new_dynamic_attr gets third argument, type as filters know it. commit 12d5677aa3e6217edc7d5508ac3dbbf87edc8624 Author: Martin Mares Date: Wed Apr 12 13:56:04 2000 +0000 Define BGP_PATH. commit 2803c9ddbeca3ece264e618b3a63669e25f4dd85 Author: Martin Mares Date: Wed Apr 12 13:55:53 2000 +0000 Minor updates by Pavel. commit 66d573d4903801c45011de36b6b593f1cde9ea73 Author: Martin Mares Date: Wed Apr 12 13:55:30 2000 +0000 Attribute type hack. commit 10a53608860724c47596948f2fd426d4eca8224d Author: Pavel Machek Date: Wed Apr 12 13:31:39 2000 +0000 Filters now know type path. It is possible to declare variable of type path, but it is not possible to write constant of type path. It should be possible to print paths and match them. commit 775063494694d247b340bb1145e509e31af27802 Author: Martin Mares Date: Wed Apr 12 13:21:23 2000 +0000 Introduced `ARRAY_SIZE' macro to replace all the sizeof(a)/sizeof(*a) constructs. commit dcab78904794156483878b4b8cd924e30a71bcdd Author: Pavel Machek Date: Wed Apr 12 13:07:53 2000 +0000 Renamed f_path to f_path_mask -- which is what it really is. Use linklist instead of array of signed integers for path mask. commit c3edb89ec141355de58fbade353d4b2182c62c1e Author: Pavel Machek Date: Wed Apr 12 12:49:53 2000 +0000 Path masks are needed for filters. commit 77de68825caae7a9cb1275b0020e49fa9cb27e29 Author: Pavel Machek Date: Wed Apr 12 12:10:37 2000 +0000 BGP_PATH masks now actually work as data type. commit 78c6217c1e9f8a46026cecf6a6369b72d5d883b0 Author: Pavel Machek Date: Wed Apr 12 10:34:45 2000 +0000 Path printing is now much nicer: not having to put it backward simplifies it. (Sorry for previous commit, cvs is naughty). commit f7d534cf2e8932869b049bd64677bb0a67e362c1 Author: Pavel Machek Date: Wed Apr 12 10:34:02 2000 +0000 Path printing is now much nicer. commit b475c543b420b65bac90992df99a0fe6c9da7c88 Author: Martin Mares Date: Mon Apr 10 22:08:32 2000 +0000 Fix comments. commit 9196e9f8f951f7cbd372b9243dd10fc761f2fbe6 Author: Pavel Machek Date: Mon Apr 10 16:36:40 2000 +0000 Commit fixes. commit 7f77e2500218c197ba56a473d587dedda7309029 Author: Pavel Machek Date: Mon Apr 10 15:07:43 2000 +0000 Functions for matching paths added, tested lightly. Functions for working with community lists added, they compile. This should not be definitive place for this stuff. commit 73e03bce66e3e8d167f00813d942ef35bfd105e2 Author: Pavel Machek Date: Mon Apr 10 14:45:00 2000 +0000 As usuall, most important info was missing. commit ae8f5584990ce3bfb5b0bec2f7a1c052e45860df Author: Martin Mares Date: Mon Apr 10 12:39:51 2000 +0000 Implemented outgoing attribute cache. commit 6f57dcc07cdf54133bd57aeaec7446f59f2c91cd Author: Martin Mares Date: Mon Apr 10 12:39:29 2000 +0000 Export ea_same() and ea_hash(). commit f2cb1d708dc5de4167a3dc12b50001391d01f5f0 Author: Martin Mares Date: Mon Apr 10 12:38:15 2000 +0000 Dropped CPU_NEEDS_ALIGN_* as unaligned.h no longer uses them. commit 48e842cc98b1436da57c8682c6c8414ba379ed7c Author: Martin Mares Date: Mon Apr 10 11:21:40 2000 +0000 Use neighbor cache to track direct route to the peer or multihop destination. Calculate next_hop properly based on the local address we get from the neighbor entry. commit 287111fed1c8e9eb135df1108ea747e02b30e9e9 Author: Martin Mares Date: Mon Apr 10 10:40:00 2000 +0000 Fix stupid bug in neighbor cache. commit ef2c708dfac4c8b4b5ab0ed8b71842da5c7ab3d7 Author: Martin Mares Date: Sun Apr 9 22:05:02 2000 +0000 More BGP progress... For Pavel: You can use bgp_path_prepend() for prepending AS numbers to AS paths. commit d3feceff105fbcee7a9976812156aea7517c44e6 Author: Martin Mares Date: Sun Apr 9 22:04:12 2000 +0000 BGP doesn't need any inline attributes. commit 3d0ea3a7c3e3b14bd0b9602d6b14518c907d8789 Author: Pavel Machek Date: Fri Apr 7 09:02:17 2000 +0000 Fix of comment. commit 2c971094ebf73c2a2cfc5927095a0c6fd3c15836 Author: Ondrej Filip Date: Wed Apr 5 00:51:25 2000 +0000 LSA flooding done. commit 10000b96a89d1ab4425e29164c3694aa26622b1c Author: Ondrej Filip Date: Tue Apr 4 22:27:19 2000 +0000 Small clean up. (Duplicate #defines.) commit f1f7faceb445fdfa2b2a013b791882afd68ae421 Author: Ondrej Filip Date: Tue Apr 4 22:22:08 2000 +0000 "Bug in hashing" fixed. Ehm it was bug in lsrql node removing. commit d8852b362c015db38abf180888e77900f35089de Author: Ondrej Filip Date: Tue Apr 4 15:55:55 2000 +0000 LSupdate processing improved. Now there is some bug in hashing. :-( commit 921a93f2176723d235989efe882050c0265bea84 Author: Ondrej Filip Date: Tue Apr 4 00:32:17 2000 +0000 Flooding work continues. commit 8496b2e41a81f8281da0e0c3e4bbb72a57d3bf21 Author: Ondrej Filip Date: Mon Apr 3 22:31:07 2000 +0000 Minor change in area list. Now I use MJ's lists. commit 394acced118df7360e480920c65ca260c5b8c44f Author: Ondrej Filip Date: Sun Apr 2 20:41:33 2000 +0000 Work on lsupdates continues. Some checksum cleanup. commit db9fb727699a6244afcff28dcc2320a3e66ee269 Author: Ondrej Filip Date: Sun Apr 2 19:04:23 2000 +0000 lsa_cmp moved into lsalib.c commit 10be74da202b20a7d502724ef8e7a9787b7eba0a Author: Martin Mares Date: Sat Apr 1 10:21:11 2000 +0000 Formatting of dynamic attributes (except for paths and communities which will be added soon). commit dad177d7e045ed07181da02ccd619f8f943a5c80 Author: Martin Mares Date: Sat Apr 1 10:20:12 2000 +0000 RIP: Set attribute class. commit 3991d84e8fa9118a43149d4d3304726eb786bd46 Author: Martin Mares Date: Sat Apr 1 10:19:47 2000 +0000 Changed initialization of protocol list -- now we call proto_build() instead of calling the protocols manually. Implemented printing of dynamic attributes in `show route all'. Each protocol can now register its own attribute class (protocol->attr_class, set to EAP_xxx) and also a callback for naming and formatting of attributes. The callback can return one of the following results: GA_UNKNOWN Attribute not recognized. GA_NAME Attribute name recognized and put to the buffer, generic code should format the value. GA_FULL Both attribute name and value put to the buffer. Please update protocols generating dynamic attributes to provide the attr_class and formatting hook. commit f8809249906811683e7e8d2a7b8cdcccde86742a Author: Martin Mares Date: Sat Apr 1 09:17:33 2000 +0000 BGP now handles incoming routes (IPv4 only). commit 85810613993913831822b84ab7a9792a88fc7a8f Author: Martin Mares Date: Sat Apr 1 09:16:42 2000 +0000 When tracing, always print incoming part of the trace before the outgoing one. Avoid buffer overflows in `show routes' command. commit 798df5b1ab6b497d8d9d6d51764f5aef4eb2d567 Author: Martin Mares Date: Sat Apr 1 09:15:55 2000 +0000 When processing ACCEPT/REJECT carrying no message, don't print trailing newline. I hope the fix is correct, but please check. commit b157361533412de2123787a412e6e463c0b2f13a Author: Martin Mares Date: Sat Apr 1 09:15:10 2000 +0000 SOURCE should really refer to rta->source, not rta->gw. Please check that all rta attributes are available, I guess that at least rta->dest is missing. commit 499cb346f6fb29f9157e12942484c8b4362597c3 Author: Ondrej Filip Date: Sat Apr 1 02:45:49 2000 +0000 LSA checksum works. But it's very uneficient on little endian systems. commit ac4b4683aee8e5aa566b0b5f99bd940bc10d9b71 Author: Martin Mares Date: Fri Mar 31 23:40:00 2000 +0000 Removal of useless includes continues... commit 3cf4a2e2b03d00adce703cd1dc961eea77b7a57b Author: Martin Mares Date: Fri Mar 31 23:35:59 2000 +0000 Removed lots of superfluous includes. Use debug() instead of printf(). commit a37410cbddfadca651c795e9817f66c54374a943 Author: Martin Mares Date: Fri Mar 31 23:33:03 2000 +0000 Use bsprintf() instead of sprintf(). commit 221135d6bf256c85b4aeb08881d6262f6eaadff4 Author: Martin Mares Date: Fri Mar 31 23:30:21 2000 +0000 Include "lib/string.h" instead of . It should give us bzero() and other non-portable functions on all systems. commit c00d31befab5a7e932231f7a8050547c72c94631 Author: Martin Mares Date: Fri Mar 31 23:21:37 2000 +0000 Parsing of BGP attributes. commit 08732b71784b640aebbea88d4452f4c5987d0a09 Author: Martin Mares Date: Fri Mar 31 23:21:19 2000 +0000 Fixed bug in processing of dynamic attributes. commit 65e55e9cca38828980123ea64fe203d799a20810 Author: Ondrej Filip Date: Fri Mar 31 01:40:12 2000 +0000 Checksum changes. Bug is still NOT fixed. :-( commit 9f940976d10e6295f78adf4afb1868a7ed6cac73 Author: Ondrej Filip Date: Fri Mar 31 01:14:41 2000 +0000 Some bug fixes. LSA checksum is still bad. I'll fix it later. commit f45fd3164bf2f9342e12e867f8d68c7fc77d3177 Author: Ondrej Filip Date: Fri Mar 31 00:21:41 2000 +0000 Sending of lspd as responce to lsreq done. commit 14a7921c83f0ecfc8793b3a38e4ac16ae9bd75d3 Author: Ondrej Filip Date: Thu Mar 30 20:18:51 2000 +0000 LSA structure changes. (Len added.) commit de769e24c01ff0c4aa573d9b4cec833dcae182d2 Author: Ondrej Filip Date: Thu Mar 30 20:00:42 2000 +0000 Skeleton structures and files added. commit 95eb1dba3ffe810bd876546ca4580af3bccdf181 Author: Ondrej Filip Date: Thu Mar 30 19:37:26 2000 +0000 Add hashing to link state request list. commit 76915ec9798a2c067ef05c6fb94cea58af12128e Author: Ondrej Filip Date: Thu Mar 30 19:21:17 2000 +0000 Minor changes. commit 973399ae2c21b41983a35fe71657fb41351d99e6 Author: Martin Mares Date: Thu Mar 30 18:44:23 2000 +0000 Basic analysis of UPDATE packets. commit b552ecc4d7ddb1b960aa26b96ebea95a3af72043 Author: Martin Mares Date: Thu Mar 30 17:39:48 2000 +0000 Connection state machine works. commit ce0603a6eda81b97d6db021c91b86cb4c920eb04 Author: Ondrej Filip Date: Thu Mar 30 16:22:58 2000 +0000 Better list manipulation. commit 3fdbafb6f49946f15d0c10d311dd35479bf6c0f1 Author: Martin Mares Date: Thu Mar 30 10:44:20 2000 +0000 More BGP. This time it connects, but the state machine still isn't complete. commit 320f41735795b51c51a9f5c976a2335a9ec96e32 Author: Martin Mares Date: Thu Mar 30 10:43:37 2000 +0000 Defined sk_close() which closes the socket safely even if called from socket hook. Replaces the SK_DELETED hack. Squashed a couple of bugs in handling of TCP sockets. commit 3a6337ecb2f6e5c8454a8416214c60432611aaa6 Author: Martin Mares Date: Thu Mar 30 08:50:46 2000 +0000 Use FF_FORCE_TMPATTR where appropriate. commit 3076b5aedc1d348413276b361806053e80dca7c6 Author: Martin Mares Date: Thu Mar 30 08:50:30 2000 +0000 Renamed FF_OUTGOING to FF_FORCE_TMPATTR which much better fits the semantics. Call rte_cow() instead of rte_do_cow(), so that COW works properly. Stripped "\n" off several (de)bug messages. commit 6d2b32114feadb283cb988daa7ed80142aa8c4d1 Author: Ondrej Filip Date: Thu Mar 30 00:18:59 2000 +0000 LSreq initial work. commit 3ee2310c5dccebe2b63098ab478b5b1d61e4fcb2 Author: Martin Mares Date: Wed Mar 29 22:57:46 2000 +0000 Avoid conflicts with libraries defining their own xmalloc by defining xmalloc to bird_xmalloc internally. commit 2560c8860eeed2e352c394aec920a4f696563e6c Author: Ondrej Filip Date: Wed Mar 29 17:51:40 2000 +0000 Slave bug fix. commit 910e557b47f52bf38aa923a69249670d71befc02 Author: Ondrej Filip Date: Wed Mar 29 17:18:06 2000 +0000 Many changes in dbdes sending & receiving. EXDONE caused. commit 315648af8ed75c91e0dd82748a933963b9e0c4ec Author: Ondrej Filip Date: Wed Mar 29 13:02:58 2000 +0000 RXMT timer handling bug fix. commit 3fba20968816a9dbd4565fd6806f29d72d73f638 Author: Ondrej Filip Date: Wed Mar 29 12:47:07 2000 +0000 Some FIXME added. commit 96501dfe5f6fd7a2837aee910c78f147e54e4f0b Author: Ondrej Filip Date: Wed Mar 29 12:45:37 2000 +0000 Sending of DBdes bug fixed. commit 04c6319a630e9e18bc45da5e5b1c1f11d726c261 Author: Ondrej Filip Date: Wed Mar 29 12:32:25 2000 +0000 IMMS reverted to bits. Outgoing packets dumping added. Cisco does not set inteface MTU. Hmm.... commit 0a06a9b8b3dbd59c850303c49eea97c12e1ac0ff Author: Pavel Machek Date: Wed Mar 29 09:02:00 2000 +0000 f_run gets one more parameter to distinguish between in and out modes. commit 8d2e3eba92e339f0635e0cb2fbfb49482b26295a Author: Pavel Machek Date: Wed Mar 29 08:58:06 2000 +0000 Cross-protocol issues solved better commit 963ea03d872db30e1a0d0216e488b1960590af2d Author: Ondrej Filip Date: Wed Mar 29 00:34:28 2000 +0000 DBdes sending/receiving changes. commit d0031c5ee94b29b7a5419a0504c160e424d970b0 Author: Pavel Machek Date: Mon Mar 27 12:21:11 2000 +0000 Use neigh_connected_to in rip, and behave more correctly w.r.t. whotoldme and nexthop. commit 200accf396b869267fd707b56afddb27d8479acc Author: Martin Mares Date: Mon Mar 27 12:16:37 2000 +0000 if_connected() is again private. Introduced neigh_connected_to() to serve the same purpose efficiently. commit 6480dd08803bc46bcd19b466ac6c499699d17448 Author: Pavel Machek Date: Sun Mar 26 21:31:57 2000 +0000 I broke compilation. Sorry. commit 8c86f96fa6f783326455f8a8d88a242cd8dd9f1b Author: Pavel Machek Date: Sun Mar 26 18:01:27 2000 +0000 Split horizont done right. Locks done better. commit 697711be2cf6b5da140b8c12c301affa53488021 Author: Pavel Machek Date: Sun Mar 26 18:00:45 2000 +0000 if_connected is usefull outside of neighbour cache. commit 9ee07ca53fd94ad72b7cb2776cc15f13a026a910 Author: Pavel Machek Date: Fri Mar 24 10:08:20 2000 +0000 FIXME was actually already resolved commit 772f489932cf24d7a408835ac67f7b4f4d85a1eb Author: Pavel Machek Date: Thu Mar 23 12:08:40 2000 +0000 Minor change to make code more readable. commit ff8ed6328595c77e8b0ed3ed4cea3fb4d9bb141d Author: Pavel Machek Date: Wed Mar 22 14:26:03 2000 +0000 Rip now tries to lock interface. Fixed fatal errors which caused segfault at startup. Fixed fatal errors in rip which caused it not to send more than first update. commit ba4466701aed032f947272dead47b3abc7bb7a3f Author: Pavel Machek Date: Wed Mar 22 14:23:40 2000 +0000 Format of dates changed, so rip authentication is now commented out. commit 72a6ef11fe6589d0f4d5158c207ff8a0669becc3 Author: Martin Mares Date: Tue Mar 21 15:53:50 2000 +0000 Construction of BGP packets. commit a8f944cb6e6c75c1aac2500ccf1f3905c4c3fd7a Author: Martin Mares Date: Tue Mar 21 15:51:30 2000 +0000 Wrote real version of unaligned data access functions (needed for BGP). commit c01e37416d09a92bf838250a15fe99fdc48bc010 Author: Martin Mares Date: Mon Mar 20 21:50:17 2000 +0000 Started work on BGP. Wrote main part of the connection handling code. commit 1cf716f0751ce1d146d6d5114cb36686844d4817 Author: Martin Mares Date: Mon Mar 20 21:49:21 2000 +0000 Handle EINPROGRESS properly. Set IP_DONTROUTE sockopt only if sk->ttl == 1. commit 267a2c0ebd980c16c1cf01044b0ee44095f34b9e Author: Martin Mares Date: Mon Mar 20 20:52:18 2000 +0000 Added missing newline in debug output. commit ca97b489de8cca61d1affa49983b7cdc1c81cf96 Author: Martin Mares Date: Mon Mar 20 18:45:03 2000 +0000 Define new data types for BGP. commit 2638249d34cc7f600fba25edd29538c00a3aca31 Author: Martin Mares Date: Sun Mar 19 22:09:07 2000 +0000 Bare skeleton of the BGP. commit 349e21bb0bb7584fb18c19859d876893c3130947 Author: Martin Mares Date: Sun Mar 19 21:59:24 2000 +0000 Protocol tracing: Don't dump core on filtered out routes. commit 856b87d1e4c44608df5debd8e4246a3c4026bbcb Author: Pavel Machek Date: Mon Mar 13 13:31:00 2000 +0000 Cleanup, mostly debugging messages. commit abf2be7d0cabc3c8c021b6f6784cf63610571715 Author: Martin Mares Date: Sun Mar 12 23:04:04 2000 +0000 Add internal commands of the client to the command list. commit 971b2310ae4d367d608e34e9465ad5d2c65e505d Author: Martin Mares Date: Sun Mar 12 22:55:09 2000 +0000 Commands which failed expansions are to be stored to history, too. commit f098e072bec8d5858afbf713635217ea84c7e45d Author: Martin Mares Date: Sun Mar 12 22:53:05 2000 +0000 Fixed a bunch of FIXME's by removing them :) commit 432709027680d7791b325b2c2116c658eba21c8d Author: Martin Mares Date: Sun Mar 12 22:44:54 2000 +0000 Made `show status' show uptime and time of last reconfiguration. commit 7a88832e78cbc18db109c091d74f6d27284cff44 Author: Martin Mares Date: Sun Mar 12 22:43:13 2000 +0000 Added tm_format_datetime(). commit 81ce667b7b7c38e109984602cf4e5ecbec80f7f1 Author: Martin Mares Date: Sun Mar 12 22:40:07 2000 +0000 Don't crash when filter_same() gets called on FILTER_ACCEPT or FILTER_REJECT. commit a92bebe0ec3545b1f99909d20224977aa6da1827 Author: Martin Mares Date: Sun Mar 12 21:58:51 2000 +0000 Yet another LOCAL_DEBUG turned off. commit 832fa033b7ecacf3225d7aa8c86e30484a07d946 Author: Martin Mares Date: Sun Mar 12 21:54:39 2000 +0000 Cleaned up debugging in kernel syncer. Netlink has still LOCAL_DEBUG turned on, but after some testing I'll gag it. commit e68dd11c43ebec527da69da7b093ae90ef6d6ea9 Author: Martin Mares Date: Sun Mar 12 21:47:25 2000 +0000 Use do { } while(0) instead of empty DBG if not debugging. commit 6b9fa320806ce8a734d865ebcb8052ba0e50c527 Author: Martin Mares Date: Sun Mar 12 21:01:38 2000 +0000 Great cleanup of debug messages. LOCAL_DEBUG turned off in most modules, several debug() calls converted to DBG(). commit 6a9f28b0b9254ba21c36126d6f10388815840001 Author: Martin Mares Date: Sun Mar 12 20:50:35 2000 +0000 Added tracing of interface events. commit b0a47440e33e7a270205130b01d59faadb6b6726 Author: Martin Mares Date: Sun Mar 12 20:49:08 2000 +0000 Oops, got `<' and `>' markers in trace output reversed. commit cfd46ee4c5b0d3689f8f9d094a68bc4b732cd0af Author: Martin Mares Date: Sun Mar 12 20:30:53 2000 +0000 Added debugging of communication between protocols and routing tables. Just ask for "debug routes" if you want to see the routes and "debug filters" if you want even the rejected ones. commit c8d5ffafb7c7e644048691221ca9d56ec68925a0 Author: Pavel Machek Date: Fri Mar 10 20:21:12 2000 +0000 Fix <=, >=, != commit ce17d4c165cadb09d391e34cda1b796a125ef012 Author: Ondrej Filip Date: Thu Mar 9 22:38:05 2000 +0000 LSA DB is completely redesigned. Now it should be faster and it needs less memory. commit af834f8630eb0078c723fb9b0af053dba6725d5e Author: Pavel Machek Date: Thu Mar 9 16:38:51 2000 +0000 Categorized TRACE() messages in rip commit cb822c0777657703e546bc99a7e5b646abe83d3f Author: Pavel Machek Date: Thu Mar 9 15:12:41 2000 +0000 Rip tracing: still need config hunk to set p->debug. commit 38466dbdacc706d7a6abcf348c448bd9f8fb01d4 Author: Pavel Machek Date: Thu Mar 9 14:59:10 2000 +0000 log() classes done right commit 995e5894cd9872603bc7c0ffd79fef96e4839006 Author: Pavel Machek Date: Thu Mar 9 14:47:43 2000 +0000 1 less shift/reduce conflict print now takes arguments separated by , [ 1.2.3.0/24 .. 3.4.5.0/8 ] is now forbidden [ 1.2.3.0/8 ] now actually works commit e4a73dbfcbb24a6a01ca960b641ce29d5045b3ba Author: Pavel Machek Date: Thu Mar 9 13:21:40 2000 +0000 CONST() is now gone commit 30147b89ff3a389ad40096505f3d1a5ba1705736 Author: Ondrej Filip Date: Wed Mar 8 12:50:28 2000 +0000 Sending of DBDes. (Checksum and length calculation NOT done.) commit 839380d7ecd133531ead2403c6dbc74950dad13c Author: Martin Mares Date: Tue Mar 7 21:50:21 2000 +0000 Added debugging of protocol state transitions. commit f30b86f9d5004a3e159c385269e76efc71b1566a Author: Martin Mares Date: Tue Mar 7 21:50:03 2000 +0000 Added configuration of default protocol debugging flags. commit 3eb0b586ca93b1d0d34f935cac8524e02f708126 Author: Martin Mares Date: Tue Mar 7 21:04:36 2000 +0000 No longer echoes commands before sending them. commit 3cbfcafecdf4f3dd1b201e0adf849f9959284c87 Author: Martin Mares Date: Tue Mar 7 21:04:14 2000 +0000 DBG calls debug() if defined(LOCAL_DEBUG) || defined(GLOBAL_DEBUG). commit 96d8e3bff242d5c9d0eb75fa04a21f6c09d8dbcf Author: Martin Mares Date: Tue Mar 7 20:49:48 2000 +0000 Added protocol debugging flags (protocol.h: D_xxx), parsing of them in configuration files and commands for manipulating them. Current debug message policy: o D_STATES, D_ROUTES and D_FILTERS are handled in generic code. o Other debug flags should be handled in the protocols and whenever the flag is set, the corresponding messages should be printed using calls to log(L_TRACE, ...), each message prefixed with the name of the protocol instance. These messages should cover the whole normal operation of the protocol and should be useful for an administrator trying to understand what does the protocol behave on his network or who is attempting to diagnose network problems. If your messages don't fit to the categories I've defined, feel free to add your own ones (by adding them to protocol.h and on two places in nest/config.Y), but please try to keep the categories as general as possible (i.e., not tied to your protocol). o Internal debug messages not interesting even to an experienced user should be printed by calling DBG() which is either void or a call to debug() depending on setting of the LOCAL_DEBUG symbol at the top of your source. o Dump functions (proto->dump etc.) should call debug() to print their messages. o If you are doing any internal consistency checks, use ASSERT or bug(). o Nobody shall ever call printf() or any other stdio functions. Also please try to log any protocol errors you encounter and tag them with the appropriate message category (usually L_REMOTE or L_AUTH). Always carefully check contents of any message field you receive and verify all IP addresses you work with (by calling ipa_classify() or by using the neighbour cache if you want to check direct connectedness as well). commit c801e1fbabee49838287a9e96814d3d0bf84ffa2 Author: Martin Mares Date: Tue Mar 7 20:09:35 2000 +0000 Renamed command `shutdown' to `down', so that `s' can be used as an abbreviation for `show'. commit 3549667925d04fa6a46ea35f56a9d3c741634d6a Author: Martin Mares Date: Sun Mar 5 22:48:30 2000 +0000 Implemented real slab allocator. If you suspect it from being buggy, just #define FAKE_SLAB at the top of lib/slab.c to bypass it. commit 9f4929e749d945c727f245ed7ef30c557124c352 Author: Martin Mares Date: Sat Mar 4 22:30:44 2000 +0000 Renamed EAF_INLINE to EAF_TEMP to make the name reflect the real meaning. commit b9626ec6eaf299b889f52d017d025f356b43371a Author: Martin Mares Date: Sat Mar 4 22:21:06 2000 +0000 Garbage collector events and counters are now per table and one day they can be made configurable if it turns out to be useful. commit 16c07e3d519b87a2166a513dd4edd8dab3bc3d19 Author: Martin Mares Date: Sat Mar 4 21:27:57 2000 +0000 Removed bogus comment. commit 54fb7701a21693eb7a51342eb98d663dd7324e8a Author: Martin Mares Date: Sat Mar 4 21:26:35 2000 +0000 Fixed display of short continued messages in verbose mode. commit c7814f01fc5fb51ae4054833ea8074ab9bcc86de Author: Martin Mares Date: Sat Mar 4 21:26:19 2000 +0000 Enabled short continuations. commit a58dad62383855ad1a60d4ec5406c38d24874506 Author: Martin Mares Date: Sat Mar 4 21:19:10 2000 +0000 Please *think* when defining operator priorities. (-: num_of_parser_conflicts -= 42 :-) commit ee76a92a80a0241421f57fe332c251255d2af4f8 Author: Martin Mares Date: Sat Mar 4 21:09:14 2000 +0000 Implemented real attribute cache. commit d4d7562806b7306d6e5ed9b759906e264b743dc5 Author: Pavel Machek Date: Thu Mar 2 22:23:18 2000 +0000 Avoid being exponential, do not allow ! = commit c8518ae136d94dc9576531a311947ba13213aea0 Author: Martin Mares Date: Wed Mar 1 15:05:43 2000 +0000 Removed RTF_EXTERIOR and RTF_TAGGED (unused). commit 85053fce04a2cba09332a6eb667f09f9c4182392 Author: Martin Mares Date: Wed Mar 1 14:51:47 2000 +0000 Reimplemented neighbor cache. Now uses real hashing. commit 7293c5dd8175aac4650cb48c68c7dd278a74371e Author: Martin Mares Date: Wed Mar 1 14:49:07 2000 +0000 Added proto->hash_key which contains randomly generated hash key used for calculation of hash functions depending on proto. commit 62ab789de5f5ace97a93fce551469f0229ba8c92 Author: Pavel Machek Date: Wed Mar 1 14:42:59 2000 +0000 Added type parameter to f_new_dynamic_attr. commit 31e79264a21df1acdbfbb66af40e05073b115a2c Author: Pavel Machek Date: Wed Mar 1 14:31:31 2000 +0000 tmp_attrs fixed. I do not know if it is right since mj ingores talk once started :-(. commit 4ebbbd4079cbf6295367b9c7a555c1b668fa0d8c Author: Martin Mares Date: Wed Mar 1 12:15:20 2000 +0000 Changed comments regarding hash function. commit 14a6c2a705fce9143e721b8da167dcbaa053c936 Author: Martin Mares Date: Wed Mar 1 12:03:43 2000 +0000 IP_PREC_INTERNET_CONTROL for IPv6 (see the comment). commit 4c1b4e1a582ea8d13943c46ad87588d5743439cb Author: Martin Mares Date: Wed Mar 1 11:48:11 2000 +0000 If the user has specified identical preferences for instances of different protocols, break the tie by comparing addresses, so we keep the ordering unambiguous. commit aee539f241dd233eb9e716e11ee2c449ab482a75 Author: Martin Mares Date: Wed Mar 1 11:42:13 2000 +0000 Made `datetime' more user friendly. Now it should be a quoted string of type "dd-mm-yyyy". commit db1326aa5e39711d88d305ac08a0afa137ab77f0 Author: Martin Mares Date: Wed Mar 1 11:32:23 2000 +0000 Dynamic attributes are now declared in per-protocol grammar files instead of filter/config.Y. Bird now compiles even if you disable RIP. Removed RTA and IMPOSSIBLE tokens (unused). Removed superfluous comment in filter.h. I've tried to do my best, but Pavel, please check these changes. commit 2ca3d9a8fc25be6f7d41d8a6ff50a70612c11c93 Author: Martin Mares Date: Wed Mar 1 11:30:16 2000 +0000 Defined INVALID_TOKEN which is a token guaranteed to be never generated. commit d07bab399735ee80205637f8e180e7595e0c0a67 Author: Martin Mares Date: Wed Mar 1 11:29:30 2000 +0000 ipa_opposite hack is not applicable in IPv6. commit ef0883a12fc699fbcef61f56fe8445f5e2ac1bb7 Author: Martin Mares Date: Tue Feb 29 23:20:55 2000 +0000 Adapted RIP to new interface flags. Pavel, please verify it's right. commit 6a636392d33627944df9d5a9573932cdc0bf6da5 Author: Martin Mares Date: Tue Feb 29 23:19:52 2000 +0000 Rewrote interface type detection logic. The `unnumbered' flag is now per address, not per interface (hence it's ifa->flags & IA_UNNUMBERED) and should be set reliably. IF_MULTIACCESS should be fixed now, but it isn't wise to rely on it on interfaces configured with /30 prefix. commit e69e4ed9349ee28262fe74f70e7e52c181d5d098 Author: Martin Mares Date: Sun Feb 27 22:00:19 2000 +0000 Support expansion of command abbreviations. Client considered finished (modulo bugs). commit de30342f97490e3a3626c4a5fbf3352d1d0aa9c8 Author: Ondrej Filip Date: Fri Feb 25 19:19:41 2000 +0000 Router LSA & area adding. commit b786df7035f43bb5eb4f7bca980e3bf684e527b7 Author: Ondrej Filip Date: Fri Feb 25 14:26:54 2000 +0000 Memory allocation in ospf_area changed. commit 2d496d2028e1283384f1c9d243f96eb59c42297e Author: Pavel Machek Date: Fri Feb 25 11:15:26 2000 +0000 Get rid of 'ab'-s, added return to functions. commit df0cf75dc849f5182d75328f4d4189a2d6048b57 Author: Martin Mares Date: Thu Feb 24 18:46:24 2000 +0000 Hmmm, libreadline 2.1 seems to be the oldest version we work with. commit 1d4ba6583afa5e6d4118aca0d0a645342d575b68 Author: Martin Mares Date: Thu Feb 24 18:43:23 2000 +0000 Moan loudly if libreadline is an old version which doesn't support callbacks. commit ab56f6b16fd9401565a066122be3231dccd24fb6 Author: Ondrej Filip Date: Thu Feb 24 00:26:10 2000 +0000 Area work and router LSA starts when interface goes up. commit ea28da044af9a35407724ba091d9a823c1cfe7e7 Author: Ondrej Filip Date: Wed Feb 23 23:23:19 2000 +0000 Small change for debugging. commit 91808fffc22e37b6d558f22db911ad0a3277d694 Author: Ondrej Filip Date: Wed Feb 23 23:14:18 2000 +0000 Structures for router LSA added. commit 6fa948d6c5abd0620836f66c654354ce38936f3a Author: Ondrej Filip Date: Wed Feb 23 23:13:27 2000 +0000 Better debugging. commit e6fcf113eca687d4dd888ef41033114ec8be82b9 Author: Ondrej Filip Date: Wed Feb 23 23:13:10 2000 +0000 Better debuging. commit fae0396ea4fd9d2530086eef77b8a11b6640d640 Author: Martin Mares Date: Thu Feb 17 23:37:16 2000 +0000 Completion works. Unfortunately, we have to access a couple of internal symbols of libreadline :-( commit 0223d4fff11badc03470b4320fa9dfe28afd1bed Author: Martin Mares Date: Thu Feb 17 22:00:13 2000 +0000 Client: Online help works (Cisco style: just press `?' at the end of a line). commit c51f132d582632037b4ef064fbd32d785af245fc Author: Martin Mares Date: Tue Feb 15 12:18:37 2000 +0000 First usable version of the client. No command completion and similar nifty features yet, but it works. commit 973304bc2b274ffaa6e27612256f6cea4a3a40c1 Author: Martin Mares Date: Mon Feb 14 17:32:50 2000 +0000 Don't make dependencies in client directory if the client is not configured in. commit 4bf6de87379a3458b59275373b9e88611baabb88 Author: Ondrej Filip Date: Tue Feb 8 22:43:10 2000 +0000 Hash table structure redesigned. commit 316d7bd7d16ea7ea26831bb7100dd0ac3c63084e Author: Ondrej Filip Date: Tue Feb 8 22:13:12 2000 +0000 Other LS struct added. commit d3cb698053e14b3d35750d92389c34b71503bfc6 Author: Ondrej Filip Date: Tue Feb 8 19:24:22 2000 +0000 LSA type changed from u16 to u8. commit c7b915d68c9475ba3a23c99ec7f796ec0a53978b Author: Ondrej Filip Date: Tue Feb 8 19:12:42 2000 +0000 Malloc() changed to cfg_alloc(). commit 9a4037d40891321a2f091cb1f1003bb1ee725136 Author: Pavel Machek Date: Mon Jan 31 17:44:22 2000 +0000 filter_same() implemented. Don't bet on it, yet. commit 70844a6a46305080d7ada79936fb272beb411cf4 Author: Pavel Machek Date: Wed Jan 26 21:28:53 2000 +0000 Updated docs about filters, and added fixme. commit bd215f8bab7e0d94fa482b47ff8d5971cd5ab799 Author: Pavel Machek Date: Wed Jan 26 14:12:18 2000 +0000 Do not send empty packets in rip. commit 8660913ba83d66491caf407a7e6eb16a4eeda2d0 Author: Pavel Machek Date: Wed Jan 26 12:07:18 2000 +0000 Output made prettier. commit 7211be1cffdee84fd15e8b6b2a07a644948f1455 Author: Martin Mares Date: Thu Jan 20 13:13:30 2000 +0000 Configure, link and use the readline library. commit 9fac310d1a4e46f4bcc70177e59cbf93763ef479 Author: Martin Mares Date: Wed Jan 19 15:07:00 2000 +0000 Put client on a stony ground. The whole client is going to be system-specific (the current version UNIX-specific) anyway, so it's useless to try splitting it to sysdep and generic part. Instead of this, configure script decides (based on system type and user's wish) what (if any) client should be built and what autoconfiguration it requires. Also, the client provides its own die/bug/... functions. commit f50b9e48b93e3f69423a0e6e5fef273ba2022958 Author: Martin Mares Date: Wed Jan 19 14:37:56 2000 +0000 Generate a list of all commands and their help texts for the client to use. commit 4b87e256eba51a8711c24fbae501ac7975b4ecd3 Author: Martin Mares Date: Wed Jan 19 12:30:19 2000 +0000 Split off general commands to cmds.c. Added `show symbols' command which dumps whole symbol table together with symbol types etc. commit f5ad9f87a389c1167a8468d0190bcf6d3cc33cf6 Author: Martin Mares Date: Wed Jan 19 11:52:32 2000 +0000 Killed a couple of bugs in the neighbor cache. Manual disable/enable/restart/shutdown/reconfiguration of protocols no longer hangs on loops in neighbor lists :) commit 3ea1ba632b3cdb5005a9339fd5e74d5f93631a48 Author: Martin Mares Date: Tue Jan 18 11:01:03 2000 +0000 Killed protocol->priority. Protocol startup should be clean and hack-free now. It seems everything still works (except for disable/enable/restart which hangs sometimes, but it's another story). commit 54aaa89ada2d048c64a5afd58844bc395b1a3cfe Author: Martin Mares Date: Tue Jan 18 10:42:45 2000 +0000 protocol->startup_counter no longer exists. commit aa8761de9471dbe28149d990bdbc851c744f4e2b Author: Martin Mares Date: Tue Jan 18 10:39:30 2000 +0000 Kernel route syncer now supports dynamic reconfiguration. Also it doesn't depend on the startup counter hack now and uses a zero-time timer instead to make itself scheduled after normal protocol startup. commit fb89b1a4ced5f3d847ecbc1d4b86a0cb47564ef7 Author: Martin Mares Date: Mon Jan 17 12:40:00 2000 +0000 Removed point-to-point tunnel hack as it breaks ordinary PtP interfaces. I'll find a better solution soon. commit 295ae16d4ddf4b714e716a0a1537f40c54f1119c Author: Martin Mares Date: Mon Jan 17 12:38:50 2000 +0000 Static protocol supports full dynamic reconfiguration. commit 471cc0be651a8db7068a65963ecfd4cc45f97ab1 Author: Martin Mares Date: Mon Jan 17 12:38:07 2000 +0000 Moved initlialization of protocol lists to global init. Argh. commit d272fe22dddcb5c293d6aac18d36e3e3e66406a5 Author: Martin Mares Date: Mon Jan 17 11:52:50 2000 +0000 Separated `official protocol names' used in status dumps from name templates used for automatic generation of instance names. protocol->name is the official name protocol->template is the name template (usually "name%d"), should be all lowercase. Updated all protocols to define the templates, checked that their configuration grammar includes proto_name which generates the name and interns it in the symbol table. commit f7fcb752520759ab3aed274ca608e8e6f96665c8 Author: Martin Mares Date: Mon Jan 17 11:17:33 2000 +0000 Reconfiguration for device protocol. commit 0ec90e9fc6f6bec2d0b64f6b9711a6d3edb4bd52 Author: Martin Mares Date: Mon Jan 17 00:20:45 2000 +0000 Pipe protocol supports reconfiguration. commit 88dc89f9918f524d9ca143d409c261a4a8230555 Author: Martin Mares Date: Mon Jan 17 00:20:17 2000 +0000 Device protocol supports reconfiguration. commit 26368f656c2398acc4d3ed55879d2f371cecf75b Author: Martin Mares Date: Mon Jan 17 00:19:58 2000 +0000 Don't forget changing proto->name to point to name in new configuration (to avoid the name being freed with the old config). Also remember to add proto_pipe to protocol_list. commit ca0edc53956ecd493055ba1625754ee75d58a9c7 Author: Martin Mares Date: Sun Jan 16 23:36:53 2000 +0000 When a quoted string is encountered, don't forget to copy it to the config pool before passing it to the parser. commit 99278e10421a2e6703e77f91e6ef436eaf660405 Author: Martin Mares Date: Sun Jan 16 23:36:19 2000 +0000 Wording changes. commit f14a4becbe77cfb3c2e4243d6fc383b0acd8956f Author: Martin Mares Date: Sun Jan 16 23:30:06 2000 +0000 Reworked proto lists -- each proto is now in two lists: the global one (proto_list) and per-type one (original lists). A lot of things simplified. Implemented `disable', `enable' and `restart' CLI commands. commit 30a6108cccac93048440113211df2eed1fb541b1 Author: Martin Mares Date: Sun Jan 16 17:49:32 2000 +0000 Added filter_same() for comparision of two filters. Pavel, please implement this as soon as possible. commit bf8558bc9cab35f31bccd6a55e51f121370765c4 Author: Martin Mares Date: Sun Jan 16 17:40:26 2000 +0000 Converted shutdown to a kind of reconfiguration, it's no more handled as a exception in protocol state machines. Introduced a `shutdown' CLI command. Killed few reconfiguration bugs. commit ebc793a5f552bb676014f771d81c074b7dd4345d Author: Martin Mares Date: Sun Jan 16 17:39:16 2000 +0000 No more problems when events get scheduled during event processing. commit 50fe90edf3deab409ea7887c131bfe6ce89fa556 Author: Martin Mares Date: Sun Jan 16 16:44:50 2000 +0000 First attempt on dynamic reconfiguration. There are still lots of bugs and problems to solve, but the hardest part works. commit 394aec8fdd112a81da1e2f6f0e09ee74256dc24e Author: Martin Mares Date: Sun Jan 16 16:40:57 2000 +0000 Don't forget to set proto->min_scope = SCOPE_HOST. commit 150875747813977ddf12474fa10a771090586402 Author: Ondrej Filip Date: Wed Jan 5 00:03:47 2000 +0000 Preparing for building LS databaze. Huh, why is it so complicated? :-( Adding definition of some constants. commit 7a7c1d9f34b95263d3bc100dec6cf3b94f1a9802 Author: Pavel Machek Date: Mon Dec 20 19:14:06 1999 +0000 Few more entries for bird documentation commit c8c0f62444a048e9d0986463ee1bfcdfc06df7c8 Author: Pavel Machek Date: Sat Dec 18 20:41:19 1999 +0000 This is first version of documentation. Be sure to take a close look at it, and it would be very nice if you wrote at least introductions to your chapters... commit 60d7d10e6f19483545760f2241312758dd72a2ad Author: Pavel Machek Date: Sat Dec 18 20:39:53 1999 +0000 Added fixme. commit 476e10842503b51331a7994b6e25c91b20eb8e71 Author: Martin Mares Date: Thu Dec 16 13:51:43 1999 +0000 Minor cleanups. commit e693ddff874890a9e5c990f6ca75d2e2358d065a Author: Martin Mares Date: Thu Dec 16 13:23:32 1999 +0000 Handle cases when SIOCGIFINDEX is defined, but doesn't work (new glibc with 2.0 kernels). commit 3f996d46df3cf1bdbefe0b0b0f5245c76b12756b Author: Martin Mares Date: Thu Dec 16 13:14:32 1999 +0000 Added missing semicolon. rip.h compiles in IPv6 mode, rip.c still doesn't. commit a2867cd957c9282d47440a1f42a6b823f5c9e4b2 Author: Martin Mares Date: Thu Dec 16 13:14:02 1999 +0000 Better order of includes. set_inaddr() moved to sysio.h. commit 12a9d139eecea7e7fb5e73e82a2531c70894d4c8 Author: Martin Mares Date: Thu Dec 16 13:13:22 1999 +0000 ipv6_compare() accepts non-lvalue arguments as well. This makes filters compile with IPv6. commit 67ece6df42b20ecc524cf3e5c14e8b541afec860 Author: Martin Mares Date: Thu Dec 16 13:06:13 1999 +0000 Tried to clean up multicast handling. Now we don't try to guess multicast abilities depending on definedness of symbols and use hard-wired system-dependent configuration defines instead. Please test whereever you can. commit ccdc33975648647270bf33511ec5bbab4d634634 Author: Martin Mares Date: Thu Dec 16 12:59:09 1999 +0000 Avoid touching F_MODIFY, it no longer exists. commit 6aea8905c4f0c2b0da6061b445894496e473145d Author: Martin Mares Date: Thu Dec 16 12:18:33 1999 +0000 TODO entries and FIXME's. commit d46ffc97ffc9ae753f999614bb69033b1f44df6d Author: Martin Mares Date: Thu Dec 16 12:18:19 1999 +0000 Kicked off F_MODIFY (not generated nor used) commit f545d38707bf01aa9db3915d782a547f89f92c1d Author: Martin Mares Date: Thu Dec 9 18:54:20 1999 +0000 Added universal locking mechanism which will solve problems with protocols wanting to use the same port on the same interface during reconfiguration time. How to use locks: In the if_notify hook, just order locks for the interfaces you want to work with and do the real socket opening after the lock hook function gets called. When you stop using the socket, close it and rfree() the lock. Please update your protocols to use the new locking mechanism. commit 30bc402ebb324749f9468f8ff196545bb0a58442 Author: Martin Mares Date: Wed Dec 8 15:12:54 1999 +0000 Temporary work-arounds for multicast problems. Needs further investigation. commit 0da472d7e867e31c49fccc4ee45df3ef47c29c9b Author: Martin Mares Date: Wed Dec 8 14:16:13 1999 +0000 Except for special protocols (nowadays only the kernel syncer), don't export host and link scope routes. commit dff1f5791794102e4e6880516545145c5036873f Author: Pavel Machek Date: Wed Dec 8 13:33:44 1999 +0000 Added hooks for show route. Fixed passing metrics around routing tables. commit dc82daaa9b0d88dca8684a7a766b253853ee7023 Author: Martin Mares Date: Wed Dec 8 13:20:19 1999 +0000 - Path to control socket is selectable via command-line option. - die() when control socket open failed. commit 4d4de35f002e3d7a780462b834f01eeb0f70239a Author: Pavel Machek Date: Wed Dec 8 12:51:45 1999 +0000 Fix timing and fix endianity in metrics. commit 2e18b87dcf5d4029d11bc46b37d601aae4f97174 Author: Pavel Machek Date: Wed Dec 8 12:51:26 1999 +0000 Disallow rta.net syntax. commit 3df563fa4c3c0acca181ce09dbb05452720e90e8 Author: Pavel Machek Date: Wed Dec 8 12:51:15 1999 +0000 Put rip options into config file. commit 9b47eb8530263b5ebd4a41f9ef3dab982775fc44 Author: Pavel Machek Date: Wed Dec 8 12:50:57 1999 +0000 Make bird.conf that does not crash machine when you run bird as root. commit 6c14255dd666c362f19f193a41a31f66310a34ea Author: Pavel Machek Date: Wed Dec 8 10:15:51 1999 +0000 Make rta. syntax optional. commit febe526303996d48a667cd077f5703ca91f43219 Author: Pavel Machek Date: Wed Dec 8 10:15:40 1999 +0000 Separated bird.conf and bird.conf for testing filters. commit f78056fb2cf4554d5dcc50b5e0e79bc09ae825cf Author: Martin Mares Date: Mon Dec 6 13:51:04 1999 +0000 Allow logging to stderr as well. commit 4ab5331c6370ba83dc7b228f9a94ccc1c64a973e Author: Martin Mares Date: Mon Dec 6 13:50:50 1999 +0000 Added type `g' for void (general) pointer. commit a0c37b45e59f024fc24b65ffbaf2c9e0f1996938 Author: Martin Mares Date: Mon Dec 6 13:45:56 1999 +0000 Logging is now configurable. You can define multiple log outputs (to both files and syslog) and assign lists of message categories to each of them. commit 7c0cc76ed76100ef8492f13eeec1e061d52b9be0 Author: Martin Mares Date: Mon Dec 6 13:44:45 1999 +0000 Moved initialization of protocol list to proto.c. Added sysdep configuration hooks. commit a9c986f98116fef5c35d956e7a867be0735f3268 Author: Martin Mares Date: Mon Dec 6 13:43:47 1999 +0000 Added tracked_fopen() which is a fopen registered in resource database. Will be used for log files. commit 34350a52700955d50895058d01b5407aea970e9b Author: Martin Mares Date: Mon Dec 6 12:34:45 1999 +0000 Implemented echoing of log messages to CLI connections. Just try `echo all'. commit f3792601dfe85c3017c984a6de5722d0e9da8a16 Author: Martin Mares Date: Sat Dec 4 23:28:56 1999 +0000 Don't forget to send an OK reply after dumping debug information. commit 305a01f57bd97906000c36bb154d63bc90012ef7 Author: Martin Mares Date: Sat Dec 4 23:17:29 1999 +0000 Added DEBUG commands. Removed CLI tests, real commands now serve as much better examples. commit feed82267663c6826da896309de180417bd0b39f Author: Martin Mares Date: Fri Dec 3 11:41:23 1999 +0000 Implemented `show static'. It's a relatively good example of how to write show commands for other protocols. commit 02c1fbddd462fecc6887a44ef67202870bcae7be Author: Martin Mares Date: Fri Dec 3 11:40:45 1999 +0000 Added proto_get_named() to be used in CLI commands to get protocol instance of a given protocol with optionally given name. See `show static' for an example. commit 28e01f85c65c536837227829f645818dfa6a2652 Author: Martin Mares Date: Fri Dec 3 11:10:50 1999 +0000 Renamed SHOW PROTOCOLS VERBOSE to SHOW PROTOCOLS ALL to be consistent with the other commands. commit 430da60fa29196cf8715e09e1d81c7ea0b672f05 Author: Martin Mares Date: Thu Dec 2 14:04:44 1999 +0000 Implemented `show route where ' command. Pavel, please check my addition to filter/config.Y. commit f2c6c80a2422b87a2947b7324ad14309198d64a4 Author: Martin Mares Date: Thu Dec 2 14:03:25 1999 +0000 I tried to turn on the YYERROR_VERBOSE switch, but bison is buggy as hell, so it doesn't even compile. Turned it again off and added a comment on it. commit efe51e38632dd7875af6789536be9ccfefd758c9 Author: Martin Mares Date: Thu Dec 2 12:04:39 1999 +0000 Avoid `default rule can be matched' warning in CLI state. commit 9c3726afd2edabf42f11f21cf787061db6c5a33a Author: Martin Mares Date: Wed Dec 1 15:17:24 1999 +0000 Updated TODO file. commit 730f2e2c8c29b3461caa096fa514cbf71f84e51b Author: Martin Mares Date: Wed Dec 1 15:10:21 1999 +0000 Added dumping of routing tables (`show route'). This includes filtering. commit 04a60c689aeb10fafa9919bcff5f8391e0f3a158 Author: Martin Mares Date: Wed Dec 1 15:08:32 1999 +0000 Added get_route_info and show_route_data hooks to struct protocol. Please implement them. commit f611f0ee824a6b363dc675e8f6ac963f20e7d007 Author: Martin Mares Date: Wed Dec 1 15:07:56 1999 +0000 Reset temporary parser data before parsing, not afterwards. This enables deferred CLI command handlers to store their temporary data in the CLI parsing pool. commit 2ad6dcdb2c949904643eabbbf6d0029045e8ea45 Author: Martin Mares Date: Wed Dec 1 15:07:06 1999 +0000 Make ACCEPT/REJECT actually return the result... commit e7f76bae8ccfe405ce3032aaa3a5e9228e5feb98 Author: Pavel Machek Date: Wed Dec 1 13:44:42 1999 +0000 Stupid bug (essentially while(1) loop) occuring sometimes during start of bird fixed. commit 7e1f99719e01af86006bc5c9b9a472516ec85a2c Author: Pavel Machek Date: Wed Dec 1 12:54:23 1999 +0000 accept should behave as return, not running any commands after it. commit 639e62855495fcf461c177373d8f5eb0d5d87332 Author: Pavel Machek Date: Wed Dec 1 12:52:57 1999 +0000 Actually check sequence numbers. commit 3daf783f95790682025ef03ac5b2f486943e6214 Author: Martin Mares Date: Wed Dec 1 12:01:41 1999 +0000 Implemented get_status for the pipe protocol (reports name of the other side of the pipe). Please do so for your protocols as well. commit 9685deb910c9e7400915209c1924e100b1feb5d5 Author: Martin Mares Date: Wed Dec 1 12:00:15 1999 +0000 `show protocols' now shows time of last state change and protocol-dependent status information (obtained via newly introduced hook protocol->get_status). commit 5954dcfab74c8d8a2774f259c9940c1d87e76518 Author: Martin Mares Date: Wed Dec 1 11:59:24 1999 +0000 Introduced new protocol-dependent integer field `aux' to struct neighbor. commit afa8937ac8433a7cb430a14f7613e8d0555f1149 Author: Martin Mares Date: Wed Dec 1 11:59:00 1999 +0000 Added tm_format_reltime() for formatting of relative time quantities. commit 6781e5213b3c910317a68aaee7ee53e81ee93948 Author: Pavel Machek Date: Wed Dec 1 11:39:58 1999 +0000 FIXME's cleaned up: I have actually fixed things without killing comments. There are no urgent FIXME's in filters. Perhaps we should start with documentation? commit f2ed663aea02ac38621ecfe91cd1f37f4a56dc4d Author: Martin Mares Date: Wed Dec 1 10:28:39 1999 +0000 Use linux-22 configuration with all 2.2.x and 2.3.x kernels. This means you need to have your kernel compiled with netlink routing messages enabled. If it doesn't work for you, use --with-sysconfig=linux-21 and let me know what's going wrong. commit 1d2664a4d4455470e0b6c7fc50d232283e39e1e0 Author: Martin Mares Date: Tue Nov 30 14:04:09 1999 +0000 Remember protocol instance in proto_config and use that for `show protocols '. commit c9aae7f47fd7ad71b80cbc86c01a26c504ba08d0 Author: Martin Mares Date: Tue Nov 30 14:03:36 1999 +0000 Lexer supports fallback symbol tables and uses them to recognize symbols from global config when parsing CLI commands. cf_lex_init_tables() is now called automatically inside the lexer. commit f0474f207061151183bb85d59f09422e7bb7e2ee Author: Martin Mares Date: Tue Nov 30 14:02:27 1999 +0000 Use TIME_INFINITY for initialization of password entries instead of 2000000000 (BTW who wrote that???) commit 487d1afa523706d8b0caec63492f4a2b6cef3bce Author: Martin Mares Date: Tue Nov 30 14:01:39 1999 +0000 Moved TIME_INFINITY to timer.h, so that it's publicly available. commit 0d3e6bceeeec4ebf007e02374f799cd1fb21f20c Author: Martin Mares Date: Tue Nov 30 12:57:14 1999 +0000 `show interfaces' and `show protocols' works. commit 10b5baaef32076369b06b4318cc61e6fa11e5493 Author: Martin Mares Date: Tue Nov 30 12:56:52 1999 +0000 Don't use continuation shortcuts until real client is written. commit 163b2073465b1d2f90d23832456e79463fdec308 Author: Ondrej Filip Date: Tue Nov 30 10:35:26 1999 +0000 Inicialisation of Topology Graph (TG). commit ae97b946e99bef043613d210489a926fe4807ec1 Author: Martin Mares Date: Thu Nov 25 15:35:30 1999 +0000 Added few basic commands: show status, show interfaces [summary], show protocols (incomplete). commit 35793769273f7286aafa0455547d1d7cfeef3931 Author: Martin Mares Date: Thu Nov 25 15:34:51 1999 +0000 cli_msg() moved to cli.h, so that it can be used outside the parser. commit ea32afb765381e642a525409a8f6cdff99aa0225 Author: Martin Mares Date: Thu Nov 25 15:34:20 1999 +0000 Added ip_scope_text() for translating of scopes to strings. commit 1a509a6310cb2a5211bf3ac9fd963f06d9109cb1 Author: Pavel Machek Date: Thu Nov 25 15:03:12 1999 +0000 md5 authentication seems to work. commit d3702d57fd5357e9a11ada6c46769a79da8e547a Author: Pavel Machek Date: Thu Nov 25 14:54:08 1999 +0000 Bugfixes: select right password for password authentication, do not try to process authentication blocks as datablocks, make it possible to add data at end of packet. Password authentication should actually work. commit 4aa885a53c479c774aab5befe55a1714b89cdc9e Author: Pavel Machek Date: Thu Nov 25 13:42:49 1999 +0000 Filters: fix rta access to use ->aux field. commit 7e61cac325aae2628d668673f60853608e072e66 Author: Pavel Machek Date: Thu Nov 25 13:38:25 1999 +0000 Triggered updates should now actually work. Fixed metric=16 -> time it out logic. commit 774f149959030b66faca7a97dfb4d1703a84e0d7 Author: Pavel Machek Date: Thu Nov 25 12:01:45 1999 +0000 Fix timeouts. Triggered updates are not done, yet. commit 455ca441d99184e1514415bd7acb25f82d01366e Author: Pavel Machek Date: Wed Nov 24 12:16:31 1999 +0000 Check that prefixes are really prefixes + fix config file to comply. (:-( 1.2.3.4/8 looks nicer than 1.0.0.0/8). commit 8f013d9ca443d4ff39af7560039f108efa9ef474 Author: Pavel Machek Date: Wed Nov 24 12:09:58 1999 +0000 Sorry, previous commit did not even compile. commit 48f9e0195488db0a515e4e5140d402fe4fe7d927 Author: Pavel Machek Date: Wed Nov 24 12:04:32 1999 +0000 Filters: write access to dynamic attributes should actually work. It would be nice to find method of testing such beasts. commit 99bbd23b229419403f673c626001eb0f35cc3a4e Author: Martin Mares Date: Thu Nov 18 14:41:43 1999 +0000 More CLI plans... commit 8d24b6899d0aba52fef8c48921ce4d1481ee212c Author: Martin Mares Date: Thu Nov 18 14:41:29 1999 +0000 Allow EA type to be set to 'undefined' which overrides all further definitons of that EA in the same list and causes ea_find() to fail unless you add EA_ALLOW_UNDEF to the second argument. ea_sort (resp. ea_do_prune()) removes all undef'd attributes from the list. I hope this works :) commit f31156ca217226ad110cc46e6365d70e64c527e0 Author: Pavel Machek Date: Thu Nov 18 14:29:10 1999 +0000 Filters: first parts of extended attributes being read-write. It can not actually work since I do not do rta/rte cow, yet. commit c7b43f33ae8d583ead531d76ed81f1b5deb507f3 Author: Pavel Machek Date: Thu Nov 18 14:01:36 1999 +0000 Split inst->code into inst->code and inst->aux. Both are only 16 bit, so aux is suitable for storing type but not much more. commit da40b6f753f4dd48dbcaebbe6174decb28705ab8 Author: Martin Mares Date: Thu Nov 18 13:42:51 1999 +0000 DEF_PREF_UKR and DEF_PREF_SINK removed. commit 346a12c2109b99d907e7ebeb3560992e92a6c26b Author: Pavel Machek Date: Thu Nov 18 13:21:52 1999 +0000 You can now print enum. commit 4364b47e48ddedb841e8ec8db25c8b4fa878a911 Author: Ondrej Filip Date: Wed Nov 17 15:50:41 1999 +0000 ospf.c and ospc.h splitted into various files. commit bff1db76292b194bbbf0c476d960f40aa0ea47ce Author: Martin Mares Date: Wed Nov 17 14:58:21 1999 +0000 Added skeleton of command tree. Please inspect. commit 2af2636a691da37c73ba032ece29dee1dd20fff7 Author: Ondrej Filip Date: Wed Nov 17 13:28:51 1999 +0000 Another bugfix. (In EXCHANGE state.) commit e17baa31088766f7f278be6754d0acc6e8380e4e Author: Ondrej Filip Date: Wed Nov 17 13:15:01 1999 +0000 Fixed bug receiving dbdes packets in EXSTART state. commit 62a463954815748d0d82da0e30651e6eea7bc9cf Author: Martin Mares Date: Wed Nov 17 12:14:44 1999 +0000 Added some temporary examples of how to define CLI commands (search for CF_CLI). To define a new command, just add a new rule to the gramar: CF_CLI(COMMAND NAME, arguments, help-args, help-text) { what-should-the-command-do } ; where are appended to the RHS of the rule, is the argument list as shown in the help and is description of the command for the help. is a C code snippet to be executed. It should not take too much time to execute. If you want to print out a lot of information, you can schedule a routine to be called after the current buffer is flushed by making cli->cont point to the routine (see the TEST LONG command definition for an example); if the connection is closed in the meantime, cli->cleanup gets called. You can access `struct cli' belonging to the connection you're currently servicing as this_cli, but only during parse time, not from routines scheduled for deferred execution. Functions to call inside command handlers: cli_printf(cli, code, printf-args) -- print text to CLI connection, is message code as assigned in doc/reply_codes or a negative one if it's a continuation line. cli_msg(code, printf-args) -- the same for this_cli. Use 'sock -x bird.ctl' for connecting to the CLI until a client is written. commit 30770df2ab33ffbfd75a9478265ac5e1a1db98d9 Author: Martin Mares Date: Wed Nov 17 12:04:24 1999 +0000 If the main event queue is not empty, call select() with zero timeout, so that the events are ran again after the FD's are checked. This allows us to schedule I/O checks between processing of user commands. commit 84a7d7f77c05578d9ebfff90672e73f021999d25 Author: Martin Mares Date: Wed Nov 17 12:01:11 1999 +0000 ev_run() now returns whether the event has been requeued or not. ev_run_list() now returns number of events which remain in the list. commit ffb59d243a350ed525850e864b38af0ecb0ffea5 Author: Martin Mares Date: Wed Nov 17 12:00:21 1999 +0000 Command line interface now works. commit ea9bb932a31e5df14e3a1a5f580e62b6aedc0247 Author: Martin Mares Date: Wed Nov 17 11:16:15 1999 +0000 Commented out nexthop selection, see the comment. commit 7d509304b58d7ebf1d53e36a8e656830b409e1e8 Author: Martin Mares Date: Mon Nov 15 11:36:22 1999 +0000 An example of how to define enums. commit fd54b602665f71879087faeb0b733fefa9c964bb Author: Martin Mares Date: Mon Nov 15 11:36:09 1999 +0000 ENUM's are now recognized as constants. commit 944f008af7a46144e38f963097e8e4cce493e2a7 Author: Martin Mares Date: Mon Nov 15 11:35:41 1999 +0000 Defined CF_ENUM. commit cbc31830079fb5e49c14c3de446b10ed8da99ce0 Author: Martin Mares Date: Mon Nov 15 11:34:51 1999 +0000 SYM_STAT is gone. commit 4515bdba4f56b298e62150ffe24608ba1a42e7da Author: Pavel Machek Date: Thu Nov 11 13:55:39 1999 +0000 Fixed order of arguments for function call. Enumeration types should work once CF_ENUM() is ready. Created test.conf for testing of filters. (I'm currently thinking about ./tests in root directory which will just fire all available tests...) commit 4ed8718a19747bba95ff86fb8d3c6ea357b50101 Author: Pavel Machek Date: Thu Nov 11 13:27:59 1999 +0000 Shift/reduce conflict goes away _and_ if/then/else works. commit 986e34131dbd2bca668c2b0a6ebb25de6848fc0a Author: Ondrej Filip Date: Wed Nov 10 16:06:12 1999 +0000 Sending DBDES packet in EXSTART done. commit 1183b6b2297f03113d31dc73ef0edc8fc7ef0b7e Author: Pavel Machek Date: Wed Nov 10 13:59:13 1999 +0000 Enums do not work, this is testcase. commit cb8034f42cfaa2753152fa1d776cc618d07fedda Author: Pavel Machek Date: Wed Nov 10 13:44:29 1999 +0000 First try on enumerational types. Mj's noassoc removed: this brings back shift/reduce conflict but it makes parser actually work. Mj please check it. IF/THEN/ELSE still will not work. commit 2f702671b46fa2ea01021170f685f554e4012782 Author: Pavel Machek Date: Wed Nov 10 13:07:18 1999 +0000 No more shift/reduce conflicts. commit 4995564570f9779686f767ec98034ce58d836203 Author: Martin Mares Date: Wed Nov 10 13:05:57 1999 +0000 Shift/reduce conflicts in IF/THEN/ELSE rules solved. commit f453665704cc8d946f86057e67151ef27419e280 Author: Pavel Machek Date: Wed Nov 10 12:44:07 1999 +0000 Enumerational types, defined keyword added. commit 6ba36f06ae10ea7efd60c30f8ef40d6143c69ef6 Author: Martin Mares Date: Wed Nov 10 12:27:01 1999 +0000 Added LSA hashing table (parts of code stolen from rt-fib.c, but heavily simplified since we don't need asynchronous walking). commit 3918b1b050701dee217fa9bc8c4c44d47cb84124 Author: Pavel Machek Date: Wed Nov 10 11:52:36 1999 +0000 Added timeout for routes (which means proper expiring of routes) added few fixmes. commit 024dcaaea253e1f69f4325edebec4a9b5618caea Author: Martin Mares Date: Wed Nov 10 10:48:19 1999 +0000 Added project status report for KSVI. commit a5b583f20abfbf8181b46c08947df7043c213113 Author: Pavel Machek Date: Thu Nov 4 14:39:51 1999 +0000 FIXME's updated. One fixme is remaining for correct RIPv4. Wow. commit 7bf19253d0c33e6accd5b36a5b221f6d1d9cadcc Author: Pavel Machek Date: Thu Nov 4 14:26:18 1999 +0000 Reject packets which are not authenticated. Set correct nexthop on outgoing packets. commit 3c989eb4a784c34870e9d66d5be3c976d8f03797 Author: Pavel Machek Date: Thu Nov 4 14:05:40 1999 +0000 Fixed comments about shift/reduce conflicts. commit ae3e1af2a86c428f473ef0270151cead16cc0e8e Author: Pavel Machek Date: Thu Nov 4 14:03:45 1999 +0000 Add possibility of local variables. commit f30b25f9625d5542ace217bb6b3610d0a09f228a Author: Pavel Machek Date: Thu Nov 4 14:03:36 1999 +0000 Use local variables to test that functionality. commit df8b85e33f6df0567127efdd80acf98ba6f3ffea Author: Martin Mares Date: Thu Nov 4 13:53:47 1999 +0000 Silly bug. commit c8f61a01ea1862d0c0a3ec4cc15c5d49e1366725 Author: Martin Mares Date: Thu Nov 4 13:51:52 1999 +0000 Symbols are not scoped. commit 91447965fed2728a1f877e21f7f58aab4c0022c7 Author: Pavel Machek Date: Thu Nov 4 13:33:30 1999 +0000 Possibility to access first extended attributes. commit 2727bb7c5bbdac54661a5097f86d979799095db8 Author: Martin Mares Date: Thu Nov 4 13:29:43 1999 +0000 Renamed attr->attrs to attr->eattrs. commit 6dc7a0cb39d712c7670a113d5a66e9e868eb9872 Author: Pavel Machek Date: Wed Nov 3 22:23:01 1999 +0000 Filters now do not allow function (int arg; int arg2; ). commit e5005be2b415ebd9bdea28a3515961f4eb904501 Author: Pavel Machek Date: Wed Nov 3 22:21:26 1999 +0000 You should not follow next two times. commit ecc3cf6f50768284b9660b5717190107e742404f Author: Ondrej Filip Date: Wed Nov 3 12:59:38 1999 +0000 Working on db des receiving. Preparing for building LDA database. commit 03b7bd14de501891ea8ae1d914e1da0b1f4147d5 Author: Martin Mares Date: Sun Oct 31 17:48:21 1999 +0000 Started a list of CLI reply codes. commit bc2fb68098faaf09393437a7743285d2af71d102 Author: Martin Mares Date: Sun Oct 31 17:47:47 1999 +0000 Parse CLI commands. We use the same parser as for configuration files (because we want to allow filter and similar complex constructs to be used in commands and we should avoid code duplication), only with CLI_MARKER token prepended before the whole input. Defined macro CF_CLI(cmd, args, help) for defining CLI commands in .Y files. The first argument specifies the command itself, the remaining two arguments are copied to the help file (er, will be copied after the help file starts to exist). This macro automatically creates a skeleton rule for the command, you only need to append arguments as in: CF_CLI(STEAL MONEY, <$>, [[Steal <$> US dollars or equivalent in any other currency]]): NUM { cli_msg(0, "%d$ stolen", $3); } ; Also don't forget to reset lexer state between inputs. commit b9672a845f7ff7d2441e21746566eacc51f274b7 Author: Martin Mares Date: Sun Oct 31 15:43:44 1999 +0000 The CLI I/O functions work as desired. commit 7d3aab1c1643e8b2bcff7f856e0d4455fa0ba4b4 Author: Martin Mares Date: Fri Oct 29 12:10:10 1999 +0000 First steps of the Command Line Interface: I/O routines. commit b93abffae4ad5767625b35c9a09513e9d27a5256 Author: Martin Mares Date: Fri Oct 29 12:09:29 1999 +0000 Implemented unix-domain sockets. commit 0d70292d88276a9883ab8bc15b00e6a2e2fe4487 Author: Martin Mares Date: Fri Oct 29 12:08:49 1999 +0000 Events now return a value. If it's non-zero, the event is re-queued for processing in next event cycle. This can be used to prevent background actions (hint: user commands) from hogging the CPU for too long time. commit 92af6f309b9283482384bd9bbd0351cd71e3cf1d Author: Martin Mares Date: Fri Oct 29 10:08:27 1999 +0000 Simplify handling of free chunks. commit 54165b1315dd09b0ea97705367b73086131c1ed8 Author: Martin Mares Date: Fri Oct 29 10:08:09 1999 +0000 Configure PATH_CONTROL_SOCKET. autoconf.h is now written to obj/sysdep, the source tree is hopefully completely read-only now. commit ed6081502ad814289b9b7b5537658c3b1ad435e5 Author: Martin Mares Date: Fri Oct 29 09:44:44 1999 +0000 Added skeleton of the client. Does nothing, but at least compiles. commit 41be4444f2f548c5cc135593b2c820180a22ff99 Author: Pavel Machek Date: Thu Oct 28 21:03:36 1999 +0000 switch() { } done right. commit c2250f91c749f563229ad624bbd03053c1d671d0 Author: Ondrej Filip Date: Tue Oct 19 16:13:06 1999 +0000 Minor changes and bug fixes. Preparing for Exchange and higher states. commit 96f1b8ba10f7787fc7cf0e0430a85766200707a5 Author: Ondrej Filip Date: Mon Oct 18 21:48:51 1999 +0000 Huge changes. Neighbor and interface state machines rewritten. It should be cleaner now, I'm preparing for file splitting. Maybe I added some minor bugs. :-( commit f942a589ef627f5b2604955cbfdbe91fa706f29d Author: Pavel Machek Date: Tue Oct 12 13:04:50 1999 +0000 FIXME's for rip added. Will we ever able to generate packets saying "route 1.2.3.4 using someone else"? commit 89dc383a8ce26bfe49250e5063bcadec22ff42c6 Author: Martin Mares Date: Tue Oct 12 07:46:08 1999 +0000 Changed syntax of ip_class_mask, the old one was stupid. commit d3dd620b96c5960207b9321b416423b8130a4df7 Author: Pavel Machek Date: Tue Oct 12 06:27:42 1999 +0000 Filters: permit variables of prefix types, cleanup around variables. TODO list added, hopefully complete. Use new features of filters in bird.conf commit c79ec2ec1962394f1550afa10a8b396f0e4dfc52 Author: Pavel Machek Date: Mon Oct 11 14:19:29 1999 +0000 Untested IPv6 support added. I do not know if it compiles in IPV6 mode. commit 720d911d777f64872df923e102ebc509113885f0 Author: Pavel Machek Date: Thu Oct 7 14:10:08 1999 +0000 Added constants of type prefix and pair, added their printing commit 4872cef4dfcadab405d0393a21f9136852d7b9c4 Author: Pavel Machek Date: Thu Oct 7 14:09:50 1999 +0000 Added examples of pairs and prefixes commit c9f8c1a855cfdde2095cd792289dbce2b7a06371 Author: Pavel Machek Date: Thu Oct 7 13:38:26 1999 +0000 FIXME's added. Hopefully fixme list is now complete for filters. commit f782b72c538b5728f6c3f531a25f669f0bf99b2c Author: Martin Mares Date: Sat Oct 2 11:06:44 1999 +0000 Failure to set socket TOS is not a fatal error. commit 507cb9e58b947ad8c6ad1c73706a08010d90f4cc Author: Martin Mares Date: Sat Oct 2 10:55:19 1999 +0000 Don't forget to free large blocks. commit ac40c888c21c72ae7f6c3d329dd2ba5417eec009 Author: Pavel Machek Date: Sat Oct 2 10:44:48 1999 +0000 Obvious bugs in authentication fixed. commit 7db7b7db603a2d852066c313da76c72673a204fa Author: Pavel Machek Date: Wed Sep 29 14:24:58 1999 +0000 Case arg { 1: printf "one"; } works. You can not use two commands after one label, yet. commit 4caa2231fc75ed351b9a9f20a97a81ce5d4421d0 Author: Pavel Machek Date: Wed Sep 29 14:23:11 1999 +0000 Make configuration use new case statement. commit 2c1d1cc765238aef0e8bfdbc1d8bc954fa0fc222 Author: Ondrej Filip Date: Wed Aug 25 18:44:50 1999 +0000 DD packet receiving in ExStart. commit 1af664158d20e9887ca11b63fc062a63f333297a Author: Ondrej Filip Date: Tue Aug 24 18:32:26 1999 +0000 A structure for receiving DD seq packets added. commit e3121112ab8cda4b4e413a801e5626f9ffb02ca8 Author: Ondrej Filip Date: Tue Aug 24 14:42:51 1999 +0000 Preparing to send DD packets. commit 2981814066543b72e292b7b36ca41bfa1cc2554c Author: Pavel Machek Date: Fri Aug 20 09:59:39 1999 +0000 Few FIXME's removed from auth, few FIXME's added to filter. commit bce8a34b128f1c0495f3f7a28d832d9c2b4a9543 Author: Pavel Machek Date: Wed Aug 18 13:19:33 1999 +0000 Few fixme's fixed in rip (will not crash any more on request for sending routing table - hopefully). Next few steps in md5 authentication (not yet complete). commit f651941402079052fbdabf64092e7dd4a6a8cafe Author: Martin Mares Date: Tue Aug 17 20:47:40 1999 +0000 Added a function for generating 32-bit random numbers. commit b332fcdfc8f0b1ac7111a63c55f72ba4b00b8035 Author: Ondrej Filip Date: Mon Aug 16 10:32:05 1999 +0000 Better dumping. commit 032df28048c1c3d64716d3876ea759660d9d3cf0 Author: Ondrej Filip Date: Tue Aug 10 12:06:45 1999 +0000 Small bux fixes. A neigh_chstate added. commit a7d388d23e26bdc94aefc3788b6be6c278f6dc5b Author: Ondrej Filip Date: Mon Aug 9 18:59:37 1999 +0000 Multiple "hton problems" fixed. Now we're in EXSTART state. commit 2be22ddb4cf4c7a88a0c424f0de7c968e5c326a1 Author: Ondrej Filip Date: Mon Aug 9 18:49:50 1999 +0000 "My own IP problem" fixed. commit a4c2ee717cf42bb53688c18840bd7294b6bf61dd Author: Ondrej Filip Date: Mon Aug 9 18:34:08 1999 +0000 Bug fix in checksum calculation. commit b1693b8f749ccc683a2a78dc3129e56e500bc73f Author: Ondrej Filip Date: Mon Aug 9 18:11:51 1999 +0000 Bug in election fixed. commit e83dc0d7e78fd31b435b36424beb790bf55881a8 Author: Ondrej Filip Date: Mon Aug 9 17:58:01 1999 +0000 (Backup) Designated Router election added. commit 8c51f96acff1cfb05d1cf05f4355fce655c32599 Author: Ondrej Filip Date: Mon Aug 9 13:03:28 1999 +0000 Some interface state machine changes. I found some problem in RFC, trying to conntact authors. commit 55e06729b173b24ce0c243db7e96094f10071eaf Author: Martin Mares Date: Tue Aug 3 19:57:43 1999 +0000 Forgot to do a `cvs add', grr. commit d7975d261f8a30efcdbd9fad6ba47419a6ac6c39 Author: Martin Mares Date: Tue Aug 3 19:38:48 1999 +0000 Ouch, how could I write this? commit 4532a89e31734a457d4debe56df713d66e31cdd6 Author: Martin Mares Date: Tue Aug 3 19:37:37 1999 +0000 Taught Netlink how to behave in IPv6 world. commit 4f22c9818554087d8f5ab51b8666a7a48d1f4329 Author: Martin Mares Date: Tue Aug 3 19:36:51 1999 +0000 Support for IPv6 sockets. How nice one doesn't have to ifdef around ten years of API evolution :-) commit dce267832a0468ed5e596f0b0733b926af7ead3a Author: Martin Mares Date: Tue Aug 3 19:36:06 1999 +0000 Basic support for IPv6. The system-dependent part doesn't work yet, but the core routines are there and seem to be working. o lib/ipv6.[ch] written o Lexical analyser recognizes IPv6 addresses and when in IPv6 mode, treats pure IPv4 addresses as router IDs. o Router ID must be configured manually on IPv6 systems. o Added SCOPE_ORGANIZATION for org-scoped IPv6 multicasts. o Fixed few places where ipa_(hton|ntoh) was called as a function returning converted address. commit 707ef833783ef731c56baae1c0dc7b7a9e7321ff Author: Martin Mares Date: Tue Aug 3 19:35:01 1999 +0000 Pruned the TODO list. commit 9c11ec9efca2fc75495cf8dcb28a959ba22b01fa Author: Martin Mares Date: Tue Aug 3 19:34:26 1999 +0000 Implemented a Table-to-Table protocol a.k.a The Pipe. commit 8c943173ced1fb85c627a8ba1c3d7360eab7d22b Author: Martin Mares Date: Tue Aug 3 19:33:45 1999 +0000 Allow announces of rte's to protocols in FS_FEEDING state. Else, we would get chicken-egg problems in the table-to-table protocol. commit 7de45ba4a01bfdc986a4b597c04ad39d9b97a58a Author: Martin Mares Date: Tue Aug 3 19:33:22 1999 +0000 Kernel route syncer supports multiple tables. The changes are just too extensive for lazy me to list them there, but see the comment at the top of sysdep/unix/krt.c. The code got a bit more ifdeffy than I'd like, though. Also fixed a bunch of FIXME's and added a couple of others. :) commit 9d8856897f92ad74be140adafaac41f9df6edf31 Author: Martin Mares Date: Tue Aug 3 19:31:54 1999 +0000 Protocol engine bug fixes: o Make proto_config->table always point to the right table even if it should be the default one. o When shutting down, kill protocol in reverse order of their priority. o When stopping a protocol down, disconnect it from routing tables immediately instead of waiting for the delayed protocol flush event. Also added a protocol instance counter (used by KRT code in very magic ways). commit b6628a8c98fa53c1b293221ad0f7e0611cb0b76d Author: Martin Mares Date: Tue Aug 3 19:31:30 1999 +0000 Added macros for walking lists backwards. commit 9a706f32afe703a44e605e92cc50cc77d4e91088 Author: Martin Mares Date: Tue Aug 3 19:31:11 1999 +0000 Added missing structure declarations. commit 8edf2361f9c4bd745a1249db3f66dfc079dd2ca1 Author: Martin Mares Date: Tue Aug 3 19:30:49 1999 +0000 Cleaned up handling of interface patterns: o Parsing of interface patterns moved to generic code, introduced this_ipatt which works similarly to this_iface. o Interface patterns now support selection by both interface names and primary IP addresses. o Proto `direct' updated. o RIP updated as well, it also seems the memory corruption bug there is gone. commit 9273035403ace754e5b405b2c5efba7d55c28e78 Author: Martin Mares Date: Tue Aug 3 19:30:20 1999 +0000 Changes to interface handling on traditional Unices: o Aliases are interpreted as secondary addresses. o When the system doesn't supply interface indices, generate our ones. commit 5e13ffe6f4e229974238bb2ea96ea2ce8282b7ed Author: Martin Mares Date: Tue Aug 3 19:29:57 1999 +0000 Faster checksum function. commit 913f7dc9f2dca8bebf8daebcce006b96f55ae6db Author: Martin Mares Date: Tue Aug 3 19:29:27 1999 +0000 Added functions for parsing and formatting of dates. commit 6542ece91a783e999f61cc51cbe18c8b4c96a36c Author: Pavel Machek Date: Thu Jul 1 09:11:21 1999 +0000 Function calling in filters works - somehow. Calling syntax is currently very ugly, beware. Variables are not really local - that needs to be fixed. commit 39369d6fbe4b3f73c8110b14623f367c8ffded50 Author: Ondrej Filip Date: Wed Jun 2 16:31:13 1999 +0000 Fixed stupid bug with hello vs inactim timers. commit bae0f7dbb111e2c8fbb8a94b59de6e241020ad66 Author: Ondrej Filip Date: Tue Jun 1 17:29:56 1999 +0000 Neigbor deleting done. (I have some problems with timers, so it does not send hello.) commit cd70d93470498c0b68a084be5aeab5dd45a0df60 Author: Ondrej Filip Date: Tue Jun 1 16:35:18 1999 +0000 Detecting of new neighbor added. It starts inactivity timer. commit bd7f1081f24aa6ca4cdba004478742b730644a91 Author: Martin Mares Date: Tue Jun 1 15:31:43 1999 +0000 Grrr, the "obvious fix" to multicasting code from yesterday was fundamentally wrong. Reversed. commit 3e1f30610e109b3eff7e3d8b420c4b7988bd3152 Author: Martin Mares Date: Tue Jun 1 13:57:24 1999 +0000 Defined IP_PREC_INTERNET_CONTROL and made all (well, both :)) protocols use it when creating sockets. commit 9de840bdbd59669a129f68f1ff3595b34439ec09 Author: Pavel Machek Date: Mon May 31 20:34:48 1999 +0000 Set corectly destination address for RIP multicast. Broadcasting & multicasting rip actually works [broadcasting is kind of hard to turn it on, through]. commit b94bbe00278b0c6e84f34875367d85d34d08621b Author: Pavel Machek Date: Mon May 31 20:30:16 1999 +0000 Added FIXME: mode broadcast randombly corrupts memory. Small cleaning and bugfixes. commit c7208da0b72dc7e4ff512edbecc62a99b0392c5a Author: Martin Mares Date: Mon May 31 20:28:46 1999 +0000 Fix potential multicasting bug. commit 9607536dbf7c50f9c2fc7a670eab51e5c313d10f Author: Pavel Machek Date: Mon May 31 19:43:08 1999 +0000 Kill duplicity between rif and rif_patt. commit 72efa4b6f82222f91b63b9f61bbc88e458096ea7 Author: Pavel Machek Date: Mon May 31 19:37:16 1999 +0000 Small fixes to rip. commit bf97bd28276af42aa59ea29b926b4848ae14e149 Author: Pavel Machek Date: Mon May 31 19:22:40 1999 +0000 Cleanup of warnings commit 91c7c7416b4a18ac2b9e872c2a1a6391cf8b3dc8 Author: Pavel Machek Date: Mon May 31 19:16:22 1999 +0000 Incoming side of authentication done but untested. Right handling of filters in rip. commit 2e6197d634a14533899915477032f082e675e35f Author: Pavel Machek Date: Mon May 31 19:15:52 1999 +0000 Added password_strncpy() which pads destination with zeros. commit 9c9e49ac392dfdbff97be579842028a4eb1d0dec Author: Pavel Machek Date: Mon May 31 19:15:32 1999 +0000 Added extended attributes for rip. commit c72b09c8508d71b9a0a998c2dabe475d54b4d014 Author: Ondrej Filip Date: Mon May 31 19:07:31 1999 +0000 IP socket priority (sock->tos) added. Constant taken from tcpdump of CISCO and gated. commit 35ff423d54ebabffc5ab9dd757dfa2a1a70e9676 Author: Ondrej Filip Date: Mon May 31 18:56:20 1999 +0000 Some RX_Hello checks added. commit bb027be1e232ca2207a03a8e001441965cc07801 Author: Martin Mares Date: Mon May 31 18:55:35 1999 +0000 Added extra argument to rt_update hook which contains a pointer to the temporary attribute list. commit 75b84c34e3434209517f2ebc8160f39d33e3735e Author: Ondrej Filip Date: Mon May 31 18:24:54 1999 +0000 Sending and receving of hello pkts works. No I will start building neighbor database. commit 4a4911a36a865525f5de86ea8b575164ea9a855a Author: Martin Mares Date: Mon May 31 17:39:44 1999 +0000 Added missing quotes. commit 10915c9650d4b63b12140effc68718e2aecd01d3 Author: Pavel Machek Date: Mon May 31 17:12:38 1999 +0000 Modified rip to new password handling in nest. Now it at least compiles. commit 900d5470ae2cada4d37ed62f8bf2ce64c84349cd Author: Pavel Machek Date: Mon May 31 17:12:00 1999 +0000 Added PASSIVE option to paswwords. commit 139ca21d05df71b59a72af126d063170421cf9f7 Author: Martin Mares Date: Mon May 31 13:21:07 1999 +0000 Added sk_send_buffer_empty(). commit fd5f8704bb7c2e9845a7c4785ace83a2b77d2c57 Author: Pavel Machek Date: Wed May 26 14:37:47 1999 +0000 Make rip use newly defined password lists. commit 858a717796d7aa48fe9b22a6b035fec9edbb5a2a Author: Pavel Machek Date: Wed May 26 14:37:07 1999 +0000 Change format of passwords (less ;'s) and fix password.h to allow multiple inclusions. commit 7eb01479c92cd2f615993f2112aa5986f3e2b0ad Author: Pavel Machek Date: Wed May 26 14:36:34 1999 +0000 Example of password list usage. commit 1a2ded450ecfbb8ccb7f459d7265fc5333d13420 Author: Pavel Machek Date: Wed May 26 14:24:57 1999 +0000 Skeleton for password handling, currently I only build structures and do nothing more advanced for them commit 9d79fec8dc7c5a3b7e590c00df7eadcef9e80144 Author: Pavel Machek Date: Wed May 26 14:24:32 1999 +0000 Added notion of datetime commit 6bd08d017b5cb2608a81c0c7c9fe8fb5da73ba60 Author: Pavel Machek Date: Wed May 26 14:22:41 1999 +0000 Better date/time input methods need to be done commit 903a3f3928a5d7c223ff4c0087343cf214f8478d Author: Ondrej Filip Date: Mon May 24 21:49:22 1999 +0000 struct ospf_neigbor corrected. commit c76674f0e98d356ea235ea76fd55d71a3673b123 Author: Ondrej Filip Date: Mon May 24 21:17:16 1999 +0000 struct ospf_neigbor added. Neigbor state machine implementation can start. commit 65112dd270dbfa598c1f8a5074bf7224b9e1469c Author: Ondrej Filip Date: Mon May 24 18:22:00 1999 +0000 ifa->time split into wait_timer and hello_timer. I will send hello in WAITING state. commit daeb60393d011f8ee1326e212b310983276b6ba1 Author: Ondrej Filip Date: Mon May 24 17:37:45 1999 +0000 Small bug in ipv4_skip_header. commit b9f8590025fd5d6dd360f759c5a219d69b975123 Author: Ondrej Filip Date: Mon May 24 17:29:05 1999 +0000 IP header test added. commit 4b0d57e53120e404e00f7d252119e45288ceeb71 Author: Martin Mares Date: Fri May 21 14:29:44 1999 +0000 Added CONFIG_MULTIPLE_TABLES whereever appropriate. commit 1c3c9dceb385198199c6c0190f3011d106142b67 Author: Martin Mares Date: Fri May 21 14:29:23 1999 +0000 Removed one unused structure field. commit a70693ca9bc935513d1bfa9b3a49459d27927657 Author: Martin Mares Date: Fri May 21 14:28:44 1999 +0000 Don't forget to export CPPFLAGS to GCC. :) commit a07e9d82352d0060ff4f00aa8d0a2575cafc781a Author: Martin Mares Date: Fri May 21 14:09:06 1999 +0000 Added --with-sysinclude to allow explicitly setting where kernel includes reside, so that you can easily switch between 2.0 and 2.2 ones. Check existence of for linux-22 configs to make sure we're using the correct set of includes. commit 4f1a6d27b9a44f61329bc7b6779a0c645362e181 Author: Martin Mares Date: Mon May 17 20:16:53 1999 +0000 Kill remaining master_table relics in KRT code. Make all protocols pass routing table to rte_update and rte_discard. commit 0e02abfd5770062768eeb4c75061b7d2f656489d Author: Martin Mares Date: Mon May 17 20:14:52 1999 +0000 From now we support multiple tables. The master_table variable is definitely gone. Both rte_update() and rte_discard() have an additional argument telling which table should they modify. Also, rte_update() no longer walks the whole protocol list -- each table has a list of all protocols connected to this table and having the rt_notify hook set. Each protocol can also freely decide (by calling proto_add_announce_hook) to connect to any other table, but it will be probably used only by the table-to-table protocol. The default debugging dumps now include all routing tables and also all their connections. commit 4107df1d1b7454a16e6f45ea55aae13b01c9f566 Author: Martin Mares Date: Mon May 17 20:06:19 1999 +0000 Implemented two new symbol handling functions: o cf_define_symbol() -- it assigns a meaning to a symbol, bailing out if it already has one. o cf_find_symbol() -- finds symbol by name and creates it if not found. Also modified filter/config.Y to make use of the first function. commit b23c5e0ff4e9071b2568bf2f7d437bc13273d17d Author: Martin Mares Date: Fri May 14 18:03:09 1999 +0000 Added ip_skip_header() and modified OSPF to use it. commit 11ce4490fac7d0446802738f5fb8fd68c36bd30b Author: Ondrej Filip Date: Fri May 14 08:50:25 1999 +0000 *** empty log message *** commit 67ff91302f21f6a40201bcc8a01c9c76eaaf1ed1 Author: Ondrej Filip Date: Fri May 14 08:46:06 1999 +0000 Netmask checking for hello packets added. commit 7426ee3d49fab13428f198c78c8b7f3da131382e Author: Ondrej Filip Date: Thu May 13 09:18:36 1999 +0000 Checksum control added. commit 296ecb56eb4d1951d23d74d502d2c48a42eb6eee Author: Ondrej Filip Date: Tue May 11 15:34:33 1999 +0000 OSPF RX implementation starts.... commit 1b16029c12a501752388523ebfe2981e7d7d7ed3 Author: Pavel Machek Date: Tue May 11 09:53:45 1999 +0000 Mensi updaty do ripu. Pridana passwd autentikace (netestovano). commit f7103dfcfe174d39c8aa10eb100550e3ec213981 Author: Ondrej Filip Date: Tue May 11 09:50:02 1999 +0000 Better logging output. Added 'struct proto *' info 'struct ospf iface'. commit 1a54d44a23de7b0bf0dfe62dd3d09d8167e5a597 Author: Martin Mares Date: Mon May 10 21:37:39 1999 +0000 Added packet checksumming code. Watch the comments for an explanation. commit a2697f02ac5109e749bff4d07bee6cedd0ab650b Author: Martin Mares Date: Fri May 7 13:46:16 1999 +0000 Netlink support for secondary interface addresses. commit 9a158361da249e0eab1e0f7bd2c7dbe9f32eddfa Author: Martin Mares Date: Thu May 6 21:38:11 1999 +0000 I rewrote the interface handling code, so that it supports multiple addresses per interface (needed for example for IPv6 support). Visible changes: o struct iface now contains a list of all interface addresses (represented by struct ifa), iface->addr points to the primary address (if any). o Interface has IF_UP set iff it's up and it has a primary address. o IF_UP is now independent on IF_IGNORED (i.e., you need to test IF_IGNORED in the protocols; I've added this, but please check). o The if_notify_change hook has been simplified (only one interface pointer etc.). o Introduced a ifa_notify_change hook. (For now, only the Direct protocol does use it -- it's wise to just listen to device routes in all other protocols.) o Removed IF_CHANGE_FLAGS notifier flag (it was meaningless anyway). o Updated all the code except netlink (I'll look at it tomorrow) to match the new semantics (please look at your code to ensure I did it right). Things to fix: o Netlink. o Make krt-iface interpret "eth0:1"-type aliases as secondary addresses. commit ec8b579e9c9703601bf745745b620103fe2e2477 Author: Martin Mares Date: Tue Apr 27 16:03:17 1999 +0000 Recognize site scope for IPv4 addresses (prefixes reserved for private networks). Removed old #ifndef logic which was used to avoid IPv4/IPv6 clashes before conditionals in Modules lists were introduced. commit 59e2188cb7020e43e25c9d5bdcd011f341ddfc1d Author: Ondrej Filip Date: Tue Apr 27 13:04:33 1999 +0000 Just changes of comments. commit 6376a961332552e2bc178d647f1e5cfa01a1ac32 Author: Ondrej Filip Date: Tue Apr 27 12:56:52 1999 +0000 Hello timer implemented. commit 93bde8dce23ae10476263a84cc40bbe186263fdc Author: Ondrej Filip Date: Thu Apr 22 13:12:28 1999 +0000 Work on hello continues. commit 36bbfc704c7d2153537751e24413db9b9c97bc58 Author: Pavel Machek Date: Mon Apr 19 18:41:56 1999 +0000 Updated filters: they now actually see IP/pxlen of net being filtered, gateway, and who told us, so they can do usefull jobs from now on. commit afbc41ab3d4f07f7dc4dbc6c769fe7fa1567f357 Author: Pavel Machek Date: Wed Apr 14 21:11:24 1999 +0000 SImplify code a tiny bit. commit b11d8a4f59b3559779938b0a37914a7bc8c07a6b Author: Ondrej Filip Date: Wed Apr 14 15:13:44 1999 +0000 Redesigned struct ospf_iface & new struct ospf_sock. commit b31568a516142e905712bad498914fb6a82dc25b Author: Ondrej Filip Date: Wed Apr 14 12:47:18 1999 +0000 Small bug fix in memcpy. commit 4c5e5e3a1c438cb2e92535e3fabc458aa0d6deb3 Author: Martin Mares Date: Wed Apr 14 12:29:47 1999 +0000 Multicasts once again: When using SO_BINDTODEVICE, don't specify IP address of the interface. commit 1b50a1e4be2b54bd4ccadfaeaf558aea15255de4 Author: Martin Mares Date: Wed Apr 14 11:39:07 1999 +0000 Next attempt to get SO_BINDTODEVICE work :) commit 36154beb705cdaf03f9ee050798d9e653ded6ca5 Author: Martin Mares Date: Wed Apr 14 11:21:02 1999 +0000 Use SO_BINDTODEVICE if we're using old multicast API (i.e., struct ip_mreq and not ip_mreqn). This should get multicasts on unnumbered PtP links work. commit 9da4d143402efd16bec286e3723b42386b20968b Author: Martin Mares Date: Wed Apr 14 11:09:55 1999 +0000 A couple of OSPF fixes: o ((flags & IF_CHANGE_UP) == IF_CHANGE_UP) -> (flags & IF_CHANGE_UP) o bcopy -> memcpy (bcopy is unportable) o Ifdeffed out add_tail(&(ifa->sk_list),NODE mcsk) -- the node in socket structure is for internal use by the resource manager only. (Now, the debugging dump of open sockets looks sane :-)). commit 1ab4dee0288e4ad6c8fbefae3aa64ca873cf4500 Author: Martin Mares Date: Wed Apr 14 10:49:31 1999 +0000 Removed redeclaration of `idval', so that it compiles :) commit 4c630a6dd7e02cbbe1cca2c626feb86801ee4d03 Author: Ondrej Filip Date: Tue Apr 13 21:46:20 1999 +0000 Added wait timer for eligible BCAST & NBMA interface. commit 55e7732a5a5fe47752eafe6024ba473bd7959e45 Author: Ondrej Filip Date: Tue Apr 13 19:27:44 1999 +0000 Change in ospf_iface. (My bad understanding of lists manipulation.) commit aec76c6e8e5702144522f0061bc102d26e10b97c Author: Ondrej Filip Date: Tue Apr 13 18:21:53 1999 +0000 IPv6 changes. commit 43fc099b98594fb3ac6a56a90fd00f42fc98f742 Author: Pavel Machek Date: Tue Apr 13 11:40:04 1999 +0000 Sets of IP addresses should work, now. (From now on it is also possible to write if 1.2.3.4 < 1.2.3.5, but I'm not sure if it is good for anything.) commit 24eaae9e5d0b154ec47d9d4e13649fb066814ef1 Author: Ondrej Filip Date: Tue Apr 13 00:46:34 1999 +0000 Small change to stop using loopback. commit cb2e8c49706c14ea662df44cd3911c1f9db4b4a8 Author: Ondrej Filip Date: Tue Apr 13 00:24:05 1999 +0000 A small init change to avoid core dump. commit 5b1a92e6d4350bcecff4f78b9cfabfb98ca7ce2a Author: Ondrej Filip Date: Mon Apr 12 23:54:21 1999 +0000 Not all I mean serious. Almost everything will change. Changes: struct ospf_iface draft, various constants added... commit 2f5d154466e8d76f4054561a361bb45f157c29a6 Author: Martin Mares Date: Mon Apr 12 20:26:06 1999 +0000 Added ipa_compare as requested. commit 38506f71b0bea5580987e999a7b1a69f58aec7ec Author: Pavel Machek Date: Mon Apr 12 19:58:18 1999 +0000 Sets of integers now actually work. Sets of IP will work as soon as compare function is ready. commit 01bd7759b260b379089acf28cc47bd49572ebd22 Author: Martin Mares Date: Mon Apr 12 18:07:05 1999 +0000 Ignore alias interfaces (some day, we will treat them as pure secondary interface addresses). commit 08e2d6259a71c5e43ac0083ea6d81357678f99eb Author: Martin Mares Date: Mon Apr 12 18:01:07 1999 +0000 Removed TOS support. This simplifies many things a lot. commit 170c984a9ef1bde00711f405b03d24a2e151501c Author: Martin Mares Date: Mon Apr 12 17:27:21 1999 +0000 Cosmetic message fix. commit 113694892e9669a1ae3dd44274f27c862c6c293a Author: Martin Mares Date: Mon Apr 12 17:21:11 1999 +0000 Use $(CC) instead of gcc even when generating dependencies. commit 620c4f90c9437362bf17180e6dbbf14c4e480e40 Author: Martin Mares Date: Mon Apr 12 17:20:50 1999 +0000 Oops, a typo in previous struct ip_mreqn changes... commit 61fb537c6273c50deb7d33f8af246993eab4bc4d Author: Martin Mares Date: Mon Apr 12 15:27:56 1999 +0000 Use `struct ip_mreqn' instead of `struct ip_mreq' for multicast operations on 2.1/2.2 kernels. This allows passing of real interface indexes instead of referencing interfaces by their IP addresses which fails badly in presence of unnumbered interfaces. Unfortunately, this structure is not visible with glibc 2.0 as it provides its own networking headers :-( Both libc5 and glibc 2.1 should be OK. commit 5a99ade413b97a780758f5c8f927604ad6c8e57b Author: Martin Mares Date: Mon Apr 12 14:57:46 1999 +0000 Fixed a couple of bugs in handling of multicast sockets. See comments in lib/socket.h for a detailed guide on how to use them. commit bad631e04806287e99e2464c0fdc884f9efa1e71 Author: Pavel Machek Date: Mon Apr 12 12:07:15 1999 +0000 Oops, typo. commit 8ba2cc064b823274e8af043bf0676bfc252e810a Author: Pavel Machek Date: Mon Apr 12 12:01:59 1999 +0000 In case no startup function is defined, don't try to launch it. commit ed9a82369ffc660ec20d9b7fa64188a450267672 Author: Martin Mares Date: Sun Apr 11 19:28:16 1999 +0000 Added new target "tags" to generate a tag table for Emacs. Also made "depend" work before the tree is compiled first time. commit 2db3b2887ea93c9946956a9a5ce5a06f0ef783c3 Author: Pavel Machek Date: Sat Apr 10 09:45:08 1999 +0000 Decrease number of warnings. commit 49ed70b48e3b66c4dd71315e842733d69204698e Author: Martin Mares Date: Wed Apr 7 14:25:56 1999 +0000 Portability fixes. commit 23b1539bf90bfb6b35d9a2be0a2b6b1e311c1460 Author: Pavel Machek Date: Wed Apr 7 12:11:08 1999 +0000 Filters upgraded - a bit. Moved code to filter.c because it is where it belongs. (f-util.c stays there for auxiliary and non-important things.) commit 7976a574b692f747d833d899caf0fbbf702714c1 Author: Martin Mares Date: Tue Apr 6 21:31:03 1999 +0000 ip_pton: Avoid modification of the string we're converting. commit e2dc2f30efd65cf3da4db150fae695978388e247 Author: Martin Mares Date: Mon Apr 5 20:25:03 1999 +0000 Routing table core changes to support full route filtering: o Introduced rte_cow() which should be used for copying on write the rte's in filters. Each rte now carries a flag saying whether it's a real route (possessing table linkage and other insignia) or a local copy. This function can be expected to be fast since its fast-path is inlined. o Introduced rte_update_pool which is a linear memory pool used for all temporary data during rte_update. You should not reference it directly -- instead use a pool pointer passed to all related functions. o Split rte_update to three functions: rte_update The front end: handles all checking, inbound filtering and calls rte_recalculate() for the final version of the route. rte_recalculate Update the table according to already filtered route. rte_announce Announce routing table changes to all protocols, passing them through export filters and so on. The interface has _not_ changed -- still call rte_update() and it will do the rest for you automagically. o Use new filtering semantics to be explained in a separate mail. commit 9e0e485e50ea74c4f1c5cb65bdfe6ce819c2cee2 Author: Martin Mares Date: Mon Apr 5 20:17:59 1999 +0000 Added some new protocol hooks (look at the comments for better explanation): make_tmp_attrs Convert inline attributes to ea_list store_tmp_attrs Convert ea_list to inline attributes import_control Pre-import decisions commit 5056c559c4eb253a4eee10cf35b694faec5265eb Author: Martin Mares Date: Mon Apr 5 20:15:31 1999 +0000 Changed syntax of attaching filters to protocols to hopefully the final version: EXPORT for outbound routes (i.e., those announced by BIRD to the rest of the world). IMPORT for inbound routes (i.e., those imported by BIRD from the rest of the world). where is one of: ALL pass all routes NONE drop all routes FILTER use named filter FILTER { } use explicitly defined filter For all protocols, the default is IMPORT ALL, EXPORT NONE. This includes the kernel protocol, so that you need to add EXPORT ALL to get the previous configuration of kernel syncer (as usually, see doc/bird.conf.example for a bird.conf example :)). commit 63a381dbf5e37c2740982d07988cea983c699816 Author: Martin Mares Date: Mon Apr 5 20:10:31 1999 +0000 Several filter changes. (Pavel, please check if they are OK.) o Changed parameters of f_run. Changed rtein+rteout pair to rte pointer passed by reference, added ea_list of temporary attrs again passed by reference and finally added a pointer to memory pool for storing temporary data (new ea_lists's, temporary rta's etc.). o Re-ordered result codes, so that all accepts come before all rejects. o Introduced FILTER_ACCEPT and FILTER_REJECT dummy values (will be used in protocol configurations). o Added filter_name() which returns name of a filter or ACCEPT/REJECT for the dummies. commit d4ff748224fc18e460e74ab14d70d01fd50e4b92 Author: Martin Mares Date: Mon Apr 5 20:06:02 1999 +0000 Use a more reasonable pool chunk size: 4080 bytes seem to be a good approximation of a integral fraction of page size even if both malloc overhead and chunk header space is counted. commit c10421d3d4b5f23dc953c887332bdb6e80ae0540 Author: Martin Mares Date: Sat Apr 3 13:05:18 1999 +0000 More changes to the kernel syncer. o Now compatible with filtering. o Learning of kernel routes supported only on CONFIG_SELF_CONSCIOUS systems (on the others it's impossible to get it semantically correct). o Learning now stores all of its routes in a separate fib and selects the ones the kernel really uses for forwarding packets. o Better treatment of CONFIG_AUTO_ROUTES ports. o Lots of internal changes. commit 69ec9087ad3fb631f46275220909a876deadb6b5 Author: Martin Mares Date: Sat Apr 3 13:01:58 1999 +0000 Added new protocol hook for dumping of protocol-dependent route attributes. Please implement in all protocols. commit 73c7bed168890399981f70e1d0be35d8cde01fed Author: Martin Mares Date: Sat Apr 3 13:00:52 1999 +0000 Defined CONFIG_SELF_CONSCIOUS whenever the kernel scanner is able to distinguish between our own routes and alien ones. commit fe662dfd782619fd6505a1456b973b2525ab6ebf Author: Martin Mares Date: Fri Apr 2 13:38:54 1999 +0000 Fixed `too many interfaces' cases. commit 0498d92f955f011ceb70e1124f25ac567c359005 Author: Pavel Machek Date: Fri Apr 2 11:45:55 1999 +0000 Believe it or not, printf()'s does not work too much without this one. commit 8cda9cdbcf445ebe828b7bf89dcb4c7f83937756 Author: Martin Mares Date: Thu Apr 1 19:23:59 1999 +0000 Argh, the fix was wrong. commit e4241f24f2ebc796a9cfb03db2a9502f5ebd9c0c Author: Martin Mares Date: Thu Apr 1 15:35:15 1999 +0000 Portability fixes. commit abae6e9cd3f041648eaa85fad2f861515b67c1ce Author: Martin Mares Date: Thu Apr 1 15:33:52 1999 +0000 First few FreeBSD portability fixes. commit 6accdf4f437ef2a3251df917f2b83fe985e64961 Author: Martin Mares Date: Mon Mar 29 20:46:00 1999 +0000 Updated the TODO list. commit fb71b23e6004d18480dcfdfbc2e7da7bbc4eb400 Author: Martin Mares Date: Mon Mar 29 20:33:45 1999 +0000 Remember that we can run device syncer without kernel syncer and vice versa now. commit 78d5ec15043ab67fdf31feabe4a83129488625fe Author: Martin Mares Date: Mon Mar 29 20:28:25 1999 +0000 Please don't commit debugging code which makes BIRD exit before anything actually starts to happen. Grrr. commit e4912e3594c9211c8a147f1dcd4eeaf3b0095ed0 Author: Martin Mares Date: Mon Mar 29 20:26:32 1999 +0000 Prefer `gm4' over `m4' (due to BSD et al.). commit ba92164871f65bb9adcfa66b901d1a7b86697a86 Author: Pavel Machek Date: Mon Mar 29 20:21:28 1999 +0000 Update of filters towards new interface. commit 5bc512aa3a0d3e4ca378fff3316b75c131f17637 Author: Martin Mares Date: Mon Mar 29 20:14:33 1999 +0000 Clarify resource dumps and include them in the main debugging dump. commit 3f2a21fd348e49cf3ca98750b14e14dd04b3209b Author: Martin Mares Date: Mon Mar 29 20:14:00 1999 +0000 Don't try to delete interface routes on CONFIG_AUTO_ROUTES systems. commit 6c02d83f4d225abc03f99fb80299f1ba10ac174a Author: Martin Mares Date: Mon Mar 29 19:56:32 1999 +0000 Added FIXME: If a strange interface appears, ignore it instead of only writing an error message... commit f5c687f7911501ac1efd8163fade4862dc65456c Author: Martin Mares Date: Mon Mar 29 19:35:47 1999 +0000 Added lp_flush() which flushes contents of a linear pool, leaving all the memory available for subsequent allocations from the same pool. Both flushing and re-using the memory costs just few instructions. commit f54801ffedf3d6342b37c1560502bfc24e7fe64a Author: Martin Mares Date: Mon Mar 29 19:14:43 1999 +0000 Moved all system-dependent #include's containing endianity conversion functions to sysdep header endian.h. commit 6134024815adf2541293008f848dce4e8a21d061 Author: Martin Mares Date: Mon Mar 29 19:13:36 1999 +0000 #define NULL if not defined by system includes. commit 7f400d1c620e80461e61384c7d0b8893edb92695 Author: Martin Mares Date: Mon Mar 29 19:04:14 1999 +0000 After today's lengthy discussions about filter syntax, let's clean up whitespace/semicolon rules for whole config file: o All non-zero amounts of whitespace are equivalent to single space (aka `all the whitespace has been born equal' ;-)). o Comments count as whitespace. o Whitespace has no syntactic signifance (it can only separate lexical elements). o Consequence: line ends are no longer treated as `;'s. o Every declaration must be terminated by an explicit `;' unless or by a group enclosed in `{' and `}'. commit 1127ac6ec7eff52d4ccbc4d836a63fa6513f6d48 Author: Martin Mares Date: Sat Mar 27 22:51:05 1999 +0000 Cleaned up system configuration files -- removed few obsolete parameters, documented the remaining ones (sysdep/cf/README). Available configurations: o linux-20: Old Linux interface via /proc/net/route (selected by default on pre-2.1 kernels). o linux-21: Old Linux interface, but device routes handled by the kernel (selected by default for 2.1 and newer kernels). o linux-22: Linux with Netlink (I play with it a lot yet, so it isn't a default). o linux-ipv6: Prototype config for IPv6 on Linux. Not functional yet. commit 7dc4827c968053e45bcb7f145e9986eeb20c993b Author: Martin Mares Date: Fri Mar 26 21:50:43 1999 +0000 Added everything protocols need to know about multiple routing tables, i.e. struct proto now contains field 'table' pointing to routing table the protocol is attached to. Use this instead of &master_table. Modified all protocols except the kernel syncer to use this field. commit 7e5f5ffdda7232048c4baf3fdec358afb494a29d Author: Martin Mares Date: Fri Mar 26 21:44:38 1999 +0000 Moved to a much more systematic way of configuring kernel protocols. o Nothing is configured automatically. You _need_ to specify the kernel syncer in config file in order to get it started. o Syncing has been split to route syncer (protocol "Kernel") and interface syncer (protocol "Device"), device routes are generated by protocol "Direct" (now can exist in multiple instances, so that it will be possible to feed different device routes to different routing tables once multiple tables get supported). See doc/bird.conf.example for a living example of these shiny features. commit 739ebd8e82b090ed91b3ebe77509ecd6784eca9a Author: Martin Mares Date: Fri Mar 26 21:38:02 1999 +0000 Allow different instances of the same protocol with identical preferences. commit 4ba84ebc8285c3a5c556fc769101cc29cb3d3708 Author: Martin Mares Date: Fri Mar 26 21:37:29 1999 +0000 Slightly better generator of default protocol instance names. commit 241b7311ec5a091b7f3e1a1f2a776f3ef403c500 Author: Martin Mares Date: Fri Mar 26 21:35:28 1999 +0000 Don't compile OSPF by default. commit b5239f223874b87dd7c9de4d624cdf1230022111 Author: Martin Mares Date: Fri Mar 26 21:33:36 1999 +0000 Don't try to manipulate neighbor lists for copied interface structures. This avoids few nasty references to free memory. commit f79a749d0b9a5a7509db9ad6c547bbabc0457675 Author: Martin Mares Date: Wed Mar 24 09:23:34 1999 +0000 Removed our declaration of RTPROT_BIRD since Alexey has assigned us a real protocol number in 2.2.4 kernel. commit 421838ffef49338218dd85ff5efd1d5396ab7ccf Author: Martin Mares Date: Wed Mar 17 15:01:07 1999 +0000 rte_update: Check sanity of incoming entries. Throw out (and log) all routes to bogus prefixes and non-local routes to host scope addresses. commit 529c414953c24c326d9063a8f06fa652f0dfbc30 Author: Martin Mares Date: Wed Mar 17 14:31:26 1999 +0000 Allow input and output filters (only accept/reject style as we didn't define modifying filters yet) to be attached to protocol instances. commit e0f2e42f4f420f7bbdda3d4656c9dda585f1297a Author: Martin Mares Date: Wed Mar 17 14:29:39 1999 +0000 A couple of filter tweaks: o Introduced struct filter which serves as an external reference to filter. Using struct symbol for this is unwise since it doesn't allow extra information attached to the filter and it also forces all filters to be named. o Implemented config rule 'filter' which matches either named filter or an embedded unnamed filter (`{ }'). o Fixed totally bogus comment at the top of filter.h. o Added a missing prototype for f_run() to filter.h. commit c612a3be310069b9fbbcfef931bb546d536a716f Author: Martin Mares Date: Wed Mar 17 13:13:18 1999 +0000 Removed the `rta_same' hook since it's no longer needed (all protocols needing some local information should use extended attrs and cached rta's). commit b77ae37d11aa6e16dce31f50ca42ea30714a793e Author: Martin Mares Date: Wed Mar 17 13:09:09 1999 +0000 Implemented extended route attributes and all related functions. commit 9a38757c6ab87bf64ebc22b25b1410a3a09e6b10 Author: Pavel Machek Date: Wed Mar 17 13:05:25 1999 +0000 Initialize pointers to functions so that code is actually alive. commit 3c7ad64c57de77763357684fab919b2fc082a759 Author: Pavel Machek Date: Wed Mar 17 13:04:33 1999 +0000 Compilation fix for mj. commit 29df5739c455a954598c809c2e930abc41c8488e Author: Pavel Machek Date: Wed Mar 17 10:20:23 1999 +0000 Don't segfault on unknown interface. commit d36d838df5f726e1f6845fe0e6e5c188426ac00d Author: Pavel Machek Date: Wed Mar 17 10:19:07 1999 +0000 accept & reject should now work commit c1f8dc9149d3868e5a0f4e4ad97759fb3b177bec Author: Ondrej Filip Date: Tue Mar 9 22:27:43 1999 +0000 Yes, joining the crew. Sorry for being late. Added dummy functions for OSPF. commit 2575593e0fa9fb84a4cc481928c32519b3fea2cd Author: Pavel Machek Date: Tue Mar 9 14:45:27 1999 +0000 Resolved conflicts, you no longer need to wrap constants in const() commit 1aa5cf1c6171393d4be4447eada173d4e1eb983a Author: Pavel Machek Date: Tue Mar 9 14:44:43 1999 +0000 Added '=' to operator list commit b7005824453583d1459b49c5a424b50e2ea9a2c8 Author: Pavel Machek Date: Mon Mar 8 20:30:06 1999 +0000 Filters are now a tiny bit stronger (if is actually working ;-) commit 111213f0b66cff8f562f7d9117c9080a9882129e Author: Martin Mares Date: Thu Mar 4 19:00:31 1999 +0000 Fixed processing of !krt_capable() routes. Converted device route decisions to the krt_capable mechanism as well. commit e16155ae4aaee5d9ba7b6940f8312b36707718e4 Author: Martin Mares Date: Thu Mar 4 18:36:18 1999 +0000 KRT: Implemented asynchronous route / interface state notifications (via Netlink). Tweaked kernel synchronization rules a bit. Discovered locking bug in kernel Netlink :-) Future plans: Hunt all the bugs and solve all the FIXME's. commit 2253c9e239253d2094b4b1cabd97d296af885afb Author: Martin Mares Date: Thu Mar 4 14:23:32 1999 +0000 Although there are still heaps of FIXME's, Netlink works. To build BIRD with Netlink support, just configure it with ./configure --with-sysconfig=linux-21 After it will be tested well enough, I'll probably make it a default for 2.2 kernels (and rename it to linux-22 :)). commit f81dc8564ae6c17638d7e3970b9980d0d00fc78a Author: Martin Mares Date: Thu Mar 4 11:40:05 1999 +0000 Converted some mb_alloc/bzero pairs to mb_allocz. commit 8fe48f1377c8b501e9b090748b195c62f5b582d2 Author: Martin Mares Date: Thu Mar 4 11:39:24 1999 +0000 Initialize allocated struct proto :-) commit 7a2105becdbadf20c1b4e4d2359e339c90610825 Author: Martin Mares Date: Thu Mar 4 11:36:26 1999 +0000 Use dmalloc instead of EFence when available (dmalloc has lot of improvements over EFence and also hopefully smaller memory overhead, but sadly it's non-free for commercial use). If the DMALLOC_OPTIONS environment variable is not set, switch on `reasonable' checks by default. Also introduced mb_allocz() for cleared mb_alloc(). commit aa64578641c15b137172acc927d9d7af5914576b Author: Martin Mares Date: Wed Mar 3 20:57:29 1999 +0000 Netlink scans routes... commit 51ad41f2fc0c95179cb4ba65e568d2b84de32a28 Author: Martin Mares Date: Wed Mar 3 20:56:33 1999 +0000 EFence helped to find using of already free rte's in rt_prune(). commit 53b7a2982adf5d09a1cfddbc12cf172e0700fc55 Author: Martin Mares Date: Wed Mar 3 20:55:35 1999 +0000 Fix several things I broke today. commit 0e889c52542508dd49433bed1785072cb7799009 Author: Martin Mares Date: Wed Mar 3 20:40:51 1999 +0000 Added a hack forcing protocols with priority>0 to be started up immediately. Grrr, need to find a real solution some day. commit 2d14045224f2233aed386eddf155d10a81892c3f Author: Martin Mares Date: Wed Mar 3 19:49:56 1999 +0000 Rewrote the kernel syncer. The old layering was horrible. The new kernel syncer is cleanly split between generic UNIX module and OS dependent submodules: - krt.c (the generic part) - krt-iface (low-level functions for interface handling) - krt-scan (low-level functions for routing table scanning) - krt-set (low-level functions for setting of kernel routes) krt-set and krt-iface are common for all BSD-like Unices, krt-scan is heavily system dependent (most Unices require /dev/kmem parsing, Linux uses /proc), Netlink substitues all three modules. We expect each UNIX port supports kernel routing table scanning, kernel interface table scanning, kernel route manipulation and possibly also asynchronous event notifications (new route, interface state change; not implemented yet) and build the KRT protocol on the top of these primitive operations. commit b2280748ad5087b5dab54dd4e423053ffe1f2387 Author: Martin Mares Date: Wed Mar 3 19:33:54 1999 +0000 Introduced protocol priority (all 'normal' protocols should use the default zero priority). No more "kernel syncer initialized before device routes" problems. commit 84c7e1943f0dbf896b1dd8d02a21120aa00463f4 Author: Pavel Machek Date: Tue Mar 2 19:49:28 1999 +0000 Add interface for running filters (please comment!), avoid bison warnings commit 05a845ed8e623c51025058037d0ca25db712ae68 Author: Pavel Machek Date: Tue Mar 2 19:49:22 1999 +0000 Avoid segfault commit 7972248d5d7f404a65fd630b2af712703aca0746 Author: Martin Mares Date: Tue Mar 2 18:37:02 1999 +0000 Netlink module supports interface scan on startup. Working on more. commit e35ef181a41384446aca614522a7cbb10606dd5b Author: Martin Mares Date: Tue Mar 2 18:36:09 1999 +0000 o The if_change_too_big_p change was too high-spirited. Fixed. o Introduced if_find_by_index() o Recognizing two types of interface updates: full update (starting with if_start_update(), ending with if_end_update(), guaranteed to see all existing interfaces) and a partial update (only if_update(), usually due to asynchronous interface notifications). commit bcbd8cc3be670a96e1405b896cff4be0912ba379 Author: Martin Mares Date: Tue Mar 2 17:28:06 1999 +0000 Interface logic changes: o Introduced IF_LINK_UP flag corresponding to real link state. o Allowed addressless interfaces. o IF_UP is now automatically calculated and set iff the interface is administratively up, has link up and has an IP address assigned. It may be IF_IGNORED, though (as in case of the loopback). o Any changes which include up/down transition are considered small enough to not provoke artificial upping and downing of the interface. o When an interface disappears (i.e., it wasn't seen in the last scan), we announce this change only once. o IF_LOOPBACK implies IF_IGNORE. commit 25287d6f7e687c77704816e565529960c65e3250 Author: Martin Mares Date: Tue Mar 2 17:20:07 1999 +0000 Don't try to install static routes to disconnected neighbors. commit eab0d1e5e5e89d82e435d224f5faf1a16524c69c Author: Martin Mares Date: Tue Mar 2 16:39:41 1999 +0000 Latest changes broke out-of-tree compilation. commit 3d8ef0c9ef7878292ef314a0f5f34390d74f4e9f Author: Pavel Machek Date: Tue Mar 2 13:15:35 1999 +0000 I just don't like files enclosed in <>. commit e834074dd43cabd10ca9811191a212f86b8f6ed7 Author: Martin Mares Date: Mon Mar 1 22:42:47 1999 +0000 If we are compiling with debugging enabled and libefence is available, link it to get debugging malloc. commit b982b6db2bc9df396d4cd329e23c5b3199a409a2 Author: Martin Mares Date: Mon Mar 1 22:31:27 1999 +0000 Implemented netlink protocol parsing functions. More to come tomorrow. commit b4b3b39e20a669ab3f33f71474e937b5e9ce6d26 Author: Martin Mares Date: Mon Mar 1 22:30:33 1999 +0000 Added SK_MAGIC type sockets for internal use by system dependent code, especially for netlink communication. commit c748cdb9ec8b7de5daaf759825bc428cd0bcd400 Author: Pavel Machek Date: Mon Mar 1 21:18:01 1999 +0000 Hopefully ended translating to new interface commit bdb95a21a45bce1754bf54de3e7423cf8eebf9ee Author: Martin Mares Date: Mon Mar 1 20:17:46 1999 +0000 Added skeletal version of Linux netlink interface. It doesn't work yet, but the framework is there and I'll try finish it soon. commit ea3582a6f66223dfd2c0dd6c597dc40b48033fd5 Author: Martin Mares Date: Mon Mar 1 20:15:14 1999 +0000 Include "config.h" instead of "autoconf.h" in all Modules lists to make defines in the static portion of configuration includes available as well. commit 1b769b08c195f7d95525131f65e5794c3c09a335 Author: Martin Mares Date: Mon Mar 1 20:13:54 1999 +0000 Renamed struct rtattr to struct rta to make things more consistent and avoid namespace clashes with . Other files should not be affected since they use 'rta' directly. commit 025d14cd5a0909b534762e5a50bfef97c2b4c9ee Author: Martin Mares Date: Mon Mar 1 19:05:58 1999 +0000 Use traditional Unix route/iface interface only when CONFIG_NETLINK is not defined. Also moved declarations of Unix iface logic to krt.h. commit 12be9b8c1870ab8813d29350a2e2743f8e144642 Author: Martin Mares Date: Mon Mar 1 17:51:29 1999 +0000 Pruned the TODO list. commit 293e313ec91d4d23d6333e8cd852d425079cee68 Author: Pavel Machek Date: Mon Feb 15 13:34:43 1999 +0000 More rip fixes (config data moved to struct rip_proto_config), still not tested. commit b5fe3dc21c930e1d9864e342a75785efe862bd24 Author: Martin Mares Date: Sat Feb 13 22:13:04 1999 +0000 Cleaned up TODO file. That's all for today, midnight gets closer. commit 45090fecd97c97cceb677257c6e8c26044065d13 Author: Martin Mares Date: Sat Feb 13 22:02:21 1999 +0000 Synced example config with new options. commit d88e99a92ae688cc7f6534af4c2555fe6f6709f6 Author: Martin Mares Date: Sat Feb 13 21:59:48 1999 +0000 Implemented static device routes. Expect for reconfiguration issues, the static protocol is complete now. commit d1f7eab6b5f1bd86a47402cb8fdb5cbcedc8947f Author: Martin Mares Date: Sat Feb 13 21:58:53 1999 +0000 Parameter order for the proto->if_notify hook was different in the include file and different in reality. Decided to use the same order as we do for proto->rt_notify (i.e., first new value and second the old one). commit 726141746b7f86b02a902bd6b316792e4be0380c Author: Martin Mares Date: Sat Feb 13 21:34:33 1999 +0000 '#' comments in config files are equivalent to end of line, therefore also to implicit ';'. commit 5996da6a1d2eb11ac45d9d578618b9350e58593d Author: Martin Mares Date: Sat Feb 13 21:29:01 1999 +0000 Implemented garbage collection of routing tables to delete orphaned network nodes having no routes attached. Such cleanup must be done from event handler since most functions manipulating the routing tables expect network entries won't disappear from under their hands and it's also probably faster when done asynchronously. commit f4a0a64e02c13b2b467f9c1a29222f817b54ce2d Author: Martin Mares Date: Sat Feb 13 21:00:25 1999 +0000 Static protocol doesn't need any shutdown function. Everything gets disposed by the core: neighbors, rte's, etc's... commit 3fb4ca2ce2b5750d38a5e31023d2873c9942cc78 Author: Martin Mares Date: Sat Feb 13 20:57:47 1999 +0000 Don't send any neighbor notifications to protocols being flushed. commit 783f8b689a29aaffbe75e964fdd09a3c219ea81c Author: Martin Mares Date: Sat Feb 13 20:55:08 1999 +0000 When protocols go down, prune the neighbor list. commit 013a9b91fe495371cbf9a5690613de45b634e3af Author: Martin Mares Date: Sat Feb 13 20:46:03 1999 +0000 When shutting down, remove all routes (except for RTS_INHERIT and RTS_DEVICE routes) from kernel routing tables unless the "persist" switch is set. commit 0a2e9d9f5685fb4ca63e02fd3645194bb6de79d7 Author: Martin Mares Date: Sat Feb 13 20:19:24 1999 +0000 Moved sanity check of protocol state during annoucements to rte_announce. commit f4aabcee62890b7c3e999e188ab72752fbb20b79 Author: Martin Mares Date: Sat Feb 13 20:15:36 1999 +0000 Perform gracious shutdown upon receipt of SIGTERM. Finally we can test the whole protocol shutdown code... :) commit 7f3d1a0850ff7f240b2f240db6d44b3a5dee6d48 Author: Martin Mares Date: Sat Feb 13 19:57:19 1999 +0000 Squashed one bug in timing of route scans. commit 4c9dd1e4b95e273eacc900abb63db4b8bafaf34b Author: Martin Mares Date: Sat Feb 13 19:43:21 1999 +0000 Synchronize signals to the main select/event/timer loop. Parse command line options. commit 1a54b1c6ac5177a1ef21f799f6cf28f355c5bbe9 Author: Martin Mares Date: Sat Feb 13 19:15:28 1999 +0000 Implemented real cleanup and pruning of routing table on protocol shutdown. commit ab749558a2a4356c38ed760649ef7d62daa48223 Author: Martin Mares Date: Sat Feb 13 19:14:16 1999 +0000 Pass new argument to FIB_ITERATE_END. commit 2569bc40731081ac70ee328a7df37109399b53c6 Author: Martin Mares Date: Sat Feb 13 19:13:51 1999 +0000 Fixed bug in FIB_ITERATE_END: it assumed the control variable is named "z". I've added an argument specifying name of the variable. Renamed "again" label in FIB_ITERATE_* to "fis_again" to avoid name clashes. commit 4e9498cbb171d52e2f3015d3e9d6c7b1b7205e27 Author: Martin Mares Date: Sat Feb 13 18:42:00 1999 +0000 config->router_id works again. commit 67bd949a520151a5ab50090d02617adc4960868c Author: Martin Mares Date: Thu Feb 11 22:59:06 1999 +0000 Real implementation of protocol state machines. Delayed startup/shutdown should work now. Initial feeding of protocols by interfaces/routes is done from the event queue to prevent unwanted recursion. commit 14dea0ed25cd0385ce35cf66ff309a78960b18ca Author: Martin Mares Date: Thu Feb 11 22:51:15 1999 +0000 Run the event queue before writing SIGUSR dumps. commit 64011f898c1bc99183a57f21d6e099c8f4496a09 Author: Martin Mares Date: Thu Feb 11 22:45:54 1999 +0000 struct proto again contains instance name (a copy of proto->cf->name). commit 3b15402fd4055cb5bd66cd9ac1106ceecff9f760 Author: Martin Mares Date: Thu Feb 11 22:18:36 1999 +0000 Grrr, forgot to commit the event routines themselves :| commit e8f73195fa68b027fdcb89f239107c2d4902bd9a Author: Martin Mares Date: Thu Feb 11 21:18:26 1999 +0000 Added simple event scheduling system to avoid recursive calling of various callbacks. Events are just another resource type objects (thus automatically freed and unlinked when the protocol using them shuts down). Each event can be linked in at most one event list. For most purposes, just use the global event list handled by the following functions: ev_schedule Schedule event to be called at the next event scheduling point. If the event was already scheduled, it's just re-linked to the end of the list. ev_postpone Postpone an already scheduled event, so that it won't get called. Postponed events can be scheduled again by ev_schedule(). You can also create custom event lists to build your own synchronization primitives. Just use: ev_init_list to initialize an event list ev_enqueue to schedule event on specified event list ev_postpone works as well for custom lists ev_run_list to run all events on your custom list ev_run to run a specific event and dequeue it commit edf62ba13fa6a74447d7ad44b23acbee964731bc Author: Pavel Machek Date: Mon Feb 8 22:50:32 1999 +0000 Propagate depend into all subdirectories; make rip compile after latest mj's changes. commit ed245f967f76d29d6a4ce971ba4287ba6a7031f7 Author: Martin Mares Date: Fri Feb 5 21:39:21 1999 +0000 Synced Linux sysdeps to new interface. commit 10d807d000155a6257f6fbad88eb72a8bf9045da Author: Martin Mares Date: Fri Feb 5 21:38:50 1999 +0000 Synced kernel interface to new interface. commit e9e3dc265971fbf985c5df09cb1d98494c386581 Author: Martin Mares Date: Fri Feb 5 21:38:22 1999 +0000 Modified static router to use new interface. commit 31b3e1bbf5bc823ec5cf6d88931132f00e6c52b9 Author: Martin Mares Date: Fri Feb 5 21:37:34 1999 +0000 Implemented new configuration/reconfiguration interface and defined protocol state machines. Full explanation will follow soon. commit c4c63eecc37a744c53c23da89b1ba09b9640cb6e Author: Martin Mares Date: Fri Feb 5 21:29:19 1999 +0000 Added several parentheses to MIN/MAX macros. commit 292099d55f1131d75efec647d3780e7a1a665fdf Author: Pavel Machek Date: Wed Feb 3 12:28:16 1999 +0000 Few fixes in parsing of filters commit 294c182eb1dd02d0ae8658acb4a21db5d2977f3c Author: Martin Mares Date: Sat Jan 23 21:08:59 1999 +0000 Replaced the old ugly ipv6 compilation hack by a conditional in Modules. commit 2c2f67bd83c267c1dbee68c6ed7d67f9be77e566 Author: Martin Mares Date: Sat Jan 23 21:08:36 1999 +0000 Filter all `Modules' files through C preprocessor, so that they can reference BIRD configuration. By the way: Do you know GCC by default does `#define unix 1'? commit ca3d562b24d5a3e303ab00d276496fb38b7382ee Author: Pavel Machek Date: Fri Jan 15 18:13:55 1999 +0000 filters_init() renamed to filters_postconfig(). commit c9b6670608577521c883db4bccd75b871568b7f7 Author: Martin Mares Date: Fri Jan 15 18:04:28 1999 +0000 Original `expr' is back, filter expressions renamed to `term'. In the future, we'll allow any filter term in place of `expr' and we'll just evaluate it immediately, but not now as we have no evaluation routines. commit 3169cf699175a2489712eee955a9ee9890ef00c9 Author: Martin Mares Date: Fri Jan 15 17:18:41 1999 +0000 Added bird.conf to .cvsignore and created an example configuration file. If you want to run bird now, just copy doc/bird.conf.example as bird.conf and edit it to suit your needs. commit e3a39a9ee70bf7060f9de38268885b637bc1a65a Author: Martin Mares Date: Fri Jan 15 16:59:26 1999 +0000 Killed duplicate %type for expr. commit ca6dfded2c22c74298ff595e59afe4672151889b Author: Pavel Machek Date: Fri Jan 15 16:52:14 1999 +0000 Make filters actually compiled. commit b9d70dc84e488212328103438bdf4e369c7d27a1 Author: Pavel Machek Date: Fri Jan 15 16:49:17 1999 +0000 Filters, second try. This time they have their own directory. commit b79f9215b99c7a54dbb2639c972dda497d141133 Author: Martin Mares Date: Fri Jan 15 16:40:14 1999 +0000 Propagate "depend" target to real top-level Makefile. commit 489b6b5e003f4a8a7856688ab0372b2ca59c84d9 Author: Pavel Machek Date: Fri Jan 15 16:13:51 1999 +0000 #if 1 that creeped into cvs killed. commit eeb05158acd0cb8def7aa155c2c718f608e6a5ae Author: Pavel Machek Date: Fri Jan 15 14:42:55 1999 +0000 Be a tiny bit more verbose. commit 72380a3447d2c54730a4a32495e5dd964c34f57e Author: Pavel Machek Date: Fri Jan 15 14:41:51 1999 +0000 Filters added. They are unable to do anything interesting for now (with exception of printing integers to screen), but they exist. commit 41183888ee8addbd7887936e3b41974f5824d8ae Author: Pavel Machek Date: Fri Jan 15 14:40:50 1999 +0000 Properly initialize filters. Also bumped version to 0.0.0 as it actually does something. commit cceb3e7d2fafcf3acee1db1d762ed697863b6f3b Author: Martin Mares Date: Tue Jan 12 20:36:18 1999 +0000 Fixed trivial bug in naming of `depend' file. Argh. commit 663683a575cb170c656db06770b490037ecf3db7 Author: Pavel Machek Date: Tue Jan 12 16:50:38 1999 +0000 Make it compile again (stupid makefiles!), make quiet option work (multicast/broadcast options are currently unimplemented). commit 77cedad1f6de8fcd0e59f280d08437ab3216428e Author: Pavel Machek Date: Tue Jan 12 16:41:34 1999 +0000 Keep protocol data out of iface_patt. commit 50e89a6ea26caba59c7d4dd512fdc12c09cee64c Author: Pavel Machek Date: Tue Jan 12 16:40:55 1999 +0000 Patterns expanded in the right way commit 18fff6a1979725c1ed839d9a10285e22dc0b8214 Author: Martin Mares Date: Sun Jan 10 00:26:11 1999 +0000 Initialize only protocols which are compiled in :) commit b296730cb6b72ff84ba04fa58a6c7198f3a831e0 Author: Martin Mares Date: Sun Jan 10 00:25:50 1999 +0000 Few last-minute bug fixes. commit 49e7e5ee0b2848f5bf120a962e2e7eb11b86566a Author: Martin Mares Date: Sun Jan 10 00:18:32 1999 +0000 New makefiles. Includes support for out-of-source-tree builds. commit 2f9bcf9713523f6fefecd143cc2aa2a8dda7f27f Author: Martin Mares Date: Sat Jan 9 15:02:11 1999 +0000 First step of "autoconfization". Created a configure script which guesses most system-dependent parameters and determines name of system configuration file (sysdep/cf/...) with the remaining ones. To compile BIRD, you now need to do: autoconf # Create configure from configure.in ./configure # Run configure script make # Compile everything Configuration files: sysdep/config.h Master config file sysdep/autoconf.h Parameters determined by configure script sysdep/cf/*.h Fixed system configuration we're unable to guess. Makefiles are still the original ones, but this will change soon. commit 6996f459c6d8e6205bbacd83e3656b47635f7d6d Author: Pavel Machek Date: Tue Dec 22 19:41:04 1998 +0000 Bird now uses fib structure instead of linklist. commit 1d7c44b7119d30874563c9f8bbac25273ecabb57 Author: Pavel Machek Date: Tue Dec 22 19:20:43 1998 +0000 Oops, previous modification for passing NULL to fib_init() did not compile :-(. commit ce45fc128783ea7b93bd7ebd5ac4eec763adbb40 Author: Pavel Machek Date: Tue Dec 22 18:55:49 1998 +0000 Allow NULL to init_fib(). commit 852fc0af31ed885e355bb1d14ce0e4468830c359 Author: Martin Mares Date: Sun Dec 20 14:29:06 1998 +0000 log(), die() and bug() messages shound NOT contain trailing newlines. commit 08c69a7720af32a82b8e2b4b9ea3742074b3b8ee Author: Martin Mares Date: Sun Dec 20 14:27:37 1998 +0000 die() -> bug() where appropriate. commit ee969ea7f4c4f40020e4209b167da04d04aba52c Author: Martin Mares Date: Sun Dec 20 14:26:57 1998 +0000 Added #if 0 to rip_postconfig(), so that it doesn't crash whole daemon when RIP is unconfigured. die() -> bug() commit 98e87c8628f9b0a0a96bc46879b65a78b756a718 Author: Martin Mares Date: Sun Dec 20 14:24:35 1998 +0000 Finer grained logging levels: #define L_DEBUG "\001" /* Debugging messages */ #define L_INFO "\002" /* Informational messages */ #define L_WARN "\003" /* Warnings */ #define L_ERR "\004" /* Errors */ #define L_AUTH "\005" /* Authorization failed etc. */ #define L_FATAL "\006" /* Fatal errors */ #define L_TRACE "\002" /* Protocol tracing */ #define L_INFO "\003" /* Informational messages */ #define L_REMOTE "\004" /* Remote protocol errors */ #define L_WARN "\004" /* Local warnings */ #define L_ERR "\005" /* Local errors */ #define L_AUTH "\006" /* Authorization failed etc. */ #define L_FATAL "\007" /* Fatal errors */ #define L_BUG "\010" /* BIRD bugs */ Introduced bug() which is like die(), but with level L_BUG. Protocols should _never_ call die() as it should be used only during initialization and on irrecoverable catastrophic events like out of memory. Also introduced ASSERT() which behaves like normal assert(), but it calls bug() when assertion fails. When !defined(DEBUGGING), it gets ignored. commit e440395d7d3c503692321e2f6ec4e42bf758acb1 Author: Martin Mares Date: Sun Dec 20 14:01:37 1998 +0000 When printing a routing table, fib_check() it. commit 3ab001b97402bc01a4777cf1cb60ce940d50ffe3 Author: Martin Mares Date: Sun Dec 20 14:01:20 1998 +0000 Rewrote fib functions to make them insert/delete/asynchronous-walk safe. This is implemented in a way similar to lib/slists.h, but it took some more effort to make rehashing not disturb the readers. We do it by just taking _highest_ k bits of ipa_hash as our hash value and sorting each box by whole ipa_hash(). Consult FIB_ITERATE_* macros in nest/route.h. Implemented fib_check() debugging function and also rewrote the rehashing algorithm to use better thresholds and not to waste time by rehashing forth and back. commit a6f250f5c6d079badc4a1274b19a21a52de6acec Author: Martin Mares Date: Sun Dec 20 13:57:49 1998 +0000 New hash functions according to benchmarks posted yesterday. (The IPv6 version has not been benchmarked yet due to insufficient test data.) Now ipa_hash() returns a uniformely distributed 16-bit value. commit a05406e69c699c8b6f43bf58f47b8b0385113083 Author: Martin Mares Date: Sun Dec 20 13:56:27 1998 +0000 Implemented deletion/insertion/asynchronous-walk lists. For example of their use, look at comments in lib/slists.h. commit 29ad2c9ee11df80c780c4e3f0fd217783af1d727 Author: Martin Mares Date: Sat Dec 19 21:53:28 1998 +0000 Variance estimation fixed. commit 87b60bf7e8ad12b3efd3d6f37df0d029f50d2d91 Author: Martin Mares Date: Sat Dec 19 11:51:47 1998 +0000 Added several tools for fib hashing function analysis. It turned out we can use very simple function which is monotonic with respect to re-hashing: n ^= n >> 16; n ^= n << 10; h = (n >> (16 - o)) & ((1 << o) - 1); where o is table order. Statistical analysis for both backbone routing table and local OSPF routing tables gives values near theoretical optimum for uniform distribution (see ips.c for formulae). The trick is very simple: We always calculate a 16-bit hash value n and use o most significant bits (this gives us monotonity wrt. rehashing if we sort the chains by the value of n). The first shift/xor pair reduces the IP address to a 16-bit one, the second pair makes higher bits of the 16-bit value uniformly distributed even for tables containing lots of long prefixes (typical interior routing case with 24-bit or even longer prefixes). commit 02933ddbbec94f1bb01c0b9e5198fe272c1f5025 Author: Pavel Machek Date: Wed Dec 9 20:08:57 1998 +0000 debug() -> DBG() in rip. commit 06fa1453cdc419acd0c037ac82f49b4d8e77cfbd Author: Pavel Machek Date: Wed Dec 9 15:22:40 1998 +0000 Initial multicast support (can not work, but skeleton is there) commit 8e66a0ebb927f40c9fcb48bbf5f2d811d7b7c7f3 Author: Martin Mares Date: Tue Dec 8 18:37:58 1998 +0000 Hopefully finished kernel syncer (krt) rewrite: o Interface syncing is now a part of krt and it can have configurable parameters. Actually, the only one is scan rate now :) o Kernel routing table syncing is now synchronized with interface syncing (we need the most recent version of the interface list to prevent lots of routes to non-existent destinations from appearing). Instead of its own timer, we just check if it's route scan time after each iface list scan. o Syncing of device routes implemented. o CONFIG_AUTO_ROUTES should control syncing of automatic device routes. o Rewrote krt_remove_route() to really remove routes :) o Better diagnostics. o Fixed a couple of bugs. commit 980297d2899a5aec6609d1f7b44626e52e6e4417 Author: Martin Mares Date: Tue Dec 8 18:31:31 1998 +0000 Fixed a couple of bugs in static protocol. All static routes except device ones seem to work well. commit 618533af91051b7b26ac19816e89cd81352b0f13 Author: Martin Mares Date: Tue Dec 8 18:30:35 1998 +0000 Added source RTS_DUMMY for temporary routes. They should never appear in the main table. commit f39e4713c270752d7bbfcc8115a7ea7f589c3997 Author: Martin Mares Date: Tue Dec 8 16:20:13 1998 +0000 Rewritten kernel syncer. Now uses the rta trickery I've introduced yesterday and does things "the right way". Few things are still missing (device routes etc.), I'll add them later in the evening. commit 04925e9040330afc92f8001e6a19ae2146e36782 Author: Martin Mares Date: Mon Dec 7 21:59:15 1998 +0000 Minor rte/rta interface changes: o rte can now contain a pointer to both cached and uncached rta. Protocols which don't need their own attribute caching can now just fill-in a rta, link it to rte without any calls to attribute cache and call rte_update() which will replace rte->attrs by a cached copy. o In order to support this, one of previously pad bytes in struct rta now holds new attribute flags (RTAF_CACHED). If you call rte_update() with uncached rta, you _must_ clear these flags. In other cases rta_lookup() sets it appropriately. o Added rte_free() which is useful when you construct a rte and then the circumstances change and you decide not to use it for an update. (Needed for temporary rte's in kernel syncer...) commit cdc6bfa70f730c3741537cc21cdd0a5d13ed2af9 Author: Martin Mares Date: Mon Dec 7 10:16:15 1998 +0000 Comparison of kernel reject routes fixed. commit 12df4d909bdfa9e99dd0dd1b9fd690ce85b87dc5 Author: Martin Mares Date: Mon Dec 7 10:15:42 1998 +0000 KRF_* flags moved to krt.h as they are internal to kernel syncer, fib->pad0,pad1 renamed to x0,x1 and in case of struct net x0 is reserved for kernel syncing as well. commit f6bd206607d9fcad3572841813d7376bd2df4952 Author: Martin Mares Date: Sun Dec 6 23:13:31 1998 +0000 All static routes except for device ones should work and appear/disappear when their destination comes on/off link. Deserves better testing :) See example in bird.conf. commit 78d06cf2bc8ec8b9850802fc9d34afe4d1782c6c Author: Martin Mares Date: Sun Dec 6 23:11:47 1998 +0000 Removed protocol-specific data in rte for protocol static since no such data ever existed. commit 436965d25e840ef5f9614ed55181f5bf8c765d3b Author: Martin Mares Date: Sun Dec 6 23:11:18 1998 +0000 Aesthetic fix for neighbor cache debug dump. commit 89d2355d3d16ac51ad5861d91b17eaa65713f80b Author: Martin Mares Date: Sun Dec 6 23:10:45 1998 +0000 Added new rule for prefix length / netmask. commit cc12cf05c789ef85d72cf19e9b52f0c4982542f7 Author: Martin Mares Date: Sun Dec 6 23:10:28 1998 +0000 cf_error() now accepts any format strings instead of just an error message. Also added extra kludge to get rid of collisions of REJECT symbols. commit a1bf6440b5c27f7fb829eb25f6ac1c2629eb72eb Author: Martin Mares Date: Sun Dec 6 18:21:23 1998 +0000 Added skeleton of static route protocol. commit 980ffedbb04bf3beedf147fc7dfed40cdbf968aa Author: Martin Mares Date: Sun Dec 6 17:40:42 1998 +0000 Kernel syncer is now configurable. It will probably need some more options, but at least basic tuning is possible now. commit 0846203e896d8ab009217968e391b5e13ea3c4c6 Author: Martin Mares Date: Sun Dec 6 17:39:08 1998 +0000 Fixed bug in CF_ADDTO. How it's possible it has ever worked? commit 166b9c4912f1a52d7910c630280cf5a076eb1990 Author: Martin Mares Date: Sun Dec 6 17:38:42 1998 +0000 Added rule "bool" for boolean switches. commit b35d72ac668c52ef0755cedba89bdca54bd995ac Author: Martin Mares Date: Sun Dec 6 11:59:18 1998 +0000 Name cleanups as suggested by Pavel: - cfg_strcpy() -> cfg_strdup() - mempool -> linpool, mp_* -> lp_* [to avoid confusion with memblock, mb_*] Anyway, it might be better to stop ranting about names and do some *real* work. commit 2d9290e973b9cfc909057a0409152e020d1c29db Author: Pavel Machek Date: Fri Dec 4 11:45:51 1998 +0000 Rip now has configurable per-interface metric (please rewiev), and few more configurable parameters. To do that, union was added into iface_patt. commit 9b999c393c6f89a73d5fe0f4e152b77ca0afb1b2 Author: Pavel Machek Date: Tue Dec 1 16:17:10 1998 +0000 Infinity is now configurable ammount. commit 50d8424ad1f40f9979214c1d6cbf8e290ba9a5cb Author: Martin Mares Date: Sun Nov 29 22:03:58 1998 +0000 Added configuration of the device internal protocol. This is primarily intended to serve as an example of interface pattern list use. As a side effect, you can disable generating of device routes by disabling this protocol. commit 66efdf962a343c7cf5aef475f35f9e3864cb4fdd Author: Martin Mares Date: Sun Nov 29 22:01:33 1998 +0000 Handle disabled protocol instances. commit ed45f2e126680c7197be2058f9c162f1d5019eeb Author: Martin Mares Date: Sun Nov 29 22:01:03 1998 +0000 Added functions for manipulating interface name pattern lists: o iface_patt_match(list, iface) -- match interface against list o iface_patts_equal(a, b, c) -- compare whether two pattern lists are equal or not. c(x,y) is called for comparison of protocol-dependent data. commit 49e4a4d1fd64da045182f6ccd38753feb364f9c5 Author: Martin Mares Date: Sun Nov 29 21:59:37 1998 +0000 Created new functions for allocating configuration data: o cfg_alloc(size) -- generic memory allocation o cfg_allocu(size) -- unaligned memory allocation o cfg_allocz(size) -- zeroed memory allocation o cfg_strcpy(str) -- allocate a copy of a string Also fixed a bug in lexing of string literals. commit 5cd462f291b45a6a33168cdfbc4ba55ee068af65 Author: Martin Mares Date: Sun Nov 29 14:51:47 1998 +0000 `wc -l TODO` decreased. commit dee929d86844b1956b1c0f1d2c0289a787ab9226 Author: Martin Mares Date: Sun Nov 29 14:47:24 1998 +0000 Added function for shell-like pattern matching. Will be used for matching interface names in protocol-to-iface bindings. commit bd5d0d62f10c65d56e1900014be5989a3feb8380 Author: Martin Mares Date: Sun Nov 29 14:40:39 1998 +0000 Allow setting debug value and `disabled' flag in protocol definition. commit 0cf86f0fc34c7daf020a9189279644af89e273a1 Author: Martin Mares Date: Sun Nov 29 14:38:34 1998 +0000 Renamed `DEBUG' symbol to `DEBUGGING' to prevent collisions with token names and include files. commit 7af99789c78894fa2c7ffce3d7172d6a46c1c0e3 Author: Martin Mares Date: Fri Nov 27 21:34:03 1998 +0000 Oops, forgot to remove a debugging kludge. commit 0b62c3a7c7548cd447b4f18e0346cc9e74862ab3 Author: Martin Mares Date: Fri Nov 27 21:32:45 1998 +0000 Trivial 15-line bison excercise: Implemented expressions including user-defined numeric symbols. Whenever possible, use `expr' instead of `NUM' to get full express ion power :-) commit c74c0e3cdf008988a8873d3f76c0d71b29ab8673 Author: Martin Mares Date: Fri Nov 27 21:09:57 1998 +0000 First attempt at protocol configuration (now done only for RIP). commit 93fb60d54ca7ce3efec1cc0b39fb0840d055ccd1 Author: Martin Mares Date: Fri Nov 27 21:08:37 1998 +0000 Fixed few misspellings and exported instance init as rip_init_instance(). commit 8450be97d6ffb052fce95292d39c3f67afbcdc1c Author: Martin Mares Date: Fri Nov 27 21:07:02 1998 +0000 Added generator of default names. commit 906b0170a41cc0d8ea11c7bae0a9fea3d18fe6d1 Author: Martin Mares Date: Fri Nov 27 19:39:16 1998 +0000 Experimental config file. commit b4712244a0fb49b32dc58d28523f122d8ed2cae8 Author: Martin Mares Date: Fri Nov 27 19:38:30 1998 +0000 Dummy grammar for RIP configuration. Now empty, but must be here since it's referenced in the makefiles. commit da87782278cdb38a90f5236fbbc4928c9ca2ee15 Author: Martin Mares Date: Fri Nov 27 19:37:57 1998 +0000 Parser fragment for the core. Now handles only router ID setting. commit 70591fa06481e7935dcf66ec79812c470c71f4c8 Author: Martin Mares Date: Fri Nov 27 19:37:07 1998 +0000 Compile and use the new configuration code by default. commit f142750d3420d482d7e9344c71777fdd37754114 Author: Martin Mares Date: Fri Nov 27 19:36:06 1998 +0000 Base of the parser. commit 82fc7be7bbb9af40d0abf8477f7af25e1423da1a Author: Martin Mares Date: Fri Nov 27 19:35:50 1998 +0000 Lexical analyser. commit fe7cec12e8589b7d6af6033cb80804fbcbe7c0b8 Author: Martin Mares Date: Fri Nov 27 19:35:10 1998 +0000 Replaced nest/confile.h by conf/conf.h, added a lot of new definitions. commit ce6ca80926c0ce87c9a08ea4f4236b1a95846086 Author: Martin Mares Date: Fri Nov 27 19:33:53 1998 +0000 This script takes configuration fragments and generates full Bison grammar from them. commit 882c588a4060739a4820941cd1c6014bd10ab0db Author: Martin Mares Date: Fri Nov 27 19:33:26 1998 +0000 This script takes configuration fragments and extracts keyword list from them. commit d2ed2579fa365fa36b7882ef847b9e640290c05e Author: Martin Mares Date: Fri Nov 27 19:31:41 1998 +0000 Now merges configuration fragments (*.Y) as well. commit dfeef5d8bb9fe19cb44d4121fd8324179a38b7a0 Author: Martin Mares Date: Fri Nov 27 19:29:27 1998 +0000 Implemented ip_pton() commit a3afae585af9a544f919a95509107aae33fbe53c Author: Martin Mares Date: Fri Nov 27 19:29:00 1998 +0000 Removed prototype of rp_free() since this function has never existed. commit 3cef8c706ccfbc17d8af6aed7820c9231d908214 Author: Martin Mares Date: Fri Nov 27 19:28:29 1998 +0000 Added path to config file. commit 4254dc45e77b4c2d45178c7a5ce1e9bff19b8bf7 Author: Martin Mares Date: Sat Nov 21 10:25:34 1998 +0000 Killed bug in processing of 'h' prefix. Patch taken from linux-2.1.129. commit 9158ca99f740d5b1b50d233e0f64e61504dc6fdf Author: Martin Mares Date: Mon Nov 16 21:41:21 1998 +0000 Complain loudly if the logging buffer would overflow. commit 53a416d376a16b2091dce898a16600b0cd27c348 Author: Martin Mares Date: Mon Nov 16 21:40:35 1998 +0000 Implemented snprintf and similar functions. It took a lot of thinking, but the modifications were relatively simple and straightforward. commit c3e9b2ab2448bce4a6fe6a5be9c8de8beecc8e17 Author: Pavel Machek Date: Mon Oct 26 15:35:19 1998 +0000 RIP now includes notion of interface, and is correctly talking to itself on second host. Split horizont is broken. commit dafd580ed94f38c95a84d8d00d3a57c7c194d6db Author: Martin Mares Date: Mon Oct 26 15:24:32 1998 +0000 Previous fix was wrong. commit db6984c43c47bfb549394f6571f024df301b19ee Author: Martin Mares Date: Mon Oct 26 15:01:04 1998 +0000 rte_update: Doesn't loop forever when multiple routes point to the same destination. commit dc7c7494e372febc44ae7d1f4ed618a6fe8bf45e Author: Pavel Machek Date: Tue Oct 20 16:45:53 1998 +0000 RIP _NOW_ actually talks to itself (workaround core bug: send data from other port than we receive at), few FIXME's added. commit 756b86dea31f2b94b1fbc1d95098f1a177b2817e Author: Martin Mares Date: Tue Oct 20 16:39:04 1998 +0000 Learn static device routes from the kernel (temporary until we can make such things configurable). commit feb6abe009aa13b3cd0ce22e6333163fb7561c16 Author: Pavel Machek Date: Tue Oct 20 16:12:43 1998 +0000 RIP now actually talks to itself. commit 8ca8683c705c76dc155521204ef098e6fe547696 Author: Martin Mares Date: Tue Oct 20 15:47:02 1998 +0000 Beware the NULL route, my son... The bugs that bite, the BIRDs that crash :-) commit acc62f5e1d4a100ec0be5c73e928a041aa9a4f9d Author: Martin Mares Date: Tue Oct 20 15:17:38 1998 +0000 Insert/remove hooks return void, not int. commit a0762910a62085d875b5bf5e1494c4fdde6f603f Author: Martin Mares Date: Tue Oct 20 15:13:18 1998 +0000 Added pointer to network to RTE. The complications with passing NET separately aren't worth 4 bytes per RTE. rte_discard and rte_dump don't need net * as parameter. commit b6903c948b2325f11cfb07f2df0590708920b987 Author: Martin Mares Date: Mon Oct 19 18:18:12 1998 +0000 Updated TODO. commit 7d8329078066b5682a0330b20dbdf74c7a01cbac Author: Martin Mares Date: Mon Oct 19 18:13:36 1998 +0000 Generate router_id automatically if possible (standard "smallest of local regular interface addresses" rule). Protocols should NOT rely on router_id existence -- when router ID is not available, the router_id variable is set to zero and protocols requiring valid router ID should just refuse to start, reporting such error to the log. commit 08045252553478457f923a9f941675df9992f507 Author: Martin Mares Date: Mon Oct 19 17:52:29 1998 +0000 Basic kernel routing table syncing implemented. Learning of routes installed by other programs or the kernel itself is not supported yet, but it's not needed for development of other protocols. commit 567e6c62208d3bb05b58b8ed08c2be29d6542f2b Author: Martin Mares Date: Mon Oct 19 17:48:45 1998 +0000 Use (SOCK_DGRAM,IPPROTO_IP) socket instead of (SOCK_STREAM,IPPROTO_TCP). This is exactly what Linux ifconfig does and seems to be the preferred way. commit 4cf45766bac4b1e3f5196f7e36d012cb7c010dc1 Author: Martin Mares Date: Mon Oct 19 17:47:50 1998 +0000 Exporting fill_in_sockaddr() for use by other unix-dependent code. commit 36f2caf147fb80e2b3db59d367e07f5d143f3710 Author: Martin Mares Date: Mon Oct 19 17:46:45 1998 +0000 Fixed generation of device routes for unnumbered point-to-point links. commit f184ea6f7e1233403d06fa4615cb9f27f9d9a839 Author: Martin Mares Date: Mon Oct 19 17:45:29 1998 +0000 Proto struct now contain (down | starting | up) state. commit 16a8ba30a97d82f8e43385d1a9b116fdb16746a8 Author: Martin Mares Date: Sun Oct 18 22:25:56 1998 +0000 We parse /proc/net/route and flag RT entries according to it. More to come today in the morning... commit 4c45595e3bb9f0b605e3102742831dad8915b309 Author: Martin Mares Date: Sun Oct 18 22:24:41 1998 +0000 o FIB flags now available for FIB users. o struct network: FIB flags used for kernel syncing. o struct network: `next' field deleted (historical relic). commit ab3a76a382745e0195b213c6d87ddc0e3cabd690 Author: Martin Mares Date: Sun Oct 18 22:22:28 1998 +0000 Added ipa_from_u32 and ipa_from_u32 for use in the kernel sync code (IPv4 only). Don't ever think of using it in routing protocols. commit 7e7790c61f14dff300d7c5464fdd47e4c15a0731 Author: Martin Mares Date: Sun Oct 18 12:50:43 1998 +0000 Since almost every UNIX system requires different techniques for reading the kernel routing table as opposed to modifying it which is approximately the same on non-netlink systems, I've split the kernel routing table routines to read and write parts. To be implemented later ;-) commit 8b1688177b2b3c6a3740f792997f3057b9bff0da Author: Martin Mares Date: Sun Oct 18 12:48:15 1998 +0000 * Please distinguish between DGB() and debug(). commit 3629bcf0c7ff8ccc56baabc4769f90635d1a7864 Author: Martin Mares Date: Sun Oct 18 12:26:02 1998 +0000 Preconfig, postconfig and init hooks can be NULL. commit 0432c0173bb4d234e8ba8e4afea0a8e708e119d8 Author: Martin Mares Date: Sun Oct 18 11:53:21 1998 +0000 Split protocol init to building of protocol list and real protocol init. Added kernel route table syncer skeleton. commit 05e56feb57b8e313a2328dbe82e2c2a70ff5115a Author: Martin Mares Date: Sun Oct 18 11:50:36 1998 +0000 Removed global pointer to proto_dev. commit 5b22683d2f27fcc5954cc9d4d58e55e539414d53 Author: Martin Mares Date: Sun Oct 18 11:13:16 1998 +0000 After contemplating about RIP route timeouts for a long time, I've implemented protocol callbacks for route insertion and deletion from the central table. RIP should maintain its own per-protocol queue of existing routes, scan it periodically and call rte_discard() for routes that have timed out. commit 570ce189d77fc40841e8e9f8f86ea3c3840aa450 Author: Martin Mares Date: Sun Oct 18 10:49:46 1998 +0000 Implemented `route last modified' time. commit 2a900b1b1565d778f19c10b087aea558f067bba7 Author: Martin Mares Date: Sat Oct 17 11:26:28 1998 +0000 Fixed misleading comment. commit 7f3d198df118dc218bb2049f1cc0597ec62864bc Author: Martin Mares Date: Sat Oct 17 11:24:13 1998 +0000 Each protocol now hears even its own routes and needs to make its own loop detection. This is needed since both RIP and OSPF handle multiple neighbors and they need to redistribute routes learned from each neighbor to the remaining ones. commit 47b793064c25c8adcab48cacc018be1675f2448a Author: Martin Mares Date: Sat Oct 17 11:05:18 1998 +0000 Solve chicken-and-egg problems with protocol startup. We now queue all inactive protocols and don't send route/interface updates to them and when they come up, we resend the whole route/interface tables privately. Removed the "scan interface list after protocol start" work-around. commit d92882be9b1bfcc1a8e8a7bd552bdec4831694aa Author: Martin Mares Date: Sat Oct 17 11:02:39 1998 +0000 WALK_LIST_DELSAFE now actually works (it really couldn't since it didn't reference list head at all). commit c05ea56f8eb15dfe3c9d18496deaa926e0cf8aac Author: Pavel Machek Date: Sat Oct 17 10:25:22 1998 +0000 rip should now correctly listen, but entries will not time out. commit 8333431c4d0d7dcf065938e21440b4ce20cb8f8f Author: Pavel Machek Date: Thu Oct 15 15:12:24 1998 +0000 Rip: rip_rta_same added. commit 93f1c532e99cddb5575075313c0707bcd4758f07 Author: Martin Mares Date: Wed Oct 14 13:38:17 1998 +0000 Moved scanning of interfaces, so that they get initialized after all routing protocol instances. commit cf3934c5691ec4a00d54b863576916f9a1dd1f1a Author: Pavel Machek Date: Wed Oct 14 13:27:53 1998 +0000 Lists: unneccessary test killed, make code friendly to non-gcc. commit c93214d442644c9667d69f904d57aef6b4ddd47e Author: Martin Mares Date: Tue Oct 13 19:57:33 1998 +0000 o There are cases when SIOCGIFINDEX is defined, but it doesn't work. When this happens, don't reject the whole interface, just mark it as index 0. o Removed Pavel's comment about EFAULT and SIGSEGV. EFAULT is a valid return code for cases where the buffer is too small. o Commented out the smart interface list size logic temporarily as it seems Linux 2.0 SIOCGIFCONF doesn't react to ifc_req==NULL sanely. Replaced it by exponential stepping. commit fdf33cde1cd14a2a0215d6d459489e258fe20789 Author: Pavel Machek Date: Tue Oct 13 14:59:46 1998 +0000 Strange, on atrey ioctl() does not fill structure, and bird segfaults on it. Now we "only" die(). commit 21580e304f612b276a90d2a90f4fb86569609255 Author: Pavel Machek Date: Tue Oct 13 14:32:18 1998 +0000 I prefer to have broken drivers than completely stupid ones... Linus Torvalds Rip now uses main routing table properly: entries are stored directly into main routing table and we are relying on core to call our's compare. That unfortunately broke garbage collecting (and probably many more things). It compiles. commit 1d941de47a90fb9ca39d7acf6aa396447d1fc7df Author: Pavel Machek Date: Wed Oct 7 19:33:50 1998 +0000 RIP now somehow listens to main routing table (dont expect it to work) commit 8c43696da0c0680820aa949da35e823e68162788 Author: Martin Mares Date: Mon Aug 31 21:13:42 1998 +0000 Route update hook now gets network prefix as well as updated route attributes. commit bf65d27deaa0bacd801ec06a3257dda03a53fee2 Author: Pavel Machek Date: Thu Jul 30 07:43:45 1998 +0000 Bird's info are now understood by ripquery. commit 279f4c7b7b2ebe13793649f191040042a8c4c014 Author: Pavel Machek Date: Tue Jul 28 21:44:11 1998 +0000 Rip now includes code to reply, but it is currently broken. commit 48b41d58112737f87f1217414291e61f5430f611 Author: Pavel Machek Date: Tue Jul 28 21:42:08 1998 +0000 Do not segfault on iface == NULL. commit a872b0f7dae38cfef574d0d3b30609e968cdf95b Author: Pavel Machek Date: Mon Jul 20 20:05:40 1998 +0000 Reversed buggy patch. commit c25e90efed6bc76d05370403839640ed05017506 Author: Martin Mares Date: Wed Jul 15 19:42:23 1998 +0000 Added comment explaining `now'. commit 1be52eea5777f082b02e0f484620e692017b16a2 Author: Martin Mares Date: Fri Jul 10 08:39:34 1998 +0000 Removed format specification attributes for log() and debug() until GCC is fixed to handle custom formats. commit 786d0bb9e7c5db5104e3fd0ff7fdfbd1e19844ea Author: Martin Mares Date: Fri Jul 10 08:38:29 1998 +0000 Added ipa_class_mask() which guesses netmask for classful addressing. For pure A/B/C class addresses it just returns the class netmask, for subnets it tries to guess subnet mask. Please make sure the address you pass to this function is really a valid host address (i.e., call ipa_validate() first). commit 28a9a189d71ef3b05daa21d60277149edb8e98ad Author: Martin Mares Date: Fri Jul 10 08:32:18 1998 +0000 Replaced remaining references of clock_t by bird_clock_t. commit a103373f6147f27e4ac71e5903563e57ce52902c Author: Pavel Machek Date: Thu Jul 9 19:39:04 1998 +0000 Commiting RIP. RIP should somehow listen, will not reply. I needed to commit it so that whole thing compiles. commit 86b0023033a25cdc6ab5480e03893f516184a2a5 Author: Pavel Machek Date: Thu Jul 9 19:37:39 1998 +0000 Making SIGUSR1 dump also all protocols. commit 87d2be86e5f8af0e2f01e7fb711bd282e29e376b Author: Pavel Machek Date: Thu Jul 9 19:36:52 1998 +0000 Adding proto_dump_all() function commit cf3527e2f4f1f4009fa332e6284b8904c24d0d43 Author: Pavel Machek Date: Thu Jul 9 19:36:05 1998 +0000 Adding MIN()/MAX() macros commit aea2dcabdc4ed80172ac8d4f5c4d31bc8607d1e7 Author: Pavel Machek Date: Thu Jul 9 19:35:23 1998 +0000 Adding walk list which permits you to delete entries. commit 962ba482fd7bba97cf13a96105503efff4dcb88a Author: Martin Mares Date: Wed Jun 17 14:36:02 1998 +0000 Use '%I' instead of dirty address printing hacks. commit d997534f65903e8078efe2f8ceb19941692598f7 Author: Martin Mares Date: Wed Jun 17 14:34:13 1998 +0000 Oops, forgot '%m'... commit 9556f225853748d5fee9a21e179b8fd5da2d3c42 Author: Martin Mares Date: Wed Jun 17 14:33:29 1998 +0000 debug() and log() use the new printf. Feel free to use new formatting sequences for all output. commit ecacdfa434acf8af38ed8c1c0c8e71dab400b0f4 Author: Martin Mares Date: Wed Jun 17 14:31:36 1998 +0000 Added local version of sprintf (bsprintf and bvsprintf) offering few new format strings: %I IP address %#I IP address in hexadecimal %1I IP address padded to full length %m strerror(errno) commit 97d858c590998786d4d8a16b5c1f657800d74736 Author: Martin Mares Date: Wed Jun 17 14:28:46 1998 +0000 ip_ntop() and ip_ntox() for IPv4. commit 6b5e06abb57528a091fd171dff379634fa7c4dad Author: Martin Mares Date: Wed Jun 17 14:26:30 1998 +0000 Added function for converting of IP addresses to printable form. commit 620a355a15d65a8a2980f98b2de3e7d04c3dab62 Author: Martin Mares Date: Thu Jun 4 20:30:11 1998 +0000 Now sending IF_CHANGE_CREATE when a new interface appears and IF_CHANGE_UP only if it's really up. commit 236d4eb8ce5dc894e97bcf1f561186d41c361cea Author: Martin Mares Date: Thu Jun 4 20:29:44 1998 +0000 FIB_WALK and friends are now slightly more friendly. commit 66e53309acceb0fd7e56faf54e1cc733a5477c67 Author: Martin Mares Date: Thu Jun 4 20:29:05 1998 +0000 Dumping of _static_ attributes implemented. commit b1e4f81485c15bacfff6040a1295bee31479a875 Author: Martin Mares Date: Thu Jun 4 20:28:43 1998 +0000 We have full interface routes now. commit 0cdbd3975a1ebc5e6705d23ed90388269c24b42e Author: Martin Mares Date: Thu Jun 4 20:28:19 1998 +0000 Handle route deletion without segfaults. A bit more debug dumps. commit 5331da6a4d0c77e70d134fa40b5061b00ab593b0 Author: Martin Mares Date: Thu Jun 4 20:27:49 1998 +0000 Fixed processing of timers. commit fd50083df499dd7aa4dd3eec97171003da300250 Author: Martin Mares Date: Wed Jun 3 08:43:44 1998 +0000 Killed socket debug code. Initialize config pool and protocols. More to come later... commit c5ffa447598bc24cf1b674553bc4d3cc80a831d1 Author: Martin Mares Date: Wed Jun 3 08:42:16 1998 +0000 Skeleton of device route protocol. As it's tightly coupled with our kernel, it sits here instead of `proto/dev'. commit d9f330c5ffe03c05b7e6541a06adac657f24407b Author: Martin Mares Date: Wed Jun 3 08:40:10 1998 +0000 Protocol hooks. All of them may be NULL. commit 7f4a39886c128bfc2e39987180eb1482ee04d553 Author: Martin Mares Date: Wed Jun 3 08:38:53 1998 +0000 Basic protocol operations. commit a5f1a60e0254871c3285aabde372f5a6790c19c3 Author: Martin Mares Date: Wed Jun 3 08:38:06 1998 +0000 Changed protocol declarations a bit. commit 33beab4f6c7904204a5116b4eb4cbed5f859f24a Author: Martin Mares Date: Wed Jun 3 08:36:34 1998 +0000 Added configuration pool. commit c5fd704e48333fb8e690d78a3be1303f6c2638c7 Author: Martin Mares Date: Wed Jun 3 08:35:40 1998 +0000 Protocols will reside in directory `proto'. commit 869c695998f0bc3b80d8500d88a53fb169c21bc1 Author: Martin Mares Date: Mon Jun 1 21:41:32 1998 +0000 Synced to new interface code. commit 4cc78c5082344f0d237a5cdfb05e53dfd04ffd8b Author: Martin Mares Date: Mon Jun 1 21:41:11 1998 +0000 - Rewrote whole interface logic. Removed support for multiple addresses per interface since it makes much trouble everywhere. Instead, we understand secondary addresses as subinterfaces. - In case interface addresses or basic flags change, we simply convert it to a down/up sequence. - Implemented the universal neighbour cache. (Just forget what did previous includes say of neighbour caching, this one is brand new.) commit 0fe3b28b68f10a32f3fe43e8221559a72be5ca28 Author: Martin Mares Date: Mon Jun 1 21:36:58 1998 +0000 Added ipa_xor() and ipa_in_net(). commit af847acc27978cf48721aafbacab70e48f42ede7 Author: Martin Mares Date: Tue May 26 21:46:38 1998 +0000 Whee, multicast sockets work! Implemented recurrent timers. commit 140f03410500420a4b44e62a98896a29c99a2b00 Author: Martin Mares Date: Tue May 26 21:44:54 1998 +0000 Added CONFIG_AUTO_ROUTES (automatic device route creation) and CONFIG_ALL_MULTICAST (all interfaces capable of multicasting, not depending on IFF_MULTICAST flag). commit fe82105e5dc2077c16da802f721160443e0c6fc2 Author: Martin Mares Date: Tue May 26 21:43:45 1998 +0000 Debug messages. commit 8a48ecb8b15e827f779d4b9fb080dff280b99872 Author: Martin Mares Date: Tue May 26 21:42:05 1998 +0000 Implemented scanning of network interfaces. Mostly very ugly code due to terrible kernel interface (SIOGIFCONF and friends). commit b1487ee909ebd4cfc59f30d3678cb6667d4a72c8 Author: Martin Mares Date: Tue May 26 21:38:06 1998 +0000 Added generic functions for unaligned data access. commit ed68a5c6a4da7050995934adb07612dea1cf6644 Author: Martin Mares Date: Tue May 26 21:37:37 1998 +0000 Resource pools are now named. commit d5417b379f05541418fb4f1ac87100ba8106b0c6 Author: Martin Mares Date: Tue May 26 21:36:48 1998 +0000 Added ipa_opposite(). commit 5222c46ceb8035f2292c3a91f6ee85fbbed82c5e Author: Martin Mares Date: Tue May 26 21:36:17 1998 +0000 DBG now calls debug() instead of sending it to log(). commit d804db0dabf944495071fe6b62a9d836f78997af Author: Martin Mares Date: Sun May 24 15:00:48 1998 +0000 Added few socket declarations. commit b5d9ee5c878b41ffbc138be171d700992e9d78c7 Author: Martin Mares Date: Sun May 24 14:50:18 1998 +0000 Added UNIX implementation of both timers and sockets. Timers should work, sockets were tested only in TCP mode. main.c now contains some test cases for socket code. commit 6d45cf21be3f979ba4e8a1a5f557663618fadfb3 Author: Martin Mares Date: Sun May 24 14:49:14 1998 +0000 Added debug dump function, but it's still empty :( commit ded3ee6dddae06c1cabc3a2d34e3139eb0eb338f Author: Martin Mares Date: Sun May 24 14:48:52 1998 +0000 protos_init, not proto_init. commit b53499cdaa21994f5d92afed23fdf85c2b7fe134 Author: Martin Mares Date: Sun May 24 14:48:09 1998 +0000 Added interface index (used only by OS-dependent code since ifindexes itself are OS-dependent). commit d4bc8dc00037e868771fb259a1e7b9ae5e92ed5a Author: Martin Mares Date: Sun May 24 14:46:20 1998 +0000 Staticized some variables and functions. commit 315aba32b3c5744a040331d653218d15a55455a5 Author: Martin Mares Date: Sun May 24 14:44:25 1998 +0000 Fixed path to includes. commit a2ccbb0b97c1eac3a68f01b7786822a66aaaefa2 Author: Martin Mares Date: Sun May 24 14:40:29 1998 +0000 Implemented timers. Using bird_clock_t for absolute time from now... commit 235562ca5ac1db2e2ea026bff42c8c2a898b44db Author: Martin Mares Date: Sun May 24 09:20:59 1998 +0000 Point-to-point links: added address of the opposite end. commit 480effedac0ae45a4f01ce32bac962db08ba5a3d Author: Martin Mares Date: Sun May 24 09:19:26 1998 +0000 Added declarations of all our socket functions. commit 2326b001d6f28e69b88c3c19795d8c0999f07db1 Author: Martin Mares Date: Wed May 20 11:54:33 1998 +0000 Added routing table and routing attribute code. commit 3994080eb1a86f085498bee1f36cbdb52b30191d Author: Martin Mares Date: Fri May 15 13:43:59 1998 +0000 Fixed path to includes. commit 25697773b529d80278679978b7416ca9c87e15e9 Author: Martin Mares Date: Fri May 15 07:56:13 1998 +0000 The library is now glued together from generic and OS-dependent parts by the `mergedirs' script. Few more IP address manipulation functions and some fixes. commit 62aa008abd627c6862310daf65ffd337a920bdbb Author: Martin Mares Date: Fri May 15 07:54:32 1998 +0000 Parts of routing table code. Data structure declarations should be complete now. commit 18c8241a91bd9208879666f1a1a13f454e66d75b Author: Martin Mares Date: Sun May 3 16:43:39 1998 +0000 BIRD library: The story continues. Complete resource manages and IP address handling. commit a8b6038225d18155883e330c96b2bc2e44153e1e Author: Martin Mares Date: Sun May 3 16:42:45 1998 +0000 Next attempt on data structures... commit 6032aa6ade49545d7c8b6025cf6e6373eb7c910c Author: Martin Mares Date: Sun May 3 16:42:08 1998 +0000 Added new subdir for UNIX-dependent files. Now contains only functions for logging, but it will change soon. commit 1feea03e7463d8eaeb00d5df6c2cd3e8e20f2bcd Author: Martin Mares Date: Tue Apr 28 14:39:34 1998 +0000 Changed #include to #include "x/y" for our local includes, so that gcc -MM can be used to separate them from the system ones. Added automatic generation of dependencies. commit c40e05a0dffa33a8724e56121a2b6dcdfa9183e0 Author: Martin Mares Date: Thu Apr 23 14:01:15 1998 +0000 Added IP address manipulation macros, interface declarations and logging. commit 481f69854a788bd2bea5c6938e038ec6e21c491b Author: Martin Mares Date: Thu Apr 23 08:09:39 1998 +0000 Added few route attributes. commit 58ef912c6babf1866193ab04674a5866dd761f13 Author: Martin Mares Date: Wed Apr 22 12:58:34 1998 +0000 First look at data structures. More to come tomorrow... commit b60f7489148d021cb541414b8788f795ec4378fa Author: Martin Mares Date: Fri Mar 20 18:30:55 1998 +0000 Added banner presented to KSVI. bird-2.0.8/configure0000775000175000017500000057451414025754400013305 0ustar feelafeela#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69e. # # # Copyright (C) 1992-1996, 1998-2017, 2020 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="as_nop=: if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ) then : else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 blah=\$(echo \$(echo blah)) test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null then : as_have_required=yes else $as_nop as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null then : else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$as_shell as_have_required=yes if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null then : break 2 fi fi done;; esac as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop if { test -f "$SHELL" || test -f "$SHELL.exe"; } && as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null then : CONFIG_SHELL=$SHELL as_have_required=yes fi fi if test "x$CONFIG_SHELL" != x then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno then : printf "%s\n" "$0: This script requires a shell more modern than all" printf "%s\n" "$0: the shells that I found on your system." if test ${ZSH_VERSION+y} ; then printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_nop # --------- # Do nothing but, unlike ":", preserve the value of $?. as_fn_nop () { return $? } as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='' PACKAGE_TARNAME='' PACKAGE_VERSION='' PACKAGE_STRING='' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="conf/confbase.Y" # Factoring default headers for most tests. ac_includes_default="\ #include #include #include #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_header_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS CLIENT_LIBS CLIENT protocols DAEMON_LIBS iproutedir sysdep_dirs BISONFLAGS M4FLAGS RANLIB INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM CPP host_os host_vendor host_cpu host build_os build_vendor build_cpu build OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC CONTROL_SOCKET CONFIG_FILE srcdir exedir objdir M4 BISON FLEX target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_client enable_debug enable_debug_generated enable_debug_expensive enable_memcheck enable_pthreads enable_libssh enable_mpls_kernel with_protocols with_sysconfig with_runtimedir with_iproutedir ' ac_precious_vars='build_alias host_alias target_alias FLEX BISON M4 CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-client enable building of BIRD client [yes] --enable-debug enable internal debugging routines [no] --enable-debug-generated enable this to abstain from generating #line [no] --enable-debug-expensive enable expensive consistency checks (implies --enable-debug) [no] --enable-memcheck check memory allocations when debugging [yes] --enable-pthreads enable POSIX threads support [try] --enable-libssh enable LibSSH support in RPKI [try] --enable-mpls-kernel enable MPLS support in kernel protocol [try] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-protocols=LIST include specified routing protocols [all] --with-sysconfig=FILE use specified BIRD system configuration file --with-runtimedir=PATH run-state data, obsolete variant of --runstatedir --with-iproutedir=PATH path to iproute2 config files [/etc/iproute2] Some influential environment variables: FLEX location of the Flex program BISON location of the Bison program M4 location of the M4 program CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for configure.gnu first; this name is used for a wrapper for # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.69e Copyright (C) 2020 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 printf %s "checking for $2... " >&6; } if eval test \${$3+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$3=yes" else $as_nop eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including # INCLUDES, setting cache variable VAR accordingly. ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 printf %s "checking for $2.$3... " >&6; } if eval test \${$4+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main (void) { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : eval "$4=yes" else $as_nop eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$4 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member # ac_fn_c_try_run LINENO # ---------------------- # Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that # executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } then : ac_retval=0 else $as_nop printf "%s\n" "$as_me: program exited with status $ac_status" >&5 printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run ac_configure_args_raw= for ac_arg do case $ac_arg in *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_configure_args_raw " '$ac_arg'" done case $ac_configure_args_raw in *$as_nl*) ac_safe_unquote= ;; *) ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. ac_unsafe_a="$ac_unsafe_z#~" ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; esac cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.69e. Invocation command line was $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Sanitize IFS. IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && printf "%s\n" "$as_me: caught signal $ac_signal" printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi for ac_site_file in $ac_site_files do case $ac_site_file in #( */*) : ;; #( *) : ac_site_file=./$ac_site_file ;; esac if test -f "$ac_site_file" && test -r "$ac_site_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" as_fn_append ac_header_c_list " alloca.h alloca_h HAVE_ALLOCA_H" as_fn_append ac_header_c_list " syslog.h syslog_h HAVE_SYSLOG_H" # Auxiliary files required by this configure script. ac_aux_files="install-sh config.guess config.sub" # Locations in which to look for auxiliary files. ac_aux_dir_candidates="${srcdir}/tools" # Search for a directory containing all of the required auxiliary files, # $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. # If we don't find one directory that contains all the files we need, # we report the set of missing files from the *first* directory in # $ac_aux_dir_candidates and give up. ac_missing_aux_files="" ac_first_candidate=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in $ac_aux_dir_candidates do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac as_found=: printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 ac_aux_dir_found=yes ac_install_sh= for ac_aux in $ac_aux_files do # As a special case, if "install-sh" is required, that requirement # can be satisfied by any of "install-sh", "install.sh", or "shtool", # and $ac_install_sh is set appropriately for whichever one is found. if test x"$ac_aux" = x"install-sh" then if test -f "${as_dir}install-sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 ac_install_sh="${as_dir}install-sh -c" elif test -f "${as_dir}install.sh"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 ac_install_sh="${as_dir}install.sh -c" elif test -f "${as_dir}shtool"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 ac_install_sh="${as_dir}shtool install -c" else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} install-sh" else break fi fi else if test -f "${as_dir}${ac_aux}"; then printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 else ac_aux_dir_found=no if $ac_first_candidate; then ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" else break fi fi fi done if test "$ac_aux_dir_found" = yes; then ac_aux_dir="$as_dir" break fi ac_first_candidate=false as_found=false done IFS=$as_save_IFS if $as_found then : else $as_nop as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. if test -f "${ac_aux_dir}config.guess"; then ac_config_guess="$SHELL ${ac_aux_dir}config.guess" fi if test -f "${ac_aux_dir}config.sub"; then ac_config_sub="$SHELL ${ac_aux_dir}config.sub" fi if test -f "$ac_aux_dir/configure"; then ac_configure="$SHELL ${ac_aux_dir}configure" fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --enable-client was given. if test ${enable_client+y} then : enableval=$enable_client; else $as_nop enable_client=yes fi # Check whether --enable-debug was given. if test ${enable_debug+y} then : enableval=$enable_debug; else $as_nop enable_debug=no fi # Check whether --enable-debug-generated was given. if test ${enable_debug_generated+y} then : enableval=$enable_debug_generated; else $as_nop enable_debug_generated=no fi # Check whether --enable-debug-expensive was given. if test ${enable_debug_expensive+y} then : enableval=$enable_debug_expensive; else $as_nop enable_debug_expensive=no fi # Check whether --enable-memcheck was given. if test ${enable_memcheck+y} then : enableval=$enable_memcheck; else $as_nop enable_memcheck=yes fi # Check whether --enable-pthreads was given. if test ${enable_pthreads+y} then : enableval=$enable_pthreads; else $as_nop enable_pthreads=try fi # Check whether --enable-libssh was given. if test ${enable_libssh+y} then : enableval=$enable_libssh; else $as_nop enable_libssh=try fi # Check whether --enable-mpls-kernel was given. if test ${enable_mpls_kernel+y} then : enableval=$enable_mpls_kernel; else $as_nop enable_mpls_kernel=try fi # Check whether --with-protocols was given. if test ${with_protocols+y} then : withval=$with_protocols; else $as_nop with_protocols="all" fi # Check whether --with-sysconfig was given. if test ${with_sysconfig+y} then : withval=$with_sysconfig; fi # Check whether --with-runtimedir was given. if test ${with_runtimedir+y} then : withval=$with_runtimedir; runstatedir="$with_runtimedir" fi # Check whether --with-iproutedir was given. if test ${with_iproutedir+y} then : withval=$with_iproutedir; given_iproutedir="yes" fi if test "$enable_debug_expensive" = yes; then enable_debug=yes fi if test "$srcdir" = . ; then # Building in current directory => create obj directory holding all objects objdir=obj else # Building in separate directory objdir=. fi exedir=. # Workaround for older Autoconfs that do not define runstatedir if test -z "${runstatedir}" then : runstatedir='${localstatedir}/run' fi CONFIG_FILE="\$(sysconfdir)/bird.conf" CONTROL_SOCKET="\$(runstatedir)/bird.ctl" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. set dummy ${ac_tool_prefix}clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 printf "%s\n" "$CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "clang", so it can be a program name with args. set dummy clang; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_CC+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="clang" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 printf "%s\n" "$ac_ct_CC" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi fi test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 printf %s "checking whether the C compiler works... " >&6; } ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else $as_nop ac_file='' fi if test -z "$ac_file" then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 printf %s "checking for C compiler default output file name... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 printf %s "checking for suffix of object files... " >&6; } if test ${ac_cv_objext+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_nop printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 printf %s "checking whether the compiler supports GNU C... " >&6; } if test ${ac_cv_c_compiler_gnu+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_compiler_gnu=yes else $as_nop ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 printf %s "checking whether $CC accepts -g... " >&6; } if test ${ac_cv_prog_cc_g+y} then : printf %s "(cached) " >&6 else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 printf "%s\n" "$ac_cv_prog_cc_g" >&6; } if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 printf %s "checking for $CC option to enable C11 features... " >&6; } if test ${ac_cv_prog_cc_c11+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment; extern char aligned_as_int; char _Alignas (0) _Alignas (int) aligned_as_int; // Check _Alignof. enum { int_alignment = _Alignof (int), int_array_alignment = _Alignof (int[100]), char_alignment = _Alignof (char) }; _Static_assert (0 < -_Alignof (int), "_Alignof is signed"); // Check _Noreturn. int _Noreturn does_not_return (void) { for (;;) continue; } // Check _Static_assert. struct test_static_assert { int x; _Static_assert (sizeof (int) <= sizeof (long int), "_Static_assert does not work in struct"); long int y; }; // Check UTF-8 literals. #define u8 syntax error! char const utf8_literal[] = u8"happens to be ASCII" "another string"; // Check duplicate typedefs. typedef long *long_ptr; typedef long int *long_ptr; typedef long_ptr long_ptr; // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. struct anonymous { union { struct { int i; int j; }; struct { int k; long int l; } w; }; int m; } v1; int main (void) { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); v1.i = 2; v1.w.k = 5; _Static_assert ((offsetof (struct anonymous, i) == offsetof (struct anonymous, w.k)), "Anonymous union alignment botch"); ; return 0; } _ACEOF for ac_arg in '' -std=gnu11 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c11=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c11" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL ac_prog_cc_stdc_options= case "x$ac_cv_prog_cc_c11" in x) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } ;; xno) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } ;; *) ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c11" CC=$CC$ac_prog_cc_stdc_options { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } ;; esac if test "x$ac_cv_prog_cc_c11" != xno then : ac_prog_cc_stdc=c11 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 printf %s "checking for $CC option to enable C99 features... " >&6; } if test ${ac_cv_prog_cc_c99+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static bool test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str = ""; int number = 0; float fnumber = 0; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); return *str && number && fnumber; } int main (void) { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. success &= test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL ac_prog_cc_stdc_options= case "x$ac_cv_prog_cc_c99" in x) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } ;; xno) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } ;; *) ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c99" CC=$CC$ac_prog_cc_stdc_options { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno then : ac_prog_cc_stdc=c99 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 else $as_nop { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 printf %s "checking for $CC option to enable C89 features... " >&6; } if test ${ac_cv_prog_cc_c89+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main (void) { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO" then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL ac_prog_cc_stdc_options= case "x$ac_cv_prog_cc_c89" in x) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 printf "%s\n" "none needed" >&6; } ;; xno) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 printf "%s\n" "unsupported" >&6; } ;; *) ac_prog_cc_stdc_options=" $ac_cv_prog_cc_c89" CC=$CC$ac_prog_cc_stdc_options { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno then : ac_prog_cc_stdc=c89 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 else $as_nop ac_prog_cc_stdc=no ac_cv_prog_cc_stdc=no fi fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 printf %s "checking for library containing clock_gettime... " >&6; } if test ${ac_cv_search_clock_gettime+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char clock_gettime (); int main (void) { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt posix4 do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_clock_gettime+y} then : break fi done if test ${ac_cv_search_clock_gettime+y} then : else $as_nop ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 printf "%s\n" "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else $as_nop as_fn_error $? "Function clock_gettime not available." "$LINENO" 5 fi # Make sure we can run config.sub. $SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 printf %s "checking build system type... " >&6; } if test ${ac_cv_build+y} then : printf %s "(cached) " >&6 else $as_nop ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 printf "%s\n" "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 printf %s "checking host system type... " >&6; } if test ${ac_cv_host+y} then : printf %s "(cached) " >&6 else $as_nop if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 printf "%s\n" "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC if test "$ac_test_CFLAGS" != set ; then bird_cflags_default=yes fi if test -z "$GCC" ; then as_fn_error $? "This program requires the GNU C Compiler." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _Thread_local is known" >&5 printf %s "checking whether _Thread_local is known... " >&6; } if test ${bird_cv_thread_local+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _Thread_local static int x = 42; int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : bird_cv_thread_local=yes else $as_nop bird_cv_thread_local=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_thread_local" >&5 printf "%s\n" "$bird_cv_thread_local" >&6; } if test "$bird_cv_thread_local" = yes ; then printf "%s\n" "#define HAVE_THREAD_LOCAL 1" >>confdefs.h fi if test "$enable_pthreads" != no ; then bird_tmp_cflags="$CFLAGS" CFLAGS="$CFLAGS -pthread" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether POSIX threads are available" >&5 printf %s "checking whether POSIX threads are available... " >&6; } if test ${bird_cv_lib_pthreads+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { pthread_t pt; pthread_create(&pt, NULL, NULL, NULL); pthread_spinlock_t lock; pthread_spin_lock(&lock); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_lib_pthreads=yes else $as_nop bird_cv_lib_pthreads=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_lib_pthreads" >&5 printf "%s\n" "$bird_cv_lib_pthreads" >&6; } CFLAGS="$bird_tmp_cflags" if test "$bird_cv_lib_pthreads" = yes ; then printf "%s\n" "#define USE_PTHREADS 1" >>confdefs.h CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" proto_bfd=bfd elif test "$enable_pthreads" = yes ; then as_fn_error $? "POSIX threads not available." "$LINENO" 5 fi if test "$enable_pthreads" = try ; then enable_pthreads="$bird_cv_lib_pthreads" fi fi # This is assumed to be necessary for proper BIRD build CFLAGS="$CFLAGS -fno-strict-aliasing -fno-strict-overflow" if test "$bird_cflags_default" = yes ; then bird_tmp_cflags="$CFLAGS" CFLAGS="-Wall -Wno-pointer-sign" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CC supports -Wno-pointer-sign" >&5 printf %s "checking whether CC supports -Wno-pointer-sign... " >&6; } if test ${bird_cv_c_option_wno_pointer_sign+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : bird_cv_c_option_wno_pointer_sign=yes else $as_nop bird_cv_c_option_wno_pointer_sign=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_c_option_wno_pointer_sign" >&5 printf "%s\n" "$bird_cv_c_option_wno_pointer_sign" >&6; } CFLAGS="$bird_tmp_cflags" bird_tmp_cflags="$CFLAGS" CFLAGS="-Wall -Wextra -Wno-missing-field-initializers" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CC supports -Wno-missing-field-initializers" >&5 printf %s "checking whether CC supports -Wno-missing-field-initializers... " >&6; } if test ${bird_cv_c_option_wno_missing_init+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : bird_cv_c_option_wno_missing_init=yes else $as_nop bird_cv_c_option_wno_missing_init=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_c_option_wno_missing_init" >&5 printf "%s\n" "$bird_cv_c_option_wno_missing_init" >&6; } CFLAGS="$bird_tmp_cflags" if test "$enable_debug" = no; then bird_tmp_cflags="$CFLAGS" bird_tmp_ldflags="$LDFLAGS" CFLAGS="-flto" LDFLAGS="-flto=4" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether link time optimizer is available" >&5 printf %s "checking whether link time optimizer is available... " >&6; } if test ${bird_cv_c_lto+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_c_lto=yes else $as_nop bird_cv_c_lto=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_c_lto" >&5 printf "%s\n" "$bird_cv_c_lto" >&6; } CFLAGS="$bird_tmp_cflags" LDFLAGS="$bird_tmp_ldflags" fi if test "$bird_cv_c_lto" = yes; then CFLAGS="$CFLAGS -flto" LDFLAGS="$LDFLAGS -flto=4 -g" else LDFLAGS="$LDFLAGS -g" fi CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses" if test "$bird_cv_c_option_wno_pointer_sign" = yes ; then CFLAGS="$CFLAGS -Wno-pointer-sign" fi if test "$bird_cv_c_option_wno_missing_init" = yes ; then CFLAGS="$CFLAGS -Wno-missing-field-initializers" fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking CFLAGS" >&5 printf %s "checking CFLAGS... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CFLAGS" >&5 printf "%s\n" "$CFLAGS" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LDFLAGS" >&5 printf %s "checking LDFLAGS... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LDFLAGS" >&5 printf "%s\n" "$LDFLAGS" >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 printf %s "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test ${ac_cv_prog_CPP+y} then : printf %s "(cached) " >&6 else $as_nop # Double quotes because $CC needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO" then : else $as_nop # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : # Broken: success on invalid input. continue else $as_nop # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 printf "%s\n" "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO" then : else $as_nop # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO" then : # Broken: success on invalid input. continue else $as_nop # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok then : else $as_nop { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 printf %s "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if test ${ac_cv_path_install+y} then : printf %s "(cached) " >&6 else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac # Account for fact that we put trailing slashes in our PATH walk. case $as_dir in #(( ./ | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test ${ac_cv_path_install+y}; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 printf "%s\n" "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 printf "%s\n" "$RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_ac_ct_RANLIB+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 printf "%s\n" "$ac_ct_RANLIB" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_FLEX+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$FLEX"; then ac_cv_prog_FLEX="$FLEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_FLEX="flex" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi FLEX=$ac_cv_prog_FLEX if test -n "$FLEX"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5 printf "%s\n" "$FLEX" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi # Extract the first word of "bison", so it can be a program name with args. set dummy bison; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_BISON+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$BISON"; then ac_cv_prog_BISON="$BISON" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_BISON="bison" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi BISON=$ac_cv_prog_BISON if test -n "$BISON"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5 printf "%s\n" "$BISON" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi for ac_prog in gm4 m4 do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 printf %s "checking for $ac_word... " >&6; } if test ${ac_cv_prog_M4+y} then : printf %s "(cached) " >&6 else $as_nop if test -n "$M4"; then ac_cv_prog_M4="$M4" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_M4="$ac_prog" printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi M4=$ac_cv_prog_M4 if test -n "$M4"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $M4" >&5 printf "%s\n" "$M4" >&6; } else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } fi test -n "$M4" && break done test -z "$FLEX" && as_fn_error $? "Flex is missing." "$LINENO" 5 test -z "$BISON" && as_fn_error $? "Bison is missing." "$LINENO" 5 test -z "$M4" && as_fn_error $? "M4 is missing." "$LINENO" 5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking bison version" >&5 printf %s "checking bison version... " >&6; } BISON_VERSION=`bison --version | ( read line; echo ${line##* } )` case "$BISON_VERSION" in 1.* | 2.0* | 2.1* | 2.2* | 2.3*) as_fn_error $? "Provided Bison version $BISON_VERSION is too old, need at least 2.4" "$LINENO" 5 ;; 2.*) bird_bison_synclines=no bird_bison_enhanced_error=no ;; 3.* | 4.* | 5.* | 6.* | 7.* | 8.* | 9.*) bird_bison_synclines=yes bird_bison_enhanced_error=yes ;; *) as_fn_error $? "Couldn't parse Bison version $BISON_VERSION. Call the developers for help." "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BISON_VERSION" >&5 printf "%s\n" "$BISON_VERSION" >&6; } if test "$bird_bison_synclines" = yes && test "$enable_debug_generated" = no; then M4FLAGS="$M4FLAGS -s" fi if test "$bird_bison_enhanced_error" = yes; then BISONFLAGS="$BISONFLAGS -Dparse.lac=full -Dparse.error=verbose" fi # Check for GNU $M4 case `"$M4" --version 2>&1` in *GNU*) ;; *) as_fn_error $? "Provided M4 is not GNU M4." "$LINENO" 5 ;; esac if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then if test -f $with_sysconfig ; then sysdesc=$with_sysconfig else sysdesc=$srcdir/sysdep/cf/$with_sysconfig if ! test -f $sysdesc ; then sysdesc=$sysdesc.h fi fi elif test -f sysconfig.h ; then sysdesc=sysconfig else case "$host_os" in linux*) sysdesc=linux default_iproutedir="/etc/iproute2" ;; freebsd*) sysdesc=bsd CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" ;; kfreebsd*) sysdesc=bsd ;; netbsd*) sysdesc=bsd CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib" ;; openbsd*) sysdesc=bsd ;; dragonfly*) sysdesc=bsd ;; *) as_fn_error $? "Cannot determine correct system configuration. Please use --with-sysconfig to set it manually." "$LINENO" 5 ;; esac sysdesc=$srcdir/sysdep/cf/$sysdesc.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which OS configuration should we use" >&5 printf %s "checking which OS configuration should we use... " >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sysdesc" >&5 printf "%s\n" "$sysdesc" >&6; } if ! test -f $sysdesc ; then as_fn_error $? "The system configuration file is missing." "$LINENO" 5 fi sysname=`echo $sysdesc | sed 's/\.h$//'` printf "%s\n" "#define SYSCONF_INCLUDE \"$sysdesc\"" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking system-dependent directories" >&5 printf %s "checking system-dependent directories... " >&6; } sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sysdep_dirs" >&5 printf "%s\n" "$sysdep_dirs" >&6; } if test "$with_iproutedir" = no ; then with_iproutedir= ; fi if test -n "$given_iproutedir" then iproutedir=$with_iproutedir else iproutedir=$default_iproutedir fi DAEMON_LIBS= if test "$enable_libssh" != no ; then ac_fn_c_check_header_compile "$LINENO" "libssh/libssh.h" "ac_cv_header_libssh_libssh_h" " " if test "x$ac_cv_header_libssh_libssh_h" = xyes then : true else $as_nop fail=yes fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ssh_connect in -lssh" >&5 printf %s "checking for ssh_connect in -lssh... " >&6; } if test ${ac_cv_lib_ssh_ssh_connect+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lssh $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char ssh_connect (); int main (void) { return ssh_connect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_ssh_ssh_connect=yes else $as_nop ac_cv_lib_ssh_ssh_connect=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssh_ssh_connect" >&5 printf "%s\n" "$ac_cv_lib_ssh_ssh_connect" >&6; } if test "x$ac_cv_lib_ssh_ssh_connect" = xyes then : true else $as_nop fail=yes fi if test "$fail" != yes ; then printf "%s\n" "#define HAVE_LIBSSH 1" >>confdefs.h DAEMON_LIBS="-lssh $DAEMON_LIBS" enable_libssh=yes else if test "$enable_libssh" = yes ; then as_fn_error $? "LibSSH not available." "$LINENO" 5 else enable_libssh=no fi fi fi if test "$enable_mpls_kernel" != no ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux MPLS headers" >&5 printf %s "checking for Linux MPLS headers... " >&6; } if test ${bird_cv_mpls_kernel+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include void t(int arg); int main (void) { t(AF_MPLS); t(RTA_VIA); t(RTA_NEWDST); t(RTA_ENCAP_TYPE); t(RTA_ENCAP); struct rtvia rtvia; t(LWTUNNEL_ENCAP_MPLS); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : bird_cv_mpls_kernel=yes else $as_nop bird_cv_mpls_kernel=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_mpls_kernel" >&5 printf "%s\n" "$bird_cv_mpls_kernel" >&6; } if test "$bird_cv_mpls_kernel" = yes ; then printf "%s\n" "#define HAVE_MPLS_KERNEL 1" >>confdefs.h elif test "$enable_mpls_kernel" = yes ; then as_fn_error $? "Kernel MPLS support not found." "$LINENO" 5 fi if test "$enable_mpls_kernel" = try ; then enable_mpls_kernel="$bird_cv_mpls_kernel" fi fi all_protocols="$proto_bfd babel bgp mrt ospf perf pipe radv rip rpki static" all_protocols=`echo $all_protocols | sed 's/ /,/g'` if test "$with_protocols" = all ; then with_protocols="$all_protocols" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking protocols" >&5 printf %s "checking protocols... " >&6; } protocols=`echo "$with_protocols" | sed 's/,/ /g'` if test "$protocols" = no ; then protocols= ; fi for a in $protocols ; do if ! test -f $srcdir/proto/$a/Makefile ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 printf "%s\n" "failed" >&6; } as_fn_error $? "Requested protocol $a not found" "$LINENO" 5 fi cat >>confdefs.h <<_ACEOF #define CONFIG_`echo $a | tr 'a-z' 'A-Z'` 1 _ACEOF done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 printf "%s\n" "ok" >&6; } case $sysdesc in */linux*) ac_fn_c_check_header_compile "$LINENO" "linux/rtnetlink.h" "ac_cv_header_linux_rtnetlink_h" " #include #include " if test "x$ac_cv_header_linux_rtnetlink_h" = xyes then : else $as_nop as_fn_error $? "Appropriate version of Linux kernel headers not found." "$LINENO" 5 fi ;; esac ac_header= ac_cache= for ac_item in $ac_header_c_list do if test $ac_cache; then ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then printf "%s\n" "#define $ac_item 1" >> confdefs.h fi ac_header= ac_cache= elif test $ac_header; then ac_cache=$ac_item else ac_header=$ac_item fi done printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h printf "%s\n" "#define HAVE_STRING_H 1" >>confdefs.h printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h ac_fn_c_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" "#include " if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes then : printf "%s\n" "#define HAVE_STRUCT_SOCKADDR_SA_LEN 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 printf %s "checking whether byte ordering is bigendian... " >&6; } if test ${ac_cv_c_bigendian+y} then : printf %s "(cached) " >&6 else $as_nop ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO" then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : ac_cv_c_bigendian=yes else $as_nop ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ unsigned short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; unsigned short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } unsigned short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; unsigned short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main (void) { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main (void) { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO" then : ac_cv_c_bigendian=no else $as_nop ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 printf "%s\n" "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) printf "%s\n" "#define CPU_BIG_ENDIAN 1" >>confdefs.h ;; #( no) printf "%s\n" "#define CPU_LITTLE_ENDIAN 1" >>confdefs.h ;; #( universal) printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "Cannot determine CPU endianity." "$LINENO" 5 ;; esac { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for glob.h" >&5 printf %s "checking for glob.h... " >&6; } if test ${bird_cv_lib_glob+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { glob(NULL, 0, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_lib_glob=yes else $as_nop bird_tmp_libs="$LIBS" LIBS="$LIBS -landroid-glob" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main (void) { glob(NULL, 0, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_lib_glob=-landroid-glob else $as_nop bird_cv_lib_glob=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$bird_tmp_libs" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_lib_glob" >&5 printf "%s\n" "$bird_cv_lib_glob" >&6; } if test "$bird_cv_lib_glob" = no ; then as_fn_error $? "glob.h not found." "$LINENO" 5 elif test "$bird_cv_lib_glob" != yes ; then LIBS="$LIBS $bird_cv_lib_glob" fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for syslog lib flags" >&5 printf %s "checking for syslog lib flags... " >&6; } if test ${bird_cv_lib_log+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { syslog(0, ""); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_lib_log=yes else $as_nop bird_tmp_libs="$LIBS" LIBS="$LIBS -llog" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main (void) { syslog(0, ""); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : bird_cv_lib_log=-llog else $as_nop bird_cv_lib_log=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$bird_tmp_libs" fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_lib_log" >&5 printf "%s\n" "$bird_cv_lib_log" >&6; } if test "$bird_cv_lib_log" = no ; then as_fn_error $? "don't know how to link syslog." "$LINENO" 5 elif test "$bird_cv_lib_log" != yes ; then LIBS="$LIBS $bird_cv_lib_log" fi if test "$enable_debug" = yes ; then printf "%s\n" "#define DEBUGGING 1" >>confdefs.h LDFLAGS="$LDFLAGS -rdynamic" CFLAGS="$CFLAGS -O0 -ggdb -g3" bird_tmp_cflags="$CFLAGS" CFLAGS=" -gdwarf-4" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CC supports -gdwarf-4" >&5 printf %s "checking whether CC supports -gdwarf-4... " >&6; } if test ${bird_cv_c_option_dwarf4+y} then : printf %s "(cached) " >&6 else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main (void) { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO" then : bird_cv_c_option_dwarf4=yes else $as_nop bird_cv_c_option_dwarf4=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $bird_cv_c_option_dwarf4" >&5 printf "%s\n" "$bird_cv_c_option_dwarf4" >&6; } CFLAGS="$bird_tmp_cflags" if test "$bird_cv_c_option_dwarf4" = yes ; then CFLAGS="$CFLAGS -gdwarf-4" fi ac_fn_c_check_header_compile "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default" if test "x$ac_cv_header_execinfo_h" = xyes then : printf "%s\n" "#define HAVE_EXECINFO_H 1" >>confdefs.h { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing backtrace" >&5 printf %s "checking for library containing backtrace... " >&6; } if test ${ac_cv_search_backtrace+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char backtrace (); int main (void) { return backtrace (); ; return 0; } _ACEOF for ac_lib in '' execinfo do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_backtrace=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_backtrace+y} then : break fi done if test ${ac_cv_search_backtrace+y} then : else $as_nop ac_cv_search_backtrace=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_backtrace" >&5 printf "%s\n" "$ac_cv_search_backtrace" >&6; } ac_res=$ac_cv_search_backtrace if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" else $as_nop as_fn_error $? "Function backtrace not available." "$LINENO" 5 fi fi if test "$enable_memcheck" = yes ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dmalloc_debug in -ldmalloc" >&5 printf %s "checking for dmalloc_debug in -ldmalloc... " >&6; } if test ${ac_cv_lib_dmalloc_dmalloc_debug+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldmalloc $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char dmalloc_debug (); int main (void) { return dmalloc_debug (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_dmalloc_dmalloc_debug=yes else $as_nop ac_cv_lib_dmalloc_dmalloc_debug=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5 printf "%s\n" "$ac_cv_lib_dmalloc_dmalloc_debug" >&6; } if test "x$ac_cv_lib_dmalloc_dmalloc_debug" = xyes then : printf "%s\n" "#define HAVE_LIBDMALLOC 1" >>confdefs.h LIBS="-ldmalloc $LIBS" fi if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for malloc in -lefence" >&5 printf %s "checking for malloc in -lefence... " >&6; } if test ${ac_cv_lib_efence_malloc+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lefence $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char malloc (); int main (void) { return malloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_efence_malloc=yes else $as_nop ac_cv_lib_efence_malloc=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_efence_malloc" >&5 printf "%s\n" "$ac_cv_lib_efence_malloc" >&6; } if test "x$ac_cv_lib_efence_malloc" = xyes then : printf "%s\n" "#define HAVE_LIBEFENCE 1" >>confdefs.h LIBS="-lefence $LIBS" fi fi fi if test "enable_debug_expensive" = yes ; then printf "%s\n" "#define ENABLE_EXPENSIVE_CHECKS 1" >>confdefs.h fi fi CLIENT=birdcl CLIENT_LIBS= if test "$enable_client" = yes ; then CLIENT="$CLIENT birdc" BASE_LIBS="$LIBS" LIBS="" for ac_header in curses.h do : ac_fn_c_check_header_compile "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default " if test "x$ac_cv_header_curses_h" = xyes then : printf "%s\n" "#define HAVE_CURSES_H 1" >>confdefs.h else $as_nop as_fn_error $? "The client requires ncurses library. Either install the library or use --disable-client to compile without the client." "$LINENO" 5 fi done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 printf %s "checking for library containing tgetent... " >&6; } if test ${ac_cv_search_tgetent+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char tgetent (); int main (void) { return tgetent (); ; return 0; } _ACEOF for ac_lib in '' tinfo tinfow ncurses curses termcap do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_tgetent=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_tgetent+y} then : break fi done if test ${ac_cv_search_tgetent+y} then : else $as_nop ac_cv_search_tgetent=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetent" >&5 printf "%s\n" "$ac_cv_search_tgetent" >&6; } ac_res=$ac_cv_search_tgetent if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" TINFO_LIBS="$LIBS"; LIBS="" else $as_nop as_fn_error $? "The client requires ncurses library. Either install the library or use --disable-client to compile without the client." "$LINENO" 5 fi for ac_header in readline/readline.h readline/history.h do : as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes" then : cat >>confdefs.h <<_ACEOF #define `printf "%s\n" "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF else $as_nop as_fn_error $? "The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client." "$LINENO" 5 fi done { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing rl_callback_read_char" >&5 printf %s "checking for library containing rl_callback_read_char... " >&6; } if test ${ac_cv_search_rl_callback_read_char+y} then : printf %s "(cached) " >&6 else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char rl_callback_read_char (); int main (void) { return rl_callback_read_char (); ; return 0; } _ACEOF for ac_lib in '' readline do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $TINFO_LIBS $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO" then : ac_cv_search_rl_callback_read_char=$ac_res fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext if test ${ac_cv_search_rl_callback_read_char+y} then : break fi done if test ${ac_cv_search_rl_callback_read_char+y} then : else $as_nop ac_cv_search_rl_callback_read_char=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_rl_callback_read_char" >&5 printf "%s\n" "$ac_cv_search_rl_callback_read_char" >&6; } ac_res=$ac_cv_search_rl_callback_read_char if test "$ac_res" != no then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" READLINE_LIBS="$LIBS"; LIBS="" else $as_nop as_fn_error $? "The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for rl_crlf in -lreadline" >&5 printf %s "checking for rl_crlf in -lreadline... " >&6; } if test ${ac_cv_lib_readline_rl_crlf+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $TINFO_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char rl_crlf (); int main (void) { return rl_crlf (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_readline_rl_crlf=yes else $as_nop ac_cv_lib_readline_rl_crlf=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_crlf" >&5 printf "%s\n" "$ac_cv_lib_readline_rl_crlf" >&6; } if test "x$ac_cv_lib_readline_rl_crlf" = xyes then : printf "%s\n" "#define HAVE_RL_CRLF 1" >>confdefs.h fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for rl_ding in -lreadline" >&5 printf %s "checking for rl_ding in -lreadline... " >&6; } if test ${ac_cv_lib_readline_rl_ding+y} then : printf %s "(cached) " >&6 else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $TINFO_LIBS $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ char rl_ding (); int main (void) { return rl_ding (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : ac_cv_lib_readline_rl_ding=yes else $as_nop ac_cv_lib_readline_rl_ding=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_ding" >&5 printf "%s\n" "$ac_cv_lib_readline_rl_ding" >&6; } if test "x$ac_cv_lib_readline_rl_ding" = xyes then : printf "%s\n" "#define HAVE_RL_DING 1" >>confdefs.h fi LIBS="$BASE_LIBS" CLIENT_LIBS="$READLINE_LIBS $TINFO_LIBS" fi mkdir -p $objdir/sysdep ac_config_headers="$ac_config_headers $objdir/sysdep/autoconf.h:sysdep/autoconf.h.in" ac_config_files="$ac_config_files Makefile:Makefile.in" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh as_nop=: if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi # Reset variables that may have inherited troublesome values from # the environment. # IFS needs to be set, to space, tab, and newline, in precisely that order. # (If _AS_PATH_WALK were called with IFS unset, it would have the # side effect of setting IFS to empty, thus disabling word splitting.) # Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl IFS=" "" $as_nl" PS1='$ ' PS2='> ' PS4='+ ' # Ensure predictable behavior from utilities with locale-dependent output. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # We cannot yet rely on "unset" to work, but we need these variables # to be unset--not just set to an empty or harmless value--now, to # avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct # also avoids known problems related to "unset" and subshell syntax # in other old shells (e.g. bash 2.01 and pdksh 5.2.14). for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH do eval test \${$as_var+y} \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done # Ensure that fds 0, 1, and 2 are open. if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS case $as_dir in #((( '') as_dir=./ ;; */) ;; *) as_dir=$as_dir/ ;; esac test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null then : eval 'as_fn_append () { eval $1+=\$2 }' else $as_nop as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null then : eval 'as_fn_arith () { as_val=$(( $* )) }' else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # Determine whether it's possible to make 'echo' print without a newline. # These variables are no longer used directly by Autoconf, but are AC_SUBSTed # for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac # For backward compatibility with old third-party macros, we provide # the shell variables $as_echo and $as_echo_n. New code should use # AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. as_echo='printf %s\n' as_echo_n='printf %s' rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.69e. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to the package provider." _ACEOF ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.69e, with options \\"\$ac_cs_config\\" Copyright (C) 2020 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX printf "%s\n" "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "$objdir/sysdep/autoconf.h") CONFIG_HEADERS="$CONFIG_HEADERS $objdir/sysdep/autoconf.h:sysdep/autoconf.h.in" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:Makefile.in" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5 printf "%s\n" "" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: BIRD was configured with the following options:" >&5 printf "%s\n" "BIRD was configured with the following options:" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Source directory: $srcdir" >&5 printf "%s\n" " Source directory: $srcdir" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Object directory: $objdir" >&5 printf "%s\n" " Object directory: $objdir" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Iproute2 directory: $iproutedir" >&5 printf "%s\n" " Iproute2 directory: $iproutedir" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: System configuration: $sysdesc" >&5 printf "%s\n" " System configuration: $sysdesc" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Debugging: $enable_debug" >&5 printf "%s\n" " Debugging: $enable_debug" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: POSIX threads: $enable_pthreads" >&5 printf "%s\n" " POSIX threads: $enable_pthreads" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Routing protocols: $protocols" >&5 printf "%s\n" " Routing protocols: $protocols" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: LibSSH support in RPKI: $enable_libssh" >&5 printf "%s\n" " LibSSH support in RPKI: $enable_libssh" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Kernel MPLS support: $enable_mpls_kernel" >&5 printf "%s\n" " Kernel MPLS support: $enable_mpls_kernel" >&6; } { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Client: $enable_client" >&5 printf "%s\n" " Client: $enable_client" >&6; } rm -f $objdir/.*-stamp bird-2.0.8/tools/0000775000175000017500000000000014025745105012520 5ustar feelafeelabird-2.0.8/tools/gendist0000775000175000017500000000201714025745077014113 0ustar feelafeela#!/bin/sh # # Generate BIRD Distribution Archive # (c) 2000--2004 Martin Mares # VERSION=`grep 'BIRD_VERSION \"' sysdep/config.h | sed '/BIRD_VERSION/!d;s/^.*"\(.*\)"$/\1/'` REL=bird-$VERSION DREL=bird-doc-$VERSION T=/tmp/bird set -e AC=autoreconf $AC ./configure make docs rm -rf $T/$REL $T/$DREL mkdir -p $T/$REL $T/$DREL $T/$DREL/doc mv obj/doc/*.pdf $T/$DREL/doc make distclean find . -name "*~" -exec rm -f '{}' '+' $AC rm -rf autom4te*cache echo Building $REL cp -a . $T/$REL echo Generating ChangeLog git log >$T/$REL/ChangeLog rm -f $T/$REL/bird.conf* rm -rf $T/$REL/.git/ rm -rf `find $T/$REL -name CVS -o -name tmp` $T/$REL/{misc,rfc,doc/slides,doc/slt2001,doc/old,doc/*.out} ( cd $T ; tar czvvf $REL.tar.gz $REL ) ( cd $T ; tar czvvf $DREL.tar.gz $DREL ) rm -rf $T/$REL $T/$DREL echo -n "OK? " read OK #echo Uploading to Atrey... #scp $T/$REL.tar.gz $T/$DREL.tar.gz atrey.karlin.mff.cuni.cz:~ftp/pub/bird/ echo Uploading to Trubka... scp $T/$REL.tar.gz $T/$DREL.tar.gz bird.network.cz:~ftp/pub/bird/ echo Done. bird-2.0.8/tools/progdoc0000775000175000017500000000264414025744326014115 0ustar feelafeela#!/usr/bin/perl $srcdir = $ARGV[0]; $out = $ARGV[1]; open(OUT, ">", $out) || die "Cannot create output file"; process($srcdir, "doc/prog-root"); close OUT; gen_deps(); exit 0; sub include { my $f = shift @_; open(IN, "$f") || die "Unable to find $f"; push(@deps, "$f"); while () { print OUT; } close IN; } sub process { my $dir = shift @_; my $doc = "$dir/" . shift @_; print "$doc\n"; open(IN, $doc) || die "Unable to read $doc"; push(@deps, $doc); my @docfile = ; close IN; foreach $_ (@docfile) { chomp; /^#/ && next; /^([A-Z]+)\s*(.*)/ || die "Parse error: $_"; $cmd = $1; $arg = $2; if ($cmd eq "C") { process("$dir/$arg", "Doc"); } elsif ($cmd eq "H") { push @stack, "H"; print OUT "$arg\n"; } elsif ($cmd eq "S") { print " $arg\n"; my @files = map("$dir/$_", split(' ', $arg)); my $fargs = join(' ', @files); open(DOC, "$srcdir/doc/kernel-doc -bird $fargs |") || die "Unable to start kernel-doc"; push(@deps, @files); while () { print OUT; } close DOC; } elsif ($cmd eq "D") { print " $arg\n"; include("$dir/$arg"); } else { die "Unknown command: $cmd"; } } } sub gen_deps { open(DEP, ">", "$out.d"); print DEP "$out:"; foreach $f (@deps) { print DEP " \\\n $f"; } print DEP "\n\n"; foreach $f (@deps) { print DEP "$f:\n\n"; } close DEP; } bird-2.0.8/tools/install-sh0000775000175000017500000001124314025744326014531 0ustar feelafeela#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" tranformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 bird-2.0.8/tools/cvslog0000775000175000017500000000264714025744326013760 0ustar feelafeela#!/usr/bin/perl # Process `cvs log' output to get a resonable changelog # (c) 2003--2004 Martin Mares use Digest::MD5; use POSIX; my %names= ( 'mj' => 'Martin Mares ', 'feela' => 'Ondrej Filip ', 'pavel' => 'Pavel Machek ' ); while () { chomp; /^$/ && next; /^[?]/ && next; /^RCS file: / || die; $_ = ; chomp; my ($file) = /^Working file: (.*)$/ or die; #print "$file\n"; do { $_ = or die; } while (!/^description:/); $_ = ; for(;;) { /^======/ && last; if (/^------/) { $_ = ; next; } /^revision / || die; $_ = ; my ($author) = /;\s*author:\s*([^;]+)/ or die; my ($yy,$mm,$dd,$HH,$MM,$SS) = /^date: (....)\/(..)\/(..) (..):(..):(..);/ or die; my $t = POSIX::mktime($SS,$MM,$HH,$dd,$mm-1,$yy-1900) or die; my $T = sprintf("%06d", int(($t + 1800)/3600)); $d = ""; while ($_ = ) { /^(-----|=====)/ && last; $d .= " $_"; } my $id = "$T:" . Digest::MD5::md5_hex($d); if (!defined $msg{$id}) { $date{$id} = "$yy-$mm-$dd $HH:$MM:$SS"; $msg{$id} = $d; $files{$id} = ""; $author{$id} = $author; } $files{$id} .= " * $file\n"; #print "\t$id\n"; } } foreach $id (sort keys %date) { if (!exists ($names{$author{$id}})) { die "Unknown commiter $author{$id}"; } print "### ", $date{$id}, " ", $names{$author{$id}}, "\n\n"; print $files{$id}, "\n"; print $msg{$id}, "\n"; } bird-2.0.8/tools/config.sub0000775000175000017500000010661714025744326014522 0ustar feelafeela#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-04-16' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo "$1" | sed 's/-[^-]*$//'` if [ "$basic_machine" != "$1" ] then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper | csky \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; m9s12z | m68hcs12z | hcs12z | s12z) basic_machine=s12z-unknown os=-none ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2*) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; nsv-tandem) basic_machine=nsv-tandem ;; nsx-tandem) basic_machine=nsx-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh5el) basic_machine=sh5le-unknown ;; simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; x64) basic_machine=x86_64-pc ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases that might get confused # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # es1800 is here to avoid being matched by es* (a different OS) -es1800*) os=-ose ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* | -hcos* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -xray | -os68k* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4*) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -pikeos*) # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. case $basic_machine in arm*) os=-eabi ;; *) os=-elf ;; esac ;; -nacl*) ;; -ios) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; pru-*) os=-elf ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac echo "$basic_machine$os" exit # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: bird-2.0.8/tools/config.guess0000775000175000017500000012620614025744326015053 0ustar feelafeela#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-03-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval "$set_cc_for_build" cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" # If ldd exists, use it to detect musl libc. if command -v ldd >/dev/null && \ ldd --version 2>&1 | grep -q ^musl then LIBC=musl fi ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval "$set_cc_for_build" SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ [ "$TARGET_BINARY_INTERFACE"x = x ] then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "$HP_ARCH" = "" ]; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ "$HP_ARCH" = hppa2.0w ] then eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: bird-2.0.8/test/0000775000175000017500000000000014025744326012343 5ustar feelafeelabird-2.0.8/test/bt-utils.h0000664000175000017500000000230414025744326014256 0ustar feelafeela/* * BIRD Test -- Utils for testing parsing configuration file * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRDTEST_UTILS_H_ #define _BIRDTEST_UTILS_H_ #include "sysdep/config.h" #define PRIip4 "%d.%d.%d.%d" #define ARGip4(x) (_I(x) >> 24) & 0xff, (_I(x) >> 16) & 0xff, (_I(x) >> 8) & 0xff, _I(x) & 0xff #define PRIip6 "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X" #define ARGip6_HIGH(x,i) (((x).addr[(i)] >> 16) & 0xffff) #define ARGip6_LOW(x,i) ((x).addr[(i)] & 0xffff) #define ARGip6_BOTH(x,i) ARGip6_HIGH(x,i), ARGip6_LOW(x,i) #define ARGip6(x) ARGip6_BOTH((x), 0), ARGip6_BOTH((x), 1), ARGip6_BOTH((x), 2), ARGip6_BOTH((x), 3) #define BT_CONFIG_PARSE_ROUTER_ID "router id 1.1.1.1; \n" #define BT_CONFIG_PARSE_STATIC_PROTO "protocol static { ipv4; } \n" #define BT_CONFIG_SIMPLE BT_CONFIG_PARSE_ROUTER_ID BT_CONFIG_PARSE_STATIC_PROTO uint bt_naive_pow(uint base, uint power); void bt_bytes_to_hex(char *buf, const byte *in_data, size_t size); void bt_bird_init(void); void bt_bird_cleanup(void); struct config *bt_config_parse(const char *cfg); struct config *bt_config_file_parse(const char *filepath); #endif /* _BIRDTEST_UTILS_H_ */ bird-2.0.8/test/bt-utils.c0000664000175000017500000001112614025744326014253 0ustar feelafeela/* * BIRD Test -- Utils for testing parsing configuration file * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include "test/birdtest.h" #include "test/bt-utils.h" #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" #include "sysdep/unix/unix.h" #include "sysdep/unix/krt.h" #include "nest/iface.h" #include "nest/locks.h" #include "filter/filter.h" #define BETWEEN(a, b, c) (((a) >= (b)) && ((a) <= (c))) static const byte *bt_config_parse_pos; static uint bt_config_parse_remain_len; /* This is cf_read_hook for hard-coded text configuration */ static int cf_static_read(byte *dest, uint max_len, int fd UNUSED) { if (max_len > bt_config_parse_remain_len) max_len = bt_config_parse_remain_len; memcpy(dest, bt_config_parse_pos, max_len); bt_config_parse_pos += max_len; bt_config_parse_remain_len -= max_len; return max_len; } /* This is cf_read_hook for reading configuration files, * function is copied from main.c, cf_read() */ static int cf_file_read(byte *dest, uint max_len, int fd) { int l = read(fd, dest, max_len); if (l < 0) cf_error("Read error"); return l; } void bt_bird_init(void) { if(bt_verbose) log_init_debug(""); log_switch(bt_verbose != 0, NULL, NULL); resource_init(); olock_init(); timer_init(); io_init(); rt_init(); if_init(); config_init(); protos_build(); proto_build(&proto_unix_kernel); proto_build(&proto_unix_iface); } void bt_bird_cleanup(void) { for (int i = 0; i < PROTOCOL__MAX; i++) class_to_protocol[i] = NULL; config = new_config = NULL; } static char * bt_load_file(const char *filename, int quiet) { FILE *f = fopen(filename, "rb"); if (!quiet) bt_assert_msg(f != NULL, "Open %s", filename); if (f == NULL) return NULL; fseek(f, 0, SEEK_END); long file_size_ = ftell(f); fseek(f, 0, SEEK_SET); if (file_size_ < 0) return NULL; size_t file_size = file_size_; size_t read_size = 0; char *file_body = mb_allocz(&root_pool, file_size+1); /* XXX: copied from cf-lex.c */ errno=0; while ((read_size += fread(file_body+read_size, 1, file_size-read_size, f)) != file_size && ferror(f)) { bt_debug("iteration \n"); if(errno != EINTR) { bt_abort_msg("errno: %d", errno); break; } errno=0; clearerr(f); } fclose(f); if (!quiet) bt_assert_msg(read_size == file_size, "Read %s", filename); return file_body; } static void bt_show_cfg_error(const struct config *cfg) { int lino = 0; int lino_delta = 5; int lino_err = cfg->err_lino; const char *str = bt_load_file(cfg->err_file_name, 1); while (str && *str) { lino++; if (BETWEEN(lino, lino_err - lino_delta, lino_err + lino_delta)) bt_debug("%4u%s", lino, (lino_err == lino ? " >> " : " ")); do { if (BETWEEN(lino, lino_err - lino_delta, lino_err + lino_delta)) bt_debug("%c", *str); } while (*str && *(str++) != '\n'); } bt_debug("\n"); } static struct config * bt_config_parse__(struct config *cfg) { bt_assert_msg(config_parse(cfg) == 1, "Parse %s", cfg->file_name); if (cfg->err_msg) { bt_log("Parse error %s, line %d: %s", cfg->err_file_name, cfg->err_lino, cfg->err_msg); bt_show_cfg_error(cfg); return NULL; } config_commit(cfg, RECONFIG_HARD, 0); new_config = cfg; return cfg; } struct config * bt_config_parse(const char *cfg_str) { struct config *cfg = config_alloc("configuration"); bt_config_parse_pos = cfg_str; bt_config_parse_remain_len = strlen(cfg_str); cf_read_hook = cf_static_read; return bt_config_parse__(cfg); } struct config * bt_config_file_parse(const char *filepath) { struct config *cfg = config_alloc(filepath); cfg->file_fd = open(filepath, O_RDONLY); bt_assert_msg(cfg->file_fd > 0, "Open %s", filepath); if (cfg->file_fd < 0) return NULL; cf_read_hook = cf_file_read; return bt_config_parse__(cfg); } /* * Returns @base raised to the power of @power. */ uint bt_naive_pow(uint base, uint power) { uint result = 1; uint i; for (i = 0; i < power; i++) result *= base; return result; } /** * bytes_to_hex - transform data into hexadecimal representation * @buf: preallocated string buffer * @in_data: data for transformation * @size: the length of @in_data * * This function transforms @in_data of length @size into hexadecimal * representation and writes it into @buf. */ void bt_bytes_to_hex(char *buf, const byte *in_data, size_t size) { size_t i; for(i = 0; i < size; i++) sprintf(buf + i*2, "%02x", in_data[i]); } bird-2.0.8/test/birdtest.h0000664000175000017500000001265514025744326014345 0ustar feelafeela/* * BIRD -- Unit Test Framework (BIRD Test) * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRDTEST_H_ #define _BIRDTEST_H_ #include #include #include #include #include #include #include "nest/bird.h" extern int bt_result; extern int bt_suite_result; extern char bt_out_fmt_buf[1024]; extern uint bt_verbose; #define BT_VERBOSE_NO 0 #define BT_VERBOSE_SUITE 1 #define BT_VERBOSE_SUITE_CASE 2 #define BT_VERBOSE_ABSOLUTELY_ALL 3 extern const char *bt_filename; extern const char *bt_test_id; void bt_init(int argc, char *argv[]); int bt_exit_value(void); int bt_test_suite_base(int (*test_fn)(const void *), const char *test_id, const void *test_fn_argument, int forked, int timeout, const char *dsc, ...); static inline u64 bt_random(void) { return ((u64) random() & 0xffffffff) | ((u64) random() << 32); } void bt_log_suite_result(int result, const char *fmt, ...); void bt_log_suite_case_result(int result, const char *fmt, ...); #define BT_TIMEOUT 5 /* Default timeout in seconds */ #define BT_FORKING 1 /* Forking is enabled in default */ #define BT_RANDOM_SEED 0x5097d2bb #define BT_BUFFER_SIZE 10000 #define BT_PROMPT_GREEN "\e[1;32m" #define BT_PROMPT_RED "\e[1;31m" #define BT_PROMPT_NORMAL "\e[0m" #define BT_PROMPT_OK " [" BT_PROMPT_GREEN " OK " BT_PROMPT_NORMAL "] " #define BT_PROMPT_OK_NO_COLOR " [" " OK " "] " #define BT_PROMPT_FAIL " [" BT_PROMPT_RED "FAIL" BT_PROMPT_NORMAL "] " #define BT_PROMPT_FAIL_NO_COLOR " [" "FAIL" "] " #define BT_PROMPT_OK_FAIL_STRLEN 8 /* strlen ' [FAIL] ' */ static inline int bt_test_fn_noarg(const void *cp) { return ((int (*)(void)) cp)(); } #define bt_test_suite(fn, dsc, ...) \ bt_test_suite_extra(fn, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) #define bt_test_suite_extra(fn, f, t, dsc, ...) \ bt_test_suite_base(bt_test_fn_noarg, #fn, fn, f, t, dsc, ##__VA_ARGS__) #define bt_test_suite_arg(fn, arg, dsc, ...) \ bt_test_suite_arg_extra(fn, arg, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__) #define bt_test_suite_arg_extra(fn, arg, f, t, dsc, ...) \ bt_test_suite_base(fn, #fn, arg, f, t, dsc, ##__VA_ARGS__) #define bt_abort() \ bt_abort_msg("Aborted at %s:%d", __FILE__, __LINE__) #define bt_abort_msg(format, ...) \ do \ { \ bt_log(format, ##__VA_ARGS__); \ abort(); \ } while (0) #define bt_log(format, ...) \ do \ { \ if (bt_test_id) \ printf("%s: %s: " format "\n", bt_filename, bt_test_id, ##__VA_ARGS__); \ else \ printf("%s: " format "\n", bt_filename, ##__VA_ARGS__); \ } while(0) #define bt_debug(format, ...) \ do \ { \ if (bt_verbose >= BT_VERBOSE_ABSOLUTELY_ALL) \ printf(format, ##__VA_ARGS__); \ } while (0) #define bt_assert(test) \ bt_assert_msg(test, "Assertion (%s) at %s:%d", #test, __FILE__, __LINE__) #define bt_assert_msg(test, format, ...) \ do \ { \ int bt_suit_case_result = 1; \ if ((test) == 0) \ { \ bt_result = 0; \ bt_suite_result = 0; \ bt_suit_case_result = 0; \ } \ bt_log_suite_case_result(bt_suit_case_result, format, ##__VA_ARGS__); \ } while (0) #define bt_syscall(test, format, ...) \ do \ { \ if (test) \ { \ bt_log(format ": %s", ##__VA_ARGS__, strerror(errno)); \ exit(3); \ } \ } while (0) #define bt_sprintf_concat(s, format, ...) \ snprintf(s + strlen(s), sizeof(s) - strlen(s), format, ##__VA_ARGS__) struct bt_pair { const void *in; const void *out; }; /* Data structure used by bt_assert_batch() function */ struct bt_batch { /* in_fmt / out_fmt - formating data * @buf: buffer for write stringified @data * @size: empty size in @buf * @data: data for stringify * * There are some build-in functions, see bt_fmt_* functions */ void (*in_fmt)(char *buf, size_t size, const void *data); void (*out_fmt)(char *buf, size_t size, const void *data); /* Temporary output buffer */ void *out_buf; /* test_fn - testing function * @out: output data from tested function * @in: data for input * @expected_out: expected data from tested function * * Input arguments should not be stringified using in_fmt() or out_fmt() * function already. This function should return only 0 or 1 */ int (*test_fn)(void *out, const void *in, const void *expected_out); /* Name of testing function @test_fn */ const char *test_fn_name; /* Number of items in data */ int ndata; /* Array of input and expected output pairs */ struct bt_pair *data; }; void bt_fmt_str(char *buf, size_t size, const void *data); void bt_fmt_unsigned(char *buf, size_t size, const void *data); void bt_fmt_ipa(char *buf, size_t size, const void *data); int bt_assert_batch__(struct bt_batch *opts); int bt_is_char(byte c); #define bt_assert_batch(data__, fn__, in_fmt__, out_fmt__) \ bt_assert_batch__(& (struct bt_batch) { \ .data = data__, \ .ndata = ARRAY_SIZE(data__), \ .test_fn = fn__, \ .test_fn_name = #fn__, \ .in_fmt = in_fmt__, \ .out_fmt = out_fmt__, \ .out_buf = bt_out_fmt_buf, /* Global memory for this usage */ \ }) #endif /* _BIRDTEST_H_ */ bird-2.0.8/test/birdtest.c0000664000175000017500000003000414025744326014324 0ustar feelafeela/* * BIRD -- Unit Test Framework (BIRD Test) * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "test/birdtest.h" #include "lib/string.h" #ifdef HAVE_EXECINFO_H #include #endif #define BACKTRACE_MAX_LINES 100 #define sprintf_concat(s, format, ...) \ snprintf(s + strlen(s), sizeof(s) - strlen(s), format, ##__VA_ARGS__) static const char *request; static int list_tests; static int do_core; static int do_die; static int no_fork; static int no_timeout; static int is_terminal; /* Whether stdout is a live terminal or pipe redirect */ volatile sig_atomic_t async_config_flag; /* Asynchronous reconfiguration/dump scheduled */ volatile sig_atomic_t async_dump_flag; volatile sig_atomic_t async_shutdown_flag; uint bt_verbose; const char *bt_filename; const char *bt_test_id; int bt_result; /* Overall program run result */ int bt_suite_result; /* One suit result */ char bt_out_fmt_buf[1024]; /* Temporary memory buffer for output of testing function */ struct timespec bt_begin, bt_suite_begin, bt_suite_case_begin; u64 bt_random_state[] = { 0x80241f302bd4d95d, 0xd10ba2e910f772b, 0xea188c9046f507c5, 0x4c4c581f04e6da05, 0x53d9772877c1b647, 0xab8ce3eb466de6c5, 0xad02844c8a8e865f, 0xe8cc78080295065d }; void bt_init(int argc, char *argv[]) { int c; initstate(BT_RANDOM_SEED, (char *) bt_random_state, sizeof(bt_random_state)); bt_verbose = 0; bt_filename = argv[0]; bt_result = 1; bt_test_id = NULL; is_terminal = isatty(fileno(stdout)); while ((c = getopt(argc, argv, "lcdftv")) >= 0) switch (c) { case 'l': list_tests = 1; break; case 'c': do_core = 1; break; case 'd': do_die = 1; break; case 'f': no_fork = 1; break; case 't': no_timeout = 1; break; case 'v': bt_verbose++; break; default: goto usage; } /* Optional requested test_id */ if ((optind + 1) == argc) request = argv[optind++]; if (optind != argc) goto usage; if (do_core) { struct rlimit rl = {RLIM_INFINITY, RLIM_INFINITY}; int rv = setrlimit(RLIMIT_CORE, &rl); bt_syscall(rv < 0, "setrlimit RLIMIT_CORE"); } clock_gettime(CLOCK_MONOTONIC, &bt_begin); bt_suite_case_begin = bt_suite_begin = bt_begin; return; usage: printf("Usage: %s [-l] [-c] [-d] [-f] [-t] [-vvv] []\n", argv[0]); printf("Options: \n"); printf(" -l List all test suite names and descriptions \n"); printf(" -c Force unlimit core dumps (needs root privileges) \n"); printf(" -d Die on first failed test case \n"); printf(" -f No forking \n"); printf(" -t No timeout limit \n"); printf(" -v More verbosity, maximum is 3 -vvv \n"); exit(3); } static void bt_dump_backtrace(void) { #ifdef HAVE_EXECINFO_H void *buf[BACKTRACE_MAX_LINES]; char **pp_backtrace; int lines, j; if (!bt_verbose) return; lines = backtrace(buf, BACKTRACE_MAX_LINES); bt_log("backtrace() returned %d addresses", lines); pp_backtrace = backtrace_symbols(buf, lines); if (pp_backtrace == NULL) { perror("backtrace_symbols"); exit(EXIT_FAILURE); } for (j = 0; j < lines; j++) bt_log("%s", pp_backtrace[j]); free(pp_backtrace); #endif /* HAVE_EXECINFO_H */ } static int bt_run_test_fn(int (*fn)(const void *), const void *fn_arg, int timeout) { int result; alarm(timeout); result = fn(fn_arg); if (!bt_suite_result) result = 0; return result; } static uint get_num_terminal_cols(void) { struct winsize w = {}; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); uint cols = w.ws_col; return (cols > 0 ? cols : 80); } /** * bt_log_result - pretty print of test result * @result: 1 or 0 * @fmt: a description message (could be long, over more lines) * @argptr: variable argument list * * This function is used for pretty printing of test results on all verbose * levels. */ static void bt_log_result(int result, u64 time, const char *fmt, va_list argptr) { static char msg_buf[BT_BUFFER_SIZE]; char *pos; snprintf(msg_buf, sizeof(msg_buf), "%s%s%s %" PRIu64 ".%09" PRIu64 "s%s", bt_filename, bt_test_id ? ": " : "", bt_test_id ? bt_test_id : "", time / 1000000000, time % 1000000000, (fmt && strlen(fmt) > 0) ? ": " : ""); pos = msg_buf + strlen(msg_buf); if (fmt) vsnprintf(pos, sizeof(msg_buf) - (pos - msg_buf), fmt, argptr); int chrs = 0; for (uint i = 0; i < strlen(msg_buf); i += get_num_terminal_cols()) { if (i) printf("\n"); char *stop = msg_buf + i + get_num_terminal_cols(); char backup = *stop; *stop = 0; chrs = printf("%s", msg_buf + i); *stop = backup; } int offset = get_num_terminal_cols() - chrs - BT_PROMPT_OK_FAIL_STRLEN; if (offset < 0) { printf("\n"); offset = get_num_terminal_cols() - BT_PROMPT_OK_FAIL_STRLEN; } for (int i = 0; i < offset; i++) putchar(' '); const char *result_str = is_terminal ? BT_PROMPT_OK : BT_PROMPT_OK_NO_COLOR; if (!result) result_str = is_terminal ? BT_PROMPT_FAIL : BT_PROMPT_FAIL_NO_COLOR; printf("%s\n", result_str); if (do_die && !result) abort(); } static u64 get_time_diff(struct timespec *begin) { struct timespec end; clock_gettime(CLOCK_MONOTONIC, &end); return (end.tv_sec - begin->tv_sec) * 1000000000ULL + end.tv_nsec - begin->tv_nsec; } /** * bt_log_overall_result - pretty print of suite case result * @result: 1 or 0 * @fmt: a description message (could be long, over more lines) * ...: variable argument list * * This function is used for pretty printing of test suite case result. */ static void bt_log_overall_result(int result, const char *fmt, ...) { va_list argptr; va_start(argptr, fmt); bt_log_result(result, get_time_diff(&bt_begin), fmt, argptr); va_end(argptr); } /** * bt_log_suite_result - pretty print of suite case result * @result: 1 or 0 * @fmt: a description message (could be long, over more lines) * ...: variable argument list * * This function is used for pretty printing of test suite case result. */ void bt_log_suite_result(int result, const char *fmt, ...) { if (bt_verbose >= BT_VERBOSE_SUITE || !result) { va_list argptr; va_start(argptr, fmt); bt_log_result(result, get_time_diff(&bt_suite_begin), fmt, argptr); va_end(argptr); } } /** * bt_log_suite_case_result - pretty print of suite result * @result: 1 or 0 * @fmt: a description message (could be long, over more lines) * ...: variable argument list * * This function is used for pretty printing of test suite result. */ void bt_log_suite_case_result(int result, const char *fmt, ...) { if(bt_verbose >= BT_VERBOSE_SUITE_CASE) { va_list argptr; va_start(argptr, fmt); bt_log_result(result, get_time_diff(&bt_suite_case_begin), fmt, argptr); va_end(argptr); } } int bt_test_suite_base(int (*fn)(const void *), const char *id, const void *fn_arg, int forked, int timeout, const char *dsc, ...) { if (list_tests) { printf("%28s - ", id); va_list args; va_start(args, dsc); vprintf(dsc, args); va_end(args); printf("\n"); return 1; } if (no_fork) forked = 0; if (no_timeout) timeout = 0; if (request && strcmp(id, request)) return 1; bt_suite_result = 1; bt_test_id = id; if (bt_verbose >= BT_VERBOSE_ABSOLUTELY_ALL) bt_log("Starting"); clock_gettime(CLOCK_MONOTONIC, &bt_suite_begin); bt_suite_case_begin = bt_suite_begin; if (!forked) { bt_suite_result = bt_run_test_fn(fn, fn_arg, timeout); } else { pid_t pid = fork(); bt_syscall(pid < 0, "fork"); if (pid == 0) { /* child of fork */ _exit(bt_run_test_fn(fn, fn_arg, timeout)); } int s; int rv = waitpid(pid, &s, 0); bt_syscall(rv < 0, "waitpid"); if (WIFEXITED(s)) { /* Normal exit */ bt_suite_result = WEXITSTATUS(s); } else if (WIFSIGNALED(s)) { /* Stopped by signal */ bt_suite_result = 0; int sn = WTERMSIG(s); if (sn == SIGALRM) { bt_log("Timeout expired"); } else if (sn == SIGSEGV) { bt_log("Segmentation fault"); bt_dump_backtrace(); } else if (sn != SIGABRT) bt_log("Signal %d received", sn); } if (WCOREDUMP(s) && bt_verbose) bt_log("Core dumped"); } if (!bt_suite_result) bt_result = 0; bt_log_suite_result(bt_suite_result, NULL); bt_test_id = NULL; return bt_suite_result; } int bt_exit_value(void) { if (!list_tests || (list_tests && !bt_result)) bt_log_overall_result(bt_result, ""); return bt_result ? EXIT_SUCCESS : EXIT_FAILURE; } /** * bt_assert_batch__ - test a batch of inputs/outputs tests * @opts: includes all necessary data * * Should be called using macro bt_assert_batch(). * Returns 1 or 0. */ int bt_assert_batch__(struct bt_batch *opts) { int i; for (i = 0; i < opts->ndata; i++) { if (bt_verbose >= BT_VERBOSE_SUITE) clock_gettime(CLOCK_MONOTONIC, &bt_suite_case_begin); int bt_suit_case_result = opts->test_fn(opts->out_buf, opts->data[i].in, opts->data[i].out); if (bt_suit_case_result == 0) bt_suite_result = 0; char b[BT_BUFFER_SIZE]; snprintf(b, sizeof(b), "%s(", opts->test_fn_name); opts->in_fmt(b+strlen(b), sizeof(b)-strlen(b), opts->data[i].in); sprintf_concat(b, ") gives "); opts->out_fmt(b+strlen(b), sizeof(b)-strlen(b), opts->out_buf); if (bt_suit_case_result == 0) { sprintf_concat(b, ", but expecting is "); opts->out_fmt(b+strlen(b), sizeof(b)-strlen(b), opts->data[i].out); } bt_log_suite_case_result(bt_suit_case_result, "%s", b); } return bt_suite_result; } /** * bt_fmt_str - formating string into output buffer * @buf: buffer for write * @size: empty size in @buf * @data: null-byte terminated string * * This function can be used with bt_assert_batch() function. * Input @data should be const char * string. */ void bt_fmt_str(char *buf, size_t size, const void *data) { const byte *s = data; snprintf(buf, size, "\""); while (*s) { snprintf(buf+strlen(buf), size-strlen(buf), bt_is_char(*s) ? "%c" : "\\%03u", *s); s++; } snprintf(buf+strlen(buf), size-strlen(buf), "\""); } /** * bt_fmt_unsigned - formating unsigned int into output buffer * @buf: buffer for write * @size: empty size in @buf * @data: unsigned number * * This function can be used with bt_assert_batch() function. */ void bt_fmt_unsigned(char *buf, size_t size, const void *data) { const uint *n = data; snprintf(buf, size, "0x%x (%u)", *n, *n); } /** * bt_fmt_ipa - formating ip_addr into output buffer * @buf: buffer for write * @size: empty size in @buf * @data: should be struct ip_addr * * * This function can be used with bt_assert_batch() function. */ void bt_fmt_ipa(char *buf, size_t size, const void *data) { const ip_addr *ip = data; if (data) bsnprintf(buf, size, "%I", *ip); else bsnprintf(buf, size, "(null)"); } int bt_is_char(byte c) { return (c >= (byte) 32 && c <= (byte) 126); } /* * Mock-ups of all necessary public functions in main.c */ int parse_and_exit; char *bird_name; void async_config(void) {} void async_dump(void) {} void async_shutdown(void) {} char *get_hostname(linpool *lp UNUSED) { return NULL; } void cmd_check_config(char *name UNUSED) {} void cmd_reconfig(char *name UNUSED, int type UNUSED, int timeout UNUSED) {} void cmd_reconfig_confirm(void) {} void cmd_reconfig_undo(void) {} void cmd_reconfig_status(void) {} void cmd_graceful_restart(void) {} void cmd_shutdown(void) {} void cmd_reconfig_undo_notify(void) {} #include "nest/bird.h" #include "lib/net.h" #include "conf/conf.h" void sysdep_preconfig(struct config *c UNUSED) {} int sysdep_commit(struct config *new UNUSED, struct config *old UNUSED) { return 0; } void sysdep_shutdown_done(void) {} #include "nest/cli.h" int cli_get_command(cli *c UNUSED) { return 0; } void cli_write_trigger(cli *c UNUSED) {} cli *cmd_reconfig_stored_cli; bird-2.0.8/test/Makefile0000664000175000017500000000013614025744326014003 0ustar feelafeelasrc := birdtest.c bt-utils.c obj := $(src-o-files) tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/sysdep/0000775000175000017500000000000014025754400012665 5ustar feelafeelabird-2.0.8/sysdep/autoconf.h.in0000664000175000017500000000726014025754370015274 0ustar feelafeela/* sysdep/autoconf.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Babel protocol */ #undef CONFIG_BABEL /* BFD protocol */ #undef CONFIG_BFD /* BGP protocol */ #undef CONFIG_BGP /* MRT protocol */ #undef CONFIG_MRT /* OSPF protocol */ #undef CONFIG_OSPF /* Pipe protocol */ #undef CONFIG_PIPE /* RAdv protocol */ #undef CONFIG_RADV /* RIP protocol */ #undef CONFIG_RIP /* RPKI protocol */ #undef CONFIG_RPKI /* Static protocol */ #undef CONFIG_STATIC /* Define to 1 if cpu is big endian */ #undef CPU_BIG_ENDIAN /* Define to 1 if cpu is little endian */ #undef CPU_LITTLE_ENDIAN /* Define to 1 if debugging is enabled */ #undef DEBUGGING /* Define to 1 if you want to run expensive consistency checks. */ #undef ENABLE_EXPENSIVE_CHECKS /* Define to 1 if you have the header file. */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H /* Define to 1 if you have the header file. */ #undef HAVE_EXECINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ #undef HAVE_LIBDMALLOC /* Define to 1 if you have the `efence' library (-lefence). */ #undef HAVE_LIBEFENCE /* Define to 1 if you have the `ssh' library (-lssh). */ #undef HAVE_LIBSSH /* Define to 1 if kernel is MPLS capable */ #undef HAVE_MPLS_KERNEL /* Define to 1 if you have the header file. */ #undef HAVE_READLINE_HISTORY_H /* Define to 1 if you have the header file. */ #undef HAVE_READLINE_READLINE_H /* Define to 1 if you have rl_crlf() */ #undef HAVE_RL_CRLF /* Define to 1 if you have rl_ding() */ #undef HAVE_RL_DING /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Always define to 1, for backward compatibility. You can assume exists. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Always define to 1, for backward compatibility. You can assume exists. */ #undef HAVE_STRING_H /* Define to 1 if `sa_len' is a member of `struct sockaddr'. */ #undef HAVE_STRUCT_SOCKADDR_SA_LEN /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if _Thread_local is available */ #undef HAVE_THREAD_LOCAL /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Always define to 1, for backward compatibility. You can assume the C90 standard headers exist. */ #undef STDC_HEADERS /* Which sysdep header to include */ #undef SYSCONF_INCLUDE /* Define to 1 if pthreads are enabled */ #undef USE_PTHREADS /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif bird-2.0.8/sysdep/unix/0000775000175000017500000000000014025744326013656 5ustar feelafeelabird-2.0.8/sysdep/unix/unix.h0000664000175000017500000000743214025744326015020 0ustar feelafeela/* * BIRD -- Declarations Common to Unix Port * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_UNIX_H_ #define _BIRD_UNIX_H_ #include #include struct pool; struct iface; struct birdsock; struct rfile; /* main.c */ extern char *bird_name; extern int parse_and_exit; void async_config(void); void async_dump(void); void async_shutdown(void); char *get_hostname(linpool *lp); void cmd_check_config(const char *name); void cmd_reconfig(const char *name, int type, uint timeout); void cmd_reconfig_confirm(void); void cmd_reconfig_undo(void); void cmd_reconfig_status(void); void cmd_shutdown(void); void cmd_graceful_restart(void); #define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300 #define UNIX_DEFAULT_LATENCY_LIMIT (1 S_) #define UNIX_DEFAULT_WATCHDOG_WARNING (5 S_) /* io.c */ #define ERR(c) do { s->err = c; return -1; } while (0) #define ERR2(c) do { s->err = c; goto err; } while (0) #define ERR_MSG(c) do { errno = 0; s->err = c; return -1; } while (0) #define SOCKADDR_SIZE 32 typedef struct sockaddr_bird { struct sockaddr sa; char padding[SOCKADDR_SIZE - sizeof(struct sockaddr)]; } sockaddr; /* This is sloppy hack, it should be detected by configure script */ /* Linux systems have it defined so this is definition for BSD systems */ #ifndef s6_addr32 #define s6_addr32 __u6_addr.__u6_addr32 #endif static inline ip_addr ipa_from_in4(struct in_addr a) { return ipa_from_u32(ntohl(a.s_addr)); } static inline ip_addr ipa_from_in6(struct in6_addr a) { return ipa_build6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); } static inline ip_addr ipa_from_sa4(sockaddr *sa) { return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); } static inline ip_addr ipa_from_sa6(sockaddr *sa) { return ipa_from_in6(((struct sockaddr_in6 *) sa)->sin6_addr); } static inline ip_addr ipa_from_sa(sockaddr *sa) { switch (sa->sa.sa_family) { case AF_INET: return ipa_from_sa4(sa); case AF_INET6: return ipa_from_sa6(sa); default: return IPA_NONE; } } static inline struct in_addr ipa_to_in4(ip_addr a) { return (struct in_addr) { htonl(ipa_to_u32(a)) }; } static inline struct in_addr ip4_to_in4(ip4_addr a) { return (struct in_addr) { htonl(ip4_to_u32(a)) }; } static inline struct in6_addr ipa_to_in6(ip_addr a) { return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; } void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port); int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port); #ifndef SUN_LEN #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((ptr)->sun_path)) #endif extern volatile sig_atomic_t async_config_flag; extern volatile sig_atomic_t async_dump_flag; extern volatile sig_atomic_t async_shutdown_flag; void io_init(void); void io_loop(void); void io_log_dump(void); int sk_open_unix(struct birdsock *s, char *name); struct rfile *rf_open(struct pool *, const char *name, const char *mode); void *rf_file(struct rfile *f); int rf_fileno(struct rfile *f); void test_old_bird(char *path); /* krt.c bits */ void krt_io_init(void); /* log.c */ void main_thread_init(void); void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */ void log_switch(int initial, list *l, const char *); struct log_config { node n; uint mask; /* Classes to log */ void *fh; /* FILE to log to, NULL=syslog */ struct rfile *rf; /* Resource for log file */ const char *filename; /* Log filename */ const char *backup; /* Secondary filename (for log rotation) */ off_t pos; /* Position/size of current log */ off_t limit; /* Log size limit */ int terminal_flag; }; #endif bird-2.0.8/sysdep/unix/random.c0000664000175000017500000000057614025744326015312 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Random Numbers * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "nest/bird.h" u32 random_u32(void) { long int rand_low, rand_high; rand_low = random(); rand_high = random(); return (rand_low & 0xffff) | ((rand_high & 0xffff) << 16); } bird-2.0.8/sysdep/unix/main.c0000664000175000017500000004211614025744326014752 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Unix Entry Point * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #undef LOCAL_DEBUG #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/event.h" #include "lib/timer.h" #include "lib/string.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "nest/cli.h" #include "nest/locks.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/data.h" #include "unix.h" #include "krt.h" /* * Debugging */ void async_dump(void) { debug("INTERNAL STATE DUMP\n\n"); rdump(&root_pool); sk_dump_all(); // XXXX tm_dump_all(); if_dump_all(); neigh_dump_all(); rta_dump_all(); rt_dump_all(); protos_dump_all(); debug("\n"); } /* * Dropping privileges */ #ifdef CONFIG_RESTRICTED_PRIVILEGES #include CONFIG_INCLUDE_SYSPRIV_H #else static inline void drop_uid(uid_t uid UNUSED) { die("Cannot change user on this platform"); } #endif static inline void drop_gid(gid_t gid) { if (setgid(gid) < 0) die("setgid: %m"); if (setgroups(0, NULL) < 0) die("setgroups: %m"); } /* * Hostname */ char * get_hostname(linpool *lp) { struct utsname uts = {}; if (uname(&uts) < 0) return NULL; return lp_strdup(lp, uts.nodename); } /* * Reading the Configuration */ #ifdef PATH_IPROUTE_DIR static inline void add_num_const(char *name, int val, const char *file, const uint line) { struct f_val *v = cfg_alloc(sizeof(struct f_val)); *v = (struct f_val) { .type = T_INT, .val.i = val }; struct symbol *sym = cf_get_symbol(name); if (sym->class && (sym->scope == conf_this_scope)) cf_error("Error reading value for %s from %s:%d: already defined", name, file, line); cf_define_symbol(sym, SYM_CONSTANT | T_INT, val, v); } /* the code of read_iproute_table() is based on rtnl_tab_initialize() from iproute2 package */ static void read_iproute_table(char *file, char *prefix, int max) { char buf[512], namebuf[512]; char *name; int val; FILE *fp; strcpy(namebuf, prefix); name = namebuf + strlen(prefix); fp = fopen(file, "r"); if (!fp) return; for (uint line = 1; fgets(buf, sizeof(buf), fp); line++) { char *p = buf; while (*p == ' ' || *p == '\t') p++; if (*p == '#' || *p == '\n' || *p == 0) continue; if (sscanf(p, "0x%x %s\n", &val, name) != 2 && sscanf(p, "0x%x %s #", &val, name) != 2 && sscanf(p, "%d %s\n", &val, name) != 2 && sscanf(p, "%d %s #", &val, name) != 2) continue; if (val < 0 || val > max) continue; for(p = name; *p; p++) if ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z') && (*p < '0' || *p > '9') && (*p != '_')) *p = '_'; add_num_const(namebuf, val, file, line); } fclose(fp); } #endif // PATH_IPROUTE_DIR static char *config_name = PATH_CONFIG_FILE; static int cf_read(byte *dest, uint len, int fd) { int l = read(fd, dest, len); if (l < 0) cf_error("Read error"); return l; } void sysdep_preconfig(struct config *c) { init_list(&c->logfiles); c->latency_limit = UNIX_DEFAULT_LATENCY_LIMIT; c->watchdog_warning = UNIX_DEFAULT_WATCHDOG_WARNING; #ifdef PATH_IPROUTE_DIR read_iproute_table(PATH_IPROUTE_DIR "/rt_protos", "ipp_", 256); read_iproute_table(PATH_IPROUTE_DIR "/rt_realms", "ipr_", 256); read_iproute_table(PATH_IPROUTE_DIR "/rt_scopes", "ips_", 256); read_iproute_table(PATH_IPROUTE_DIR "/rt_tables", "ipt_", 256); #endif } int sysdep_commit(struct config *new, struct config *old UNUSED) { log_switch(0, &new->logfiles, new->syslog_name); return 0; } static int unix_read_config(struct config **cp, const char *name) { struct config *conf = config_alloc(name); int ret; *cp = conf; conf->file_fd = open(name, O_RDONLY); if (conf->file_fd < 0) return 0; cf_read_hook = cf_read; ret = config_parse(conf); close(conf->file_fd); return ret; } static struct config * read_config(void) { struct config *conf; if (!unix_read_config(&conf, config_name)) { if (conf->err_msg) die("%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg); else die("Unable to open configuration file %s: %m", config_name); } return conf; } void async_config(void) { struct config *conf; log(L_INFO "Reconfiguration requested by SIGHUP"); if (!unix_read_config(&conf, config_name)) { if (conf->err_msg) log(L_ERR "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg); else log(L_ERR "Unable to open configuration file %s: %m", config_name); config_free(conf); } else config_commit(conf, RECONFIG_HARD, 0); } static struct config * cmd_read_config(const char *name) { struct config *conf; if (!name) name = config_name; cli_msg(-2, "Reading configuration from %s", name); if (!unix_read_config(&conf, name)) { if (conf->err_msg) cli_msg(8002, "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg); else cli_msg(8002, "%s: %m", name); config_free(conf); conf = NULL; } return conf; } void cmd_check_config(const char *name) { struct config *conf = cmd_read_config(name); if (!conf) return; cli_msg(20, "Configuration OK"); config_free(conf); } static void cmd_reconfig_msg(int r) { switch (r) { case CONF_DONE: cli_msg( 3, "Reconfigured"); break; case CONF_PROGRESS: cli_msg( 4, "Reconfiguration in progress"); break; case CONF_QUEUED: cli_msg( 5, "Reconfiguration already in progress, queueing new config"); break; case CONF_UNQUEUED: cli_msg(17, "Reconfiguration already in progress, removing queued config"); break; case CONF_CONFIRM: cli_msg(18, "Reconfiguration confirmed"); break; case CONF_SHUTDOWN: cli_msg( 6, "Reconfiguration ignored, shutting down"); break; case CONF_NOTHING: cli_msg(19, "Nothing to do"); break; default: break; } } /* Hack for scheduled undo notification */ cli *cmd_reconfig_stored_cli; void cmd_reconfig_undo_notify(void) { if (cmd_reconfig_stored_cli) { cli *c = cmd_reconfig_stored_cli; cli_printf(c, CLI_ASYNC_CODE, "Config timeout expired, starting undo"); cli_write_trigger(c); } } void cmd_reconfig(const char *name, int type, uint timeout) { if (cli_access_restricted()) return; struct config *conf = cmd_read_config(name); if (!conf) return; int r = config_commit(conf, type, timeout); if ((r >= 0) && (timeout > 0)) { cmd_reconfig_stored_cli = this_cli; cli_msg(-22, "Undo scheduled in %d s", timeout); } cmd_reconfig_msg(r); } void cmd_reconfig_confirm(void) { if (cli_access_restricted()) return; int r = config_confirm(); cmd_reconfig_msg(r); } void cmd_reconfig_undo(void) { if (cli_access_restricted()) return; cli_msg(-21, "Undo requested"); int r = config_undo(); cmd_reconfig_msg(r); } void cmd_reconfig_status(void) { int s = config_status(); btime t = config_timer_status(); switch (s) { case CONF_DONE: cli_msg(-3, "Daemon is up and running"); break; case CONF_PROGRESS: cli_msg(-4, "Reconfiguration in progress"); break; case CONF_QUEUED: cli_msg(-5, "Reconfiguration in progress, next one enqueued"); break; case CONF_SHUTDOWN: cli_msg(-6, "Shutdown in progress"); break; default: break; } if (t >= 0) cli_msg(-22, "Configuration unconfirmed, undo in %t s", t); cli_msg(0, ""); } /* * Command-Line Interface */ static sock *cli_sk; static char *path_control_socket = PATH_CONTROL_SOCKET; static void cli_write(cli *c) { sock *s = c->priv; while (c->tx_pos) { struct cli_out *o = c->tx_pos; int len = o->wpos - o->outpos; s->tbuf = o->outpos; o->outpos = o->wpos; if (sk_send(s, len) <= 0) return; c->tx_pos = o->next; } /* Everything is written */ s->tbuf = NULL; cli_written(c); } void cli_write_trigger(cli *c) { sock *s = c->priv; if (s->tbuf == NULL) cli_write(c); } static void cli_tx(sock *s) { cli_write(s->data); } int cli_get_command(cli *c) { sock *s = c->priv; byte *t = c->rx_aux ? : s->rbuf; byte *tend = s->rpos; byte *d = c->rx_pos; byte *dend = c->rx_buf + CLI_RX_BUF_SIZE - 2; while (t < tend) { if (*t == '\r') t++; else if (*t == '\n') { t++; c->rx_pos = c->rx_buf; c->rx_aux = t; *d = 0; return (d < dend) ? 1 : -1; } else if (d < dend) *d++ = *t++; } c->rx_aux = s->rpos = s->rbuf; c->rx_pos = d; return 0; } static int cli_rx(sock *s, uint size UNUSED) { cli_kick(s->data); return 0; } static void cli_err(sock *s, int err) { if (config->cli_debug) { if (err) log(L_INFO "CLI connection dropped: %s", strerror(err)); else log(L_INFO "CLI connection closed"); } cli_free(s->data); } static int cli_connect(sock *s, uint size UNUSED) { cli *c; if (config->cli_debug) log(L_INFO "CLI connect"); s->rx_hook = cli_rx; s->tx_hook = cli_tx; s->err_hook = cli_err; s->data = c = cli_new(s); s->pool = c->pool; /* We need to have all the socket buffers allocated in the cli pool */ s->fast_rx = 1; c->rx_pos = c->rx_buf; c->rx_aux = NULL; rmove(s, c->pool); return 1; } static void cli_init_unix(uid_t use_uid, gid_t use_gid) { sock *s; cli_init(); s = cli_sk = sk_new(cli_pool); s->type = SK_UNIX_PASSIVE; s->rx_hook = cli_connect; s->rbsize = 1024; s->fast_rx = 1; /* Return value intentionally ignored */ unlink(path_control_socket); if (sk_open_unix(s, path_control_socket) < 0) die("Cannot create control socket %s: %m", path_control_socket); if (use_uid || use_gid) if (chown(path_control_socket, use_uid, use_gid) < 0) die("chown: %m"); if (chmod(path_control_socket, 0660) < 0) die("chmod: %m"); } /* * PID file */ static char *pid_file; static int pid_fd; static inline void open_pid_file(void) { if (!pid_file) return; pid_fd = open(pid_file, O_WRONLY|O_CREAT, 0664); if (pid_fd < 0) die("Cannot create PID file %s: %m", pid_file); } static inline void write_pid_file(void) { int pl, rv; char ps[24]; if (!pid_file) return; /* We don't use PID file for uniqueness, so no need for locking */ pl = bsnprintf(ps, sizeof(ps), "%ld\n", (s64) getpid()); if (pl < 0) bug("PID buffer too small"); rv = ftruncate(pid_fd, 0); if (rv < 0) die("fruncate: %m"); rv = write(pid_fd, ps, pl); if(rv < 0) die("write: %m"); close(pid_fd); } static inline void unlink_pid_file(void) { if (pid_file) unlink(pid_file); } /* * Shutdown */ void cmd_shutdown(void) { if (cli_access_restricted()) return; cli_msg(7, "Shutdown requested"); order_shutdown(0); } void async_shutdown(void) { DBG("Shutting down...\n"); order_shutdown(0); } void sysdep_shutdown_done(void) { unlink_pid_file(); unlink(path_control_socket); log_msg(L_FATAL "Shutdown completed"); exit(0); } void cmd_graceful_restart(void) { if (cli_access_restricted()) return; cli_msg(25, "Graceful restart requested"); order_shutdown(1); } /* * Signals */ volatile sig_atomic_t async_config_flag; volatile sig_atomic_t async_dump_flag; volatile sig_atomic_t async_shutdown_flag; static void handle_sighup(int sig UNUSED) { DBG("Caught SIGHUP...\n"); async_config_flag = 1; } static void handle_sigusr(int sig UNUSED) { DBG("Caught SIGUSR...\n"); async_dump_flag = 1; } static void handle_sigterm(int sig UNUSED) { DBG("Caught SIGTERM...\n"); async_shutdown_flag = 1; } void watchdog_sigalrm(int sig UNUSED); static void signal_init(void) { struct sigaction sa; bzero(&sa, sizeof(sa)); sa.sa_handler = handle_sigusr; sa.sa_flags = SA_RESTART; sigaction(SIGUSR1, &sa, NULL); sa.sa_handler = handle_sighup; sa.sa_flags = SA_RESTART; sigaction(SIGHUP, &sa, NULL); sa.sa_handler = handle_sigterm; sa.sa_flags = SA_RESTART; sigaction(SIGTERM, &sa, NULL); sa.sa_handler = watchdog_sigalrm; sa.sa_flags = 0; sigaction(SIGALRM, &sa, NULL); signal(SIGPIPE, SIG_IGN); } /* * Parsing of command-line arguments */ static char *opt_list = "bc:dD:ps:P:u:g:flRh"; int parse_and_exit; char *bird_name; static char *use_user; static char *use_group; static int run_in_foreground = 0; static void display_usage(void) { fprintf(stderr, "Usage: %s [--version] [--help] [-c ] [OPTIONS]\n", bird_name); } static void display_help(void) { display_usage(); fprintf(stderr, "\n" "Options: \n" " -c Use given configuration file instead of\n" " " PATH_CONFIG_FILE "\n" " -d Enable debug messages and run bird in foreground\n" " -D Log debug messages to given file instead of stderr\n" " -f Run bird in foreground\n" " -g Use given group ID\n" " -h, --help Display this information\n" " -l Look for a configuration file and a control socket\n" " in the current working directory\n" " -p Test configuration file and exit without start\n" " -P Create a PID file with given filename\n" " -R Apply graceful restart recovery after start\n" " -s Use given filename for a control socket\n" " -u Drop privileges and use given user ID\n" " --version Display version of BIRD\n"); exit(0); } static void display_version(void) { fprintf(stderr, "BIRD version " BIRD_VERSION "\n"); exit(0); } static inline char * get_bird_name(char *s, char *def) { char *t; if (!s) return def; t = strrchr(s, '/'); if (!t) return s; if (!t[1]) return def; return t+1; } static inline uid_t get_uid(const char *s) { struct passwd *pw; char *endptr; long int rv; if (!s) return 0; errno = 0; rv = strtol(s, &endptr, 10); if (!errno && !*endptr) return rv; pw = getpwnam(s); if (!pw) die("Cannot find user '%s'", s); return pw->pw_uid; } static inline gid_t get_gid(const char *s) { struct group *gr; char *endptr; long int rv; if (!s) return 0; errno = 0; rv = strtol(s, &endptr, 10); if (!errno && !*endptr) return rv; gr = getgrnam(s); if (!gr) die("Cannot find group '%s'", s); return gr->gr_gid; } static void parse_args(int argc, char **argv) { int config_changed = 0; int socket_changed = 0; int c; bird_name = get_bird_name(argv[0], "bird"); if (argc == 2) { if (!strcmp(argv[1], "--version")) display_version(); if (!strcmp(argv[1], "--help")) display_help(); } while ((c = getopt(argc, argv, opt_list)) >= 0) switch (c) { case 'c': config_name = optarg; config_changed = 1; break; case 'd': log_init_debug(""); run_in_foreground = 1; break; case 'D': log_init_debug(optarg); break; case 'p': parse_and_exit = 1; break; case 's': path_control_socket = optarg; socket_changed = 1; break; case 'P': pid_file = optarg; break; case 'u': use_user = optarg; break; case 'g': use_group = optarg; break; case 'f': run_in_foreground = 1; break; case 'l': if (!config_changed) config_name = xbasename(config_name); if (!socket_changed) path_control_socket = xbasename(path_control_socket); break; case 'R': graceful_restart_recovery(); break; case 'h': display_help(); break; default: fputc('\n', stderr); display_usage(); exit(1); } if (optind < argc) { display_usage(); exit(1); } } /* * Hic Est main() */ int main(int argc, char **argv) { #ifdef HAVE_LIBDMALLOC if (!getenv("DMALLOC_OPTIONS")) dmalloc_debug(0x2f03d00); #endif parse_args(argc, argv); log_switch(1, NULL, NULL); net_init(); resource_init(); timer_init(); olock_init(); io_init(); rt_init(); if_init(); // roa_init(); config_init(); uid_t use_uid = get_uid(use_user); gid_t use_gid = get_gid(use_group); if (!parse_and_exit) { test_old_bird(path_control_socket); cli_init_unix(use_uid, use_gid); } if (use_gid) drop_gid(use_gid); if (use_uid) drop_uid(use_uid); if (!parse_and_exit) open_pid_file(); protos_build(); proto_build(&proto_unix_kernel); proto_build(&proto_unix_iface); struct config *conf = read_config(); if (parse_and_exit) exit(0); if (!run_in_foreground) { pid_t pid = fork(); if (pid < 0) die("fork: %m"); if (pid) return 0; setsid(); close(0); if (open("/dev/null", O_RDWR) < 0) die("Cannot open /dev/null: %m"); dup2(0, 1); dup2(0, 2); } main_thread_init(); write_pid_file(); signal_init(); config_commit(conf, RECONFIG_HARD, 0); graceful_restart_init(); #ifdef LOCAL_DEBUG async_dump_flag = 1; #endif log(L_INFO "Started"); DBG("Entering I/O loop.\n"); io_loop(); bug("I/O loop died"); } bird-2.0.8/sysdep/unix/log.c0000664000175000017500000002202314025744326014602 0ustar feelafeela/* * BIRD Library -- Logging Functions * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Logging * * The Logging module offers a simple set of functions for writing * messages to system logs and to the debug output. Message classes * used by this module are described in |birdlib.h| and also in the * user's manual. */ #include #include #include #include #include #include #include #include #include "nest/bird.h" #include "nest/cli.h" #include "conf/conf.h" #include "lib/string.h" #include "lib/lists.h" #include "sysdep/unix/unix.h" static FILE *dbgf; static list *current_log_list; static char *current_syslog_name; /* NULL -> syslog closed */ #ifdef USE_PTHREADS #include static pthread_mutex_t log_mutex; static inline void log_lock(void) { pthread_mutex_lock(&log_mutex); } static inline void log_unlock(void) { pthread_mutex_unlock(&log_mutex); } static pthread_t main_thread; void main_thread_init(void) { main_thread = pthread_self(); } static int main_thread_self(void) { return pthread_equal(pthread_self(), main_thread); } #else static inline void log_lock(void) { } static inline void log_unlock(void) { } void main_thread_init(void) { } static int main_thread_self(void) { return 1; } #endif #ifdef HAVE_SYSLOG_H #include static int syslog_priorities[] = { LOG_DEBUG, LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_ERR, LOG_WARNING, LOG_ERR, LOG_ERR, LOG_CRIT, LOG_CRIT }; #endif static char *class_names[] = { "???", "DBG", "TRACE", "INFO", "RMT", "WARN", "ERR", "AUTH", "FATAL", "BUG" }; static inline off_t log_size(struct log_config *l) { struct stat st; return (!fstat(rf_fileno(l->rf), &st) && S_ISREG(st.st_mode)) ? st.st_size : 0; } static void log_close(struct log_config *l) { rfree(l->rf); l->rf = NULL; l->fh = NULL; } static int log_open(struct log_config *l) { l->rf = rf_open(config->pool, l->filename, "a"); if (!l->rf) { /* Well, we cannot do much in case of error as log is closed */ l->mask = 0; return -1; } l->fh = rf_file(l->rf); l->pos = log_size(l); return 0; } static int log_rotate(struct log_config *l) { log_close(l); /* If we cannot rename the logfile, we at least try to delete it in order to continue logging and not exceeding logfile size */ if ((rename(l->filename, l->backup) < 0) && (unlink(l->filename) < 0)) { l->mask = 0; return -1; } return log_open(l); } /** * log_commit - commit a log message * @class: message class information (%L_DEBUG to %L_BUG, see |lib/birdlib.h|) * @buf: message to write * * This function writes a message prepared in the log buffer to the * log file (as specified in the configuration). The log buffer is * reset after that. The log message is a full line, log_commit() * terminates it. * * The message class is an integer, not a first char of a string like * in log(), so it should be written like *L_INFO. */ void log_commit(int class, buffer *buf) { struct log_config *l; if (buf->pos == buf->end) strcpy(buf->end - 100, " ... "); log_lock(); WALK_LIST(l, *current_log_list) { if (!(l->mask & (1 << class))) continue; if (l->fh) { if (l->terminal_flag) fputs("bird: ", l->fh); else { byte tbuf[TM_DATETIME_BUFFER_SIZE]; const char *fmt = config ? config->tf_log.fmt1 : "%F %T.%3f"; if (!tm_format_real_time(tbuf, sizeof(tbuf), fmt, current_real_time())) strcpy(tbuf, ""); if (l->limit) { off_t msg_len = strlen(tbuf) + strlen(class_names[class]) + (buf->pos - buf->start) + 5; if (l->pos < 0) l->pos = log_size(l); if (l->pos + msg_len > l->limit) if (log_rotate(l) < 0) continue; l->pos += msg_len; } fprintf(l->fh, "%s <%s> ", tbuf, class_names[class]); } fputs(buf->start, l->fh); fputc('\n', l->fh); fflush(l->fh); } #ifdef HAVE_SYSLOG_H else syslog(syslog_priorities[class], "%s", buf->start); #endif } log_unlock(); /* cli_echo is not thread-safe, so call it just from the main thread */ if (main_thread_self()) cli_echo(class, buf->start); buf->pos = buf->start; } int buffer_vprint(buffer *buf, const char *fmt, va_list args); static void vlog(int class, const char *msg, va_list args) { buffer buf; LOG_BUFFER_INIT(buf); buffer_vprint(&buf, msg, args); log_commit(class, &buf); } /** * log - log a message * @msg: printf-like formatting string with message class information * prepended (%L_DEBUG to %L_BUG, see |lib/birdlib.h|) * * This function formats a message according to the format string @msg * and writes it to the corresponding log file (as specified in the * configuration). Please note that the message is automatically * formatted as a full line, no need to include |\n| inside. * It is essentially a sequence of log_reset(), logn() and log_commit(). */ void log_msg(const char *msg, ...) { int class = 1; va_list args; va_start(args, msg); if (*msg >= 1 && *msg <= 8) class = *msg++; vlog(class, msg, args); va_end(args); } void log_rl(struct tbf *f, const char *msg, ...) { int class = 1; va_list args; /* Rate limiting is a bit tricky here as it also logs '...' during the first hit */ if (tbf_limit(f) && (f->drop > 1)) return; if (*msg >= 1 && *msg <= 8) class = *msg++; va_start(args, msg); vlog(class, (f->drop ? "..." : msg), args); va_end(args); } /** * bug - report an internal error * @msg: a printf-like error message * * This function logs an internal error and aborts execution * of the program. */ void bug(const char *msg, ...) { va_list args; va_start(args, msg); vlog(L_BUG[0], msg, args); va_end(args); abort(); } /** * bug - report a fatal error * @msg: a printf-like error message * * This function logs a fatal error and aborts execution * of the program. */ void die(const char *msg, ...) { va_list args; va_start(args, msg); vlog(L_FATAL[0], msg, args); va_end(args); exit(1); } /** * debug - write to debug output * @msg: a printf-like message * * This function formats the message @msg and prints it out * to the debugging output. No newline character is appended. */ void debug(const char *msg, ...) { #define MAX_DEBUG_BUFSIZE 65536 va_list args; static uint bufsize = 4096; static char *buf = NULL; if (!buf) buf = mb_alloc(&root_pool, bufsize); va_start(args, msg); if (dbgf) { while (bvsnprintf(buf, bufsize, msg, args) < 0) if (bufsize >= MAX_DEBUG_BUFSIZE) bug("Extremely long debug output, split it."); else buf = mb_realloc(buf, (bufsize *= 2)); fputs(buf, dbgf); } va_end(args); } static list * default_log_list(int initial, const char **syslog_name) { static list log_list; init_list(&log_list); *syslog_name = NULL; #ifdef HAVE_SYSLOG_H if (!dbgf) { static struct log_config lc_syslog; lc_syslog = (struct log_config){ .mask = ~0 }; add_tail(&log_list, &lc_syslog.n); *syslog_name = bird_name; } #endif if (dbgf && (dbgf != stderr)) { static struct log_config lc_debug; lc_debug = (struct log_config){ .mask = ~0, .fh = dbgf }; add_tail(&log_list, &lc_debug.n); } if (initial || (dbgf == stderr)) { static struct log_config lc_stderr; lc_stderr = (struct log_config){ .mask = ~0, .terminal_flag = 1, .fh = stderr }; add_tail(&log_list, &lc_stderr.n); } return &log_list; } void log_switch(int initial, list *logs, const char *new_syslog_name) { struct log_config *l; /* We should not manipulate with log list when other threads may use it */ log_lock(); if (!logs || EMPTY_LIST(*logs)) logs = default_log_list(initial, &new_syslog_name); /* Close the logs to avoid pinning them on disk when deleted */ if (current_log_list) WALK_LIST(l, *current_log_list) if (l->rf) log_close(l); /* Reopen the logs, needed for 'configure undo' */ if (logs) WALK_LIST(l, *logs) if (l->filename && !l->rf) log_open(l); current_log_list = logs; #ifdef HAVE_SYSLOG_H if (!bstrcmp(current_syslog_name, new_syslog_name)) goto done; if (current_syslog_name) { closelog(); xfree(current_syslog_name); current_syslog_name = NULL; } if (new_syslog_name) { current_syslog_name = xstrdup(new_syslog_name); openlog(current_syslog_name, LOG_CONS | LOG_NDELAY, LOG_DAEMON); } #endif done: /* Logs exchange done, let the threads log as before */ log_unlock(); } void log_init_debug(char *f) { if (dbgf && dbgf != stderr) fclose(dbgf); if (!f) dbgf = NULL; else if (!*f) dbgf = stderr; else if (!(dbgf = fopen(f, "a"))) { /* Cannot use die() nor log() here, logging is not yet initialized */ fprintf(stderr, "bird: Unable to open debug file %s: %s\n", f, strerror(errno)); exit(1); } if (dbgf) setvbuf(dbgf, NULL, _IONBF, 0); } bird-2.0.8/sysdep/unix/krt.h0000664000175000017500000001070414025744326014631 0ustar feelafeela/* * BIRD -- UNIX Kernel Route Syncer * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_KRT_H_ #define _BIRD_KRT_H_ struct config; struct krt_config; struct krt_proto; struct kif_config; struct kif_proto; #include "nest/iface.h" #include "sysdep/config.h" #include CONFIG_INCLUDE_KRTSYS_H #define KRT_DEFAULT_ECMP_LIMIT 16 #define EA_KRT_SOURCE EA_CODE(PROTOCOL_KERNEL, 0) #define EA_KRT_METRIC EA_CODE(PROTOCOL_KERNEL, 1) /* Whenever we recognize our own routes, we allow learing of foreign routes */ #ifdef CONFIG_SELF_CONSCIOUS #define KRT_ALLOW_LEARN #endif /* krt.c */ extern struct protocol proto_unix_kernel; struct krt_config { struct proto_config c; struct krt_params sys; /* Sysdep params */ btime scan_time; /* How often we re-scan routes */ int persist; /* Keep routes when we exit */ int learn; /* Learn routes from other sources */ int graceful_restart; /* Regard graceful restart recovery */ int merge_paths; /* Exported routes are merged for ECMP */ }; struct krt_proto { struct proto p; struct krt_state sys; /* Sysdep state */ #ifdef KRT_ALLOW_LEARN struct rtable krt_table; /* Internal table of inherited routes */ #endif #ifndef CONFIG_ALL_TABLES_AT_ONCE timer *scan_timer; #endif struct bmap sync_map; /* Keeps track which exported routes were successfully written to kernel */ struct bmap seen_map; /* Routes seen during last periodic scan */ node krt_node; /* Node in krt_proto_list */ byte af; /* Kernel address family (AF_*) */ byte ready; /* Initial feed has been finished */ byte initialized; /* First scan has been finished */ byte reload; /* Next scan is doing reload */ }; extern pool *krt_pool; #define KRT_CF ((struct krt_config *)p->p.cf) #define KRT_TRACE(pr, fl, msg, args...) do { \ DBG("KRT: " msg "\n" , ## args); \ if (pr->p.debug & fl) \ { log(L_TRACE "%s: " msg, pr->p.name , ## args); } } while(0) struct proto_config * kif_init_config(int class); void kif_request_scan(void); void krt_got_route(struct krt_proto *p, struct rte *e); void krt_got_route_async(struct krt_proto *p, struct rte *e, int new); static inline int krt_get_sync_error(struct krt_proto *p, struct rte *e) { return (p->p.proto_state == PS_UP) && bmap_test(&p->p.main_channel->export_map, e->id) && !bmap_test(&p->sync_map, e->id); } /* Values for rte->u.krt_sync.src */ #define KRT_SRC_UNKNOWN -1 /* Nobody knows */ #define KRT_SRC_BIRD 0 /* Our route (not passed in async mode) */ #define KRT_SRC_REDIRECT 1 /* Redirect route, delete it */ #define KRT_SRC_ALIEN 2 /* Route installed by someone else */ #define KRT_SRC_KERNEL 3 /* Kernel routes, are ignored by krt syncer */ extern struct protocol proto_unix_iface; struct kif_config { struct proto_config c; struct kif_params sys; /* Sysdep params */ list iface_list; /* List of iface configs (struct kif_iface_config) */ btime scan_time; /* How often we re-scan interfaces */ }; struct kif_iface_config { struct iface_patt i; ip_addr pref_v4; ip_addr pref_v6; ip_addr pref_ll; }; struct kif_proto { struct proto p; struct kif_state sys; /* Sysdep state */ }; extern struct kif_proto *kif_proto; #define KIF_CF ((struct kif_config *)p->p.cf) struct kif_iface_config * kif_get_iface_config(struct iface *iface); struct proto_config * krt_init_config(int class); /* krt sysdep */ void krt_sys_io_init(void); void krt_sys_init(struct krt_proto *); int krt_sys_start(struct krt_proto *); void krt_sys_shutdown(struct krt_proto *); int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o); void krt_sys_preconfig(struct config *); void krt_sys_postconfig(struct krt_config *); void krt_sys_init_config(struct krt_config *); void krt_sys_copy_config(struct krt_config *, struct krt_config *); int krt_capable(rte *e); void krt_do_scan(struct krt_proto *); void krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old); int krt_sys_get_attr(const eattr *a, byte *buf, int buflen); /* kif sysdep */ void kif_sys_init(struct kif_proto *); void kif_sys_start(struct kif_proto *); void kif_sys_shutdown(struct kif_proto *); int kif_sys_reconfigure(struct kif_proto *, struct kif_config *, struct kif_config *); void kif_sys_init_config(struct kif_config *); void kif_sys_copy_config(struct kif_config *, struct kif_config *); void kif_do_scan(struct kif_proto *); int kif_update_sysdep_addr(struct iface *i); #endif bird-2.0.8/sysdep/unix/krt.c0000664000175000017500000006301014025744326014622 0ustar feelafeela/* * BIRD -- UNIX Kernel Synchronization * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Kernel synchronization * * This system dependent module implements the Kernel and Device protocol, * that is synchronization of interface lists and routing tables with the * OS kernel. * * The whole kernel synchronization is a bit messy and touches some internals * of the routing table engine, because routing table maintenance is a typical * example of the proverbial compatibility between different Unices and we want * to keep the overhead of our KRT business as low as possible and avoid maintaining * a local routing table copy. * * The kernel syncer can work in three different modes (according to system config header): * Either with a single routing table and single KRT protocol [traditional UNIX] * or with many routing tables and separate KRT protocols for all of them * or with many routing tables, but every scan including all tables, so we start * separate KRT protocols which cooperate with each other [Linux]. * In this case, we keep only a single scan timer. * * We use FIB node flags in the routing table to keep track of route * synchronization status. We also attach temporary &rte's to the routing table, * but it cannot do any harm to the rest of BIRD since table synchronization is * an atomic process. * * When starting up, we cheat by looking if there is another * KRT instance to be initialized later and performing table scan * only once for all the instances. * * The code uses OS-dependent parts for kernel updates and scans. These parts are * in more specific sysdep directories (e.g. sysdep/linux) in functions krt_sys_* * and kif_sys_* (and some others like krt_replace_rte()) and krt-sys.h header file. * This is also used for platform specific protocol options and route attributes. * * There was also an old code that used traditional UNIX ioctls for these tasks. * It was unmaintained and later removed. For reference, see sysdep/krt-* files * in commit 396dfa9042305f62da1f56589c4b98fac57fc2f6 */ /* * If you are brave enough, continue now. You cannot say you haven't been warned. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" #include "nest/route.h" #include "nest/protocol.h" #include "filter/filter.h" #include "conf/conf.h" #include "lib/string.h" #include "lib/timer.h" #include "unix.h" #include "krt.h" /* * Global resources */ pool *krt_pool; static linpool *krt_filter_lp; static list krt_proto_list; void krt_io_init(void) { krt_pool = rp_new(&root_pool, "Kernel Syncer"); krt_filter_lp = lp_new_default(krt_pool); init_list(&krt_proto_list); krt_sys_io_init(); } /* * Interfaces */ struct kif_proto *kif_proto; static struct kif_config *kif_cf; static timer *kif_scan_timer; static btime kif_last_shot; static struct kif_iface_config kif_default_iface = {}; struct kif_iface_config * kif_get_iface_config(struct iface *iface) { struct kif_config *cf = (void *) (kif_proto->p.cf); struct kif_iface_config *ic = (void *) iface_patt_find(&cf->iface_list, iface, NULL); return ic ?: &kif_default_iface; } static void kif_scan(timer *t) { struct kif_proto *p = t->data; KRT_TRACE(p, D_EVENTS, "Scanning interfaces"); kif_last_shot = current_time(); kif_do_scan(p); } static void kif_force_scan(void) { if (kif_proto && ((kif_last_shot + 2 S) < current_time())) { kif_scan(kif_scan_timer); tm_start(kif_scan_timer, ((struct kif_config *) kif_proto->p.cf)->scan_time); } } void kif_request_scan(void) { if (kif_proto && (kif_scan_timer->expires > (current_time() + 1 S))) tm_start(kif_scan_timer, 1 S); } static struct proto * kif_init(struct proto_config *c) { struct kif_proto *p = proto_new(c); kif_sys_init(p); return &p->p; } static int kif_start(struct proto *P) { struct kif_proto *p = (struct kif_proto *) P; kif_proto = p; kif_sys_start(p); /* Start periodic interface scanning */ kif_scan_timer = tm_new_init(P->pool, kif_scan, p, KIF_CF->scan_time, 0); kif_scan(kif_scan_timer); tm_start(kif_scan_timer, KIF_CF->scan_time); return PS_UP; } static int kif_shutdown(struct proto *P) { struct kif_proto *p = (struct kif_proto *) P; tm_stop(kif_scan_timer); kif_sys_shutdown(p); kif_proto = NULL; return PS_DOWN; } static int kif_reconfigure(struct proto *p, struct proto_config *new) { struct kif_config *o = (struct kif_config *) p->cf; struct kif_config *n = (struct kif_config *) new; if (!kif_sys_reconfigure((struct kif_proto *) p, n, o)) return 0; if (o->scan_time != n->scan_time) { tm_stop(kif_scan_timer); kif_scan_timer->recurrent = n->scan_time; kif_scan(kif_scan_timer); tm_start(kif_scan_timer, n->scan_time); } if (!EMPTY_LIST(o->iface_list) || !EMPTY_LIST(n->iface_list)) { /* This is hack, we have to update a configuration * to the new value just now, because it is used * for recalculation of preferred addresses. */ p->cf = new; if_recalc_all_preferred_addresses(); } return 1; } static void kif_preconfig(struct protocol *P UNUSED, struct config *c) { kif_cf = NULL; kif_sys_preconfig(c); } struct proto_config * kif_init_config(int class) { if (kif_cf) cf_error("Kernel device protocol already defined"); kif_cf = (struct kif_config *) proto_config_new(&proto_unix_iface, class); kif_cf->scan_time = 60 S; init_list(&kif_cf->iface_list); kif_sys_init_config(kif_cf); return (struct proto_config *) kif_cf; } static void kif_copy_config(struct proto_config *dest, struct proto_config *src) { struct kif_config *d = (struct kif_config *) dest; struct kif_config *s = (struct kif_config *) src; /* Copy interface config list */ cfg_copy_list(&d->iface_list, &s->iface_list, sizeof(struct kif_iface_config)); /* Fix sysdep parts */ kif_sys_copy_config(d, s); } struct protocol proto_unix_iface = { .name = "Device", .template = "device%d", .class = PROTOCOL_DEVICE, .proto_size = sizeof(struct kif_proto), .config_size = sizeof(struct kif_config), .preconfig = kif_preconfig, .init = kif_init, .start = kif_start, .shutdown = kif_shutdown, .reconfigure = kif_reconfigure, .copy_config = kif_copy_config }; /* * Tracing of routes */ static inline void krt_trace_in(struct krt_proto *p, rte *e, char *msg) { if (p->p.debug & D_PACKETS) log(L_TRACE "%s: %N: %s", p->p.name, e->net->n.addr, msg); } static inline void krt_trace_in_rl(struct tbf *f, struct krt_proto *p, rte *e, char *msg) { if (p->p.debug & D_PACKETS) log_rl(f, L_TRACE "%s: %N: %s", p->p.name, e->net->n.addr, msg); } /* * Inherited Routes */ #ifdef KRT_ALLOW_LEARN static struct tbf rl_alien = TBF_DEFAULT_LOG_LIMITS; /* * krt_same_key() specifies what (aside from the net) is the key in * kernel routing tables. It should be OS-dependent, this is for * Linux. It is important for asynchronous alien updates, because a * positive update is implicitly a negative one for any old route with * the same key. */ static inline int krt_same_key(rte *a, rte *b) { return a->u.krt.metric == b->u.krt.metric; } static inline int krt_uptodate(rte *a, rte *b) { if (a->attrs != b->attrs) return 0; if (a->u.krt.proto != b->u.krt.proto) return 0; return 1; } static void krt_learn_announce_update(struct krt_proto *p, rte *e) { net *n = e->net; rta *aa = rta_clone(e->attrs); rte *ee = rte_get_temp(aa); ee->pflags = EA_ID_FLAG(EA_KRT_SOURCE) | EA_ID_FLAG(EA_KRT_METRIC); ee->u.krt = e->u.krt; rte_update(&p->p, n->n.addr, ee); } static void krt_learn_announce_delete(struct krt_proto *p, net *n) { rte_update(&p->p, n->n.addr, NULL); } /* Called when alien route is discovered during scan */ static void krt_learn_scan(struct krt_proto *p, rte *e) { net *n0 = e->net; net *n = net_get(&p->krt_table, n0->n.addr); rte *m, **mm; e->attrs = rta_lookup(e->attrs); for(mm=&n->routes; m = *mm; mm=&m->next) if (krt_same_key(m, e)) break; if (m) { if (krt_uptodate(m, e)) { krt_trace_in_rl(&rl_alien, p, e, "[alien] seen"); rte_free(e); m->u.krt.seen = 1; } else { krt_trace_in(p, e, "[alien] updated"); *mm = m->next; rte_free(m); m = NULL; } } else krt_trace_in(p, e, "[alien] created"); if (!m) { e->next = n->routes; n->routes = e; e->u.krt.seen = 1; } } static void krt_learn_prune(struct krt_proto *p) { struct fib *fib = &p->krt_table.fib; struct fib_iterator fit; KRT_TRACE(p, D_EVENTS, "Pruning inherited routes"); FIB_ITERATE_INIT(&fit, fib); again: FIB_ITERATE_START(fib, &fit, net, n) { rte *e, **ee, *best, **pbest, *old_best; /* * Note that old_best may be NULL even if there was an old best route in * the previous step, because it might be replaced in krt_learn_scan(). * But in that case there is a new valid best route. */ old_best = NULL; best = NULL; pbest = NULL; ee = &n->routes; while (e = *ee) { if (e->u.krt.best) old_best = e; if (!e->u.krt.seen) { *ee = e->next; rte_free(e); continue; } if (!best || best->u.krt.metric > e->u.krt.metric) { best = e; pbest = ee; } e->u.krt.seen = 0; e->u.krt.best = 0; ee = &e->next; } if (!n->routes) { DBG("%I/%d: deleting\n", n->n.prefix, n->n.pxlen); if (old_best) krt_learn_announce_delete(p, n); FIB_ITERATE_PUT(&fit); fib_delete(fib, n); goto again; } best->u.krt.best = 1; *pbest = best->next; best->next = n->routes; n->routes = best; if ((best != old_best) || p->reload) { DBG("%I/%d: announcing (metric=%d)\n", n->n.prefix, n->n.pxlen, best->u.krt.metric); krt_learn_announce_update(p, best); } else DBG("%I/%d: uptodate (metric=%d)\n", n->n.prefix, n->n.pxlen, best->u.krt.metric); } FIB_ITERATE_END; p->reload = 0; } static void krt_learn_async(struct krt_proto *p, rte *e, int new) { net *n0 = e->net; net *n = net_get(&p->krt_table, n0->n.addr); rte *g, **gg, *best, **bestp, *old_best; e->attrs = rta_lookup(e->attrs); old_best = n->routes; for(gg=&n->routes; g = *gg; gg = &g->next) if (krt_same_key(g, e)) break; if (new) { if (g) { if (krt_uptodate(g, e)) { krt_trace_in(p, e, "[alien async] same"); rte_free(e); return; } krt_trace_in(p, e, "[alien async] updated"); *gg = g->next; rte_free(g); } else krt_trace_in(p, e, "[alien async] created"); e->next = n->routes; n->routes = e; } else if (!g) { krt_trace_in(p, e, "[alien async] delete failed"); rte_free(e); return; } else { krt_trace_in(p, e, "[alien async] removed"); *gg = g->next; rte_free(e); rte_free(g); } best = n->routes; bestp = &n->routes; for(gg=&n->routes; g=*gg; gg=&g->next) { if (best->u.krt.metric > g->u.krt.metric) { best = g; bestp = gg; } g->u.krt.best = 0; } if (best) { best->u.krt.best = 1; *bestp = best->next; best->next = n->routes; n->routes = best; } if (best != old_best) { DBG("krt_learn_async: distributing change\n"); if (best) krt_learn_announce_update(p, best); else krt_learn_announce_delete(p, n); } } static void krt_learn_init(struct krt_proto *p) { if (KRT_CF->learn) { struct rtable_config *cf = mb_allocz(p->p.pool, sizeof(struct rtable_config)); cf->name = "Inherited"; cf->addr_type = p->p.net_type; rt_setup(p->p.pool, &p->krt_table, cf); } } static void krt_dump(struct proto *P) { struct krt_proto *p = (struct krt_proto *) P; if (!KRT_CF->learn) return; debug("KRT: Table of inheritable routes\n"); rt_dump(&p->krt_table); } static void krt_dump_attrs(rte *e) { debug(" [m=%d,p=%d]", e->u.krt.metric, e->u.krt.proto); } #endif /* * Routes */ static inline int krt_is_installed(struct krt_proto *p, net *n) { return n->routes && bmap_test(&p->p.main_channel->export_map, n->routes->id); } static void krt_flush_routes(struct krt_proto *p) { struct rtable *t = p->p.main_channel->table; KRT_TRACE(p, D_EVENTS, "Flushing kernel routes"); FIB_WALK(&t->fib, net, n) { if (krt_is_installed(p, n)) { /* FIXME: this does not work if gw is changed in export filter */ krt_replace_rte(p, n, NULL, n->routes); } } FIB_WALK_END; } static struct rte * krt_export_net(struct krt_proto *p, net *net, rte **rt_free) { struct channel *c = p->p.main_channel; const struct filter *filter = c->out_filter; rte *rt; if (c->ra_mode == RA_MERGED) return rt_export_merged(c, net, rt_free, krt_filter_lp, 1); rt = net->routes; *rt_free = NULL; if (!rte_is_valid(rt)) return NULL; if (filter == FILTER_REJECT) return NULL; rte_make_tmp_attrs(&rt, krt_filter_lp, NULL); /* We could run krt_preexport() here, but it is already handled by krt_is_installed() */ if (filter == FILTER_ACCEPT) goto accept; if (f_run(filter, &rt, krt_filter_lp, FF_SILENT) > F_ACCEPT) goto reject; accept: if (rt != net->routes) *rt_free = rt; return rt; reject: if (rt != net->routes) rte_free(rt); return NULL; } static int krt_same_dest(rte *k, rte *e) { rta *ka = k->attrs, *ea = e->attrs; if (ka->dest != ea->dest) return 0; if (ka->dest == RTD_UNICAST) return nexthop_same(&(ka->nh), &(ea->nh)); return 1; } /* * This gets called back when the low-level scanning code discovers a route. * We expect that the route is a temporary rte and its attributes are uncached. */ void krt_got_route(struct krt_proto *p, rte *e) { rte *new = NULL, *rt_free = NULL; net *n = e->net; #ifdef KRT_ALLOW_LEARN switch (e->u.krt.src) { case KRT_SRC_KERNEL: goto ignore; case KRT_SRC_REDIRECT: goto delete; case KRT_SRC_ALIEN: if (KRT_CF->learn) krt_learn_scan(p, e); else { krt_trace_in_rl(&rl_alien, p, e, "[alien] ignored"); rte_free(e); } return; } #endif /* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */ /* We wait for the initial feed to have correct installed state */ if (!p->ready) goto ignore; if (!krt_is_installed(p, n)) goto delete; new = krt_export_net(p, n, &rt_free); /* Rejected by filters */ if (!new) goto delete; /* Route to this destination was already seen. Strange, but it happens... */ if (bmap_test(&p->seen_map, new->id)) goto aseen; /* Mark route as seen */ bmap_set(&p->seen_map, new->id); /* TODO: There also may be changes in route eattrs, we ignore that for now. */ if (!bmap_test(&p->sync_map, new->id) || !krt_same_dest(e, new)) goto update; goto seen; seen: krt_trace_in(p, e, "seen"); goto done; aseen: krt_trace_in(p, e, "already seen"); goto done; ignore: krt_trace_in(p, e, "ignored"); goto done; update: krt_trace_in(p, new, "updating"); krt_replace_rte(p, n, new, e); goto done; delete: krt_trace_in(p, e, "deleting"); krt_replace_rte(p, n, NULL, e); goto done; done: rte_free(e); if (rt_free) rte_free(rt_free); lp_flush(krt_filter_lp); } static void krt_init_scan(struct krt_proto *p) { bmap_reset(&p->seen_map, 1024); } static void krt_prune(struct krt_proto *p) { struct rtable *t = p->p.main_channel->table; KRT_TRACE(p, D_EVENTS, "Pruning table %s", t->name); FIB_WALK(&t->fib, net, n) { if (p->ready && krt_is_installed(p, n) && !bmap_test(&p->seen_map, n->routes->id)) { rte *rt_free = NULL; rte *new = krt_export_net(p, n, &rt_free); if (new) { krt_trace_in(p, new, "installing"); krt_replace_rte(p, n, new, NULL); } if (rt_free) rte_free(rt_free); lp_flush(krt_filter_lp); } } FIB_WALK_END; #ifdef KRT_ALLOW_LEARN if (KRT_CF->learn) krt_learn_prune(p); #endif if (p->ready) p->initialized = 1; } void krt_got_route_async(struct krt_proto *p, rte *e, int new) { net *net = e->net; switch (e->u.krt.src) { case KRT_SRC_BIRD: /* Should be filtered by the back end */ bug("BIRD originated routes should not get here."); case KRT_SRC_REDIRECT: if (new) { krt_trace_in(p, e, "[redirect] deleting"); krt_replace_rte(p, net, NULL, e); } /* If !new, it is probably echo of our deletion */ break; #ifdef KRT_ALLOW_LEARN case KRT_SRC_ALIEN: if (KRT_CF->learn) { krt_learn_async(p, e, new); return; } #endif } rte_free(e); } /* * Periodic scanning */ #ifdef CONFIG_ALL_TABLES_AT_ONCE static timer *krt_scan_timer; static int krt_scan_count; static void krt_scan(timer *t UNUSED) { struct krt_proto *p; node *n; kif_force_scan(); /* We need some node to decide whether to print the debug messages or not */ p = SKIP_BACK(struct krt_proto, krt_node, HEAD(krt_proto_list)); KRT_TRACE(p, D_EVENTS, "Scanning routing table"); WALK_LIST2(p, n, krt_proto_list, krt_node) krt_init_scan(p); krt_do_scan(NULL); WALK_LIST2(p, n, krt_proto_list, krt_node) krt_prune(p); } static void krt_scan_timer_start(struct krt_proto *p) { if (!krt_scan_count) krt_scan_timer = tm_new_init(krt_pool, krt_scan, NULL, KRT_CF->scan_time, 0); krt_scan_count++; tm_start(krt_scan_timer, 1 S); } static void krt_scan_timer_stop(struct krt_proto *p UNUSED) { krt_scan_count--; if (!krt_scan_count) { rfree(krt_scan_timer); krt_scan_timer = NULL; } } static void krt_scan_timer_kick(struct krt_proto *p UNUSED) { tm_start(krt_scan_timer, 0); } #else static void krt_scan(timer *t) { struct krt_proto *p = t->data; kif_force_scan(); KRT_TRACE(p, D_EVENTS, "Scanning routing table"); krt_init_scan(p); krt_do_scan(p); krt_prune(p); } static void krt_scan_timer_start(struct krt_proto *p) { p->scan_timer = tm_new_init(p->p.pool, krt_scan, p, KRT_CF->scan_time, 0); tm_start(p->scan_timer, 1 S); } static void krt_scan_timer_stop(struct krt_proto *p) { tm_stop(p->scan_timer); } static void krt_scan_timer_kick(struct krt_proto *p) { tm_start(p->scan_timer, 0); } #endif /* * Updates */ static void krt_make_tmp_attrs(struct rte *rt, struct linpool *pool) { rte_init_tmp_attrs(rt, pool, 2); rte_make_tmp_attr(rt, EA_KRT_SOURCE, EAF_TYPE_INT, rt->u.krt.proto); rte_make_tmp_attr(rt, EA_KRT_METRIC, EAF_TYPE_INT, rt->u.krt.metric); } static void krt_store_tmp_attrs(struct rte *rt, struct linpool *pool) { rte_init_tmp_attrs(rt, pool, 2); rt->u.krt.proto = rte_store_tmp_attr(rt, EA_KRT_SOURCE); rt->u.krt.metric = rte_store_tmp_attr(rt, EA_KRT_METRIC); } static int krt_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED) { // struct krt_proto *p = (struct krt_proto *) P; rte *e = *new; if (e->attrs->src->proto == P) return -1; if (!krt_capable(e)) return -1; return 0; } static void krt_rt_notify(struct proto *P, struct channel *ch UNUSED, net *net, rte *new, rte *old) { struct krt_proto *p = (struct krt_proto *) P; if (config->shutdown) return; #ifdef CONFIG_SINGLE_ROUTE /* * Implicit withdraw - when the imported kernel route becomes the best one, * we know that the previous one exported to the kernel was already removed, * but if we processed the update as usual, we would send withdraw to the * kernel, which would remove the new imported route instead. */ rte *best = net->routes; if (!new && best && (best->attrs->src->proto == P)) return; #endif if (p->initialized) /* Before first scan we don't touch the routes */ krt_replace_rte(p, net, new, old); } static void krt_if_notify(struct proto *P, uint flags, struct iface *iface UNUSED) { struct krt_proto *p = (struct krt_proto *) P; /* * When interface went down, we should remove routes to it. In the ideal world, * OS kernel would send us route removal notifications in such cases, but we * cannot rely on it as it is often not true. E.g. Linux kernel removes related * routes when an interface went down, but it does not notify userspace about * that. To be sure, we just schedule a scan to ensure synchronization. */ if ((flags & IF_CHANGE_DOWN) && KRT_CF->learn) krt_scan_timer_kick(p); } static void krt_reload_routes(struct channel *C) { struct krt_proto *p = (void *) C->proto; /* Although we keep learned routes in krt_table, we rather schedule a scan */ if (KRT_CF->learn) { p->reload = 1; krt_scan_timer_kick(p); } } static void krt_feed_end(struct channel *C) { struct krt_proto *p = (void *) C->proto; p->ready = 1; krt_scan_timer_kick(p); } static int krt_rte_same(rte *a, rte *b) { /* src is always KRT_SRC_ALIEN and type is irrelevant */ return (a->u.krt.proto == b->u.krt.proto) && (a->u.krt.metric == b->u.krt.metric); } /* * Protocol glue */ struct krt_config *krt_cf; static void krt_preconfig(struct protocol *P UNUSED, struct config *c) { krt_cf = NULL; krt_sys_preconfig(c); } static void krt_postconfig(struct proto_config *CF) { struct krt_config *cf = (void *) CF; /* Do not check templates at all */ if (cf->c.class == SYM_TEMPLATE) return; if (EMPTY_LIST(CF->channels)) cf_error("Channel not specified"); #ifdef CONFIG_ALL_TABLES_AT_ONCE if (krt_cf->scan_time != cf->scan_time) cf_error("All kernel syncers must use the same table scan interval"); #endif struct channel_config *cc = proto_cf_main_channel(CF); struct rtable_config *tab = cc->table; if (tab->krt_attached) cf_error("Kernel syncer (%s) already attached to table %s", tab->krt_attached->name, tab->name); tab->krt_attached = CF; if (cf->merge_paths) { cc->ra_mode = RA_MERGED; cc->merge_limit = cf->merge_paths; } krt_sys_postconfig(cf); } static struct proto * krt_init(struct proto_config *CF) { struct krt_proto *p = proto_new(CF); // struct krt_config *cf = (void *) CF; p->p.main_channel = proto_add_channel(&p->p, proto_cf_main_channel(CF)); p->p.preexport = krt_preexport; p->p.rt_notify = krt_rt_notify; p->p.if_notify = krt_if_notify; p->p.reload_routes = krt_reload_routes; p->p.feed_end = krt_feed_end; p->p.make_tmp_attrs = krt_make_tmp_attrs; p->p.store_tmp_attrs = krt_store_tmp_attrs; p->p.rte_same = krt_rte_same; krt_sys_init(p); return &p->p; } static int krt_start(struct proto *P) { struct krt_proto *p = (struct krt_proto *) P; switch (p->p.net_type) { case NET_IP4: p->af = AF_INET; break; case NET_IP6: p->af = AF_INET6; break; case NET_IP6_SADR: p->af = AF_INET6; break; #ifdef AF_MPLS case NET_MPLS: p->af = AF_MPLS; break; #endif default: log(L_ERR "KRT: Tried to start with strange net type: %d", p->p.net_type); return PS_START; break; } bmap_init(&p->sync_map, p->p.pool, 1024); bmap_init(&p->seen_map, p->p.pool, 1024); add_tail(&krt_proto_list, &p->krt_node); #ifdef KRT_ALLOW_LEARN krt_learn_init(p); #endif if (!krt_sys_start(p)) { rem_node(&p->krt_node); return PS_START; } krt_scan_timer_start(p); if (p->p.gr_recovery && KRT_CF->graceful_restart) p->p.main_channel->gr_wait = 1; return PS_UP; } static int krt_shutdown(struct proto *P) { struct krt_proto *p = (struct krt_proto *) P; krt_scan_timer_stop(p); /* FIXME we should flush routes even when persist during reconfiguration */ if (p->initialized && !KRT_CF->persist && (P->down_code != PDC_CMD_GR_DOWN)) krt_flush_routes(p); p->ready = 0; p->initialized = 0; if (p->p.proto_state == PS_START) return PS_DOWN; krt_sys_shutdown(p); rem_node(&p->krt_node); bmap_free(&p->sync_map); return PS_DOWN; } static int krt_reconfigure(struct proto *p, struct proto_config *CF) { struct krt_config *o = (void *) p->cf; struct krt_config *n = (void *) CF; if (!proto_configure_channel(p, &p->main_channel, proto_cf_main_channel(CF))) return 0; if (!krt_sys_reconfigure((struct krt_proto *) p, n, o)) return 0; /* persist, graceful restart need not be the same */ return o->scan_time == n->scan_time && o->learn == n->learn; } struct proto_config * krt_init_config(int class) { #ifndef CONFIG_MULTIPLE_TABLES if (krt_cf) cf_error("Kernel protocol already defined"); #endif krt_cf = (struct krt_config *) proto_config_new(&proto_unix_kernel, class); krt_cf->scan_time = 60 S; krt_sys_init_config(krt_cf); return (struct proto_config *) krt_cf; } static void krt_copy_config(struct proto_config *dest, struct proto_config *src) { struct krt_config *d = (struct krt_config *) dest; struct krt_config *s = (struct krt_config *) src; /* Fix sysdep parts */ krt_sys_copy_config(d, s); } static int krt_get_attr(const eattr *a, byte *buf, int buflen) { switch (a->id) { case EA_KRT_SOURCE: bsprintf(buf, "source"); return GA_NAME; case EA_KRT_METRIC: bsprintf(buf, "metric"); return GA_NAME; default: return krt_sys_get_attr(a, buf, buflen); } } #ifdef CONFIG_IP6_SADR_KERNEL #define MAYBE_IP6_SADR NB_IP6_SADR #else #define MAYBE_IP6_SADR 0 #endif #ifdef HAVE_MPLS_KERNEL #define MAYBE_MPLS NB_MPLS #else #define MAYBE_MPLS 0 #endif struct protocol proto_unix_kernel = { .name = "Kernel", .template = "kernel%d", .class = PROTOCOL_KERNEL, .preference = DEF_PREF_INHERITED, .channel_mask = NB_IP | MAYBE_IP6_SADR | MAYBE_MPLS, .proto_size = sizeof(struct krt_proto), .config_size = sizeof(struct krt_config), .preconfig = krt_preconfig, .postconfig = krt_postconfig, .init = krt_init, .start = krt_start, .shutdown = krt_shutdown, .reconfigure = krt_reconfigure, .copy_config = krt_copy_config, .get_attr = krt_get_attr, #ifdef KRT_ALLOW_LEARN .dump = krt_dump, .dump_attrs = krt_dump_attrs, #endif }; bird-2.0.8/sysdep/unix/krt.Y0000664000175000017500000000547714025744326014625 0ustar feelafeela/* * BIRD -- UNIX Kernel Syncer Configuration * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "sysdep/unix/krt.h" CF_DEFINES #define THIS_KRT ((struct krt_config *) this_proto) #define THIS_KIF ((struct kif_config *) this_proto) #define KIF_IFACE ((struct kif_iface_config *) this_ipatt) static void kif_set_preferred(ip_addr ip) { if (ipa_is_ip4(ip)) KIF_IFACE->pref_v4 = ip; else if (!ipa_is_link_local(ip)) KIF_IFACE->pref_v6 = ip; else KIF_IFACE->pref_ll = ip; } CF_DECLS CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS) CF_KEYWORDS(INTERFACE, PREFERRED) %type kern_mp_limit CF_GRAMMAR /* Kernel syncer protocol */ proto: kern_proto '}' ; kern_proto_start: proto_start KERNEL { this_proto = krt_init_config($1); } ; kern_proto: kern_proto_start proto_name '{' ; kern_proto: kern_proto kern_item ';' ; kern_mp_limit: /* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; } | LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error("Merge paths limit must be in range 1-255"); } ; kern_item: proto_item | proto_channel { this_proto->net_type = $1->net_type; } | PERSIST bool { THIS_KRT->persist = $2; } | SCAN TIME expr { /* Scan time of 0 means scan on startup only */ THIS_KRT->scan_time = $3 S_; } | LEARN bool { THIS_KRT->learn = $2; #ifndef KRT_ALLOW_LEARN if ($2) cf_error("Learning of kernel routes not supported on this platform"); #endif } | GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; } | MERGE PATHS bool kern_mp_limit { THIS_KRT->merge_paths = $3 ? $4 : 0; #ifndef KRT_ALLOW_MERGE_PATHS if ($3) cf_error("Path merging not supported on this platform"); #endif } ; /* Kernel interface protocol */ proto: kif_proto '}' ; kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); } ; kif_proto: kif_proto_start proto_name '{' ; kif_proto: kif_proto kif_item ';' ; kif_item: proto_item | INTERFACE kif_iface | SCAN TIME expr { /* Scan time of 0 means scan on startup only */ THIS_KIF->scan_time = $3 S_; } ; kif_iface_start: { this_ipatt = cfg_allocz(sizeof(struct kif_iface_config)); add_tail(&THIS_KIF->iface_list, NODE this_ipatt); init_list(&this_ipatt->ipn_list); } kif_iface_item: PREFERRED ipa { kif_set_preferred($2); } ; kif_iface_opts: /* empty */ | kif_iface_opts kif_iface_item ';' ; kif_iface_opt_list: /* empty */ | '{' kif_iface_opts '}' ; kif_iface: kif_iface_start iface_patt_list_nopx kif_iface_opt_list; dynamic_attr: KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SOURCE); } ; dynamic_attr: KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_METRIC); } ; CF_CODE CF_END bird-2.0.8/sysdep/unix/io.c0000664000175000017500000014105014025744326014432 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Unix I/O * * (c) 1998--2004 Martin Mares * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ /* Unfortunately, some glibc versions hide parts of RFC 3542 API if _GNU_SOURCE is not defined. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/event.h" #include "lib/timer.h" #include "lib/string.h" #include "nest/iface.h" #include "conf/conf.h" #include "sysdep/unix/unix.h" #include CONFIG_INCLUDE_SYSIO_H /* Maximum number of calls of tx handler for one socket in one * poll iteration. Should be small enough to not monopolize CPU by * one protocol instance. */ #define MAX_STEPS 4 /* Maximum number of calls of rx handler for all sockets in one poll iteration. RX callbacks are often much more costly so we limit this to gen small latencies */ #define MAX_RX_STEPS 4 /* * Tracked Files */ struct rfile { resource r; FILE *f; }; static void rf_free(resource *r) { struct rfile *a = (struct rfile *) r; fclose(a->f); } static void rf_dump(resource *r) { struct rfile *a = (struct rfile *) r; debug("(FILE *%p)\n", a->f); } static struct resclass rf_class = { "FILE", sizeof(struct rfile), rf_free, rf_dump, NULL, NULL }; struct rfile * rf_open(pool *p, const char *name, const char *mode) { FILE *f = fopen(name, mode); if (!f) return NULL; struct rfile *r = ralloc(p, &rf_class); r->f = f; return r; } void * rf_file(struct rfile *f) { return f->f; } int rf_fileno(struct rfile *f) { return fileno(f->f); } /* * Time clock */ btime boot_time; void times_init(struct timeloop *loop) { struct timespec ts; int rv; rv = clock_gettime(CLOCK_MONOTONIC, &ts); if (rv < 0) die("Monotonic clock is missing"); if ((ts.tv_sec < 0) || (((u64) ts.tv_sec) > ((u64) 1 << 40))) log(L_WARN "Monotonic clock is crazy"); loop->last_time = ts.tv_sec S + ts.tv_nsec NS; loop->real_time = 0; } void times_update(struct timeloop *loop) { struct timespec ts; int rv; rv = clock_gettime(CLOCK_MONOTONIC, &ts); if (rv < 0) die("clock_gettime: %m"); btime new_time = ts.tv_sec S + ts.tv_nsec NS; if (new_time < loop->last_time) log(L_ERR "Monotonic clock is broken"); loop->last_time = new_time; loop->real_time = 0; } void times_update_real_time(struct timeloop *loop) { struct timespec ts; int rv; rv = clock_gettime(CLOCK_REALTIME, &ts); if (rv < 0) die("clock_gettime: %m"); loop->real_time = ts.tv_sec S + ts.tv_nsec NS; } /** * DOC: Sockets * * Socket resources represent network connections. Their data structure (&socket) * contains a lot of fields defining the exact type of the socket, the local and * remote addresses and ports, pointers to socket buffers and finally pointers to * hook functions to be called when new data have arrived to the receive buffer * (@rx_hook), when the contents of the transmit buffer have been transmitted * (@tx_hook) and when an error or connection close occurs (@err_hook). * * Freeing of sockets from inside socket hooks is perfectly safe. */ #ifndef SOL_IP #define SOL_IP IPPROTO_IP #endif #ifndef SOL_IPV6 #define SOL_IPV6 IPPROTO_IPV6 #endif #ifndef SOL_ICMPV6 #define SOL_ICMPV6 IPPROTO_ICMPV6 #endif /* * Sockaddr helper functions */ static inline int UNUSED sockaddr_length(int af) { return (af == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); } static inline void sockaddr_fill4(struct sockaddr_in *sa, ip_addr a, uint port) { memset(sa, 0, sizeof(struct sockaddr_in)); #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN sa->sin_len = sizeof(struct sockaddr_in); #endif sa->sin_family = AF_INET; sa->sin_port = htons(port); sa->sin_addr = ipa_to_in4(a); } static inline void sockaddr_fill6(struct sockaddr_in6 *sa, ip_addr a, struct iface *ifa, uint port) { memset(sa, 0, sizeof(struct sockaddr_in6)); #ifdef SIN6_LEN sa->sin6_len = sizeof(struct sockaddr_in6); #endif sa->sin6_family = AF_INET6; sa->sin6_port = htons(port); sa->sin6_flowinfo = 0; sa->sin6_addr = ipa_to_in6(a); if (ifa && ipa_is_link_local(a)) sa->sin6_scope_id = ifa->index; } void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port) { if (af == AF_INET) sockaddr_fill4((struct sockaddr_in *) sa, a, port); else if (af == AF_INET6) sockaddr_fill6((struct sockaddr_in6 *) sa, a, ifa, port); else bug("Unknown AF"); } static inline void sockaddr_read4(struct sockaddr_in *sa, ip_addr *a, uint *port) { *port = ntohs(sa->sin_port); *a = ipa_from_in4(sa->sin_addr); } static inline void sockaddr_read6(struct sockaddr_in6 *sa, ip_addr *a, struct iface **ifa, uint *port) { *port = ntohs(sa->sin6_port); *a = ipa_from_in6(sa->sin6_addr); if (ifa && ipa_is_link_local(*a)) *ifa = if_find_by_index(sa->sin6_scope_id); } int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port) { if (sa->sa.sa_family != af) goto fail; if (af == AF_INET) sockaddr_read4((struct sockaddr_in *) sa, a, port); else if (af == AF_INET6) sockaddr_read6((struct sockaddr_in6 *) sa, a, ifa, port); else goto fail; return 0; fail: *a = IPA_NONE; *port = 0; return -1; } /* * IPv6 multicast syscalls */ /* Fortunately standardized in RFC 3493 */ #define INIT_MREQ6(maddr,ifa) \ { .ipv6mr_multiaddr = ipa_to_in6(maddr), .ipv6mr_interface = ifa->index } static inline int sk_setup_multicast6(sock *s) { int index = s->iface->index; int ttl = s->ttl; int n = 0; if (setsockopt(s->fd, SOL_IPV6, IPV6_MULTICAST_IF, &index, sizeof(index)) < 0) ERR("IPV6_MULTICAST_IF"); if (setsockopt(s->fd, SOL_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)) < 0) ERR("IPV6_MULTICAST_HOPS"); if (setsockopt(s->fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &n, sizeof(n)) < 0) ERR("IPV6_MULTICAST_LOOP"); return 0; } static inline int sk_join_group6(sock *s, ip_addr maddr) { struct ipv6_mreq mr = INIT_MREQ6(maddr, s->iface); if (setsockopt(s->fd, SOL_IPV6, IPV6_JOIN_GROUP, &mr, sizeof(mr)) < 0) ERR("IPV6_JOIN_GROUP"); return 0; } static inline int sk_leave_group6(sock *s, ip_addr maddr) { struct ipv6_mreq mr = INIT_MREQ6(maddr, s->iface); if (setsockopt(s->fd, SOL_IPV6, IPV6_LEAVE_GROUP, &mr, sizeof(mr)) < 0) ERR("IPV6_LEAVE_GROUP"); return 0; } /* * IPv6 packet control messages */ /* Also standardized, in RFC 3542 */ /* * RFC 2292 uses IPV6_PKTINFO for both the socket option and the cmsg * type, RFC 3542 changed the socket option to IPV6_RECVPKTINFO. If we * don't have IPV6_RECVPKTINFO we suppose the OS implements the older * RFC and we use IPV6_PKTINFO. */ #ifndef IPV6_RECVPKTINFO #define IPV6_RECVPKTINFO IPV6_PKTINFO #endif /* * Same goes for IPV6_HOPLIMIT -> IPV6_RECVHOPLIMIT. */ #ifndef IPV6_RECVHOPLIMIT #define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT #endif #define CMSG6_SPACE_PKTINFO CMSG_SPACE(sizeof(struct in6_pktinfo)) #define CMSG6_SPACE_TTL CMSG_SPACE(sizeof(int)) static inline int sk_request_cmsg6_pktinfo(sock *s) { int y = 1; if (setsockopt(s->fd, SOL_IPV6, IPV6_RECVPKTINFO, &y, sizeof(y)) < 0) ERR("IPV6_RECVPKTINFO"); return 0; } static inline int sk_request_cmsg6_ttl(sock *s) { int y = 1; if (setsockopt(s->fd, SOL_IPV6, IPV6_RECVHOPLIMIT, &y, sizeof(y)) < 0) ERR("IPV6_RECVHOPLIMIT"); return 0; } static inline void sk_process_cmsg6_pktinfo(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IPV6_PKTINFO) { struct in6_pktinfo *pi = (struct in6_pktinfo *) CMSG_DATA(cm); s->laddr = ipa_from_in6(pi->ipi6_addr); s->lifindex = pi->ipi6_ifindex; } } static inline void sk_process_cmsg6_ttl(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IPV6_HOPLIMIT) s->rcv_ttl = * (int *) CMSG_DATA(cm); } static inline void sk_prepare_cmsgs6(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen) { struct cmsghdr *cm; struct in6_pktinfo *pi; int controllen = 0; msg->msg_control = cbuf; msg->msg_controllen = cbuflen; cm = CMSG_FIRSTHDR(msg); cm->cmsg_level = SOL_IPV6; cm->cmsg_type = IPV6_PKTINFO; cm->cmsg_len = CMSG_LEN(sizeof(*pi)); controllen += CMSG_SPACE(sizeof(*pi)); pi = (struct in6_pktinfo *) CMSG_DATA(cm); pi->ipi6_ifindex = s->iface ? s->iface->index : 0; pi->ipi6_addr = ipa_to_in6(s->saddr); msg->msg_controllen = controllen; } /* * Miscellaneous socket syscalls */ static inline int sk_set_ttl4(sock *s, int ttl) { if (setsockopt(s->fd, SOL_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) ERR("IP_TTL"); return 0; } static inline int sk_set_ttl6(sock *s, int ttl) { if (setsockopt(s->fd, SOL_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)) < 0) ERR("IPV6_UNICAST_HOPS"); return 0; } static inline int sk_set_tos4(sock *s, int tos) { if (setsockopt(s->fd, SOL_IP, IP_TOS, &tos, sizeof(tos)) < 0) ERR("IP_TOS"); return 0; } static inline int sk_set_tos6(sock *s, int tos) { if (setsockopt(s->fd, SOL_IPV6, IPV6_TCLASS, &tos, sizeof(tos)) < 0) ERR("IPV6_TCLASS"); return 0; } static inline int sk_set_high_port(sock *s UNUSED) { /* Port range setting is optional, ignore it if not supported */ #ifdef IP_PORTRANGE if (sk_is_ipv4(s)) { int range = IP_PORTRANGE_HIGH; if (setsockopt(s->fd, SOL_IP, IP_PORTRANGE, &range, sizeof(range)) < 0) ERR("IP_PORTRANGE"); } #endif #ifdef IPV6_PORTRANGE if (sk_is_ipv6(s)) { int range = IPV6_PORTRANGE_HIGH; if (setsockopt(s->fd, SOL_IPV6, IPV6_PORTRANGE, &range, sizeof(range)) < 0) ERR("IPV6_PORTRANGE"); } #endif return 0; } static inline byte * sk_skip_ip_header(byte *pkt, int *len) { if ((*len < 20) || ((*pkt & 0xf0) != 0x40)) return NULL; int hlen = (*pkt & 0x0f) * 4; if ((hlen < 20) || (hlen > *len)) return NULL; *len -= hlen; return pkt + hlen; } byte * sk_rx_buffer(sock *s, int *len) { if (sk_is_ipv4(s) && (s->type == SK_IP)) return sk_skip_ip_header(s->rbuf, len); else return s->rbuf; } /* * Public socket functions */ /** * sk_setup_multicast - enable multicast for given socket * @s: socket * * Prepare transmission of multicast packets for given datagram socket. * The socket must have defined @iface. * * Result: 0 for success, -1 for an error. */ int sk_setup_multicast(sock *s) { ASSERT(s->iface); if (sk_is_ipv4(s)) return sk_setup_multicast4(s); else return sk_setup_multicast6(s); } /** * sk_join_group - join multicast group for given socket * @s: socket * @maddr: multicast address * * Join multicast group for given datagram socket and associated interface. * The socket must have defined @iface. * * Result: 0 for success, -1 for an error. */ int sk_join_group(sock *s, ip_addr maddr) { if (sk_is_ipv4(s)) return sk_join_group4(s, maddr); else return sk_join_group6(s, maddr); } /** * sk_leave_group - leave multicast group for given socket * @s: socket * @maddr: multicast address * * Leave multicast group for given datagram socket and associated interface. * The socket must have defined @iface. * * Result: 0 for success, -1 for an error. */ int sk_leave_group(sock *s, ip_addr maddr) { if (sk_is_ipv4(s)) return sk_leave_group4(s, maddr); else return sk_leave_group6(s, maddr); } /** * sk_setup_broadcast - enable broadcast for given socket * @s: socket * * Allow reception and transmission of broadcast packets for given datagram * socket. The socket must have defined @iface. For transmission, packets should * be send to @brd address of @iface. * * Result: 0 for success, -1 for an error. */ int sk_setup_broadcast(sock *s) { int y = 1; if (setsockopt(s->fd, SOL_SOCKET, SO_BROADCAST, &y, sizeof(y)) < 0) ERR("SO_BROADCAST"); return 0; } /** * sk_set_ttl - set transmit TTL for given socket * @s: socket * @ttl: TTL value * * Set TTL for already opened connections when TTL was not set before. Useful * for accepted connections when different ones should have different TTL. * * Result: 0 for success, -1 for an error. */ int sk_set_ttl(sock *s, int ttl) { s->ttl = ttl; if (sk_is_ipv4(s)) return sk_set_ttl4(s, ttl); else return sk_set_ttl6(s, ttl); } /** * sk_set_min_ttl - set minimal accepted TTL for given socket * @s: socket * @ttl: TTL value * * Set minimal accepted TTL for given socket. Can be used for TTL security. * implementations. * * Result: 0 for success, -1 for an error. */ int sk_set_min_ttl(sock *s, int ttl) { if (sk_is_ipv4(s)) return sk_set_min_ttl4(s, ttl); else return sk_set_min_ttl6(s, ttl); } #if 0 /** * sk_set_md5_auth - add / remove MD5 security association for given socket * @s: socket * @local: IP address of local side * @remote: IP address of remote side * @ifa: Interface for link-local IP address * @passwd: Password used for MD5 authentication * @setkey: Update also system SA/SP database * * In TCP MD5 handling code in kernel, there is a set of security associations * used for choosing password and other authentication parameters according to * the local and remote address. This function is useful for listening socket, * for active sockets it may be enough to set s->password field. * * When called with passwd != NULL, the new pair is added, * When called with passwd == NULL, the existing pair is removed. * * Note that while in Linux, the MD5 SAs are specific to socket, in BSD they are * stored in global SA/SP database (but the behavior also must be enabled on * per-socket basis). In case of multiple sockets to the same neighbor, the * socket-specific state must be configured for each socket while global state * just once per src-dst pair. The @setkey argument controls whether the global * state (SA/SP database) is also updated. * * Result: 0 for success, -1 for an error. */ int sk_set_md5_auth(sock *s, ip_addr local, ip_addr remote, struct iface *ifa, char *passwd, int setkey) { DUMMY; } #endif /** * sk_set_ipv6_checksum - specify IPv6 checksum offset for given socket * @s: socket * @offset: offset * * Specify IPv6 checksum field offset for given raw IPv6 socket. After that, the * kernel will automatically fill it for outgoing packets and check it for * incoming packets. Should not be used on ICMPv6 sockets, where the position is * known to the kernel. * * Result: 0 for success, -1 for an error. */ int sk_set_ipv6_checksum(sock *s, int offset) { if (setsockopt(s->fd, SOL_IPV6, IPV6_CHECKSUM, &offset, sizeof(offset)) < 0) ERR("IPV6_CHECKSUM"); return 0; } int sk_set_icmp6_filter(sock *s, int p1, int p2) { /* a bit of lame interface, but it is here only for Radv */ struct icmp6_filter f; ICMP6_FILTER_SETBLOCKALL(&f); ICMP6_FILTER_SETPASS(p1, &f); ICMP6_FILTER_SETPASS(p2, &f); if (setsockopt(s->fd, SOL_ICMPV6, ICMP6_FILTER, &f, sizeof(f)) < 0) ERR("ICMP6_FILTER"); return 0; } void sk_log_error(sock *s, const char *p) { log(L_ERR "%s: Socket error: %s%#m", p, s->err); } /* * Actual struct birdsock code */ static list sock_list; static struct birdsock *current_sock; static struct birdsock *stored_sock; static inline sock * sk_next(sock *s) { if (!s->n.next->next) return NULL; else return SKIP_BACK(sock, n, s->n.next); } static void sk_alloc_bufs(sock *s) { if (!s->rbuf && s->rbsize) s->rbuf = s->rbuf_alloc = xmalloc(s->rbsize); s->rpos = s->rbuf; if (!s->tbuf && s->tbsize) s->tbuf = s->tbuf_alloc = xmalloc(s->tbsize); s->tpos = s->ttx = s->tbuf; } static void sk_free_bufs(sock *s) { if (s->rbuf_alloc) { xfree(s->rbuf_alloc); s->rbuf = s->rbuf_alloc = NULL; } if (s->tbuf_alloc) { xfree(s->tbuf_alloc); s->tbuf = s->tbuf_alloc = NULL; } } #ifdef HAVE_LIBSSH static void sk_ssh_free(sock *s) { struct ssh_sock *ssh = s->ssh; if (s->ssh == NULL) return; s->ssh = NULL; if (ssh->channel) { if (ssh_channel_is_open(ssh->channel)) ssh_channel_close(ssh->channel); ssh_channel_free(ssh->channel); ssh->channel = NULL; } if (ssh->session) { ssh_disconnect(ssh->session); ssh_free(ssh->session); ssh->session = NULL; } } #endif static void sk_free(resource *r) { sock *s = (sock *) r; sk_free_bufs(s); #ifdef HAVE_LIBSSH if (s->type == SK_SSH || s->type == SK_SSH_ACTIVE) sk_ssh_free(s); #endif if (s->fd < 0) return; /* FIXME: we should call sk_stop() for SKF_THREAD sockets */ if (!(s->flags & SKF_THREAD)) { if (s == current_sock) current_sock = sk_next(s); if (s == stored_sock) stored_sock = sk_next(s); rem_node(&s->n); } if (s->type != SK_SSH && s->type != SK_SSH_ACTIVE) close(s->fd); s->fd = -1; } void sk_set_rbsize(sock *s, uint val) { ASSERT(s->rbuf_alloc == s->rbuf); if (s->rbsize == val) return; s->rbsize = val; xfree(s->rbuf_alloc); s->rbuf_alloc = xmalloc(val); s->rpos = s->rbuf = s->rbuf_alloc; } void sk_set_tbsize(sock *s, uint val) { ASSERT(s->tbuf_alloc == s->tbuf); if (s->tbsize == val) return; byte *old_tbuf = s->tbuf; s->tbsize = val; s->tbuf = s->tbuf_alloc = xrealloc(s->tbuf_alloc, val); s->tpos = s->tbuf + (s->tpos - old_tbuf); s->ttx = s->tbuf + (s->ttx - old_tbuf); } void sk_set_tbuf(sock *s, void *tbuf) { s->tbuf = tbuf ?: s->tbuf_alloc; s->ttx = s->tpos = s->tbuf; } void sk_reallocate(sock *s) { sk_free_bufs(s); sk_alloc_bufs(s); } static void sk_dump(resource *r) { sock *s = (sock *) r; static char *sk_type_names[] = { "TCP<", "TCP>", "TCP", "UDP", NULL, "IP", NULL, "MAGIC", "UNIX<", "UNIX", "SSH>", "SSH", "DEL!" }; debug("(%s, ud=%p, sa=%I, sp=%d, da=%I, dp=%d, tos=%d, ttl=%d, if=%s)\n", sk_type_names[s->type], s->data, s->saddr, s->sport, s->daddr, s->dport, s->tos, s->ttl, s->iface ? s->iface->name : "none"); } static struct resclass sk_class = { "Socket", sizeof(sock), sk_free, sk_dump, NULL, NULL }; /** * sk_new - create a socket * @p: pool * * This function creates a new socket resource. If you want to use it, * you need to fill in all the required fields of the structure and * call sk_open() to do the actual opening of the socket. * * The real function name is sock_new(), sk_new() is a macro wrapper * to avoid collision with OpenSSL. */ sock * sock_new(pool *p) { sock *s = ralloc(p, &sk_class); s->pool = p; // s->saddr = s->daddr = IPA_NONE; s->tos = s->priority = s->ttl = -1; s->fd = -1; return s; } static int sk_setup(sock *s) { int y = 1; int fd = s->fd; if (s->type == SK_SSH_ACTIVE) return 0; if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) ERR("O_NONBLOCK"); if (!s->af) return 0; if (ipa_nonzero(s->saddr) && !(s->flags & SKF_BIND)) s->flags |= SKF_PKTINFO; #ifdef CONFIG_USE_HDRINCL if (sk_is_ipv4(s) && (s->type == SK_IP) && (s->flags & SKF_PKTINFO)) { s->flags &= ~SKF_PKTINFO; s->flags |= SKF_HDRINCL; if (setsockopt(fd, SOL_IP, IP_HDRINCL, &y, sizeof(y)) < 0) ERR("IP_HDRINCL"); } #endif if (s->vrf && !s->iface) { /* Bind socket to associated VRF interface. This is Linux-specific, but so is SO_BINDTODEVICE. */ #ifdef SO_BINDTODEVICE struct ifreq ifr = {}; strcpy(ifr.ifr_name, s->vrf->name); if (setsockopt(s->fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) ERR("SO_BINDTODEVICE"); #endif } if (s->iface) { #ifdef SO_BINDTODEVICE struct ifreq ifr = {}; strcpy(ifr.ifr_name, s->iface->name); if (setsockopt(s->fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) ERR("SO_BINDTODEVICE"); #endif #ifdef CONFIG_UNIX_DONTROUTE if (setsockopt(s->fd, SOL_SOCKET, SO_DONTROUTE, &y, sizeof(y)) < 0) ERR("SO_DONTROUTE"); #endif } if (sk_is_ipv4(s)) { if (s->flags & SKF_LADDR_RX) if (sk_request_cmsg4_pktinfo(s) < 0) return -1; if (s->flags & SKF_TTL_RX) if (sk_request_cmsg4_ttl(s) < 0) return -1; if ((s->type == SK_UDP) || (s->type == SK_IP)) if (sk_disable_mtu_disc4(s) < 0) return -1; if (s->ttl >= 0) if (sk_set_ttl4(s, s->ttl) < 0) return -1; if (s->tos >= 0) if (sk_set_tos4(s, s->tos) < 0) return -1; } if (sk_is_ipv6(s)) { if ((s->type == SK_TCP_PASSIVE) || (s->type == SK_TCP_ACTIVE) || (s->type == SK_UDP)) if (setsockopt(fd, SOL_IPV6, IPV6_V6ONLY, &y, sizeof(y)) < 0) ERR("IPV6_V6ONLY"); if (s->flags & SKF_LADDR_RX) if (sk_request_cmsg6_pktinfo(s) < 0) return -1; if (s->flags & SKF_TTL_RX) if (sk_request_cmsg6_ttl(s) < 0) return -1; if ((s->type == SK_UDP) || (s->type == SK_IP)) if (sk_disable_mtu_disc6(s) < 0) return -1; if (s->ttl >= 0) if (sk_set_ttl6(s, s->ttl) < 0) return -1; if (s->tos >= 0) if (sk_set_tos6(s, s->tos) < 0) return -1; } /* Must be after sk_set_tos4() as setting ToS on Linux also mangles priority */ if (s->priority >= 0) if (sk_set_priority(s, s->priority) < 0) return -1; return 0; } static void sk_insert(sock *s) { add_tail(&sock_list, &s->n); } static void sk_tcp_connected(sock *s) { sockaddr sa; int sa_len = sizeof(sa); if ((getsockname(s->fd, &sa.sa, &sa_len) < 0) || (sockaddr_read(&sa, s->af, &s->saddr, &s->iface, &s->sport) < 0)) log(L_WARN "SOCK: Cannot get local IP address for TCP>"); s->type = SK_TCP; sk_alloc_bufs(s); s->tx_hook(s); } #ifdef HAVE_LIBSSH static void sk_ssh_connected(sock *s) { sk_alloc_bufs(s); s->type = SK_SSH; s->tx_hook(s); } #endif static int sk_passive_connected(sock *s, int type) { sockaddr loc_sa, rem_sa; int loc_sa_len = sizeof(loc_sa); int rem_sa_len = sizeof(rem_sa); int fd = accept(s->fd, ((type == SK_TCP) ? &rem_sa.sa : NULL), &rem_sa_len); if (fd < 0) { if ((errno != EINTR) && (errno != EAGAIN)) s->err_hook(s, errno); return 0; } sock *t = sk_new(s->pool); t->type = type; t->data = s->data; t->af = s->af; t->fd = fd; t->ttl = s->ttl; t->tos = s->tos; t->vrf = s->vrf; t->rbsize = s->rbsize; t->tbsize = s->tbsize; if (type == SK_TCP) { if ((getsockname(fd, &loc_sa.sa, &loc_sa_len) < 0) || (sockaddr_read(&loc_sa, s->af, &t->saddr, &t->iface, &t->sport) < 0)) log(L_WARN "SOCK: Cannot get local IP address for TCP<"); if (sockaddr_read(&rem_sa, s->af, &t->daddr, &t->iface, &t->dport) < 0) log(L_WARN "SOCK: Cannot get remote IP address for TCP<"); } if (sk_setup(t) < 0) { /* FIXME: Call err_hook instead ? */ log(L_ERR "SOCK: Incoming connection: %s%#m", t->err); /* FIXME: handle it better in rfree() */ close(t->fd); t->fd = -1; rfree(t); return 1; } sk_insert(t); sk_alloc_bufs(t); s->rx_hook(t, 0); return 1; } #ifdef HAVE_LIBSSH /* * Return SSH_OK or SSH_AGAIN or SSH_ERROR */ static int sk_ssh_connect(sock *s) { s->fd = ssh_get_fd(s->ssh->session); /* Big fall thru automata */ switch (s->ssh->state) { case SK_SSH_CONNECT: { switch (ssh_connect(s->ssh->session)) { case SSH_AGAIN: /* A quick look into libSSH shows that ssh_get_fd() should return non-(-1) * after SSH_AGAIN is returned by ssh_connect(). This is however nowhere * documented but our code relies on that. */ return SSH_AGAIN; case SSH_OK: break; default: return SSH_ERROR; } } /* fallthrough */ case SK_SSH_SERVER_KNOWN: { s->ssh->state = SK_SSH_SERVER_KNOWN; if (s->ssh->server_hostkey_path) { int server_identity_is_ok = 1; /* Check server identity */ switch (ssh_is_server_known(s->ssh->session)) { #define LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s,msg,args...) log(L_WARN "SSH Identity %s@%s:%u: " msg, (s)->ssh->username, (s)->host, (s)->dport, ## args); case SSH_SERVER_KNOWN_OK: /* The server is known and has not changed. */ break; case SSH_SERVER_NOT_KNOWN: LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s, "The server is unknown, its public key was not found in the known host file %s", s->ssh->server_hostkey_path); break; case SSH_SERVER_KNOWN_CHANGED: LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s, "The server key has changed. Either you are under attack or the administrator changed the key."); server_identity_is_ok = 0; break; case SSH_SERVER_FILE_NOT_FOUND: LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s, "The known host file %s does not exist", s->ssh->server_hostkey_path); server_identity_is_ok = 0; break; case SSH_SERVER_ERROR: LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s, "Some error happened"); server_identity_is_ok = 0; break; case SSH_SERVER_FOUND_OTHER: LOG_WARN_ABOUT_SSH_SERVER_VALIDATION(s, "The server gave use a key of a type while we had an other type recorded. " \ "It is a possible attack."); server_identity_is_ok = 0; break; } if (!server_identity_is_ok) return SSH_ERROR; } } /* fallthrough */ case SK_SSH_USERAUTH: { s->ssh->state = SK_SSH_USERAUTH; switch (ssh_userauth_publickey_auto(s->ssh->session, NULL, NULL)) { case SSH_AUTH_AGAIN: return SSH_AGAIN; case SSH_AUTH_SUCCESS: break; default: return SSH_ERROR; } } /* fallthrough */ case SK_SSH_CHANNEL: { s->ssh->state = SK_SSH_CHANNEL; s->ssh->channel = ssh_channel_new(s->ssh->session); if (s->ssh->channel == NULL) return SSH_ERROR; } /* fallthrough */ case SK_SSH_SESSION: { s->ssh->state = SK_SSH_SESSION; switch (ssh_channel_open_session(s->ssh->channel)) { case SSH_AGAIN: return SSH_AGAIN; case SSH_OK: break; default: return SSH_ERROR; } } /* fallthrough */ case SK_SSH_SUBSYSTEM: { s->ssh->state = SK_SSH_SUBSYSTEM; if (s->ssh->subsystem) { switch (ssh_channel_request_subsystem(s->ssh->channel, s->ssh->subsystem)) { case SSH_AGAIN: return SSH_AGAIN; case SSH_OK: break; default: return SSH_ERROR; } } } /* fallthrough */ case SK_SSH_ESTABLISHED: s->ssh->state = SK_SSH_ESTABLISHED; } return SSH_OK; } /* * Return file descriptor number if success * Return -1 if failed */ static int sk_open_ssh(sock *s) { if (!s->ssh) bug("sk_open() sock->ssh is not allocated"); ssh_session sess = ssh_new(); if (sess == NULL) ERR2("Cannot create a ssh session"); s->ssh->session = sess; const int verbosity = SSH_LOG_NOLOG; ssh_options_set(sess, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); ssh_options_set(sess, SSH_OPTIONS_HOST, s->host); ssh_options_set(sess, SSH_OPTIONS_PORT, &(s->dport)); /* TODO: Add SSH_OPTIONS_BINDADDR */ ssh_options_set(sess, SSH_OPTIONS_USER, s->ssh->username); if (s->ssh->server_hostkey_path) ssh_options_set(sess, SSH_OPTIONS_KNOWNHOSTS, s->ssh->server_hostkey_path); if (s->ssh->client_privkey_path) ssh_options_set(sess, SSH_OPTIONS_IDENTITY, s->ssh->client_privkey_path); ssh_set_blocking(sess, 0); switch (sk_ssh_connect(s)) { case SSH_AGAIN: break; case SSH_OK: sk_ssh_connected(s); break; case SSH_ERROR: ERR2(ssh_get_error(sess)); break; } return ssh_get_fd(sess); err: return -1; } #endif /** * sk_open - open a socket * @s: socket * * This function takes a socket resource created by sk_new() and * initialized by the user and binds a corresponding network connection * to it. * * Result: 0 for success, -1 for an error. */ int sk_open(sock *s) { int af = AF_UNSPEC; int fd = -1; int do_bind = 0; int bind_port = 0; ip_addr bind_addr = IPA_NONE; sockaddr sa; if (s->type <= SK_IP) { /* * For TCP/IP sockets, Address family (IPv4 or IPv6) can be specified either * explicitly (SK_IPV4 or SK_IPV6) or implicitly (based on saddr, daddr). * But the specifications have to be consistent. */ switch (s->subtype) { case 0: ASSERT(ipa_zero(s->saddr) || ipa_zero(s->daddr) || (ipa_is_ip4(s->saddr) == ipa_is_ip4(s->daddr))); af = (ipa_is_ip4(s->saddr) || ipa_is_ip4(s->daddr)) ? AF_INET : AF_INET6; break; case SK_IPV4: ASSERT(ipa_zero(s->saddr) || ipa_is_ip4(s->saddr)); ASSERT(ipa_zero(s->daddr) || ipa_is_ip4(s->daddr)); af = AF_INET; break; case SK_IPV6: ASSERT(ipa_zero(s->saddr) || !ipa_is_ip4(s->saddr)); ASSERT(ipa_zero(s->daddr) || !ipa_is_ip4(s->daddr)); af = AF_INET6; break; default: bug("Invalid subtype %d", s->subtype); } } switch (s->type) { case SK_TCP_ACTIVE: s->ttx = ""; /* Force s->ttx != s->tpos */ /* Fall thru */ case SK_TCP_PASSIVE: fd = socket(af, SOCK_STREAM, IPPROTO_TCP); bind_port = s->sport; bind_addr = s->saddr; do_bind = bind_port || ipa_nonzero(bind_addr); break; #ifdef HAVE_LIBSSH case SK_SSH_ACTIVE: s->ttx = ""; /* Force s->ttx != s->tpos */ fd = sk_open_ssh(s); break; #endif case SK_UDP: fd = socket(af, SOCK_DGRAM, IPPROTO_UDP); bind_port = s->sport; bind_addr = (s->flags & SKF_BIND) ? s->saddr : IPA_NONE; do_bind = 1; break; case SK_IP: fd = socket(af, SOCK_RAW, s->dport); bind_port = 0; bind_addr = (s->flags & SKF_BIND) ? s->saddr : IPA_NONE; do_bind = ipa_nonzero(bind_addr); break; case SK_MAGIC: af = 0; fd = s->fd; break; default: bug("sk_open() called for invalid sock type %d", s->type); } if (fd < 0) ERR("socket"); s->af = af; s->fd = fd; if (sk_setup(s) < 0) goto err; if (do_bind) { if (bind_port) { int y = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(y)) < 0) ERR2("SO_REUSEADDR"); #ifdef CONFIG_NO_IFACE_BIND /* Workaround missing ability to bind to an iface */ if ((s->type == SK_UDP) && s->iface && ipa_zero(bind_addr)) { if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &y, sizeof(y)) < 0) ERR2("SO_REUSEPORT"); } #endif } else if (s->flags & SKF_HIGH_PORT) if (sk_set_high_port(s) < 0) log(L_WARN "Socket error: %s%#m", s->err); sockaddr_fill(&sa, s->af, bind_addr, s->iface, bind_port); if (bind(fd, &sa.sa, SA_LEN(sa)) < 0) ERR2("bind"); } if (s->password) if (sk_set_md5_auth(s, s->saddr, s->daddr, -1, s->iface, s->password, 0) < 0) goto err; switch (s->type) { case SK_TCP_ACTIVE: sockaddr_fill(&sa, s->af, s->daddr, s->iface, s->dport); if (connect(fd, &sa.sa, SA_LEN(sa)) >= 0) sk_tcp_connected(s); else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != ECONNREFUSED && errno != EHOSTUNREACH && errno != ENETUNREACH) ERR2("connect"); break; case SK_TCP_PASSIVE: if (listen(fd, 8) < 0) ERR2("listen"); break; case SK_SSH_ACTIVE: case SK_MAGIC: break; default: sk_alloc_bufs(s); } if (!(s->flags & SKF_THREAD)) sk_insert(s); return 0; err: close(fd); s->fd = -1; return -1; } int sk_open_unix(sock *s, char *name) { struct sockaddr_un sa; int fd; /* We are sloppy during error (leak fd and not set s->err), but we die anyway */ fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) return -1; if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) return -1; /* Path length checked in test_old_bird() but we may need unix sockets for other reasons in future */ ASSERT_DIE(strlen(name) < sizeof(sa.sun_path)); sa.sun_family = AF_UNIX; strcpy(sa.sun_path, name); if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0) return -1; if (listen(fd, 8) < 0) return -1; s->fd = fd; sk_insert(s); return 0; } #define CMSG_RX_SPACE MAX(CMSG4_SPACE_PKTINFO+CMSG4_SPACE_TTL, \ CMSG6_SPACE_PKTINFO+CMSG6_SPACE_TTL) #define CMSG_TX_SPACE MAX(CMSG4_SPACE_PKTINFO,CMSG6_SPACE_PKTINFO) static void sk_prepare_cmsgs(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen) { if (sk_is_ipv4(s)) sk_prepare_cmsgs4(s, msg, cbuf, cbuflen); else sk_prepare_cmsgs6(s, msg, cbuf, cbuflen); } static void sk_process_cmsgs(sock *s, struct msghdr *msg) { struct cmsghdr *cm; s->laddr = IPA_NONE; s->lifindex = 0; s->rcv_ttl = -1; for (cm = CMSG_FIRSTHDR(msg); cm != NULL; cm = CMSG_NXTHDR(msg, cm)) { if ((cm->cmsg_level == SOL_IP) && sk_is_ipv4(s)) { sk_process_cmsg4_pktinfo(s, cm); sk_process_cmsg4_ttl(s, cm); } if ((cm->cmsg_level == SOL_IPV6) && sk_is_ipv6(s)) { sk_process_cmsg6_pktinfo(s, cm); sk_process_cmsg6_ttl(s, cm); } } } static inline int sk_sendmsg(sock *s) { struct iovec iov = {s->tbuf, s->tpos - s->tbuf}; byte cmsg_buf[CMSG_TX_SPACE]; sockaddr dst; int flags = 0; sockaddr_fill(&dst, s->af, s->daddr, s->iface, s->dport); struct msghdr msg = { .msg_name = &dst.sa, .msg_namelen = SA_LEN(dst), .msg_iov = &iov, .msg_iovlen = 1 }; #ifdef CONFIG_DONTROUTE_UNICAST /* FreeBSD silently changes TTL to 1 when MSG_DONTROUTE is used, therefore we cannot use it for other cases (e.g. when TTL security is used). */ if (ipa_is_ip4(s->daddr) && ip4_is_unicast(ipa_to_ip4(s->daddr)) && (s->ttl == 1)) flags = MSG_DONTROUTE; #endif #ifdef CONFIG_USE_HDRINCL byte hdr[20]; struct iovec iov2[2] = { {hdr, 20}, iov }; if (s->flags & SKF_HDRINCL) { sk_prepare_ip_header(s, hdr, iov.iov_len); msg.msg_iov = iov2; msg.msg_iovlen = 2; } #endif if (s->flags & SKF_PKTINFO) sk_prepare_cmsgs(s, &msg, cmsg_buf, sizeof(cmsg_buf)); return sendmsg(s->fd, &msg, flags); } static inline int sk_recvmsg(sock *s) { struct iovec iov = {s->rbuf, s->rbsize}; byte cmsg_buf[CMSG_RX_SPACE]; sockaddr src; struct msghdr msg = { .msg_name = &src.sa, .msg_namelen = sizeof(src), // XXXX ?? .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cmsg_buf, .msg_controllen = sizeof(cmsg_buf), .msg_flags = 0 }; int rv = recvmsg(s->fd, &msg, 0); if (rv < 0) return rv; //ifdef IPV4 // if (cf_type == SK_IP) // rv = ipv4_skip_header(pbuf, rv); //endif sockaddr_read(&src, s->af, &s->faddr, NULL, &s->fport); sk_process_cmsgs(s, &msg); if (msg.msg_flags & MSG_TRUNC) s->flags |= SKF_TRUNCATED; else s->flags &= ~SKF_TRUNCATED; return rv; } static inline void reset_tx_buffer(sock *s) { s->ttx = s->tpos = s->tbuf; } static int sk_maybe_write(sock *s) { int e; switch (s->type) { case SK_TCP: case SK_MAGIC: case SK_UNIX: while (s->ttx != s->tpos) { e = write(s->fd, s->ttx, s->tpos - s->ttx); if (e < 0) { if (errno != EINTR && errno != EAGAIN) { reset_tx_buffer(s); /* EPIPE is just a connection close notification during TX */ s->err_hook(s, (errno != EPIPE) ? errno : 0); return -1; } return 0; } s->ttx += e; } reset_tx_buffer(s); return 1; #ifdef HAVE_LIBSSH case SK_SSH: while (s->ttx != s->tpos) { e = ssh_channel_write(s->ssh->channel, s->ttx, s->tpos - s->ttx); if (e < 0) { s->err = ssh_get_error(s->ssh->session); s->err_hook(s, ssh_get_error_code(s->ssh->session)); reset_tx_buffer(s); /* EPIPE is just a connection close notification during TX */ s->err_hook(s, (errno != EPIPE) ? errno : 0); return -1; } s->ttx += e; } reset_tx_buffer(s); return 1; #endif case SK_UDP: case SK_IP: { if (s->tbuf == s->tpos) return 1; e = sk_sendmsg(s); if (e < 0) { if (errno != EINTR && errno != EAGAIN) { reset_tx_buffer(s); s->err_hook(s, errno); return -1; } if (!s->tx_hook) reset_tx_buffer(s); return 0; } reset_tx_buffer(s); return 1; } default: bug("sk_maybe_write: unknown socket type %d", s->type); } } int sk_rx_ready(sock *s) { int rv; struct pollfd pfd = { .fd = s->fd }; pfd.events |= POLLIN; redo: rv = poll(&pfd, 1, 0); if ((rv < 0) && (errno == EINTR || errno == EAGAIN)) goto redo; return rv; } /** * sk_send - send data to a socket * @s: socket * @len: number of bytes to send * * This function sends @len bytes of data prepared in the * transmit buffer of the socket @s to the network connection. * If the packet can be sent immediately, it does so and returns * 1, else it queues the packet for later processing, returns 0 * and calls the @tx_hook of the socket when the tranmission * takes place. */ int sk_send(sock *s, unsigned len) { s->ttx = s->tbuf; s->tpos = s->tbuf + len; return sk_maybe_write(s); } /** * sk_send_to - send data to a specific destination * @s: socket * @len: number of bytes to send * @addr: IP address to send the packet to * @port: port to send the packet to * * This is a sk_send() replacement for connection-less packet sockets * which allows destination of the packet to be chosen dynamically. * Raw IP sockets should use 0 for @port. */ int sk_send_to(sock *s, unsigned len, ip_addr addr, unsigned port) { s->daddr = addr; if (port) s->dport = port; s->ttx = s->tbuf; s->tpos = s->tbuf + len; return sk_maybe_write(s); } /* int sk_send_full(sock *s, unsigned len, struct iface *ifa, ip_addr saddr, ip_addr daddr, unsigned dport) { s->iface = ifa; s->saddr = saddr; s->daddr = daddr; s->dport = dport; s->ttx = s->tbuf; s->tpos = s->tbuf + len; return sk_maybe_write(s); } */ static void call_rx_hook(sock *s, int size) { if (s->rx_hook(s, size)) { /* We need to be careful since the socket could have been deleted by the hook */ if (current_sock == s) s->rpos = s->rbuf; } } #ifdef HAVE_LIBSSH static int sk_read_ssh(sock *s) { ssh_channel rchans[2] = { s->ssh->channel, NULL }; struct timeval timev = { 1, 0 }; if (ssh_channel_select(rchans, NULL, NULL, &timev) == SSH_EINTR) return 1; /* Try again */ if (ssh_channel_is_eof(s->ssh->channel) != 0) { /* The remote side is closing the connection */ s->err_hook(s, 0); return 0; } if (rchans[0] == NULL) return 0; /* No data is available on the socket */ const uint used_bytes = s->rpos - s->rbuf; const int read_bytes = ssh_channel_read_nonblocking(s->ssh->channel, s->rpos, s->rbsize - used_bytes, 0); if (read_bytes > 0) { /* Received data */ s->rpos += read_bytes; call_rx_hook(s, used_bytes + read_bytes); return 1; } else if (read_bytes == 0) { if (ssh_channel_is_eof(s->ssh->channel) != 0) { /* The remote side is closing the connection */ s->err_hook(s, 0); } } else { s->err = ssh_get_error(s->ssh->session); s->err_hook(s, ssh_get_error_code(s->ssh->session)); } return 0; /* No data is available on the socket */ } #endif /* sk_read() and sk_write() are called from BFD's event loop */ int sk_read(sock *s, int revents) { switch (s->type) { case SK_TCP_PASSIVE: return sk_passive_connected(s, SK_TCP); case SK_UNIX_PASSIVE: return sk_passive_connected(s, SK_UNIX); case SK_TCP: case SK_UNIX: { int c = read(s->fd, s->rpos, s->rbuf + s->rbsize - s->rpos); if (c < 0) { if (errno != EINTR && errno != EAGAIN) s->err_hook(s, errno); else if (errno == EAGAIN && !(revents & POLLIN)) { log(L_ERR "Got EAGAIN from read when revents=%x (without POLLIN)", revents); s->err_hook(s, 0); } } else if (!c) s->err_hook(s, 0); else { s->rpos += c; call_rx_hook(s, s->rpos - s->rbuf); return 1; } return 0; } #ifdef HAVE_LIBSSH case SK_SSH: return sk_read_ssh(s); #endif case SK_MAGIC: return s->rx_hook(s, 0); default: { int e = sk_recvmsg(s); if (e < 0) { if (errno != EINTR && errno != EAGAIN) s->err_hook(s, errno); return 0; } s->rpos = s->rbuf + e; s->rx_hook(s, e); return 1; } } } int sk_write(sock *s) { switch (s->type) { case SK_TCP_ACTIVE: { sockaddr sa; sockaddr_fill(&sa, s->af, s->daddr, s->iface, s->dport); if (connect(s->fd, &sa.sa, SA_LEN(sa)) >= 0 || errno == EISCONN) sk_tcp_connected(s); else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS) s->err_hook(s, errno); return 0; } #ifdef HAVE_LIBSSH case SK_SSH_ACTIVE: { switch (sk_ssh_connect(s)) { case SSH_OK: sk_ssh_connected(s); break; case SSH_AGAIN: return 1; case SSH_ERROR: s->err = ssh_get_error(s->ssh->session); s->err_hook(s, ssh_get_error_code(s->ssh->session)); break; } return 0; } #endif default: if (s->ttx != s->tpos && sk_maybe_write(s) > 0) { if (s->tx_hook) s->tx_hook(s); return 1; } return 0; } } int sk_is_ipv4(sock *s) { return s->af == AF_INET; } int sk_is_ipv6(sock *s) { return s->af == AF_INET6; } void sk_err(sock *s, int revents) { int se = 0, sse = sizeof(se); if ((s->type != SK_MAGIC) && (revents & POLLERR)) if (getsockopt(s->fd, SOL_SOCKET, SO_ERROR, &se, &sse) < 0) { log(L_ERR "IO: Socket error: SO_ERROR: %m"); se = 0; } s->err_hook(s, se); } void sk_dump_all(void) { node *n; sock *s; debug("Open sockets:\n"); WALK_LIST(n, sock_list) { s = SKIP_BACK(sock, n, n); debug("%p ", s); sk_dump(&s->r); } debug("\n"); } /* * Internal event log and watchdog */ #define EVENT_LOG_LENGTH 32 struct event_log_entry { void *hook; void *data; btime timestamp; btime duration; }; static struct event_log_entry event_log[EVENT_LOG_LENGTH]; static struct event_log_entry *event_open; static int event_log_pos, event_log_num, watchdog_active; static btime last_time; static btime loop_time; static void io_update_time(void) { struct timespec ts; int rv; /* * This is third time-tracking procedure (after update_times() above and * times_update() in BFD), dedicated to internal event log and latency * tracking. Hopefully, we consolidate these sometimes. */ rv = clock_gettime(CLOCK_MONOTONIC, &ts); if (rv < 0) die("clock_gettime: %m"); last_time = ts.tv_sec S + ts.tv_nsec NS; if (event_open) { event_open->duration = last_time - event_open->timestamp; if (event_open->duration > config->latency_limit) log(L_WARN "Event 0x%p 0x%p took %d ms", event_open->hook, event_open->data, (int) (event_open->duration TO_MS)); event_open = NULL; } } /** * io_log_event - mark approaching event into event log * @hook: event hook address * @data: event data address * * Store info (hook, data, timestamp) about the following internal event into * a circular event log (@event_log). When latency tracking is enabled, the log * entry is kept open (in @event_open) so the duration can be filled later. */ void io_log_event(void *hook, void *data) { if (config->latency_debug) io_update_time(); struct event_log_entry *en = event_log + event_log_pos; en->hook = hook; en->data = data; en->timestamp = last_time; en->duration = 0; event_log_num++; event_log_pos++; event_log_pos %= EVENT_LOG_LENGTH; event_open = config->latency_debug ? en : NULL; } static inline void io_close_event(void) { if (event_open) io_update_time(); } void io_log_dump(void) { int i; log(L_DEBUG "Event log:"); for (i = 0; i < EVENT_LOG_LENGTH; i++) { struct event_log_entry *en = event_log + (event_log_pos + i) % EVENT_LOG_LENGTH; if (en->hook) log(L_DEBUG " Event 0x%p 0x%p at %8d for %d ms", en->hook, en->data, (int) ((last_time - en->timestamp) TO_MS), (int) (en->duration TO_MS)); } } void watchdog_sigalrm(int sig UNUSED) { /* Update last_time and duration, but skip latency check */ config->latency_limit = 0xffffffff; io_update_time(); /* We want core dump */ abort(); } static inline void watchdog_start1(void) { io_update_time(); loop_time = last_time; } static inline void watchdog_start(void) { io_update_time(); loop_time = last_time; event_log_num = 0; if (config->watchdog_timeout) { alarm(config->watchdog_timeout); watchdog_active = 1; } } static inline void watchdog_stop(void) { io_update_time(); if (watchdog_active) { alarm(0); watchdog_active = 0; } btime duration = last_time - loop_time; if (duration > config->watchdog_warning) log(L_WARN "I/O loop cycle took %d ms for %d events", (int) (duration TO_MS), event_log_num); } /* * Main I/O Loop */ void io_init(void) { init_list(&sock_list); init_list(&global_event_list); init_list(&global_work_list); krt_io_init(); // XXX init_times(); // XXX update_times(); boot_time = current_time(); u64 now = (u64) current_real_time(); srandom((uint) (now ^ (now >> 32))); } static int short_loops = 0; #define SHORT_LOOP_MAX 10 #define WORK_EVENTS_MAX 10 void io_loop(void) { int poll_tout, timeout; int nfds, events, pout; timer *t; sock *s; node *n; int fdmax = 256; struct pollfd *pfd = xmalloc(fdmax * sizeof(struct pollfd)); watchdog_start1(); for(;;) { times_update(&main_timeloop); events = ev_run_list(&global_event_list); events = ev_run_list_limited(&global_work_list, WORK_EVENTS_MAX) || events; timers_fire(&main_timeloop); io_close_event(); // FIXME poll_tout = (events ? 0 : 3000); /* Time in milliseconds */ if (t = timers_first(&main_timeloop)) { times_update(&main_timeloop); timeout = (tm_remains(t) TO_MS) + 1; poll_tout = MIN(poll_tout, timeout); } nfds = 0; WALK_LIST(n, sock_list) { pfd[nfds] = (struct pollfd) { .fd = -1 }; /* everything other set to 0 by this */ s = SKIP_BACK(sock, n, n); if (s->rx_hook) { pfd[nfds].fd = s->fd; pfd[nfds].events |= POLLIN; } if (s->tx_hook && s->ttx != s->tpos) { pfd[nfds].fd = s->fd; pfd[nfds].events |= POLLOUT; } if (pfd[nfds].fd != -1) { s->index = nfds; nfds++; } else s->index = -1; if (nfds >= fdmax) { fdmax *= 2; pfd = xrealloc(pfd, fdmax * sizeof(struct pollfd)); } } /* * Yes, this is racy. But even if the signal comes before this test * and entering poll(), it gets caught on the next timer tick. */ if (async_config_flag) { io_log_event(async_config, NULL); async_config(); async_config_flag = 0; continue; } if (async_dump_flag) { io_log_event(async_dump, NULL); async_dump(); async_dump_flag = 0; continue; } if (async_shutdown_flag) { io_log_event(async_shutdown, NULL); async_shutdown(); async_shutdown_flag = 0; continue; } /* And finally enter poll() to find active sockets */ watchdog_stop(); pout = poll(pfd, nfds, poll_tout); watchdog_start(); if (pout < 0) { if (errno == EINTR || errno == EAGAIN) continue; die("poll: %m"); } if (pout) { times_update(&main_timeloop); /* guaranteed to be non-empty */ current_sock = SKIP_BACK(sock, n, HEAD(sock_list)); while (current_sock) { sock *s = current_sock; if (s->index == -1) { current_sock = sk_next(s); goto next; } int e; int steps; steps = MAX_STEPS; if (s->fast_rx && (pfd[s->index].revents & POLLIN) && s->rx_hook) do { steps--; io_log_event(s->rx_hook, s->data); e = sk_read(s, pfd[s->index].revents); if (s != current_sock) goto next; } while (e && s->rx_hook && steps); steps = MAX_STEPS; if (pfd[s->index].revents & POLLOUT) do { steps--; io_log_event(s->tx_hook, s->data); e = sk_write(s); if (s != current_sock) goto next; } while (e && steps); current_sock = sk_next(s); next: ; } short_loops++; if (events && (short_loops < SHORT_LOOP_MAX)) continue; short_loops = 0; int count = 0; current_sock = stored_sock; if (current_sock == NULL) current_sock = SKIP_BACK(sock, n, HEAD(sock_list)); while (current_sock && count < MAX_RX_STEPS) { sock *s = current_sock; if (s->index == -1) { current_sock = sk_next(s); goto next2; } if (!s->fast_rx && (pfd[s->index].revents & POLLIN) && s->rx_hook) { count++; io_log_event(s->rx_hook, s->data); sk_read(s, pfd[s->index].revents); if (s != current_sock) goto next2; } if (pfd[s->index].revents & (POLLHUP | POLLERR)) { sk_err(s, pfd[s->index].revents); if (s != current_sock) goto next2; } current_sock = sk_next(s); next2: ; } stored_sock = current_sock; } } } void test_old_bird(char *path) { int fd; struct sockaddr_un sa; fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) die("Cannot create socket: %m"); if (strlen(path) >= sizeof(sa.sun_path)) die("Socket path too long"); bzero(&sa, sizeof(sa)); sa.sun_family = AF_UNIX; strcpy(sa.sun_path, path); if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == 0) die("I found another BIRD running."); close(fd); } bird-2.0.8/sysdep/unix/endian.h0000664000175000017500000000053714025744326015272 0ustar feelafeela/* * BIRD -- Endianity Conversion * * (c) 1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_ENDIAN_H_ #define _BIRD_ENDIAN_H_ /* hton[sl] and ntoh[sl] are defined here */ #include #include #ifdef HAVE_STDINT_H #include #endif #endif bird-2.0.8/sysdep/unix/config.Y0000664000175000017500000000775414025744326015272 0ustar feelafeela/* * BIRD -- UNIX Configuration * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "sysdep/unix/unix.h" #include CF_DEFINES static struct log_config *this_log; CF_DECLS CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT) CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, STATUS) CF_KEYWORDS(GRACEFUL, RESTART) %type log_mask log_mask_list log_cat cfg_timeout %type cfg_name %type timeformat_which %type syslog_name CF_GRAMMAR conf: log_config ; log_begin: { this_log = cfg_allocz(sizeof(struct log_config)); }; log_config: LOG log_begin log_file log_mask ';' { this_log->mask = $4; add_tail(&new_config->logfiles, &this_log->n); } ; syslog_name: NAME text { $$ = $2; } | { $$ = bird_name; } ; log_limit: /* empty */ | expr text { this_log->limit = $1; this_log->backup = $2; } ; log_file: text log_limit { if (!parse_and_exit) { this_log->rf = rf_open(new_config->pool, $1, "a"); if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1); this_log->fh = rf_file(this_log->rf); } this_log->pos = -1; this_log->filename = $1; } | SYSLOG syslog_name { this_log->fh = NULL; new_config->syslog_name = $2; } | STDERR { this_log->fh = stderr; } ; log_mask: ALL { $$ = ~0; } | '{' log_mask_list '}' { $$ = $2; } ; log_mask_list: log_cat { $$ = 1 << $1; } | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); } ; log_cat: DEBUG { $$ = L_DEBUG[0]; } | TRACE { $$ = L_TRACE[0]; } | INFO { $$ = L_INFO[0]; } | REMOTE { $$ = L_REMOTE[0]; } | WARNING { $$ = L_WARN[0]; } | ERROR { $$ = L_ERR[0]; } | AUTH { $$ = L_AUTH[0]; } | FATAL { $$ = L_FATAL[0]; } | BUG { $$ = L_BUG[0]; } ; conf: mrtdump_base ; mrtdump_base: MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; } | MRTDUMP text ';' { if (!parse_and_exit) { struct rfile *f = rf_open(new_config->pool, $2, "a"); if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2); new_config->mrtdump_file = rf_fileno(f); } } ; conf: debug_unix ; debug_unix: DEBUG LATENCY bool { new_config->latency_debug = $3; } | DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; } | WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; } | WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; } ; /* Unix specific commands */ CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]]) CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"\"] [timeout []], [[Reload configuration]]) { cmd_reconfig($2, RECONFIG_HARD, $3); } ; CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"\"] [timeout []], [[Reload configuration and ignore changes in filters]]) { cmd_reconfig($3, RECONFIG_SOFT, $4); } ; /* Hack to get input completion for 'timeout' */ CF_CLI_CMD(CONFIGURE TIMEOUT, [], [[Reload configuration with undo timeout]]) CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [], [[Reload configuration with undo timeout]]) CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]]) { cmd_reconfig_confirm(); } ; CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]]) { cmd_reconfig_undo(); } ; CF_CLI(CONFIGURE STATUS,,, [[Show configuration status]]) { cmd_reconfig_status(); } ; CF_CLI(CONFIGURE CHECK, cfg_name, [\"\"], [[Parse configuration and check its validity]]) { cmd_check_config($3); } ; CF_CLI(DOWN,,, [[Shut the daemon down]]) { cmd_shutdown(); } ; CF_CLI_HELP(GRACEFUL, restart, [[Shut the daemon down for graceful restart]]) CF_CLI(GRACEFUL RESTART,,, [[Shut the daemon down for graceful restart]]) { cmd_graceful_restart(); } ; cfg_name: /* empty */ { $$ = NULL; } | TEXT ; cfg_timeout: /* empty */ { $$ = 0; } | TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; } | TIMEOUT expr { $$ = $2; } ; CF_CODE CF_END bird-2.0.8/sysdep/unix/Makefile0000664000175000017500000000030514025744326015314 0ustar feelafeelasrc := io.c krt.c log.c main.c random.c obj := $(src-o-files) $(all-daemon) $(cf-local) $(conf-y-targets): $(s)krt.Y src := $(filter-out main.c, $(src)) tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/sysdep/unix/Doc0000664000175000017500000000006514025744326014307 0ustar feelafeelaS log.c S krt.c # io.c is documented under Resources bird-2.0.8/sysdep/sysdep.sgml0000664000175000017500000000173714025744326015076 0ustar feelafeela System dependent parts Introduction

We've tried to make BIRD as portable as possible, but unfortunately communication with the network stack differs from one OS to another, so we need at least some OS specific code. The good news is that this code is isolated in a small set of modules: is a header file with configuration information, definition of the standard set of types and so on. bird-2.0.8/sysdep/linux/0000775000175000017500000000000014025744326014032 5ustar feelafeelabird-2.0.8/sysdep/linux/syspriv.h0000664000175000017500000000355014025744326015725 0ustar feelafeela#ifndef _BIRD_SYSPRIV_H_ #define _BIRD_SYSPRIV_H_ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #ifndef _LINUX_CAPABILITY_VERSION_3 #define _LINUX_CAPABILITY_VERSION_3 0x20080522 #define _LINUX_CAPABILITY_U32S_3 2 #endif /* CAP_TO_MASK is missing in CentOS header files */ #ifndef CAP_TO_MASK #define CAP_TO_MASK(x) (1 << ((x) & 31)) #endif /* capset() prototype is missing ... */ int capset(cap_user_header_t hdrp, const cap_user_data_t datap); static inline int set_capabilities(u32 caps) { struct __user_cap_header_struct cap_hdr; struct __user_cap_data_struct cap_dat[_LINUX_CAPABILITY_U32S_3]; int err; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = 0; memset(cap_dat, 0, sizeof(cap_dat)); cap_dat[0].effective = cap_dat[0].permitted = caps; err = capset(&cap_hdr, cap_dat); if (!err) return 0; /* Kernel may support do not support our version of capability interface. The last call returned supported version so we just retry it. */ if (errno == EINVAL) { err = capset(&cap_hdr, cap_dat); if (!err) return 0; } return -1; } static void drop_uid(uid_t uid) { u32 caps = CAP_TO_MASK(CAP_NET_BIND_SERVICE) | CAP_TO_MASK(CAP_NET_BROADCAST) | CAP_TO_MASK(CAP_NET_ADMIN) | CAP_TO_MASK(CAP_NET_RAW); /* change effective user ID to be able to switch to that user ID completely after dropping CAP_SETUID */ if (seteuid(uid) < 0) die("seteuid: %m"); /* restrict the capabilities */ if (set_capabilities(caps) < 0) die("capset: %m"); /* keep the capabilities after dropping root ID */ if (prctl(PR_SET_KEEPCAPS, 1) < 0) die("prctl: %m"); /* completely switch to the unprivileged user ID */ if (setresuid(uid, uid, uid) < 0) die("setresuid: %m"); } #endif /* _BIRD_SYSPRIV_H_ */ bird-2.0.8/sysdep/linux/sysio.h0000664000175000017500000001334414025744326015356 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Linux Multicasting and Network Includes * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef IPV6_MINHOPCOUNT #define IPV6_MINHOPCOUNT 73 #endif #ifndef TCP_MD5SIG_EXT #define TCP_MD5SIG_EXT 32 #endif #ifndef TCP_MD5SIG_FLAG_PREFIX #define TCP_MD5SIG_FLAG_PREFIX 1 #endif /* We redefine the tcp_md5sig structure with different name to avoid collision with older headers */ struct tcp_md5sig_ext { struct sockaddr_storage tcpm_addr; /* Address associated */ u8 tcpm_flags; /* Extension flags */ u8 tcpm_prefixlen; /* Address prefix */ u16 tcpm_keylen; /* Key length */ u32 __tcpm_pad2; /* Zero */ u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary) */ }; /* Linux does not care if sa_len is larger than needed */ #define SA_LEN(x) sizeof(sockaddr) /* * Linux IPv4 multicast syscalls */ #define INIT_MREQ4(maddr,ifa) \ { .imr_multiaddr = ipa_to_in4(maddr), .imr_ifindex = ifa->index } static inline int sk_setup_multicast4(sock *s) { struct ip_mreqn mr = { .imr_ifindex = s->iface->index }; int ttl = s->ttl; int n = 0; /* This defines where should we send _outgoing_ multicasts */ if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_IF, &mr, sizeof(mr)) < 0) ERR("IP_MULTICAST_IF"); if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) ERR("IP_MULTICAST_TTL"); if (setsockopt(s->fd, SOL_IP, IP_MULTICAST_LOOP, &n, sizeof(n)) < 0) ERR("IP_MULTICAST_LOOP"); return 0; } static inline int sk_join_group4(sock *s, ip_addr maddr) { struct ip_mreqn mr = INIT_MREQ4(maddr, s->iface); if (setsockopt(s->fd, SOL_IP, IP_ADD_MEMBERSHIP, &mr, sizeof(mr)) < 0) ERR("IP_ADD_MEMBERSHIP"); return 0; } static inline int sk_leave_group4(sock *s, ip_addr maddr) { struct ip_mreqn mr = INIT_MREQ4(maddr, s->iface); if (setsockopt(s->fd, SOL_IP, IP_DROP_MEMBERSHIP, &mr, sizeof(mr)) < 0) ERR("IP_DROP_MEMBERSHIP"); return 0; } /* * Linux IPv4 packet control messages */ /* Mostly similar to standardized IPv6 code */ #define CMSG4_SPACE_PKTINFO CMSG_SPACE(sizeof(struct in_pktinfo)) #define CMSG4_SPACE_TTL CMSG_SPACE(sizeof(int)) static inline int sk_request_cmsg4_pktinfo(sock *s) { int y = 1; if (setsockopt(s->fd, SOL_IP, IP_PKTINFO, &y, sizeof(y)) < 0) ERR("IP_PKTINFO"); return 0; } static inline int sk_request_cmsg4_ttl(sock *s) { int y = 1; if (setsockopt(s->fd, SOL_IP, IP_RECVTTL, &y, sizeof(y)) < 0) ERR("IP_RECVTTL"); return 0; } static inline void sk_process_cmsg4_pktinfo(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IP_PKTINFO) { struct in_pktinfo *pi = (struct in_pktinfo *) CMSG_DATA(cm); s->laddr = ipa_from_in4(pi->ipi_addr); s->lifindex = pi->ipi_ifindex; } } static inline void sk_process_cmsg4_ttl(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IP_TTL) s->rcv_ttl = * (int *) CMSG_DATA(cm); } static inline void sk_prepare_cmsgs4(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen) { struct cmsghdr *cm; struct in_pktinfo *pi; int controllen = 0; msg->msg_control = cbuf; msg->msg_controllen = cbuflen; cm = CMSG_FIRSTHDR(msg); cm->cmsg_level = SOL_IP; cm->cmsg_type = IP_PKTINFO; cm->cmsg_len = CMSG_LEN(sizeof(*pi)); controllen += CMSG_SPACE(sizeof(*pi)); pi = (struct in_pktinfo *) CMSG_DATA(cm); pi->ipi_ifindex = s->iface ? s->iface->index : 0; pi->ipi_spec_dst = ipa_to_in4(s->saddr); pi->ipi_addr = ipa_to_in4(IPA_NONE); msg->msg_controllen = controllen; } /* * Miscellaneous Linux socket syscalls */ int sk_set_md5_auth(sock *s, ip_addr local UNUSED, ip_addr remote, int pxlen, struct iface *ifa, const char *passwd, int setkey UNUSED) { struct tcp_md5sig_ext md5; memset(&md5, 0, sizeof(md5)); sockaddr_fill((sockaddr *) &md5.tcpm_addr, s->af, remote, ifa, 0); if (passwd) { int len = strlen(passwd); if (len > TCP_MD5SIG_MAXKEYLEN) ERR_MSG("The password for TCP MD5 Signature is too long"); md5.tcpm_keylen = len; memcpy(&md5.tcpm_key, passwd, len); } if (pxlen < 0) { if (setsockopt(s->fd, SOL_TCP, TCP_MD5SIG, &md5, sizeof(md5)) < 0) if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support TCP MD5 signatures"); else ERR("TCP_MD5SIG"); } else { md5.tcpm_flags = TCP_MD5SIG_FLAG_PREFIX; md5.tcpm_prefixlen = pxlen; if (setsockopt(s->fd, SOL_TCP, TCP_MD5SIG_EXT, &md5, sizeof(md5)) < 0) { if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support extended TCP MD5 signatures"); else ERR("TCP_MD5SIG_EXT"); } } return 0; } static inline int sk_set_min_ttl4(sock *s, int ttl) { if (setsockopt(s->fd, SOL_IP, IP_MINTTL, &ttl, sizeof(ttl)) < 0) { if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support IPv4 TTL security"); else ERR("IP_MINTTL"); } return 0; } static inline int sk_set_min_ttl6(sock *s, int ttl) { if (setsockopt(s->fd, SOL_IPV6, IPV6_MINHOPCOUNT, &ttl, sizeof(ttl)) < 0) { if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support IPv6 TTL security"); else ERR("IPV6_MINHOPCOUNT"); } return 0; } static inline int sk_disable_mtu_disc4(sock *s) { int dont = IP_PMTUDISC_DONT; if (setsockopt(s->fd, SOL_IP, IP_MTU_DISCOVER, &dont, sizeof(dont)) < 0) ERR("IP_MTU_DISCOVER"); return 0; } static inline int sk_disable_mtu_disc6(sock *s) { int dont = IPV6_PMTUDISC_DONT; if (setsockopt(s->fd, SOL_IPV6, IPV6_MTU_DISCOVER, &dont, sizeof(dont)) < 0) ERR("IPV6_MTU_DISCOVER"); return 0; } int sk_priority_control = 7; static inline int sk_set_priority(sock *s, int prio) { if (setsockopt(s->fd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)) < 0) ERR("SO_PRIORITY"); return 0; } bird-2.0.8/sysdep/linux/netlink.c0000664000175000017500000014530214025744326015647 0ustar feelafeela/* * BIRD -- Linux Netlink Interface * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include #include #include #include #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "lib/alloca.h" #include "sysdep/unix/unix.h" #include "sysdep/unix/krt.h" #include "lib/socket.h" #include "lib/string.h" #include "lib/hash.h" #include "conf/conf.h" #include #include #include #include #ifdef HAVE_MPLS_KERNEL #include #endif #ifndef MSG_TRUNC /* Hack: Several versions of glibc miss this one :( */ #define MSG_TRUNC 0x20 #endif #ifndef IFA_FLAGS #define IFA_FLAGS 8 #endif #ifndef IFF_LOWER_UP #define IFF_LOWER_UP 0x10000 #endif #ifndef RTA_TABLE #define RTA_TABLE 15 #endif #ifndef RTA_VIA #define RTA_VIA 18 #endif #ifndef RTA_NEWDST #define RTA_NEWDST 19 #endif #ifndef RTA_ENCAP_TYPE #define RTA_ENCAP_TYPE 21 #endif #ifndef RTA_ENCAP #define RTA_ENCAP 22 #endif #define krt_ipv4(p) ((p)->af == AF_INET) #define krt_ecmp6(p) ((p)->af == AF_INET6) const int rt_default_ecmp = 16; /* * Structure nl_parse_state keeps state of received route processing. Ideally, * we could just independently parse received Netlink messages and immediately * propagate received routes to the rest of BIRD, but older Linux kernel (before * version 4.11) represents and announces IPv6 ECMP routes not as one route with * multiple next hops (like RTA_MULTIPATH in IPv4 ECMP), but as a sequence of * routes with the same prefix. More recent kernels work as with IPv4. * * Therefore, BIRD keeps currently processed route in nl_parse_state structure * and postpones its propagation until we expect it to be final; i.e., when * non-matching route is received or when the scan ends. When another matching * route is received, it is merged with the already processed route to form an * ECMP route. Note that merging is done only for IPv6 (merge == 1), but the * postponing is done in both cases (for simplicity). All IPv4 routes or IPv6 * routes with RTA_MULTIPATH set are just considered non-matching. * * This is ignored for asynchronous notifications (every notification is handled * as a separate route). It is not an issue for our routes, as we ignore such * notifications anyways. But importing alien IPv6 ECMP routes does not work * properly with older kernels. * * Whatever the kernel version is, IPv6 ECMP routes are sent as multiple routes * for the same prefix. */ struct nl_parse_state { struct linpool *pool; int scan; int merge; net *net; rta *attrs; struct krt_proto *proto; s8 new; s8 krt_src; u8 krt_type; u8 krt_proto; u32 krt_metric; u32 rta_flow; /* Used during parsing */ }; /* * Synchronous Netlink interface */ struct nl_sock { int fd; u32 seq; byte *rx_buffer; /* Receive buffer */ struct nlmsghdr *last_hdr; /* Recently received packet */ uint last_size; }; #define NL_RX_SIZE 8192 #define NL_OP_DELETE 0 #define NL_OP_ADD (NLM_F_CREATE|NLM_F_EXCL) #define NL_OP_REPLACE (NLM_F_CREATE|NLM_F_REPLACE) #define NL_OP_APPEND (NLM_F_CREATE|NLM_F_APPEND) static linpool *nl_linpool; static struct nl_sock nl_scan = {.fd = -1}; /* Netlink socket for synchronous scan */ static struct nl_sock nl_req = {.fd = -1}; /* Netlink socket for requests */ static void nl_open_sock(struct nl_sock *nl) { if (nl->fd < 0) { nl->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (nl->fd < 0) die("Unable to open rtnetlink socket: %m"); nl->seq = (u32) (current_time() TO_S); /* Or perhaps random_u32() ? */ nl->rx_buffer = xmalloc(NL_RX_SIZE); nl->last_hdr = NULL; nl->last_size = 0; } } static void nl_open(void) { nl_open_sock(&nl_scan); nl_open_sock(&nl_req); } static void nl_send(struct nl_sock *nl, struct nlmsghdr *nh) { struct sockaddr_nl sa; memset(&sa, 0, sizeof(sa)); sa.nl_family = AF_NETLINK; nh->nlmsg_pid = 0; nh->nlmsg_seq = ++(nl->seq); nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len); if (sendto(nl->fd, nh, nh->nlmsg_len, 0, (struct sockaddr *)&sa, sizeof(sa)) < 0) die("rtnetlink sendto: %m"); nl->last_hdr = NULL; } static void nl_request_dump(int af, int cmd) { struct { struct nlmsghdr nh; struct rtgenmsg g; } req = { .nh.nlmsg_type = cmd, .nh.nlmsg_len = sizeof(req), .nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP, .g.rtgen_family = af }; nl_send(&nl_scan, &req.nh); } static struct nlmsghdr * nl_get_reply(struct nl_sock *nl) { for(;;) { if (!nl->last_hdr) { struct iovec iov = { nl->rx_buffer, NL_RX_SIZE }; struct sockaddr_nl sa; struct msghdr m = { .msg_name = &sa, .msg_namelen = sizeof(sa), .msg_iov = &iov, .msg_iovlen = 1, }; int x = recvmsg(nl->fd, &m, 0); if (x < 0) die("nl_get_reply: %m"); if (sa.nl_pid) /* It isn't from the kernel */ { DBG("Non-kernel packet\n"); continue; } nl->last_size = x; nl->last_hdr = (void *) nl->rx_buffer; if (m.msg_flags & MSG_TRUNC) bug("nl_get_reply: got truncated reply which should be impossible"); } if (NLMSG_OK(nl->last_hdr, nl->last_size)) { struct nlmsghdr *h = nl->last_hdr; nl->last_hdr = NLMSG_NEXT(h, nl->last_size); if (h->nlmsg_seq != nl->seq) { log(L_WARN "nl_get_reply: Ignoring out of sequence netlink packet (%x != %x)", h->nlmsg_seq, nl->seq); continue; } return h; } if (nl->last_size) log(L_WARN "nl_get_reply: Found packet remnant of size %d", nl->last_size); nl->last_hdr = NULL; } } static struct tbf rl_netlink_err = TBF_DEFAULT_LOG_LIMITS; static int nl_error(struct nlmsghdr *h, int ignore_esrch) { struct nlmsgerr *e; int ec; if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { log(L_WARN "Netlink: Truncated error message received"); return ENOBUFS; } e = (struct nlmsgerr *) NLMSG_DATA(h); ec = -e->error; if (ec && !(ignore_esrch && (ec == ESRCH))) log_rl(&rl_netlink_err, L_WARN "Netlink: %s", strerror(ec)); return ec; } static struct nlmsghdr * nl_get_scan(void) { struct nlmsghdr *h = nl_get_reply(&nl_scan); if (h->nlmsg_type == NLMSG_DONE) return NULL; if (h->nlmsg_type == NLMSG_ERROR) { nl_error(h, 0); return NULL; } return h; } static int nl_exchange(struct nlmsghdr *pkt, int ignore_esrch) { struct nlmsghdr *h; nl_send(&nl_req, pkt); for(;;) { h = nl_get_reply(&nl_req); if (h->nlmsg_type == NLMSG_ERROR) break; log(L_WARN "nl_exchange: Unexpected reply received"); } return nl_error(h, ignore_esrch) ? -1 : 0; } /* * Netlink attributes */ static int nl_attr_len; static void * nl_checkin(struct nlmsghdr *h, int lsize) { nl_attr_len = h->nlmsg_len - NLMSG_LENGTH(lsize); if (nl_attr_len < 0) { log(L_ERR "nl_checkin: underrun by %d bytes", -nl_attr_len); return NULL; } return NLMSG_DATA(h); } struct nl_want_attrs { u8 defined:1; u8 checksize:1; u8 size; }; #define BIRD_IFLA_MAX (IFLA_WIRELESS+1) static struct nl_want_attrs ifla_attr_want[BIRD_IFLA_MAX] = { [IFLA_IFNAME] = { 1, 0, 0 }, [IFLA_MTU] = { 1, 1, sizeof(u32) }, [IFLA_MASTER] = { 1, 1, sizeof(u32) }, [IFLA_WIRELESS] = { 1, 0, 0 }, }; #define BIRD_IFA_MAX (IFA_FLAGS+1) static struct nl_want_attrs ifa_attr_want4[BIRD_IFA_MAX] = { [IFA_ADDRESS] = { 1, 1, sizeof(ip4_addr) }, [IFA_LOCAL] = { 1, 1, sizeof(ip4_addr) }, [IFA_BROADCAST] = { 1, 1, sizeof(ip4_addr) }, [IFA_FLAGS] = { 1, 1, sizeof(u32) }, }; static struct nl_want_attrs ifa_attr_want6[BIRD_IFA_MAX] = { [IFA_ADDRESS] = { 1, 1, sizeof(ip6_addr) }, [IFA_LOCAL] = { 1, 1, sizeof(ip6_addr) }, [IFA_FLAGS] = { 1, 1, sizeof(u32) }, }; #define BIRD_RTA_MAX (RTA_ENCAP+1) static struct nl_want_attrs nexthop_attr_want4[BIRD_RTA_MAX] = { [RTA_GATEWAY] = { 1, 1, sizeof(ip4_addr) }, [RTA_VIA] = { 1, 0, 0 }, [RTA_FLOW] = { 1, 1, sizeof(u32) }, [RTA_ENCAP_TYPE]= { 1, 1, sizeof(u16) }, [RTA_ENCAP] = { 1, 0, 0 }, }; static struct nl_want_attrs nexthop_attr_want6[BIRD_RTA_MAX] = { [RTA_GATEWAY] = { 1, 1, sizeof(ip6_addr) }, [RTA_VIA] = { 1, 0, 0 }, [RTA_FLOW] = { 1, 1, sizeof(u32) }, [RTA_ENCAP_TYPE]= { 1, 1, sizeof(u16) }, [RTA_ENCAP] = { 1, 0, 0 }, }; #ifdef HAVE_MPLS_KERNEL static struct nl_want_attrs nexthop_attr_want_mpls[BIRD_RTA_MAX] = { [RTA_VIA] = { 1, 0, 0 }, [RTA_NEWDST] = { 1, 0, 0 }, }; static struct nl_want_attrs encap_mpls_want[BIRD_RTA_MAX] = { [RTA_DST] = { 1, 0, 0 }, }; #endif static struct nl_want_attrs rtm_attr_want4[BIRD_RTA_MAX] = { [RTA_DST] = { 1, 1, sizeof(ip4_addr) }, [RTA_OIF] = { 1, 1, sizeof(u32) }, [RTA_GATEWAY] = { 1, 1, sizeof(ip4_addr) }, [RTA_PRIORITY] = { 1, 1, sizeof(u32) }, [RTA_PREFSRC] = { 1, 1, sizeof(ip4_addr) }, [RTA_METRICS] = { 1, 0, 0 }, [RTA_MULTIPATH] = { 1, 0, 0 }, [RTA_FLOW] = { 1, 1, sizeof(u32) }, [RTA_TABLE] = { 1, 1, sizeof(u32) }, [RTA_VIA] = { 1, 0, 0 }, [RTA_ENCAP_TYPE]= { 1, 1, sizeof(u16) }, [RTA_ENCAP] = { 1, 0, 0 }, }; static struct nl_want_attrs rtm_attr_want6[BIRD_RTA_MAX] = { [RTA_DST] = { 1, 1, sizeof(ip6_addr) }, [RTA_SRC] = { 1, 1, sizeof(ip6_addr) }, [RTA_IIF] = { 1, 1, sizeof(u32) }, [RTA_OIF] = { 1, 1, sizeof(u32) }, [RTA_GATEWAY] = { 1, 1, sizeof(ip6_addr) }, [RTA_PRIORITY] = { 1, 1, sizeof(u32) }, [RTA_PREFSRC] = { 1, 1, sizeof(ip6_addr) }, [RTA_METRICS] = { 1, 0, 0 }, [RTA_MULTIPATH] = { 1, 0, 0 }, [RTA_FLOW] = { 1, 1, sizeof(u32) }, [RTA_TABLE] = { 1, 1, sizeof(u32) }, [RTA_VIA] = { 1, 0, 0 }, [RTA_ENCAP_TYPE]= { 1, 1, sizeof(u16) }, [RTA_ENCAP] = { 1, 0, 0 }, }; #ifdef HAVE_MPLS_KERNEL static struct nl_want_attrs rtm_attr_want_mpls[BIRD_RTA_MAX] = { [RTA_DST] = { 1, 1, sizeof(u32) }, [RTA_IIF] = { 1, 1, sizeof(u32) }, [RTA_OIF] = { 1, 1, sizeof(u32) }, [RTA_PRIORITY] = { 1, 1, sizeof(u32) }, [RTA_METRICS] = { 1, 0, 0 }, [RTA_MULTIPATH] = { 1, 0, 0 }, [RTA_FLOW] = { 1, 1, sizeof(u32) }, [RTA_TABLE] = { 1, 1, sizeof(u32) }, [RTA_VIA] = { 1, 0, 0 }, [RTA_NEWDST] = { 1, 0, 0 }, }; #endif static int nl_parse_attrs(struct rtattr *a, struct nl_want_attrs *want, struct rtattr **k, int ksize) { int max = ksize / sizeof(struct rtattr *); bzero(k, ksize); for ( ; RTA_OK(a, nl_attr_len); a = RTA_NEXT(a, nl_attr_len)) { if ((a->rta_type >= max) || !want[a->rta_type].defined) continue; if (want[a->rta_type].checksize && (RTA_PAYLOAD(a) != want[a->rta_type].size)) { log(L_ERR "nl_parse_attrs: Malformed attribute received"); return 0; } k[a->rta_type] = a; } if (nl_attr_len) { log(L_ERR "nl_parse_attrs: remnant of size %d", nl_attr_len); return 0; } return 1; } static inline u16 rta_get_u16(struct rtattr *a) { return *(u16 *) RTA_DATA(a); } static inline u32 rta_get_u32(struct rtattr *a) { return *(u32 *) RTA_DATA(a); } static inline ip4_addr rta_get_ip4(struct rtattr *a) { return ip4_ntoh(*(ip4_addr *) RTA_DATA(a)); } static inline ip6_addr rta_get_ip6(struct rtattr *a) { return ip6_ntoh(*(ip6_addr *) RTA_DATA(a)); } static inline ip_addr rta_get_ipa(struct rtattr *a) { if (RTA_PAYLOAD(a) == sizeof(ip4_addr)) return ipa_from_ip4(rta_get_ip4(a)); else return ipa_from_ip6(rta_get_ip6(a)); } #ifdef HAVE_MPLS_KERNEL static inline ip_addr rta_get_via(struct rtattr *a) { struct rtvia *v = RTA_DATA(a); switch(v->rtvia_family) { case AF_INET: return ipa_from_ip4(ip4_ntoh(*(ip4_addr *) v->rtvia_addr)); case AF_INET6: return ipa_from_ip6(ip6_ntoh(*(ip6_addr *) v->rtvia_addr)); } return IPA_NONE; } static u32 rta_mpls_stack[MPLS_MAX_LABEL_STACK]; static inline int rta_get_mpls(struct rtattr *a, u32 *stack) { if (!a) return 0; if (RTA_PAYLOAD(a) % 4) log(L_WARN "KRT: Strange length of received MPLS stack: %u", RTA_PAYLOAD(a)); int labels = mpls_get(RTA_DATA(a), RTA_PAYLOAD(a) & ~0x3, stack); if (labels < 0) { log(L_WARN "KRT: Too long MPLS stack received, ignoring"); labels = 0; } return labels; } #endif struct rtattr * nl_add_attr(struct nlmsghdr *h, uint bufsize, uint code, const void *data, uint dlen) { uint pos = NLMSG_ALIGN(h->nlmsg_len); uint len = RTA_LENGTH(dlen); if (pos + len > bufsize) bug("nl_add_attr: packet buffer overflow"); struct rtattr *a = (struct rtattr *)((char *)h + pos); a->rta_type = code; a->rta_len = len; h->nlmsg_len = pos + len; if (dlen > 0) memcpy(RTA_DATA(a), data, dlen); return a; } static inline struct rtattr * nl_open_attr(struct nlmsghdr *h, uint bufsize, uint code) { return nl_add_attr(h, bufsize, code, NULL, 0); } static inline void nl_close_attr(struct nlmsghdr *h, struct rtattr *a) { a->rta_len = (void *)h + NLMSG_ALIGN(h->nlmsg_len) - (void *)a; } static inline void nl_add_attr_u16(struct nlmsghdr *h, uint bufsize, int code, u16 data) { nl_add_attr(h, bufsize, code, &data, 2); } static inline void nl_add_attr_u32(struct nlmsghdr *h, uint bufsize, int code, u32 data) { nl_add_attr(h, bufsize, code, &data, 4); } static inline void nl_add_attr_ip4(struct nlmsghdr *h, uint bufsize, int code, ip4_addr ip4) { ip4 = ip4_hton(ip4); nl_add_attr(h, bufsize, code, &ip4, sizeof(ip4)); } static inline void nl_add_attr_ip6(struct nlmsghdr *h, uint bufsize, int code, ip6_addr ip6) { ip6 = ip6_hton(ip6); nl_add_attr(h, bufsize, code, &ip6, sizeof(ip6)); } static inline void nl_add_attr_ipa(struct nlmsghdr *h, uint bufsize, int code, ip_addr ipa) { if (ipa_is_ip4(ipa)) nl_add_attr_ip4(h, bufsize, code, ipa_to_ip4(ipa)); else nl_add_attr_ip6(h, bufsize, code, ipa_to_ip6(ipa)); } #ifdef HAVE_MPLS_KERNEL static inline void nl_add_attr_mpls(struct nlmsghdr *h, uint bufsize, int code, int len, u32 *stack) { char buf[len*4]; mpls_put(buf, len, stack); nl_add_attr(h, bufsize, code, buf, len*4); } static inline void nl_add_attr_mpls_encap(struct nlmsghdr *h, uint bufsize, int len, u32 *stack) { nl_add_attr_u16(h, bufsize, RTA_ENCAP_TYPE, LWTUNNEL_ENCAP_MPLS); struct rtattr *nest = nl_open_attr(h, bufsize, RTA_ENCAP); nl_add_attr_mpls(h, bufsize, RTA_DST, len, stack); nl_close_attr(h, nest); } static inline void nl_add_attr_via(struct nlmsghdr *h, uint bufsize, ip_addr ipa) { struct rtvia *via = alloca(sizeof(struct rtvia) + 16); if (ipa_is_ip4(ipa)) { via->rtvia_family = AF_INET; put_ip4(via->rtvia_addr, ipa_to_ip4(ipa)); nl_add_attr(h, bufsize, RTA_VIA, via, sizeof(struct rtvia) + 4); } else { via->rtvia_family = AF_INET6; put_ip6(via->rtvia_addr, ipa_to_ip6(ipa)); nl_add_attr(h, bufsize, RTA_VIA, via, sizeof(struct rtvia) + 16); } } #endif static inline struct rtnexthop * nl_open_nexthop(struct nlmsghdr *h, uint bufsize) { uint pos = NLMSG_ALIGN(h->nlmsg_len); uint len = RTNH_LENGTH(0); if (pos + len > bufsize) bug("nl_open_nexthop: packet buffer overflow"); h->nlmsg_len = pos + len; return (void *)h + pos; } static inline void nl_close_nexthop(struct nlmsghdr *h, struct rtnexthop *nh) { nh->rtnh_len = (void *)h + NLMSG_ALIGN(h->nlmsg_len) - (void *)nh; } static inline void nl_add_nexthop(struct nlmsghdr *h, uint bufsize, struct nexthop *nh, int af UNUSED) { #ifdef HAVE_MPLS_KERNEL if (nh->labels > 0) if (af == AF_MPLS) nl_add_attr_mpls(h, bufsize, RTA_NEWDST, nh->labels, nh->label); else nl_add_attr_mpls_encap(h, bufsize, nh->labels, nh->label); if (ipa_nonzero(nh->gw)) { if (af == (ipa_is_ip4(nh->gw) ? AF_INET : AF_INET6)) nl_add_attr_ipa(h, bufsize, RTA_GATEWAY, nh->gw); else nl_add_attr_via(h, bufsize, nh->gw); } #else if (ipa_nonzero(nh->gw)) nl_add_attr_ipa(h, bufsize, RTA_GATEWAY, nh->gw); #endif } static void nl_add_multipath(struct nlmsghdr *h, uint bufsize, struct nexthop *nh, int af, ea_list *eattrs) { struct rtattr *a = nl_open_attr(h, bufsize, RTA_MULTIPATH); eattr *flow = ea_find(eattrs, EA_KRT_REALM); for (; nh; nh = nh->next) { struct rtnexthop *rtnh = nl_open_nexthop(h, bufsize); rtnh->rtnh_flags = 0; rtnh->rtnh_hops = nh->weight; rtnh->rtnh_ifindex = nh->iface->index; nl_add_nexthop(h, bufsize, nh, af); if (nh->flags & RNF_ONLINK) rtnh->rtnh_flags |= RTNH_F_ONLINK; /* Our KRT_REALM is per-route, but kernel RTA_FLOW is per-nexthop. Therefore, we need to attach the same attribute to each nexthop. */ if (flow) nl_add_attr_u32(h, bufsize, RTA_FLOW, flow->u.data); nl_close_nexthop(h, rtnh); } nl_close_attr(h, a); } static struct nexthop * nl_parse_multipath(struct nl_parse_state *s, struct krt_proto *p, struct rtattr *ra, int af) { struct rtattr *a[BIRD_RTA_MAX]; struct rtnexthop *nh = RTA_DATA(ra); struct nexthop *rv, *first, **last; unsigned len = RTA_PAYLOAD(ra); first = NULL; last = &first; while (len) { /* Use RTNH_OK(nh,len) ?? */ if ((len < sizeof(*nh)) || (len < nh->rtnh_len)) return NULL; if (nh->rtnh_flags & RTNH_F_DEAD) goto next; *last = rv = lp_allocz(s->pool, NEXTHOP_MAX_SIZE); last = &(rv->next); rv->weight = nh->rtnh_hops; rv->iface = if_find_by_index(nh->rtnh_ifindex); if (!rv->iface) return NULL; /* Nonexistent RTNH_PAYLOAD ?? */ nl_attr_len = nh->rtnh_len - RTNH_LENGTH(0); switch (af) { case AF_INET: if (!nl_parse_attrs(RTNH_DATA(nh), nexthop_attr_want4, a, sizeof(a))) return NULL; break; case AF_INET6: if (!nl_parse_attrs(RTNH_DATA(nh), nexthop_attr_want6, a, sizeof(a))) return NULL; break; #ifdef HAVE_MPLS_KERNEL case AF_MPLS: if (!nl_parse_attrs(RTNH_DATA(nh), nexthop_attr_want_mpls, a, sizeof(a))) return NULL; if (a[RTA_NEWDST]) rv->labels = rta_get_mpls(a[RTA_NEWDST], rv->label); break; #endif default: return NULL; } if (a[RTA_GATEWAY]) rv->gw = rta_get_ipa(a[RTA_GATEWAY]); if (a[RTA_FLOW]) s->rta_flow = rta_get_u32(a[RTA_FLOW]); #ifdef HAVE_MPLS_KERNEL if (a[RTA_VIA]) rv->gw = rta_get_via(a[RTA_VIA]); #endif if (ipa_nonzero(rv->gw)) { if (nh->rtnh_flags & RTNH_F_ONLINK) rv->flags |= RNF_ONLINK; neighbor *nbr; nbr = neigh_find(&p->p, rv->gw, rv->iface, (rv->flags & RNF_ONLINK) ? NEF_ONLINK : 0); if (!nbr || (nbr->scope == SCOPE_HOST)) return NULL; } #ifdef HAVE_MPLS_KERNEL if (a[RTA_ENCAP] && a[RTA_ENCAP_TYPE]) { if (rta_get_u16(a[RTA_ENCAP_TYPE]) != LWTUNNEL_ENCAP_MPLS) { log(L_WARN "KRT: Unknown encapsulation method %d in multipath", rta_get_u16(a[RTA_ENCAP_TYPE])); return NULL; } struct rtattr *enca[BIRD_RTA_MAX]; nl_attr_len = RTA_PAYLOAD(a[RTA_ENCAP]); nl_parse_attrs(RTA_DATA(a[RTA_ENCAP]), encap_mpls_want, enca, sizeof(enca)); rv->labels = rta_get_mpls(enca[RTA_DST], rv->label); } #endif next: len -= NLMSG_ALIGN(nh->rtnh_len); nh = RTNH_NEXT(nh); } /* Ensure nexthops are sorted to satisfy nest invariant */ if (!nexthop_is_sorted(first)) first = nexthop_sort(first); return first; } static void nl_add_metrics(struct nlmsghdr *h, uint bufsize, u32 *metrics, int max) { struct rtattr *a = nl_open_attr(h, bufsize, RTA_METRICS); int t; for (t = 1; t < max; t++) if (metrics[0] & (1 << t)) nl_add_attr_u32(h, bufsize, t, metrics[t]); nl_close_attr(h, a); } static int nl_parse_metrics(struct rtattr *hdr, u32 *metrics, int max) { struct rtattr *a = RTA_DATA(hdr); int len = RTA_PAYLOAD(hdr); metrics[0] = 0; for (; RTA_OK(a, len); a = RTA_NEXT(a, len)) { if (a->rta_type == RTA_UNSPEC) continue; if (a->rta_type >= max) continue; if (RTA_PAYLOAD(a) != 4) return -1; metrics[0] |= 1 << a->rta_type; metrics[a->rta_type] = rta_get_u32(a); } if (len > 0) return -1; return 0; } /* * Scanning of interfaces */ static void nl_parse_link(struct nlmsghdr *h, int scan) { struct ifinfomsg *i; struct rtattr *a[BIRD_IFLA_MAX]; int new = h->nlmsg_type == RTM_NEWLINK; struct iface f = {}; struct iface *ifi; char *name; u32 mtu, master = 0; uint fl; if (!(i = nl_checkin(h, sizeof(*i))) || !nl_parse_attrs(IFLA_RTA(i), ifla_attr_want, a, sizeof(a))) return; if (!a[IFLA_IFNAME] || (RTA_PAYLOAD(a[IFLA_IFNAME]) < 2) || !a[IFLA_MTU]) { /* * IFLA_IFNAME and IFLA_MTU are required, in fact, but there may also come * a message with IFLA_WIRELESS set, where (e.g.) no IFLA_IFNAME exists. * We simply ignore all such messages with IFLA_WIRELESS without notice. */ if (a[IFLA_WIRELESS]) return; log(L_ERR "KIF: Malformed message received"); return; } name = RTA_DATA(a[IFLA_IFNAME]); mtu = rta_get_u32(a[IFLA_MTU]); if (a[IFLA_MASTER]) master = rta_get_u32(a[IFLA_MASTER]); ifi = if_find_by_index(i->ifi_index); if (!new) { DBG("KIF: IF%d(%s) goes down\n", i->ifi_index, name); if (!ifi) return; if_delete(ifi); } else { DBG("KIF: IF%d(%s) goes up (mtu=%d,flg=%x)\n", i->ifi_index, name, mtu, i->ifi_flags); if (ifi && strncmp(ifi->name, name, sizeof(ifi->name)-1)) if_delete(ifi); strncpy(f.name, name, sizeof(f.name)-1); f.index = i->ifi_index; f.mtu = mtu; f.master_index = master; f.master = if_find_by_index(master); fl = i->ifi_flags; if (fl & IFF_UP) f.flags |= IF_ADMIN_UP; if (fl & IFF_LOWER_UP) f.flags |= IF_LINK_UP; if (fl & IFF_LOOPBACK) /* Loopback */ f.flags |= IF_MULTIACCESS | IF_LOOPBACK | IF_IGNORE; else if (fl & IFF_POINTOPOINT) /* PtP */ f.flags |= IF_MULTICAST; else if (fl & IFF_BROADCAST) /* Broadcast */ f.flags |= IF_MULTIACCESS | IF_BROADCAST | IF_MULTICAST; else f.flags |= IF_MULTIACCESS; /* NBMA */ if (fl & IFF_MULTICAST) f.flags |= IF_MULTICAST; ifi = if_update(&f); if (!scan) if_end_partial_update(ifi); } } static void nl_parse_addr4(struct ifaddrmsg *i, int scan, int new) { struct rtattr *a[BIRD_IFA_MAX]; struct iface *ifi; u32 ifa_flags; int scope; if (!nl_parse_attrs(IFA_RTA(i), ifa_attr_want4, a, sizeof(a))) return; if (!a[IFA_LOCAL]) { log(L_ERR "KIF: Malformed message received (missing IFA_LOCAL)"); return; } if (!a[IFA_ADDRESS]) { log(L_ERR "KIF: Malformed message received (missing IFA_ADDRESS)"); return; } ifi = if_find_by_index(i->ifa_index); if (!ifi) { log(L_ERR "KIF: Received address message for unknown interface %d", i->ifa_index); return; } if (a[IFA_FLAGS]) ifa_flags = rta_get_u32(a[IFA_FLAGS]); else ifa_flags = i->ifa_flags; struct ifa ifa; bzero(&ifa, sizeof(ifa)); ifa.iface = ifi; if (ifa_flags & IFA_F_SECONDARY) ifa.flags |= IA_SECONDARY; ifa.ip = rta_get_ipa(a[IFA_LOCAL]); if (i->ifa_prefixlen > IP4_MAX_PREFIX_LENGTH) { log(L_ERR "KIF: Invalid prefix length for interface %s: %d", ifi->name, i->ifa_prefixlen); new = 0; } if (i->ifa_prefixlen == IP4_MAX_PREFIX_LENGTH) { ifa.brd = rta_get_ipa(a[IFA_ADDRESS]); net_fill_ip4(&ifa.prefix, rta_get_ip4(a[IFA_ADDRESS]), i->ifa_prefixlen); /* It is either a host address or a peer address */ if (ipa_equal(ifa.ip, ifa.brd)) ifa.flags |= IA_HOST; else { ifa.flags |= IA_PEER; ifa.opposite = ifa.brd; } } else { net_fill_ip4(&ifa.prefix, ipa_to_ip4(ifa.ip), i->ifa_prefixlen); net_normalize(&ifa.prefix); if (i->ifa_prefixlen == IP4_MAX_PREFIX_LENGTH - 1) ifa.opposite = ipa_opposite_m1(ifa.ip); if (i->ifa_prefixlen == IP4_MAX_PREFIX_LENGTH - 2) ifa.opposite = ipa_opposite_m2(ifa.ip); if (ifi->flags & IF_BROADCAST) { /* If kernel offers us a broadcast address, we trust it */ if (a[IFA_BROADCAST]) ifa.brd = ipa_from_ip4(rta_get_ip4(a[IFA_BROADCAST])); /* Otherwise we create one (except for /31) */ else if (i->ifa_prefixlen < (IP4_MAX_PREFIX_LENGTH - 1)) ifa.brd = ipa_from_ip4(ip4_or(ipa_to_ip4(ifa.ip), ip4_not(ip4_mkmask(i->ifa_prefixlen)))); } } scope = ipa_classify(ifa.ip); if (scope < 0) { log(L_ERR "KIF: Invalid interface address %I for %s", ifa.ip, ifi->name); return; } ifa.scope = scope & IADDR_SCOPE_MASK; DBG("KIF: IF%d(%s): %s IPA %I, flg %x, net %N, brd %I, opp %I\n", ifi->index, ifi->name, new ? "added" : "removed", ifa.ip, ifa.flags, &ifa.prefix, ifa.brd, ifa.opposite); if (new) ifa_update(&ifa); else ifa_delete(&ifa); if (!scan) if_end_partial_update(ifi); } static void nl_parse_addr6(struct ifaddrmsg *i, int scan, int new) { struct rtattr *a[BIRD_IFA_MAX]; struct iface *ifi; u32 ifa_flags; int scope; if (!nl_parse_attrs(IFA_RTA(i), ifa_attr_want6, a, sizeof(a))) return; if (!a[IFA_ADDRESS]) { log(L_ERR "KIF: Malformed message received (missing IFA_ADDRESS)"); return; } ifi = if_find_by_index(i->ifa_index); if (!ifi) { log(L_ERR "KIF: Received address message for unknown interface %d", i->ifa_index); return; } if (a[IFA_FLAGS]) ifa_flags = rta_get_u32(a[IFA_FLAGS]); else ifa_flags = i->ifa_flags; struct ifa ifa; bzero(&ifa, sizeof(ifa)); ifa.iface = ifi; if (ifa_flags & IFA_F_SECONDARY) ifa.flags |= IA_SECONDARY; /* Ignore tentative addresses silently */ if (ifa_flags & IFA_F_TENTATIVE) return; /* IFA_LOCAL can be unset for IPv6 interfaces */ ifa.ip = rta_get_ipa(a[IFA_LOCAL] ? : a[IFA_ADDRESS]); if (i->ifa_prefixlen > IP6_MAX_PREFIX_LENGTH) { log(L_ERR "KIF: Invalid prefix length for interface %s: %d", ifi->name, i->ifa_prefixlen); new = 0; } if (i->ifa_prefixlen == IP6_MAX_PREFIX_LENGTH) { ifa.brd = rta_get_ipa(a[IFA_ADDRESS]); net_fill_ip6(&ifa.prefix, rta_get_ip6(a[IFA_ADDRESS]), i->ifa_prefixlen); /* It is either a host address or a peer address */ if (ipa_equal(ifa.ip, ifa.brd)) ifa.flags |= IA_HOST; else { ifa.flags |= IA_PEER; ifa.opposite = ifa.brd; } } else { net_fill_ip6(&ifa.prefix, ipa_to_ip6(ifa.ip), i->ifa_prefixlen); net_normalize(&ifa.prefix); if (i->ifa_prefixlen == IP6_MAX_PREFIX_LENGTH - 1) ifa.opposite = ipa_opposite_m1(ifa.ip); } scope = ipa_classify(ifa.ip); if (scope < 0) { log(L_ERR "KIF: Invalid interface address %I for %s", ifa.ip, ifi->name); return; } ifa.scope = scope & IADDR_SCOPE_MASK; DBG("KIF: IF%d(%s): %s IPA %I, flg %x, net %N, brd %I, opp %I\n", ifi->index, ifi->name, new ? "added" : "removed", ifa.ip, ifa.flags, &ifa.prefix, ifa.brd, ifa.opposite); if (new) ifa_update(&ifa); else ifa_delete(&ifa); if (!scan) if_end_partial_update(ifi); } static void nl_parse_addr(struct nlmsghdr *h, int scan) { struct ifaddrmsg *i; if (!(i = nl_checkin(h, sizeof(*i)))) return; int new = (h->nlmsg_type == RTM_NEWADDR); switch (i->ifa_family) { case AF_INET: return nl_parse_addr4(i, scan, new); case AF_INET6: return nl_parse_addr6(i, scan, new); } } void kif_do_scan(struct kif_proto *p UNUSED) { struct nlmsghdr *h; if_start_update(); nl_request_dump(AF_UNSPEC, RTM_GETLINK); while (h = nl_get_scan()) if (h->nlmsg_type == RTM_NEWLINK || h->nlmsg_type == RTM_DELLINK) nl_parse_link(h, 1); else log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type); /* Re-resolve master interface for slaves */ struct iface *i; WALK_LIST(i, iface_list) if (i->master_index) { struct iface f = { .flags = i->flags, .mtu = i->mtu, .index = i->index, .master_index = i->master_index, .master = if_find_by_index(i->master_index) }; if (f.master != i->master) { memcpy(f.name, i->name, sizeof(f.name)); if_update(&f); } } nl_request_dump(AF_INET, RTM_GETADDR); while (h = nl_get_scan()) if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR) nl_parse_addr(h, 1); else log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type); nl_request_dump(AF_INET6, RTM_GETADDR); while (h = nl_get_scan()) if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR) nl_parse_addr(h, 1); else log(L_DEBUG "nl_scan_ifaces: Unknown packet received (type=%d)", h->nlmsg_type); if_end_update(); } /* * Routes */ static inline u32 krt_table_id(struct krt_proto *p) { return KRT_CF->sys.table_id; } static HASH(struct krt_proto) nl_table_map; #define RTH_KEY(p) p->af, krt_table_id(p) #define RTH_NEXT(p) p->sys.hash_next #define RTH_EQ(a1,i1,a2,i2) a1 == a2 && i1 == i2 #define RTH_FN(a,i) a ^ u32_hash(i) #define RTH_REHASH rth_rehash #define RTH_PARAMS /8, *2, 2, 2, 6, 20 HASH_DEFINE_REHASH_FN(RTH, struct krt_proto) int krt_capable(rte *e) { rta *a = e->attrs; switch (a->dest) { case RTD_UNICAST: case RTD_BLACKHOLE: case RTD_UNREACHABLE: case RTD_PROHIBIT: return 1; default: return 0; } } static inline int nh_bufsize(struct nexthop *nh) { int rv = 0; for (; nh != NULL; nh = nh->next) rv += RTNH_LENGTH(RTA_LENGTH(sizeof(ip_addr))); return rv; } static int nl_send_route(struct krt_proto *p, rte *e, int op, int dest, struct nexthop *nh) { eattr *ea; net *net = e->net; rta *a = e->attrs; ea_list *eattrs = a->eattrs; int bufsize = 128 + KRT_METRICS_MAX*8 + nh_bufsize(&(a->nh)); u32 priority = 0; struct { struct nlmsghdr h; struct rtmsg r; char buf[0]; } *r; int rsize = sizeof(*r) + bufsize; r = alloca(rsize); DBG("nl_send_route(%N,op=%x)\n", net->n.addr, op); bzero(&r->h, sizeof(r->h)); bzero(&r->r, sizeof(r->r)); r->h.nlmsg_type = op ? RTM_NEWROUTE : RTM_DELROUTE; r->h.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); r->h.nlmsg_flags = op | NLM_F_REQUEST | NLM_F_ACK; r->r.rtm_family = p->af; r->r.rtm_dst_len = net_pxlen(net->n.addr); r->r.rtm_protocol = RTPROT_BIRD; r->r.rtm_scope = RT_SCOPE_NOWHERE; #ifdef HAVE_MPLS_KERNEL if (p->af == AF_MPLS) { /* * Kernel MPLS code is a bit picky. We must: * 1) Always set RT_SCOPE_UNIVERSE and RTN_UNICAST (even for RTM_DELROUTE) * 2) Never use RTA_PRIORITY */ u32 label = net_mpls(net->n.addr); nl_add_attr_mpls(&r->h, rsize, RTA_DST, 1, &label); r->r.rtm_scope = RT_SCOPE_UNIVERSE; r->r.rtm_type = RTN_UNICAST; } else #endif { nl_add_attr_ipa(&r->h, rsize, RTA_DST, net_prefix(net->n.addr)); /* Add source address for IPv6 SADR routes */ if (net->n.addr->type == NET_IP6_SADR) { net_addr_ip6_sadr *a = (void *) &net->n.addr; nl_add_attr_ip6(&r->h, rsize, RTA_SRC, a->src_prefix); r->r.rtm_src_len = a->src_pxlen; } } /* * Strange behavior for RTM_DELROUTE: * 1) rtm_family is ignored in IPv6, works for IPv4 * 2) not setting RTA_PRIORITY is different from setting default value (on IPv6) * 3) not setting RTA_PRIORITY is equivalent to setting 0, which is wildcard */ if (krt_table_id(p) < 256) r->r.rtm_table = krt_table_id(p); else nl_add_attr_u32(&r->h, rsize, RTA_TABLE, krt_table_id(p)); if (p->af == AF_MPLS) priority = 0; else if (a->source == RTS_DUMMY) priority = e->u.krt.metric; else if (KRT_CF->sys.metric) priority = KRT_CF->sys.metric; else if ((op != NL_OP_DELETE) && (ea = ea_find(eattrs, EA_KRT_METRIC))) priority = ea->u.data; if (priority) nl_add_attr_u32(&r->h, rsize, RTA_PRIORITY, priority); /* For route delete, we do not specify remaining route attributes */ if (op == NL_OP_DELETE) goto dest; /* Default scope is LINK for device routes, UNIVERSE otherwise */ if (p->af == AF_MPLS) r->r.rtm_scope = RT_SCOPE_UNIVERSE; else if (ea = ea_find(eattrs, EA_KRT_SCOPE)) r->r.rtm_scope = ea->u.data; else r->r.rtm_scope = (dest == RTD_UNICAST && ipa_zero(nh->gw)) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE; if (ea = ea_find(eattrs, EA_KRT_PREFSRC)) nl_add_attr_ipa(&r->h, rsize, RTA_PREFSRC, *(ip_addr *)ea->u.ptr->data); if (ea = ea_find(eattrs, EA_KRT_REALM)) nl_add_attr_u32(&r->h, rsize, RTA_FLOW, ea->u.data); u32 metrics[KRT_METRICS_MAX]; metrics[0] = 0; struct ea_walk_state ews = { .eattrs = eattrs }; while (ea = ea_walk(&ews, EA_KRT_METRICS, KRT_METRICS_MAX)) { int id = ea->id - EA_KRT_METRICS; metrics[0] |= 1 << id; metrics[id] = ea->u.data; } if (metrics[0]) nl_add_metrics(&r->h, rsize, metrics, KRT_METRICS_MAX); dest: switch (dest) { case RTD_UNICAST: r->r.rtm_type = RTN_UNICAST; if (nh->next && !krt_ecmp6(p)) nl_add_multipath(&r->h, rsize, nh, p->af, eattrs); else { nl_add_attr_u32(&r->h, rsize, RTA_OIF, nh->iface->index); nl_add_nexthop(&r->h, rsize, nh, p->af); if (nh->flags & RNF_ONLINK) r->r.rtm_flags |= RTNH_F_ONLINK; } break; case RTD_BLACKHOLE: r->r.rtm_type = RTN_BLACKHOLE; break; case RTD_UNREACHABLE: r->r.rtm_type = RTN_UNREACHABLE; break; case RTD_PROHIBIT: r->r.rtm_type = RTN_PROHIBIT; break; case RTD_NONE: break; default: bug("krt_capable inconsistent with nl_send_route"); } /* Ignore missing for DELETE */ return nl_exchange(&r->h, (op == NL_OP_DELETE)); } static inline int nl_add_rte(struct krt_proto *p, rte *e) { rta *a = e->attrs; int err = 0; if (krt_ecmp6(p) && a->nh.next) { struct nexthop *nh = &(a->nh); err = nl_send_route(p, e, NL_OP_ADD, RTD_UNICAST, nh); if (err < 0) return err; for (nh = nh->next; nh; nh = nh->next) err += nl_send_route(p, e, NL_OP_APPEND, RTD_UNICAST, nh); return err; } return nl_send_route(p, e, NL_OP_ADD, a->dest, &(a->nh)); } static inline int nl_delete_rte(struct krt_proto *p, rte *e) { int err = 0; /* For IPv6, we just repeatedly request DELETE until we get error */ do err = nl_send_route(p, e, NL_OP_DELETE, RTD_NONE, NULL); while (krt_ecmp6(p) && !err); return err; } static inline int nl_replace_rte(struct krt_proto *p, rte *e) { rta *a = e->attrs; return nl_send_route(p, e, NL_OP_REPLACE, a->dest, &(a->nh)); } void krt_replace_rte(struct krt_proto *p, net *n UNUSED, rte *new, rte *old) { int err = 0; /* * We use NL_OP_REPLACE for IPv4, it has an issue with not checking for * matching rtm_protocol, but that is OK when dedicated priority is used. * * We do not use NL_OP_REPLACE for IPv6, as it has broken semantics for ECMP * and with some kernel versions ECMP replace crashes kernel. Would need more * testing and checks for kernel versions. * * For IPv6, we use NL_OP_DELETE and then NL_OP_ADD. We also do not trust the * old route value, so we do not try to optimize IPv6 ECMP reconfigurations. */ if (krt_ipv4(p) && old && new) { err = nl_replace_rte(p, new); } else { if (old) nl_delete_rte(p, old); if (new) err = nl_add_rte(p, new); } if (new) { if (err < 0) bmap_clear(&p->sync_map, new->id); else bmap_set(&p->sync_map, new->id); } } static int nl_mergable_route(struct nl_parse_state *s, net *net, struct krt_proto *p, uint priority, uint krt_type, uint rtm_family) { /* Route merging is used for IPv6 scans */ if (!s->scan || (rtm_family != AF_INET6)) return 0; /* Saved and new route must have same network, proto/table, and priority */ if ((s->net != net) || (s->proto != p) || (s->krt_metric != priority)) return 0; /* Both must be regular unicast routes */ if ((s->krt_type != RTN_UNICAST) || (krt_type != RTN_UNICAST)) return 0; return 1; } static void nl_announce_route(struct nl_parse_state *s) { rte *e = rte_get_temp(s->attrs); e->net = s->net; e->u.krt.src = s->krt_src; e->u.krt.proto = s->krt_proto; e->u.krt.seen = 0; e->u.krt.best = 0; e->u.krt.metric = s->krt_metric; if (s->scan) krt_got_route(s->proto, e); else krt_got_route_async(s->proto, e, s->new); s->net = NULL; s->attrs = NULL; s->proto = NULL; lp_flush(s->pool); } static inline void nl_parse_begin(struct nl_parse_state *s, int scan) { memset(s, 0, sizeof (struct nl_parse_state)); s->pool = nl_linpool; s->scan = scan; } static inline void nl_parse_end(struct nl_parse_state *s) { if (s->net) nl_announce_route(s); } #define SKIP(ARG...) do { DBG("KRT: Ignoring route - " ARG); return; } while(0) static void nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h) { struct krt_proto *p; struct rtmsg *i; struct rtattr *a[BIRD_RTA_MAX]; int new = h->nlmsg_type == RTM_NEWROUTE; net_addr dst, src = {}; u32 oif = ~0; u32 table_id; u32 priority = 0; u32 def_scope = RT_SCOPE_UNIVERSE; int krt_src; if (!(i = nl_checkin(h, sizeof(*i)))) return; switch (i->rtm_family) { case AF_INET: if (!nl_parse_attrs(RTM_RTA(i), rtm_attr_want4, a, sizeof(a))) return; if (a[RTA_DST]) net_fill_ip4(&dst, rta_get_ip4(a[RTA_DST]), i->rtm_dst_len); else net_fill_ip4(&dst, IP4_NONE, 0); break; case AF_INET6: if (!nl_parse_attrs(RTM_RTA(i), rtm_attr_want6, a, sizeof(a))) return; if (a[RTA_DST]) net_fill_ip6(&dst, rta_get_ip6(a[RTA_DST]), i->rtm_dst_len); else net_fill_ip6(&dst, IP6_NONE, 0); if (a[RTA_SRC]) net_fill_ip6(&src, rta_get_ip6(a[RTA_SRC]), i->rtm_src_len); else net_fill_ip6(&src, IP6_NONE, 0); break; #ifdef HAVE_MPLS_KERNEL case AF_MPLS: if (!nl_parse_attrs(RTM_RTA(i), rtm_attr_want_mpls, a, sizeof(a))) return; if (!a[RTA_DST]) SKIP("MPLS route without RTA_DST"); if (rta_get_mpls(a[RTA_DST], rta_mpls_stack) != 1) SKIP("MPLS route with multi-label RTA_DST"); net_fill_mpls(&dst, rta_mpls_stack[0]); break; #endif default: return; } if (a[RTA_OIF]) oif = rta_get_u32(a[RTA_OIF]); if (a[RTA_TABLE]) table_id = rta_get_u32(a[RTA_TABLE]); else table_id = i->rtm_table; /* Do we know this table? */ p = HASH_FIND(nl_table_map, RTH, i->rtm_family, table_id); if (!p) SKIP("unknown table %u\n", table_id); if (a[RTA_SRC] && (p->p.net_type != NET_IP6_SADR)) SKIP("src prefix for non-SADR channel\n"); if (a[RTA_IIF]) SKIP("IIF set\n"); if (i->rtm_tos != 0) /* We don't support TOS */ SKIP("TOS %02x\n", i->rtm_tos); if (s->scan && !new) SKIP("RTM_DELROUTE in scan\n"); if (a[RTA_PRIORITY]) priority = rta_get_u32(a[RTA_PRIORITY]); int c = net_classify(&dst); if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK)) SKIP("strange class/scope\n"); switch (i->rtm_protocol) { case RTPROT_UNSPEC: SKIP("proto unspec\n"); case RTPROT_REDIRECT: krt_src = KRT_SRC_REDIRECT; break; case RTPROT_KERNEL: krt_src = KRT_SRC_KERNEL; return; case RTPROT_BIRD: if (!s->scan) SKIP("echo\n"); krt_src = KRT_SRC_BIRD; break; case RTPROT_BOOT: default: krt_src = KRT_SRC_ALIEN; } net_addr *n = &dst; if (p->p.net_type == NET_IP6_SADR) { n = alloca(sizeof(net_addr_ip6_sadr)); net_fill_ip6_sadr(n, net6_prefix(&dst), net6_pxlen(&dst), net6_prefix(&src), net6_pxlen(&src)); } net *net = net_get(p->p.main_channel->table, n); if (s->net && !nl_mergable_route(s, net, p, priority, i->rtm_type, i->rtm_family)) nl_announce_route(s); rta *ra = lp_allocz(s->pool, RTA_MAX_SIZE); ra->src = p->p.main_source; ra->source = RTS_INHERIT; ra->scope = SCOPE_UNIVERSE; if (a[RTA_FLOW]) s->rta_flow = rta_get_u32(a[RTA_FLOW]); else s->rta_flow = 0; switch (i->rtm_type) { case RTN_UNICAST: ra->dest = RTD_UNICAST; if (a[RTA_MULTIPATH]) { struct nexthop *nh = nl_parse_multipath(s, p, a[RTA_MULTIPATH], i->rtm_family); if (!nh) { log(L_ERR "KRT: Received strange multipath route %N", net->n.addr); return; } nexthop_link(ra, nh); break; } if (i->rtm_flags & RTNH_F_DEAD) return; ra->nh.iface = if_find_by_index(oif); if (!ra->nh.iface) { log(L_ERR "KRT: Received route %N with unknown ifindex %u", net->n.addr, oif); return; } if (a[RTA_GATEWAY]) ra->nh.gw = rta_get_ipa(a[RTA_GATEWAY]); #ifdef HAVE_MPLS_KERNEL if (a[RTA_VIA]) ra->nh.gw = rta_get_via(a[RTA_VIA]); #endif if (ipa_nonzero(ra->nh.gw)) { /* Silently skip strange 6to4 routes */ const net_addr_ip6 sit = NET_ADDR_IP6(IP6_NONE, 96); if ((i->rtm_family == AF_INET6) && ipa_in_netX(ra->nh.gw, (net_addr *) &sit)) return; if (i->rtm_flags & RTNH_F_ONLINK) ra->nh.flags |= RNF_ONLINK; neighbor *nbr; nbr = neigh_find(&p->p, ra->nh.gw, ra->nh.iface, (ra->nh.flags & RNF_ONLINK) ? NEF_ONLINK : 0); if (!nbr || (nbr->scope == SCOPE_HOST)) { log(L_ERR "KRT: Received route %N with strange next-hop %I", net->n.addr, ra->nh.gw); return; } } break; case RTN_BLACKHOLE: ra->dest = RTD_BLACKHOLE; break; case RTN_UNREACHABLE: ra->dest = RTD_UNREACHABLE; break; case RTN_PROHIBIT: ra->dest = RTD_PROHIBIT; break; /* FIXME: What about RTN_THROW? */ default: SKIP("type %d\n", i->rtm_type); return; } #ifdef HAVE_MPLS_KERNEL if ((i->rtm_family == AF_MPLS) && a[RTA_NEWDST] && !ra->nh.next) ra->nh.labels = rta_get_mpls(a[RTA_NEWDST], ra->nh.label); if (a[RTA_ENCAP] && a[RTA_ENCAP_TYPE] && !ra->nh.next) { switch (rta_get_u16(a[RTA_ENCAP_TYPE])) { case LWTUNNEL_ENCAP_MPLS: { struct rtattr *enca[BIRD_RTA_MAX]; nl_attr_len = RTA_PAYLOAD(a[RTA_ENCAP]); nl_parse_attrs(RTA_DATA(a[RTA_ENCAP]), encap_mpls_want, enca, sizeof(enca)); ra->nh.labels = rta_get_mpls(enca[RTA_DST], ra->nh.label); break; } default: SKIP("unknown encapsulation method %d\n", rta_get_u16(a[RTA_ENCAP_TYPE])); break; } } #endif if (i->rtm_scope != def_scope) { ea_list *ea = lp_alloc(s->pool, sizeof(ea_list) + sizeof(eattr)); ea->next = ra->eattrs; ra->eattrs = ea; ea->flags = EALF_SORTED; ea->count = 1; ea->attrs[0].id = EA_KRT_SCOPE; ea->attrs[0].flags = 0; ea->attrs[0].type = EAF_TYPE_INT; ea->attrs[0].u.data = i->rtm_scope; } if (a[RTA_PREFSRC]) { ip_addr ps = rta_get_ipa(a[RTA_PREFSRC]); ea_list *ea = lp_alloc(s->pool, sizeof(ea_list) + sizeof(eattr)); ea->next = ra->eattrs; ra->eattrs = ea; ea->flags = EALF_SORTED; ea->count = 1; ea->attrs[0].id = EA_KRT_PREFSRC; ea->attrs[0].flags = 0; ea->attrs[0].type = EAF_TYPE_IP_ADDRESS; struct adata *ad = lp_alloc(s->pool, sizeof(struct adata) + sizeof(ps)); ad->length = sizeof(ps); memcpy(ad->data, &ps, sizeof(ps)); ea->attrs[0].u.ptr = ad; } /* Can be set per-route or per-nexthop */ if (s->rta_flow) { ea_list *ea = lp_alloc(s->pool, sizeof(ea_list) + sizeof(eattr)); ea->next = ra->eattrs; ra->eattrs = ea; ea->flags = EALF_SORTED; ea->count = 1; ea->attrs[0].id = EA_KRT_REALM; ea->attrs[0].flags = 0; ea->attrs[0].type = EAF_TYPE_INT; ea->attrs[0].u.data = s->rta_flow; } if (a[RTA_METRICS]) { u32 metrics[KRT_METRICS_MAX]; ea_list *ea = lp_alloc(s->pool, sizeof(ea_list) + KRT_METRICS_MAX * sizeof(eattr)); int t, n = 0; if (nl_parse_metrics(a[RTA_METRICS], metrics, ARRAY_SIZE(metrics)) < 0) { log(L_ERR "KRT: Received route %N with strange RTA_METRICS attribute", net->n.addr); return; } for (t = 1; t < KRT_METRICS_MAX; t++) if (metrics[0] & (1 << t)) { ea->attrs[n].id = EA_CODE(PROTOCOL_KERNEL, KRT_METRICS_OFFSET + t); ea->attrs[n].flags = 0; ea->attrs[n].type = EAF_TYPE_INT; /* FIXME: Some are EAF_TYPE_BITFIELD */ ea->attrs[n].u.data = metrics[t]; n++; } if (n > 0) { ea->next = ra->eattrs; ea->flags = EALF_SORTED; ea->count = n; ra->eattrs = ea; } } /* * Ideally, now we would send the received route to the rest of kernel code. * But IPv6 ECMP routes before 4.11 are sent as a sequence of routes, so we * postpone it and merge next hops until the end of the sequence. Note that * when doing merging of next hops, we expect the new route to be unipath. * Otherwise, we ignore additional next hops in nexthop_insert(). */ if (!s->net) { /* Store the new route */ s->net = net; s->attrs = ra; s->proto = p; s->new = new; s->krt_src = krt_src; s->krt_type = i->rtm_type; s->krt_proto = i->rtm_protocol; s->krt_metric = priority; } else { /* Merge next hops with the stored route */ rta *oa = s->attrs; struct nexthop *nhs = &oa->nh; nexthop_insert(&nhs, &ra->nh); /* Perhaps new nexthop is inserted at the first position */ if (nhs == &ra->nh) { /* Swap rtas */ s->attrs = ra; /* Keep old eattrs */ ra->eattrs = oa->eattrs; } } } void krt_do_scan(struct krt_proto *p UNUSED) /* CONFIG_ALL_TABLES_AT_ONCE => p is NULL */ { struct nlmsghdr *h; struct nl_parse_state s; nl_parse_begin(&s, 1); nl_request_dump(AF_UNSPEC, RTM_GETROUTE); while (h = nl_get_scan()) if (h->nlmsg_type == RTM_NEWROUTE || h->nlmsg_type == RTM_DELROUTE) nl_parse_route(&s, h); else log(L_DEBUG "nl_scan_fire: Unknown packet received (type=%d)", h->nlmsg_type); nl_parse_end(&s); } /* * Asynchronous Netlink interface */ static sock *nl_async_sk; /* BIRD socket for asynchronous notifications */ static byte *nl_async_rx_buffer; /* Receive buffer */ static void nl_async_msg(struct nlmsghdr *h) { struct nl_parse_state s; switch (h->nlmsg_type) { case RTM_NEWROUTE: case RTM_DELROUTE: DBG("KRT: Received async route notification (%d)\n", h->nlmsg_type); nl_parse_begin(&s, 0); nl_parse_route(&s, h); nl_parse_end(&s); break; case RTM_NEWLINK: case RTM_DELLINK: DBG("KRT: Received async link notification (%d)\n", h->nlmsg_type); if (kif_proto) nl_parse_link(h, 0); break; case RTM_NEWADDR: case RTM_DELADDR: DBG("KRT: Received async address notification (%d)\n", h->nlmsg_type); if (kif_proto) nl_parse_addr(h, 0); break; default: DBG("KRT: Received unknown async notification (%d)\n", h->nlmsg_type); } } static int nl_async_hook(sock *sk, uint size UNUSED) { struct iovec iov = { nl_async_rx_buffer, NL_RX_SIZE }; struct sockaddr_nl sa; struct msghdr m = { .msg_name = &sa, .msg_namelen = sizeof(sa), .msg_iov = &iov, .msg_iovlen = 1, }; struct nlmsghdr *h; int x; uint len; x = recvmsg(sk->fd, &m, 0); if (x < 0) { if (errno == ENOBUFS) { /* * Netlink reports some packets have been thrown away. * One day we might react to it by asking for route table * scan in near future. */ log(L_WARN "Kernel dropped some netlink messages, will resync on next scan."); return 1; /* More data are likely to be ready */ } else if (errno != EWOULDBLOCK) log(L_ERR "Netlink recvmsg: %m"); return 0; } if (sa.nl_pid) /* It isn't from the kernel */ { DBG("Non-kernel packet\n"); return 1; } h = (void *) nl_async_rx_buffer; len = x; if (m.msg_flags & MSG_TRUNC) { log(L_WARN "Netlink got truncated asynchronous message"); return 1; } while (NLMSG_OK(h, len)) { nl_async_msg(h); h = NLMSG_NEXT(h, len); } if (len) log(L_WARN "nl_async_hook: Found packet remnant of size %d", len); return 1; } static void nl_async_err_hook(sock *sk, int e UNUSED) { nl_async_hook(sk, 0); } static void nl_open_async(void) { sock *sk; struct sockaddr_nl sa; int fd; if (nl_async_sk) return; DBG("KRT: Opening async netlink socket\n"); fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (fd < 0) { log(L_ERR "Unable to open asynchronous rtnetlink socket: %m"); return; } bzero(&sa, sizeof(sa)); sa.nl_family = AF_NETLINK; sa.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_IFADDR | RTMGRP_IPV6_ROUTE; if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { log(L_ERR "Unable to bind asynchronous rtnetlink socket: %m"); close(fd); return; } nl_async_rx_buffer = xmalloc(NL_RX_SIZE); sk = nl_async_sk = sk_new(krt_pool); sk->type = SK_MAGIC; sk->rx_hook = nl_async_hook; sk->err_hook = nl_async_err_hook; sk->fd = fd; if (sk_open(sk) < 0) bug("Netlink: sk_open failed"); } /* * Interface to the UNIX krt module */ void krt_sys_io_init(void) { nl_linpool = lp_new_default(krt_pool); HASH_INIT(nl_table_map, krt_pool, 6); } int krt_sys_start(struct krt_proto *p) { struct krt_proto *old = HASH_FIND(nl_table_map, RTH, p->af, krt_table_id(p)); if (old) { log(L_ERR "%s: Kernel table %u already registered by %s", p->p.name, krt_table_id(p), old->p.name); return 0; } HASH_INSERT2(nl_table_map, RTH, krt_pool, p); nl_open(); nl_open_async(); return 1; } void krt_sys_shutdown(struct krt_proto *p) { HASH_REMOVE2(nl_table_map, RTH, krt_pool, p); } int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o) { return (n->sys.table_id == o->sys.table_id) && (n->sys.metric == o->sys.metric); } void krt_sys_init_config(struct krt_config *cf) { cf->sys.table_id = RT_TABLE_MAIN; cf->sys.metric = 32; } void krt_sys_copy_config(struct krt_config *d, struct krt_config *s) { d->sys.table_id = s->sys.table_id; d->sys.metric = s->sys.metric; } static const char *krt_metrics_names[KRT_METRICS_MAX] = { NULL, "lock", "mtu", "window", "rtt", "rttvar", "sstresh", "cwnd", "advmss", "reordering", "hoplimit", "initcwnd", "features", "rto_min", "initrwnd", "quickack" }; static const char *krt_features_names[KRT_FEATURES_MAX] = { "ecn", NULL, NULL, "allfrag" }; int krt_sys_get_attr(const eattr *a, byte *buf, int buflen UNUSED) { switch (a->id) { case EA_KRT_PREFSRC: bsprintf(buf, "prefsrc"); return GA_NAME; case EA_KRT_REALM: bsprintf(buf, "realm"); return GA_NAME; case EA_KRT_SCOPE: bsprintf(buf, "scope"); return GA_NAME; case EA_KRT_LOCK: buf += bsprintf(buf, "lock:"); ea_format_bitfield(a, buf, buflen, krt_metrics_names, 2, KRT_METRICS_MAX); return GA_FULL; case EA_KRT_FEATURES: buf += bsprintf(buf, "features:"); ea_format_bitfield(a, buf, buflen, krt_features_names, 0, KRT_FEATURES_MAX); return GA_FULL; default:; int id = (int)EA_ID(a->id) - KRT_METRICS_OFFSET; if (id > 0 && id < KRT_METRICS_MAX) { bsprintf(buf, "%s", krt_metrics_names[id]); return GA_NAME; } return GA_UNKNOWN; } } void kif_sys_start(struct kif_proto *p UNUSED) { nl_open(); nl_open_async(); } void kif_sys_shutdown(struct kif_proto *p UNUSED) { } int kif_update_sysdep_addr(struct iface *i UNUSED) { return 0; } bird-2.0.8/sysdep/linux/netlink.Y0000664000175000017500000000661514025744326015640 0ustar feelafeela/* * BIRD -- Linux Netlink Configuration * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR CF_DECLS CF_KEYWORDS(KERNEL, TABLE, METRIC, KRT_PREFSRC, KRT_REALM, KRT_SCOPE, KRT_MTU, KRT_WINDOW, KRT_RTT, KRT_RTTVAR, KRT_SSTRESH, KRT_CWND, KRT_ADVMSS, KRT_REORDERING, KRT_HOPLIMIT, KRT_INITCWND, KRT_RTO_MIN, KRT_INITRWND, KRT_QUICKACK, KRT_LOCK_MTU, KRT_LOCK_WINDOW, KRT_LOCK_RTT, KRT_LOCK_RTTVAR, KRT_LOCK_SSTRESH, KRT_LOCK_CWND, KRT_LOCK_ADVMSS, KRT_LOCK_REORDERING, KRT_LOCK_HOPLIMIT, KRT_LOCK_RTO_MIN, KRT_FEATURE_ECN, KRT_FEATURE_ALLFRAG) CF_GRAMMAR kern_proto: kern_proto kern_sys_item ';' ; kern_sys_item: KERNEL TABLE expr { THIS_KRT->sys.table_id = $3; } | METRIC expr { THIS_KRT->sys.metric = $2; } ; dynamic_attr: KRT_PREFSRC { $$ = f_new_dynamic_attr(EAF_TYPE_IP_ADDRESS, T_IP, EA_KRT_PREFSRC); } ; dynamic_attr: KRT_REALM { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_REALM); } ; dynamic_attr: KRT_SCOPE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SCOPE); } ; dynamic_attr: KRT_MTU { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_MTU); } ; dynamic_attr: KRT_WINDOW { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_WINDOW); } ; dynamic_attr: KRT_RTT { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_RTT); } ; dynamic_attr: KRT_RTTVAR { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_RTTVAR); } ; dynamic_attr: KRT_SSTRESH { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SSTRESH); } ; dynamic_attr: KRT_CWND { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_CWND); } ; dynamic_attr: KRT_ADVMSS { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_ADVMSS); } ; dynamic_attr: KRT_REORDERING { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_REORDERING); } ; dynamic_attr: KRT_HOPLIMIT { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_HOPLIMIT); } ; dynamic_attr: KRT_INITCWND { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_INITCWND); } ; dynamic_attr: KRT_RTO_MIN { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_RTO_MIN); } ; dynamic_attr: KRT_INITRWND { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_INITRWND); } ; dynamic_attr: KRT_QUICKACK { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_QUICKACK); } ; /* Bits of EA_KRT_LOCK, based on RTAX_* constants */ dynamic_attr: KRT_LOCK_MTU { $$ = f_new_dynamic_attr_bit(2, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_WINDOW { $$ = f_new_dynamic_attr_bit(3, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_RTT { $$ = f_new_dynamic_attr_bit(4, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_RTTVAR { $$ = f_new_dynamic_attr_bit(5, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_SSTRESH { $$ = f_new_dynamic_attr_bit(6, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_CWND { $$ = f_new_dynamic_attr_bit(7, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_ADVMSS { $$ = f_new_dynamic_attr_bit(8, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_REORDERING { $$ = f_new_dynamic_attr_bit(9, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_HOPLIMIT { $$ = f_new_dynamic_attr_bit(10, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_LOCK_RTO_MIN { $$ = f_new_dynamic_attr_bit(13, T_BOOL, EA_KRT_LOCK); } ; dynamic_attr: KRT_FEATURE_ECN { $$ = f_new_dynamic_attr_bit(0, T_BOOL, EA_KRT_FEATURES); } ; dynamic_attr: KRT_FEATURE_ALLFRAG { $$ = f_new_dynamic_attr(3, T_BOOL, EA_KRT_FEATURES); } ; CF_CODE CF_END bird-2.0.8/sysdep/linux/krt-sys.h0000664000175000017500000000523514025744326015624 0ustar feelafeela/* * BIRD -- Linux Kernel Netlink Route Syncer * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_KRT_SYS_H_ #define _BIRD_KRT_SYS_H_ /* Kernel interfaces */ struct kif_params { }; struct kif_state { }; static inline void kif_sys_init(struct kif_proto *p UNUSED) { } static inline int kif_sys_reconfigure(struct kif_proto *p UNUSED, struct kif_config *n UNUSED, struct kif_config *o UNUSED) { return 1; } static inline void kif_sys_preconfig(struct config *c UNUSED) { } static inline void kif_sys_postconfig(struct kif_config *c UNUSED) { } static inline void kif_sys_init_config(struct kif_config *c UNUSED) { } static inline void kif_sys_copy_config(struct kif_config *d UNUSED, struct kif_config *s UNUSED) { } static inline struct ifa * kif_get_primary_ip(struct iface *i UNUSED) { return NULL; } /* Kernel routes */ #define KRT_ALLOW_MERGE_PATHS 1 #define EA_KRT_PREFSRC EA_CODE(PROTOCOL_KERNEL, 0x10) #define EA_KRT_REALM EA_CODE(PROTOCOL_KERNEL, 0x11) #define EA_KRT_SCOPE EA_CODE(PROTOCOL_KERNEL, 0x12) #define KRT_METRICS_MAX 0x10 /* RTAX_QUICKACK+1 */ #define KRT_METRICS_OFFSET 0x20 /* Offset of EA_KRT_* vs RTAX_* */ #define KRT_FEATURES_MAX 4 /* * Following attributes are parts of RTA_METRICS kernel route attribute, their * ids must be consistent with their RTAX_* constants (+ KRT_METRICS_OFFSET) */ #define EA_KRT_METRICS EA_CODE(PROTOCOL_KERNEL, 0x20) /* Dummy one */ #define EA_KRT_LOCK EA_CODE(PROTOCOL_KERNEL, 0x21) #define EA_KRT_MTU EA_CODE(PROTOCOL_KERNEL, 0x22) #define EA_KRT_WINDOW EA_CODE(PROTOCOL_KERNEL, 0x23) #define EA_KRT_RTT EA_CODE(PROTOCOL_KERNEL, 0x24) #define EA_KRT_RTTVAR EA_CODE(PROTOCOL_KERNEL, 0x25) #define EA_KRT_SSTRESH EA_CODE(PROTOCOL_KERNEL, 0x26) #define EA_KRT_CWND EA_CODE(PROTOCOL_KERNEL, 0x27) #define EA_KRT_ADVMSS EA_CODE(PROTOCOL_KERNEL, 0x28) #define EA_KRT_REORDERING EA_CODE(PROTOCOL_KERNEL, 0x29) #define EA_KRT_HOPLIMIT EA_CODE(PROTOCOL_KERNEL, 0x2a) #define EA_KRT_INITCWND EA_CODE(PROTOCOL_KERNEL, 0x2b) #define EA_KRT_FEATURES EA_CODE(PROTOCOL_KERNEL, 0x2c) #define EA_KRT_RTO_MIN EA_CODE(PROTOCOL_KERNEL, 0x2d) #define EA_KRT_INITRWND EA_CODE(PROTOCOL_KERNEL, 0x2e) #define EA_KRT_QUICKACK EA_CODE(PROTOCOL_KERNEL, 0x2f) struct krt_params { u32 table_id; /* Kernel table ID we sync with */ u32 metric; /* Kernel metric used for all routes */ }; struct krt_state { struct krt_proto *hash_next; }; static inline void krt_sys_init(struct krt_proto *p UNUSED) { } static inline void krt_sys_preconfig(struct config *c UNUSED) { } static inline void krt_sys_postconfig(struct krt_config *x UNUSED) { } #endif bird-2.0.8/sysdep/linux/Makefile0000664000175000017500000000020214025744326015464 0ustar feelafeelasrc := netlink.c obj := $(src-o-files) $(all-daemon) $(conf-y-targets): $(s)netlink.Y tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/sysdep/config.h0000664000175000017500000000171314025744326014313 0ustar feelafeela/* * This file contains all parameters dependent on the * operating system and build-time configuration. */ #ifndef _BIRD_CONFIG_H_ #define _BIRD_CONFIG_H_ #define XSTR2(X) #X #define XSTR1(X) XSTR2(X) /* BIRD version */ #ifdef GIT_LABEL #define BIRD_VERSION XSTR1(GIT_LABEL) #else #define BIRD_VERSION "2.0.8" #endif /* Include parameters determined by configure script */ #include "sysdep/autoconf.h" /* Include OS configuration file as chosen in autoconf.h */ #include SYSCONF_INCLUDE #ifndef MACROS_ONLY /* * Of course we could add the paths to autoconf.h, but autoconf * is stupid and puts make-specific substitutious to the paths. */ #include "sysdep/paths.h" /* Types */ #include typedef int8_t s8; typedef uint8_t u8; typedef int16_t s16; typedef uint16_t u16; typedef int32_t s32; typedef uint32_t u32; typedef int64_t s64; typedef uint64_t u64; typedef uint8_t byte; typedef uint16_t word; typedef unsigned int uint; #endif #endif bird-2.0.8/sysdep/cf/0000775000175000017500000000000014025744326013263 5ustar feelafeelabird-2.0.8/sysdep/cf/linux.h0000664000175000017500000000124614025744326014576 0ustar feelafeela/* * Configuration for Linux based systems * * (c) 1998--1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #define CONFIG_AUTO_ROUTES #define CONFIG_SELF_CONSCIOUS #define CONFIG_MULTIPLE_TABLES #define CONFIG_ALL_TABLES_AT_ONCE #define CONFIG_IP6_SADR_KERNEL #define CONFIG_MC_PROPER_SRC #define CONFIG_UNIX_DONTROUTE #define CONFIG_INCLUDE_SYSIO_H "sysdep/linux/sysio.h" #define CONFIG_INCLUDE_KRTSYS_H "sysdep/linux/krt-sys.h" #define CONFIG_RESTRICTED_PRIVILEGES #define CONFIG_INCLUDE_SYSPRIV_H "sysdep/linux/syspriv.h" #ifndef AF_MPLS #define AF_MPLS 28 #endif /* Link: sysdep/linux Link: sysdep/unix */ bird-2.0.8/sysdep/cf/bsd.h0000664000175000017500000000104714025744326014206 0ustar feelafeela/* * Configuration for *BSD based systems (tested on FreeBSD and NetBSD) * * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #define CONFIG_AUTO_ROUTES #define CONFIG_SELF_CONSCIOUS #define CONFIG_MULTIPLE_TABLES #define CONFIG_SINGLE_ROUTE #define CONFIG_SKIP_MC_BIND #define CONFIG_NO_IFACE_BIND #define CONFIG_USE_HDRINCL #define CONFIG_INCLUDE_SYSIO_H "sysdep/bsd/sysio.h" #define CONFIG_INCLUDE_KRTSYS_H "sysdep/bsd/krt-sys.h" /* Link: sysdep/unix Link: sysdep/bsd */ bird-2.0.8/sysdep/cf/README0000664000175000017500000000175014025744326014146 0ustar feelafeelaAvailable configuration variables: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CONFIG_AUTO_ROUTES Device routes are added automagically by the kernel CONFIG_SELF_CONSCIOUS We're able to recognize whether route was installed by us CONFIG_MULTIPLE_TABLES The kernel supports multiple routing tables CONFIG_ALL_TABLES_AT_ONCE Kernel scanner wants to process all tables at once CONFIG_SINGLE_ROUTE There is only one route per network CONFIG_MC_PROPER_SRC Multicast packets have source address according to socket saddr field CONFIG_SKIP_MC_BIND Don't call bind on multicast socket (def for *BSD) CONFIG_NO_IFACE_BIND Bind to iface is not available, use workarounds (def for *BSD) CONFIG_UNIX_DONTROUTE Use setsockopts DONTROUTE (undef for *BSD) CONFIG_DONTROUTE_UNICAST Use MSG_DONTROUTE flag for unicast packets (def for FreeBSD) CONFIG_USE_HDRINCL Use IP_HDRINCL instead of control messages for source address on raw IP sockets. CONFIG_RESTRICTED_PRIVILEGES Implements restricted privileges using drop_uid() bird-2.0.8/sysdep/bsd/0000775000175000017500000000000014025744326013443 5ustar feelafeelabird-2.0.8/sysdep/bsd/sysio.h0000664000175000017500000001350414025744326014765 0ustar feelafeela/* * BIRD Internet Routing Daemon -- BSD Multicasting and Network Includes * * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include // Workaround for some BSDs #include #include #ifdef __FreeBSD__ /* Should be defined in sysdep/cf/bsd.h, but it is flavor-specific */ #define CONFIG_DONTROUTE_UNICAST #endif #ifdef __NetBSD__ #ifndef IP_RECVTTL #define IP_RECVTTL 23 #endif #ifndef IP_MINTTL #define IP_MINTTL 24 #endif #endif #ifdef __DragonFly__ #define TCP_MD5SIG TCP_SIGNATURE_ENABLE #endif #undef SA_LEN #define SA_LEN(x) (x).sa.sa_len /* * BSD IPv4 multicast syscalls */ #define INIT_MREQ4(maddr,ifa) \ { .imr_multiaddr = ipa_to_in4(maddr), .imr_interface = ip4_to_in4(ifa->sysdep) } static inline int sk_setup_multicast4(sock *s) { struct in_addr ifa = ip4_to_in4(s->iface->sysdep); u8 ttl = s->ttl; u8 n = 0; /* This defines where should we send _outgoing_ multicasts */ if (setsockopt(s->fd, IPPROTO_IP, IP_MULTICAST_IF, &ifa, sizeof(ifa)) < 0) ERR("IP_MULTICAST_IF"); if (setsockopt(s->fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0) ERR("IP_MULTICAST_TTL"); if (setsockopt(s->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &n, sizeof(n)) < 0) ERR("IP_MULTICAST_LOOP"); return 0; } static inline int sk_join_group4(sock *s, ip_addr maddr) { struct ip_mreq mr = INIT_MREQ4(maddr, s->iface); if (setsockopt(s->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mr, sizeof(mr)) < 0) ERR("IP_ADD_MEMBERSHIP"); return 0; } static inline int sk_leave_group4(sock *s, ip_addr maddr) { struct ip_mreq mr = INIT_MREQ4(maddr, s->iface); if (setsockopt(s->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mr, sizeof(mr)) < 0) ERR("IP_ADD_MEMBERSHIP"); return 0; } /* * BSD IPv4 packet control messages */ /* It uses IP_RECVDSTADDR / IP_RECVIF socket options instead of IP_PKTINFO */ #define CMSG4_SPACE_PKTINFO (CMSG_SPACE(sizeof(struct in_addr)) + \ CMSG_SPACE(sizeof(struct sockaddr_dl))) #define CMSG4_SPACE_TTL CMSG_SPACE(sizeof(char)) static inline int sk_request_cmsg4_pktinfo(sock *s) { int y = 1; if (setsockopt(s->fd, IPPROTO_IP, IP_RECVDSTADDR, &y, sizeof(y)) < 0) ERR("IP_RECVDSTADDR"); if (setsockopt(s->fd, IPPROTO_IP, IP_RECVIF, &y, sizeof(y)) < 0) ERR("IP_RECVIF"); return 0; } static inline int sk_request_cmsg4_ttl(sock *s) { int y = 1; if (setsockopt(s->fd, IPPROTO_IP, IP_RECVTTL, &y, sizeof(y)) < 0) ERR("IP_RECVTTL"); return 0; } static inline void sk_process_cmsg4_pktinfo(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IP_RECVDSTADDR) s->laddr = ipa_from_in4(* (struct in_addr *) CMSG_DATA(cm)); if (cm->cmsg_type == IP_RECVIF) s->lifindex = ((struct sockaddr_dl *) CMSG_DATA(cm))->sdl_index; } static inline void sk_process_cmsg4_ttl(sock *s, struct cmsghdr *cm) { if (cm->cmsg_type == IP_RECVTTL) s->rcv_ttl = * (byte *) CMSG_DATA(cm); } #ifdef IP_SENDSRCADDR static inline void sk_prepare_cmsgs4(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen) { /* Unfortunately, IP_SENDSRCADDR does not work for raw IP sockets on BSD kernels */ struct cmsghdr *cm; struct in_addr *sa; int controllen = 0; msg->msg_control = cbuf; msg->msg_controllen = cbuflen; cm = CMSG_FIRSTHDR(msg); cm->cmsg_level = IPPROTO_IP; cm->cmsg_type = IP_SENDSRCADDR; cm->cmsg_len = CMSG_LEN(sizeof(*sa)); controllen += CMSG_SPACE(sizeof(*sa)); sa = (struct in_addr *) CMSG_DATA(cm); *sa = ipa_to_in4(s->saddr); msg->msg_controllen = controllen; } #else static inline void sk_prepare_cmsgs4(sock *s UNUSED, struct msghdr *msg UNUSED, void *cbuf UNUSED, size_t cbuflen UNUSED) { } #endif static void UNUSED sk_prepare_ip_header(sock *s, void *hdr, int dlen) { struct ip *ip = hdr; bzero(ip, 20); ip->ip_v = 4; ip->ip_hl = 5; ip->ip_tos = (s->tos < 0) ? 0 : s->tos; ip->ip_len = 20 + dlen; ip->ip_ttl = (s->ttl < 0) ? 64 : s->ttl; ip->ip_p = s->dport; ip->ip_src = ipa_to_in4(s->saddr); ip->ip_dst = ipa_to_in4(s->daddr); #if (defined __OpenBSD__) || (defined __DragonFly__) || (defined __FreeBSD__ && (__FreeBSD_version >= 1100030)) /* Different BSDs have different expectations of ip_len endianity */ ip->ip_len = htons(ip->ip_len); #endif } /* * Miscellaneous BSD socket syscalls */ #ifndef TCP_KEYLEN_MAX #define TCP_KEYLEN_MAX 80 #endif #ifndef TCP_SIG_SPI #define TCP_SIG_SPI 0x1000 #endif #if defined(__FreeBSD__) #define USE_MD5SIG_SETKEY #include "sysdep/bsd/setkey.h" #endif int sk_set_md5_auth(sock *s, ip_addr local UNUSED, ip_addr remote UNUSED, int pxlen UNUSED, struct iface *ifa UNUSED, const char *passwd, int setkey UNUSED) { #ifdef USE_MD5SIG_SETKEY if (setkey) if (sk_set_md5_in_sasp_db(s, local, remote, pxlen, ifa, passwd) < 0) return -1; #endif int enable = (passwd && *passwd) ? TCP_SIG_SPI : 0; if (setsockopt(s->fd, IPPROTO_TCP, TCP_MD5SIG, &enable, sizeof(enable)) < 0) { if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support TCP MD5 signatures"); else ERR("TCP_MD5SIG"); } return 0; } static inline int sk_set_min_ttl4(sock *s, int ttl) { if (setsockopt(s->fd, IPPROTO_IP, IP_MINTTL, &ttl, sizeof(ttl)) < 0) { if (errno == ENOPROTOOPT) ERR_MSG("Kernel does not support IPv4 TTL security"); else ERR("IP_MINTTL"); } return 0; } static inline int sk_set_min_ttl6(sock *s, int ttl UNUSED) { ERR_MSG("Kernel does not support IPv6 TTL security"); } static inline int sk_disable_mtu_disc4(sock *s UNUSED) { /* TODO: Set IP_DONTFRAG to 0 ? */ return 0; } static inline int sk_disable_mtu_disc6(sock *s UNUSED) { /* TODO: Set IPV6_DONTFRAG to 0 ? */ return 0; } int sk_priority_control = -1; static inline int sk_set_priority(sock *s, int prio UNUSED) { ERR_MSG("Socket priority not supported"); } bird-2.0.8/sysdep/bsd/setkey.h0000664000175000017500000001154614025744326015127 0ustar feelafeela/* * BIRD -- Manipulation the IPsec SA/SP database using setkey(8) utility * * (c) 2016 CZ.NIC z.s.p.o. */ #include #include #include #include #include #include "nest/bird.h" #include "sysdep/unix/unix.h" /* * Open a socket for manage the IPsec SA/SP database entries */ static int setkey_open_socket(void) { int s = socket(PF_KEY, SOCK_RAW, PF_KEY_V2); if (s < 0) { log(L_ERR "SETKEY: socket: %m"); return -1; } return s; } static int setkey_send(struct sadb_msg *msg, uint len) { int s = setkey_open_socket(); if (s < 0) return -1; if (msg->sadb_msg_type == SADB_ADD) { /* Delete possible current key in the IPsec SA/SP database */ msg->sadb_msg_type = SADB_DELETE; send(s, msg, len, 0); msg->sadb_msg_type = SADB_ADD; } if (send(s, msg, len, 0) < 0) { log(L_ERR "SETKEY: send: %m"); close(s); return -1; } close(s); return 0; } /* * Perform setkey(8)-like operation for set the password for TCP MD5 Signature. * Could be called with SABD_ADD or SADB_DELETE argument. Note that SADB_ADD * argument is internally processed as a pair of SADB_ADD and SADB_DELETE * operations to implement replace. */ static int setkey_md5(sockaddr *src, uint slen, sockaddr *dst, uint dlen, const char *passwd, uint type) { uint passwd_len = passwd ? strlen(passwd) : 0; uint total = sizeof(struct sadb_msg) + sizeof(struct sadb_key) + PFKEY_ALIGN8(passwd_len) + sizeof(struct sadb_sa) + sizeof(struct sadb_x_sa2) + sizeof(struct sadb_address) + PFKEY_ALIGN8(src->sa.sa_len) + sizeof(struct sadb_address) + PFKEY_ALIGN8(dst->sa.sa_len); char *buf = alloca(total); char *pos = buf; uint len; memset(buf, 0, total); struct sadb_msg *msg = (void *) pos; len = sizeof(struct sadb_msg); msg->sadb_msg_version = PF_KEY_V2; msg->sadb_msg_type = type; msg->sadb_msg_satype = SADB_X_SATYPE_TCPSIGNATURE; msg->sadb_msg_len = 0; /* Fix it later */ msg->sadb_msg_pid = getpid(); pos += len; /* Set authentication algorithm and password */ struct sadb_key *key = (void *) pos; len = sizeof(struct sadb_key) + PFKEY_ALIGN8(passwd_len); key->sadb_key_len = PFKEY_UNIT64(len); key->sadb_key_exttype = SADB_EXT_KEY_AUTH; key->sadb_key_bits = passwd_len * 8; memcpy(pos + sizeof(struct sadb_key), passwd, passwd_len); pos += len; struct sadb_sa *sa = (void *) pos; len = sizeof(struct sadb_sa); sa->sadb_sa_len = PFKEY_UNIT64(len); sa->sadb_sa_exttype = SADB_EXT_SA; sa->sadb_sa_spi = htonl((u32) TCP_SIG_SPI); sa->sadb_sa_auth = SADB_X_AALG_TCP_MD5; sa->sadb_sa_encrypt = SADB_EALG_NONE; sa->sadb_sa_flags = SADB_X_EXT_CYCSEQ; pos += len; struct sadb_x_sa2 *sa2 = (void *) pos; len = sizeof(struct sadb_x_sa2); sa2->sadb_x_sa2_len = PFKEY_UNIT64(len); sa2->sadb_x_sa2_exttype = SADB_X_EXT_SA2; sa2->sadb_x_sa2_mode = IPSEC_MODE_ANY; pos += len; /* Set source address */ struct sadb_address *saddr = (void *) pos; len = sizeof(struct sadb_address) + PFKEY_ALIGN8(src->sa.sa_len); saddr->sadb_address_len = PFKEY_UNIT64(len); saddr->sadb_address_exttype = SADB_EXT_ADDRESS_SRC; saddr->sadb_address_proto = IPSEC_ULPROTO_ANY; saddr->sadb_address_prefixlen = slen; memcpy(pos + sizeof(struct sadb_address), &src->sa, src->sa.sa_len); pos += len; /* Set destination address */ struct sadb_address *daddr = (void *) pos; len = sizeof(struct sadb_address) + PFKEY_ALIGN8(dst->sa.sa_len); daddr->sadb_address_len = PFKEY_UNIT64(len); daddr->sadb_address_exttype = SADB_EXT_ADDRESS_DST; daddr->sadb_address_proto = IPSEC_ULPROTO_ANY; daddr->sadb_address_prefixlen = dlen; memcpy(pos + sizeof(struct sadb_address), &dst->sa, dst->sa.sa_len); pos += len; len = pos - buf; msg->sadb_msg_len = PFKEY_UNIT64(len); return setkey_send(msg, len); } /* * Manipulation with the IPsec SA/SP database */ static int sk_set_md5_in_sasp_db(sock *s, ip_addr local, ip_addr remote, int pxlen, struct iface *ifa, const char *passwd) { sockaddr src, dst; sockaddr_fill(&src, s->af, local, ifa, 0); sockaddr_fill(&dst, s->af, remote, ifa, 0); uint maxlen = (s->af == AF_INET) ? IP4_MAX_PREFIX_LENGTH : IP6_MAX_PREFIX_LENGTH; uint slen = maxlen; uint dlen = (pxlen < 0) ? maxlen : pxlen; if (passwd && *passwd) { int len = strlen(passwd); if (len > TCP_KEYLEN_MAX) ERR_MSG("The password for TCP MD5 Signature is too long"); if ((setkey_md5(&src, slen, &dst, dlen, passwd, SADB_ADD) < 0) || (setkey_md5(&dst, dlen, &src, slen, passwd, SADB_ADD) < 0)) ERR_MSG("Cannot add TCP-MD5 password into the IPsec SA/SP database"); } else { if ((setkey_md5(&src, slen, &dst, dlen, NULL, SADB_DELETE) < 0) || (setkey_md5(&dst, dlen, &src, slen, NULL, SADB_DELETE) < 0)) ERR_MSG("Cannot delete TCP-MD5 password from the IPsec SA/SP database"); } return 0; } bird-2.0.8/sysdep/bsd/krt-sys.h0000664000175000017500000000243014025744326015227 0ustar feelafeela/* * BIRD -- *BSD Kernel Route Syncer * * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_KRT_SYS_H_ #define _BIRD_KRT_SYS_H_ struct birdsock; /* Kernel interfaces */ struct kif_params { }; struct kif_state { }; static inline void kif_sys_init(struct kif_proto *p UNUSED) { } static inline int kif_sys_reconfigure(struct kif_proto *p UNUSED, struct kif_config *n UNUSED, struct kif_config *o UNUSED) { return 1; } static inline void kif_sys_preconfig(struct config *c UNUSED) { } static inline void kif_sys_postconfig(struct kif_config *c UNUSED) { } static inline void kif_sys_init_config(struct kif_config *c UNUSED) { } static inline void kif_sys_copy_config(struct kif_config *d UNUSED, struct kif_config *s UNUSED) { } /* Kernel routes */ extern uint krt_max_tables; struct krt_params { int table_id; /* Kernel table ID we sync with */ }; struct krt_state { struct birdsock *sk; }; static inline void krt_sys_io_init(void) { } static inline void krt_sys_init(struct krt_proto *p UNUSED) { } static inline void krt_sys_postconfig(struct krt_config *x UNUSED) { } static inline int krt_sys_get_attr(const eattr *a UNUSED, byte *buf UNUSED, int buflen UNUSED) { return GA_UNKNOWN; } #endif bird-2.0.8/sysdep/bsd/krt-sock.c0000664000175000017500000006177414025744326015363 0ustar feelafeela/* * BIRD -- BSD Routing Table Syncing * * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "sysdep/unix/unix.h" #include "sysdep/unix/krt.h" #include "lib/string.h" #include "lib/socket.h" const int rt_default_ecmp = 0; /* * There are significant differences in multiple tables support between BSD variants. * * OpenBSD has table_id field for routes in route socket protocol, therefore all * tables could be managed by one kernel socket. FreeBSD lacks such field, * therefore multiple sockets (locked to specific table using SO_SETFIB socket * option) must be used. * * Both FreeBSD and OpenBSD uses separate scans for each table. In OpenBSD, * table_id is specified explicitly as sysctl scan argument, while in FreeBSD it * is handled implicitly by changing default table using setfib() syscall. * * KRT_SHARED_SOCKET - use shared kernel socked instead of one for each krt_proto * KRT_USE_SETFIB_SCAN - use setfib() for sysctl() route scan * KRT_USE_SETFIB_SOCK - use SO_SETFIB socket option for kernel sockets * KRT_USE_SYSCTL_7 - use 7-th arg of sysctl() as table id for route scans * KRT_USE_SYSCTL_NET_FIBS - use net.fibs sysctl() for dynamic max number of fibs */ #ifdef __FreeBSD__ #define KRT_MAX_TABLES 256 #define KRT_USE_SETFIB_SCAN #define KRT_USE_SETFIB_SOCK #define KRT_USE_SYSCTL_NET_FIBS #endif #ifdef __OpenBSD__ #define KRT_MAX_TABLES (RT_TABLEID_MAX+1) #define KRT_SHARED_SOCKET #define KRT_USE_SYSCTL_7 #endif #ifndef KRT_MAX_TABLES #define KRT_MAX_TABLES 1 #endif /* Dynamic max number of tables */ uint krt_max_tables; #ifdef KRT_USE_SYSCTL_NET_FIBS static uint krt_get_max_tables(void) { int fibs; size_t fibs_len = sizeof(fibs); if (sysctlbyname("net.fibs", &fibs, &fibs_len, NULL, 0) < 0) { log(L_WARN "KRT: unable to get max number of fib tables: %m"); return 1; } /* Should not happen */ if (fibs < 1) return 1; return (uint) MIN(fibs, KRT_MAX_TABLES); } #else static int krt_get_max_tables(void) { return KRT_MAX_TABLES; } #endif /* KRT_USE_SYSCTL_NET_FIBS */ /* setfib() syscall for FreeBSD scans */ #ifdef KRT_USE_SETFIB_SCAN /* static int krt_default_fib; static int krt_get_active_fib(void) { int fib; size_t fib_len = sizeof(fib); if (sysctlbyname("net.my_fibnum", &fib, &fib_len, NULL, 0) < 0) { log(L_WARN "KRT: unable to get active fib number: %m"); return 0; } return fib; } */ extern int setfib(int fib); #endif /* KRT_USE_SETFIB_SCAN */ /* table_id -> krt_proto map */ #ifdef KRT_SHARED_SOCKET static struct krt_proto *krt_table_map[KRT_MAX_TABLES][2]; #endif /* Route socket message processing */ int krt_capable(rte *e) { rta *a = e->attrs; return ((a->dest == RTD_UNICAST && !a->nh.next) /* No multipath support */ #ifdef RTF_REJECT || a->dest == RTD_UNREACHABLE #endif #ifdef RTF_BLACKHOLE || a->dest == RTD_BLACKHOLE #endif ); } #ifndef RTAX_MAX #define RTAX_MAX 8 #endif struct ks_msg { struct rt_msghdr rtm; struct sockaddr_storage buf[RTAX_MAX]; } PACKED; #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #define NEXTADDR(w, u) \ if (msg.rtm.rtm_addrs & (w)) {\ l = ROUNDUP(((struct sockaddr *)&(u))->sa_len);\ memmove(body, &(u), l); body += l;} #define GETADDR(p, F) \ bzero(p, sizeof(*p));\ if ((addrs & (F)) && ((struct sockaddr *)body)->sa_len) {\ uint l = ROUNDUP(((struct sockaddr *)body)->sa_len);\ memcpy(p, body, (l > sizeof(*p) ? sizeof(*p) : l));\ body += l;} static inline void sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa) { uint len = OFFSETOF(struct sockaddr_dl, sdl_data); memset(sa, 0, len); sa->sdl_len = len; sa->sdl_family = AF_LINK; sa->sdl_index = ifa->index; } static int krt_send_route(struct krt_proto *p, int cmd, rte *e) { net *net = e->net; rta *a = e->attrs; static int msg_seq; struct iface *j, *i = a->nh.iface; int l; struct ks_msg msg; char *body = (char *)msg.buf; sockaddr gate, mask, dst; DBG("krt-sock: send %I/%d via %I\n", net->n.prefix, net->n.pxlen, a->gw); bzero(&msg,sizeof (struct rt_msghdr)); msg.rtm.rtm_version = RTM_VERSION; msg.rtm.rtm_type = cmd; msg.rtm.rtm_seq = msg_seq++; msg.rtm.rtm_addrs = RTA_DST; msg.rtm.rtm_flags = RTF_UP | RTF_PROTO1; /* XXXX */ if (net_pxlen(net->n.addr) == net_max_prefix_length[net->n.addr->type]) msg.rtm.rtm_flags |= RTF_HOST; else msg.rtm.rtm_addrs |= RTA_NETMASK; #ifdef KRT_SHARED_SOCKET msg.rtm.rtm_tableid = KRT_CF->sys.table_id; #endif #ifdef RTF_REJECT if(a->dest == RTD_UNREACHABLE) msg.rtm.rtm_flags |= RTF_REJECT; #endif #ifdef RTF_BLACKHOLE if(a->dest == RTD_BLACKHOLE) msg.rtm.rtm_flags |= RTF_BLACKHOLE; #endif /* * This is really very nasty, but I'm not able to add reject/blackhole route * without gateway address. */ if (!i) { WALK_LIST(j, iface_list) { if (j->flags & IF_LOOPBACK) { i = j; break; } } if (!i) { log(L_ERR "KRT: Cannot find loopback iface"); return -1; } } int af = AF_UNSPEC; switch (net->n.addr->type) { case NET_IP4: af = AF_INET; break; case NET_IP6: af = AF_INET6; break; default: log(L_ERR "KRT: Not sending route %N to kernel", net->n.addr); return -1; } sockaddr_fill(&dst, af, net_prefix(net->n.addr), NULL, 0); sockaddr_fill(&mask, af, net_pxmask(net->n.addr), NULL, 0); switch (a->dest) { case RTD_UNICAST: if (ipa_nonzero(a->nh.gw)) { ip_addr gw = a->nh.gw; /* Embed interface ID to link-local address */ if (ipa_is_link_local(gw)) _I0(gw) = 0xfe800000 | (i->index & 0x0000ffff); sockaddr_fill(&gate, af, gw, NULL, 0); msg.rtm.rtm_flags |= RTF_GATEWAY; msg.rtm.rtm_addrs |= RTA_GATEWAY; break; } #ifdef RTF_REJECT case RTD_UNREACHABLE: #endif #ifdef RTF_BLACKHOLE case RTD_BLACKHOLE: #endif { /* Fallback for all other valid cases */ #if __OpenBSD__ /* Keeping temporarily old code for OpenBSD */ struct ifa *addr = (net->n.addr->type == NET_IP4) ? i->addr4 : (i->addr6 ?: i->llv6); if (!addr) { log(L_ERR "KRT: interface %s has no IP addess", i->name); return -1; } /* Embed interface ID to link-local address */ ip_addr gw = addr->ip; if (ipa_is_link_local(gw)) _I0(gw) = 0xfe800000 | (i->index & 0x0000ffff); sockaddr_fill(&gate, af, gw, i, 0); #else sockaddr_fill_dl(&gate, i); #endif msg.rtm.rtm_addrs |= RTA_GATEWAY; break; } default: bug("krt-sock: unknown flags, but not filtered"); } msg.rtm.rtm_index = i->index; NEXTADDR(RTA_DST, dst); NEXTADDR(RTA_GATEWAY, gate); NEXTADDR(RTA_NETMASK, mask); l = body - (char *)&msg; msg.rtm.rtm_msglen = l; if ((l = write(p->sys.sk->fd, (char *)&msg, l)) < 0) { log(L_ERR "KRT: Error sending route %N to kernel: %m", net->n.addr); return -1; } return 0; } void krt_replace_rte(struct krt_proto *p, net *n, rte *new, rte *old) { int err = 0; if (old) krt_send_route(p, RTM_DELETE, old); if (new) err = krt_send_route(p, RTM_ADD, new); if (new) { if (err < 0) bmap_clear(&p->sync_map, new->id); else bmap_set(&p->sync_map, new->id); } } #define SKIP(ARG...) do { DBG("KRT: Ignoring route - " ARG); return; } while(0) static void krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan) { /* p is NULL iff KRT_SHARED_SOCKET and !scan */ int ipv6; rte *e; net *net; sockaddr dst, gate, mask; ip_addr idst, igate, imask; net_addr ndst; void *body = (char *)msg->buf; int new = (msg->rtm.rtm_type != RTM_DELETE); char *errmsg = "KRT: Invalid route received"; int flags = msg->rtm.rtm_flags; int addrs = msg->rtm.rtm_addrs; int src; byte src2; if (!(flags & RTF_UP) && scan) SKIP("not up in scan\n"); if (!(flags & RTF_DONE) && !scan) SKIP("not done in async\n"); if (flags & RTF_LLINFO) SKIP("link-local\n"); GETADDR(&dst, RTA_DST); GETADDR(&gate, RTA_GATEWAY); GETADDR(&mask, RTA_NETMASK); switch (dst.sa.sa_family) { case AF_INET: ipv6 = 0; break; case AF_INET6: ipv6 = 1; break; default: SKIP("invalid DST"); } /* We do not test family for RTA_NETMASK, because BSD sends us some strange values, but interpreting them as IPv4/IPv6 works */ mask.sa.sa_family = dst.sa.sa_family; idst = ipa_from_sa(&dst); imask = ipa_from_sa(&mask); igate = (gate.sa.sa_family == dst.sa.sa_family) ? ipa_from_sa(&gate) : IPA_NONE; #ifdef KRT_SHARED_SOCKET if (!scan) { int table_id = msg->rtm.rtm_tableid; p = (table_id < KRT_MAX_TABLES) ? krt_table_map[table_id][ipv6] : NULL; if (!p) SKIP("unknown table id %d\n", table_id); } #endif if ((!ipv6) && (p->p.main_channel->table->addr_type != NET_IP4)) SKIP("reading only IPv4 routes"); if ( ipv6 && (p->p.main_channel->table->addr_type != NET_IP6)) SKIP("reading only IPv6 routes"); int c = ipa_classify_net(idst); if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK)) SKIP("strange class/scope\n"); int pxlen; if (ipv6) pxlen = (flags & RTF_HOST) ? IP6_MAX_PREFIX_LENGTH : ip6_masklen(&ipa_to_ip6(imask)); else pxlen = (flags & RTF_HOST) ? IP4_MAX_PREFIX_LENGTH : ip4_masklen(ipa_to_ip4(imask)); if (pxlen < 0) { log(L_ERR "%s (%I) - netmask %I", errmsg, idst, imask); return; } if (ipv6) net_fill_ip6(&ndst, ipa_to_ip6(idst), pxlen); else net_fill_ip4(&ndst, ipa_to_ip4(idst), pxlen); if ((flags & RTF_GATEWAY) && ipa_zero(igate)) { log(L_ERR "%s (%N) - missing gateway", errmsg, ndst); return; } u32 self_mask = RTF_PROTO1; u32 alien_mask = RTF_STATIC | RTF_PROTO1 | RTF_GATEWAY; src2 = (flags & RTF_STATIC) ? 1 : 0; src2 |= (flags & RTF_PROTO1) ? 2 : 0; #ifdef RTF_PROTO2 alien_mask |= RTF_PROTO2; src2 |= (flags & RTF_PROTO2) ? 4 : 0; #endif #ifdef RTF_PROTO3 alien_mask |= RTF_PROTO3; src2 |= (flags & RTF_PROTO3) ? 8 : 0; #endif #ifdef RTF_REJECT alien_mask |= RTF_REJECT; #endif #ifdef RTF_BLACKHOLE alien_mask |= RTF_BLACKHOLE; #endif if (flags & (RTF_DYNAMIC | RTF_MODIFIED)) src = KRT_SRC_REDIRECT; else if (flags & self_mask) { if (!scan) SKIP("echo\n"); src = KRT_SRC_BIRD; } else if (flags & alien_mask) src = KRT_SRC_ALIEN; else src = KRT_SRC_KERNEL; net = net_get(p->p.main_channel->table, &ndst); rta a = { .src = p->p.main_source, .source = RTS_INHERIT, .scope = SCOPE_UNIVERSE, }; /* reject/blackhole routes have also set RTF_GATEWAY, we wil check them first. */ #ifdef RTF_REJECT if(flags & RTF_REJECT) { a.dest = RTD_UNREACHABLE; goto done; } #endif #ifdef RTF_BLACKHOLE if(flags & RTF_BLACKHOLE) { a.dest = RTD_BLACKHOLE; goto done; } #endif a.nh.iface = if_find_by_index(msg->rtm.rtm_index); if (!a.nh.iface) { log(L_ERR "KRT: Received route %N with unknown ifindex %u", net->n.addr, msg->rtm.rtm_index); return; } a.dest = RTD_UNICAST; if (flags & RTF_GATEWAY) { neighbor *ng; a.nh.gw = igate; /* Clean up embedded interface ID returned in link-local address */ if (ipa_is_link_local(a.nh.gw)) _I0(a.nh.gw) = 0xfe800000; ng = neigh_find(&p->p, a.nh.gw, a.nh.iface, 0); if (!ng || (ng->scope == SCOPE_HOST)) { /* Ignore routes with next-hop 127.0.0.1, host routes with such next-hop appear on OpenBSD for address aliases. */ if (ipa_classify(a.nh.gw) == (IADDR_HOST | SCOPE_HOST)) return; log(L_ERR "KRT: Received route %N with strange next-hop %I", net->n.addr, a.nh.gw); return; } } done: e = rte_get_temp(&a); e->net = net; e->u.krt.src = src; e->u.krt.proto = src2; e->u.krt.seen = 0; e->u.krt.best = 0; e->u.krt.metric = 0; if (scan) krt_got_route(p, e); else krt_got_route_async(p, e, new); } static void krt_read_ifannounce(struct ks_msg *msg) { struct if_announcemsghdr *ifam = (struct if_announcemsghdr *)&msg->rtm; if (ifam->ifan_what == IFAN_ARRIVAL) { /* Not enough info to create the iface, so we just trigger iface scan */ kif_request_scan(); } else if (ifam->ifan_what == IFAN_DEPARTURE) { struct iface *iface = if_find_by_index(ifam->ifan_index); /* Interface is destroyed */ if (!iface) { DBG("KRT: unknown interface (%s, #%d) going down. Ignoring\n", ifam->ifan_name, ifam->ifan_index); return; } if_delete(iface); } DBG("KRT: IFANNOUNCE what: %d index %d name %s\n", ifam->ifan_what, ifam->ifan_index, ifam->ifan_name); } static void krt_read_ifinfo(struct ks_msg *msg, int scan) { struct if_msghdr *ifm = (struct if_msghdr *)&msg->rtm; void *body = (void *)(ifm + 1); struct sockaddr_dl *dl = NULL; uint i; struct iface *iface = NULL, f = {}; int fl = ifm->ifm_flags; int nlen = 0; for (i = 1; i<=RTA_IFP; i <<= 1) { if (i & ifm->ifm_addrs) { if (i == RTA_IFP) { dl = (struct sockaddr_dl *)body; break; } body += ROUNDUP(((struct sockaddr *)&(body))->sa_len); } } if (dl && (dl->sdl_family != AF_LINK)) { log(L_WARN "Ignoring strange IFINFO"); return; } if (dl) nlen = MIN(sizeof(f.name)-1, dl->sdl_nlen); /* Note that asynchronous IFINFO messages do not contain iface name, so we have to found an existing iface by iface index */ iface = if_find_by_index(ifm->ifm_index); if (!iface) { /* New interface */ if (!dl) return; /* No interface name, ignoring */ memcpy(f.name, dl->sdl_data, nlen); DBG("New interface '%s' found\n", f.name); } else if (dl && memcmp(iface->name, dl->sdl_data, nlen)) { /* Interface renamed */ if_delete(iface); memcpy(f.name, dl->sdl_data, nlen); } else { /* Old interface */ memcpy(f.name, iface->name, sizeof(f.name)); } f.index = ifm->ifm_index; f.mtu = ifm->ifm_data.ifi_mtu; if (fl & IFF_UP) f.flags |= IF_ADMIN_UP; if (ifm->ifm_data.ifi_link_state != LINK_STATE_DOWN) f.flags |= IF_LINK_UP; /* up or unknown */ if (fl & IFF_LOOPBACK) /* Loopback */ f.flags |= IF_MULTIACCESS | IF_LOOPBACK | IF_IGNORE; else if (fl & IFF_POINTOPOINT) /* PtP */ f.flags |= IF_MULTICAST; else if (fl & IFF_BROADCAST) /* Broadcast */ f.flags |= IF_MULTIACCESS | IF_BROADCAST | IF_MULTICAST; else f.flags |= IF_MULTIACCESS; /* NBMA */ iface = if_update(&f); if (!scan) if_end_partial_update(iface); } static void krt_read_addr(struct ks_msg *msg, int scan) { struct ifa_msghdr *ifam = (struct ifa_msghdr *)&msg->rtm; void *body = (void *)(ifam + 1); sockaddr addr, mask, brd; struct iface *iface = NULL; struct ifa ifa; struct sockaddr null; ip_addr iaddr, imask, ibrd; int addrs = ifam->ifam_addrs; int scope, masklen = -1; int new = (ifam->ifam_type == RTM_NEWADDR); /* Strange messages with zero (invalid) ifindex appear on OpenBSD */ if (ifam->ifam_index == 0) return; if(!(iface = if_find_by_index(ifam->ifam_index))) { log(L_ERR "KIF: Received address message for unknown interface %d", ifam->ifam_index); return; } GETADDR (&null, RTA_DST); GETADDR (&null, RTA_GATEWAY); GETADDR (&mask, RTA_NETMASK); GETADDR (&null, RTA_GENMASK); GETADDR (&null, RTA_IFP); GETADDR (&addr, RTA_IFA); GETADDR (&null, RTA_AUTHOR); GETADDR (&brd, RTA_BRD); /* Is addr family IP4 or IP6? */ int ipv6; switch (addr.sa.sa_family) { case AF_INET: ipv6 = 0; break; case AF_INET6: ipv6 = 1; break; default: return; } /* We do not test family for RTA_NETMASK, because BSD sends us some strange values, but interpreting them as IPv4/IPv6 works */ mask.sa.sa_family = addr.sa.sa_family; iaddr = ipa_from_sa(&addr); imask = ipa_from_sa(&mask); ibrd = ipa_from_sa(&brd); if ((ipv6 ? (masklen = ip6_masklen(&ipa_to_ip6(imask))) : (masklen = ip4_masklen(ipa_to_ip4(imask)))) < 0) { log(L_ERR "KIF: Invalid mask %I for %s", imask, iface->name); return; } /* Clean up embedded interface ID returned in link-local address */ if (ipa_is_link_local(iaddr)) _I0(iaddr) = 0xfe800000; if (ipa_is_link_local(ibrd)) _I0(ibrd) = 0xfe800000; bzero(&ifa, sizeof(ifa)); ifa.iface = iface; ifa.ip = iaddr; scope = ipa_classify(ifa.ip); if (scope < 0) { log(L_ERR "KIF: Invalid interface address %I for %s", ifa.ip, iface->name); return; } ifa.scope = scope & IADDR_SCOPE_MASK; if (masklen < (ipv6 ? IP6_MAX_PREFIX_LENGTH : IP4_MAX_PREFIX_LENGTH)) { net_fill_ipa(&ifa.prefix, ifa.ip, masklen); net_normalize(&ifa.prefix); if (masklen == ((ipv6 ? IP6_MAX_PREFIX_LENGTH : IP4_MAX_PREFIX_LENGTH) - 1)) ifa.opposite = ipa_opposite_m1(ifa.ip); if ((!ipv6) && (masklen == IP4_MAX_PREFIX_LENGTH - 2)) ifa.opposite = ipa_opposite_m2(ifa.ip); if (iface->flags & IF_BROADCAST) ifa.brd = ibrd; if (!(iface->flags & IF_MULTIACCESS)) ifa.opposite = ibrd; } else if (!(iface->flags & IF_MULTIACCESS) && ipa_nonzero(ibrd)) { net_fill_ipa(&ifa.prefix, ibrd, (ipv6 ? IP6_MAX_PREFIX_LENGTH : IP4_MAX_PREFIX_LENGTH)); ifa.opposite = ibrd; ifa.flags |= IA_PEER; } else { net_fill_ipa(&ifa.prefix, ifa.ip, (ipv6 ? IP6_MAX_PREFIX_LENGTH : IP4_MAX_PREFIX_LENGTH)); ifa.flags |= IA_HOST; } if (new) ifa_update(&ifa); else ifa_delete(&ifa); if (!scan) if_end_partial_update(iface); } static void krt_read_msg(struct proto *p, struct ks_msg *msg, int scan) { /* p is NULL iff KRT_SHARED_SOCKET and !scan */ switch (msg->rtm.rtm_type) { case RTM_GET: if(!scan) return; case RTM_ADD: case RTM_DELETE: case RTM_CHANGE: krt_read_route(msg, (struct krt_proto *)p, scan); break; case RTM_IFANNOUNCE: krt_read_ifannounce(msg); break; case RTM_IFINFO: krt_read_ifinfo(msg, scan); break; case RTM_NEWADDR: case RTM_DELADDR: krt_read_addr(msg, scan); break; default: break; } } /* Sysctl based scans */ static byte *krt_buffer; static size_t krt_buflen, krt_bufmin; static struct proto *krt_buffer_owner; static byte * krt_buffer_update(struct proto *p, size_t *needed) { size_t req = *needed; if ((req > krt_buflen) || ((p == krt_buffer_owner) && (req < krt_bufmin))) { /* min buflen is 32 kB, step is 8 kB, or 128 kB if > 1 MB */ size_t step = (req < 0x100000) ? 0x2000 : 0x20000; krt_buflen = (req < 0x6000) ? 0x8000 : (req + step); krt_bufmin = (req < 0x8000) ? 0 : (req - 2*step); if (krt_buffer) mb_free(krt_buffer); krt_buffer = mb_alloc(krt_pool, krt_buflen); krt_buffer_owner = p; } *needed = krt_buflen; return krt_buffer; } static void krt_buffer_release(struct proto *p) { if (p == krt_buffer_owner) { mb_free(krt_buffer); krt_buffer = NULL; krt_buflen = 0; krt_buffer_owner = 0; } } static void krt_sysctl_scan(struct proto *p, int cmd, int table_id) { byte *buf, *next; int mib[7], mcnt; size_t needed; struct ks_msg *m; int retries = 3; int rv; mib[0] = CTL_NET; mib[1] = PF_ROUTE; mib[2] = 0; mib[3] = 0; // Set AF to 0 for all available families mib[4] = cmd; mib[5] = 0; mcnt = 6; #ifdef KRT_USE_SYSCTL_7 if (table_id >= 0) { mib[6] = table_id; mcnt = 7; } #endif #ifdef KRT_USE_SETFIB_SCAN if (table_id > 0) if (setfib(table_id) < 0) { log(L_ERR "KRT: setfib(%d) failed: %m", table_id); return; } #endif try: rv = sysctl(mib, mcnt, NULL, &needed, NULL, 0); if (rv < 0) { /* OpenBSD returns EINVAL for not yet used tables */ if ((errno == EINVAL) && (table_id > 0)) goto exit; log(L_ERR "KRT: Route scan estimate failed: %m"); goto exit; } /* The table is empty */ if (needed == 0) goto exit; buf = krt_buffer_update(p, &needed); rv = sysctl(mib, mcnt, buf, &needed, NULL, 0); if (rv < 0) { /* The buffer size changed since last sysctl ('needed' is not changed) */ if ((errno == ENOMEM) && retries--) goto try; log(L_ERR "KRT: Route scan failed: %m"); goto exit; } #ifdef KRT_USE_SETFIB_SCAN if (table_id > 0) if (setfib(0) < 0) die("KRT: setfib(%d) failed: %m", 0); #endif /* Process received messages */ for (next = buf; next < (buf + needed); next += m->rtm.rtm_msglen) { m = (struct ks_msg *)next; krt_read_msg(p, m, 1); } return; exit: krt_buffer_release(p); #ifdef KRT_USE_SETFIB_SCAN if (table_id > 0) if (setfib(0) < 0) die("KRT: setfib(%d) failed: %m", 0); #endif } void krt_do_scan(struct krt_proto *p) { krt_sysctl_scan(&p->p, NET_RT_DUMP, KRT_CF->sys.table_id); } void kif_do_scan(struct kif_proto *p) { if_start_update(); krt_sysctl_scan(&p->p, NET_RT_IFLIST, -1); if_end_update(); } /* Kernel sockets */ static int krt_sock_hook(sock *sk, uint size UNUSED) { struct ks_msg msg; int l = read(sk->fd, (char *)&msg, sizeof(msg)); if (l <= 0) log(L_ERR "krt-sock: read failed"); else krt_read_msg((struct proto *) sk->data, &msg, 0); return 0; } static void krt_sock_err_hook(sock *sk, int e UNUSED) { krt_sock_hook(sk, 0); } static sock * krt_sock_open(pool *pool, void *data, int table_id UNUSED) { sock *sk; int fd; fd = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC); if (fd < 0) die("Cannot open kernel socket for routes"); #ifdef KRT_USE_SETFIB_SOCK if (table_id > 0) { if (setsockopt(fd, SOL_SOCKET, SO_SETFIB, &table_id, sizeof(table_id)) < 0) die("Cannot set FIB %d for kernel socket: %m", table_id); } #endif sk = sk_new(pool); sk->type = SK_MAGIC; sk->rx_hook = krt_sock_hook; sk->err_hook = krt_sock_err_hook; sk->fd = fd; sk->data = data; if (sk_open(sk) < 0) bug("krt-sock: sk_open failed"); return sk; } static u32 krt_table_cf[(KRT_MAX_TABLES+31) / 32][2]; #ifdef KRT_SHARED_SOCKET static sock *krt_sock; static int krt_sock_count; static void krt_sock_open_shared(void) { if (!krt_sock_count) krt_sock = krt_sock_open(krt_pool, NULL, -1); krt_sock_count++; } static void krt_sock_close_shared(void) { krt_sock_count--; if (!krt_sock_count) { rfree(krt_sock); krt_sock = NULL; } } int krt_sys_start(struct krt_proto *p) { int id = KRT_CF->sys.table_id; if (krt_table_cf[id/32][!!(p->af == AF_INET6)] & (1 << (id%32))) { log(L_ERR "%s: Multiple kernel syncers defined for table #%d", p->p.name, id); return 0; } krt_table_cf[id/32][!!(p->af == AF_INET6)] |= (1 << (id%32)); krt_table_map[KRT_CF->sys.table_id][!!(p->af == AF_INET6)] = p; krt_sock_open_shared(); p->sys.sk = krt_sock; return 1; } void krt_sys_shutdown(struct krt_proto *p) { krt_table_cf[(KRT_CF->sys.table_id)/32][!!(p->af == AF_INET6)] &= ~(1 << ((KRT_CF->sys.table_id)%32)); krt_sock_close_shared(); p->sys.sk = NULL; krt_table_map[KRT_CF->sys.table_id][!!(p->af == AF_INET6)] = NULL; krt_buffer_release(&p->p); } #else int krt_sys_start(struct krt_proto *p) { int id = KRT_CF->sys.table_id; if (krt_table_cf[id/32][!!(p->af == AF_INET6)] & (1 << (id%32))) { log(L_ERR "%s: Multiple kernel syncers defined for table #%d", p->p.name, id); return 0; } krt_table_cf[id/32][!!(p->af == AF_INET6)] |= (1 << (id%32)); p->sys.sk = krt_sock_open(p->p.pool, p, KRT_CF->sys.table_id); return 1; } void krt_sys_shutdown(struct krt_proto *p) { krt_table_cf[(KRT_CF->sys.table_id)/32][!!(p->af == AF_INET6)] &= ~(1 << ((KRT_CF->sys.table_id)%32)); rfree(p->sys.sk); p->sys.sk = NULL; krt_buffer_release(&p->p); } #endif /* KRT_SHARED_SOCKET */ /* KRT configuration callbacks */ int krt_sys_reconfigure(struct krt_proto *p UNUSED, struct krt_config *n, struct krt_config *o) { return n->sys.table_id == o->sys.table_id; } void krt_sys_preconfig(struct config *c UNUSED) { krt_max_tables = krt_get_max_tables(); bzero(&krt_table_cf, sizeof(krt_table_cf)); } void krt_sys_init_config(struct krt_config *c) { c->sys.table_id = 0; /* Default table */ } void krt_sys_copy_config(struct krt_config *d, struct krt_config *s) { d->sys.table_id = s->sys.table_id; } /* KIF misc code */ void kif_sys_start(struct kif_proto *p UNUSED) { } void kif_sys_shutdown(struct kif_proto *p) { krt_buffer_release(&p->p); } int kif_update_sysdep_addr(struct iface *i) { static int fd = -1; if (fd < 0) fd = socket(AF_INET, SOCK_DGRAM, 0); struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, i->name, IFNAMSIZ); int rv = ioctl(fd, SIOCGIFADDR, (char *) &ifr); if (rv < 0) return 0; ip4_addr old = i->sysdep; i->sysdep = ipa_to_ip4(ipa_from_sa4(&ifr.ifr_addr)); return !ip4_equal(i->sysdep, old); } bird-2.0.8/sysdep/bsd/krt-sock.Y0000664000175000017500000000106214025744326015331 0ustar feelafeela/* * BIRD -- BSD Kernel Syncer Configuration * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR CF_DECLS CF_KEYWORDS(KERNEL, TABLE) CF_GRAMMAR kern_proto: kern_proto kern_sys_item ';' ; kern_sys_item: KERNEL TABLE expr { if ($3 && (krt_max_tables == 1)) cf_error("Multiple kernel routing tables not supported"); if ($3 >= krt_max_tables) cf_error("Kernel table id must be in range 0-%u", krt_max_tables - 1); THIS_KRT->sys.table_id = $3; } ; CF_CODE CF_END bird-2.0.8/sysdep/bsd/Makefile0000664000175000017500000000020414025744326015077 0ustar feelafeelasrc := krt-sock.c obj := $(src-o-files) $(all-daemon) $(conf-y-targets): $(s)krt-sock.Y tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/sysdep/Doc0000664000175000017500000000002514025744326013320 0ustar feelafeelaD sysdep.sgml C unix bird-2.0.8/proto/0000775000175000017500000000000014025744326012527 5ustar feelafeelabird-2.0.8/proto/static/0000775000175000017500000000000014025744326014016 5ustar feelafeelabird-2.0.8/proto/static/static.h0000664000175000017500000000540314025744326015460 0ustar feelafeela/* * BIRD -- Static Route Generator * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_STATIC_H_ #define _BIRD_STATIC_H_ #include "nest/route.h" #include "nest/bfd.h" #include "lib/buffer.h" struct static_config { struct proto_config c; list routes; /* List of static routes (struct static_route) */ int check_link; /* Whether iface link state is used */ struct rtable_config *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */ struct rtable_config *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */ }; struct static_proto { struct proto p; struct event *event; /* Event for announcing updated routes */ BUFFER_(struct static_route *) marked; /* Routes marked for reannouncement */ int marked_all; /* All routes are marked */ rtable *igp_table_ip4; /* Table for recursive IPv4 next hop lookups */ rtable *igp_table_ip6; /* Table for recursive IPv6 next hop lookups */ }; struct static_route { node n; net_addr *net; /* Network we route */ ip_addr via; /* Destination router */ struct iface *iface; /* Destination iface, for link-local vias or device routes */ struct neighbor *neigh; /* Associated neighbor entry */ struct static_route *chain; /* Next for the same neighbor */ struct static_route *mp_head; /* First nexthop of this route */ struct static_route *mp_next; /* Nexthops for multipath routes */ struct f_line *cmds; /* List of commands for setting attributes */ uint index; /* Distinguish different routes with same net */ byte dest; /* Destination type (RTD_*) */ byte state; /* State of route announcement (SRS_*) */ byte active; /* Next hop is active (nbr/iface/BFD available) */ byte onlink; /* Gateway is onlink regardless of IP ranges */ byte weight; /* Multipath next hop weight */ byte use_bfd; /* Configured to use BFD */ struct bfd_request *bfd_req; /* BFD request, if BFD is used */ mpls_label_stack *mls; /* MPLS label stack; may be NULL */ }; /* * Note that data fields neigh, chain, state, active and bfd_req are runtime * data, not real configuration data. Must be handled carefully. * * Regular (i.e. dest == RTD_UNICAST) routes use static_route structure for * additional next hops (fields mp_head, mp_next). Note that 'state' is for * whole route, while 'active' is for each next hop. Also note that fields * mp_head, mp_next, active are zero for other kinds of routes. */ #define RTDX_RECURSIVE 0x7f /* Phony dest value for recursive routes */ #define SRS_DOWN 0 /* Route is not announced */ #define SRS_CLEAN 1 /* Route is active and announced */ #define SRS_DIRTY 2 /* Route changed since announcement */ void static_show(struct proto *); #endif bird-2.0.8/proto/static/static.c0000664000175000017500000004460314025744326015460 0ustar feelafeela/* * BIRD -- Static Route Generator * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Static * * The Static protocol is implemented in a straightforward way. It keeps a list * of static routes. Routes of dest RTD_UNICAST have associated sticky node in * the neighbor cache to be notified about gaining or losing the neighbor and * about interface-related events (e.g. link down). They may also have a BFD * request if associated with a BFD session. When a route is notified, * static_decide() is used to see whether the route activeness is changed. In * such case, the route is marked as dirty and scheduled to be announced or * withdrawn, which is done asynchronously from event hook. Routes of other * types (e.g. black holes) are announced all the time. * * Multipath routes are a bit tricky. To represent additional next hops, dummy * static_route nodes are used, which are chained using @mp_next field and link * to the master node by @mp_head field. Each next hop has a separate neighbor * entry and an activeness state, but the master node is used for most purposes. * Note that most functions DO NOT accept dummy nodes as arguments. * * The only other thing worth mentioning is that when asked for reconfiguration, * Static not only compares the two configurations, but it also calculates * difference between the lists of static routes and it just inserts the newly * added routes, removes the obsolete ones and reannounces changed ones. */ #undef LOCAL_DEBUG #include #include "nest/bird.h" #include "nest/iface.h" #include "nest/protocol.h" #include "nest/route.h" #include "nest/cli.h" #include "conf/conf.h" #include "filter/filter.h" #include "lib/string.h" #include "lib/alloca.h" #include "static.h" static linpool *static_lp; static inline struct rte_src * static_get_source(struct static_proto *p, uint i) { return i ? rt_get_source(&p->p, i) : p->p.main_source; } static void static_announce_rte(struct static_proto *p, struct static_route *r) { rta *a = allocz(RTA_MAX_SIZE); a->src = static_get_source(p, r->index); a->source = RTS_STATIC; a->scope = SCOPE_UNIVERSE; a->dest = r->dest; if (r->dest == RTD_UNICAST) { struct static_route *r2; struct nexthop *nhs = NULL; for (r2 = r; r2; r2 = r2->mp_next) { if (!r2->active) continue; struct nexthop *nh = allocz(NEXTHOP_MAX_SIZE); nh->gw = r2->via; nh->iface = r2->neigh->iface; nh->flags = r2->onlink ? RNF_ONLINK : 0; nh->weight = r2->weight; if (r2->mls) { nh->labels = r2->mls->len; memcpy(nh->label, r2->mls->stack, r2->mls->len * sizeof(u32)); } nexthop_insert(&nhs, nh); } if (!nhs) goto withdraw; nexthop_link(a, nhs); } if (r->dest == RTDX_RECURSIVE) { rtable *tab = ipa_is_ip4(r->via) ? p->igp_table_ip4 : p->igp_table_ip6; rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls); } /* Already announced */ if (r->state == SRS_CLEAN) return; /* We skip rta_lookup() here */ rte *e = rte_get_temp(a); e->pflags = 0; if (r->cmds) { /* Create a temporary table node */ e->net = alloca(sizeof(net) + r->net->length); memset(e->net, 0, sizeof(net) + r->net->length); net_copy(e->net->n.addr, r->net); /* Evaluate the filter */ f_eval_rte(r->cmds, &e, static_lp); /* Remove the temporary node */ e->net = NULL; } rte_update2(p->p.main_channel, r->net, e, a->src); r->state = SRS_CLEAN; if (r->cmds) lp_flush(static_lp); return; withdraw: if (r->state == SRS_DOWN) return; rte_update2(p->p.main_channel, r->net, NULL, a->src); r->state = SRS_DOWN; } static void static_mark_rte(struct static_proto *p, struct static_route *r) { if (r->state == SRS_DIRTY) return; r->state = SRS_DIRTY; BUFFER_PUSH(p->marked) = r; if (!ev_active(p->event)) ev_schedule(p->event); } static void static_mark_all(struct static_proto *p) { struct static_config *cf = (void *) p->p.cf; struct static_route *r; /* We want to reload all routes, mark them as dirty */ WALK_LIST(r, cf->routes) if (r->state == SRS_CLEAN) r->state = SRS_DIRTY; p->marked_all = 1; BUFFER_FLUSH(p->marked); if (!ev_active(p->event)) ev_schedule(p->event); } static void static_announce_marked(void *P) { struct static_proto *p = P; struct static_config *cf = (void *) p->p.cf; struct static_route *r; if (p->marked_all) { WALK_LIST(r, cf->routes) if (r->state == SRS_DIRTY) static_announce_rte(p, r); p->marked_all = 0; } else { BUFFER_WALK(p->marked, r) static_announce_rte(p, r); BUFFER_FLUSH(p->marked); } } static void static_bfd_notify(struct bfd_request *req); static void static_update_bfd(struct static_proto *p, struct static_route *r) { /* The @r is a RTD_UNICAST next hop, may be a dummy node */ struct neighbor *nb = r->neigh; int bfd_up = (nb->scope > 0) && r->use_bfd; if (bfd_up && !r->bfd_req) { // ip_addr local = ipa_nonzero(r->local) ? r->local : nb->ifa->ip; r->bfd_req = bfd_request_session(p->p.pool, r->via, nb->ifa->ip, nb->iface, p->p.vrf, static_bfd_notify, r, NULL); } if (!bfd_up && r->bfd_req) { rfree(r->bfd_req); r->bfd_req = NULL; } } static int static_decide(struct static_proto *p, struct static_route *r) { /* The @r is a RTD_UNICAST next hop, may be a dummy node */ struct static_config *cf = (void *) p->p.cf; uint old_active = r->active; if (r->neigh->scope < 0) goto fail; if (cf->check_link && !(r->neigh->iface->flags & IF_LINK_UP)) goto fail; if (r->bfd_req && (r->bfd_req->state != BFD_STATE_UP)) goto fail; r->active = 1; return !old_active; fail: r->active = 0; return old_active; } static void static_add_rte(struct static_proto *p, struct static_route *r) { if (r->dest == RTD_UNICAST) { struct static_route *r2; struct neighbor *n; for (r2 = r; r2; r2 = r2->mp_next) { n = neigh_find(&p->p, r2->via, r2->iface, NEF_STICKY | (r2->onlink ? NEF_ONLINK : 0) | (ipa_zero(r2->via) ? NEF_IFACE : 0)); if (!n) { log(L_WARN "Invalid next hop %I of static route %N", r2->via, r2->net); continue; } r2->neigh = n; r2->chain = n->data; n->data = r2; static_update_bfd(p, r2); static_decide(p, r2); } } static_announce_rte(p, r); } static void static_reset_rte(struct static_proto *p UNUSED, struct static_route *r) { struct static_route *r2; for (r2 = r; r2; r2 = r2->mp_next) { r2->neigh = NULL; r2->chain = NULL; r2->state = 0; r2->active = 0; rfree(r2->bfd_req); r2->bfd_req = NULL; } } static void static_remove_rte(struct static_proto *p, struct static_route *r) { if (r->state) rte_update2(p->p.main_channel, r->net, NULL, static_get_source(p, r->index)); static_reset_rte(p, r); } static inline int static_same_dest(struct static_route *x, struct static_route *y) { if (x->dest != y->dest) return 0; switch (x->dest) { case RTD_UNICAST: for (; x && y; x = x->mp_next, y = y->mp_next) { if (!ipa_equal(x->via, y->via) || (x->iface != y->iface) || (x->onlink != y->onlink) || (x->weight != y->weight) || (x->use_bfd != y->use_bfd) || (!x->mls != !y->mls) || ((x->mls) && (y->mls) && (x->mls->len != y->mls->len))) return 0; if (!x->mls) continue; for (uint i = 0; i < x->mls->len; i++) if (x->mls->stack[i] != y->mls->stack[i]) return 0; } return !x && !y; case RTDX_RECURSIVE: if (!ipa_equal(x->via, y->via) || (!x->mls != !y->mls) || ((x->mls) && (y->mls) && (x->mls->len != y->mls->len))) return 0; if (!x->mls) return 1; for (uint i = 0; i < x->mls->len; i++) if (x->mls->stack[i] != y->mls->stack[i]) return 0; return 1; default: return 1; } } static inline int static_same_rte(struct static_route *or, struct static_route *nr) { /* Note that i_same() requires arguments in (new, old) order */ return static_same_dest(or, nr) && f_same(nr->cmds, or->cmds); } static void static_reconfigure_rte(struct static_proto *p, struct static_route *or, struct static_route *nr) { if ((or->state == SRS_CLEAN) && !static_same_rte(or, nr)) nr->state = SRS_DIRTY; else nr->state = or->state; static_add_rte(p, nr); static_reset_rte(p, or); } static void static_neigh_notify(struct neighbor *n) { struct static_proto *p = (void *) n->proto; struct static_route *r; DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface); for (r = n->data; r; r = r->chain) { static_update_bfd(p, r); if (static_decide(p, r)) static_mark_rte(p, r->mp_head); } } static void static_bfd_notify(struct bfd_request *req) { struct static_route *r = req->data; struct static_proto *p = (void *) r->neigh->proto; // if (req->down) TRACE(D_EVENTS, "BFD session down for nbr %I on %s", XXXX); if (static_decide(p, r)) static_mark_rte(p, r->mp_head); } static void static_reload_routes(struct channel *C) { struct static_proto *p = (void *) C->proto; TRACE(D_EVENTS, "Scheduling route reload"); static_mark_all(p); } static int static_rte_better(rte *new, rte *old) { u32 n = ea_get_int(new->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN); u32 o = ea_get_int(old->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN); return n < o; } static int static_rte_mergable(rte *pri, rte *sec) { u32 a = ea_get_int(pri->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN); u32 b = ea_get_int(sec->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN); return a == b; } static void static_index_routes(struct static_config *cf); static void static_postconfig(struct proto_config *CF) { struct static_config *cf = (void *) CF; struct static_route *r; if (EMPTY_LIST(CF->channels)) cf_error("Channel not specified"); struct channel_config *cc = proto_cf_main_channel(CF); if (!cf->igp_table_ip4) cf->igp_table_ip4 = (cc->table->addr_type == NET_IP4) ? cc->table : cf->c.global->def_tables[NET_IP4]; if (!cf->igp_table_ip6) cf->igp_table_ip6 = (cc->table->addr_type == NET_IP6) ? cc->table : cf->c.global->def_tables[NET_IP6]; WALK_LIST(r, cf->routes) if (r->net && (r->net->type != CF->net_type)) cf_error("Route %N incompatible with channel type", r->net); static_index_routes(cf); } static struct proto * static_init(struct proto_config *CF) { struct proto *P = proto_new(CF); struct static_proto *p = (void *) P; struct static_config *cf = (void *) CF; P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF)); P->neigh_notify = static_neigh_notify; P->reload_routes = static_reload_routes; P->rte_better = static_rte_better; P->rte_mergable = static_rte_mergable; if (cf->igp_table_ip4) p->igp_table_ip4 = cf->igp_table_ip4->table; if (cf->igp_table_ip6) p->igp_table_ip6 = cf->igp_table_ip6->table; return P; } static int static_start(struct proto *P) { struct static_proto *p = (void *) P; struct static_config *cf = (void *) P->cf; struct static_route *r; if (!static_lp) static_lp = lp_new(&root_pool, LP_GOOD_SIZE(1024)); if (p->igp_table_ip4) rt_lock_table(p->igp_table_ip4); if (p->igp_table_ip6) rt_lock_table(p->igp_table_ip6); p->event = ev_new_init(p->p.pool, static_announce_marked, p); BUFFER_INIT(p->marked, p->p.pool, 4); /* We have to go UP before routes could be installed */ proto_notify_state(P, PS_UP); WALK_LIST(r, cf->routes) static_add_rte(p, r); return PS_UP; } static int static_shutdown(struct proto *P) { struct static_proto *p = (void *) P; struct static_config *cf = (void *) P->cf; struct static_route *r; /* Just reset the flag, the routes will be flushed by the nest */ WALK_LIST(r, cf->routes) static_reset_rte(p, r); return PS_DOWN; } static void static_cleanup(struct proto *P) { struct static_proto *p = (void *) P; if (p->igp_table_ip4) rt_unlock_table(p->igp_table_ip4); if (p->igp_table_ip6) rt_unlock_table(p->igp_table_ip6); } static void static_dump_rte(struct static_route *r) { debug("%-1N (%u): ", r->net, r->index); if (r->dest == RTD_UNICAST) if (r->iface && ipa_zero(r->via)) debug("dev %s\n", r->iface->name); else debug("via %I%J\n", r->via, r->iface); else debug("rtd %d\n", r->dest); } static void static_dump(struct proto *P) { struct static_config *c = (void *) P->cf; struct static_route *r; debug("Static routes:\n"); WALK_LIST(r, c->routes) static_dump_rte(r); } #define IGP_TABLE(cf, sym) ((cf)->igp_table_##sym ? (cf)->igp_table_##sym ->table : NULL ) static inline int srt_equal(const struct static_route *a, const struct static_route *b) { return net_equal(a->net, b->net) && (a->index == b->index); } static inline int srt_compare(const struct static_route *a, const struct static_route *b) { return net_compare(a->net, b->net) ?: uint_cmp(a->index, b->index); } static inline int srt_compare_qsort(const void *A, const void *B) { return srt_compare(*(const struct static_route * const *)A, *(const struct static_route * const *)B); } static void static_index_routes(struct static_config *cf) { struct static_route *rt, **buf; uint num, i, v; num = list_length(&cf->routes); buf = xmalloc(num * sizeof(void *)); /* Initialize with sequential indexes to ensure stable sorting */ i = 0; WALK_LIST(rt, cf->routes) { buf[i] = rt; rt->index = i++; } qsort(buf, num, sizeof(struct static_route *), srt_compare_qsort); /* Compute proper indexes - sequential for routes with same network */ for (i = 0, v = 0, rt = NULL; i < num; i++, v++) { if (rt && !net_equal(buf[i]->net, rt->net)) v = 0; rt = buf[i]; rt->index = v; } xfree(buf); } static int static_reconfigure(struct proto *P, struct proto_config *CF) { struct static_proto *p = (void *) P; struct static_config *o = (void *) P->cf; struct static_config *n = (void *) CF; struct static_route *r, *r2, *or, *nr; /* Check change in IGP tables */ if ((IGP_TABLE(o, ip4) != IGP_TABLE(n, ip4)) || (IGP_TABLE(o, ip6) != IGP_TABLE(n, ip6))) return 0; if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF))) return 0; p->p.cf = CF; /* Reset route lists in neighbor entries */ WALK_LIST(r, o->routes) for (r2 = r; r2; r2 = r2->mp_next) if (r2->neigh) r2->neigh->data = NULL; /* Reconfigure initial matching sequence */ for (or = HEAD(o->routes), nr = HEAD(n->routes); NODE_VALID(or) && NODE_VALID(nr) && srt_equal(or, nr); or = NODE_NEXT(or), nr = NODE_NEXT(nr)) static_reconfigure_rte(p, or, nr); if (!NODE_VALID(or) && !NODE_VALID(nr)) return 1; /* Reconfigure remaining routes, sort them to find matching pairs */ struct static_route *or2, *nr2, **orbuf, **nrbuf; uint ornum = 0, nrnum = 0, orpos = 0, nrpos = 0, i; for (or2 = or; NODE_VALID(or2); or2 = NODE_NEXT(or2)) ornum++; for (nr2 = nr; NODE_VALID(nr2); nr2 = NODE_NEXT(nr2)) nrnum++; orbuf = xmalloc(ornum * sizeof(void *)); nrbuf = xmalloc(nrnum * sizeof(void *)); for (i = 0, or2 = or; i < ornum; i++, or2 = NODE_NEXT(or2)) orbuf[i] = or2; for (i = 0, nr2 = nr; i < nrnum; i++, nr2 = NODE_NEXT(nr2)) nrbuf[i] = nr2; qsort(orbuf, ornum, sizeof(struct static_route *), srt_compare_qsort); qsort(nrbuf, nrnum, sizeof(struct static_route *), srt_compare_qsort); while ((orpos < ornum) && (nrpos < nrnum)) { int x = srt_compare(orbuf[orpos], nrbuf[nrpos]); if (x < 0) static_remove_rte(p, orbuf[orpos++]); else if (x > 0) static_add_rte(p, nrbuf[nrpos++]); else static_reconfigure_rte(p, orbuf[orpos++], nrbuf[nrpos++]); } while (orpos < ornum) static_remove_rte(p, orbuf[orpos++]); while (nrpos < nrnum) static_add_rte(p, nrbuf[nrpos++]); xfree(orbuf); xfree(nrbuf); /* All dirty routes were announced anyways */ BUFFER_FLUSH(p->marked); p->marked_all = 0; return 1; } static void static_copy_config(struct proto_config *dest, struct proto_config *src) { struct static_config *d = (struct static_config *) dest; struct static_config *s = (struct static_config *) src; struct static_route *srt, *snh; /* Copy route list */ init_list(&d->routes); WALK_LIST(srt, s->routes) { struct static_route *drt = NULL, *dnh = NULL, **dnp = &drt; for (snh = srt; snh; snh = snh->mp_next) { dnh = cfg_alloc(sizeof(struct static_route)); memcpy(dnh, snh, sizeof(struct static_route)); memset(&dnh->n, 0, sizeof(node)); if (!drt) add_tail(&d->routes, &(dnh->n)); *dnp = dnh; dnp = &(dnh->mp_next); if (snh->mp_head) dnh->mp_head = drt; } } } static void static_get_route_info(rte *rte, byte *buf) { eattr *a = ea_find(rte->attrs->eattrs, EA_GEN_IGP_METRIC); if (a) buf += bsprintf(buf, " (%d/%u)", rte->pref, a->u.data); else buf += bsprintf(buf, " (%d)", rte->pref); } static void static_show_rt(struct static_route *r) { switch (r->dest) { case RTD_UNICAST: { struct static_route *r2; cli_msg(-1009, "%N", r->net); for (r2 = r; r2; r2 = r2->mp_next) { if (r2->iface && ipa_zero(r2->via)) cli_msg(-1009, "\tdev %s%s", r2->iface->name, r2->active ? "" : " (dormant)"); else cli_msg(-1009, "\tvia %I%J%s%s%s", r2->via, r2->iface, r2->onlink ? " onlink" : "", r2->bfd_req ? " (bfd)" : "", r2->active ? "" : " (dormant)"); } break; } case RTD_NONE: case RTD_BLACKHOLE: case RTD_UNREACHABLE: case RTD_PROHIBIT: cli_msg(-1009, "%N\t%s", r->net, rta_dest_names[r->dest]); break; case RTDX_RECURSIVE: cli_msg(-1009, "%N\trecursive %I", r->net, r->via); break; } } void static_show(struct proto *P) { struct static_config *c = (void *) P->cf; struct static_route *r; WALK_LIST(r, c->routes) static_show_rt(r); } struct protocol proto_static = { .name = "Static", .template = "static%d", .class = PROTOCOL_STATIC, .preference = DEF_PREF_STATIC, .channel_mask = NB_ANY, .proto_size = sizeof(struct static_proto), .config_size = sizeof(struct static_config), .postconfig = static_postconfig, .init = static_init, .dump = static_dump, .start = static_start, .shutdown = static_shutdown, .cleanup = static_cleanup, .reconfigure = static_reconfigure, .copy_config = static_copy_config, .get_route_info = static_get_route_info, }; bird-2.0.8/proto/static/config.Y0000664000175000017500000000746114025744326015425 0ustar feelafeela/* * BIRD -- Static Protocol Configuration * * (c) 1998--1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "proto/static/static.h" CF_DEFINES #define STATIC_CFG ((struct static_config *) this_proto) static struct static_route *this_srt, *this_snh; static struct f_inst *this_srt_cmds, *this_srt_last_cmd; static struct static_route * static_nexthop_new(void) { struct static_route *nh = this_srt; if (this_snh) { /* Additional next hop */ nh = cfg_allocz(sizeof(struct static_route)); nh->net = this_srt->net; this_snh->mp_next = nh; } nh->dest = RTD_UNICAST; nh->mp_head = this_srt; return nh; }; static void static_route_finish(void) { if (net_type_match(this_srt->net, NB_DEST) == !this_srt->dest) cf_error("Unexpected or missing nexthop/type"); this_srt->cmds = f_linearize(this_srt_cmds); } CF_DECLS CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK) CF_KEYWORDS(ONLINK, WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS) CF_GRAMMAR proto: static_proto '}' ; static_proto_start: proto_start STATIC { this_proto = proto_config_new(&proto_static, $1); init_list(&STATIC_CFG->routes); }; static_proto: static_proto_start proto_name '{' | static_proto proto_item ';' | static_proto proto_channel ';' { this_proto->net_type = $2->net_type; } | static_proto CHECK LINK bool ';' { STATIC_CFG->check_link = $4; } | static_proto IGP TABLE rtable ';' { if ($4->addr_type == NET_IP4) STATIC_CFG->igp_table_ip4 = $4; else if ($4->addr_type == NET_IP6) STATIC_CFG->igp_table_ip6 = $4; else cf_error("Incompatible IGP table type"); } | static_proto stat_route stat_route_opt_list ';' { static_route_finish(); } ; stat_nexthop: VIA ipa ipa_scope { this_snh = static_nexthop_new(); this_snh->via = $2; this_snh->iface = $3; } | VIA TEXT { this_snh = static_nexthop_new(); this_snh->via = IPA_NONE; this_snh->iface = if_get_by_name($2); } | stat_nexthop MPLS label_stack { this_snh->mls = $3; } | stat_nexthop ONLINK bool { this_snh->onlink = $3; } | stat_nexthop WEIGHT expr { this_snh->weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("Weight must be in range 1-256"); } | stat_nexthop BFD bool { this_snh->use_bfd = $3; cf_check_bfd($3); } ; stat_nexthops: stat_nexthop | stat_nexthops stat_nexthop ; stat_route0: ROUTE net_any { this_srt = cfg_allocz(sizeof(struct static_route)); add_tail(&STATIC_CFG->routes, &this_srt->n); this_srt->net = $2; this_srt_cmds = NULL; this_srt_last_cmd = NULL; this_srt->mp_next = NULL; this_snh = NULL; } ; stat_route: stat_route0 stat_nexthops | stat_route0 RECURSIVE ipa { this_srt->dest = RTDX_RECURSIVE; this_srt->via = $3; } | stat_route0 RECURSIVE ipa MPLS label_stack { this_srt->dest = RTDX_RECURSIVE; this_srt->via = $3; this_srt->mls = $5; } | stat_route0 { this_srt->dest = RTD_NONE; } | stat_route0 DROP { this_srt->dest = RTD_BLACKHOLE; } | stat_route0 REJECT { this_srt->dest = RTD_UNREACHABLE; } | stat_route0 BLACKHOLE { this_srt->dest = RTD_BLACKHOLE; } | stat_route0 UNREACHABLE { this_srt->dest = RTD_UNREACHABLE; } | stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; } ; stat_route_item: cmd { if (this_srt_last_cmd) this_srt_last_cmd->next = $1; else this_srt_cmds = $1; this_srt_last_cmd = $1; } ; stat_route_opts: /* empty */ | stat_route_opts stat_route_item ; stat_route_opt_list: /* empty */ | '{' stat_route_opts '}' ; CF_CLI(SHOW STATIC, optproto, [], [[Show details of static protocol]]) { PROTO_WALK_CMD($3, &proto_static, p) static_show(p); } ; CF_CODE CF_END bird-2.0.8/proto/static/Makefile0000664000175000017500000000015314025744326015455 0ustar feelafeelasrc := static.c obj := $(src-o-files) $(all-daemon) $(cf-local) tests_objs := $(tests_objs) $(src-o-files)bird-2.0.8/proto/static/Doc0000664000175000017500000000001314025744326014440 0ustar feelafeelaS static.c bird-2.0.8/proto/rpki/0000775000175000017500000000000014025744326013474 5ustar feelafeelabird-2.0.8/proto/rpki/transport.h0000664000175000017500000000526314025744326015707 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ /* * The RPKI transport sockets implement the communication channel * (e.g., SSH, TCP, TCP-AO) between an RPKI server and client. * * Before using the transport socket, a tr_socket must be * initialized based on a protocol-dependent init function (e.g., * rpki_tr_tcp_init()). * * The rpki_tr_* functions call the corresponding function pointers, which are * passed in the rpki_tr_sock structure, and forward the remaining arguments. */ #ifndef _BIRD_RPKI_TRANSPORT_H_ #define _BIRD_RPKI_TRANSPORT_H_ #include /* The return values for rpki_tr_ functions */ enum rpki_tr_rtvals { RPKI_TR_SUCCESS = 0, /* Operation was successful */ RPKI_TR_ERROR = -1, /* Error occurred */ RPKI_TR_WOULDBLOCK = -2, /* No data is available on the socket */ RPKI_TR_INTR = -3, /* Call was interrupted from a signal */ RPKI_TR_CLOSED = -4 /* Connection closed */ }; /* A transport socket structure */ struct rpki_tr_sock { sock *sk; /* Standard BIRD socket */ struct rpki_cache *cache; /* Cache server */ int (*open_fp)(struct rpki_tr_sock *); /* Function that establishes the socket connection */ const char *(*ident_fp)(struct rpki_tr_sock *); /* Function that returns an identifier for the socket endpoint */ const char *ident; /* Internal. Use ident_fp() hook instead of this pointer */ }; int rpki_tr_open(struct rpki_tr_sock *tr); void rpki_tr_close(struct rpki_tr_sock *tr); const char *rpki_tr_ident(struct rpki_tr_sock *tr); /* Types of supported transports */ enum rpki_tr_type { RPKI_TR_TCP, /* Unprotected transport over TCP */ #if HAVE_LIBSSH RPKI_TR_SSH, /* Protected transport by SSHv2 connection */ #endif }; /* Common configure structure for transports */ struct rpki_tr_config { enum rpki_tr_type type; /* RPKI_TR_TCP or RPKI_TR_SSH */ const void *spec; /* Specific transport configuration, i.e. rpki_tr_tcp_config or rpki_tr_ssh_config */ }; struct rpki_tr_tcp_config { /* No internal configuration data */ }; struct rpki_tr_ssh_config { const char *bird_private_key; /* Filepath to the BIRD server private key */ const char *cache_public_key; /* Filepath to the public key of cache server, can be file known_hosts */ const char *user; /* Username for SSH connection */ }; /* ssh_transport.c */ void rpki_tr_ssh_init(struct rpki_tr_sock *tr); /* tcp_transport.c */ void rpki_tr_tcp_init(struct rpki_tr_sock *tr); #endif /* _BIRD_RPKI_TRANSPORT_H_ */ bird-2.0.8/proto/rpki/transport.c0000664000175000017500000000634214025744326015701 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include "rpki.h" #include "transport.h" #include "sysdep/unix/unix.h" /** * rpki_hostname_autoresolv - auto-resolve an IP address from a hostname * @host: domain name of host, e.g. "rpki-validator.realmv6.org" * @err_msg: error message returned in case of errors * * This function resolves an IP address from a hostname. * Returns &ip_addr structure with IP address or |IPA_NONE|. */ static ip_addr rpki_hostname_autoresolv(const char *host, const char **err_msg) { struct addrinfo *res; struct addrinfo hints = { .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, .ai_flags = AI_ADDRCONFIG, }; *err_msg = NULL; if (!host) return IPA_NONE; int err_code = getaddrinfo(host, NULL, &hints, &res); if (err_code != 0) { *err_msg = gai_strerror(err_code); return IPA_NONE; } ip_addr addr = IPA_NONE; uint unused; sockaddr_read((sockaddr *) res->ai_addr, res->ai_family, &addr, NULL, &unused); freeaddrinfo(res); return addr; } /** * rpki_tr_open - prepare and open a socket connection * @tr: initialized transport socket * * Prepare and open a socket connection specified by @tr that must be initialized before. * This function ends with a calling the sk_open() function. * Returns RPKI_TR_SUCCESS or RPKI_TR_ERROR. */ int rpki_tr_open(struct rpki_tr_sock *tr) { struct rpki_cache *cache = tr->cache; struct rpki_config *cf = (void *) cache->p->p.cf; ASSERT(tr->sk == NULL); tr->sk = sk_new(cache->pool); sock *sk = tr->sk; /* sk->type -1 is invalid value, a correct value MUST be set in the specific transport layer in open_fp() hook */ sk->type = -1; sk->tx_hook = rpki_connected_hook; sk->err_hook = rpki_err_hook; sk->data = cache; sk->daddr = cf->ip; sk->dport = cf->port; sk->host = cf->hostname; sk->rbsize = RPKI_RX_BUFFER_SIZE; sk->tbsize = RPKI_TX_BUFFER_SIZE; sk->tos = IP_PREC_INTERNET_CONTROL; if (ipa_zero(sk->daddr) && sk->host) { const char *err_msg; sk->daddr = rpki_hostname_autoresolv(sk->host, &err_msg); if (ipa_zero(sk->daddr)) { log(L_ERR "%s: Cannot resolve hostname '%s': %s", cache->p->p.name, sk->host, err_msg); return RPKI_TR_ERROR; } } return tr->open_fp(tr); } /** * rpki_tr_close - close socket and prepare it for possible next open * @tr: successfully opened transport socket * * Close socket and free resources. */ void rpki_tr_close(struct rpki_tr_sock *tr) { if (tr->ident) { mb_free((char *) tr->ident); tr->ident = NULL; } if (tr->sk) { rfree(tr->sk); tr->sk = NULL; } } /** * rpki_tr_ident - Returns a string identifier for the rpki transport socket * @tr: successfully opened transport socket * * Returns a \0 terminated string identifier for the socket endpoint, e.g. ":". * Memory is allocated inside @tr structure. */ inline const char * rpki_tr_ident(struct rpki_tr_sock *tr) { return tr->ident_fp(tr); } bird-2.0.8/proto/rpki/tcp_transport.c0000664000175000017500000000257214025744326016550 0ustar feelafeela/* * BIRD -- An implementation of the TCP protocol for the RPKI protocol transport * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include #include #include #include #include #include "rpki.h" #include "sysdep/unix/unix.h" static int rpki_tr_tcp_open(struct rpki_tr_sock *tr) { sock *sk = tr->sk; sk->type = SK_TCP_ACTIVE; if (sk_open(sk) != 0) return RPKI_TR_ERROR; return RPKI_TR_SUCCESS; } static const char * rpki_tr_tcp_ident(struct rpki_tr_sock *tr) { struct rpki_cache *cache = tr->cache; struct rpki_config *cf = (void *) cache->p->p.cf; if (tr->ident != NULL) return tr->ident; /* Length: + ':' + + '\0' */ size_t len = strlen(cf->hostname) + 1 + 5 + 1; char *ident = mb_alloc(cache->pool, len); bsnprintf(ident, len, "%s:%u", cf->hostname, cf->port); tr->ident = ident; return tr->ident; } /** * rpki_tr_tcp_init - initializes the RPKI transport structure for a TCP connection * @tr: allocated RPKI transport structure */ void rpki_tr_tcp_init(struct rpki_tr_sock *tr) { tr->open_fp = &rpki_tr_tcp_open; tr->ident_fp = &rpki_tr_tcp_ident; } bird-2.0.8/proto/rpki/ssh_transport.c0000664000175000017500000000367214025744326016561 0ustar feelafeela/* * BIRD -- An implementation of the SSH protocol for the RPKI transport * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * This transport implementation uses libssh (http://www.libssh.org/) * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include #include "rpki.h" #if HAVE_LIBSSH static int rpki_tr_ssh_open(struct rpki_tr_sock *tr) { struct rpki_cache *cache = tr->cache; struct rpki_config *cf = (void *) cache->p->p.cf; struct rpki_tr_ssh_config *ssh_cf = (void *) cf->tr_config.spec; sock *sk = tr->sk; sk->type = SK_SSH_ACTIVE; sk->ssh = mb_allocz(sk->pool, sizeof(struct ssh_sock)); sk->ssh->username = ssh_cf->user; sk->ssh->client_privkey_path = ssh_cf->bird_private_key; sk->ssh->server_hostkey_path = ssh_cf->cache_public_key; sk->ssh->subsystem = "rpki-rtr"; sk->ssh->state = SK_SSH_CONNECT; if (sk_open(sk) != 0) return RPKI_TR_ERROR; return RPKI_TR_SUCCESS; } static const char * rpki_tr_ssh_ident(struct rpki_tr_sock *tr) { struct rpki_cache *cache = tr->cache; struct rpki_config *cf = (void *) cache->p->p.cf; struct rpki_tr_ssh_config *ssh_cf = (void *) cf->tr_config.spec; const char *username = ssh_cf->user; if (tr->ident != NULL) return tr->ident; /* Length: + '@' + + ' port ' + + '\0' */ size_t len = strlen(username) + 1 + strlen(cf->hostname) + 1 + 5 + 1; char *ident = mb_alloc(cache->pool, len); bsnprintf(ident, len, "%s@%s:%u", username, cf->hostname, cf->port); tr->ident = ident; return tr->ident; } /** * rpki_tr_ssh_init - initializes the RPKI transport structure for a SSH connection * @tr: allocated RPKI transport structure */ void rpki_tr_ssh_init(struct rpki_tr_sock *tr) { tr->open_fp = &rpki_tr_ssh_open; tr->ident_fp = &rpki_tr_ssh_ident; } #endif bird-2.0.8/proto/rpki/rpki.h0000664000175000017500000001315514025744326014617 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * Using RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_RPKI_H_ #define _BIRD_RPKI_H_ #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" #include "lib/socket.h" #include "lib/ip.h" #include "transport.h" #include "packets.h" #define RPKI_TCP_PORT 323 #define RPKI_SSH_PORT 22 #define RPKI_RETRY_INTERVAL 600 #define RPKI_REFRESH_INTERVAL 3600 #define RPKI_EXPIRE_INTERVAL 7200 #define RPKI_VERSION_0 0 #define RPKI_VERSION_1 1 #define RPKI_MAX_VERSION RPKI_VERSION_1 /* * RPKI Cache */ enum rpki_cache_state { RPKI_CS_CONNECTING, /* Socket is establishing the transport connection. */ RPKI_CS_ESTABLISHED, /* Connection is established, socket is waiting for a Serial Notify or expiration of the refresh_interval timer */ RPKI_CS_RESET, /* Resetting RTR connection. */ RPKI_CS_SYNC_START, /* Sending a Serial/Reset Query PDU and expecting a Cache Response PDU */ RPKI_CS_SYNC_RUNNING, /* Receiving validation records from the RTR server. A state between Cache Response PDU and End of Data PDU */ RPKI_CS_FAST_RECONNECT, /* Reconnect without any waiting period */ RPKI_CS_NO_INCR_UPDATE_AVAIL, /* Server is unable to answer the last Serial Query and sent Cache Reset. */ RPKI_CS_ERROR_NO_DATA_AVAIL, /* Server is unable to answer either a Serial Query or a Reset Query because it has no useful data available at this time. */ RPKI_CS_ERROR_FATAL, /* Fatal protocol error occurred. */ RPKI_CS_ERROR_TRANSPORT, /* Error on the transport socket occurred. */ RPKI_CS_SHUTDOWN, /* RTR Socket is stopped. */ }; struct rpki_cache { pool *pool; /* Pool containing cache objects */ struct rpki_proto *p; struct rpki_tr_sock *tr_sock; /* Transport specific socket */ enum rpki_cache_state state; /* RPKI_CS_* */ u32 session_id; u8 request_session_id; /* 1: have to request new session id; 0: we have already received session id */ u32 serial_num; /* Serial number denotes the logical version of data from cache server */ u8 version; /* Protocol version */ btime last_update; /* Last successful synchronization with cache server */ btime last_rx_prefix; /* Last received prefix PDU */ /* Intervals can be changed by cache server on the fly */ u32 refresh_interval; /* Actual refresh interval (in seconds) */ u32 retry_interval; u32 expire_interval; timer *retry_timer; /* Retry timer event */ timer *refresh_timer; /* Refresh timer event */ timer *expire_timer; /* Expire timer event */ }; const char *rpki_get_cache_ident(struct rpki_cache *cache); const char *rpki_cache_state_to_str(enum rpki_cache_state state); /* * Routes handling */ void rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr); void rpki_table_remove_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr); /* * RPKI Protocol Logic */ void rpki_cache_change_state(struct rpki_cache *cache, const enum rpki_cache_state new_state); /* * RPKI Timer Events */ const char *rpki_check_refresh_interval(uint seconds); const char *rpki_check_retry_interval(uint seconds); const char *rpki_check_expire_interval(uint seconds); /* * RPKI Protocol Configuration */ struct rpki_proto { struct proto p; struct rpki_cache *cache; struct channel *roa4_channel; struct channel *roa6_channel; u8 refresh_channels; /* For non-incremental updates using rt_refresh_begin(), rt_refresh_end() */ }; struct rpki_config { struct proto_config c; const char *hostname; /* Full domain name or stringified IP address of cache server */ ip_addr ip; /* IP address of cache server or IPA_NONE */ u16 port; /* Port number of cache server */ struct rpki_tr_config tr_config; /* Specific transport configuration structure */ u32 refresh_interval; /* Time interval (in seconds) for periodical downloading data from cache server */ u32 retry_interval; /* Time interval (in seconds) for an unreachable server */ u32 expire_interval; /* Maximal lifetime (in seconds) of ROAs without any successful refreshment */ u8 keep_refresh_interval:1; /* Do not overwrite refresh interval by cache server update */ u8 keep_retry_interval:1; /* Do not overwrite retry interval by cache server update */ u8 keep_expire_interval:1; /* Do not overwrite expire interval by cache server update */ u8 ignore_max_length:1; /* Ignore received max length and use MAX_PREFIX_LENGTH instead */ }; void rpki_check_config(struct rpki_config *cf); /* * Logger */ #define RPKI_LOG(log_level, rpki, msg, args...) \ do { \ log(log_level "%s: " msg, (rpki)->p.name , ## args); \ } while(0) #if defined(LOCAL_DEBUG) || defined(GLOBAL_DEBUG) #define CACHE_DBG(cache,msg,args...) \ do { \ RPKI_LOG(L_DEBUG, (cache)->p, "%s [%s] %s " msg, rpki_get_cache_ident(cache), rpki_cache_state_to_str((cache)->state), __func__, ## args); \ } while(0) #else #define CACHE_DBG(cache,msg,args...) do { } while(0) #endif #define RPKI_TRACE(level,rpki,msg,args...) \ do { \ if ((rpki)->p.debug & level) \ RPKI_LOG(L_TRACE, rpki, msg, ## args); \ } while(0) #define CACHE_TRACE(level,cache,msg,args...) \ do { \ if ((cache)->p->p.debug & level) \ RPKI_LOG(L_TRACE, (cache)->p, msg, ## args); \ } while(0) #define RPKI_WARN(p, msg, args...) RPKI_LOG(L_WARN, p, msg, ## args); #endif /* _BIRD_RPKI_H_ */ bird-2.0.8/proto/rpki/rpki.c0000664000175000017500000006546314025744326014623 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * Using RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: RPKI To Router (RPKI-RTR) * * The RPKI-RTR protocol is implemented in several files: |rpki.c| containing * the routes handling, protocol logic, timer events, cache connection, * reconfiguration, configuration and protocol glue with BIRD core, |packets.c| * containing the RPKI packets handling and finally all transports files: * |transport.c|, |tcp_transport.c| and |ssh_transport.c|. * * The |transport.c| is a middle layer and interface for each specific * transport. Transport is a way how to wrap a communication with a cache * server. There is supported an unprotected TCP transport and an encrypted * SSHv2 transport. The SSH transport requires LibSSH library. LibSSH is * loading dynamically using |dlopen()| function. SSH support is integrated in * |sysdep/unix/io.c|. Each transport must implement an initialization * function, an open function and a socket identification function. That's all. * * This implementation is based on the RTRlib (http://rpki.realmv6.org/). The * BIRD takes over files |packets.c|, |rtr.c| (inside |rpki.c|), |transport.c|, * |tcp_transport.c| and |ssh_transport.c| from RTRlib. * * A RPKI-RTR connection is described by a structure &rpki_cache. The main * logic is located in |rpki_cache_change_state()| function. There is a state * machine. The standard starting state flow looks like |Down| ~> |Connecting| * ~> |Sync-Start| ~> |Sync-Running| ~> |Established| and then the last three * states are periodically repeated. * * |Connecting| state establishes the transport connection. The state from a * call |rpki_cache_change_state(CONNECTING)| to a call |rpki_connected_hook()| * * |Sync-Start| state starts with sending |Reset Query| or |Serial Query| and * then waits for |Cache Response|. The state from |rpki_connected_hook()| to * |rpki_handle_cache_response_pdu()| * * During |Sync-Running| BIRD receives data with IPv4/IPv6 Prefixes from cache * server. The state starts from |rpki_handle_cache_response_pdu()| and ends * in |rpki_handle_end_of_data_pdu()|. * * |Established| state means that BIRD has synced all data with cache server. * Schedules a refresh timer event that invokes |Sync-Start|. Schedules Expire * timer event and stops a Retry timer event. * * |Transport Error| state means that we have some troubles with a network * connection. We cannot connect to a cache server or we wait too long for some * expected PDU for received - |Cache Response| or |End of Data|. It closes * current connection and schedules a Retry timer event. * * |Fatal Protocol Error| is occurred e.g. by received a bad Session ID. We * restart a protocol, so all ROAs are flushed immediately. * * The RPKI-RTR protocol (RFC 6810 bis) defines configurable refresh, retry and * expire intervals. For maintaining a connection are used timer events that * are scheduled by |rpki_schedule_next_refresh()|, * |rpki_schedule_next_retry()| and |rpki_schedule_next_expire()| functions. * * A Refresh timer event performs a sync of |Established| connection. So it * shifts state to |Sync-Start|. If at the beginning of second call of a * refresh event is connection in |Sync-Start| state then we didn't receive a * |Cache Response| from a cache server and we invoke |Transport Error| state. * * A Retry timer event attempts to connect cache server. It is activated after * |Transport Error| state and terminated by reaching |Established| state. * If cache connection is still connecting to the cache server at the beginning * of an event call then the Retry timer event invokes |Transport Error| state. * * An Expire timer event checks expiration of ROAs. If a last successful sync * was more ago than the expire interval then the Expire timer event invokes a * protocol restart thereby removes all ROAs learned from that cache server and * continue trying to connect to cache server. The Expire event is activated * by initial successful loading of ROAs, receiving End of Data PDU. * * A reconfiguration of cache connection works well without restarting when we * change only intervals values. * * Supported standards: * - RFC 6810 - main RPKI-RTR standard * - RFC 6810 bis - an explicit timing parameters and protocol version number negotiation */ #include #include #undef LOCAL_DEBUG #include "rpki.h" #include "lib/string.h" #include "nest/cli.h" /* Return values for reconfiguration functions */ #define NEED_RESTART 0 #define SUCCESSFUL_RECONF 1 static int rpki_open_connection(struct rpki_cache *cache); static void rpki_close_connection(struct rpki_cache *cache); static void rpki_schedule_next_refresh(struct rpki_cache *cache); static void rpki_schedule_next_retry(struct rpki_cache *cache); static void rpki_schedule_next_expire_check(struct rpki_cache *cache); static void rpki_stop_refresh_timer_event(struct rpki_cache *cache); static void rpki_stop_retry_timer_event(struct rpki_cache *cache); static void rpki_stop_expire_timer_event(struct rpki_cache *cache); /* * Routes handling */ void rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr) { struct rpki_proto *p = cache->p; rta a0 = { .src = p->p.main_source, .source = RTS_RPKI, .scope = SCOPE_UNIVERSE, .dest = RTD_NONE, }; rta *a = rta_lookup(&a0); rte *e = rte_get_temp(a); e->pflags = 0; rte_update2(channel, &pfxr->n, e, a0.src); } void rpki_table_remove_roa(struct rpki_cache *cache, struct channel *channel, const net_addr_union *pfxr) { struct rpki_proto *p = cache->p; rte_update2(channel, &pfxr->n, NULL, p->p.main_source); } /* * RPKI Protocol Logic */ static const char *str_cache_states[] = { [RPKI_CS_CONNECTING] = "Connecting", [RPKI_CS_ESTABLISHED] = "Established", [RPKI_CS_RESET] = "Reseting", [RPKI_CS_SYNC_START] = "Sync-Start", [RPKI_CS_SYNC_RUNNING] = "Sync-Running", [RPKI_CS_FAST_RECONNECT] = "Fast-Reconnect", [RPKI_CS_NO_INCR_UPDATE_AVAIL]= "No-Increment-Update-Available", [RPKI_CS_ERROR_NO_DATA_AVAIL] = "Cache-Error-No-Data-Available", [RPKI_CS_ERROR_FATAL] = "Fatal-Protocol-Error", [RPKI_CS_ERROR_TRANSPORT] = "Transport-Error", [RPKI_CS_SHUTDOWN] = "Down" }; /** * rpki_cache_state_to_str - give a text representation of cache state * @state: A cache state * * The function converts logic cache state into string. */ const char * rpki_cache_state_to_str(enum rpki_cache_state state) { return str_cache_states[state]; } /** * rpki_start_cache - connect to a cache server * @cache: RPKI connection instance * * This function is a high level method to kick up a connection to a cache server. */ static void rpki_start_cache(struct rpki_cache *cache) { rpki_cache_change_state(cache, RPKI_CS_CONNECTING); } /** * rpki_force_restart_proto - force shutdown and start protocol again * @p: RPKI protocol instance * * This function calls shutdown and frees all protocol resources as well. * After calling this function should be no operations with protocol data, * they could be freed already. */ static void rpki_force_restart_proto(struct rpki_proto *p) { if (p->cache) { CACHE_DBG(p->cache, "Connection object destroying"); } /* Sign as freed */ p->cache = NULL; proto_notify_state(&p->p, PS_DOWN); } /** * rpki_cache_change_state - check and change cache state * @cache: RPKI cache instance * @new_state: suggested new state * * This function makes transitions between internal states. * It represents the core of logic management of RPKI protocol. * Cannot transit into the same state as cache is in already. */ void rpki_cache_change_state(struct rpki_cache *cache, const enum rpki_cache_state new_state) { const enum rpki_cache_state old_state = cache->state; if (old_state == new_state) return; cache->state = new_state; CACHE_TRACE(D_EVENTS, cache, "Changing from %s to %s state", rpki_cache_state_to_str(old_state), rpki_cache_state_to_str(new_state)); switch (new_state) { case RPKI_CS_CONNECTING: { sock *sk = cache->tr_sock->sk; if (sk == NULL || sk->fd < 0) rpki_open_connection(cache); else rpki_cache_change_state(cache, RPKI_CS_SYNC_START); rpki_schedule_next_retry(cache); break; } case RPKI_CS_ESTABLISHED: rpki_schedule_next_refresh(cache); rpki_schedule_next_expire_check(cache); rpki_stop_retry_timer_event(cache); break; case RPKI_CS_RESET: /* Resetting cache connection. */ cache->request_session_id = 1; cache->serial_num = 0; rpki_cache_change_state(cache, RPKI_CS_SYNC_START); break; case RPKI_CS_SYNC_START: /* Requesting for receive ROAs from a cache server. */ if (cache->request_session_id) { /* Send request for Session ID */ if (rpki_send_reset_query(cache) != RPKI_SUCCESS) rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); } else { /* We have already a session_id. So send a Serial Query and start an incremental sync */ if (rpki_send_serial_query(cache) != RPKI_SUCCESS) rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); } break; case RPKI_CS_SYNC_RUNNING: /* The state between Cache Response and End of Data. Only waiting for * receiving all IP Prefix PDUs and finally a End of Data PDU. */ break; case RPKI_CS_NO_INCR_UPDATE_AVAIL: /* Server was unable to answer the last Serial Query and sent Cache Reset. */ rpki_cache_change_state(cache, RPKI_CS_RESET); break; case RPKI_CS_ERROR_NO_DATA_AVAIL: /* No validation records are available on the cache server. */ rpki_cache_change_state(cache, RPKI_CS_RESET); break; case RPKI_CS_ERROR_FATAL: /* Fatal protocol error occurred. */ rpki_force_restart_proto(cache->p); break; case RPKI_CS_ERROR_TRANSPORT: /* Error on the transport socket occurred. */ rpki_close_connection(cache); rpki_schedule_next_retry(cache); rpki_stop_refresh_timer_event(cache); break; case RPKI_CS_FAST_RECONNECT: /* Reconnect without any waiting period */ rpki_close_connection(cache); rpki_cache_change_state(cache, RPKI_CS_CONNECTING); break; case RPKI_CS_SHUTDOWN: bug("This isn't never really called."); break; }; } /* * RPKI Timer Events */ static void rpki_schedule_next_refresh(struct rpki_cache *cache) { btime t = cache->refresh_interval S; CACHE_DBG(cache, "after %t s", t); tm_start(cache->refresh_timer, t); } static void rpki_schedule_next_retry(struct rpki_cache *cache) { btime t = cache->retry_interval S; CACHE_DBG(cache, "after %t s", t); tm_start(cache->retry_timer, t); } static void rpki_schedule_next_expire_check(struct rpki_cache *cache) { /* A minimum time to wait is 1 second */ btime t = cache->last_update + cache->expire_interval S - current_time(); t = MAX(t, 1 S); CACHE_DBG(cache, "after %t s", t); tm_start(cache->expire_timer, t); } static void rpki_stop_refresh_timer_event(struct rpki_cache *cache) { CACHE_DBG(cache, "Stop"); tm_stop(cache->refresh_timer); } static void rpki_stop_retry_timer_event(struct rpki_cache *cache) { CACHE_DBG(cache, "Stop"); tm_stop(cache->retry_timer); } static void UNUSED rpki_stop_expire_timer_event(struct rpki_cache *cache) { CACHE_DBG(cache, "Stop"); tm_stop(cache->expire_timer); } static int rpki_do_we_recv_prefix_pdu_in_last_seconds(struct rpki_cache *cache) { if (!cache->last_rx_prefix) return 0; return ((current_time() - cache->last_rx_prefix) <= 2 S); } /** * rpki_refresh_hook - control a scheduling of downloading data from cache server * @tm: refresh timer with cache connection instance in data * * This function is periodically called during &ESTABLISHED or &SYNC* state * cache connection. The first refresh schedule is invoked after receiving a * |End of Data| PDU and has run by some &ERROR is occurred. */ static void rpki_refresh_hook(timer *tm) { struct rpki_cache *cache = tm->data; CACHE_DBG(cache, "%s", rpki_cache_state_to_str(cache->state)); switch (cache->state) { case RPKI_CS_ESTABLISHED: rpki_cache_change_state(cache, RPKI_CS_SYNC_START); break; case RPKI_CS_SYNC_START: /* We sent Serial/Reset Query in last refresh hook call * and didn't receive Cache Response yet. It is probably * troubles with network. */ case RPKI_CS_SYNC_RUNNING: /* We sent Serial/Reset Query in last refresh hook call * and we got Cache Response but didn't get End-Of-Data yet. * It could be a trouble with network or only too long synchronization. */ if (!rpki_do_we_recv_prefix_pdu_in_last_seconds(cache)) { CACHE_TRACE(D_EVENTS, cache, "Sync takes more time than refresh interval %us, resetting connection", cache->refresh_interval); rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); } break; default: break; } if (cache->state != RPKI_CS_SHUTDOWN && cache->state != RPKI_CS_ERROR_TRANSPORT) rpki_schedule_next_refresh(cache); else rpki_stop_refresh_timer_event(cache); } /** * rpki_retry_hook - control a scheduling of retrying connection to cache server * @tm: retry timer with cache connection instance in data * * This function is periodically called during &ERROR* state cache connection. * The first retry schedule is invoked after any &ERROR* state occurred and * ends by reaching of &ESTABLISHED state again. */ static void rpki_retry_hook(timer *tm) { struct rpki_cache *cache = tm->data; CACHE_DBG(cache, "%s", rpki_cache_state_to_str(cache->state)); switch (cache->state) { case RPKI_CS_ESTABLISHED: case RPKI_CS_SHUTDOWN: break; case RPKI_CS_CONNECTING: case RPKI_CS_SYNC_START: case RPKI_CS_SYNC_RUNNING: if (!rpki_do_we_recv_prefix_pdu_in_last_seconds(cache)) { /* We tried to establish a connection in last retry hook call and haven't done * yet. It looks like troubles with network. We are aggressive here. */ CACHE_TRACE(D_EVENTS, cache, "Sync takes more time than retry interval %us, resetting connection.", cache->retry_interval); rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); } break; default: rpki_cache_change_state(cache, RPKI_CS_CONNECTING); break; } if (cache->state != RPKI_CS_ESTABLISHED) rpki_schedule_next_retry(cache); else rpki_stop_retry_timer_event(cache); } /** * rpki_expire_hook - control a expiration of ROA entries * @tm: expire timer with cache connection instance in data * * This function is scheduled after received a |End of Data| PDU. * A waiting interval is calculated dynamically by last update. * If we reach an expiration time then we invoke a restarting * of the protocol. */ static void rpki_expire_hook(timer *tm) { struct rpki_cache *cache = tm->data; if (!cache->last_update) return; CACHE_DBG(cache, "%s", rpki_cache_state_to_str(cache->state)); btime t = cache->last_update + cache->expire_interval S - current_time(); if (t <= 0) { CACHE_TRACE(D_EVENTS, cache, "All ROAs expired"); rpki_force_restart_proto(cache->p); } else { CACHE_DBG(cache, "Remains %t seconds to become ROAs obsolete", t); rpki_schedule_next_expire_check(cache); } } /** * rpki_check_refresh_interval - check validity of refresh interval value * @seconds: suggested value * * This function validates value and should return |NULL|. * If the check doesn't pass then returns error message. */ const char * rpki_check_refresh_interval(uint seconds) { if (seconds < 1) return "Minimum allowed refresh interval is 1 second"; if (seconds > 86400) return "Maximum allowed refresh interval is 86400 seconds"; return NULL; } /** * rpki_check_retry_interval - check validity of retry interval value * @seconds: suggested value * * This function validates value and should return |NULL|. * If the check doesn't pass then returns error message. */ const char * rpki_check_retry_interval(uint seconds) { if (seconds < 1) return "Minimum allowed retry interval is 1 second"; if (seconds > 7200) return "Maximum allowed retry interval is 7200 seconds"; return NULL; } /** * rpki_check_expire_interval - check validity of expire interval value * @seconds: suggested value * * This function validates value and should return |NULL|. * If the check doesn't pass then returns error message. */ const char * rpki_check_expire_interval(uint seconds) { if (seconds < 600) return "Minimum allowed expire interval is 600 seconds"; if (seconds > 172800) return "Maximum allowed expire interval is 172800 seconds"; return NULL; } /* * RPKI Cache */ static struct rpki_cache * rpki_init_cache(struct rpki_proto *p, struct rpki_config *cf) { pool *pool = rp_new(p->p.pool, cf->hostname); struct rpki_cache *cache = mb_allocz(pool, sizeof(struct rpki_cache)); cache->pool = pool; cache->p = p; cache->state = RPKI_CS_SHUTDOWN; cache->request_session_id = 1; cache->version = RPKI_MAX_VERSION; cache->refresh_interval = cf->refresh_interval; cache->retry_interval = cf->retry_interval; cache->expire_interval = cf->expire_interval; cache->refresh_timer = tm_new_init(pool, &rpki_refresh_hook, cache, 0, 0); cache->retry_timer = tm_new_init(pool, &rpki_retry_hook, cache, 0, 0); cache->expire_timer = tm_new_init(pool, &rpki_expire_hook, cache, 0, 0); cache->tr_sock = mb_allocz(pool, sizeof(struct rpki_tr_sock)); cache->tr_sock->cache = cache; switch (cf->tr_config.type) { case RPKI_TR_TCP: rpki_tr_tcp_init(cache->tr_sock); break; #if HAVE_LIBSSH case RPKI_TR_SSH: rpki_tr_ssh_init(cache->tr_sock); break; #endif }; CACHE_DBG(cache, "Connection object created"); return cache; } /** * rpki_get_cache_ident - give a text representation of cache server name * @cache: RPKI connection instance * * The function converts cache connection into string. */ const char * rpki_get_cache_ident(struct rpki_cache *cache) { return rpki_tr_ident(cache->tr_sock); } static int rpki_open_connection(struct rpki_cache *cache) { CACHE_TRACE(D_EVENTS, cache, "Opening a connection"); if (rpki_tr_open(cache->tr_sock) == RPKI_TR_ERROR) { rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); return RPKI_TR_ERROR; } return RPKI_TR_SUCCESS; } static void rpki_close_connection(struct rpki_cache *cache) { CACHE_TRACE(D_EVENTS, cache, "Closing a connection"); rpki_tr_close(cache->tr_sock); proto_notify_state(&cache->p->p, PS_START); } static int rpki_shutdown(struct proto *P) { struct rpki_proto *p = (void *) P; rpki_force_restart_proto(p); /* Protocol memory pool will be automatically freed */ return PS_DOWN; } /* * RPKI Reconfiguration */ /** * rpki_reconfigure_cache - a cache reconfiguration * @p: RPKI protocol instance * @cache: a cache connection * @new: new RPKI configuration * @old: old RPKI configuration * * This function reconfigures existing single cache server connection with new * existing configuration. Generally, a change of time intervals could be * reconfigured without restarting and all others changes requires a restart of * protocol. Returns |NEED_TO_RESTART| or |SUCCESSFUL_RECONF|. */ static int rpki_reconfigure_cache(struct rpki_proto *p UNUSED, struct rpki_cache *cache, struct rpki_config *new, struct rpki_config *old) { u8 try_reset = 0; u8 try_fast_reconnect = 0; if (strcmp(old->hostname, new->hostname) != 0) { CACHE_TRACE(D_EVENTS, cache, "Cache server address changed to %s", new->hostname); return NEED_RESTART; } if (old->port != new->port) { CACHE_TRACE(D_EVENTS, cache, "Cache server port changed to %u", new->port); return NEED_RESTART; } if (old->tr_config.type != new->tr_config.type) { CACHE_TRACE(D_EVENTS, cache, "Transport type changed"); return NEED_RESTART; } if (old->ignore_max_length != new->ignore_max_length) { CACHE_TRACE(D_EVENTS, cache, "Ignore max length changed"); try_reset = 1; } #if HAVE_LIBSSH else if (new->tr_config.type == RPKI_TR_SSH) { struct rpki_tr_ssh_config *ssh_old = (void *) old->tr_config.spec; struct rpki_tr_ssh_config *ssh_new = (void *) new->tr_config.spec; if (bstrcmp(ssh_old->bird_private_key, ssh_new->bird_private_key) || bstrcmp(ssh_old->cache_public_key, ssh_new->cache_public_key) || bstrcmp(ssh_old->user, ssh_new->user)) { CACHE_TRACE(D_EVENTS, cache, "Settings of SSH transport configuration changed"); try_fast_reconnect = 1; } } #endif #define TEST_INTERVAL(name, Name) \ if (old->name##_interval != new->name##_interval || \ old->keep_##name##_interval != new->keep_##name##_interval) \ { \ cache->name##_interval = new->name##_interval; \ CACHE_TRACE(D_EVENTS, cache, #Name " interval changed to %u seconds %s", cache->name##_interval, (new->keep_##name##_interval ? "and keep it" : "")); \ try_fast_reconnect = 1; \ } TEST_INTERVAL(refresh, Refresh); TEST_INTERVAL(retry, Retry); TEST_INTERVAL(expire, Expire); #undef TEST_INTERVAL if (try_reset || try_fast_reconnect) { if (cache->state != RPKI_CS_ESTABLISHED) return NEED_RESTART; if (try_reset && !try_fast_reconnect) rpki_cache_change_state(cache, RPKI_CS_RESET); if (try_fast_reconnect) { if (try_reset) { /* Force reset during reconnect */ cache->request_session_id = 1; cache->serial_num = 0; } rpki_cache_change_state(cache, RPKI_CS_FAST_RECONNECT); } } return SUCCESSFUL_RECONF; } /** * rpki_reconfigure - a protocol reconfiguration hook * @P: a protocol instance * @CF: a new protocol configuration * * This function reconfigures whole protocol. * It sets new protocol configuration into a protocol structure. * Returns |NEED_TO_RESTART| or |SUCCESSFUL_RECONF|. */ static int rpki_reconfigure(struct proto *P, struct proto_config *CF) { struct rpki_proto *p = (void *) P; struct rpki_config *new = (void *) CF; struct rpki_config *old = (void *) p->p.cf; struct rpki_cache *cache = p->cache; if (!proto_configure_channel(&p->p, &p->roa4_channel, proto_cf_find_channel(CF, NET_ROA4)) || !proto_configure_channel(&p->p, &p->roa6_channel, proto_cf_find_channel(CF, NET_ROA6))) return NEED_RESTART; if (rpki_reconfigure_cache(p, cache, new, old) != SUCCESSFUL_RECONF) return NEED_RESTART; return SUCCESSFUL_RECONF; } /* * RPKI Protocol Glue */ static struct proto * rpki_init(struct proto_config *CF) { struct proto *P = proto_new(CF); struct rpki_proto *p = (void *) P; proto_configure_channel(&p->p, &p->roa4_channel, proto_cf_find_channel(CF, NET_ROA4)); proto_configure_channel(&p->p, &p->roa6_channel, proto_cf_find_channel(CF, NET_ROA6)); return P; } static int rpki_start(struct proto *P) { struct rpki_proto *p = (void *) P; struct rpki_config *cf = (void *) P->cf; p->cache = rpki_init_cache(p, cf); rpki_start_cache(p->cache); return PS_START; } static void rpki_get_status(struct proto *P, byte *buf) { struct rpki_proto *p = (struct rpki_proto *) P; if (P->proto_state == PS_DOWN) { *buf = 0; return; } if (p->cache) bsprintf(buf, "%s", rpki_cache_state_to_str(p->cache->state)); else bsprintf(buf, "No cache server configured"); } static void rpki_show_proto_info_timer(const char *name, uint num, timer *t) { if (tm_active(t)) cli_msg(-1006, " %-16s: %t/%u", name, tm_remains(t), num); else cli_msg(-1006, " %-16s: ---", name); } static void rpki_show_proto_info(struct proto *P) { struct rpki_proto *p = (struct rpki_proto *) P; struct rpki_config *cf = (void *) p->p.cf; struct rpki_cache *cache = p->cache; if (P->proto_state == PS_DOWN) return; if (cache) { const char *transport_name = "---"; switch (cf->tr_config.type) { #if HAVE_LIBSSH case RPKI_TR_SSH: transport_name = "SSHv2"; break; #endif case RPKI_TR_TCP: transport_name = "Unprotected over TCP"; break; }; cli_msg(-1006, " Cache server: %s", cf->hostname); cli_msg(-1006, " Status: %s", rpki_cache_state_to_str(cache->state)); cli_msg(-1006, " Transport: %s", transport_name); cli_msg(-1006, " Protocol version: %u", cache->version); if (cache->request_session_id) cli_msg(-1006, " Session ID: ---"); else cli_msg(-1006, " Session ID: %u", cache->session_id); if (cache->last_update) { cli_msg(-1006, " Serial number: %u", cache->serial_num); cli_msg(-1006, " Last update: before %t s", current_time() - cache->last_update); } else { cli_msg(-1006, " Serial number: ---"); cli_msg(-1006, " Last update: ---"); } rpki_show_proto_info_timer("Refresh timer", cache->refresh_interval, cache->refresh_timer); rpki_show_proto_info_timer("Retry timer", cache->retry_interval, cache->retry_timer); rpki_show_proto_info_timer("Expire timer", cache->expire_interval, cache->expire_timer); if (p->roa4_channel) channel_show_info(p->roa4_channel); else cli_msg(-1006, " No roa4 channel"); if (p->roa6_channel) channel_show_info(p->roa6_channel); else cli_msg(-1006, " No roa6 channel"); } } /* * RPKI Protocol Configuration */ /** * rpki_check_config - check and complete configuration of RPKI protocol * @cf: RPKI configuration * * This function is called at the end of parsing RPKI protocol configuration. */ void rpki_check_config(struct rpki_config *cf) { /* Do not check templates at all */ if (cf->c.class == SYM_TEMPLATE) return; if (ipa_zero(cf->ip) && cf->hostname == NULL) cf_error("IP address or hostname of cache server must be set"); /* Set default transport type */ if (cf->tr_config.spec == NULL) { cf->tr_config.spec = cfg_allocz(sizeof(struct rpki_tr_tcp_config)); cf->tr_config.type = RPKI_TR_TCP; } if (cf->port == 0) { /* Set default port numbers */ switch (cf->tr_config.type) { #if HAVE_LIBSSH case RPKI_TR_SSH: cf->port = RPKI_SSH_PORT; break; #endif default: cf->port = RPKI_TCP_PORT; } } } static void rpki_postconfig(struct proto_config *CF) { /* Define default channel */ if (EMPTY_LIST(CF->channels)) channel_config_new(NULL, net_label[CF->net_type], CF->net_type, CF); } static void rpki_copy_config(struct proto_config *dest UNUSED, struct proto_config *src UNUSED) { /* FIXME: Should copy transport */ } struct protocol proto_rpki = { .name = "RPKI", .template = "rpki%d", .class = PROTOCOL_RPKI, .preference = DEF_PREF_RPKI, .proto_size = sizeof(struct rpki_proto), .config_size = sizeof(struct rpki_config), .init = rpki_init, .start = rpki_start, .postconfig = rpki_postconfig, .channel_mask = (NB_ROA4 | NB_ROA6), .show_proto_info = rpki_show_proto_info, .shutdown = rpki_shutdown, .copy_config = rpki_copy_config, .reconfigure = rpki_reconfigure, .get_status = rpki_get_status, }; bird-2.0.8/proto/rpki/packets.h0000664000175000017500000000231614025744326015301 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_RPKI_PACKETS_H_ #define _BIRD_RPKI_PACKETS_H_ #include #define RPKI_PDU_HEADER_LEN 8 /* A Error PDU size is the biggest (has encapsulate PDU inside): * +8 bytes (Header size) * +4 bytes (Length of Encapsulated PDU) * +32 bytes (Encapsulated PDU IPv6 32) * +4 bytes (Length of inserted text) * +800 bytes (UTF-8 text 400*2 bytes) * ------------ * = 848 bytes (Maximal expected PDU size) */ #define RPKI_PDU_MAX_LEN 848 /* RX buffer size has a great impact to scheduler granularity */ #define RPKI_RX_BUFFER_SIZE 4096 #define RPKI_TX_BUFFER_SIZE RPKI_PDU_MAX_LEN /* Return values */ enum rpki_rtvals { RPKI_SUCCESS = 0, RPKI_ERROR = -1 }; int rpki_send_serial_query(struct rpki_cache *cache); int rpki_send_reset_query(struct rpki_cache *cache); int rpki_rx_hook(sock *sk, uint size); void rpki_connected_hook(sock *sk); void rpki_err_hook(sock *sk, int size); #endif bird-2.0.8/proto/rpki/packets.c0000664000175000017500000007236514025744326015307 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * (c) 2015 Pavel Tvrdik * * This file was a part of RTRlib: http://rpki.realmv6.org/ * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #undef LOCAL_DEBUG #include "rpki.h" #include "transport.h" #include "packets.h" #define RPKI_ADD_FLAG 0b00000001 enum rpki_transmit_type { RPKI_RECV = 0, RPKI_SEND = 1, }; enum pdu_error_type { CORRUPT_DATA = 0, INTERNAL_ERROR = 1, NO_DATA_AVAIL = 2, INVALID_REQUEST = 3, UNSUPPORTED_PROTOCOL_VER = 4, UNSUPPORTED_PDU_TYPE = 5, WITHDRAWAL_OF_UNKNOWN_RECORD = 6, DUPLICATE_ANNOUNCEMENT = 7, PDU_TOO_BIG = 32 }; static const char *str_pdu_error_type[] = { [CORRUPT_DATA] = "Corrupt-Data", [INTERNAL_ERROR] = "Internal-Error", [NO_DATA_AVAIL] = "No-Data-Available", [INVALID_REQUEST] = "Invalid-Request", [UNSUPPORTED_PROTOCOL_VER] = "Unsupported-Protocol-Version", [UNSUPPORTED_PDU_TYPE] = "Unsupported-PDU-Type", [WITHDRAWAL_OF_UNKNOWN_RECORD]= "Withdrawal-Of-Unknown-Record", [DUPLICATE_ANNOUNCEMENT] = "Duplicate-Announcement", [PDU_TOO_BIG] = "PDU-Too-Big", }; enum pdu_type { SERIAL_NOTIFY = 0, SERIAL_QUERY = 1, RESET_QUERY = 2, CACHE_RESPONSE = 3, IPV4_PREFIX = 4, RESERVED = 5, IPV6_PREFIX = 6, END_OF_DATA = 7, CACHE_RESET = 8, ROUTER_KEY = 9, ERROR = 10, PDU_TYPE_MAX }; static const char *str_pdu_type_[] = { [SERIAL_NOTIFY] = "Serial Notify", [SERIAL_QUERY] = "Serial Query", [RESET_QUERY] = "Reset Query", [CACHE_RESPONSE] = "Cache Response", [IPV4_PREFIX] = "IPv4 Prefix", [RESERVED] = "Reserved", [IPV6_PREFIX] = "IPv6 Prefix", [END_OF_DATA] = "End of Data", [CACHE_RESET] = "Cache Reset", [ROUTER_KEY] = "Router Key", [ERROR] = "Error" }; static const char *str_pdu_type(uint type) { if (type < PDU_TYPE_MAX) return str_pdu_type_[type]; else return "Undefined packet type"; } /* * 0 8 16 24 31 * .-------------------------------------------. * | Protocol | PDU | | * | Version | Type | reserved = zero | * | 0 or 1 | 0 - 10 | | * +-------------------------------------------+ * | | * | Length >= 8 | * | | * `-------------------------------------------' */ struct pdu_header { u8 ver; u8 type; u16 reserved; u32 len; } PACKED; struct pdu_cache_response { u8 ver; u8 type; u16 session_id; u32 len; } PACKED; struct pdu_serial_notify { u8 ver; u8 type; u16 session_id; u32 len; u32 serial_num; } PACKED; struct pdu_serial_query { u8 ver; u8 type; u16 session_id; u32 len; u32 serial_num; } PACKED; struct pdu_ipv4 { u8 ver; u8 type; u16 reserved; u32 len; u8 flags; u8 prefix_len; u8 max_prefix_len; u8 zero; ip4_addr prefix; u32 asn; } PACKED; struct pdu_ipv6 { u8 ver; u8 type; u16 reserved; u32 len; u8 flags; u8 prefix_len; u8 max_prefix_len; u8 zero; ip6_addr prefix; u32 asn; } PACKED; /* * 0 8 16 24 31 * .-------------------------------------------. * | Protocol | PDU | | * | Version | Type | Error Code | * | 1 | 10 | | * +-------------------------------------------+ * | | * | Length | * | | * +-------------------------------------------+ * | | * | Length of Encapsulated PDU | * | | * +-------------------------------------------+ * | | * ~ Copy of Erroneous PDU ~ * | | * +-------------------------------------------+ * | | * | Length of Error Text | * | | * +-------------------------------------------+ * | | * | Arbitrary Text | * | of | * ~ Error Diagnostic Message ~ * | | * `-------------------------------------------' */ struct pdu_error { u8 ver; u8 type; u16 error_code; u32 len; u32 len_enc_pdu; /* Length of Encapsulated PDU */ byte rest[]; /* Copy of Erroneous PDU * Length of Error Text * Error Diagnostic Message */ } PACKED; struct pdu_reset_query { u8 ver; u8 type; u16 flags; u32 len; } PACKED; struct pdu_end_of_data_v0 { u8 ver; u8 type; u16 session_id; u32 len; u32 serial_num; } PACKED; struct pdu_end_of_data_v1 { u8 ver; u8 type; u16 session_id; u32 len; u32 serial_num; u32 refresh_interval; u32 retry_interval; u32 expire_interval; } PACKED; static const size_t min_pdu_size[] = { [SERIAL_NOTIFY] = sizeof(struct pdu_serial_notify), [SERIAL_QUERY] = sizeof(struct pdu_serial_query), [RESET_QUERY] = sizeof(struct pdu_reset_query), [CACHE_RESPONSE] = sizeof(struct pdu_cache_response), [IPV4_PREFIX] = sizeof(struct pdu_ipv4), [RESERVED] = sizeof(struct pdu_header), [IPV6_PREFIX] = sizeof(struct pdu_ipv6), [END_OF_DATA] = sizeof(struct pdu_end_of_data_v0), [CACHE_RESET] = sizeof(struct pdu_cache_response), [ROUTER_KEY] = sizeof(struct pdu_header), /* FIXME */ [ERROR] = 16, }; static int rpki_send_error_pdu(struct rpki_cache *cache, const enum pdu_error_type error_code, const u32 err_pdu_len, const struct pdu_header *erroneous_pdu, const char *fmt, ...); static void rpki_pdu_to_network_byte_order(struct pdu_header *pdu) { pdu->reserved = htons(pdu->reserved); pdu->len = htonl(pdu->len); switch (pdu->type) { case SERIAL_QUERY: { /* Note that a session_id is converted using converting header->reserved */ struct pdu_serial_query *sq_pdu = (void *) pdu; sq_pdu->serial_num = htonl(sq_pdu->serial_num); break; } case ERROR: { struct pdu_error *err = (void *) pdu; u32 *err_text_len = (u32 *)(err->rest + err->len_enc_pdu); *err_text_len = htonl(*err_text_len); err->len_enc_pdu = htonl(err->len_enc_pdu); break; } case RESET_QUERY: break; default: bug("PDU type %s should not be sent by us", str_pdu_type(pdu->type)); } } static void rpki_pdu_to_host_byte_order(struct pdu_header *pdu) { /* The Router Key PDU has two one-byte fields instead of one two-bytes field. */ if (pdu->type != ROUTER_KEY) pdu->reserved = ntohs(pdu->reserved); pdu->len = ntohl(pdu->len); switch (pdu->type) { case SERIAL_NOTIFY: { /* Note that a session_id is converted using converting header->reserved */ struct pdu_serial_notify *sn_pdu = (void *) pdu; sn_pdu->serial_num = ntohl(sn_pdu->serial_num); break; } case END_OF_DATA: { /* Note that a session_id is converted using converting header->reserved */ struct pdu_end_of_data_v0 *eod0 = (void *) pdu; eod0->serial_num = ntohl(eod0->serial_num); /* Same either for version 1 */ if (pdu->ver == RPKI_VERSION_1) { struct pdu_end_of_data_v1 *eod1 = (void *) pdu; eod1->expire_interval = ntohl(eod1->expire_interval); eod1->refresh_interval = ntohl(eod1->refresh_interval); eod1->retry_interval = ntohl(eod1->retry_interval); } break; } case IPV4_PREFIX: { struct pdu_ipv4 *ipv4 = (void *) pdu; ipv4->prefix = ip4_ntoh(ipv4->prefix); ipv4->asn = ntohl(ipv4->asn); break; } case IPV6_PREFIX: { struct pdu_ipv6 *ipv6 = (void *) pdu; ipv6->prefix = ip6_ntoh(ipv6->prefix); ipv6->asn = ntohl(ipv6->asn); break; } case ERROR: { /* Note that a error_code is converted using converting header->reserved */ struct pdu_error *err = (void *) pdu; err->len_enc_pdu = ntohl(err->len_enc_pdu); u32 *err_text_len = (u32 *)(err->rest + err->len_enc_pdu); *err_text_len = htonl(*err_text_len); break; } case ROUTER_KEY: /* Router Key PDU is not supported yet */ case SERIAL_QUERY: case RESET_QUERY: /* Serial/Reset Query are sent only in direction router to cache. * We don't care here. */ case CACHE_RESPONSE: case CACHE_RESET: /* Converted with pdu->reserved */ break; } } /** * rpki_convert_pdu_back_to_network_byte_order - convert host-byte order PDU back to network-byte order * @out: allocated memory for writing a converted PDU of size @in->len * @in: host-byte order PDU * * Assumed: |A == ntoh(ntoh(A))| */ static struct pdu_header * rpki_pdu_back_to_network_byte_order(struct pdu_header *out, const struct pdu_header *in) { memcpy(out, in, in->len); rpki_pdu_to_host_byte_order(out); return out; } static void rpki_log_packet(struct rpki_cache *cache, const struct pdu_header *pdu, const enum rpki_transmit_type action) { if (!(cache->p->p.debug & D_PACKETS)) return; const char *str_type = str_pdu_type(pdu->type); char detail[256]; #define SAVE(fn) \ do { \ if (fn < 0) \ { \ bsnprintf(detail + sizeof(detail) - 16, 16, "... )"); \ goto detail_finished; \ } \ } while(0) \ switch (pdu->type) { case SERIAL_NOTIFY: case SERIAL_QUERY: SAVE(bsnprintf(detail, sizeof(detail), "(session id: %u, serial number: %u)", pdu->reserved, ((struct pdu_serial_notify *) pdu)->serial_num)); break; case END_OF_DATA: { const struct pdu_end_of_data_v1 *eod = (void *) pdu; if (eod->ver == RPKI_VERSION_1) SAVE(bsnprintf(detail, sizeof(detail), "(session id: %u, serial number: %u, refresh: %us, retry: %us, expire: %us)", eod->session_id, eod->serial_num, eod->refresh_interval, eod->retry_interval, eod->expire_interval)); else SAVE(bsnprintf(detail, sizeof(detail), "(session id: %u, serial number: %u)", eod->session_id, eod->serial_num)); break; } case CACHE_RESPONSE: SAVE(bsnprintf(detail, sizeof(detail), "(session id: %u)", pdu->reserved)); break; case IPV4_PREFIX: { const struct pdu_ipv4 *ipv4 = (void *) pdu; SAVE(bsnprintf(detail, sizeof(detail), "(%I4/%u-%u AS%u)", ipv4->prefix, ipv4->prefix_len, ipv4->max_prefix_len, ipv4->asn)); break; } case IPV6_PREFIX: { const struct pdu_ipv6 *ipv6 = (void *) pdu; SAVE(bsnprintf(detail, sizeof(detail), "(%I6/%u-%u AS%u)", ipv6->prefix, ipv6->prefix_len, ipv6->max_prefix_len, ipv6->asn)); break; } case ROUTER_KEY: /* We don't support saving Router Key PDUs yet */ SAVE(bsnprintf(detail, sizeof(detail), "(ignored)")); break; case ERROR: { const struct pdu_error *err = (void *) pdu; SAVE(bsnprintf(detail, sizeof(detail), "(%s", str_pdu_error_type[err->error_code])); /* Optional description of error */ const u32 len_err_txt = *((u32 *) (err->rest + err->len_enc_pdu)); if (len_err_txt > 0) { size_t expected_len = err->len_enc_pdu + len_err_txt + 16; if (expected_len == err->len) { char txt[len_err_txt + 1]; char *pdu_txt = (char *) err->rest + err->len_enc_pdu + 4; bsnprintf(txt, sizeof(txt), "%s", pdu_txt); /* it's ensured that txt is ended with a null byte */ SAVE(bsnprintf(detail + strlen(detail), sizeof(detail) - strlen(detail), ": '%s'", txt)); } else { SAVE(bsnprintf(detail + strlen(detail), sizeof(detail) - strlen(detail), ", malformed size")); } } /* Optional encapsulated erroneous packet */ if (err->len_enc_pdu) { SAVE(bsnprintf(detail + strlen(detail), sizeof(detail) - strlen(detail), ", %s packet:", str_pdu_type(((struct pdu_header *) err->rest)->type))); if (err->rest + err->len_enc_pdu <= (byte *)err + err->len) { for (const byte *c = err->rest; c != err->rest + err->len_enc_pdu; c++) SAVE(bsnprintf(detail + strlen(detail), sizeof(detail) - strlen(detail), " %02X", *c)); } } SAVE(bsnprintf(detail + strlen(detail), sizeof(detail) - strlen(detail), ")")); break; } default: *detail = '\0'; } #undef SAVE detail_finished: if (action == RPKI_RECV) { CACHE_TRACE(D_PACKETS, cache, "Received %s packet %s", str_type, detail); } else { CACHE_TRACE(D_PACKETS, cache, "Sending %s packet %s", str_type, detail); } #if defined(LOCAL_DEBUG) || defined(GLOBAL_DEBUG) int seq = 0; for(const byte *c = pdu; c != pdu + pdu->len; c++) { if ((seq % 4) == 0) DBG("%2d: ", seq); DBG(" 0x%02X %-3u", *c, *c); if ((++seq % 4) == 0) DBG("\n"); } if ((seq % 4) != 0) DBG("\n"); #endif } static int rpki_send_pdu(struct rpki_cache *cache, const void *pdu, const uint len) { struct rpki_proto *p = cache->p; sock *sk = cache->tr_sock->sk; rpki_log_packet(cache, pdu, RPKI_SEND); if (sk->tbuf != sk->tpos) { RPKI_WARN(p, "Old packet overwritten in TX buffer"); } if (len > sk->tbsize) { RPKI_WARN(p, "%u bytes is too much for send", len); ASSERT(0); return RPKI_ERROR; } memcpy(sk->tbuf, pdu, len); rpki_pdu_to_network_byte_order((void *) sk->tbuf); if (!sk_send(sk, len)) { DBG("Cannot send just the whole data. It will be sent using a call of tx_hook()"); } return RPKI_SUCCESS; } /** * rpki_check_receive_packet - make a basic validation of received RPKI PDU header * @cache: cache connection instance * @pdu: RPKI PDU in network byte order * * This function checks protocol version, PDU type, version and size. If all is all right then * function returns |RPKI_SUCCESS| otherwise sends Error PDU and returns * |RPKI_ERROR|. */ static int rpki_check_receive_packet(struct rpki_cache *cache, const struct pdu_header *pdu) { u32 pdu_len = ntohl(pdu->len); /* * Minimal and maximal allowed PDU size is treated in rpki_rx_hook() function. * @header.len corresponds to number of bytes of @pdu and * it is in range from RPKI_PDU_HEADER_LEN to RPKI_PDU_MAX_LEN bytes. */ /* Do not handle error PDUs here, leave this task to rpki_handle_error_pdu() */ if (pdu->ver != cache->version && pdu->type != ERROR) { /* If this is the first PDU we have received */ if (cache->request_session_id) { if (pdu->type == SERIAL_NOTIFY) { /* * The router MUST ignore any Serial Notify PDUs it might receive from * the cache during this initial start-up period, regardless of the * Protocol Version field in the Serial Notify PDU. * (https://tools.ietf.org/html/draft-ietf-sidr-rpki-rtr-rfc6810-bis-07#section-7) */ } else if (!cache->last_update && (pdu->ver <= RPKI_MAX_VERSION) && (pdu->ver < cache->version)) { CACHE_TRACE(D_EVENTS, cache, "Downgrade session to %s from %u to %u version", rpki_get_cache_ident(cache), cache->version, pdu->ver); cache->version = pdu->ver; } else { /* If this is not the first PDU we have received, something is wrong with * the server implementation -> Error */ rpki_send_error_pdu(cache, UNSUPPORTED_PROTOCOL_VER, pdu_len, pdu, "PDU with unsupported Protocol version received"); return RPKI_ERROR; } } } if ((pdu->type >= PDU_TYPE_MAX) || (pdu->ver == RPKI_VERSION_0 && pdu->type == ROUTER_KEY)) { rpki_send_error_pdu(cache, UNSUPPORTED_PDU_TYPE, pdu_len, pdu, "Unsupported PDU type %u received", pdu->type); return RPKI_ERROR; } if (pdu_len < min_pdu_size[pdu->type]) { rpki_send_error_pdu(cache, CORRUPT_DATA, pdu_len, pdu, "Received %s packet with %d bytes, but expected at least %d bytes", str_pdu_type(pdu->type), pdu_len, min_pdu_size[pdu->type]); return RPKI_ERROR; } return RPKI_SUCCESS; } static int rpki_handle_error_pdu(struct rpki_cache *cache, const struct pdu_error *pdu) { switch (pdu->error_code) { case CORRUPT_DATA: case INTERNAL_ERROR: case INVALID_REQUEST: case UNSUPPORTED_PDU_TYPE: rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); break; case NO_DATA_AVAIL: rpki_cache_change_state(cache, RPKI_CS_ERROR_NO_DATA_AVAIL); break; case UNSUPPORTED_PROTOCOL_VER: CACHE_TRACE(D_PACKETS, cache, "Client uses unsupported protocol version"); if (pdu->ver <= RPKI_MAX_VERSION && pdu->ver < cache->version) { CACHE_TRACE(D_EVENTS, cache, "Downgrading from protocol version %d to version %d", cache->version, pdu->ver); cache->version = pdu->ver; rpki_cache_change_state(cache, RPKI_CS_FAST_RECONNECT); } else { CACHE_TRACE(D_PACKETS, cache, "Got UNSUPPORTED_PROTOCOL_VER error PDU with invalid values, " \ "current version: %d, PDU version: %d", cache->version, pdu->ver); rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); } break; default: CACHE_TRACE(D_PACKETS, cache, "Error unknown, server sent unsupported error code %u", pdu->error_code); rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); break; } return RPKI_SUCCESS; } static void rpki_handle_serial_notify_pdu(struct rpki_cache *cache, const struct pdu_serial_notify *pdu) { /* The router MUST ignore any Serial Notify PDUs it might receive from * the cache during this initial start-up period, regardless of the * Protocol Version field in the Serial Notify PDU. * (https://tools.ietf.org/html/draft-ietf-sidr-rpki-rtr-rfc6810-bis-07#section-7) */ if (cache->request_session_id) { CACHE_TRACE(D_PACKETS, cache, "Ignore a Serial Notify packet during initial start-up period"); return; } /* XXX Serial number should be compared using method RFC 1982 (3.2) */ if (cache->serial_num != pdu->serial_num) rpki_cache_change_state(cache, RPKI_CS_SYNC_START); } static int rpki_handle_cache_response_pdu(struct rpki_cache *cache, const struct pdu_cache_response *pdu) { if (cache->request_session_id) { if (cache->last_update) { /* * This isn't the first sync and we already received records. This point * is after Reset Query and before importing new records from cache * server. We need to load new ones and kick out missing ones. So start * a refresh cycle. */ if (cache->p->roa4_channel) rt_refresh_begin(cache->p->roa4_channel->table, cache->p->roa4_channel); if (cache->p->roa6_channel) rt_refresh_begin(cache->p->roa6_channel->table, cache->p->roa6_channel); cache->p->refresh_channels = 1; } cache->session_id = pdu->session_id; cache->request_session_id = 0; } else { if (cache->session_id != pdu->session_id) { byte tmp[pdu->len]; const struct pdu_header *hton_pdu = rpki_pdu_back_to_network_byte_order((void *) tmp, (const void *) pdu); rpki_send_error_pdu(cache, CORRUPT_DATA, pdu->len, hton_pdu, "Wrong session_id %u in Cache Response PDU", pdu->session_id); rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); return RPKI_ERROR; } } rpki_cache_change_state(cache, RPKI_CS_SYNC_RUNNING); return RPKI_SUCCESS; } /** * rpki_prefix_pdu_2_net_addr - convert IPv4/IPv6 Prefix PDU into net_addr_union * @pdu: host byte order IPv4/IPv6 Prefix PDU * @n: allocated net_addr_union for save ROA * * This function reads ROA data from IPv4/IPv6 Prefix PDU and * write them into net_addr_roa4 or net_addr_roa6 data structure. */ static net_addr_union * rpki_prefix_pdu_2_net_addr(const struct pdu_header *pdu, net_addr_union *n) { /* * Note that sizeof(net_addr_roa6) > sizeof(net_addr) * and thence we must use net_addr_union and not only net_addr */ if (pdu->type == IPV4_PREFIX) { const struct pdu_ipv4 *ipv4 = (void *) pdu; n->roa4.type = NET_ROA4; n->roa4.length = sizeof(net_addr_roa4); n->roa4.prefix = ipv4->prefix; n->roa4.asn = ipv4->asn; n->roa4.pxlen = ipv4->prefix_len; n->roa4.max_pxlen = ipv4->max_prefix_len; } else { const struct pdu_ipv6 *ipv6 = (void *) pdu; n->roa6.type = NET_ROA6; n->roa6.length = sizeof(net_addr_roa6); n->roa6.prefix = ipv6->prefix; n->roa6.asn = ipv6->asn; n->roa6.pxlen = ipv6->prefix_len; n->roa6.max_pxlen = ipv6->max_prefix_len; } return n; } static int rpki_handle_prefix_pdu(struct rpki_cache *cache, const struct pdu_header *pdu) { const struct rpki_config *cf = (void *) cache->p->p.cf; const enum pdu_type type = pdu->type; ASSERT(type == IPV4_PREFIX || type == IPV6_PREFIX); net_addr_union addr = {}; rpki_prefix_pdu_2_net_addr(pdu, &addr); if (cf->ignore_max_length) { if (type == IPV4_PREFIX) addr.roa4.max_pxlen = IP4_MAX_PREFIX_LENGTH; else addr.roa6.max_pxlen = IP6_MAX_PREFIX_LENGTH; } struct channel *channel = NULL; if (type == IPV4_PREFIX) channel = cache->p->roa4_channel; if (type == IPV6_PREFIX) channel = cache->p->roa6_channel; if (!channel) { CACHE_TRACE(D_ROUTES, cache, "Skip %N, missing %s channel", &addr, (type == IPV4_PREFIX ? "roa4" : "roa6"), addr); return RPKI_ERROR; } cache->last_rx_prefix = current_time(); /* A place for 'flags' is same for both data structures pdu_ipv4 or pdu_ipv6 */ struct pdu_ipv4 *pfx = (void *) pdu; if (pfx->flags & RPKI_ADD_FLAG) rpki_table_add_roa(cache, channel, &addr); else rpki_table_remove_roa(cache, channel, &addr); return RPKI_SUCCESS; } static uint rpki_check_interval(struct rpki_cache *cache, const char *(check_fn)(uint), uint interval) { if (check_fn(interval)) { RPKI_WARN(cache->p, "%s, received %u seconds", check_fn(interval), interval); return 0; } return 1; } static void rpki_handle_end_of_data_pdu(struct rpki_cache *cache, const struct pdu_end_of_data_v1 *pdu) { const struct rpki_config *cf = (void *) cache->p->p.cf; if (pdu->session_id != cache->session_id) { byte tmp[pdu->len]; const struct pdu_header *hton_pdu = rpki_pdu_back_to_network_byte_order((void *) tmp, (const void *) pdu); rpki_send_error_pdu(cache, CORRUPT_DATA, pdu->len, hton_pdu, "Received Session ID %u, but expected %u", pdu->session_id, cache->session_id); rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); return; } if (pdu->ver == RPKI_VERSION_1) { if (!cf->keep_refresh_interval && rpki_check_interval(cache, rpki_check_refresh_interval, pdu->refresh_interval)) cache->refresh_interval = pdu->refresh_interval; if (!cf->keep_retry_interval && rpki_check_interval(cache, rpki_check_retry_interval, pdu->retry_interval)) cache->retry_interval = pdu->retry_interval; if (!cf->keep_expire_interval && rpki_check_interval(cache, rpki_check_expire_interval, pdu->expire_interval)) cache->expire_interval = pdu->expire_interval; CACHE_TRACE(D_EVENTS, cache, "New interval values: " "refresh: %s%us, " "retry: %s%us, " "expire: %s%us", (cf->keep_refresh_interval ? "keeps " : ""), cache->refresh_interval, (cf->keep_retry_interval ? "keeps " : ""), cache->retry_interval, (cf->keep_expire_interval ? "keeps " : ""), cache->expire_interval); } if (cache->p->refresh_channels) { cache->p->refresh_channels = 0; if (cache->p->roa4_channel) rt_refresh_end(cache->p->roa4_channel->table, cache->p->roa4_channel); if (cache->p->roa6_channel) rt_refresh_end(cache->p->roa6_channel->table, cache->p->roa6_channel); } cache->last_update = current_time(); cache->serial_num = pdu->serial_num; rpki_cache_change_state(cache, RPKI_CS_ESTABLISHED); } /** * rpki_rx_packet - process a received RPKI PDU * @cache: RPKI connection instance * @pdu: a RPKI PDU in network byte order */ static void rpki_rx_packet(struct rpki_cache *cache, struct pdu_header *pdu) { struct rpki_proto *p = cache->p; if (rpki_check_receive_packet(cache, pdu) == RPKI_ERROR) { rpki_cache_change_state(cache, RPKI_CS_ERROR_FATAL); return; } rpki_pdu_to_host_byte_order(pdu); rpki_log_packet(cache, pdu, RPKI_RECV); switch (pdu->type) { case RESET_QUERY: case SERIAL_QUERY: RPKI_WARN(p, "Received a %s packet that is destined for cache server", str_pdu_type(pdu->type)); break; case SERIAL_NOTIFY: /* This is a signal to synchronize with the cache server just now */ rpki_handle_serial_notify_pdu(cache, (void *) pdu); break; case CACHE_RESPONSE: rpki_handle_cache_response_pdu(cache, (void *) pdu); break; case IPV4_PREFIX: case IPV6_PREFIX: rpki_handle_prefix_pdu(cache, pdu); break; case END_OF_DATA: rpki_handle_end_of_data_pdu(cache, (void *) pdu); break; case CACHE_RESET: /* Cache cannot provide an incremental update. */ rpki_cache_change_state(cache, RPKI_CS_NO_INCR_UPDATE_AVAIL); break; case ERROR: rpki_handle_error_pdu(cache, (void *) pdu); break; case ROUTER_KEY: /* TODO: Implement Router Key PDU handling */ break; default: CACHE_TRACE(D_PACKETS, cache, "Received unsupported type (%u)", pdu->type); }; } int rpki_rx_hook(struct birdsock *sk, uint size) { struct rpki_cache *cache = sk->data; struct rpki_proto *p = cache->p; byte *pkt_start = sk->rbuf; byte *end = pkt_start + size; DBG("rx hook got %u bytes \n", size); while (end >= pkt_start + RPKI_PDU_HEADER_LEN) { struct pdu_header *pdu = (void *) pkt_start; u32 pdu_size = ntohl(pdu->len); if (pdu_size < RPKI_PDU_HEADER_LEN || pdu_size > RPKI_PDU_MAX_LEN) { RPKI_WARN(p, "Received invalid packet length %u, purge the whole receiving buffer", pdu_size); return 1; /* Purge recv buffer */ } if (end < pkt_start + pdu_size) break; rpki_rx_packet(cache, pdu); /* It is possible that bird socket was freed/closed */ if (p->p.proto_state == PS_DOWN || sk != cache->tr_sock->sk) return 0; pkt_start += pdu_size; } if (pkt_start != sk->rbuf) { CACHE_DBG(cache, "Move %u bytes of a memory at the start of buffer", end - pkt_start); memmove(sk->rbuf, pkt_start, end - pkt_start); sk->rpos = sk->rbuf + (end - pkt_start); } return 0; /* Not purge sk->rbuf */ } void rpki_err_hook(struct birdsock *sk, int error_num) { struct rpki_cache *cache = sk->data; if (error_num) { /* sk->err may contains a SSH error description */ if (sk->err) CACHE_TRACE(D_EVENTS, cache, "Lost connection: %s", sk->err); else CACHE_TRACE(D_EVENTS, cache, "Lost connection: %M", error_num); } else { CACHE_TRACE(D_EVENTS, cache, "The other side closed a connection"); } rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); } static int rpki_fire_tx(struct rpki_cache *cache) { sock *sk = cache->tr_sock->sk; uint bytes_to_send = sk->tpos - sk->tbuf; DBG("Sending %u bytes", bytes_to_send); return sk_send(sk, bytes_to_send); } void rpki_tx_hook(sock *sk) { struct rpki_cache *cache = sk->data; while (rpki_fire_tx(cache) > 0) ; } void rpki_connected_hook(sock *sk) { struct rpki_cache *cache = sk->data; CACHE_TRACE(D_EVENTS, cache, "Connected"); proto_notify_state(&cache->p->p, PS_UP); sk->rx_hook = rpki_rx_hook; sk->tx_hook = rpki_tx_hook; rpki_cache_change_state(cache, RPKI_CS_SYNC_START); } /** * rpki_send_error_pdu - send RPKI Error PDU * @cache: RPKI connection instance * @error_code: PDU Error type * @err_pdu_len: length of @erroneous_pdu * @erroneous_pdu: optional network byte-order PDU that invokes Error by us or NULL * @fmt: optional description text of error or NULL * @args: optional arguments for @fmt * * This function prepares Error PDU and sends it to a cache server. */ static int rpki_send_error_pdu(struct rpki_cache *cache, const enum pdu_error_type error_code, const u32 err_pdu_len, const struct pdu_header *erroneous_pdu, const char *fmt, ...) { va_list args; char msg[128]; /* Size including the terminating null byte ('\0') */ int msg_len = 0; /* Don't send errors for erroneous error PDUs */ if (err_pdu_len >= 2) { if (erroneous_pdu->type == ERROR) return RPKI_SUCCESS; } if (fmt) { va_start(args, fmt); msg_len = bvsnprintf(msg, sizeof(msg), fmt, args) + 1; va_end(args); } u32 pdu_size = 16 + err_pdu_len + msg_len; byte pdu[pdu_size]; memset(pdu, 0, sizeof(pdu)); struct pdu_error *e = (void *) pdu; e->ver = cache->version; e->type = ERROR; e->error_code = error_code; e->len = pdu_size; e->len_enc_pdu = err_pdu_len; if (err_pdu_len > 0) memcpy(e->rest, erroneous_pdu, err_pdu_len); *((u32 *)(e->rest + err_pdu_len)) = msg_len; if (msg_len > 0) memcpy(e->rest + err_pdu_len + 4, msg, msg_len); return rpki_send_pdu(cache, pdu, pdu_size); } int rpki_send_serial_query(struct rpki_cache *cache) { struct pdu_serial_query pdu = { .ver = cache->version, .type = SERIAL_QUERY, .session_id = cache->session_id, .len = sizeof(pdu), .serial_num = cache->serial_num }; if (rpki_send_pdu(cache, &pdu, sizeof(pdu)) != RPKI_SUCCESS) { rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); return RPKI_ERROR; } return RPKI_SUCCESS; } int rpki_send_reset_query(struct rpki_cache *cache) { struct pdu_reset_query pdu = { .ver = cache->version, .type = RESET_QUERY, .len = sizeof(pdu), }; if (rpki_send_pdu(cache, &pdu, sizeof(pdu)) != RPKI_SUCCESS) { rpki_cache_change_state(cache, RPKI_CS_ERROR_TRANSPORT); return RPKI_ERROR; } return RPKI_SUCCESS; } bird-2.0.8/proto/rpki/config.Y0000664000175000017500000000716514025744326015104 0ustar feelafeela/* * BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol * * (c) 2015 CZ.NIC * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "proto/rpki/rpki.h" CF_DEFINES #define RPKI_CFG ((struct rpki_config *) this_proto) #define RPKI_TR_SSH_CFG ((struct rpki_tr_ssh_config *) RPKI_CFG->tr_config.spec) static void rpki_check_unused_hostname(void) { if (RPKI_CFG->hostname != NULL) cf_error("Only one cache server per protocol allowed"); } static void rpki_check_unused_transport(void) { if (RPKI_CFG->tr_config.spec != NULL) cf_error("At the most one transport per protocol allowed"); } CF_DECLS CF_KEYWORDS(RPKI, REMOTE, BIRD, PRIVATE, PUBLIC, KEY, TCP, SSH, TRANSPORT, USER, RETRY, REFRESH, EXPIRE, KEEP, IGNORE, MAX, LENGTH) %type rpki_keep_interval CF_GRAMMAR proto: rpki_proto ; rpki_proto_start: proto_start RPKI { this_proto = proto_config_new(&proto_rpki, $1); RPKI_CFG->retry_interval = RPKI_RETRY_INTERVAL; RPKI_CFG->refresh_interval = RPKI_REFRESH_INTERVAL; RPKI_CFG->expire_interval = RPKI_EXPIRE_INTERVAL; }; rpki_proto: rpki_proto_start proto_name '{' rpki_proto_opts '}' { rpki_check_config(RPKI_CFG); }; rpki_proto_opts: /* empty */ | rpki_proto_opts rpki_proto_item ';' ; rpki_proto_item: proto_item | proto_channel | REMOTE rpki_cache_addr | REMOTE rpki_cache_addr rpki_proto_item_port | rpki_proto_item_port | TRANSPORT rpki_transport | REFRESH rpki_keep_interval expr { if (rpki_check_refresh_interval($3)) cf_error(rpki_check_refresh_interval($3)); RPKI_CFG->refresh_interval = $3; RPKI_CFG->keep_refresh_interval = $2; } | RETRY rpki_keep_interval expr { if (rpki_check_retry_interval($3)) cf_error(rpki_check_retry_interval($3)); RPKI_CFG->retry_interval = $3; RPKI_CFG->keep_retry_interval = $2; } | EXPIRE rpki_keep_interval expr { if (rpki_check_expire_interval($3)) cf_error(rpki_check_expire_interval($3)); RPKI_CFG->expire_interval = $3; RPKI_CFG->keep_expire_interval = $2; } | IGNORE MAX LENGTH bool { RPKI_CFG->ignore_max_length = $4; } ; rpki_keep_interval: /* empty */ { $$ = 0; } | KEEP { $$ = 1; } ; rpki_proto_item_port: PORT expr { check_u16($2); RPKI_CFG->port = $2; }; rpki_cache_addr: text { rpki_check_unused_hostname(); RPKI_CFG->hostname = $1; } | ipa { rpki_check_unused_hostname(); RPKI_CFG->ip = $1; /* Ensure hostname is filled */ char *hostname = cfg_allocz(INET6_ADDRSTRLEN + 1); bsnprintf(hostname, INET6_ADDRSTRLEN+1, "%I", RPKI_CFG->ip); RPKI_CFG->hostname = hostname; } ; rpki_transport: TCP rpki_transport_tcp_init | SSH rpki_transport_ssh_init '{' rpki_transport_ssh_opts '}' rpki_transport_ssh_check ; rpki_transport_tcp_init: { rpki_check_unused_transport(); RPKI_CFG->tr_config.spec = cfg_allocz(sizeof(struct rpki_tr_tcp_config)); RPKI_CFG->tr_config.type = RPKI_TR_TCP; }; rpki_transport_ssh_init: { #if HAVE_LIBSSH rpki_check_unused_transport(); RPKI_CFG->tr_config.spec = cfg_allocz(sizeof(struct rpki_tr_ssh_config)); RPKI_CFG->tr_config.type = RPKI_TR_SSH; #else cf_error("This build doesn't support SSH"); #endif }; rpki_transport_ssh_opts: /* empty */ | rpki_transport_ssh_opts rpki_transport_ssh_item ';' ; rpki_transport_ssh_item: BIRD PRIVATE KEY text { RPKI_TR_SSH_CFG->bird_private_key = $4; } | REMOTE PUBLIC KEY text { RPKI_TR_SSH_CFG->cache_public_key = $4; } | USER text { RPKI_TR_SSH_CFG->user = $2; } ; rpki_transport_ssh_check: { if (RPKI_TR_SSH_CFG->user == NULL) cf_error("User must be set"); }; CF_CODE CF_END bird-2.0.8/proto/rpki/Makefile0000664000175000017500000000023714025744326015136 0ustar feelafeelasrc := rpki.c packets.c tcp_transport.c ssh_transport.c transport.c obj := $(src-o-files) $(all-daemon) $(cf-local) tests_objs := $(tests_objs) $(src-o-files)bird-2.0.8/proto/rpki/Doc0000664000175000017500000000010714025744326014122 0ustar feelafeelaS rpki.c S packets.c S transport.c S tcp_transport.c S ssh_transport.c bird-2.0.8/proto/rip/0000775000175000017500000000000014025744326013321 5ustar feelafeelabird-2.0.8/proto/rip/rip.h0000664000175000017500000001751014025744326014270 0ustar feelafeela/* * BIRD -- Routing Information Protocol (RIP) * * (c) 1998--1999 Pavel Machek * (c) 2004--2013 Ondrej Filip * (c) 2009--2015 Ondrej Zajicek * (c) 2009--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_RIP_H_ #define _BIRD_RIP_H_ #include "nest/bird.h" #include "nest/cli.h" #include "nest/iface.h" #include "nest/protocol.h" #include "nest/route.h" #include "nest/password.h" #include "nest/locks.h" #include "nest/bfd.h" #include "lib/lists.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/string.h" #include "lib/timer.h" #define RIP_V1 1 #define RIP_V2 2 #define RIP_PORT 520 /* RIP for IPv4 */ #define RIP_NG_PORT 521 /* RIPng */ #define RIP_MAX_PKT_LENGTH 532 /* 512 + IP4_HEADER_LENGTH */ #define RIP_AUTH_TAIL_LENGTH 4 /* Without auth_data */ #define RIP_DEFAULT_ECMP_LIMIT 16 #define RIP_DEFAULT_INFINITY 16 #define RIP_DEFAULT_UPDATE_TIME (30 S_) #define RIP_DEFAULT_TIMEOUT_TIME (180 S_) #define RIP_DEFAULT_GARBAGE_TIME (120 S_) #define RIP_DEFAULT_RXMT_TIME (1 S_) struct rip_config { struct proto_config c; list patt_list; /* List of iface configs (struct rip_iface_config) */ u8 rip2; /* RIPv2 (IPv4) or RIPng (IPv6) */ u8 ecmp; /* Maximum number of nexthops in ECMP route, or 0 */ u8 infinity; /* Maximum metric value, representing infinity */ btime min_timeout_time; /* Minimum of interface timeout_time */ btime max_garbage_time; /* Maximum of interface garbage_time */ }; struct rip_iface_config { struct iface_patt i; ip_addr address; /* Configured dst address */ u16 port; /* Src+dst port */ u8 metric; /* Incoming metric */ u8 mode; /* Interface mode (RIP_IM_*) */ u8 passive; /* Passive iface - no packets are sent */ u8 version; /* RIP version used for outgoing packets */ u8 version_only; /* FIXXX */ u8 split_horizon; /* Split horizon is used in route updates */ u8 poison_reverse; /* Poisoned reverse is used in route updates */ u8 check_zero; /* Validation of RIPv1 reserved fields */ u8 ecmp_weight; /* Weight for ECMP routes*/ u8 auth_type; /* Authentication type (RIP_AUTH_*) */ u8 ttl_security; /* bool + 2 for TX only (send, but do not check on RX) */ u8 check_link; /* Whether iface link change is used */ u8 demand_circuit; /* Use demand circuit extensions (RFC 2091) */ u8 bfd; /* Use BFD on iface */ u16 rx_buffer; /* RX buffer size, 0 for MTU */ u16 tx_length; /* TX packet length limit (including headers), 0 for MTU */ int tx_tos; int tx_priority; btime update_time; /* Periodic update interval */ btime timeout_time; /* Route expiration timeout */ btime garbage_time; /* Unreachable entry GC timeout */ btime rxmt_time; /* Retransmit timeout for demand circuit */ list *passwords; /* Passwords for authentication */ }; struct rip_proto { struct proto p; struct fib rtable; /* Internal routing table */ list iface_list; /* List of interfaces (struct rip_iface) */ slab *rte_slab; /* Slab for internal routes (struct rip_rte) */ timer *timer; /* Main protocol timer */ u8 rip2; /* RIPv2 (IPv4) or RIPng (IPv6) */ u8 ecmp; /* Maximum number of nexthops in ECMP route, or 0 */ u8 infinity; /* Maximum metric value, representing infinity */ u8 triggered; /* Logical AND of interface want_triggered values */ u8 rt_reload; /* Route reload is scheduled */ struct tbf log_pkt_tbf; /* TBF for packet messages */ struct tbf log_rte_tbf; /* TBF for RTE messages */ }; struct rip_iface { node n; struct rip_proto *rip; struct iface *iface; /* Underyling core interface */ struct rip_iface_config *cf; /* Related config, must be updated in reconfigure */ struct object_lock *lock; /* Interface lock */ timer *timer; /* Interface timer */ timer *rxmt_timer; /* Retransmission timer */ sock *sk; /* UDP socket */ u8 up; /* Interface is active */ u8 csn_ready; /* Nonzero CSN can be used */ u16 tx_plen; /* Max TX packet data length */ u32 csn; /* Last used crypto sequence number */ ip_addr addr; /* Destination multicast/broadcast address */ list neigh_list; /* List of iface neighbors (struct rip_neighbor) */ /* Update scheduling */ btime next_regular; /* Next time when regular update should be called */ btime next_triggered; /* Next time when triggerd update may be called */ btime want_triggered; /* Nonzero if triggered update is scheduled */ /* Active update */ int tx_active; /* Update session is active */ int tx_waiting; ip_addr tx_addr; /* Update session destination address */ btime tx_changed; /* Minimal changed time for triggered update */ struct fib_iterator tx_fit; /* FIB iterator in RIP routing table (p.rtable) */ struct fib_iterator tx_done; /* FIB iterator for acked routes (p.rtable) */ /* Update message */ u8 tx_pending; u8 tx_flush; u16 tx_seqnum; u8 req_pending; }; struct rip_neighbor { node n; struct rip_iface *ifa; /* Associated interface, may be NULL if stale */ struct neighbor *nbr; /* Associaded core neighbor, may be NULL if stale */ struct bfd_request *bfd_req; /* BFD request, if BFD is used */ btime last_seen; /* Time of last received and accepted message */ u32 uc; /* Use count, number of routes linking the neighbor */ u32 csn; /* Last received crypto sequence number */ }; struct rip_entry { struct rip_rte *routes; /* List of incoming routes */ u8 valid; /* Entry validity state (RIP_ENTRY_*) */ u8 metric; /* Outgoing route metric */ u16 tag; /* Outgoing route tag */ struct iface *from; /* Outgoing route from, NULL if from proto */ struct iface *iface; /* Outgoing route iface (for next hop) */ ip_addr next_hop; /* Outgoing route next hop */ btime changed; /* Last time when the outgoing route metric changed */ struct fib_node n; }; struct rip_rte { struct rip_rte *next; struct rip_neighbor *from; /* Advertising router */ ip_addr next_hop; /* Route next hop (iface is from->nbr->iface) */ u16 metric; /* Route metric (after increase) */ u16 tag; /* Route tag */ btime expires; /* Time of route expiration */ }; #define RIP_AUTH_NONE 0 #define RIP_AUTH_PLAIN 2 #define RIP_AUTH_CRYPTO 3 #define RIP_IM_MULTICAST 1 #define RIP_IM_BROADCAST 2 #define RIP_ENTRY_DUMMY 0 /* Only used to store list of incoming routes */ #define RIP_ENTRY_VALID 1 /* Valid outgoing route */ #define RIP_ENTRY_STALE 2 /* Stale outgoing route, waiting for GC */ #define EA_RIP_METRIC EA_CODE(PROTOCOL_RIP, 0) #define EA_RIP_TAG EA_CODE(PROTOCOL_RIP, 1) static inline int rip_is_v2(struct rip_proto *p) { return p->rip2; } static inline int rip_is_ng(struct rip_proto *p) { return ! p->rip2; } static inline void rip_reset_tx_session(struct rip_proto *p, struct rip_iface *ifa) { if (ifa->tx_active) { FIB_ITERATE_UNLINK(&ifa->tx_fit, &p->rtable); FIB_ITERATE_UNLINK(&ifa->tx_done, &p->rtable); ifa->tx_active = 0; } } /* rip.c */ void rip_update_rte(struct rip_proto *p, net_addr *n, struct rip_rte *new); void rip_withdraw_rte(struct rip_proto *p, net_addr *n, struct rip_neighbor *from); void rip_flush_table(struct rip_proto *p, struct rip_neighbor *n); struct rip_neighbor * rip_get_neighbor(struct rip_proto *p, ip_addr *a, struct rip_iface *ifa); void rip_update_bfd(struct rip_proto *p, struct rip_neighbor *n); void rip_show_interfaces(struct proto *P, const char *iff); void rip_show_neighbors(struct proto *P, const char *iff); /* packets.c */ void rip_send_request(struct rip_proto *p, struct rip_iface *ifa); void rip_send_table(struct rip_proto *p, struct rip_iface *ifa, ip_addr addr, btime changed); int rip_send_flush(struct rip_proto *p, struct rip_iface *ifa); void rip_rxmt_timeout(timer *t); int rip_open_socket(struct rip_iface *ifa); #endif bird-2.0.8/proto/rip/rip.c0000664000175000017500000010237614025744326014270 0ustar feelafeela/* * BIRD -- Routing Information Protocol (RIP) * * (c) 1998--1999 Pavel Machek * (c) 2004--2013 Ondrej Filip * (c) 2009--2015 Ondrej Zajicek * (c) 2009--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Routing Information Protocol (RIP) * * The RIP protocol is implemented in two files: |rip.c| containing the protocol * logic, route management and the protocol glue with BIRD core, and |packets.c| * handling RIP packet processing, RX, TX and protocol sockets. * * Each instance of RIP is described by a structure &rip_proto, which contains * an internal RIP routing table, a list of protocol interfaces and the main * timer responsible for RIP routing table cleanup. * * RIP internal routing table contains incoming and outgoing routes. For each * network (represented by structure &rip_entry) there is one outgoing route * stored directly in &rip_entry and an one-way linked list of incoming routes * (structures &rip_rte). The list contains incoming routes from different RIP * neighbors, but only routes with the lowest metric are stored (i.e., all * stored incoming routes have the same metric). * * Note that RIP itself does not select outgoing route, that is done by the core * routing table. When a new incoming route is received, it is propagated to the * RIP table by rip_update_rte() and possibly stored in the list of incoming * routes. Then the change may be propagated to the core by rip_announce_rte(). * The core selects the best route and propagate it to RIP by rip_rt_notify(), * which updates outgoing route part of &rip_entry and possibly triggers route * propagation by rip_trigger_update(). * * RIP interfaces are represented by structures &rip_iface. A RIP interface * contains a per-interface socket, a list of associated neighbors, interface * configuration, and state information related to scheduled interface events * and running update sessions. RIP interfaces are added and removed based on * core interface notifications. * * There are two RIP interface events - regular updates and triggered updates. * Both are managed from the RIP interface timer (rip_iface_timer()). Regular * updates are called at fixed interval and propagate the whole routing table, * while triggered updates are scheduled by rip_trigger_update() due to some * routing table change and propagate only the routes modified since the time * they were scheduled. There are also unicast-destined requested updates, but * these are sent directly as a reaction to received RIP request message. The * update session is started by rip_send_table(). There may be at most one * active update session per interface, as the associated state (including the * fib iterator) is stored directly in &rip_iface structure. * * RIP neighbors are represented by structures &rip_neighbor. Compared to * neighbor handling in other routing protocols, RIP does not have explicit * neighbor discovery and adjacency maintenance, which makes the &rip_neighbor * related code a bit peculiar. RIP neighbors are interlinked with core neighbor * structures (&neighbor) and use core neighbor notifications to ensure that RIP * neighbors are timely removed. RIP neighbors are added based on received route * notifications and removed based on core neighbor and RIP interface events. * * RIP neighbors are linked by RIP routes and use counter to track the number of * associated routes, but when these RIP routes timeout, associated RIP neighbor * is still alive (with zero counter). When RIP neighbor is removed but still * has some associated routes, it is not freed, just changed to detached state * (core neighbors and RIP ifaces are unlinked), then during the main timer * cleanup phase the associated routes are removed and the &rip_neighbor * structure is finally freed. * * Supported standards: * RFC 1058 - RIPv1 * RFC 2453 - RIPv2 * RFC 2080 - RIPng * RFC 2091 - Triggered RIP for demand circuits * RFC 4822 - RIP cryptographic authentication */ #include #include "rip.h" static inline void rip_lock_neighbor(struct rip_neighbor *n); static inline void rip_unlock_neighbor(struct rip_neighbor *n); static inline int rip_iface_link_up(struct rip_iface *ifa); static inline void rip_kick_timer(struct rip_proto *p); static inline void rip_iface_kick_timer(struct rip_iface *ifa); static void rip_iface_timer(timer *timer); static void rip_trigger_update(struct rip_proto *p); /* * RIP routes */ static struct rip_rte * rip_add_rte(struct rip_proto *p, struct rip_rte **rp, struct rip_rte *src) { struct rip_rte *rt = sl_alloc(p->rte_slab); memcpy(rt, src, sizeof(struct rip_rte)); rt->next = *rp; *rp = rt; rip_lock_neighbor(rt->from); return rt; } static inline void rip_remove_rte(struct rip_proto *p, struct rip_rte **rp) { struct rip_rte *rt = *rp; rip_unlock_neighbor(rt->from); *rp = rt->next; sl_free(p->rte_slab, rt); } static inline int rip_same_rte(struct rip_rte *a, struct rip_rte *b) { return a->metric == b->metric && a->tag == b->tag && ipa_equal(a->next_hop, b->next_hop); } static inline int rip_valid_rte(struct rip_rte *rt) { return rt->from->ifa != NULL; } /** * rip_announce_rte - announce route from RIP routing table to the core * @p: RIP instance * @en: related network * * The function takes a list of incoming routes from @en, prepare appropriate * &rte for the core and propagate it by rte_update(). */ static void rip_announce_rte(struct rip_proto *p, struct rip_entry *en) { struct rip_rte *rt = en->routes; /* Find first valid rte */ while (rt && !rip_valid_rte(rt)) rt = rt->next; if (rt) { /* Update */ rta a0 = { .src = p->p.main_source, .source = RTS_RIP, .scope = SCOPE_UNIVERSE, .dest = RTD_UNICAST, }; u8 rt_metric = rt->metric; u16 rt_tag = rt->tag; if (p->ecmp) { /* ECMP route */ struct nexthop *nhs = NULL; int num = 0; for (rt = en->routes; rt && (num < p->ecmp); rt = rt->next) { if (!rip_valid_rte(rt)) continue; struct nexthop *nh = allocz(sizeof(struct nexthop)); nh->gw = rt->next_hop; nh->iface = rt->from->ifa->iface; nh->weight = rt->from->ifa->cf->ecmp_weight; nexthop_insert(&nhs, nh); num++; if (rt->tag != rt_tag) rt_tag = 0; } a0.nh = *nhs; } else { /* Unipath route */ a0.from = rt->from->nbr->addr; a0.nh.gw = rt->next_hop; a0.nh.iface = rt->from->ifa->iface; } rta *a = rta_lookup(&a0); rte *e = rte_get_temp(a); e->u.rip.from = a0.nh.iface; e->u.rip.metric = rt_metric; e->u.rip.tag = rt_tag; e->pflags = EA_ID_FLAG(EA_RIP_METRIC) | EA_ID_FLAG(EA_RIP_TAG); rte_update(&p->p, en->n.addr, e); } else { /* Withdraw */ rte_update(&p->p, en->n.addr, NULL); } } /** * rip_update_rte - enter a route update to RIP routing table * @p: RIP instance * @addr: network address * @new: a &rip_rte representing the new route * * The function is called by the RIP packet processing code whenever it receives * a reachable route. The appropriate routing table entry is found and the list * of incoming routes is updated. Eventually, the change is also propagated to * the core by rip_announce_rte(). Note that for unreachable routes, * rip_withdraw_rte() should be called instead of rip_update_rte(). */ void rip_update_rte(struct rip_proto *p, net_addr *n, struct rip_rte *new) { struct rip_entry *en = fib_get(&p->rtable, n); struct rip_rte *rt, **rp; int changed = 0; /* If the new route is better, remove all current routes */ if (en->routes && new->metric < en->routes->metric) while (en->routes) rip_remove_rte(p, &en->routes); /* Find the old route (also set rp for later) */ for (rp = &en->routes; rt = *rp; rp = &rt->next) if (rt->from == new->from) { if (rip_same_rte(rt, new)) { rt->expires = new->expires; return; } /* Remove the old route */ rip_remove_rte(p, rp); changed = 1; break; } /* If the new route is optimal, add it to the list */ if (!en->routes || new->metric == en->routes->metric) { rt = rip_add_rte(p, rp, new); changed = 1; } /* Announce change if on relevant position (the first or any for ECMP) */ if (changed && (rp == &en->routes || p->ecmp)) rip_announce_rte(p, en); } /** * rip_withdraw_rte - enter a route withdraw to RIP routing table * @p: RIP instance * @addr: network address * @from: a &rip_neighbor propagating the withdraw * * The function is called by the RIP packet processing code whenever it receives * an unreachable route. The incoming route for given network from nbr @from is * removed. Eventually, the change is also propagated by rip_announce_rte(). */ void rip_withdraw_rte(struct rip_proto *p, net_addr *n, struct rip_neighbor *from) { struct rip_entry *en = fib_find(&p->rtable, n); struct rip_rte *rt, **rp; if (!en) return; /* Find the old route */ for (rp = &en->routes; rt = *rp; rp = &rt->next) if (rt->from == from) break; if (!rt) return; /* Remove the old route */ rip_remove_rte(p, rp); /* Announce change if on relevant position */ if (rp == &en->routes || p->ecmp) rip_announce_rte(p, en); } /* * rip_rt_notify - core tells us about new route, so store * it into our data structures. */ static void rip_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *net, struct rte *new, struct rte *old UNUSED) { struct rip_proto *p = (struct rip_proto *) P; struct rip_entry *en; int old_metric; if (new) { /* Update */ u32 rt_metric = ea_get_int(new->attrs->eattrs, EA_RIP_METRIC, 1); u32 rt_tag = ea_get_int(new->attrs->eattrs, EA_RIP_TAG, 0); if (rt_metric > p->infinity) { log(L_WARN "%s: Invalid rip_metric value %u for route %N", p->p.name, rt_metric, net->n.addr); rt_metric = p->infinity; } if (rt_tag > 0xffff) { log(L_WARN "%s: Invalid rip_tag value %u for route %N", p->p.name, rt_tag, net->n.addr); rt_metric = p->infinity; rt_tag = 0; } /* * Note that we accept exported routes with infinity metric (this could * happen if rip_metric is modified in filters). Such entry has infinity * metric but is RIP_ENTRY_VALID and therefore is not subject to garbage * collection. */ en = fib_get(&p->rtable, net->n.addr); old_metric = en->valid ? en->metric : -1; en->valid = RIP_ENTRY_VALID; en->metric = rt_metric; en->tag = rt_tag; en->from = (new->attrs->src->proto == P) ? new->u.rip.from : NULL; en->iface = new->attrs->nh.iface; en->next_hop = new->attrs->nh.gw; } else { /* Withdraw */ en = fib_find(&p->rtable, net->n.addr); if (!en || en->valid != RIP_ENTRY_VALID) return; old_metric = en->metric; en->valid = RIP_ENTRY_STALE; en->metric = p->infinity; en->tag = 0; en->from = NULL; en->iface = NULL; en->next_hop = IPA_NONE; } /* Activate triggered updates */ if (en->metric != old_metric) { en->changed = current_time(); rip_trigger_update(p); } } void rip_flush_table(struct rip_proto *p, struct rip_neighbor *n) { btime expires = current_time() + n->ifa->cf->timeout_time; FIB_WALK(&p->rtable, struct rip_entry, en) { for (struct rip_rte *e = en->routes; e; e = e->next) if ((e->from == n) && (e->expires == TIME_INFINITY)) e->expires = expires; } FIB_WALK_END; } /* * RIP neighbors */ struct rip_neighbor * rip_get_neighbor(struct rip_proto *p, ip_addr *a, struct rip_iface *ifa) { neighbor *nbr = neigh_find(&p->p, *a, ifa->iface, 0); if (!nbr || (nbr->scope == SCOPE_HOST) || !rip_iface_link_up(ifa)) return NULL; if (nbr->data) return nbr->data; TRACE(D_EVENTS, "New neighbor %I on %s", *a, ifa->iface->name); struct rip_neighbor *n = mb_allocz(p->p.pool, sizeof(struct rip_neighbor)); n->ifa = ifa; n->nbr = nbr; nbr->data = n; n->csn = nbr->aux; add_tail(&ifa->neigh_list, NODE n); return n; } static void rip_remove_neighbor(struct rip_proto *p, struct rip_neighbor *n) { neighbor *nbr = n->nbr; TRACE(D_EVENTS, "Removing neighbor %I on %s", nbr->addr, nbr->ifreq->name); rem_node(NODE n); n->ifa = NULL; n->nbr = NULL; nbr->data = NULL; nbr->aux = n->csn; rfree(n->bfd_req); n->bfd_req = NULL; n->last_seen = 0; if (!n->uc) mb_free(n); /* Related routes are removed in rip_timer() */ rip_kick_timer(p); } static inline void rip_lock_neighbor(struct rip_neighbor *n) { n->uc++; } static inline void rip_unlock_neighbor(struct rip_neighbor *n) { n->uc--; if (!n->nbr && !n->uc) mb_free(n); } static void rip_neigh_notify(struct neighbor *nbr) { struct rip_proto *p = (struct rip_proto *) nbr->proto; struct rip_neighbor *n = nbr->data; if (!n) return; /* * We assume that rip_neigh_notify() is called before rip_if_notify() for * IF_CHANGE_DOWN and therefore n->ifa is still valid. We have no such * ordering assumption for IF_CHANGE_LINK, so we test link state of the * underlying iface instead of just rip_iface state. */ if ((nbr->scope <= 0) || !rip_iface_link_up(n->ifa)) rip_remove_neighbor(p, n); } static void rip_bfd_notify(struct bfd_request *req) { struct rip_neighbor *n = req->data; struct rip_proto *p = n->ifa->rip; if (req->down) { TRACE(D_EVENTS, "BFD session down for nbr %I on %s", n->nbr->addr, n->ifa->iface->name); rip_remove_neighbor(p, n); } } void rip_update_bfd(struct rip_proto *p, struct rip_neighbor *n) { int use_bfd = n->ifa->cf->bfd && n->last_seen; if (use_bfd && !n->bfd_req) { /* * For RIPv2, use the same address as rip_open_socket(). For RIPng, neighbor * should contain an address from the same prefix, thus also link-local. It * may cause problems if two link-local addresses are assigned to one iface. */ ip_addr saddr = rip_is_v2(p) ? n->ifa->sk->saddr : n->nbr->ifa->ip; n->bfd_req = bfd_request_session(p->p.pool, n->nbr->addr, saddr, n->nbr->iface, p->p.vrf, rip_bfd_notify, n, NULL); } if (!use_bfd && n->bfd_req) { rfree(n->bfd_req); n->bfd_req = NULL; } } /* * RIP interfaces */ static void rip_iface_start(struct rip_iface *ifa) { struct rip_proto *p = ifa->rip; TRACE(D_EVENTS, "Starting interface %s", ifa->iface->name); if (! ifa->cf->demand_circuit) { ifa->next_regular = current_time() + (random() % ifa->cf->update_time) + 100 MS; tm_set(ifa->timer, ifa->next_regular); } else { ifa->next_regular = TIME_INFINITY; } ifa->up = 1; if (ifa->cf->passive) return; rip_send_request(p, ifa); rip_send_table(p, ifa, ifa->addr, 0); } static void rip_iface_stop(struct rip_iface *ifa) { struct rip_proto *p = ifa->rip; struct rip_neighbor *n; TRACE(D_EVENTS, "Stopping interface %s", ifa->iface->name); rip_reset_tx_session(p, ifa); ifa->next_regular = 0; ifa->next_triggered = 0; ifa->want_triggered = 0; if (ifa->tx_pending) ifa->tx_seqnum++; ifa->tx_pending = 0; ifa->req_pending = 0; if (ifa->cf->demand_circuit && !ifa->cf->passive) rip_send_flush(p, ifa); WALK_LIST_FIRST(n, ifa->neigh_list) rip_remove_neighbor(p, n); tm_stop(ifa->timer); tm_stop(ifa->rxmt_timer); ifa->up = 0; } static inline int rip_iface_link_up(struct rip_iface *ifa) { return !ifa->cf->check_link || (ifa->iface->flags & IF_LINK_UP); } static void rip_iface_update_state(struct rip_iface *ifa) { int up = ifa->sk && rip_iface_link_up(ifa); if (up == ifa->up) return; if (up) rip_iface_start(ifa); else rip_iface_stop(ifa); } static void rip_iface_update_buffers(struct rip_iface *ifa) { if (!ifa->sk) return; uint rbsize = ifa->cf->rx_buffer ?: ifa->iface->mtu; uint tbsize = ifa->cf->tx_length ?: ifa->iface->mtu; rbsize = MAX(rbsize, tbsize); sk_set_rbsize(ifa->sk, rbsize); sk_set_tbsize(ifa->sk, tbsize); uint headers = (rip_is_v2(ifa->rip) ? IP4_HEADER_LENGTH : IP6_HEADER_LENGTH) + UDP_HEADER_LENGTH; ifa->tx_plen = tbsize - headers; if (ifa->cf->auth_type == RIP_AUTH_CRYPTO) ifa->tx_plen -= RIP_AUTH_TAIL_LENGTH + max_mac_length(ifa->cf->passwords); } static inline void rip_iface_update_bfd(struct rip_iface *ifa) { struct rip_proto *p = ifa->rip; struct rip_neighbor *n; WALK_LIST(n, ifa->neigh_list) rip_update_bfd(p, n); } static void rip_iface_locked(struct object_lock *lock) { struct rip_iface *ifa = lock->data; struct rip_proto *p = ifa->rip; if (!rip_open_socket(ifa)) { log(L_ERR "%s: Cannot open socket for %s", p->p.name, ifa->iface->name); return; } rip_iface_update_buffers(ifa); rip_iface_update_state(ifa); } static struct rip_iface * rip_find_iface(struct rip_proto *p, struct iface *what) { struct rip_iface *ifa; WALK_LIST(ifa, p->iface_list) if (ifa->iface == what) return ifa; return NULL; } static void rip_add_iface(struct rip_proto *p, struct iface *iface, struct rip_iface_config *ic) { struct rip_iface *ifa; TRACE(D_EVENTS, "Adding interface %s", iface->name); ifa = mb_allocz(p->p.pool, sizeof(struct rip_iface)); ifa->rip = p; ifa->iface = iface; ifa->cf = ic; if (ipa_nonzero(ic->address)) ifa->addr = ic->address; else if (ic->mode == RIP_IM_MULTICAST) ifa->addr = rip_is_v2(p) ? IP4_RIP_ROUTERS : IP6_RIP_ROUTERS; else /* Broadcast */ ifa->addr = iface->addr4->brd; /* * The above is just a workaround for BSD as it can't send broadcasts * to 255.255.255.255. BSD systems need the network broadcast address instead. * * TODO: move this to sysdep code */ init_list(&ifa->neigh_list); add_tail(&p->iface_list, NODE ifa); ifa->timer = tm_new_init(p->p.pool, rip_iface_timer, ifa, 0, 0); ifa->rxmt_timer = tm_new_init(p->p.pool, rip_rxmt_timeout, ifa, 0, 0); struct object_lock *lock = olock_new(p->p.pool); lock->type = OBJLOCK_UDP; lock->port = ic->port; lock->iface = iface; lock->data = ifa; lock->hook = rip_iface_locked; ifa->lock = lock; olock_acquire(lock); } static void rip_remove_iface(struct rip_proto *p, struct rip_iface *ifa) { rip_iface_stop(ifa); TRACE(D_EVENTS, "Removing interface %s", ifa->iface->name); rem_node(NODE ifa); rfree(ifa->sk); rfree(ifa->lock); rfree(ifa->timer); mb_free(ifa); } static int rip_reconfigure_iface(struct rip_proto *p, struct rip_iface *ifa, struct rip_iface_config *new) { struct rip_iface_config *old = ifa->cf; /* Change of these options would require to reset the iface socket */ if ((new->mode != old->mode) || (new->port != old->port) || (new->tx_tos != old->tx_tos) || (new->tx_priority != old->tx_priority) || (new->ttl_security != old->ttl_security) || (new->demand_circuit != old->demand_circuit)) return 0; TRACE(D_EVENTS, "Reconfiguring interface %s", ifa->iface->name); ifa->cf = new; rip_iface_update_buffers(ifa); if ((! ifa->cf->demand_circuit) && (ifa->next_regular > (current_time() + new->update_time))) ifa->next_regular = current_time() + (random() % new->update_time) + 100 MS; if (ifa->up && new->demand_circuit && (new->passive != old->passive)) { if (new->passive) rip_send_flush(p, ifa); else { rip_send_request(p, ifa); rip_send_table(p, ifa, ifa->addr, 0); } } if (new->check_link != old->check_link) rip_iface_update_state(ifa); if (new->bfd != old->bfd) rip_iface_update_bfd(ifa); if (ifa->up) rip_iface_kick_timer(ifa); return 1; } static void rip_reconfigure_ifaces(struct rip_proto *p, struct rip_config *cf) { struct iface *iface; WALK_LIST(iface, iface_list) { if (!(iface->flags & IF_UP)) continue; /* Ignore ifaces without appropriate address */ if (rip_is_v2(p) ? !iface->addr4 : !iface->llv6) continue; struct rip_iface *ifa = rip_find_iface(p, iface); struct rip_iface_config *ic = (void *) iface_patt_find(&cf->patt_list, iface, NULL); if (ifa && ic) { if (rip_reconfigure_iface(p, ifa, ic)) continue; /* Hard restart */ log(L_INFO "%s: Restarting interface %s", p->p.name, ifa->iface->name); rip_remove_iface(p, ifa); rip_add_iface(p, iface, ic); } if (ifa && !ic) rip_remove_iface(p, ifa); if (!ifa && ic) rip_add_iface(p, iface, ic); } } static void rip_if_notify(struct proto *P, unsigned flags, struct iface *iface) { struct rip_proto *p = (void *) P; struct rip_config *cf = (void *) P->cf; struct rip_iface *ifa = rip_find_iface(p, iface); if (iface->flags & IF_IGNORE) return; /* Add, remove or restart interface */ if (flags & (IF_CHANGE_UPDOWN | (rip_is_v2(p) ? IF_CHANGE_ADDR4 : IF_CHANGE_LLV6))) { if (ifa) rip_remove_iface(p, ifa); if (!(iface->flags & IF_UP)) return; /* Ignore ifaces without appropriate address */ if (rip_is_v2(p) ? !iface->addr4 : !iface->llv6) return; struct rip_iface_config *ic = (void *) iface_patt_find(&cf->patt_list, iface, NULL); if (ic) rip_add_iface(p, iface, ic); return; } if (!ifa) return; if (flags & IF_CHANGE_MTU) rip_iface_update_buffers(ifa); if (flags & IF_CHANGE_LINK) rip_iface_update_state(ifa); } /* * RIP timer events */ /** * rip_timer - RIP main timer hook * @t: timer * * The RIP main timer is responsible for routing table maintenance. Invalid or * expired routes (&rip_rte) are removed and garbage collection of stale routing * table entries (&rip_entry) is done. Changes are propagated to core tables, * route reload is also done here. Note that garbage collection uses a maximal * GC time, while interfaces maintain an illusion of per-interface GC times in * rip_send_response(). * * Keeping incoming routes and the selected outgoing route are two independent * functions, therefore after garbage collection some entries now considered * invalid (RIP_ENTRY_DUMMY) still may have non-empty list of incoming routes, * while some valid entries (representing an outgoing route) may have that list * empty. * * The main timer is not scheduled periodically but it uses the time of the * current next event and the minimal interval of any possible event to compute * the time of the next run. */ static void rip_timer(timer *t) { struct rip_proto *p = t->data; struct rip_config *cf = (void *) (p->p.cf); struct rip_iface *ifa; struct rip_neighbor *n, *nn; struct fib_iterator fit; btime now_ = current_time(); btime next = now_ + MIN(cf->min_timeout_time, cf->max_garbage_time); btime expires = 0; TRACE(D_EVENTS, "Main timer fired"); FIB_ITERATE_INIT(&fit, &p->rtable); loop: FIB_ITERATE_START(&p->rtable, &fit, struct rip_entry, en) { struct rip_rte *rt, **rp; int changed = 0; /* Checking received routes for timeout and for dead neighbors */ for (rp = &en->routes; rt = *rp; /* rp = &rt->next */) { if (!rip_valid_rte(rt) || (rt->expires <= now_)) { rip_remove_rte(p, rp); changed = 1; continue; } next = MIN(next, rt->expires); rp = &rt->next; } /* Propagating eventual change */ if (changed || p->rt_reload) { /* * We have to restart the iteration because there may be a cascade of * synchronous events rip_announce_rte() -> nest table change -> * rip_rt_notify() -> p->rtable change, invalidating hidden variables. */ FIB_ITERATE_PUT_NEXT(&fit, &p->rtable); rip_announce_rte(p, en); goto loop; } /* Checking stale entries for garbage collection timeout */ if (en->valid == RIP_ENTRY_STALE) { expires = en->changed + cf->max_garbage_time; if (expires <= now_) { // TRACE(D_EVENTS, "entry is too old: %N", en->n.addr); en->valid = 0; } else next = MIN(next, expires); } /* Remove empty nodes */ if (!en->valid && !en->routes) { FIB_ITERATE_PUT(&fit); fib_delete(&p->rtable, en); goto loop; } } FIB_ITERATE_END; p->rt_reload = 0; /* Handling neighbor expiration */ WALK_LIST(ifa, p->iface_list) { /* No expiration for demand circuit ifaces */ if (ifa->cf->demand_circuit) continue; WALK_LIST_DELSAFE(n, nn, ifa->neigh_list) if (n->last_seen) { expires = n->last_seen + n->ifa->cf->timeout_time; if (expires <= now_) rip_remove_neighbor(p, n); else next = MIN(next, expires); } } tm_start(p->timer, MAX(next - now_, 100 MS)); } static inline void rip_kick_timer(struct rip_proto *p) { if ((p->timer->expires > (current_time() + 100 MS))) tm_start(p->timer, 100 MS); } /** * rip_iface_timer - RIP interface timer hook * @t: timer * * RIP interface timers are responsible for scheduling both regular and * triggered updates. Fixed, delay-independent period is used for regular * updates, while minimal separating interval is enforced for triggered updates. * The function also ensures that a new update is not started when the old one * is still running. */ static void rip_iface_timer(timer *t) { struct rip_iface *ifa = t->data; struct rip_proto *p = ifa->rip; btime now_ = current_time(); btime period = ifa->cf->update_time; if (ifa->cf->passive) return; TRACE(D_EVENTS, "Interface timer fired for %s", ifa->iface->name); if (ifa->tx_active) { tm_start(ifa->timer, 100 MS); return; } if (now_ >= ifa->next_regular) { /* Send regular update, set timer for next period (or following one if necessay) */ TRACE(D_EVENTS, "Sending regular updates for %s", ifa->iface->name); rip_send_table(p, ifa, ifa->addr, 0); ifa->next_regular += period * (1 + ((now_ - ifa->next_regular) / period)); ifa->want_triggered = 0; p->triggered = 0; } else if (ifa->want_triggered && (now_ >= ifa->next_triggered)) { /* Send triggered update, enforce interval between triggered updates */ TRACE(D_EVENTS, "Sending triggered updates for %s", ifa->iface->name); rip_send_table(p, ifa, ifa->addr, ifa->want_triggered); ifa->next_triggered = now_ + MIN(5 S, period / 2); ifa->want_triggered = 0; p->triggered = 0; } if (ifa->want_triggered && (ifa->next_triggered < ifa->next_regular)) tm_set(ifa->timer, ifa->next_triggered); else if (ifa->next_regular != TIME_INFINITY) tm_set(ifa->timer, ifa->next_regular); } static inline void rip_iface_kick_timer(struct rip_iface *ifa) { if ((! tm_active(ifa->timer)) || (ifa->timer->expires > (current_time() + 100 MS))) tm_start(ifa->timer, 100 MS); } static void rip_trigger_update(struct rip_proto *p) { if (p->triggered) return; struct rip_iface *ifa; WALK_LIST(ifa, p->iface_list) { /* Interface not active */ if (! ifa->up) continue; /* Already scheduled */ if (ifa->want_triggered) continue; TRACE(D_EVENTS, "Scheduling triggered updates for %s", ifa->iface->name); ifa->want_triggered = current_time(); rip_iface_kick_timer(ifa); p->triggered = 1; } } /* * RIP protocol glue */ static void rip_reload_routes(struct channel *C) { struct rip_proto *p = (struct rip_proto *) C->proto; if (p->rt_reload) return; TRACE(D_EVENTS, "Scheduling route reload"); p->rt_reload = 1; rip_kick_timer(p); } static void rip_make_tmp_attrs(struct rte *rt, struct linpool *pool) { rte_init_tmp_attrs(rt, pool, 2); rte_make_tmp_attr(rt, EA_RIP_METRIC, EAF_TYPE_INT, rt->u.rip.metric); rte_make_tmp_attr(rt, EA_RIP_TAG, EAF_TYPE_INT, rt->u.rip.tag); } static void rip_store_tmp_attrs(struct rte *rt, struct linpool *pool) { rte_init_tmp_attrs(rt, pool, 2); rt->u.rip.metric = rte_store_tmp_attr(rt, EA_RIP_METRIC); rt->u.rip.tag = rte_store_tmp_attr(rt, EA_RIP_TAG); } static int rip_rte_better(struct rte *new, struct rte *old) { return new->u.rip.metric < old->u.rip.metric; } static int rip_rte_same(struct rte *new, struct rte *old) { return ((new->u.rip.metric == old->u.rip.metric) && (new->u.rip.tag == old->u.rip.tag) && (new->u.rip.from == old->u.rip.from)); } static void rip_postconfig(struct proto_config *CF) { // struct rip_config *cf = (void *) CF; /* Define default channel */ if (EMPTY_LIST(CF->channels)) channel_config_new(NULL, net_label[CF->net_type], CF->net_type, CF); } static struct proto * rip_init(struct proto_config *CF) { struct proto *P = proto_new(CF); P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF)); P->if_notify = rip_if_notify; P->rt_notify = rip_rt_notify; P->neigh_notify = rip_neigh_notify; P->reload_routes = rip_reload_routes; P->make_tmp_attrs = rip_make_tmp_attrs; P->store_tmp_attrs = rip_store_tmp_attrs; P->rte_better = rip_rte_better; P->rte_same = rip_rte_same; return P; } static int rip_start(struct proto *P) { struct rip_proto *p = (void *) P; struct rip_config *cf = (void *) (P->cf); init_list(&p->iface_list); fib_init(&p->rtable, P->pool, cf->rip2 ? NET_IP4 : NET_IP6, sizeof(struct rip_entry), OFFSETOF(struct rip_entry, n), 0, NULL); p->rte_slab = sl_new(P->pool, sizeof(struct rip_rte)); p->timer = tm_new_init(P->pool, rip_timer, p, 0, 0); p->rip2 = cf->rip2; p->ecmp = cf->ecmp; p->infinity = cf->infinity; p->triggered = 0; p->log_pkt_tbf = (struct tbf){ .rate = 1, .burst = 5 }; p->log_rte_tbf = (struct tbf){ .rate = 4, .burst = 20 }; tm_start(p->timer, MIN(cf->min_timeout_time, cf->max_garbage_time)); return PS_UP; } static int rip_shutdown(struct proto *P) { struct rip_proto *p = (void *) P; TRACE(D_EVENTS, "Shutdown requested"); struct rip_iface *ifa; WALK_LIST(ifa, p->iface_list) rip_iface_stop(ifa); return PS_DOWN; } static int rip_reconfigure(struct proto *P, struct proto_config *CF) { struct rip_proto *p = (void *) P; struct rip_config *new = (void *) CF; // struct rip_config *old = (void *) (P->cf); if (new->rip2 != p->rip2) return 0; if (new->infinity != p->infinity) return 0; if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF))) return 0; TRACE(D_EVENTS, "Reconfiguring"); p->p.cf = CF; p->ecmp = new->ecmp; rip_reconfigure_ifaces(p, new); p->rt_reload = 1; rip_kick_timer(p); return 1; } static void rip_get_route_info(rte *rte, byte *buf) { buf += bsprintf(buf, " (%d/%d)", rte->pref, rte->u.rip.metric); if (rte->u.rip.tag) bsprintf(buf, " [%04x]", rte->u.rip.tag); } static int rip_get_attr(const eattr *a, byte *buf, int buflen UNUSED) { switch (a->id) { case EA_RIP_METRIC: bsprintf(buf, "metric: %d", a->u.data); return GA_FULL; case EA_RIP_TAG: bsprintf(buf, "tag: %04x", a->u.data); return GA_FULL; default: return GA_UNKNOWN; } } void rip_show_interfaces(struct proto *P, const char *iff) { struct rip_proto *p = (void *) P; struct rip_iface *ifa = NULL; struct rip_neighbor *n = NULL; if (p->p.proto_state != PS_UP) { cli_msg(-1021, "%s: is not up", p->p.name); return; } cli_msg(-1021, "%s:", p->p.name); cli_msg(-1021, "%-10s %-6s %6s %6s %7s", "Interface", "State", "Metric", "Nbrs", "Timer"); WALK_LIST(ifa, p->iface_list) { if (iff && !patmatch(iff, ifa->iface->name)) continue; int nbrs = 0; WALK_LIST(n, ifa->neigh_list) if (n->last_seen) nbrs++; btime now_ = current_time(); btime timer = ((ifa->next_regular < TIME_INFINITY) && (ifa->next_regular > now_)) ? (ifa->next_regular - now_) : 0; cli_msg(-1021, "%-10s %-6s %6u %6u %7t", ifa->iface->name, (ifa->up ? "Up" : "Down"), ifa->cf->metric, nbrs, timer); } } void rip_show_neighbors(struct proto *P, const char *iff) { struct rip_proto *p = (void *) P; struct rip_iface *ifa = NULL; struct rip_neighbor *n = NULL; if (p->p.proto_state != PS_UP) { cli_msg(-1022, "%s: is not up", p->p.name); return; } cli_msg(-1022, "%s:", p->p.name); cli_msg(-1022, "%-25s %-10s %6s %6s %7s", "IP address", "Interface", "Metric", "Routes", "Seen"); WALK_LIST(ifa, p->iface_list) { if (iff && !patmatch(iff, ifa->iface->name)) continue; WALK_LIST(n, ifa->neigh_list) { if (!n->last_seen) continue; btime timer = current_time() - n->last_seen; cli_msg(-1022, "%-25I %-10s %6u %6u %7t", n->nbr->addr, ifa->iface->name, ifa->cf->metric, n->uc, timer); } } } static void rip_dump(struct proto *P) { struct rip_proto *p = (struct rip_proto *) P; struct rip_iface *ifa; int i; i = 0; FIB_WALK(&p->rtable, struct rip_entry, en) { debug("RIP: entry #%d: %N via %I dev %s valid %d metric %d age %t\n", i++, en->n.addr, en->next_hop, en->iface ? en->iface->name : "(null)", en->valid, en->metric, current_time() - en->changed); for (struct rip_rte *e = en->routes; e; e = e->next) debug("RIP: via %I metric %d expires %t\n", e->next_hop, e->metric, e->expires - current_time()); } FIB_WALK_END; i = 0; WALK_LIST(ifa, p->iface_list) { debug("RIP: interface #%d: %s, %I, up = %d, busy = %d\n", i++, ifa->iface->name, ifa->sk ? ifa->sk->daddr : IPA_NONE, ifa->up, ifa->tx_active); } } struct protocol proto_rip = { .name = "RIP", .template = "rip%d", .class = PROTOCOL_RIP, .preference = DEF_PREF_RIP, .channel_mask = NB_IP, .proto_size = sizeof(struct rip_proto), .config_size = sizeof(struct rip_config), .postconfig = rip_postconfig, .init = rip_init, .dump = rip_dump, .start = rip_start, .shutdown = rip_shutdown, .reconfigure = rip_reconfigure, .get_route_info = rip_get_route_info, .get_attr = rip_get_attr }; bird-2.0.8/proto/rip/packets.c0000664000175000017500000006447414025744326015136 0ustar feelafeela/* * BIRD -- Routing Information Protocol (RIP) * * (c) 1998--1999 Pavel Machek * (c) 2004--2013 Ondrej Filip * (c) 2009--2015 Ondrej Zajicek * (c) 2009--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #undef LOCAL_DEBUG #include "rip.h" #include "lib/mac.h" #define RIP_CMD_REQUEST 1 /* want info */ #define RIP_CMD_RESPONSE 2 /* responding to request */ #define RIP_CMD_UPDATE_REQUEST 9 #define RIP_CMD_UPDATE_RESPONSE 10 #define RIP_CMD_UPDATE_ACK 11 #define RIP_BLOCK_LENGTH 20 #define RIP_PASSWD_LENGTH 16 #define RIP_AF_IPV4 2 #define RIP_AF_AUTH 0xffff #define RIP_UPDATE_VERSION 1 /* RIP packet header */ struct rip_packet { u8 command; u8 version; u16 unused; }; /* Triggered RIP update header (RFC 2091) */ struct rip_update_hdr { u8 version; u8 flush; u16 seqnum; }; /* RTE block for RIPv2 */ struct rip_block_v2 { u16 family; u16 tag; ip4_addr network; ip4_addr netmask; ip4_addr next_hop; u32 metric; }; /* RTE block for RIPng */ struct rip_block_ng { ip6_addr prefix; u16 tag; u8 pxlen; u8 metric; }; /* Authentication block for RIPv2 */ struct rip_block_auth { u16 must_be_ffff; u16 auth_type; union { char password[16]; struct { u16 packet_len; u8 key_id; u8 auth_len; u32 seq_num; u32 unused1; u32 unused2; }; }; }; /* Authentication tail, RFC 4822 */ struct rip_auth_tail { u16 must_be_ffff; u16 must_be_0001; byte auth_data[0]; }; /* Internal representation of RTE block data */ struct rip_block { net_addr net; u32 metric; u16 tag; u16 no_af; ip_addr next_hop; }; static int rip_send_ack(struct rip_proto *p, struct rip_iface *ifa, uint flush, uint seqnum); #define DROP(DSC,VAL) do { err_dsc = DSC; err_val = VAL; goto drop; } while(0) #define DROP1(DSC) do { err_dsc = DSC; goto drop; } while(0) #define SKIP(DSC) do { err_dsc = DSC; goto skip; } while(0) #define LOG_PKT(msg, args...) \ log_rl(&p->log_pkt_tbf, L_REMOTE "%s: " msg, p->p.name, args) #define LOG_PKT_AUTH(msg, args...) \ log_rl(&p->log_pkt_tbf, L_AUTH "%s: " msg, p->p.name, args) #define LOG_RTE(msg, args...) \ log_rl(&p->log_rte_tbf, L_REMOTE "%s: " msg, p->p.name, args) static inline void * rip_tx_buffer(struct rip_iface *ifa) { return ifa->sk->tbuf; } static inline uint rip_pkt_hdrlen(struct rip_iface *ifa) { return sizeof(struct rip_packet) + (ifa->cf->demand_circuit ? sizeof(struct rip_update_hdr) : 0) + (ifa->cf->auth_type ? RIP_BLOCK_LENGTH : 0); } static inline struct rip_update_hdr * rip_get_update_hdr(struct rip_packet *pkt) { return (void *) ((byte *) pkt + sizeof(struct rip_packet)); } static inline struct rip_block_auth * rip_get_auth_block(struct rip_iface *ifa, struct rip_packet *pkt) { return (void *) ((byte *) pkt + sizeof(struct rip_packet) + (ifa->cf->demand_circuit ? sizeof(struct rip_update_hdr) : 0)); } static inline void rip_put_block(struct rip_proto *p, byte *pos, struct rip_block *rte) { if (rip_is_v2(p)) { struct rip_block_v2 *block = (void *) pos; block->family = rte->no_af ? 0 : htons(RIP_AF_IPV4); block->tag = htons(rte->tag); block->network = ip4_hton(net4_prefix(&rte->net)); block->netmask = ip4_hton(ip4_mkmask(net4_pxlen(&rte->net))); block->next_hop = ip4_hton(ipa_to_ip4(rte->next_hop)); block->metric = htonl(rte->metric); } else /* RIPng */ { struct rip_block_ng *block = (void *) pos; block->prefix = ip6_hton(net6_prefix(&rte->net)); block->tag = htons(rte->tag); block->pxlen = net6_pxlen(&rte->net); block->metric = rte->metric; } } static inline void rip_put_next_hop(struct rip_proto *p UNUSED, byte *pos, struct rip_block *rte) { struct rip_block_ng *block = (void *) pos; block->prefix = ip6_hton(ipa_to_ip6(rte->next_hop)); block->tag = 0; block->pxlen = 0; block->metric = 0xff; } static inline int rip_get_block(struct rip_proto *p, byte *pos, struct rip_block *rte) { if (rip_is_v2(p)) { struct rip_block_v2 *block = (void *) pos; /* Skip blocks with strange AF, including authentication blocks */ if (block->family != (rte->no_af ? 0 : htons(RIP_AF_IPV4))) return 0; uint pxlen = ip4_masklen(ip4_ntoh(block->netmask)); net_fill_ip4(&rte->net, ip4_ntoh(block->network), pxlen); rte->metric = ntohl(block->metric); rte->tag = ntohs(block->tag); rte->next_hop = ipa_from_ip4(ip4_ntoh(block->next_hop)); return 1; } else /* RIPng */ { struct rip_block_ng *block = (void *) pos; /* Handle and skip next hop blocks */ if (block->metric == 0xff) { rte->next_hop = ipa_from_ip6(ip6_ntoh(block->prefix)); if (!ipa_is_link_local(rte->next_hop)) rte->next_hop = IPA_NONE; return 0; } uint pxlen = (block->pxlen <= IP6_MAX_PREFIX_LENGTH) ? block->pxlen : 255; net_fill_ip6(&rte->net, ip6_ntoh(block->prefix), pxlen); rte->metric = block->metric; rte->tag = ntohs(block->tag); /* rte->next_hop is deliberately kept unmodified */; return 1; } } static inline void rip_update_csn(struct rip_proto *p UNUSED, struct rip_iface *ifa) { /* * We update crypto sequence numbers at the beginning of update session to * avoid issues with packet reordering, so packets inside one update session * have the same CSN. We are using real time, but enforcing monotonicity. */ if (ifa->cf->auth_type == RIP_AUTH_CRYPTO) { u32 now_real = (u32) (current_real_time() TO_S); ifa->csn = (ifa->csn < now_real) ? now_real : ifa->csn + 1; } } static inline void rip_fill_header(struct rip_iface *ifa, struct rip_packet *pkt, uint cmd) { *pkt = (struct rip_packet) { .command = cmd, .version = ifa->cf->version }; } static inline void rip_fill_update_hdr(struct rip_packet *pkt, uint flush, uint seqnum) { struct rip_update_hdr *hdr = rip_get_update_hdr(pkt); *hdr = (struct rip_update_hdr) { .version = RIP_UPDATE_VERSION, .flush = flush, .seqnum = htons(seqnum) }; } static void rip_fill_authentication(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint *plen) { struct rip_block_auth *auth = rip_get_auth_block(ifa, pkt); struct password_item *pass = password_find(ifa->cf->passwords, 0); if (!pass) { /* FIXME: This should not happen */ log(L_ERR "%s: No suitable password found for authentication", p->p.name); memset(auth, 0, sizeof(struct rip_block_auth)); return; } switch (ifa->cf->auth_type) { case RIP_AUTH_PLAIN: auth->must_be_ffff = htons(0xffff); auth->auth_type = htons(RIP_AUTH_PLAIN); strncpy(auth->password, pass->password, RIP_PASSWD_LENGTH); return; case RIP_AUTH_CRYPTO: auth->must_be_ffff = htons(0xffff); auth->auth_type = htons(RIP_AUTH_CRYPTO); auth->packet_len = htons(*plen); auth->key_id = pass->id; auth->auth_len = mac_type_length(pass->alg); auth->seq_num = ifa->csn_ready ? htonl(ifa->csn) : 0; auth->unused1 = 0; auth->unused2 = 0; ifa->csn_ready = 1; if (pass->alg < ALG_HMAC) auth->auth_len += sizeof(struct rip_auth_tail); /* * Note that RFC 4822 is unclear whether auth_len should cover whole * authentication trailer or just auth_data length. * * FIXME: We should use just auth_data length by default. Currently we put * the whole auth trailer length in keyed hash case to keep old behavior, * but we put just auth_data length in the new HMAC case. Note that Quagga * has config option for this. * * Crypto sequence numbers are increased by sender in rip_update_csn(). * First CSN should be zero, this is handled by csn_ready. */ struct rip_auth_tail *tail = (void *) ((byte *) pkt + *plen); tail->must_be_ffff = htons(0xffff); tail->must_be_0001 = htons(0x0001); uint auth_len = mac_type_length(pass->alg); *plen += sizeof(struct rip_auth_tail) + auth_len; /* Append key for keyed hash, append padding for HMAC (RFC 4822 2.5) */ if (pass->alg < ALG_HMAC) strncpy(tail->auth_data, pass->password, auth_len); else memset32(tail->auth_data, HMAC_MAGIC, auth_len / 4); mac_fill(pass->alg, pass->password, pass->length, (byte *) pkt, *plen, tail->auth_data); return; default: bug("Unknown authentication type"); } } static int rip_check_authentication(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint *plen, uint hdr_len, struct rip_neighbor *n) { struct rip_block_auth *auth = (void *) ((byte *) pkt + hdr_len); struct password_item *pass = NULL; const char *err_dsc = NULL; uint err_val = 0; uint auth_type = 0; /* Check for authentication entry */ if ((*plen >= (hdr_len + sizeof(struct rip_block_auth))) && (auth->must_be_ffff == htons(0xffff))) auth_type = ntohs(auth->auth_type); if (auth_type != ifa->cf->auth_type) DROP("authentication method mismatch", auth_type); switch (auth_type) { case RIP_AUTH_NONE: return 1; case RIP_AUTH_PLAIN: pass = password_find_by_value(ifa->cf->passwords, auth->password, RIP_PASSWD_LENGTH); if (!pass) DROP1("wrong password"); return 1; case RIP_AUTH_CRYPTO: pass = password_find_by_id(ifa->cf->passwords, auth->key_id); if (!pass) DROP("no suitable password found", auth->key_id); uint data_len = ntohs(auth->packet_len); uint auth_len = mac_type_length(pass->alg); uint auth_len2 = sizeof(struct rip_auth_tail) + auth_len; /* * Ideally, first check should be check for internal consistency: * (data_len + sizeof(struct rip_auth_tail) + auth->auth_len) != *plen * * Second one should check expected code length: * auth->auth_len != auth_len * * But as auth->auth_len has two interpretations, we simplify this */ if (data_len + auth_len2 != *plen) DROP("packet length mismatch", *plen); /* Warning: two interpretations of auth_len field */ if ((auth->auth_len != auth_len) && (auth->auth_len != auth_len2)) DROP("wrong authentication length", auth->auth_len); struct rip_auth_tail *tail = (void *) ((byte *) pkt + data_len); if ((tail->must_be_ffff != htons(0xffff)) || (tail->must_be_0001 != htons(0x0001))) DROP1("authentication trailer is missing"); /* Accept higher sequence number, or zero if connectivity is lost */ /* FIXME: sequence number must be password/SA specific */ u32 rcv_csn = ntohl(auth->seq_num); if ((rcv_csn < n->csn) && (rcv_csn || n->uc)) { /* We want to report both new and old CSN */ LOG_PKT_AUTH("Authentication failed for %I on %s - " "lower sequence number (rcv %u, old %u)", n->nbr->addr, ifa->iface->name, rcv_csn, n->csn); return 0; } byte *auth_data = alloca(auth_len); memcpy(auth_data, tail->auth_data, auth_len); /* Append key for keyed hash, append padding for HMAC (RFC 4822 2.5) */ if (pass->alg < ALG_HMAC) strncpy(tail->auth_data, pass->password, auth_len); else memset32(tail->auth_data, HMAC_MAGIC, auth_len / 4); if (!mac_verify(pass->alg, pass->password, pass->length, (byte *) pkt, *plen, auth_data)) DROP("wrong authentication code", pass->id); *plen = data_len; n->csn = rcv_csn; return 1; } drop: LOG_PKT_AUTH("Authentication failed for %I on %s - %s (%u)", n->nbr->addr, ifa->iface->name, err_dsc, err_val); return 0; } static inline int rip_send_to(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint plen, ip_addr dst) { if (ifa->cf->auth_type) rip_fill_authentication(p, ifa, pkt, &plen); return sk_send_to(ifa->sk, plen, dst, 0); } static inline void rip_kick_rxmt_timer(struct rip_iface *ifa) { if (! tm_active(ifa->rxmt_timer)) tm_start(ifa->rxmt_timer, ifa->cf->rxmt_time); } void rip_send_request(struct rip_proto *p, struct rip_iface *ifa) { struct rip_packet *pkt = rip_tx_buffer(ifa); byte *pos = (byte *) pkt + rip_pkt_hdrlen(ifa); rip_fill_header(ifa, pkt, RIP_CMD_REQUEST); if (ifa->cf->demand_circuit) { pkt->command = RIP_CMD_UPDATE_REQUEST; rip_fill_update_hdr(pkt, 0, 0); /* Must be acknowledged by update response */ ifa->req_pending = 1; rip_kick_rxmt_timer(ifa); } struct rip_block b = { .no_af = 1, .metric = p->infinity }; rip_put_block(p, pos, &b); pos += RIP_BLOCK_LENGTH; rip_update_csn(p, ifa); TRACE(D_PACKETS, "Sending request via %s", ifa->iface->name); rip_send_to(p, ifa, pkt, pos - (byte *) pkt, ifa->addr); } static void rip_receive_request(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint plen, struct rip_neighbor *from) { TRACE(D_PACKETS, "Request received from %I on %s", from->nbr->addr, ifa->iface->name); byte *pos = (byte *) pkt + rip_pkt_hdrlen(ifa); /* We expect one regular block */ if (plen != (rip_pkt_hdrlen(ifa) + RIP_BLOCK_LENGTH)) return; struct rip_block b = { .no_af = 1 }; if (!rip_get_block(p, pos, &b)) return; /* Special case - infinity metric, for RIPng also zero prefix */ if ((b.metric != p->infinity) || (rip_is_ng(p) && !net_zero_ip6((net_addr_ip6 *) &b.net))) return; /* We do nothing if TX is already active */ if (ifa->tx_active) { TRACE(D_EVENTS, "Skipping request from %I on %s, TX is busy", from->nbr->addr, ifa->iface->name); return; } if (!ifa->cf->passive) rip_send_table(p, ifa, from->nbr->addr, 0); } static int rip_send_response(struct rip_proto *p, struct rip_iface *ifa) { if (! ifa->tx_active) return 0; /* In demand circuit mode, we may wait for ACK */ if (ifa->tx_pending) return 0; struct rip_packet *pkt = rip_tx_buffer(ifa); byte *pos = (byte *) pkt + rip_pkt_hdrlen(ifa); byte *max = (byte *) pkt + ifa->tx_plen - (rip_is_v2(p) ? RIP_BLOCK_LENGTH : 2*RIP_BLOCK_LENGTH); ip_addr last_next_hop = IPA_NONE; btime now_ = current_time(); int send = 0; rip_fill_header(ifa, pkt, RIP_CMD_RESPONSE); if (ifa->cf->demand_circuit) { pkt->command = RIP_CMD_UPDATE_RESPONSE; rip_fill_update_hdr(pkt, ifa->tx_flush, ifa->tx_seqnum); } FIB_ITERATE_START(&p->rtable, &ifa->tx_fit, struct rip_entry, en) { /* Dummy entries */ if (!en->valid) goto next_entry; /* Stale entries that should be removed */ if ((en->valid == RIP_ENTRY_STALE) && ((en->changed + ifa->cf->garbage_time) <= now_)) goto next_entry; /* Triggered updates */ if (en->changed < ifa->tx_changed) goto next_entry; /* Not enough space for current entry */ if (pos > max) { FIB_ITERATE_PUT(&ifa->tx_fit); goto send_pkt; } struct rip_block rte = { .metric = en->metric, .tag = en->tag }; net_copy(&rte.net, en->n.addr); if (en->iface == ifa->iface) rte.next_hop = en->next_hop; if (rip_is_v2(p) && (ifa->cf->version == RIP_V1)) { /* Skipping subnets (i.e. not hosts, classful networks or default route) */ if (ip4_masklen(ip4_class_mask(net4_prefix(&rte.net))) != rte.net.pxlen) goto next_entry; rte.tag = 0; rte.net.pxlen = 0; rte.next_hop = IPA_NONE; } /* Split horizon */ if (en->from == ifa->iface && ifa->cf->split_horizon) { if (ifa->cf->poison_reverse) { rte.metric = p->infinity; rte.next_hop = IPA_NONE; } else goto next_entry; } // TRACE(D_PACKETS, " %N -> %I metric %d", &rte.net, rte.next_hop, rte.metric); /* RIPng next hop entry */ if (rip_is_ng(p) && !ipa_equal(rte.next_hop, last_next_hop)) { last_next_hop = rte.next_hop; rip_put_next_hop(p, pos, &rte); pos += RIP_BLOCK_LENGTH; } rip_put_block(p, pos, &rte); pos += RIP_BLOCK_LENGTH; send = 1; next_entry: ; } FIB_ITERATE_END; if (send) { FIB_ITERATE_PUT_END(&ifa->tx_fit); goto send_pkt; } /* Do not send empty packet */ ifa->tx_active = 0; /* Unlink second iterator */ FIB_ITERATE_UNLINK(&ifa->tx_done, &p->rtable); return 0; send_pkt: /* Waiting for ack or timeout */ if (ifa->cf->demand_circuit) { ifa->tx_pending = 1; rip_kick_rxmt_timer(ifa); } TRACE(D_PACKETS, "Sending response via %s", ifa->iface->name); return rip_send_to(p, ifa, pkt, pos - (byte *) pkt, ifa->tx_addr); } /** * rip_send_table - RIP interface timer hook * @p: RIP instance * @ifa: RIP interface * @addr: destination IP address * @changed: time limit for triggered updates * * The function activates an update session and starts sending routing update * packets (using rip_send_response()). The session may be finished during the * call or may continue in rip_tx_hook() until all appropriate routes are * transmitted. Note that there may be at most one active update session per * interface, the function will terminate the old active session before * activating the new one. */ void rip_send_table(struct rip_proto *p, struct rip_iface *ifa, ip_addr addr, btime changed) { DBG("RIP: Opening TX session to %I on %s\n", addr, ifa->iface->name); rip_reset_tx_session(p, ifa); ifa->tx_active = 1; ifa->tx_addr = addr; ifa->tx_changed = changed; FIB_ITERATE_INIT(&ifa->tx_fit, &p->rtable); FIB_ITERATE_INIT(&ifa->tx_done, &p->rtable); if (ifa->cf->demand_circuit) ifa->tx_flush = ! changed; rip_update_csn(p, ifa); while (rip_send_response(p, ifa) > 0) ; } static void rip_tx_hook(sock *sk) { struct rip_iface *ifa = sk->data; struct rip_proto *p = ifa->rip; DBG("RIP: TX hook called (iface %s, src %I, dst %I)\n", sk->iface->name, sk->saddr, sk->daddr); while (rip_send_response(p, ifa) > 0) ; } static void rip_err_hook(sock *sk, int err) { struct rip_iface *ifa = sk->data; struct rip_proto *p = ifa->rip; log(L_ERR "%s: Socket error on %s: %M", p->p.name, ifa->iface->name, err); rip_reset_tx_session(p, ifa); } static void rip_receive_response(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint plen, struct rip_neighbor *from) { struct rip_block rte = {}; const char *err_dsc = NULL; TRACE(D_PACKETS, "Response received from %I on %s", from->nbr->addr, ifa->iface->name); byte *pos = (byte *) pkt + rip_pkt_hdrlen(ifa); byte *end = (byte *) pkt + plen; btime expires = current_time() + ifa->cf->timeout_time; if (pkt->command == RIP_CMD_UPDATE_RESPONSE) { struct rip_update_hdr *hdr = rip_get_update_hdr(pkt); rip_send_ack(p, ifa, hdr->flush, ntohs(hdr->seqnum)); expires = TIME_INFINITY; /* Handle flush bit */ if (hdr->flush) { /* Flush old routes */ rip_flush_table(p, from); /* Acknowledge pending request */ ifa->req_pending = 0; } } for (; pos < end; pos += RIP_BLOCK_LENGTH) { /* Find next regular RTE */ if (!rip_get_block(p, pos, &rte)) continue; if (rip_is_v2(p) && (pkt->version == RIP_V1)) { if (ifa->cf->check_zero && (rte.tag || rte.net.pxlen || ipa_nonzero(rte.next_hop))) SKIP("RIPv1 reserved field is nonzero"); rte.tag = 0; rte.net.pxlen = ip4_masklen(ip4_class_mask(net4_prefix(&rte.net))); rte.next_hop = IPA_NONE; } if (rte.net.pxlen == 255) SKIP("invalid prefix length"); net_normalize(&rte.net); int c = net_classify(&rte.net); if ((c < 0) || !(c & IADDR_HOST) || ((c & IADDR_SCOPE_MASK) <= SCOPE_LINK)) SKIP("invalid prefix"); if (rte.metric > p->infinity) SKIP("invalid metric"); if (ipa_nonzero(rte.next_hop)) { neighbor *nbr = neigh_find(&p->p, rte.next_hop, ifa->iface, 0); if (!nbr || (nbr->scope <= 0)) rte.next_hop = IPA_NONE; } // TRACE(D_PACKETS, " %N -> %I metric %d", &rte.net.n, rte.next_hop, rte.metric); rte.metric += ifa->cf->metric; if (rte.metric < p->infinity) { struct rip_rte new = { .from = from, .next_hop = ipa_nonzero(rte.next_hop) ? rte.next_hop : from->nbr->addr, .metric = rte.metric, .tag = rte.tag, .expires = expires }; rip_update_rte(p, &rte.net, &new); } else rip_withdraw_rte(p, &rte.net, from); continue; skip: LOG_RTE("Ignoring route %N received from %I - %s", &rte.net, from->nbr->addr, err_dsc); } } int rip_send_flush(struct rip_proto *p, struct rip_iface *ifa) { /* Caller should handle cleanup of pending response */ if (ifa->tx_pending) return 0; struct rip_packet *pkt = rip_tx_buffer(ifa); rip_fill_header(ifa, pkt, RIP_CMD_UPDATE_RESPONSE); rip_fill_update_hdr(pkt, 1, ifa->tx_seqnum); /* We suppose that iface is going down, so we do not expect ACK */ ifa->tx_seqnum++; TRACE(D_PACKETS, "Sending response via %s", ifa->iface->name); return rip_send_to(p, ifa, pkt, rip_pkt_hdrlen(ifa), ifa->tx_addr); } static int rip_send_ack(struct rip_proto *p, struct rip_iface *ifa, uint flush, uint seqnum) { struct rip_packet *pkt = rip_tx_buffer(ifa); rip_fill_header(ifa, pkt, RIP_CMD_UPDATE_ACK); rip_fill_update_hdr(pkt, flush, seqnum); TRACE(D_PACKETS, "Sending acknowledge via %s", ifa->iface->name); return rip_send_to(p, ifa, pkt, rip_pkt_hdrlen(ifa), ifa->tx_addr); } static void rip_receive_ack(struct rip_proto *p, struct rip_iface *ifa, struct rip_packet *pkt, uint plen UNUSED, struct rip_neighbor *from) { TRACE(D_PACKETS, "Acknowledge received from %I on %s", from->nbr->addr, ifa->iface->name); struct rip_update_hdr *hdr = rip_get_update_hdr(pkt); uint seqnum = ntohs(hdr->seqnum); if (! ifa->tx_active || ! ifa->tx_pending) { LOG_PKT("Bad acknowledge packet from %I via %s - no pending response", from->nbr->addr, ifa->iface->name); return; } if (seqnum != ifa->tx_seqnum) { LOG_PKT("Bad acknowledge packet from %I via %s - " "mismatched sequence number (rcv %u, old %u)", from->nbr->addr, ifa->iface->name, seqnum, (uint) ifa->tx_seqnum); return; } /* Move acked position */ FIB_ITERATE_COPY(&ifa->tx_done, &ifa->tx_fit, &p->rtable); /* Packet is no longer pending */ ifa->tx_pending = 0; ifa->tx_seqnum++; /* Next one does not have flush bit */ ifa->tx_flush = 0; rip_send_response(p, ifa); } /** * rip_rxmt_timeout - RIP retransmission timer hook * @t: timer * * In Demand Circuit mode, update packets must be acknowledged to ensure * reliability. If they are not acknowledged, we need to retransmit them. */ void rip_rxmt_timeout(timer *t) { struct rip_iface *ifa = t->data; struct rip_proto *p = ifa->rip; if (ifa->req_pending) rip_send_request(p, ifa); if (ifa->tx_pending) { /* Revert to acked position */ FIB_ITERATE_COPY(&ifa->tx_fit, &ifa->tx_done, &p->rtable); /* Packet is no longer pending */ ifa->tx_pending = 0; ifa->tx_seqnum++; rip_send_response(p, ifa); } } static int rip_rx_hook(sock *sk, uint len) { struct rip_iface *ifa = sk->data; struct rip_proto *p = ifa->rip; const char *err_dsc = NULL; uint err_val = 0; if (sk->lifindex != sk->iface->index) return 1; DBG("RIP: RX hook called (iface %s, src %I, dst %I)\n", sk->iface->name, sk->faddr, sk->laddr); /* Silently ignore my own packets */ if (ipa_equal(sk->faddr, sk->saddr)) return 1; if (rip_is_ng(p) && !ipa_is_link_local(sk->faddr)) DROP1("wrong src address"); struct rip_neighbor *n = rip_get_neighbor(p, &sk->faddr, ifa); if (!n) DROP1("not from neighbor"); if ((ifa->cf->ttl_security == 1) && (sk->rcv_ttl < 255)) DROP("wrong TTL", sk->rcv_ttl); if (sk->fport != sk->dport) DROP("wrong src port", sk->fport); if (len < sizeof(struct rip_packet)) DROP("too short", len); if (sk->flags & SKF_TRUNCATED) DROP("truncated", len); struct rip_packet *pkt = (struct rip_packet *) sk->rbuf; uint pkt_len = len; uint hdr_len = sizeof(struct rip_packet); uint update_msg = 0; if (!pkt->version || (ifa->cf->version_only && (pkt->version != ifa->cf->version))) DROP("wrong version", pkt->version); /* Update packets (RFC 2091) have additional header even before auth data */ if ((pkt->command == RIP_CMD_UPDATE_REQUEST) || (pkt->command == RIP_CMD_UPDATE_RESPONSE) || (pkt->command == RIP_CMD_UPDATE_ACK)) { hdr_len += sizeof(struct rip_update_hdr); if (len < hdr_len) DROP("too short", len); struct rip_update_hdr *hdr = rip_get_update_hdr(pkt); if (hdr->version != RIP_UPDATE_VERSION) DROP("wrong update header version", hdr->version); if (hdr->flush > 1) DROP("wrong flush value", hdr->flush); update_msg = 1; } /* rip_check_authentication() has its own error logging */ if (rip_is_v2(p) && !rip_check_authentication(p, ifa, pkt, &pkt_len, hdr_len, n)) return 1; if ((pkt_len - hdr_len) % RIP_BLOCK_LENGTH) DROP("invalid length", pkt_len); if (update_msg != ifa->cf->demand_circuit) DROP("demand circuit mode mismatch", update_msg); n->last_seen = current_time(); rip_update_bfd(p, n); switch (pkt->command) { case RIP_CMD_REQUEST: case RIP_CMD_UPDATE_REQUEST: rip_receive_request(p, ifa, pkt, pkt_len, n); break; case RIP_CMD_RESPONSE: case RIP_CMD_UPDATE_RESPONSE: rip_receive_response(p, ifa, pkt, pkt_len, n); break; case RIP_CMD_UPDATE_ACK: rip_receive_ack(p, ifa, pkt, pkt_len, n); break; default: DROP("unknown command", pkt->command); } return 1; drop: LOG_PKT("Bad packet from %I via %s - %s (%u)", sk->faddr, sk->iface->name, err_dsc, err_val); return 1; } int rip_open_socket(struct rip_iface *ifa) { struct rip_proto *p = ifa->rip; sock *sk = sk_new(p->p.pool); sk->type = SK_UDP; sk->subtype = rip_is_v2(p) ? SK_IPV4 : SK_IPV6; sk->sport = ifa->cf->port; sk->dport = ifa->cf->port; sk->iface = ifa->iface; sk->saddr = rip_is_v2(p) ? ifa->iface->addr4->ip : ifa->iface->llv6->ip; sk->vrf = p->p.vrf; sk->rx_hook = rip_rx_hook; sk->tx_hook = rip_tx_hook; sk->err_hook = rip_err_hook; sk->data = ifa; sk->tos = ifa->cf->tx_tos; sk->priority = ifa->cf->tx_priority; sk->ttl = ifa->cf->ttl_security ? 255 : 1; sk->flags = SKF_LADDR_RX | ((ifa->cf->ttl_security == 1) ? SKF_TTL_RX : 0); /* sk->rbsize and sk->tbsize are handled in rip_iface_update_buffers() */ if (sk_open(sk) < 0) goto err; if (ifa->cf->mode == RIP_IM_MULTICAST) { if (sk_setup_multicast(sk) < 0) goto err; if (sk_join_group(sk, ifa->addr) < 0) goto err; } else /* Broadcast */ { if (sk_setup_broadcast(sk) < 0) goto err; if (ipa_zero(ifa->addr)) { sk->err = "Missing broadcast address"; goto err; } } ifa->sk = sk; return 1; err: sk_log_error(sk, p->p.name); rfree(sk); return 0; } bird-2.0.8/proto/rip/config.Y0000664000175000017500000001625114025744326014725 0ustar feelafeela/* * BIRD -- RIP Configuration * * (c) 1998--1999 Pavel Machek * (c) 2004--2013 Ondrej Filip * (c) 2009--2015 Ondrej Zajicek * (c) 2009--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "proto/rip/rip.h" #include "nest/iface.h" CF_DEFINES #define RIP_CFG ((struct rip_config *) this_proto) #define RIP_IFACE ((struct rip_iface_config *) this_ipatt) static inline int rip_cfg_is_v2(void) { return RIP_CFG->rip2; } static inline int rip_cfg_is_ng(void) { return ! RIP_CFG->rip2; } static inline void rip_check_auth(void) { if (rip_cfg_is_ng()) cf_error("Authentication not supported in RIPng"); } CF_DECLS CF_KEYWORDS(RIP, NG, ECMP, LIMIT, WEIGHT, INFINITY, METRIC, UPDATE, TIMEOUT, GARBAGE, RETRANSMIT, PORT, ADDRESS, MODE, BROADCAST, MULTICAST, PASSIVE, VERSION, SPLIT, HORIZON, POISON, REVERSE, CHECK, ZERO, TIME, BFD, AUTHENTICATION, NONE, PLAINTEXT, CRYPTOGRAPHIC, MD5, TTL, SECURITY, RX, TX, BUFFER, LENGTH, PRIORITY, ONLY, LINK, DEMAND, CIRCUIT, RIP_METRIC, RIP_TAG) %type rip_variant rip_auth CF_GRAMMAR proto: rip_proto ; rip_variant: RIP { $$ = 1; } | RIP NG { $$ = 0; } ; rip_proto_start: proto_start rip_variant { this_proto = proto_config_new(&proto_rip, $1); this_proto->net_type = $2 ? NET_IP4 : NET_IP6; init_list(&RIP_CFG->patt_list); RIP_CFG->rip2 = $2; RIP_CFG->ecmp = rt_default_ecmp; RIP_CFG->infinity = RIP_DEFAULT_INFINITY; RIP_CFG->min_timeout_time = 60 S_; RIP_CFG->max_garbage_time = 60 S_; }; rip_proto_item: proto_item | proto_channel | ECMP bool { RIP_CFG->ecmp = $2 ? RIP_DEFAULT_ECMP_LIMIT : 0; } | ECMP bool LIMIT expr { RIP_CFG->ecmp = $2 ? $4 : 0; } | INFINITY expr { RIP_CFG->infinity = $2; } | INTERFACE rip_iface ; rip_proto_opts: /* empty */ | rip_proto_opts rip_proto_item ';' ; rip_proto: rip_proto_start proto_name '{' rip_proto_opts '}'; rip_iface_start: { this_ipatt = cfg_allocz(sizeof(struct rip_iface_config)); add_tail(&RIP_CFG->patt_list, NODE this_ipatt); init_list(&this_ipatt->ipn_list); reset_passwords(); RIP_IFACE->metric = 1; RIP_IFACE->port = rip_cfg_is_v2() ? RIP_PORT : RIP_NG_PORT; RIP_IFACE->version = rip_cfg_is_v2() ? RIP_V2 : RIP_V1; RIP_IFACE->split_horizon = 1; RIP_IFACE->poison_reverse = 1; RIP_IFACE->check_zero = 1; RIP_IFACE->check_link = 1; RIP_IFACE->ttl_security = rip_cfg_is_v2() ? 0 : 1; RIP_IFACE->rx_buffer = rip_cfg_is_v2() ? RIP_MAX_PKT_LENGTH : 0; RIP_IFACE->tx_length = rip_cfg_is_v2() ? RIP_MAX_PKT_LENGTH : 0; RIP_IFACE->tx_tos = IP_PREC_INTERNET_CONTROL; RIP_IFACE->tx_priority = sk_priority_control; RIP_IFACE->update_time = RIP_DEFAULT_UPDATE_TIME; RIP_IFACE->timeout_time = RIP_DEFAULT_TIMEOUT_TIME; RIP_IFACE->garbage_time = RIP_DEFAULT_GARBAGE_TIME; RIP_IFACE->rxmt_time = RIP_DEFAULT_RXMT_TIME; }; rip_iface_finish: { /* Default mode is broadcast for RIPv1, multicast for RIPv2 and RIPng */ if (!RIP_IFACE->mode) RIP_IFACE->mode = (rip_cfg_is_v2() && (RIP_IFACE->version == RIP_V1)) ? RIP_IM_BROADCAST : RIP_IM_MULTICAST; RIP_IFACE->passwords = get_passwords(); if (!RIP_IFACE->auth_type != !RIP_IFACE->passwords) log(L_WARN "Authentication and password options should be used together"); if (RIP_IFACE->passwords) { struct password_item *pass; WALK_LIST(pass, *RIP_IFACE->passwords) { if (pass->alg && (RIP_IFACE->auth_type != RIP_AUTH_CRYPTO)) cf_error("Password algorithm option requires cryptographic authentication"); /* Set default crypto algorithm (MD5) */ if (!pass->alg && (RIP_IFACE->auth_type == RIP_AUTH_CRYPTO)) pass->alg = ALG_MD5; } } RIP_CFG->min_timeout_time = MIN_(RIP_CFG->min_timeout_time, RIP_IFACE->timeout_time); RIP_CFG->max_garbage_time = MAX_(RIP_CFG->max_garbage_time, RIP_IFACE->garbage_time); }; rip_iface_item: METRIC expr { RIP_IFACE->metric = $2; if (($2<1) || ($2>255)) cf_error("Metric must be in range 1-255"); } | MODE MULTICAST { RIP_IFACE->mode = RIP_IM_MULTICAST; } | MODE BROADCAST { RIP_IFACE->mode = RIP_IM_BROADCAST; if (rip_cfg_is_ng()) cf_error("Broadcast not supported in RIPng"); } | PASSIVE bool { RIP_IFACE->passive = $2; } | ADDRESS ipa { RIP_IFACE->address = $2; if (ipa_is_ip4($2) != rip_cfg_is_v2()) cf_error("IP address version mismatch"); } | PORT expr { RIP_IFACE->port = $2; if (($2<1) || ($2>65535)) cf_error("Invalid port number"); } | VERSION expr { RIP_IFACE->version = $2; if (rip_cfg_is_ng()) cf_error("Version not supported in RIPng"); if (($2 != RIP_V1) && ($2 != RIP_V2)) cf_error("Unsupported version"); } | VERSION ONLY bool { RIP_IFACE->version_only = $3; } | SPLIT HORIZON bool { RIP_IFACE->split_horizon = $3; } | POISON REVERSE bool { RIP_IFACE->poison_reverse = $3; } | CHECK ZERO bool { RIP_IFACE->check_zero = $3; } | DEMAND CIRCUIT bool { RIP_IFACE->demand_circuit = $3; } | UPDATE TIME expr { RIP_IFACE->update_time = $3 S_; if ($3<=0) cf_error("Update time must be positive"); } | TIMEOUT TIME expr { RIP_IFACE->timeout_time = $3 S_; if ($3<=0) cf_error("Timeout time must be positive"); } | GARBAGE TIME expr { RIP_IFACE->garbage_time = $3 S_; if ($3<=0) cf_error("Garbage time must be positive"); } | RETRANSMIT TIME expr_us { RIP_IFACE->rxmt_time = $3; if ($3<=0) cf_error("Retransmit time must be positive"); } | ECMP WEIGHT expr { RIP_IFACE->ecmp_weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("ECMP weight must be in range 1-256"); } | RX BUFFER expr { RIP_IFACE->rx_buffer = $3; if (($3<256) || ($3>65535)) cf_error("RX length must be in range 256-65535"); } | TX LENGTH expr { RIP_IFACE->tx_length = $3; if (($3<256) || ($3>65535)) cf_error("TX length must be in range 256-65535"); } | TX tos { RIP_IFACE->tx_tos = $2; } | TX PRIORITY expr { RIP_IFACE->tx_priority = $3; } | TTL SECURITY bool { RIP_IFACE->ttl_security = $3; } | TTL SECURITY TX ONLY { RIP_IFACE->ttl_security = 2; } | CHECK LINK bool { RIP_IFACE->check_link = $3; } | BFD bool { RIP_IFACE->bfd = $2; cf_check_bfd($2); } | AUTHENTICATION rip_auth { RIP_IFACE->auth_type = $2; if ($2) rip_check_auth(); } | password_list { rip_check_auth(); } ; rip_auth: NONE { $$ = RIP_AUTH_NONE; } | PLAINTEXT { $$ = RIP_AUTH_PLAIN; } | CRYPTOGRAPHIC { $$ = RIP_AUTH_CRYPTO; } | MD5 { $$ = RIP_AUTH_CRYPTO; } /* For backward compatibility */ ; rip_iface_opts: /* empty */ | rip_iface_opts rip_iface_item ';' ; rip_iface_opt_list: /* empty */ | '{' rip_iface_opts '}' ; rip_iface: rip_iface_start iface_patt_list_nopx rip_iface_opt_list rip_iface_finish; dynamic_attr: RIP_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_RIP_METRIC); } ; dynamic_attr: RIP_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_RIP_TAG); } ; CF_CLI_HELP(SHOW RIP, ..., [[Show information about RIP protocol]]); CF_CLI(SHOW RIP INTERFACES, optproto opttext, [] [\"\"], [[Show information about RIP interfaces]]) { PROTO_WALK_CMD($4, &proto_rip, p) rip_show_interfaces(p, $5); }; CF_CLI(SHOW RIP NEIGHBORS, optproto opttext, [] [\"\"], [[Show information about RIP neighbors]]) { PROTO_WALK_CMD($4, &proto_rip, p) rip_show_neighbors(p, $5); }; CF_CODE CF_END bird-2.0.8/proto/rip/Makefile0000664000175000017500000000016214025744326014760 0ustar feelafeelasrc := packets.c rip.c obj := $(src-o-files) $(all-daemon) $(cf-local) tests_objs := $(tests_objs) $(src-o-files)bird-2.0.8/proto/rip/Doc0000664000175000017500000000002414025744326013745 0ustar feelafeelaS rip.c S packets.c bird-2.0.8/proto/radv/0000775000175000017500000000000014025744326013463 5ustar feelafeelabird-2.0.8/proto/radv/radv.h0000664000175000017500000001553514025744326014601 0ustar feelafeela/* * BIRD -- Router Advertisement * * (c) 2011--2019 Ondrej Zajicek * (c) 2011--2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_RADV_H_ #define _BIRD_RADV_H_ #include "nest/bird.h" #include "lib/ip.h" #include "lib/lists.h" #include "lib/socket.h" #include "lib/timer.h" #include "lib/resource.h" #include "nest/protocol.h" #include "nest/iface.h" #include "nest/route.h" #include "nest/cli.h" #include "nest/locks.h" #include "conf/conf.h" #include "lib/string.h" #define ICMPV6_PROTO 58 #define ICMPV6_RS 133 #define ICMPV6_RA 134 #define MAX_INITIAL_RTR_ADVERTISEMENTS 3 #define MAX_INITIAL_RTR_ADVERT_INTERVAL (16 S_) #define DEFAULT_MAX_RA_INT 600 #define DEFAULT_MIN_DELAY 3 #define DEFAULT_CURRENT_HOP_LIMIT 64 #define DEFAULT_VALID_LIFETIME 86400 #define DEFAULT_PREFERRED_LIFETIME 14400 #define DEFAULT_DNS_LIFETIME_MULT 3 struct radv_config { struct proto_config c; list patt_list; /* List of iface configs (struct radv_iface_config) */ list pref_list; /* Global list of prefix configs (struct radv_prefix_config) */ list rdnss_list; /* Global list of RDNSS configs (struct radv_rdnss_config) */ list dnssl_list; /* Global list of DNSSL configs (struct radv_dnssl_config) */ net_addr trigger; /* Prefix of a trigger route, if defined */ u8 propagate_routes; /* Do we propagate more specific routes (RFC 4191)? */ u32 max_linger_time; /* Maximum of interface route_linger_time */ }; struct radv_iface_config { struct iface_patt i; list pref_list; /* Local list of prefix configs (struct radv_prefix_config) */ list rdnss_list; /* Local list of RDNSS configs (struct radv_rdnss_config) */ list dnssl_list; /* Local list of DNSSL configs (struct radv_dnssl_config) */ u32 min_ra_int; /* Standard options from RFC 4861 */ u32 max_ra_int; u32 min_delay; u8 solicited_ra_unicast; /* Send solicited RAs as unicast */ u32 prefix_linger_time; /* How long we advertise dead prefixes with lifetime 0 */ u32 route_linger_time; /* How long we advertise dead routes with lifetime 0 */ u8 rdnss_local; /* Global list is not used for RDNSS */ u8 dnssl_local; /* Global list is not used for DNSSL */ u8 managed; /* Standard options from RFC 4861 */ u8 other_config; u32 link_mtu; u32 reachable_time; u32 retrans_timer; u32 current_hop_limit; u32 default_lifetime; u32 route_lifetime; /* Lifetime for the RFC 4191 routes */ u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */ u8 route_lifetime_sensitive; /* Whether route_lifetime depends on trigger */ u8 default_preference; /* Default Router Preference (RFC 4191) */ u8 route_preference; /* Specific Route Preference (RFC 4191) */ }; struct radv_prefix_config { node n; net_addr_ip6 prefix; u8 skip; /* Do not include this prefix to RA */ u8 onlink; /* Standard options from RFC 4861 */ u8 autonomous; u32 valid_lifetime; u32 preferred_lifetime; u8 valid_lifetime_sensitive; /* Whether valid_lifetime depends on trigger */ u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */ }; struct radv_rdnss_config { node n; u32 lifetime; /* Valid if lifetime_mult is 0 */ u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */ ip6_addr server; /* IP address of recursive DNS server */ }; struct radv_dnssl_config { node n; u32 lifetime; /* Valid if lifetime_mult is 0 */ u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */ u8 dlen_first; /* Length of first label in domain */ u8 dlen_all; /* Both dlen_ filled in radv_process_domain() */ const char *domain; /* Domain for DNS search list, in processed form */ }; /* * One more specific route as per RFC 4191. * * Note that it does *not* contain the next hop field. The next hop is always * the router sending the advertisment and the more specific route only allows * overriding the preference of the route. */ struct radv_route { u32 lifetime; /* Lifetime from an attribute */ u8 lifetime_set; /* Whether lifetime is defined */ u8 preference; /* Preference of the route, RA_PREF_* */ u8 preference_set; /* Whether preference is defined */ u8 valid; /* Whethe route is valid or withdrawn */ btime changed; /* Last time when the route changed */ struct fib_node n; }; struct radv_proto { struct proto p; list iface_list; /* List of active ifaces */ u8 valid; /* Router is valid for forwarding, used for shutdown */ u8 active; /* Whether radv is active w.r.t. triggers */ u8 fib_up; /* FIB table (routes) is initialized */ struct fib routes; /* FIB table of specific routes (struct radv_route) */ btime prune_time; /* Next time of route table pruning */ }; struct radv_prefix /* One prefix we advertise */ { node n; net_addr_ip6 prefix; u8 valid; /* Is the prefix valid? If not, we advertise it with 0 lifetime, so clients stop using it */ u8 mark; /* A temporary mark for processing */ btime changed; /* Last time when the prefix changed */ struct radv_prefix_config *cf; /* The config tied to this prefix */ }; struct radv_iface { node n; struct radv_proto *ra; struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */ struct iface *iface; struct ifa *addr; /* Link-local address of iface */ struct pool *pool; /* A pool for interface-specific things */ list prefixes; /* The prefixes we advertise (struct radv_prefix) */ btime prune_time; /* Next time of prefix list pruning */ btime valid_time; /* Cached packet is valid until first linger timeout */ timer *timer; struct object_lock *lock; sock *sk; btime last; /* Time of last sending of RA */ u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */ byte initial; /* How many RAs are still to be sent as initial */ }; #define RA_EV_INIT 1 /* Switch to initial mode */ #define RA_EV_CHANGE 2 /* Change of options or prefixes */ #define RA_EV_RS 3 /* Received RS */ /* Default Router Preferences (RFC 4191) */ #define RA_PREF_LOW 0x18 #define RA_PREF_MEDIUM 0x00 #define RA_PREF_HIGH 0x08 #define RA_PREF_MASK 0x18 /* Attributes */ #define EA_RA_PREFERENCE EA_CODE(PROTOCOL_RADV, 0) #define EA_RA_LIFETIME EA_CODE(PROTOCOL_RADV, 1) #ifdef LOCAL_DEBUG #define RADV_FORCE_DEBUG 1 #else #define RADV_FORCE_DEBUG 0 #endif #define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \ log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0) /* Invalidate cached RA packet */ static inline void radv_invalidate(struct radv_iface *ifa) { ifa->plen = 0; } /* radv.c */ void radv_iface_notify(struct radv_iface *ifa, int event); /* packets.c */ int radv_process_domain(struct radv_dnssl_config *cf); void radv_send_ra(struct radv_iface *ifa, ip_addr to); int radv_sk_open(struct radv_iface *ifa); #endif /* _BIRD_RADV_H_ */ bird-2.0.8/proto/radv/radv.c0000664000175000017500000004312714025744326014572 0ustar feelafeela/* * BIRD -- Router Advertisement * * (c) 2011--2019 Ondrej Zajicek * (c) 2011--2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "radv.h" /** * DOC: Router Advertisements * * The RAdv protocol is implemented in two files: |radv.c| containing the * interface with BIRD core and the protocol logic and |packets.c| handling low * level protocol stuff (RX, TX and packet formats). The protocol does not * export any routes. * * The RAdv is structured in the usual way - for each handled interface there is * a structure &radv_iface that contains a state related to that interface * together with its resources (a socket, a timer). There is also a prepared RA * stored in a TX buffer of the socket associated with an iface. These iface * structures are created and removed according to iface events from BIRD core * handled by radv_if_notify() callback. * * The main logic of RAdv consists of two functions: radv_iface_notify(), which * processes asynchronous events (specified by RA_EV_* codes), and radv_timer(), * which triggers sending RAs and computes the next timeout. * * The RAdv protocol could receive routes (through radv_preexport() and * radv_rt_notify()), but only the configured trigger route is tracked (in * &active var). When a radv protocol is reconfigured, the connected routing * table is examined (in radv_check_active()) to have proper &active value in * case of the specified trigger prefix was changed. * * Supported standards: * RFC 4861 - main RA standard * RFC 4191 - Default Router Preferences and More-Specific Routes * RFC 6106 - DNS extensions (RDDNS, DNSSL) */ static void radv_prune_prefixes(struct radv_iface *ifa); static void radv_prune_routes(struct radv_proto *p); static void radv_timer(timer *tm) { struct radv_iface *ifa = tm->data; struct radv_proto *p = ifa->ra; btime now = current_time(); RADV_TRACE(D_EVENTS, "Timer fired on %s", ifa->iface->name); if (ifa->prune_time <= now) radv_prune_prefixes(ifa); if (p->prune_time <= now) radv_prune_routes(p); radv_send_ra(ifa, IPA_NONE); /* Update timer */ ifa->last = now; btime t = ifa->cf->min_ra_int S; btime r = (ifa->cf->max_ra_int - ifa->cf->min_ra_int) S; t += random() % (r + 1); if (ifa->initial) { t = MIN(t, MAX_INITIAL_RTR_ADVERT_INTERVAL); ifa->initial--; } tm_start(ifa->timer, t); } static struct radv_prefix_config default_prefix = { .onlink = 1, .autonomous = 1, .valid_lifetime = DEFAULT_VALID_LIFETIME, .preferred_lifetime = DEFAULT_PREFERRED_LIFETIME }; static struct radv_prefix_config dead_prefix = { }; /* Find a corresponding config for the given prefix */ static struct radv_prefix_config * radv_prefix_match(struct radv_iface *ifa, net_addr_ip6 *px) { struct radv_proto *p = ifa->ra; struct radv_config *cf = (struct radv_config *) (p->p.cf); struct radv_prefix_config *pc; WALK_LIST(pc, ifa->cf->pref_list) if (net_in_net_ip6(px, &pc->prefix)) return pc; WALK_LIST(pc, cf->pref_list) if (net_in_net_ip6(px, &pc->prefix)) return pc; return &default_prefix; } /* * Go through the list of prefixes, compare them with configs and decide if we * want them or not. */ static void radv_prepare_prefixes(struct radv_iface *ifa) { struct radv_proto *p = ifa->ra; struct radv_prefix *pfx, *next; btime now = current_time(); /* First mark all the prefixes as unused */ WALK_LIST(pfx, ifa->prefixes) pfx->mark = 0; /* Find all the prefixes we want to use and make sure they are in the list. */ struct ifa *addr; WALK_LIST(addr, ifa->iface->addrs) { if ((addr->prefix.type != NET_IP6) || (addr->scope <= SCOPE_LINK)) continue; net_addr_ip6 *prefix = (void *) &addr->prefix; struct radv_prefix_config *pc = radv_prefix_match(ifa, prefix); if (!pc || pc->skip) continue; /* Do we have it already? */ struct radv_prefix *existing = NULL; WALK_LIST(pfx, ifa->prefixes) if (net_equal_ip6(&pfx->prefix, prefix)) { existing = pfx; break; } if (!existing) { RADV_TRACE(D_EVENTS, "Adding new prefix %N on %s", prefix, ifa->iface->name); existing = mb_allocz(ifa->pool, sizeof *existing); net_copy_ip6(&existing->prefix, prefix); add_tail(&ifa->prefixes, NODE existing); } /* * Update the information (it may have changed, or even bring a prefix back * to life). */ existing->valid = 1; existing->changed = now; existing->mark = 1; existing->cf = pc; } WALK_LIST_DELSAFE(pfx, next, ifa->prefixes) { if (pfx->valid && !pfx->mark) { RADV_TRACE(D_EVENTS, "Invalidating prefix %N on %s", &pfx->prefix, ifa->iface->name); pfx->valid = 0; pfx->changed = now; pfx->cf = &dead_prefix; } } } static void radv_prune_prefixes(struct radv_iface *ifa) { struct radv_proto *p = ifa->ra; btime now = current_time(); btime next = TIME_INFINITY; btime expires = 0; struct radv_prefix *px, *pxn; WALK_LIST_DELSAFE(px, pxn, ifa->prefixes) { if (!px->valid) { expires = px->changed + ifa->cf->prefix_linger_time S; if (expires <= now) { RADV_TRACE(D_EVENTS, "Removing prefix %N on %s", &px->prefix, ifa->iface->name); rem_node(NODE px); mb_free(px); } else next = MIN(next, expires); } } ifa->prune_time = next; } static char* ev_name[] = { NULL, "Init", "Change", "RS" }; void radv_iface_notify(struct radv_iface *ifa, int event) { struct radv_proto *p = ifa->ra; if (!ifa->sk) return; RADV_TRACE(D_EVENTS, "Event %s on %s", ev_name[event], ifa->iface->name); switch (event) { case RA_EV_CHANGE: radv_invalidate(ifa); /* fallthrough */ case RA_EV_INIT: ifa->initial = MAX_INITIAL_RTR_ADVERTISEMENTS; radv_prepare_prefixes(ifa); radv_prune_prefixes(ifa); break; case RA_EV_RS: break; } /* Update timer */ btime t = ifa->last + ifa->cf->min_delay S - current_time(); tm_start(ifa->timer, t); } static void radv_iface_notify_all(struct radv_proto *p, int event) { struct radv_iface *ifa; WALK_LIST(ifa, p->iface_list) radv_iface_notify(ifa, event); } static struct radv_iface * radv_iface_find(struct radv_proto *p, struct iface *what) { struct radv_iface *ifa; WALK_LIST(ifa, p->iface_list) if (ifa->iface == what) return ifa; return NULL; } static void radv_iface_add(struct object_lock *lock) { struct radv_iface *ifa = lock->data; struct radv_proto *p = ifa->ra; if (! radv_sk_open(ifa)) { log(L_ERR "%s: Socket open failed on interface %s", p->p.name, ifa->iface->name); return; } radv_iface_notify(ifa, RA_EV_INIT); } static void radv_iface_new(struct radv_proto *p, struct iface *iface, struct radv_iface_config *cf) { struct radv_iface *ifa; RADV_TRACE(D_EVENTS, "Adding interface %s", iface->name); pool *pool = rp_new(p->p.pool, iface->name); ifa = mb_allocz(pool, sizeof(struct radv_iface)); ifa->pool = pool; ifa->ra = p; ifa->cf = cf; ifa->iface = iface; ifa->addr = iface->llv6; init_list(&ifa->prefixes); ifa->prune_time = TIME_INFINITY; add_tail(&p->iface_list, NODE ifa); ifa->timer = tm_new_init(pool, radv_timer, ifa, 0, 0); struct object_lock *lock = olock_new(pool); lock->type = OBJLOCK_IP; lock->port = ICMPV6_PROTO; lock->iface = iface; lock->data = ifa; lock->hook = radv_iface_add; ifa->lock = lock; olock_acquire(lock); } static void radv_iface_remove(struct radv_iface *ifa) { struct radv_proto *p = ifa->ra; RADV_TRACE(D_EVENTS, "Removing interface %s", ifa->iface->name); rem_node(NODE ifa); rfree(ifa->pool); } static void radv_if_notify(struct proto *P, unsigned flags, struct iface *iface) { struct radv_proto *p = (struct radv_proto *) P; struct radv_config *cf = (struct radv_config *) (P->cf); struct radv_iface *ifa = radv_iface_find(p, iface); if (iface->flags & IF_IGNORE) return; /* Add, remove or restart interface */ if (flags & (IF_CHANGE_UPDOWN | IF_CHANGE_LLV6)) { if (ifa) radv_iface_remove(ifa); if (!(iface->flags & IF_UP)) return; /* Ignore non-multicast ifaces */ if (!(iface->flags & IF_MULTICAST)) return; /* Ignore ifaces without link-local address */ if (!iface->llv6) return; struct radv_iface_config *ic = (void *) iface_patt_find(&cf->patt_list, iface, NULL); if (ic) radv_iface_new(p, iface, ic); return; } if (!ifa) return; if ((flags & IF_CHANGE_LINK) && (iface->flags & IF_LINK_UP)) radv_iface_notify(ifa, RA_EV_INIT); } static void radv_ifa_notify(struct proto *P, unsigned flags UNUSED, struct ifa *a) { struct radv_proto *p = (struct radv_proto *) P; if (a->flags & IA_SECONDARY) return; if (a->scope <= SCOPE_LINK) return; struct radv_iface *ifa = radv_iface_find(p, a->iface); if (ifa) radv_iface_notify(ifa, RA_EV_CHANGE); } static inline int radv_trigger_valid(struct radv_config *cf) { return cf->trigger.type != 0; } static inline int radv_net_match_trigger(struct radv_config *cf, net *n) { return radv_trigger_valid(cf) && net_equal(n->n.addr, &cf->trigger); } int radv_preexport(struct proto *P, rte **new, struct linpool *pool UNUSED) { // struct radv_proto *p = (struct radv_proto *) P; struct radv_config *cf = (struct radv_config *) (P->cf); if (radv_net_match_trigger(cf, (*new)->net)) return RIC_PROCESS; if (cf->propagate_routes) return RIC_PROCESS; else return RIC_DROP; } static void radv_rt_notify(struct proto *P, struct channel *ch UNUSED, net *n, rte *new, rte *old UNUSED) { struct radv_proto *p = (struct radv_proto *) P; struct radv_config *cf = (struct radv_config *) (P->cf); struct radv_route *rt; eattr *ea; if (radv_net_match_trigger(cf, n)) { u8 old_active = p->active; p->active = !!new; if (p->active == old_active) return; if (p->active) RADV_TRACE(D_EVENTS, "Triggered"); else RADV_TRACE(D_EVENTS, "Suppressed"); radv_iface_notify_all(p, RA_EV_CHANGE); return; } if (!cf->propagate_routes) return; /* * Some other route we want to send (or stop sending). Update the cache, * with marking a removed one as dead or creating a new one as needed. * * And yes, we exclude the trigger route on purpose. */ if (new) { /* Update */ ea = ea_find(new->attrs->eattrs, EA_RA_PREFERENCE); uint preference = ea ? ea->u.data : RA_PREF_MEDIUM; uint preference_set = !!ea; ea = ea_find(new->attrs->eattrs, EA_RA_LIFETIME); uint lifetime = ea ? ea->u.data : 0; uint lifetime_set = !!ea; if ((preference != RA_PREF_LOW) && (preference != RA_PREF_MEDIUM) && (preference != RA_PREF_HIGH)) { log(L_WARN "%s: Invalid ra_preference value %u on route %N", p->p.name, preference, n->n.addr); preference = RA_PREF_MEDIUM; preference_set = 1; lifetime = 0; lifetime_set = 1; } rt = fib_get(&p->routes, n->n.addr); /* Ignore update if nothing changed */ if (rt->valid && (rt->preference == preference) && (rt->preference_set == preference_set) && (rt->lifetime == lifetime) && (rt->lifetime_set == lifetime_set)) return; if (p->routes.entries == 18) log(L_WARN "%s: More than 17 routes exported to RAdv", p->p.name); rt->valid = 1; rt->changed = current_time(); rt->preference = preference; rt->preference_set = preference_set; rt->lifetime = lifetime; rt->lifetime_set = lifetime_set; } else { /* Withdraw */ rt = fib_find(&p->routes, n->n.addr); if (!rt || !rt->valid) return; /* Invalidate the route */ rt->valid = 0; rt->changed = current_time(); /* Invalidated route will be pruned eventually */ btime expires = rt->changed + cf->max_linger_time S; p->prune_time = MIN(p->prune_time, expires); } radv_iface_notify_all(p, RA_EV_CHANGE); } /* * Cleans up all the dead routes that expired and schedules itself to be run * again if there are more routes waiting for expiration. */ static void radv_prune_routes(struct radv_proto *p) { struct radv_config *cf = (struct radv_config *) (p->p.cf); btime now = current_time(); btime next = TIME_INFINITY; btime expires = 0; /* Should not happen */ if (!p->fib_up) return; struct fib_iterator fit; FIB_ITERATE_INIT(&fit, &p->routes); again: FIB_ITERATE_START(&p->routes, &fit, struct radv_route, rt) { if (!rt->valid) { expires = rt->changed + cf->max_linger_time S; /* Delete expired nodes */ if (expires <= now) { FIB_ITERATE_PUT(&fit); fib_delete(&p->routes, rt); goto again; } else next = MIN(next, expires); } } FIB_ITERATE_END; p->prune_time = next; } static int radv_check_active(struct radv_proto *p) { struct radv_config *cf = (struct radv_config *) (p->p.cf); if (!radv_trigger_valid(cf)) return 1; struct channel *c = p->p.main_channel; return rt_examine(c->table, &cf->trigger, &p->p, c->out_filter); } static void radv_postconfig(struct proto_config *CF) { // struct radv_config *cf = (void *) CF; /* Define default channel */ if (EMPTY_LIST(CF->channels)) channel_config_new(NULL, net_label[NET_IP6], NET_IP6, CF); } static struct proto * radv_init(struct proto_config *CF) { struct proto *P = proto_new(CF); P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF)); P->preexport = radv_preexport; P->rt_notify = radv_rt_notify; P->if_notify = radv_if_notify; P->ifa_notify = radv_ifa_notify; return P; } static void radv_set_fib(struct radv_proto *p, int up) { if (up == p->fib_up) return; if (up) fib_init(&p->routes, p->p.pool, NET_IP6, sizeof(struct radv_route), OFFSETOF(struct radv_route, n), 4, NULL); else fib_free(&p->routes); p->fib_up = up; p->prune_time = TIME_INFINITY; } static int radv_start(struct proto *P) { struct radv_proto *p = (struct radv_proto *) P; struct radv_config *cf = (struct radv_config *) (P->cf); init_list(&(p->iface_list)); p->valid = 1; p->active = !radv_trigger_valid(cf); p->fib_up = 0; radv_set_fib(p, cf->propagate_routes); p->prune_time = TIME_INFINITY; return PS_UP; } static inline void radv_iface_shutdown(struct radv_iface *ifa) { if (ifa->sk) { radv_invalidate(ifa); radv_send_ra(ifa, IPA_NONE); } } static int radv_shutdown(struct proto *P) { struct radv_proto *p = (struct radv_proto *) P; p->valid = 0; struct radv_iface *ifa; WALK_LIST(ifa, p->iface_list) radv_iface_shutdown(ifa); return PS_DOWN; } static int radv_reconfigure(struct proto *P, struct proto_config *CF) { struct radv_proto *p = (struct radv_proto *) P; struct radv_config *old = (struct radv_config *) (P->cf); struct radv_config *new = (struct radv_config *) CF; if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF))) return 0; P->cf = CF; /* radv_check_active() requires proper P->cf */ p->active = radv_check_active(p); /* Allocate or free FIB */ radv_set_fib(p, new->propagate_routes); /* We started to accept routes so we need to refeed them */ if (!old->propagate_routes && new->propagate_routes) channel_request_feeding(p->p.main_channel); struct iface *iface; WALK_LIST(iface, iface_list) { if (!(iface->flags & IF_UP)) continue; /* Ignore non-multicast ifaces */ if (!(iface->flags & IF_MULTICAST)) continue; /* Ignore ifaces without link-local address */ if (!iface->llv6) continue; struct radv_iface *ifa = radv_iface_find(p, iface); struct radv_iface_config *ic = (struct radv_iface_config *) iface_patt_find(&new->patt_list, iface, NULL); if (ifa && ic) { ifa->cf = ic; /* We cheat here - always notify the change even if there isn't any. That would leads just to a few unnecessary RAs. */ radv_iface_notify(ifa, RA_EV_CHANGE); } if (ifa && !ic) { radv_iface_shutdown(ifa); radv_iface_remove(ifa); } if (!ifa && ic) radv_iface_new(p, iface, ic); } return 1; } static void radv_copy_config(struct proto_config *dest, struct proto_config *src) { struct radv_config *d = (struct radv_config *) dest; struct radv_config *s = (struct radv_config *) src; /* We clean up patt_list, ifaces are non-sharable */ init_list(&d->patt_list); /* We copy pref_list, shallow copy suffices */ cfg_copy_list(&d->pref_list, &s->pref_list, sizeof(struct radv_prefix_config)); } static void radv_get_status(struct proto *P, byte *buf) { struct radv_proto *p = (struct radv_proto *) P; if (!p->active) strcpy(buf, "Suppressed"); } static const char * radv_pref_str(u32 pref) { switch (pref) { case RA_PREF_LOW: return "low"; case RA_PREF_MEDIUM: return "medium"; case RA_PREF_HIGH: return "high"; default: return "??"; } } /* The buffer has some minimal size */ static int radv_get_attr(const eattr *a, byte *buf, int buflen UNUSED) { switch (a->id) { case EA_RA_PREFERENCE: bsprintf(buf, "preference: %s", radv_pref_str(a->u.data)); return GA_FULL; case EA_RA_LIFETIME: bsprintf(buf, "lifetime"); return GA_NAME; default: return GA_UNKNOWN; } } struct protocol proto_radv = { .name = "RAdv", .template = "radv%d", .class = PROTOCOL_RADV, .channel_mask = NB_IP6, .proto_size = sizeof(struct radv_proto), .config_size = sizeof(struct radv_config), .postconfig = radv_postconfig, .init = radv_init, .start = radv_start, .shutdown = radv_shutdown, .reconfigure = radv_reconfigure, .copy_config = radv_copy_config, .get_status = radv_get_status, .get_attr = radv_get_attr }; bird-2.0.8/proto/radv/packets.c0000664000175000017500000002670114025744326015267 0ustar feelafeela/* * BIRD -- RAdv Packet Processing * * (c) 2011--2019 Ondrej Zajicek * (c) 2011--2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "radv.h" struct radv_ra_packet { u8 type; u8 code; u16 checksum; u8 current_hop_limit; u8 flags; u16 router_lifetime; u32 reachable_time; u32 retrans_timer; }; #define OPT_RA_MANAGED 0x80 #define OPT_RA_OTHER_CFG 0x40 #define OPT_PREFIX 3 #define OPT_MTU 5 #define OPT_ROUTE 24 #define OPT_RDNSS 25 #define OPT_DNSSL 31 struct radv_opt_prefix { u8 type; u8 length; u8 pxlen; u8 flags; u32 valid_lifetime; u32 preferred_lifetime; u32 reserved; ip6_addr prefix; }; #define OPT_PX_ONLINK 0x80 #define OPT_PX_AUTONOMOUS 0x40 struct radv_opt_mtu { u8 type; u8 length; u16 reserved; u32 mtu; }; struct radv_opt_route { u8 type; u8 length; u8 pxlen; u8 flags; u32 lifetime; u8 prefix[]; }; struct radv_opt_rdnss { u8 type; u8 length; u16 reserved; u32 lifetime; ip6_addr servers[]; }; struct radv_opt_dnssl { u8 type; u8 length; u16 reserved; u32 lifetime; char domain[]; }; static int radv_prepare_route(struct radv_iface *ifa, struct radv_route *rt, char **buf, char *bufend) { struct radv_proto *p = ifa->ra; u8 px_blocks = (net6_pxlen(rt->n.addr) + 63) / 64; u8 opt_len = 8 * (1 + px_blocks); if (*buf + opt_len > bufend) { log(L_WARN, "%s: Too many RA options on interface %s", p->p.name, ifa->iface->name); return -1; } uint preference = rt->preference_set ? rt->preference : ifa->cf->route_preference; uint lifetime = rt->lifetime_set ? rt->lifetime : ifa->cf->route_lifetime; uint valid = rt->valid && p->valid && (p->active || !ifa->cf->route_lifetime_sensitive); struct radv_opt_route *opt = (void *) *buf; *buf += opt_len; opt->type = OPT_ROUTE; opt->length = 1 + px_blocks; opt->pxlen = net6_pxlen(rt->n.addr); opt->flags = preference; opt->lifetime = valid ? htonl(lifetime) : 0; /* Copy the relevant part of the prefix */ ip6_addr px_addr = ip6_hton(net6_prefix(rt->n.addr)); memcpy(opt->prefix, &px_addr, 8 * px_blocks); /* Keeping track of first linger timeout */ if (!rt->valid) ifa->valid_time = MIN(ifa->valid_time, rt->changed + ifa->cf->route_linger_time S); return 0; } static int radv_prepare_rdnss(struct radv_iface *ifa, list *rdnss_list, char **buf, char *bufend) { struct radv_rdnss_config *rcf = HEAD(*rdnss_list); while(NODE_VALID(rcf)) { struct radv_rdnss_config *rcf_base = rcf; struct radv_opt_rdnss *op = (void *) *buf; int max_i = (bufend - *buf - sizeof(struct radv_opt_rdnss)) / sizeof(ip6_addr); int i = 0; if (max_i < 1) goto too_much; op->type = OPT_RDNSS; op->reserved = 0; if (rcf->lifetime_mult) op->lifetime = htonl(rcf->lifetime_mult * ifa->cf->max_ra_int); else op->lifetime = htonl(rcf->lifetime); while(NODE_VALID(rcf) && (rcf->lifetime == rcf_base->lifetime) && (rcf->lifetime_mult == rcf_base->lifetime_mult)) { if (i >= max_i) goto too_much; op->servers[i] = ip6_hton(rcf->server); i++; rcf = NODE_NEXT(rcf); } op->length = 1+2*i; *buf += 8 * op->length; } return 0; too_much: log(L_WARN "%s: Too many RA options on interface %s", ifa->ra->p.name, ifa->iface->name); return -1; } int radv_process_domain(struct radv_dnssl_config *cf) { /* Format of domain in search list is

The routing protocols are the bird's heart and a fine amount of code is dedicated to their management and for providing support functions to them. (-: Actually, this is the reason why the directory with sources of the core code is called When talking about protocols, one need to distinguish between A protocol is represented by a Each instance has its own The protocol hooks are described in the next chapter, for more information about configuration of protocols, please refer to the configuration chapter and also to the description of the Protocol states

As startup and shutdown of each protocol are complex processes which can be affected by lots of external events (user's actions, reconfigurations, behavior of neighboring routers etc.), we have decided to supervise them by a pair of simple state machines -- the protocol state machine and a core state machine.

The

Unless the protocol is in the At any time, the core code can ask the protocol to shut itself down by calling its stop() hook. Functions of the protocol module

The protocol module provides the following functions: bird-2.0.8/nest/proto.c0000664000175000017500000016012314025744326013647 0ustar feelafeela/* * BIRD -- Protocols * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/protocol.h" #include "lib/resource.h" #include "lib/lists.h" #include "lib/event.h" #include "lib/timer.h" #include "lib/string.h" #include "conf/conf.h" #include "nest/route.h" #include "nest/iface.h" #include "nest/cli.h" #include "filter/filter.h" #include "filter/f-inst.h" pool *proto_pool; list proto_list; static list protocol_list; struct protocol *class_to_protocol[PROTOCOL__MAX]; #define CD(c, msg, args...) ({ if (c->debug & D_STATES) log(L_TRACE "%s.%s: " msg, c->proto->name, c->name ?: "?", ## args); }) #define PD(p, msg, args...) ({ if (p->debug & D_STATES) log(L_TRACE "%s: " msg, p->name, ## args); }) static timer *proto_shutdown_timer; static timer *gr_wait_timer; #define GRS_NONE 0 #define GRS_INIT 1 #define GRS_ACTIVE 2 #define GRS_DONE 3 static int graceful_restart_state; static u32 graceful_restart_locks; static char *p_states[] = { "DOWN", "START", "UP", "STOP" }; static char *c_states[] = { "DOWN", "START", "UP", "FLUSHING" }; static char *e_states[] = { "DOWN", "FEEDING", "READY" }; extern struct protocol proto_unix_iface; static void channel_request_reload(struct channel *c); static void proto_shutdown_loop(timer *); static void proto_rethink_goal(struct proto *p); static char *proto_state_name(struct proto *p); static void channel_verify_limits(struct channel *c); static inline void channel_reset_limit(struct channel_limit *l); static inline int proto_is_done(struct proto *p) { return (p->proto_state == PS_DOWN) && (p->active_channels == 0); } static inline int channel_is_active(struct channel *c) { return (c->channel_state == CS_START) || (c->channel_state == CS_UP); } static inline int channel_reloadable(struct channel *c) { return c->proto->reload_routes && c->reloadable; } static inline void channel_log_state_change(struct channel *c) { if (c->export_state) CD(c, "State changed to %s/%s", c_states[c->channel_state], e_states[c->export_state]); else CD(c, "State changed to %s", c_states[c->channel_state]); } static void proto_log_state_change(struct proto *p) { if (p->debug & D_STATES) { char *name = proto_state_name(p); if (name != p->last_state_name_announced) { p->last_state_name_announced = name; PD(p, "State changed to %s", proto_state_name(p)); } } else p->last_state_name_announced = NULL; } struct channel_config * proto_cf_find_channel(struct proto_config *pc, uint net_type) { struct channel_config *cc; WALK_LIST(cc, pc->channels) if (cc->net_type == net_type) return cc; return NULL; } /** * proto_find_channel_by_table - find channel connected to a routing table * @p: protocol instance * @t: routing table * * Returns pointer to channel or NULL */ struct channel * proto_find_channel_by_table(struct proto *p, struct rtable *t) { struct channel *c; WALK_LIST(c, p->channels) if (c->table == t) return c; return NULL; } /** * proto_find_channel_by_name - find channel by its name * @p: protocol instance * @n: channel name * * Returns pointer to channel or NULL */ struct channel * proto_find_channel_by_name(struct proto *p, const char *n) { struct channel *c; WALK_LIST(c, p->channels) if (!strcmp(c->name, n)) return c; return NULL; } /** * proto_add_channel - connect protocol to a routing table * @p: protocol instance * @cf: channel configuration * * This function creates a channel between the protocol instance @p and the * routing table specified in the configuration @cf, making the protocol hear * all changes in the table and allowing the protocol to update routes in the * table. * * The channel is linked in the protocol channel list and when active also in * the table channel list. Channels are allocated from the global resource pool * (@proto_pool) and they are automatically freed when the protocol is removed. */ struct channel * proto_add_channel(struct proto *p, struct channel_config *cf) { struct channel *c = mb_allocz(proto_pool, cf->channel->channel_size); c->name = cf->name; c->channel = cf->channel; c->proto = p; c->table = cf->table->table; c->in_filter = cf->in_filter; c->out_filter = cf->out_filter; c->rx_limit = cf->rx_limit; c->in_limit = cf->in_limit; c->out_limit = cf->out_limit; c->net_type = cf->net_type; c->ra_mode = cf->ra_mode; c->preference = cf->preference; c->debug = cf->debug; c->merge_limit = cf->merge_limit; c->in_keep_filtered = cf->in_keep_filtered; c->rpki_reload = cf->rpki_reload; c->channel_state = CS_DOWN; c->export_state = ES_DOWN; c->last_state_change = current_time(); c->reloadable = 1; init_list(&c->roa_subscriptions); CALL(c->channel->init, c, cf); add_tail(&p->channels, &c->n); CD(c, "Connected to table %s", c->table->name); return c; } void proto_remove_channel(struct proto *p UNUSED, struct channel *c) { ASSERT(c->channel_state == CS_DOWN); CD(c, "Removed", c->name); rem_node(&c->n); mb_free(c); } static void proto_start_channels(struct proto *p) { struct channel *c; WALK_LIST(c, p->channels) if (!c->disabled) channel_set_state(c, CS_UP); } static void proto_pause_channels(struct proto *p) { struct channel *c; WALK_LIST(c, p->channels) if (!c->disabled && channel_is_active(c)) channel_set_state(c, CS_START); } static void proto_stop_channels(struct proto *p) { struct channel *c; WALK_LIST(c, p->channels) if (!c->disabled && channel_is_active(c)) channel_set_state(c, CS_FLUSHING); } static void proto_remove_channels(struct proto *p) { struct channel *c; WALK_LIST_FIRST(c, p->channels) proto_remove_channel(p, c); } static void channel_schedule_feed(struct channel *c, int initial) { // DBG("%s: Scheduling meal\n", p->name); ASSERT(c->channel_state == CS_UP); c->export_state = ES_FEEDING; c->refeeding = !initial; ev_schedule_work(c->feed_event); } static void channel_feed_loop(void *ptr) { struct channel *c = ptr; if (c->export_state != ES_FEEDING) return; /* Start feeding */ if (!c->feed_active) { if (c->proto->feed_begin) c->proto->feed_begin(c, !c->refeeding); c->refeed_pending = 0; } // DBG("Feeding protocol %s continued\n", p->name); if (!rt_feed_channel(c)) { ev_schedule_work(c->feed_event); return; } /* Reset export limit if the feed ended with acceptable number of exported routes */ struct channel_limit *l = &c->out_limit; if (c->refeeding && (l->state == PLS_BLOCKED) && (c->refeed_count <= l->limit) && (c->stats.exp_routes <= l->limit)) { log(L_INFO "Protocol %s resets route export limit (%u)", c->proto->name, l->limit); channel_reset_limit(&c->out_limit); /* Continue in feed - it will process routing table again from beginning */ c->refeed_count = 0; ev_schedule_work(c->feed_event); return; } // DBG("Feeding protocol %s finished\n", p->name); c->export_state = ES_READY; channel_log_state_change(c); if (c->proto->feed_end) c->proto->feed_end(c); /* Restart feeding */ if (c->refeed_pending) channel_request_feeding(c); } static void channel_roa_in_changed(struct rt_subscription *s) { struct channel *c = s->data; int active = c->reload_event && ev_active(c->reload_event); CD(c, "Reload triggered by RPKI change%s", active ? " - already active" : ""); if (!active) channel_request_reload(c); else c->reload_pending = 1; } static void channel_roa_out_changed(struct rt_subscription *s) { struct channel *c = s->data; int active = (c->export_state == ES_FEEDING); CD(c, "Feeding triggered by RPKI change%s", active ? " - already active" : ""); if (!active) channel_request_feeding(c); else c->refeed_pending = 1; } /* Temporary code, subscriptions should be changed to resources */ struct roa_subscription { struct rt_subscription s; node roa_node; }; static int channel_roa_is_subscribed(struct channel *c, rtable *tab, int dir) { void (*hook)(struct rt_subscription *) = dir ? channel_roa_in_changed : channel_roa_out_changed; struct roa_subscription *s; node *n; WALK_LIST2(s, n, c->roa_subscriptions, roa_node) if ((s->s.tab == tab) && (s->s.hook == hook)) return 1; return 0; } static void channel_roa_subscribe(struct channel *c, rtable *tab, int dir) { if (channel_roa_is_subscribed(c, tab, dir)) return; struct roa_subscription *s = mb_allocz(c->proto->pool, sizeof(struct roa_subscription)); s->s.hook = dir ? channel_roa_in_changed : channel_roa_out_changed; s->s.data = c; rt_subscribe(tab, &s->s); add_tail(&c->roa_subscriptions, &s->roa_node); } static void channel_roa_unsubscribe(struct roa_subscription *s) { rt_unsubscribe(&s->s); rem_node(&s->roa_node); mb_free(s); } static void channel_roa_subscribe_filter(struct channel *c, int dir) { const struct filter *f = dir ? c->in_filter : c->out_filter; struct rtable *tab; int valid = 1, found = 0; if ((f == FILTER_ACCEPT) || (f == FILTER_REJECT)) return; /* No automatic reload for non-reloadable channels */ if (dir && !channel_reloadable(c)) valid = 0; #ifdef CONFIG_BGP /* No automatic reload for BGP channels without in_table / out_table */ if (c->channel == &channel_bgp) valid = dir ? !!c->in_table : !!c->out_table; #endif struct filter_iterator fit; FILTER_ITERATE_INIT(&fit, f, c->proto->pool); FILTER_ITERATE(&fit, fi) { switch (fi->fi_code) { case FI_ROA_CHECK_IMPLICIT: tab = fi->i_FI_ROA_CHECK_IMPLICIT.rtc->table; if (valid) channel_roa_subscribe(c, tab, dir); found = 1; break; case FI_ROA_CHECK_EXPLICIT: tab = fi->i_FI_ROA_CHECK_EXPLICIT.rtc->table; if (valid) channel_roa_subscribe(c, tab, dir); found = 1; break; default: break; } } FILTER_ITERATE_END; FILTER_ITERATE_CLEANUP(&fit); if (!valid && found) log(L_WARN "%s.%s: Automatic RPKI reload not active for %s", c->proto->name, c->name ?: "?", dir ? "import" : "export"); } static void channel_roa_unsubscribe_all(struct channel *c) { struct roa_subscription *s; node *n, *x; WALK_LIST2_DELSAFE(s, n, x, c->roa_subscriptions, roa_node) channel_roa_unsubscribe(s); } static void channel_start_export(struct channel *c) { ASSERT(c->channel_state == CS_UP); ASSERT(c->export_state == ES_DOWN); channel_schedule_feed(c, 1); /* Sets ES_FEEDING */ } static void channel_stop_export(struct channel *c) { /* Need to abort feeding */ if (c->export_state == ES_FEEDING) rt_feed_channel_abort(c); c->export_state = ES_DOWN; c->stats.exp_routes = 0; bmap_reset(&c->export_map, 1024); } /* Called by protocol for reload from in_table */ void channel_schedule_reload(struct channel *c) { ASSERT(c->channel_state == CS_UP); rt_reload_channel_abort(c); ev_schedule_work(c->reload_event); } static void channel_reload_loop(void *ptr) { struct channel *c = ptr; /* Start reload */ if (!c->reload_active) c->reload_pending = 0; if (!rt_reload_channel(c)) { ev_schedule_work(c->reload_event); return; } /* Restart reload */ if (c->reload_pending) channel_request_reload(c); } static void channel_reset_import(struct channel *c) { /* Need to abort feeding */ ev_postpone(c->reload_event); rt_reload_channel_abort(c); rt_prune_sync(c->in_table, 1); } static void channel_reset_export(struct channel *c) { /* Just free the routes */ rt_prune_sync(c->out_table, 1); } /* Called by protocol to activate in_table */ void channel_setup_in_table(struct channel *c) { struct rtable_config *cf = mb_allocz(c->proto->pool, sizeof(struct rtable_config)); cf->name = "import"; cf->addr_type = c->net_type; c->in_table = mb_allocz(c->proto->pool, sizeof(struct rtable)); rt_setup(c->proto->pool, c->in_table, cf); c->reload_event = ev_new_init(c->proto->pool, channel_reload_loop, c); } /* Called by protocol to activate out_table */ void channel_setup_out_table(struct channel *c) { struct rtable_config *cf = mb_allocz(c->proto->pool, sizeof(struct rtable_config)); cf->name = "export"; cf->addr_type = c->net_type; c->out_table = mb_allocz(c->proto->pool, sizeof(struct rtable)); rt_setup(c->proto->pool, c->out_table, cf); } static void channel_do_start(struct channel *c) { rt_lock_table(c->table); add_tail(&c->table->channels, &c->table_node); c->proto->active_channels++; c->feed_event = ev_new_init(c->proto->pool, channel_feed_loop, c); bmap_init(&c->export_map, c->proto->pool, 1024); memset(&c->stats, 0, sizeof(struct proto_stats)); channel_reset_limit(&c->rx_limit); channel_reset_limit(&c->in_limit); channel_reset_limit(&c->out_limit); CALL(c->channel->start, c); } static void channel_do_up(struct channel *c) { /* Register RPKI/ROA subscriptions */ if (c->rpki_reload) { channel_roa_subscribe_filter(c, 1); channel_roa_subscribe_filter(c, 0); } } static void channel_do_flush(struct channel *c) { rt_schedule_prune(c->table); c->gr_wait = 0; if (c->gr_lock) channel_graceful_restart_unlock(c); CALL(c->channel->shutdown, c); /* This have to be done in here, as channel pool is freed before channel_do_down() */ bmap_free(&c->export_map); c->in_table = NULL; c->reload_event = NULL; c->out_table = NULL; channel_roa_unsubscribe_all(c); } static void channel_do_down(struct channel *c) { ASSERT(!c->feed_active && !c->reload_active); rem_node(&c->table_node); rt_unlock_table(c->table); c->proto->active_channels--; if ((c->stats.imp_routes + c->stats.filt_routes) != 0) log(L_ERR "%s: Channel %s is down but still has some routes", c->proto->name, c->name); // bmap_free(&c->export_map); memset(&c->stats, 0, sizeof(struct proto_stats)); c->in_table = NULL; c->reload_event = NULL; c->out_table = NULL; CALL(c->channel->cleanup, c); /* Schedule protocol shutddown */ if (proto_is_done(c->proto)) ev_schedule(c->proto->event); } void channel_set_state(struct channel *c, uint state) { uint cs = c->channel_state; uint es = c->export_state; DBG("%s reporting channel %s state transition %s -> %s\n", c->proto->name, c->name, c_states[cs], c_states[state]); if (state == cs) return; c->channel_state = state; c->last_state_change = current_time(); switch (state) { case CS_START: ASSERT(cs == CS_DOWN || cs == CS_UP); if (cs == CS_DOWN) channel_do_start(c); if (es != ES_DOWN) channel_stop_export(c); if (c->in_table && (cs == CS_UP)) channel_reset_import(c); if (c->out_table && (cs == CS_UP)) channel_reset_export(c); break; case CS_UP: ASSERT(cs == CS_DOWN || cs == CS_START); if (cs == CS_DOWN) channel_do_start(c); if (!c->gr_wait && c->proto->rt_notify) channel_start_export(c); channel_do_up(c); break; case CS_FLUSHING: ASSERT(cs == CS_START || cs == CS_UP); if (es != ES_DOWN) channel_stop_export(c); if (c->in_table && (cs == CS_UP)) channel_reset_import(c); if (c->out_table && (cs == CS_UP)) channel_reset_export(c); channel_do_flush(c); break; case CS_DOWN: ASSERT(cs == CS_FLUSHING); channel_do_down(c); break; default: ASSERT(0); } channel_log_state_change(c); } /** * channel_request_feeding - request feeding routes to the channel * @c: given channel * * Sometimes it is needed to send again all routes to the channel. This is * called feeding and can be requested by this function. This would cause * channel export state transition to ES_FEEDING (during feeding) and when * completed, it will switch back to ES_READY. This function can be called * even when feeding is already running, in that case it is restarted. */ void channel_request_feeding(struct channel *c) { ASSERT(c->channel_state == CS_UP); CD(c, "Feeding requested"); /* Do nothing if we are still waiting for feeding */ if (c->export_state == ES_DOWN) return; /* If we are already feeding, we want to restart it */ if (c->export_state == ES_FEEDING) { /* Unless feeding is in initial state */ if (!c->feed_active) return; rt_feed_channel_abort(c); } /* Track number of exported routes during refeed */ c->refeed_count = 0; channel_schedule_feed(c, 0); /* Sets ES_FEEDING */ channel_log_state_change(c); } static void channel_request_reload(struct channel *c) { ASSERT(c->channel_state == CS_UP); ASSERT(channel_reloadable(c)); CD(c, "Reload requested"); c->proto->reload_routes(c); /* * Should this be done before reload_routes() hook? * Perhaps, but routes are updated asynchronously. */ channel_reset_limit(&c->rx_limit); channel_reset_limit(&c->in_limit); } const struct channel_class channel_basic = { .channel_size = sizeof(struct channel), .config_size = sizeof(struct channel_config) }; void * channel_config_new(const struct channel_class *cc, const char *name, uint net_type, struct proto_config *proto) { struct channel_config *cf = NULL; struct rtable_config *tab = NULL; if (net_type) { if (!net_val_match(net_type, proto->protocol->channel_mask)) cf_error("Unsupported channel type"); if (proto->net_type && (net_type != proto->net_type)) cf_error("Different channel type"); tab = new_config->def_tables[net_type]; } if (!cc) cc = &channel_basic; cf = cfg_allocz(cc->config_size); cf->name = name; cf->channel = cc; cf->parent = proto; cf->table = tab; cf->out_filter = FILTER_REJECT; cf->net_type = net_type; cf->ra_mode = RA_OPTIMAL; cf->preference = proto->protocol->preference; cf->debug = new_config->channel_default_debug; cf->rpki_reload = 1; add_tail(&proto->channels, &cf->n); return cf; } void * channel_config_get(const struct channel_class *cc, const char *name, uint net_type, struct proto_config *proto) { struct channel_config *cf; /* We are using name as token, so no strcmp() */ WALK_LIST(cf, proto->channels) if (cf->name == name) { /* Allow to redefine channel only if inherited from template */ if (cf->parent == proto) cf_error("Multiple %s channels", name); cf->parent = proto; return cf; } return channel_config_new(cc, name, net_type, proto); } struct channel_config * channel_copy_config(struct channel_config *src, struct proto_config *proto) { struct channel_config *dst = cfg_alloc(src->channel->config_size); memcpy(dst, src, src->channel->config_size); memset(&dst->n, 0, sizeof(node)); add_tail(&proto->channels, &dst->n); CALL(src->channel->copy_config, dst, src); return dst; } static int reconfigure_type; /* Hack to propagate type info to channel_reconfigure() */ int channel_reconfigure(struct channel *c, struct channel_config *cf) { /* FIXME: better handle these changes, also handle in_keep_filtered */ if ((c->table != cf->table->table) || (cf->ra_mode && (c->ra_mode != cf->ra_mode))) return 0; /* Note that filter_same() requires arguments in (new, old) order */ int import_changed = !filter_same(cf->in_filter, c->in_filter); int export_changed = !filter_same(cf->out_filter, c->out_filter); int rpki_reload_changed = (cf->rpki_reload != c->rpki_reload); if (c->preference != cf->preference) import_changed = 1; if (c->merge_limit != cf->merge_limit) export_changed = 1; /* Reconfigure channel fields */ c->in_filter = cf->in_filter; c->out_filter = cf->out_filter; c->rx_limit = cf->rx_limit; c->in_limit = cf->in_limit; c->out_limit = cf->out_limit; // c->ra_mode = cf->ra_mode; c->merge_limit = cf->merge_limit; c->preference = cf->preference; c->debug = cf->debug; c->in_keep_filtered = cf->in_keep_filtered; c->rpki_reload = cf->rpki_reload; channel_verify_limits(c); /* Execute channel-specific reconfigure hook */ if (c->channel->reconfigure && !c->channel->reconfigure(c, cf, &import_changed, &export_changed)) return 0; /* If the channel is not open, it has no routes and we cannot reload it anyways */ if (c->channel_state != CS_UP) goto done; /* Update RPKI/ROA subscriptions */ if (import_changed || export_changed || rpki_reload_changed) { channel_roa_unsubscribe_all(c); if (c->rpki_reload) { channel_roa_subscribe_filter(c, 1); channel_roa_subscribe_filter(c, 0); } } if (reconfigure_type == RECONFIG_SOFT) { if (import_changed) log(L_INFO "Channel %s.%s changed import", c->proto->name, c->name); if (export_changed) log(L_INFO "Channel %s.%s changed export", c->proto->name, c->name); goto done; } /* Route reload may be not supported */ if (import_changed && !channel_reloadable(c)) return 0; if (import_changed || export_changed) log(L_INFO "Reloading channel %s.%s", c->proto->name, c->name); if (import_changed) channel_request_reload(c); if (export_changed) channel_request_feeding(c); done: CD(c, "Reconfigured"); return 1; } int proto_configure_channel(struct proto *p, struct channel **pc, struct channel_config *cf) { struct channel *c = *pc; if (!c && cf) { /* We could add the channel, but currently it would just stay in down state until protocol is restarted, so it is better to force restart anyways. */ if (p->proto_state != PS_DOWN) { log(L_INFO "Cannot add channel %s.%s", p->name, cf->name); return 0; } *pc = proto_add_channel(p, cf); } else if (c && !cf) { if (c->channel_state != CS_DOWN) { log(L_INFO "Cannot remove channel %s.%s", c->proto->name, c->name); return 0; } proto_remove_channel(p, c); *pc = NULL; } else if (c && cf) { if (!channel_reconfigure(c, cf)) { log(L_INFO "Cannot reconfigure channel %s.%s", c->proto->name, c->name); return 0; } } return 1; } static void proto_event(void *ptr) { struct proto *p = ptr; if (p->do_start) { if_feed_baby(p); p->do_start = 0; } if (p->do_stop) { if (p->proto == &proto_unix_iface) if_flush_ifaces(p); p->do_stop = 0; } if (proto_is_done(p)) { if (p->proto->cleanup) p->proto->cleanup(p); p->active = 0; proto_log_state_change(p); proto_rethink_goal(p); } } /** * proto_new - create a new protocol instance * @c: protocol configuration * * When a new configuration has been read in, the core code starts * initializing all the protocol instances configured by calling their * init() hooks with the corresponding instance configuration. The initialization * code of the protocol is expected to create a new instance according to the * configuration by calling this function and then modifying the default settings * to values wanted by the protocol. */ void * proto_new(struct proto_config *cf) { struct proto *p = mb_allocz(proto_pool, cf->protocol->proto_size); p->cf = cf; p->debug = cf->debug; p->mrtdump = cf->mrtdump; p->name = cf->name; p->proto = cf->protocol; p->net_type = cf->net_type; p->disabled = cf->disabled; p->hash_key = random_u32(); cf->proto = p; init_list(&p->channels); return p; } static struct proto * proto_init(struct proto_config *c, node *n) { struct protocol *pr = c->protocol; struct proto *p = pr->init(c); p->proto_state = PS_DOWN; p->last_state_change = current_time(); p->vrf = c->vrf; p->vrf_set = c->vrf_set; insert_node(&p->n, n); p->event = ev_new_init(proto_pool, proto_event, p); PD(p, "Initializing%s", p->disabled ? " [disabled]" : ""); return p; } static void proto_start(struct proto *p) { /* Here we cannot use p->cf->name since it won't survive reconfiguration */ p->pool = rp_new(proto_pool, p->proto->name); if (graceful_restart_state == GRS_INIT) p->gr_recovery = 1; } /** * proto_config_new - create a new protocol configuration * @pr: protocol the configuration will belong to * @class: SYM_PROTO or SYM_TEMPLATE * * Whenever the configuration file says that a new instance * of a routing protocol should be created, the parser calls * proto_config_new() to create a configuration entry for this * instance (a structure staring with the &proto_config header * containing all the generic items followed by protocol-specific * ones). Also, the configuration entry gets added to the list * of protocol instances kept in the configuration. * * The function is also used to create protocol templates (when class * SYM_TEMPLATE is specified), the only difference is that templates * are not added to the list of protocol instances and therefore not * initialized during protos_commit()). */ void * proto_config_new(struct protocol *pr, int class) { struct proto_config *cf = cfg_allocz(pr->config_size); if (class == SYM_PROTO) add_tail(&new_config->protos, &cf->n); cf->global = new_config; cf->protocol = pr; cf->name = pr->name; cf->class = class; cf->debug = new_config->proto_default_debug; cf->mrtdump = new_config->proto_default_mrtdump; init_list(&cf->channels); return cf; } /** * proto_copy_config - copy a protocol configuration * @dest: destination protocol configuration * @src: source protocol configuration * * Whenever a new instance of a routing protocol is created from the * template, proto_copy_config() is called to copy a content of * the source protocol configuration to the new protocol configuration. * Name, class and a node in protos list of @dest are kept intact. * copy_config() protocol hook is used to copy protocol-specific data. */ void proto_copy_config(struct proto_config *dest, struct proto_config *src) { struct channel_config *cc; node old_node; int old_class; const char *old_name; if (dest->protocol != src->protocol) cf_error("Can't copy configuration from a different protocol type"); if (dest->protocol->copy_config == NULL) cf_error("Inheriting configuration for %s is not supported", src->protocol->name); DBG("Copying configuration from %s to %s\n", src->name, dest->name); /* * Copy struct proto_config here. Keep original node, class and name. * protocol-specific config copy is handled by protocol copy_config() hook */ old_node = dest->n; old_class = dest->class; old_name = dest->name; memcpy(dest, src, src->protocol->config_size); dest->n = old_node; dest->class = old_class; dest->name = old_name; init_list(&dest->channels); WALK_LIST(cc, src->channels) channel_copy_config(cc, dest); /* FIXME: allow for undefined copy_config */ dest->protocol->copy_config(dest, src); } void proto_clone_config(struct symbol *sym, struct proto_config *parent) { struct proto_config *cf = proto_config_new(parent->protocol, SYM_PROTO); proto_copy_config(cf, parent); cf->name = sym->name; cf->proto = NULL; cf->parent = parent; sym->class = cf->class; sym->proto = cf; } static void proto_undef_clone(struct symbol *sym, struct proto_config *cf) { rem_node(&cf->n); sym->class = SYM_VOID; sym->proto = NULL; } /** * protos_preconfig - pre-configuration processing * @c: new configuration * * This function calls the preconfig() hooks of all routing * protocols available to prepare them for reading of the new * configuration. */ void protos_preconfig(struct config *c) { struct protocol *p; init_list(&c->protos); DBG("Protocol preconfig:"); WALK_LIST(p, protocol_list) { DBG(" %s", p->name); p->name_counter = 0; if (p->preconfig) p->preconfig(p, c); } DBG("\n"); } static int proto_reconfigure(struct proto *p, struct proto_config *oc, struct proto_config *nc, int type) { /* If the protocol is DOWN, we just restart it */ if (p->proto_state == PS_DOWN) return 0; /* If there is a too big change in core attributes, ... */ if ((nc->protocol != oc->protocol) || (nc->net_type != oc->net_type) || (nc->disabled != p->disabled) || (nc->vrf != oc->vrf) || (nc->vrf_set != oc->vrf_set)) return 0; p->name = nc->name; p->debug = nc->debug; p->mrtdump = nc->mrtdump; reconfigure_type = type; /* Execute protocol specific reconfigure hook */ if (!p->proto->reconfigure || !p->proto->reconfigure(p, nc)) return 0; DBG("\t%s: same\n", oc->name); PD(p, "Reconfigured"); p->cf = nc; return 1; } /** * protos_commit - commit new protocol configuration * @new: new configuration * @old: old configuration or %NULL if it's boot time config * @force_reconfig: force restart of all protocols (used for example * when the router ID changes) * @type: type of reconfiguration (RECONFIG_SOFT or RECONFIG_HARD) * * Scan differences between @old and @new configuration and adjust all * protocol instances to conform to the new configuration. * * When a protocol exists in the new configuration, but it doesn't in the * original one, it's immediately started. When a collision with the other * running protocol would arise, the new protocol will be temporarily stopped * by the locking mechanism. * * When a protocol exists in the old configuration, but it doesn't in the * new one, it's shut down and deleted after the shutdown completes. * * When a protocol exists in both configurations, the core decides * whether it's possible to reconfigure it dynamically - it checks all * the core properties of the protocol (changes in filters are ignored * if type is RECONFIG_SOFT) and if they match, it asks the * reconfigure() hook of the protocol to see if the protocol is able * to switch to the new configuration. If it isn't possible, the * protocol is shut down and a new instance is started with the new * configuration after the shutdown is completed. */ void protos_commit(struct config *new, struct config *old, int force_reconfig, int type) { struct proto_config *oc, *nc; struct symbol *sym; struct proto *p; node *n; DBG("protos_commit:\n"); if (old) { WALK_LIST(oc, old->protos) { p = oc->proto; sym = cf_find_symbol(new, oc->name); /* Handle dynamic protocols */ if (!sym && oc->parent && !new->shutdown) { struct symbol *parsym = cf_find_symbol(new, oc->parent->name); if (parsym && parsym->class == SYM_PROTO) { /* This is hack, we would like to share config, but we need to copy it now */ new_config = new; cfg_mem = new->mem; conf_this_scope = new->root_scope; sym = cf_get_symbol(oc->name); proto_clone_config(sym, parsym->proto); new_config = NULL; cfg_mem = NULL; } } if (sym && sym->class == SYM_PROTO && !new->shutdown) { /* Found match, let's check if we can smoothly switch to new configuration */ /* No need to check description */ nc = sym->proto; nc->proto = p; /* We will try to reconfigure protocol p */ if (! force_reconfig && proto_reconfigure(p, oc, nc, type)) continue; if (nc->parent) { proto_undef_clone(sym, nc); goto remove; } /* Unsuccessful, we will restart it */ if (!p->disabled && !nc->disabled) log(L_INFO "Restarting protocol %s", p->name); else if (p->disabled && !nc->disabled) log(L_INFO "Enabling protocol %s", p->name); else if (!p->disabled && nc->disabled) log(L_INFO "Disabling protocol %s", p->name); p->down_code = nc->disabled ? PDC_CF_DISABLE : PDC_CF_RESTART; p->cf_new = nc; } else if (!new->shutdown) { remove: log(L_INFO "Removing protocol %s", p->name); p->down_code = PDC_CF_REMOVE; p->cf_new = NULL; } else if (new->gr_down) { p->down_code = PDC_CMD_GR_DOWN; p->cf_new = NULL; } else /* global shutdown */ { p->down_code = PDC_CMD_SHUTDOWN; p->cf_new = NULL; } p->reconfiguring = 1; config_add_obstacle(old); proto_rethink_goal(p); } } struct proto *first_dev_proto = NULL; n = NODE &(proto_list.head); WALK_LIST(nc, new->protos) if (!nc->proto) { /* Not a first-time configuration */ if (old) log(L_INFO "Adding protocol %s", nc->name); p = proto_init(nc, n); n = NODE p; if (p->proto == &proto_unix_iface) first_dev_proto = p; } else n = NODE nc->proto; DBG("Protocol start\n"); /* Start device protocol first */ if (first_dev_proto) proto_rethink_goal(first_dev_proto); /* Determine router ID for the first time - it has to be here and not in global_commit() because it is postponed after start of device protocol */ if (!config->router_id) { config->router_id = if_choose_router_id(config->router_id_from, 0); if (!config->router_id) die("Cannot determine router ID, please configure it manually"); } /* Start all new protocols */ WALK_LIST_DELSAFE(p, n, proto_list) proto_rethink_goal(p); } static void proto_rethink_goal(struct proto *p) { struct protocol *q; byte goal; if (p->reconfiguring && !p->active) { struct proto_config *nc = p->cf_new; node *n = p->n.prev; DBG("%s has shut down for reconfiguration\n", p->name); p->cf->proto = NULL; config_del_obstacle(p->cf->global); proto_remove_channels(p); rem_node(&p->n); rfree(p->event); mb_free(p->message); mb_free(p); if (!nc) return; p = proto_init(nc, n); } /* Determine what state we want to reach */ if (p->disabled || p->reconfiguring) goal = PS_DOWN; else goal = PS_UP; q = p->proto; if (goal == PS_UP) { if (!p->active) { /* Going up */ DBG("Kicking %s up\n", p->name); PD(p, "Starting"); proto_start(p); proto_notify_state(p, (q->start ? q->start(p) : PS_UP)); } } else { if (p->proto_state == PS_START || p->proto_state == PS_UP) { /* Going down */ DBG("Kicking %s down\n", p->name); PD(p, "Shutting down"); proto_notify_state(p, (q->shutdown ? q->shutdown(p) : PS_DOWN)); } } } struct proto * proto_spawn(struct proto_config *cf, uint disabled) { struct proto *p = proto_init(cf, TAIL(proto_list)); p->disabled = disabled; proto_rethink_goal(p); return p; } /** * DOC: Graceful restart recovery * * Graceful restart of a router is a process when the routing plane (e.g. BIRD) * restarts but both the forwarding plane (e.g kernel routing table) and routing * neighbors keep proper routes, and therefore uninterrupted packet forwarding * is maintained. * * BIRD implements graceful restart recovery by deferring export of routes to * protocols until routing tables are refilled with the expected content. After * start, protocols generate routes as usual, but routes are not propagated to * them, until protocols report that they generated all routes. After that, * graceful restart recovery is finished and the export (and the initial feed) * to protocols is enabled. * * When graceful restart recovery need is detected during initialization, then * enabled protocols are marked with @gr_recovery flag before start. Such * protocols then decide how to proceed with graceful restart, participation is * voluntary. Protocols could lock the recovery for each channel by function * channel_graceful_restart_lock() (state stored in @gr_lock flag), which means * that they want to postpone the end of the recovery until they converge and * then unlock it. They also could set @gr_wait before advancing to %PS_UP, * which means that the core should defer route export to that channel until * the end of the recovery. This should be done by protocols that expect their * neigbors to keep the proper routes (kernel table, BGP sessions with BGP * graceful restart capability). * * The graceful restart recovery is finished when either all graceful restart * locks are unlocked or when graceful restart wait timer fires. * */ static void graceful_restart_done(timer *t); /** * graceful_restart_recovery - request initial graceful restart recovery * * Called by the platform initialization code if the need for recovery * after graceful restart is detected during boot. Have to be called * before protos_commit(). */ void graceful_restart_recovery(void) { graceful_restart_state = GRS_INIT; } /** * graceful_restart_init - initialize graceful restart * * When graceful restart recovery was requested, the function starts an active * phase of the recovery and initializes graceful restart wait timer. The * function have to be called after protos_commit(). */ void graceful_restart_init(void) { if (!graceful_restart_state) return; log(L_INFO "Graceful restart started"); if (!graceful_restart_locks) { graceful_restart_done(NULL); return; } graceful_restart_state = GRS_ACTIVE; gr_wait_timer = tm_new_init(proto_pool, graceful_restart_done, NULL, 0, 0); tm_start(gr_wait_timer, config->gr_wait S); } /** * graceful_restart_done - finalize graceful restart * @t: unused * * When there are no locks on graceful restart, the functions finalizes the * graceful restart recovery. Protocols postponing route export until the end of * the recovery are awakened and the export to them is enabled. All other * related state is cleared. The function is also called when the graceful * restart wait timer fires (but there are still some locks). */ static void graceful_restart_done(timer *t UNUSED) { log(L_INFO "Graceful restart done"); graceful_restart_state = GRS_DONE; struct proto *p; WALK_LIST(p, proto_list) { if (!p->gr_recovery) continue; struct channel *c; WALK_LIST(c, p->channels) { /* Resume postponed export of routes */ if ((c->channel_state == CS_UP) && c->gr_wait && c->proto->rt_notify) channel_start_export(c); /* Cleanup */ c->gr_wait = 0; c->gr_lock = 0; } p->gr_recovery = 0; } graceful_restart_locks = 0; } void graceful_restart_show_status(void) { if (graceful_restart_state != GRS_ACTIVE) return; cli_msg(-24, "Graceful restart recovery in progress"); cli_msg(-24, " Waiting for %d channels to recover", graceful_restart_locks); cli_msg(-24, " Wait timer is %t/%u", tm_remains(gr_wait_timer), config->gr_wait); } /** * channel_graceful_restart_lock - lock graceful restart by channel * @p: channel instance * * This function allows a protocol to postpone the end of graceful restart * recovery until it converges. The lock is removed when the protocol calls * channel_graceful_restart_unlock() or when the channel is closed. * * The function have to be called during the initial phase of graceful restart * recovery and only for protocols that are part of graceful restart (i.e. their * @gr_recovery is set), which means it should be called from protocol start * hooks. */ void channel_graceful_restart_lock(struct channel *c) { ASSERT(graceful_restart_state == GRS_INIT); ASSERT(c->proto->gr_recovery); if (c->gr_lock) return; c->gr_lock = 1; graceful_restart_locks++; } /** * channel_graceful_restart_unlock - unlock graceful restart by channel * @p: channel instance * * This function unlocks a lock from channel_graceful_restart_lock(). It is also * automatically called when the lock holding protocol went down. */ void channel_graceful_restart_unlock(struct channel *c) { if (!c->gr_lock) return; c->gr_lock = 0; graceful_restart_locks--; if ((graceful_restart_state == GRS_ACTIVE) && !graceful_restart_locks) tm_start(gr_wait_timer, 0); } /** * protos_dump_all - dump status of all protocols * * This function dumps status of all existing protocol instances to the * debug output. It involves printing of general status information * such as protocol states, its position on the protocol lists * and also calling of a dump() hook of the protocol to print * the internals. */ void protos_dump_all(void) { debug("Protocols:\n"); struct proto *p; WALK_LIST(p, proto_list) { debug(" protocol %s state %s\n", p->name, p_states[p->proto_state]); struct channel *c; WALK_LIST(c, p->channels) { debug("\tTABLE %s\n", c->table->name); if (c->in_filter) debug("\tInput filter: %s\n", filter_name(c->in_filter)); if (c->out_filter) debug("\tOutput filter: %s\n", filter_name(c->out_filter)); } if (p->proto->dump && (p->proto_state != PS_DOWN)) p->proto->dump(p); } } /** * proto_build - make a single protocol available * @p: the protocol * * After the platform specific initialization code uses protos_build() * to add all the standard protocols, it should call proto_build() for * all platform specific protocols to inform the core that they exist. */ void proto_build(struct protocol *p) { add_tail(&protocol_list, &p->n); ASSERT(p->class); ASSERT(!class_to_protocol[p->class]); class_to_protocol[p->class] = p; } /* FIXME: convert this call to some protocol hook */ extern void bfd_init_all(void); /** * protos_build - build a protocol list * * This function is called during BIRD startup to insert * all standard protocols to the global protocol list. Insertion * of platform specific protocols (such as the kernel syncer) * is in the domain of competence of the platform dependent * startup code. */ void protos_build(void) { init_list(&proto_list); init_list(&protocol_list); proto_build(&proto_device); #ifdef CONFIG_RADV proto_build(&proto_radv); #endif #ifdef CONFIG_RIP proto_build(&proto_rip); #endif #ifdef CONFIG_STATIC proto_build(&proto_static); #endif #ifdef CONFIG_MRT proto_build(&proto_mrt); #endif #ifdef CONFIG_OSPF proto_build(&proto_ospf); #endif #ifdef CONFIG_PIPE proto_build(&proto_pipe); #endif #ifdef CONFIG_BGP proto_build(&proto_bgp); #endif #ifdef CONFIG_BFD proto_build(&proto_bfd); bfd_init_all(); #endif #ifdef CONFIG_BABEL proto_build(&proto_babel); #endif #ifdef CONFIG_RPKI proto_build(&proto_rpki); #endif #ifdef CONFIG_PERF proto_build(&proto_perf); #endif proto_pool = rp_new(&root_pool, "Protocols"); proto_shutdown_timer = tm_new(proto_pool); proto_shutdown_timer->hook = proto_shutdown_loop; } /* Temporary hack to propagate restart to BGP */ int proto_restart; static void proto_shutdown_loop(timer *t UNUSED) { struct proto *p, *p_next; WALK_LIST_DELSAFE(p, p_next, proto_list) if (p->down_sched) { proto_restart = (p->down_sched == PDS_RESTART); p->disabled = 1; proto_rethink_goal(p); if (proto_restart) { p->disabled = 0; proto_rethink_goal(p); } } } static inline void proto_schedule_down(struct proto *p, byte restart, byte code) { /* Does not work for other states (even PS_START) */ ASSERT(p->proto_state == PS_UP); /* Scheduled restart may change to shutdown, but not otherwise */ if (p->down_sched == PDS_DISABLE) return; p->down_sched = restart ? PDS_RESTART : PDS_DISABLE; p->down_code = 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) { const char *actions[] = { [PLA_WARN] = "warn", [PLA_BLOCK] = "block", [PLA_RESTART] = "restart", [PLA_DISABLE] = "disable", }; return actions[l->action]; } /** * channel_notify_limit: notify about limit hit and take appropriate action * @c: channel * @l: limit being hit * @dir: limit direction (PLD_*) * @rt_count: the number of routes * * The function is called by the route processing core when limit @l * is breached. It activates the limit and tooks appropriate action * according to @l->action. */ void channel_notify_limit(struct channel *c, struct channel_limit *l, int dir, u32 rt_count) { const char *dir_name[PLD_MAX] = { "receive", "import" , "export" }; const byte dir_down[PLD_MAX] = { PDC_RX_LIMIT_HIT, PDC_IN_LIMIT_HIT, PDC_OUT_LIMIT_HIT }; struct proto *p = c->proto; if (l->state == PLS_BLOCKED) return; /* For warning action, we want the log message every time we hit the limit */ if (!l->state || ((l->action == PLA_WARN) && (rt_count == l->limit))) log(L_WARN "Protocol %s hits route %s limit (%d), action: %s", p->name, dir_name[dir], l->limit, channel_limit_name(l)); switch (l->action) { case PLA_WARN: l->state = PLS_ACTIVE; break; case PLA_BLOCK: l->state = PLS_BLOCKED; break; case PLA_RESTART: case PLA_DISABLE: l->state = PLS_BLOCKED; if (p->proto_state == PS_UP) proto_schedule_down(p, l->action == PLA_RESTART, dir_down[dir]); break; } } static void channel_verify_limits(struct channel *c) { struct channel_limit *l; u32 all_routes = c->stats.imp_routes + c->stats.filt_routes; l = &c->rx_limit; if (l->action && (all_routes > l->limit)) channel_notify_limit(c, l, PLD_RX, all_routes); l = &c->in_limit; if (l->action && (c->stats.imp_routes > l->limit)) channel_notify_limit(c, l, PLD_IN, c->stats.imp_routes); l = &c->out_limit; if (l->action && (c->stats.exp_routes > l->limit)) channel_notify_limit(c, l, PLD_OUT, c->stats.exp_routes); } static inline void channel_reset_limit(struct channel_limit *l) { if (l->action) l->state = PLS_INITIAL; } static inline void proto_do_start(struct proto *p) { p->active = 1; p->do_start = 1; ev_schedule(p->event); } static void proto_do_up(struct proto *p) { if (!p->main_source) { p->main_source = rt_get_source(p, 0); rt_lock_source(p->main_source); } proto_start_channels(p); } static inline void proto_do_pause(struct proto *p) { proto_pause_channels(p); } static void proto_do_stop(struct proto *p) { p->down_sched = 0; p->gr_recovery = 0; p->do_stop = 1; ev_schedule(p->event); if (p->main_source) { rt_unlock_source(p->main_source); p->main_source = NULL; } proto_stop_channels(p); } static void proto_do_down(struct proto *p) { p->down_code = 0; neigh_prune(); rfree(p->pool); p->pool = NULL; /* Shutdown is finished in the protocol event */ if (proto_is_done(p)) ev_schedule(p->event); } /** * proto_notify_state - notify core about protocol state change * @p: protocol the state of which has changed * @ps: the new status * * Whenever a state of a protocol changes due to some event internal * to the protocol (i.e., not inside a start() or shutdown() hook), * it should immediately notify the core about the change by calling * proto_notify_state() which will write the new state to the &proto * structure and take all the actions necessary to adapt to the new * state. State change to PS_DOWN immediately frees resources of protocol * and might execute start callback of protocol; therefore, * it should be used at tail positions of protocol callbacks. */ void proto_notify_state(struct proto *p, uint state) { uint ps = p->proto_state; DBG("%s reporting state transition %s -> %s\n", p->name, p_states[ps], p_states[state]); if (state == ps) return; p->proto_state = state; p->last_state_change = current_time(); switch (state) { case PS_START: ASSERT(ps == PS_DOWN || ps == PS_UP); if (ps == PS_DOWN) proto_do_start(p); else proto_do_pause(p); break; case PS_UP: ASSERT(ps == PS_DOWN || ps == PS_START); if (ps == PS_DOWN) proto_do_start(p); proto_do_up(p); break; case PS_STOP: ASSERT(ps == PS_START || ps == PS_UP); proto_do_stop(p); break; case PS_DOWN: if (ps != PS_STOP) proto_do_stop(p); proto_do_down(p); break; default: bug("%s: Invalid state %d", p->name, ps); } proto_log_state_change(p); } /* * CLI Commands */ static char * proto_state_name(struct proto *p) { switch (p->proto_state) { case PS_DOWN: return p->active ? "flush" : "down"; case PS_START: return "start"; case PS_UP: return "up"; case PS_STOP: return "stop"; default: return "???"; } } static void channel_show_stats(struct channel *c) { struct proto_stats *s = &c->stats; if (c->in_keep_filtered) cli_msg(-1006, " Routes: %u imported, %u filtered, %u exported, %u preferred", s->imp_routes, s->filt_routes, s->exp_routes, s->pref_routes); else cli_msg(-1006, " Routes: %u imported, %u exported, %u preferred", s->imp_routes, s->exp_routes, s->pref_routes); cli_msg(-1006, " Route change stats: received rejected filtered ignored accepted"); cli_msg(-1006, " Import updates: %10u %10u %10u %10u %10u", s->imp_updates_received, s->imp_updates_invalid, s->imp_updates_filtered, s->imp_updates_ignored, s->imp_updates_accepted); cli_msg(-1006, " Import withdraws: %10u %10u --- %10u %10u", s->imp_withdraws_received, s->imp_withdraws_invalid, s->imp_withdraws_ignored, s->imp_withdraws_accepted); cli_msg(-1006, " Export updates: %10u %10u %10u --- %10u", s->exp_updates_received, s->exp_updates_rejected, s->exp_updates_filtered, s->exp_updates_accepted); cli_msg(-1006, " Export withdraws: %10u --- --- --- %10u", s->exp_withdraws_received, s->exp_withdraws_accepted); } void channel_show_limit(struct channel_limit *l, const char *dsc) { if (!l->action) return; cli_msg(-1006, " %-16s%d%s", dsc, l->limit, l->state ? " [HIT]" : ""); cli_msg(-1006, " Action: %s", channel_limit_name(l)); } void channel_show_info(struct channel *c) { cli_msg(-1006, " Channel %s", c->name); cli_msg(-1006, " State: %s", c_states[c->channel_state]); cli_msg(-1006, " Table: %s", c->table->name); cli_msg(-1006, " Preference: %d", c->preference); cli_msg(-1006, " Input filter: %s", filter_name(c->in_filter)); cli_msg(-1006, " Output filter: %s", filter_name(c->out_filter)); if (graceful_restart_state == GRS_ACTIVE) cli_msg(-1006, " GR recovery: %s%s", c->gr_lock ? " pending" : "", c->gr_wait ? " waiting" : ""); channel_show_limit(&c->rx_limit, "Receive limit:"); channel_show_limit(&c->in_limit, "Import limit:"); channel_show_limit(&c->out_limit, "Export limit:"); if (c->channel_state != CS_DOWN) channel_show_stats(c); } void channel_cmd_debug(struct channel *c, uint mask) { if (cli_access_restricted()) return; c->debug = mask; cli_msg(0, ""); } void proto_cmd_show(struct proto *p, uintptr_t verbose, int cnt) { byte buf[256], tbuf[TM_DATETIME_BUFFER_SIZE]; /* First protocol - show header */ if (!cnt) cli_msg(-2002, "%-10s %-10s %-10s %-6s %-12s %s", "Name", "Proto", "Table", "State", "Since", "Info"); buf[0] = 0; if (p->proto->get_status) p->proto->get_status(p, buf); tm_format_time(tbuf, &config->tf_proto, p->last_state_change); cli_msg(-1002, "%-10s %-10s %-10s %-6s %-12s %s", p->name, p->proto->name, p->main_channel ? p->main_channel->table->name : "---", proto_state_name(p), tbuf, buf); if (verbose) { 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_set) cli_msg(-1006, " VRF: %s", p->vrf ? p->vrf->name : "default"); if (p->proto->show_proto_info) p->proto->show_proto_info(p); else { struct channel *c; WALK_LIST(c, p->channels) channel_show_info(c); } cli_msg(-1006, ""); } } void proto_cmd_disable(struct proto *p, uintptr_t arg, int cnt UNUSED) { if (p->disabled) { cli_msg(-8, "%s: already disabled", p->name); return; } 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, uintptr_t arg, int cnt UNUSED) { if (!p->disabled) { cli_msg(-10, "%s: already enabled", p->name); return; } 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, uintptr_t arg, int cnt UNUSED) { if (p->disabled) { cli_msg(-8, "%s: already disabled", p->name); return; } 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); cli_msg(-12, "%s: restarted", p->name); } void proto_cmd_reload(struct proto *p, uintptr_t dir, int cnt UNUSED) { struct channel *c; if (p->disabled) { cli_msg(-8, "%s: already disabled", p->name); return; } /* If the protocol in not UP, it has no routes */ if (p->proto_state != PS_UP) return; /* All channels must support reload */ if (dir != CMD_RELOAD_OUT) WALK_LIST(c, p->channels) if ((c->channel_state == CS_UP) && !channel_reloadable(c)) { cli_msg(-8006, "%s: reload failed", p->name); return; } log(L_INFO "Reloading protocol %s", p->name); /* re-importing routes */ if (dir != CMD_RELOAD_OUT) WALK_LIST(c, p->channels) if (c->channel_state == CS_UP) channel_request_reload(c); /* re-exporting routes */ if (dir != CMD_RELOAD_IN) WALK_LIST(c, p->channels) if (c->channel_state == CS_UP) channel_request_feeding(c); cli_msg(-15, "%s: reloading", p->name); } extern void pipe_update_debug(struct proto *P); void proto_cmd_debug(struct proto *p, uintptr_t mask, int cnt UNUSED) { p->debug = mask; #ifdef CONFIG_PIPE if (p->proto == &proto_pipe) pipe_update_debug(p); #endif } void proto_cmd_mrtdump(struct proto *p, uintptr_t mask, int cnt UNUSED) { p->mrtdump = mask; } static void proto_apply_cmd_symbol(const struct symbol *s, void (* cmd)(struct proto *, uintptr_t, int), uintptr_t arg) { if (s->class != SYM_PROTO) { cli_msg(9002, "%s is not a protocol", s->name); return; } cmd(s->proto->proto, arg, 0); cli_msg(0, ""); } static void proto_apply_cmd_patt(const char *patt, void (* cmd)(struct proto *, uintptr_t, int), uintptr_t arg) { struct proto *p; int cnt = 0; WALK_LIST(p, proto_list) if (!patt || patmatch(patt, p->name)) cmd(p, arg, cnt++); if (!cnt) cli_msg(8003, "No protocols match"); else cli_msg(0, ""); } void proto_apply_cmd(struct proto_spec ps, void (* cmd)(struct proto *, uintptr_t, int), int restricted, uintptr_t arg) { if (restricted && cli_access_restricted()) return; if (ps.patt) proto_apply_cmd_patt(ps.ptr, cmd, arg); else proto_apply_cmd_symbol(ps.ptr, cmd, arg); } struct proto * proto_get_named(struct symbol *sym, struct protocol *pr) { struct proto *p, *q; if (sym) { if (sym->class != SYM_PROTO) cf_error("%s: Not a protocol", sym->name); p = sym->proto->proto; if (!p || p->proto != pr) cf_error("%s: Not a %s protocol", sym->name, pr->name); } else { p = NULL; WALK_LIST(q, proto_list) if ((q->proto == pr) && (q->proto_state != PS_DOWN)) { if (p) cf_error("There are multiple %s protocols running", pr->name); p = q; } if (!p) cf_error("There is no %s protocol running", pr->name); } return p; } struct proto * proto_iterate_named(struct symbol *sym, struct protocol *proto, struct proto *old) { if (sym) { /* Just the first pass */ if (old) { cli_msg(0, ""); return NULL; } if (sym->class != SYM_PROTO) cf_error("%s: Not a protocol", sym->name); struct proto *p = sym->proto->proto; if (!p || (p->proto != proto)) cf_error("%s: Not a %s protocol", sym->name, proto->name); return p; } else { for (struct proto *p = !old ? HEAD(proto_list) : NODE_NEXT(old); NODE_VALID(p); p = NODE_NEXT(p)) { if ((p->proto == proto) && (p->proto_state != PS_DOWN)) { cli_separator(this_cli); return p; } } /* Not found anything during first pass */ if (!old) cf_error("There is no %s protocol running", proto->name); /* No more items */ cli_msg(0, ""); return NULL; } } bird-2.0.8/nest/proto-hooks.c0000664000175000017500000002632514025744326014775 0ustar feelafeela/* * BIRD -- Documentation for Protocol Hooks (dummy source file) * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Protocol hooks * * Each protocol can provide a rich set of hook functions referred to by pointers * in either the &proto or &protocol structure. They are called by the core whenever * it wants the protocol to perform some action or to notify the protocol about * any change of its environment. All of the hooks can be set to %NULL which means * to ignore the change or to take a default action. */ /** * preconfig - protocol preconfiguration * @p: a routing protocol * @c: new configuration * * The preconfig() hook is called before parsing of a new configuration. */ void preconfig(struct protocol *p, struct config *c) { DUMMY; } /** * postconfig - instance post-configuration * @c: instance configuration * * The postconfig() hook is called for each configured instance after * parsing of the new configuration is finished. */ void postconfig(struct proto_config *c) { DUMMY; } /** * init - initialize an instance * @c: instance configuration * * The init() hook is called by the core to create a protocol instance * according to supplied protocol configuration. * * Result: a pointer to the instance created */ struct proto *init(struct proto_config *c) { DUMMY; } /** * reconfigure - request instance reconfiguration * @p: an instance * @c: new configuration * * The core calls the reconfigure() hook whenever it wants to ask the * protocol for switching to a new configuration. If the reconfiguration * is possible, the hook returns 1. Otherwise, it returns 0 and the core * will shut down the instance and start a new one with the new configuration. * * After the protocol confirms reconfiguration, it must no longer keep any * references to the old configuration since the memory it's stored in can * be re-used at any time. */ int reconfigure(struct proto *p, struct proto_config *c) { DUMMY; } /** * dump - dump protocol state * @p: an instance * * This hook dumps the complete state of the instance to the * debug output. */ void dump(struct proto *p) { DUMMY; } /** * dump_attrs - dump protocol-dependent attributes * @e: a route entry * * This hook dumps all attributes in the &rte which belong to this * protocol to the debug output. */ void dump_attrs(rte *e) { DUMMY; } /** * start - request instance startup * @p: protocol instance * * The start() hook is called by the core when it wishes to start * the instance. Multitable protocols should lock their tables here. * * Result: new protocol state */ int start(struct proto *p) { DUMMY; } /** * shutdown - request instance shutdown * @p: protocol instance * * The stop() hook is called by the core when it wishes to shut * the instance down for some reason. * * Returns: new protocol state */ int shutdown(struct proto *p) { DUMMY; } /** * cleanup - request instance cleanup * @p: protocol instance * * The cleanup() hook is called by the core when the protocol became * hungry/down, i.e. all protocol ahooks and routes are flushed. * Multitable protocols should unlock their tables here. */ void cleanup(struct proto *p) { DUMMY; } /** * get_status - get instance status * @p: protocol instance * @buf: buffer to be filled with the status string * * This hook is called by the core if it wishes to obtain an brief one-line user friendly * representation of the status of the instance to be printed by the accept_ra_types specifies which kind of route announcements * protocol wants to receive. */ void rt_notify(struct proto *p, net *net, rte *new, rte *old, ea_list *attrs) { DUMMY; } /** * neigh_notify - notify instance about neighbor status change * @neigh: a neighbor cache entry * * The neigh_notify() hook is called by the neighbor cache whenever * a neighbor changes its state, that is it gets disconnected or a * sticky neighbor gets connected. */ void neigh_notify(neighbor *neigh) { DUMMY; } /** * make_tmp_attrs - convert embedded attributes to temporary ones * @e: route entry * @pool: linear pool to allocate attribute memory in * * This hook is called by the routing table functions if they need * to convert the protocol attributes embedded directly in the &rte * to temporary extended attributes in order to distribute them * to other protocols or to filters. make_tmp_attrs() creates * an &ea_list in the linear pool @pool, fills it with values of the * temporary attributes and returns a pointer to it. */ ea_list *make_tmp_attrs(rte *e, struct linpool *pool) { DUMMY; } /** * store_tmp_attrs - convert temporary attributes to embedded ones * @e: route entry * @attrs: temporary attributes to be converted * * This hook is an exact opposite of make_tmp_attrs() -- it takes * a list of extended attributes and converts them to attributes * embedded in the &rte corresponding to this protocol. * * You must be prepared for any of the attributes being missing * from the list and use default values instead. */ void store_tmp_attrs(rte *e, ea_list *attrs) { DUMMY; } /** * preexport - pre-filtering decisions before route export * @p: protocol instance the route is going to be exported to * @e: the route in question * @attrs: extended attributes of the route * @pool: linear pool for allocation of all temporary data * * The preexport() hook is called as the first step of a exporting * a route from a routing table to the protocol instance. It can modify * route attributes and force acceptance or rejection of the route before * the user-specified filters are run. See rte_announce() for a complete description * of the route distribution process. * * The standard use of this hook is to reject routes having originated * from the same instance and to set default values of the protocol's metrics. * * Result: 1 if the route has to be accepted, -1 if rejected and 0 if it * should be passed to the filters. */ int preexport(struct proto *p, rte **e, ea_list **attrs, struct linpool *pool) { DUMMY; } /** * rte_recalculate - prepare routes for comparison * @table: a routing table * @net: a network entry * @new: new route for the network * @old: old route for the network * @old_best: old best route for the network (may be NULL) * * This hook is called when a route change (from @old to @new for a * @net entry) is propagated to a @table. It may be used to prepare * routes for comparison by rte_better() in the best route * selection. @new may or may not be in @net->routes list, * @old is not there. * * Result: 1 if the ordering implied by rte_better() changes enough * that full best route calculation have to be done, 0 otherwise. */ int rte_recalculate(struct rtable *table, struct network *net, struct rte *new, struct rte *old, struct rte *old_best) { DUMMY; } /** * rte_better - compare metrics of two routes * @new: the new route * @old: the original route * * This hook gets called when the routing table contains two routes * for the same network which have originated from different instances * of a single protocol and it wants to select which one is preferred * over the other one. Protocols usually decide according to route metrics. * * Result: 1 if @new is better (more preferred) than @old, 0 otherwise. */ int rte_better(rte *new, rte *old) { DUMMY; } /** * rte_same - compare two routes * @e1: route * @e2: route * * The rte_same() hook tests whether the routes @e1 and @e2 belonging * to the same protocol instance have identical contents. Contents of * &rta, all the extended attributes and &rte preference are checked * by the core code, no need to take care of them here. * * Result: 1 if @e1 is identical to @e2, 0 otherwise. */ int rte_same(rte *e1, rte *e2) { DUMMY; } /** * rte_insert - notify instance about route insertion * @n: network * @e: route * * This hook is called whenever a &rte belonging to the instance * is accepted for insertion to a routing table. * * Please avoid using this function in new protocols. */ void rte_insert(net *n, rte *e) { DUMMY; } /** * rte_remove - notify instance about route removal * @n: network * @e: route * * This hook is called whenever a &rte belonging to the instance * is removed from a routing table. * * Please avoid using this function in new protocols. */ void rte_remove(net *n, rte *e) { DUMMY; } bird-2.0.8/nest/password.h0000664000175000017500000000166014025744326014353 0ustar feelafeela/* * BIRD -- Password handling * * (c) 1999 Pavel Machek * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef PASSWORD_H #define PASSWORD_H struct password_item { node n; const char *password; /* Key data, null terminated */ uint length; /* Key length, without null */ uint id; /* Key ID */ uint alg; /* MAC algorithm */ btime accfrom, accto, genfrom, gento; }; extern struct password_item *last_password_item; struct password_item *password_find(list *l, int first_fit); struct password_item *password_find_by_id(list *l, uint id); struct password_item *password_find_by_value(list *l, char *pass, uint size); static inline int password_verify(struct password_item *p1, char *p2, uint size) { char buf[size]; strncpy(buf, p1->password, size); return !memcmp(buf, p2, size); } uint max_mac_length(list *l); #endif bird-2.0.8/nest/password.c0000664000175000017500000000277414025744326014355 0ustar feelafeela/* * BIRD -- Password handling * * (c) 1999 Pavel Machek * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "nest/password.h" #include "lib/string.h" #include "lib/timer.h" #include "lib/mac.h" struct password_item *last_password_item = NULL; struct password_item * password_find(list *l, int first_fit) { struct password_item *pi; struct password_item *pf = NULL; btime now_ = current_real_time(); if (l) { WALK_LIST(pi, *l) { if ((pi->genfrom < now_) && (pi->gento > now_)) { if (first_fit) return pi; if (!pf || pf->genfrom < pi->genfrom) pf = pi; } } } return pf; } struct password_item * password_find_by_id(list *l, uint id) { struct password_item *pi; btime now_ = current_real_time(); if (!l) return NULL; WALK_LIST(pi, *l) if ((pi->id == id) && (pi->accfrom <= now_) && (now_ < pi->accto)) return pi; return NULL; } struct password_item * password_find_by_value(list *l, char *pass, uint size) { struct password_item *pi; btime now_ = current_real_time(); if (!l) return NULL; WALK_LIST(pi, *l) if (password_verify(pi, pass, size) && (pi->accfrom <= now_) && (now_ < pi->accto)) return pi; return NULL; } uint max_mac_length(list *l) { struct password_item *pi; uint val = 0; if (!l) return 0; WALK_LIST(pi, *l) val = MAX(val, mac_type_length(pi->alg)); return val; } bird-2.0.8/nest/neighbor.c0000664000175000017500000003503514025744326014304 0ustar feelafeela/* * BIRD -- Neighbor Cache * * (c) 1998--2000 Martin Mares * (c) 2008--2018 Ondrej Zajicek * (c) 2008--2018 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Neighbor cache * * Most routing protocols need to associate their internal state data with * neighboring routers, check whether an address given as the next hop attribute * of a route is really an address of a directly connected host and which * interface is it connected through. Also, they often need to be notified when * a neighbor ceases to exist or when their long awaited neighbor becomes * connected. The neighbor cache is there to solve all these problems. * * The neighbor cache maintains a collection of neighbor entries. Each entry * represents one IP address corresponding to either our directly connected * neighbor or our own end of the link (when the scope of the address is set to * %SCOPE_HOST) together with per-neighbor data belonging to a single protocol. * A neighbor entry may be bound to a specific interface, which is required for * link-local IP addresses and optional for global IP addresses. * * Neighbor cache entries are stored in a hash table, which is indexed by triple * (protocol, IP, requested-iface), so if both regular and iface-bound neighbors * are requested, they are represented by two neighbor cache entries. Active * entries are also linked in per-interface list (allowing quick processing of * interface change events). Inactive entries exist only when the protocol has * explicitly requested it via the %NEF_STICKY flag because it wishes to be * notified when the node will again become a neighbor. Such entries are instead * linked in a special list, which is walked whenever an interface changes its * state to up. Neighbor entry VRF association is implied by respective * protocol. * * Besides the already mentioned %NEF_STICKY flag, there is also %NEF_ONLINK, * which specifies that neighbor should be considered reachable on given iface * regardless of associated address ranges, and %NEF_IFACE, which represents * pseudo-neighbor entry for whole interface (and uses %IPA_NONE IP address). * * When a neighbor event occurs (a neighbor gets disconnected or a sticky * inactive neighbor becomes connected), the protocol hook neigh_notify() is * called to advertise the change. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" #include "nest/protocol.h" #include "lib/hash.h" #include "lib/resource.h" #define NEIGH_HASH_SIZE 256 #define NEIGH_HASH_OFFSET 24 static slab *neigh_slab; static list neigh_hash_table[NEIGH_HASH_SIZE], sticky_neigh_list; static inline uint neigh_hash(struct proto *p, ip_addr a, struct iface *i) { return (p->hash_key ^ ipa_hash(a) ^ ptr_hash(i)) >> NEIGH_HASH_OFFSET; } static inline int ifa_better(struct ifa *a, struct ifa *b) { return a && (!b || (a->prefix.pxlen > b->prefix.pxlen)); } static inline int scope_better(int sa, int sb) { /* Order per preference: -1 unknown, 0 for remote, 1 for local */ sa = (sa < 0) ? sa : !sa; sb = (sb < 0) ? sb : !sb; return sa > sb; } static inline int scope_remote(int sa, int sb) { return (sa > SCOPE_HOST) && (sb > SCOPE_HOST); } static int if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags) { struct ifa *b, *addr = NULL; /* Handle iface pseudo-neighbors */ if (flags & NEF_IFACE) return *ap = NULL, (i->flags & IF_UP) ? SCOPE_HOST : -1; /* Host addresses match even if iface is down */ WALK_LIST(b, i->addrs) if (ipa_equal(a, b->ip)) return *ap = b, SCOPE_HOST; /* Rest do not match if iface is down */ if (!(i->flags & IF_UP)) return *ap = NULL, -1; /* Regular neighbors */ WALK_LIST(b, i->addrs) { if (b->flags & IA_PEER) { if (ipa_equal(a, b->opposite) && ifa_better(b, addr)) addr = b; } else { if (ipa_in_netX(a, &b->prefix) && ifa_better(b, addr)) { /* Do not allow IPv4 network and broadcast addresses */ if (ipa_is_ip4(a) && (net_pxlen(&b->prefix) < (IP4_MAX_PREFIX_LENGTH - 1)) && (ipa_equal(a, net_prefix(&b->prefix)) || /* Network address */ ipa_equal(a, b->brd))) /* Broadcast */ return *ap = NULL, -1; addr = b; } } } /* Return found address */ if (addr) return *ap = addr, addr->scope; /* Handle ONLINK flag */ if (flags & NEF_ONLINK) return *ap = NULL, ipa_classify(a) & IADDR_SCOPE_MASK; return *ap = NULL, -1; } static inline int if_connected_any(ip_addr a, struct iface *vrf, uint vrf_set, struct iface **iface, struct ifa **addr, uint flags) { struct iface *i; struct ifa *b; int s, scope = -1; *iface = NULL; *addr = NULL; /* Prefer SCOPE_HOST or longer prefix */ WALK_LIST(i, iface_list) if ((!vrf_set || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0)) if (scope_better(s, scope) || (scope_remote(s, scope) && ifa_better(b, *addr))) { *iface = i; *addr = b; scope = s; } return scope; } /* Is ifa @a subnet of any ifa on iface @ib ? */ static inline int ifa_intersect(struct ifa *a, struct iface *ib) { struct ifa *b; WALK_LIST(b, ib->addrs) if (net_in_netX(&a->prefix, &b->prefix)) return 1; return 0; } /* Is any ifa of iface @ia subnet of any ifa on iface @ib ? */ static inline int if_intersect(struct iface *ia, struct iface *ib) { struct ifa *a, *b; WALK_LIST(a, ia->addrs) WALK_LIST(b, ib->addrs) if (net_in_netX(&a->prefix, &b->prefix)) return 1; return 0; } /** * neigh_find - find or create a neighbor entry * @p: protocol which asks for the entry * @a: IP address of the node to be searched for * @iface: optionally bound neighbor to this iface (may be NULL) * @flags: %NEF_STICKY for sticky entry, %NEF_ONLINK for onlink entry * * Search the neighbor cache for a node with given IP address. Iface can be * specified for link-local addresses or for cases, where neighbor is expected * on given interface. If it is found, a pointer to the neighbor entry is * returned. If no such entry exists and the node is directly connected on one * of our active interfaces, a new entry is created and returned to the caller * with protocol-dependent fields initialized to zero. If the node is not * connected directly or *@a is not a valid unicast IP address, neigh_find() * returns %NULL. */ neighbor * neigh_find(struct proto *p, ip_addr a, struct iface *iface, uint flags) { neighbor *n; int class, scope = -1; uint h = neigh_hash(p, a, iface); struct iface *ifreq = iface; struct ifa *addr = NULL; WALK_LIST(n, neigh_hash_table[h]) /* Search the cache */ if ((n->proto == p) && ipa_equal(n->addr, a) && (n->ifreq == iface)) return n; if (flags & NEF_IFACE) { if (ipa_nonzero(a) || !iface) return NULL; } else { class = ipa_classify(a); if (class < 0) /* Invalid address */ return NULL; if (((class & IADDR_SCOPE_MASK) == SCOPE_HOST) || (((class & IADDR_SCOPE_MASK) == SCOPE_LINK) && !iface) || !(class & IADDR_HOST)) return NULL; /* Bad scope or a somecast */ } if ((flags & NEF_ONLINK) && !iface) return NULL; if (iface) { scope = if_connected(a, iface, &addr, flags); iface = (scope < 0) ? NULL : iface; } else scope = if_connected_any(a, p->vrf, p->vrf_set, &iface, &addr, flags); /* scope < 0 means i don't know neighbor */ /* scope >= 0 <=> iface != NULL */ if ((scope < 0) && !(flags & NEF_STICKY)) return NULL; n = sl_allocz(neigh_slab); add_tail(&neigh_hash_table[h], &n->n); add_tail((scope >= 0) ? &iface->neighbors : &sticky_neigh_list, &n->if_n); n->addr = a; n->ifa = addr; n->iface = iface; n->ifreq = ifreq; n->proto = p; n->flags = flags; n->scope = scope; return n; } /** * neigh_dump - dump specified neighbor entry. * @n: the entry to dump * * This functions dumps the contents of a given neighbor entry to debug output. */ void neigh_dump(neighbor *n) { debug("%p %I %s %s ", n, n->addr, n->iface ? n->iface->name : "[]", n->ifreq ? n->ifreq->name : "[]"); debug("%s %p %08x scope %s", n->proto->name, n->data, n->aux, ip_scope_text(n->scope)); if (n->flags & NEF_STICKY) debug(" STICKY"); if (n->flags & NEF_ONLINK) debug(" ONLINK"); debug("\n"); } /** * neigh_dump_all - dump all neighbor entries. * * This function dumps the contents of the neighbor cache to debug output. */ void neigh_dump_all(void) { neighbor *n; int i; debug("Known neighbors:\n"); for(i=0; iproto->neigh_notify && (n->proto->proto_state != PS_STOP)) n->proto->neigh_notify(n); } static void neigh_up(neighbor *n, struct iface *i, struct ifa *a, int scope) { DBG("Waking up sticky neighbor %I\n", n->addr); n->iface = i; n->ifa = a; n->scope = scope; rem_node(&n->if_n); add_tail(&i->neighbors, &n->if_n); neigh_notify(n); } static void neigh_down(neighbor *n) { DBG("Flushing neighbor %I on %s\n", n->addr, n->iface->name); n->iface = NULL; n->ifa = NULL; n->scope = -1; rem_node(&n->if_n); add_tail(&sticky_neigh_list, &n->if_n); neigh_notify(n); } static inline void neigh_free(neighbor *n) { rem_node(&n->n); rem_node(&n->if_n); sl_free(neigh_slab, n); } /** * neigh_update: update neighbor entry w.r.t. change on specific iface * @n: neighbor to update * @iface: changed iface * * The function recalculates state of the neighbor entry @n assuming that only * the interface @iface may changed its state or addresses. Then, appropriate * actions are executed (the neighbor goes up, down, up-down, or just notified). */ void neigh_update(neighbor *n, struct iface *iface) { struct proto *p = n->proto; struct ifa *ifa = NULL; int scope = -1; /* Iface-bound neighbors ignore other ifaces */ if (n->ifreq && (n->ifreq != iface)) return; /* VRF-bound neighbors ignore changes in other VRFs */ if (p->vrf_set && (p->vrf != iface->master)) return; scope = if_connected(n->addr, iface, &ifa, n->flags); /* Update about already assigned iface, or some other iface */ if (iface == n->iface) { /* When neighbor is going down, try to respawn it on other ifaces */ if ((scope < 0) && (n->scope >= 0) && !n->ifreq && (n->flags & NEF_STICKY)) scope = if_connected_any(n->addr, p->vrf, p->vrf_set, &iface, &ifa, n->flags); } else { /* Continue only if the new variant is better than the existing one */ if (! (scope_better(scope, n->scope) || (scope_remote(scope, n->scope) && ifa_better(ifa, n->ifa)))) return; } /* No change or minor change - ignore or notify */ if ((scope == n->scope) && (iface == n->iface)) { if (ifa != n->ifa) { n->ifa = ifa; neigh_notify(n); } return; } /* Major change - going down and/or going up */ if (n->scope >= 0) neigh_down(n); if ((n->scope < 0) && !(n->flags & NEF_STICKY)) { neigh_free(n); return; } if (scope >= 0) neigh_up(n, iface, ifa, scope); } /** * neigh_if_up: notify neighbor cache about interface up event * @i: interface in question * * Tell the neighbor cache that a new interface became up. * * The neighbor cache wakes up all inactive sticky neighbors with * addresses belonging to prefixes of the interface @i. */ void neigh_if_up(struct iface *i) { struct iface *ii; neighbor *n; node *x, *y; /* Update neighbors that might be better off with the new iface */ WALK_LIST(ii, iface_list) if (!EMPTY_LIST(ii->neighbors) && (ii != i) && if_intersect(i, ii)) WALK_LIST2_DELSAFE(n, x, y, ii->neighbors, if_n) neigh_update(n, i); WALK_LIST2_DELSAFE(n, x, y, sticky_neigh_list, if_n) neigh_update(n, i); } /** * neigh_if_down - notify neighbor cache about interface down event * @i: the interface in question * * Notify the neighbor cache that an interface has ceased to exist. * * It causes all neighbors connected to this interface to be updated or removed. */ void neigh_if_down(struct iface *i) { neighbor *n; node *x, *y; WALK_LIST2_DELSAFE(n, x, y, i->neighbors, if_n) neigh_update(n, i); } /** * neigh_if_link - notify neighbor cache about interface link change * @i: the interface in question * * Notify the neighbor cache that an interface changed link state. All owners of * neighbor entries connected to this interface are notified. */ void neigh_if_link(struct iface *i) { neighbor *n; node *x, *y; WALK_LIST2_DELSAFE(n, x, y, i->neighbors, if_n) neigh_notify(n); } /** * neigh_ifa_update: notify neighbor cache about interface address add or remove event * @a: interface address in question * * Tell the neighbor cache that an address was added or removed. * * The neighbor cache wakes up all inactive sticky neighbors with * addresses belonging to prefixes of the interface belonging to @ifa * and causes all unreachable neighbors to be flushed. */ void neigh_ifa_up(struct ifa *a) { struct iface *i = a->iface, *ii; neighbor *n; node *x, *y; /* Update neighbors that might be better off with the new ifa */ WALK_LIST(ii, iface_list) if (!EMPTY_LIST(ii->neighbors) && ifa_intersect(a, ii)) WALK_LIST2_DELSAFE(n, x, y, ii->neighbors, if_n) neigh_update(n, i); /* Wake up all sticky neighbors that are reachable now */ WALK_LIST2_DELSAFE(n, x, y, sticky_neigh_list, if_n) neigh_update(n, i); } void neigh_ifa_down(struct ifa *a) { struct iface *i = a->iface; neighbor *n; node *x, *y; /* Update all neighbors whose scope has changed */ WALK_LIST2_DELSAFE(n, x, y, i->neighbors, if_n) if (n->ifa == a) neigh_update(n, i); } static inline void neigh_prune_one(neighbor *n) { if (n->proto->proto_state != PS_DOWN) return; neigh_free(n); } /** * neigh_prune - prune neighbor cache * * neigh_prune() examines all neighbor entries cached and removes those * corresponding to inactive protocols. It's called whenever a protocol * is shut down to get rid of all its heritage. */ void neigh_prune(void) { neighbor *n; node *m; int i; DBG("Pruning neighbors\n"); for(i=0; i * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_LOCKS_H_ #define _BIRD_LOCKS_H_ #include "lib/resource.h" #include "lib/event.h" /* * The object locks are used for controlling exclusive access * to various physical resources like UDP ports on specific devices. * When you want to access such resource, you ask for a object lock * structure, fill in specification of the object and your function * you want to have called when the object is available and invoke * olock_acquire() afterwards. When the object becomes free, the lock * manager calls your function. To free the object lock, just call rfree * on its resource. */ struct object_lock { resource r; ip_addr addr; /* Identification of a object: IP address */ uint type; /* ... object type (OBJLOCK_xxx) */ uint port; /* ... port number */ uint inst; /* ... instance ID */ struct iface *iface; /* ... interface */ struct iface *vrf; /* ... or VRF (if iface is unknown) */ void (*hook)(struct object_lock *); /* Called when the lock succeeds */ void *data; /* User data */ /* ... internal to lock manager, don't touch ... */ node n; /* Node in list of olocks */ int state; /* OLOCK_STATE_xxx */ list waiters; /* Locks waiting for the same resource */ }; struct object_lock *olock_new(pool *); void olock_acquire(struct object_lock *); void olock_init(void); #define OBJLOCK_UDP 1 /* UDP port */ #define OBJLOCK_TCP 2 /* TCP port */ #define OBJLOCK_IP 3 /* IP protocol */ #define OLOCK_STATE_FREE 0 #define OLOCK_STATE_LOCKED 1 #define OLOCK_STATE_WAITING 2 #define OLOCK_STATE_EVENT 3 /* waiting for unlock processing */ #endif bird-2.0.8/nest/locks.c0000664000175000017500000001163214025744326013617 0ustar feelafeela/* * BIRD Object Locks * * (c) 1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Object locks * * The lock module provides a simple mechanism for avoiding conflicts between * various protocols which would like to use a single physical resource (for * example a network port). It would be easy to say that such collisions can * occur only when the user specifies an invalid configuration and therefore * he deserves to get what he has asked for, but unfortunately they can also * arise legitimately when the daemon is reconfigured and there exists (although * for a short time period only) an old protocol instance being shut down and a new one * willing to start up on the same interface. * * The solution is very simple: when any protocol wishes to use a network port * or some other non-shareable resource, it asks the core to lock it and it doesn't * use the resource until it's notified that it has acquired the lock. * * Object locks are represented by &object_lock structures which are in turn a * kind of resource. Lockable resources are uniquely determined by resource type * (%OBJLOCK_UDP for a UDP port etc.), IP address (usually a broadcast or * multicast address the port is bound to), port number, interface and optional * instance ID. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "lib/resource.h" #include "nest/locks.h" #include "nest/iface.h" static list olock_list; static event *olock_event; static inline int olock_same(struct object_lock *x, struct object_lock *y) { return x->type == y->type && x->iface == y->iface && x->vrf == y->vrf && x->port == y->port && x->inst == y->inst && ipa_equal(x->addr, y->addr); } static void olock_free(resource *r) { struct object_lock *q, *l = (struct object_lock *) r; node *n; DBG("olock: Freeing %p\n", l); switch (l->state) { case OLOCK_STATE_FREE: break; case OLOCK_STATE_LOCKED: case OLOCK_STATE_EVENT: rem_node(&l->n); n = HEAD(l->waiters); if (n->next) { DBG("olock: -> %p becomes locked\n", n); q = SKIP_BACK(struct object_lock, n, n); rem_node(n); add_tail_list(&q->waiters, &l->waiters); q->state = OLOCK_STATE_EVENT; add_head(&olock_list, n); ev_schedule(olock_event); } break; case OLOCK_STATE_WAITING: rem_node(&l->n); break; default: ASSERT(0); } } static void olock_dump(resource *r) { struct object_lock *l = (struct object_lock *) r; static char *olock_states[] = { "free", "locked", "waiting", "event" }; debug("(%d:%s:%I:%d:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, l->inst, olock_states[l->state]); if (!EMPTY_LIST(l->waiters)) debug(" [wanted]\n"); } static struct resclass olock_class = { "ObjLock", sizeof(struct object_lock), olock_free, olock_dump, NULL, NULL, }; /** * olock_new - create an object lock * @p: resource pool to create the lock in. * * The olock_new() function creates a new resource of type &object_lock * and returns a pointer to it. After filling in the structure, the caller * should call olock_acquire() to do the real locking. */ struct object_lock * olock_new(pool *p) { struct object_lock *l = ralloc(p, &olock_class); l->state = OLOCK_STATE_FREE; init_list(&l->waiters); return l; } /** * olock_acquire - acquire a lock * @l: the lock to acquire * * This function attempts to acquire exclusive access to the non-shareable * resource described by the lock @l. It returns immediately, but as soon * as the resource becomes available, it calls the hook() function set up * by the caller. * * When you want to release the resource, just rfree() the lock. */ void olock_acquire(struct object_lock *l) { node *n; struct object_lock *q; WALK_LIST(n, olock_list) { q = SKIP_BACK(struct object_lock, n, n); if (olock_same(q, l)) { l->state = OLOCK_STATE_WAITING; add_tail(&q->waiters, &l->n); DBG("olock: %p waits\n", l); return; } } DBG("olock: %p acquired immediately\n", l); l->state = OLOCK_STATE_EVENT; add_head(&olock_list, &l->n); ev_schedule(olock_event); } static void olock_run_event(void *unused UNUSED) { node *n; struct object_lock *q; DBG("olock: Processing events\n"); for(;;) { n = HEAD(olock_list); if (!n->next) break; q = SKIP_BACK(struct object_lock, n, n); if (q->state != OLOCK_STATE_EVENT) break; DBG("olock: %p locked\n", q); q->state = OLOCK_STATE_LOCKED; rem_node(&q->n); add_tail(&olock_list, &q->n); q->hook(q); } } /** * olock_init - initialize the object lock mechanism * * This function is called during BIRD startup. It initializes * all the internal data structures of the lock module. */ void olock_init(void) { DBG("olock: init\n"); init_list(&olock_list); olock_event = ev_new_init(&root_pool, olock_run_event, NULL); } bird-2.0.8/nest/iface.h0000664000175000017500000001406614025744326013564 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Network Interfaces * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_IFACE_H_ #define _BIRD_IFACE_H_ #include "lib/lists.h" #include "lib/ip.h" extern list iface_list; struct proto; struct pool; struct ifa { /* Interface address */ node n; struct iface *iface; /* Interface this address belongs to */ net_addr prefix; /* Network prefix */ ip_addr ip; /* IP address of this host */ ip_addr brd; /* Broadcast address */ ip_addr opposite; /* Opposite end of a point-to-point link */ unsigned scope; /* Interface address scope */ unsigned flags; /* Analogous to iface->flags */ }; struct iface { node n; char name[16]; unsigned flags; unsigned mtu; unsigned index; /* OS-dependent interface index */ unsigned master_index; /* Interface index of master iface */ struct iface *master; /* Master iface (e.g. for VRF) */ list addrs; /* Addresses assigned to this interface */ struct ifa *addr4; /* Primary address for IPv4 */ struct ifa *addr6; /* Primary address for IPv6 */ struct ifa *llv6; /* Primary link-local address for IPv6 */ ip4_addr sysdep; /* Arbitrary IPv4 address for internal sysdep use */ list neighbors; /* All neighbors on this interface */ }; #define IF_UP 1 /* Currently just IF_ADMIN_UP */ #define IF_MULTIACCESS 2 #define IF_BROADCAST 4 #define IF_MULTICAST 8 #define IF_SHUTDOWN 0x10 /* Interface disappeared */ #define IF_LOOPBACK 0x20 #define IF_IGNORE 0x40 /* Not to be used by routing protocols (loopbacks etc.) */ #define IF_ADMIN_UP 0x80 /* Administrative up (e.g. IFF_UP in Linux) */ #define IF_LINK_UP 0x100 /* Link available (e.g. IFF_LOWER_UP in Linux) */ #define IA_PRIMARY 0x10000 /* This address is primary */ #define IA_SECONDARY 0x20000 /* This address has been reported as secondary by the kernel */ #define IA_PEER 0x40000 /* A peer/ptp address */ #define IA_HOST 0x80000 /* A host/loopback address */ #define IA_FLAGS 0xff0000 /* * There are three kinds of addresses in BIRD: * - Standard (prefix-based) addresses, these may define ifa.opposite (for /30 or /31). * - Peer/ptp addresses, without common prefix for ifa.ip and ifa.opposite. * ifa.opposite is defined and ifa.prefix/pxlen == ifa.opposite/32 (for simplicity). * - Host addresses, with ifa.prefix/pxlen == ifa.ip/32 (or /128). * May be considered a special case of standard addresses. * * Peer addresses (AFAIK) do not exist in IPv6. Linux also supports generalized peer * addresses (with pxlen < 32 and ifa.ip outside prefix), we do not support that. */ #define IF_JUST_CREATED 0x10000000 /* Send creation event as soon as possible */ #define IF_TMP_DOWN 0x20000000 /* Temporary shutdown due to interface reconfiguration */ #define IF_UPDATED 0x40000000 /* Iface touched in last scan */ #define IF_NEEDS_RECALC 0x80000000 /* Preferred address recalculation is needed */ #define IF_LOST_ADDR4 0x01000000 /* Preferred address was deleted, notification needed */ #define IF_LOST_ADDR6 0x02000000 #define IF_LOST_LLV6 0x04000000 #define IA_UPDATED IF_UPDATED /* Address touched in last scan */ /* Interface change events */ #define IF_CHANGE_UP 1 #define IF_CHANGE_DOWN 2 #define IF_CHANGE_MTU 4 #define IF_CHANGE_CREATE 8 /* Seen this interface for the first time */ #define IF_CHANGE_LINK 0x10 #define IF_CHANGE_ADDR4 0x100 /* Change of iface->addr4 */ #define IF_CHANGE_ADDR6 0x200 /* ... */ #define IF_CHANGE_LLV6 0x400 #define IF_CHANGE_SYSDEP 0x800 #define IF_CHANGE_TOO_MUCH 0x40000000 /* Used internally */ #define IF_CHANGE_UPDOWN (IF_CHANGE_UP | IF_CHANGE_DOWN) #define IF_CHANGE_PREFERRED (IF_CHANGE_ADDR4 | IF_CHANGE_ADDR6 | IF_CHANGE_LLV6) void if_init(void); void if_dump(struct iface *); void if_dump_all(void); void ifa_dump(struct ifa *); void if_show(void); void if_show_summary(void); struct iface *if_update(struct iface *); void if_delete(struct iface *old); struct ifa *ifa_update(struct ifa *); void ifa_delete(struct ifa *); void if_start_update(void); void if_end_partial_update(struct iface *); void if_end_update(void); void if_flush_ifaces(struct proto *p); void if_feed_baby(struct proto *); struct iface *if_find_by_index(unsigned); struct iface *if_find_by_name(const char *); struct iface *if_get_by_name(const char *); void if_recalc_all_preferred_addresses(void); /* The Neighbor Cache */ typedef struct neighbor { node n; /* Node in neighbor hash table chain */ node if_n; /* Node in per-interface neighbor list */ ip_addr addr; /* Address of the neighbor */ struct ifa *ifa; /* Ifa on related iface */ struct iface *iface; /* Interface it's connected to */ struct iface *ifreq; /* Requested iface, NULL for any */ struct proto *proto; /* Protocol this belongs to */ void *data; /* Protocol-specific data */ uint aux; /* Protocol-specific data */ u16 flags; /* NEF_* flags */ s16 scope; /* Address scope, -1 for unreachable neighbors, SCOPE_HOST when it's our own address */ } neighbor; #define NEF_STICKY 1 #define NEF_ONLINK 2 #define NEF_IFACE 4 /* Entry for whole iface */ neighbor *neigh_find(struct proto *p, ip_addr a, struct iface *ifa, uint flags); void neigh_dump(neighbor *); void neigh_dump_all(void); void neigh_prune(void); void neigh_if_up(struct iface *); void neigh_if_down(struct iface *); void neigh_if_link(struct iface *); void neigh_ifa_up(struct ifa *a); void neigh_ifa_down(struct ifa *a); void neigh_init(struct pool *); /* * Interface Pattern Lists */ struct iface_patt_node { node n; int positive; const byte *pattern; net_addr prefix; }; struct iface_patt { node n; list ipn_list; /* A list of struct iface_patt_node */ /* Protocol-specific data follow after this structure */ }; int iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a); struct iface_patt *iface_patt_find(list *l, struct iface *i, struct ifa *a); int iface_patts_equal(list *, list *, int (*)(struct iface_patt *, struct iface_patt *)); u32 if_choose_router_id(struct iface_patt *mask, u32 old_id); #endif bird-2.0.8/nest/iface.c0000664000175000017500000005027114025744326013555 0ustar feelafeela/* * BIRD -- Management of Interfaces and Neighbor Cache * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Interfaces * * The interface module keeps track of all network interfaces in the * system and their addresses. * * Each interface is represented by an &iface structure which carries * interface capability flags (%IF_MULTIACCESS, %IF_BROADCAST etc.), * MTU, interface name and index and finally a linked list of network * prefixes assigned to the interface, each one represented by * struct &ifa. * * The interface module keeps a `soft-up' state for each &iface which * is a conjunction of link being up, the interface being of a `sane' * type and at least one IP address assigned to it. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/iface.h" #include "nest/protocol.h" #include "nest/cli.h" #include "lib/resource.h" #include "lib/string.h" #include "conf/conf.h" #include "sysdep/unix/krt.h" static pool *if_pool; list iface_list; static void if_recalc_preferred(struct iface *i); /** * ifa_dump - dump interface address * @a: interface address descriptor * * This function dumps contents of an &ifa to the debug output. */ void ifa_dump(struct ifa *a) { debug("\t%I, net %N bc %I -> %I%s%s%s%s\n", a->ip, &a->prefix, a->brd, a->opposite, (a->flags & IA_PRIMARY) ? " PRIMARY" : "", (a->flags & IA_SECONDARY) ? " SEC" : "", (a->flags & IA_HOST) ? " HOST" : "", (a->flags & IA_PEER) ? " PEER" : ""); } /** * if_dump - dump interface * @i: interface to dump * * This function dumps all information associated with a given * network interface to the debug output. */ void if_dump(struct iface *i) { struct ifa *a; debug("IF%d: %s", i->index, i->name); if (i->flags & IF_SHUTDOWN) debug(" SHUTDOWN"); if (i->flags & IF_UP) debug(" UP"); else debug(" DOWN"); if (i->flags & IF_ADMIN_UP) debug(" LINK-UP"); if (i->flags & IF_MULTIACCESS) debug(" MA"); if (i->flags & IF_BROADCAST) debug(" BC"); if (i->flags & IF_MULTICAST) debug(" MC"); if (i->flags & IF_LOOPBACK) debug(" LOOP"); if (i->flags & IF_IGNORE) debug(" IGN"); if (i->flags & IF_TMP_DOWN) debug(" TDOWN"); debug(" MTU=%d\n", i->mtu); WALK_LIST(a, i->addrs) { ifa_dump(a); ASSERT(!!(a->flags & IA_PRIMARY) == ((a == i->addr4) || (a == i->addr6) || (a == i->llv6))); } } /** * if_dump_all - dump all interfaces * * This function dumps information about all known network * interfaces to the debug output. */ void if_dump_all(void) { struct iface *i; debug("Known network interfaces:\n"); WALK_LIST(i, iface_list) if_dump(i); debug("Router ID: %08x\n", config->router_id); } static inline unsigned if_what_changed(struct iface *i, struct iface *j) { unsigned c; if (((i->flags ^ j->flags) & ~(IF_UP | IF_SHUTDOWN | IF_UPDATED | IF_ADMIN_UP | IF_LINK_UP | IF_TMP_DOWN | IF_JUST_CREATED)) || (i->index != j->index) || (i->master != j->master)) return IF_CHANGE_TOO_MUCH; c = 0; if ((i->flags ^ j->flags) & IF_UP) c |= (i->flags & IF_UP) ? IF_CHANGE_DOWN : IF_CHANGE_UP; if ((i->flags ^ j->flags) & IF_LINK_UP) c |= IF_CHANGE_LINK; if (i->mtu != j->mtu) c |= IF_CHANGE_MTU; return c; } static inline void if_copy(struct iface *to, struct iface *from) { to->flags = from->flags | (to->flags & IF_TMP_DOWN); to->mtu = from->mtu; to->master_index = from->master_index; to->master = from->master; } static inline void ifa_send_notify(struct proto *p, unsigned c, struct ifa *a) { if (p->ifa_notify && (p->proto_state != PS_DOWN) && (!p->vrf_set || p->vrf == a->iface->master)) { if (p->debug & D_IFACES) log(L_TRACE "%s < address %N on interface %s %s", p->name, &a->prefix, a->iface->name, (c & IF_CHANGE_UP) ? "added" : "removed"); p->ifa_notify(p, c, a); } } static void ifa_notify_change_(unsigned c, struct ifa *a) { struct proto *p; DBG("IFA change notification (%x) for %s:%I\n", c, a->iface->name, a->ip); WALK_LIST(p, proto_list) ifa_send_notify(p, c, a); } static inline void ifa_notify_change(unsigned c, struct ifa *a) { if (c & IF_CHANGE_DOWN) neigh_ifa_down(a); ifa_notify_change_(c, a); if (c & IF_CHANGE_UP) neigh_ifa_up(a); } static inline void if_send_notify(struct proto *p, unsigned c, struct iface *i) { if (p->if_notify && (p->proto_state != PS_DOWN) && (!p->vrf_set || p->vrf == i->master)) { if (p->debug & D_IFACES) log(L_TRACE "%s < interface %s %s", p->name, i->name, (c & IF_CHANGE_UP) ? "goes up" : (c & IF_CHANGE_DOWN) ? "goes down" : (c & IF_CHANGE_MTU) ? "changes MTU" : (c & IF_CHANGE_LINK) ? "changes link" : (c & IF_CHANGE_PREFERRED) ? "changes preferred address" : (c & IF_CHANGE_CREATE) ? "created" : "sends unknown event"); p->if_notify(p, c, i); } } static void if_notify_change(unsigned c, struct iface *i) { struct proto *p; struct ifa *a; if (i->flags & IF_JUST_CREATED) { i->flags &= ~IF_JUST_CREATED; c |= IF_CHANGE_CREATE | IF_CHANGE_MTU; } DBG("Interface change notification (%x) for %s\n", c, i->name); #ifdef LOCAL_DEBUG if_dump(i); #endif if (c & IF_CHANGE_DOWN) neigh_if_down(i); if (c & IF_CHANGE_DOWN) WALK_LIST(a, i->addrs) ifa_notify_change_(IF_CHANGE_DOWN, a); WALK_LIST(p, proto_list) if_send_notify(p, c, i); if (c & IF_CHANGE_UP) WALK_LIST(a, i->addrs) ifa_notify_change_(IF_CHANGE_UP, a); if (c & IF_CHANGE_UP) neigh_if_up(i); if ((c & (IF_CHANGE_UP | IF_CHANGE_DOWN | IF_CHANGE_LINK)) == IF_CHANGE_LINK) neigh_if_link(i); } static uint if_recalc_flags(struct iface *i UNUSED, uint flags) { if ((flags & IF_ADMIN_UP) && !(flags & (IF_SHUTDOWN | IF_TMP_DOWN)) && !(i->master_index && !i->master)) flags |= IF_UP; else flags &= ~IF_UP; return flags; } static void if_change_flags(struct iface *i, uint flags) { uint of = i->flags; i->flags = if_recalc_flags(i, flags); if ((i->flags ^ of) & IF_UP) if_notify_change((i->flags & IF_UP) ? IF_CHANGE_UP : IF_CHANGE_DOWN, i); } /** * if_delete - remove interface * @old: interface * * This function is called by the low-level platform dependent code * whenever it notices an interface disappears. It is just a shorthand * for if_update(). */ void if_delete(struct iface *old) { struct iface f = {}; strncpy(f.name, old->name, sizeof(f.name)-1); f.flags = IF_SHUTDOWN; if_update(&f); } /** * if_update - update interface status * @new: new interface status * * if_update() is called by the low-level platform dependent code * whenever it notices an interface change. * * There exist two types of interface updates -- synchronous and asynchronous * ones. In the synchronous case, the low-level code calls if_start_update(), * scans all interfaces reported by the OS, uses if_update() and ifa_update() * to pass them to the core and then it finishes the update sequence by * calling if_end_update(). When working asynchronously, the sysdep code * calls if_update() and ifa_update() whenever it notices a change. * * if_update() will automatically notify all other modules about the change. */ struct iface * if_update(struct iface *new) { struct iface *i; unsigned c; WALK_LIST(i, iface_list) if (!strcmp(new->name, i->name)) { new->flags = if_recalc_flags(new, new->flags); c = if_what_changed(i, new); if (c & IF_CHANGE_TOO_MUCH) /* Changed a lot, convert it to down/up */ { DBG("Interface %s changed too much -- forcing down/up transition\n", i->name); if_change_flags(i, i->flags | IF_TMP_DOWN); rem_node(&i->n); new->addr4 = i->addr4; new->addr6 = i->addr6; new->llv6 = i->llv6; new->sysdep = i->sysdep; memcpy(&new->addrs, &i->addrs, sizeof(i->addrs)); memcpy(i, new, sizeof(*i)); i->flags &= ~IF_UP; /* IF_TMP_DOWN will be added later */ goto newif; } if_copy(i, new); if (c) if_notify_change(c, i); i->flags |= IF_UPDATED; return i; } i = mb_alloc(if_pool, sizeof(struct iface)); memcpy(i, new, sizeof(*i)); init_list(&i->addrs); newif: init_list(&i->neighbors); i->flags |= IF_UPDATED | IF_TMP_DOWN; /* Tmp down as we don't have addresses yet */ add_tail(&iface_list, &i->n); return i; } void if_start_update(void) { struct iface *i; struct ifa *a; WALK_LIST(i, iface_list) { i->flags &= ~IF_UPDATED; WALK_LIST(a, i->addrs) a->flags &= ~IA_UPDATED; } } void if_end_partial_update(struct iface *i) { if (i->flags & IF_NEEDS_RECALC) if_recalc_preferred(i); if (i->flags & IF_TMP_DOWN) if_change_flags(i, i->flags & ~IF_TMP_DOWN); } void if_end_update(void) { struct iface *i; struct ifa *a, *b; WALK_LIST(i, iface_list) { if (!(i->flags & IF_UPDATED)) if_change_flags(i, (i->flags & ~IF_ADMIN_UP) | IF_SHUTDOWN); else { WALK_LIST_DELSAFE(a, b, i->addrs) if (!(a->flags & IA_UPDATED)) ifa_delete(a); if_end_partial_update(i); } } } void if_flush_ifaces(struct proto *p) { if (p->debug & D_EVENTS) log(L_TRACE "%s: Flushing interfaces", p->name); if_start_update(); if_end_update(); } /** * if_feed_baby - advertise interfaces to a new protocol * @p: protocol to feed * * When a new protocol starts, this function sends it a series * of notifications about all existing interfaces. */ void if_feed_baby(struct proto *p) { struct iface *i; struct ifa *a; if (!p->if_notify && !p->ifa_notify) /* shortcut */ return; DBG("Announcing interfaces to new protocol %s\n", p->name); WALK_LIST(i, iface_list) { if_send_notify(p, IF_CHANGE_CREATE | ((i->flags & IF_UP) ? IF_CHANGE_UP : 0), i); if (i->flags & IF_UP) WALK_LIST(a, i->addrs) ifa_send_notify(p, IF_CHANGE_CREATE | IF_CHANGE_UP, a); } } /** * if_find_by_index - find interface by ifindex * @idx: ifindex * * This function finds an &iface structure corresponding to an interface * of the given index @idx. Returns a pointer to the structure or %NULL * if no such structure exists. */ struct iface * if_find_by_index(unsigned idx) { struct iface *i; WALK_LIST(i, iface_list) if (i->index == idx && !(i->flags & IF_SHUTDOWN)) return i; return NULL; } /** * if_find_by_name - find interface by name * @name: interface name * * This function finds an &iface structure corresponding to an interface * of the given name @name. Returns a pointer to the structure or %NULL * if no such structure exists. */ struct iface * if_find_by_name(const char *name) { struct iface *i; WALK_LIST(i, iface_list) if (!strcmp(i->name, name) && !(i->flags & IF_SHUTDOWN)) return i; return NULL; } struct iface * if_get_by_name(const char *name) { struct iface *i; WALK_LIST(i, iface_list) if (!strcmp(i->name, name)) return i; /* No active iface, create a dummy */ i = mb_allocz(if_pool, sizeof(struct iface)); strncpy(i->name, name, sizeof(i->name)-1); i->flags = IF_SHUTDOWN; init_list(&i->addrs); init_list(&i->neighbors); add_tail(&iface_list, &i->n); return i; } static inline void if_set_preferred(struct ifa **pos, struct ifa *new) { if (*pos) (*pos)->flags &= ~IA_PRIMARY; if (new) new->flags |= IA_PRIMARY; *pos = new; } static void if_recalc_preferred(struct iface *i) { /* * Preferred address selection priority: * 1) Address configured in Device protocol * 2) Sysdep IPv4 address (BSD) * 3) Old preferred address * 4) First address in list */ struct kif_iface_config *ic = kif_get_iface_config(i); struct ifa *a4 = i->addr4, *a6 = i->addr6, *ll = i->llv6; ip_addr pref_v4 = ic->pref_v4; uint change = 0; if (kif_update_sysdep_addr(i)) change |= IF_CHANGE_SYSDEP; /* BSD sysdep address */ if (ipa_zero(pref_v4) && ip4_nonzero(i->sysdep)) pref_v4 = ipa_from_ip4(i->sysdep); struct ifa *a; WALK_LIST(a, i->addrs) { /* Secondary address is never selected */ if (a->flags & IA_SECONDARY) continue; if (ipa_is_ip4(a->ip)) { if (!a4 || ipa_equal(a->ip, pref_v4)) a4 = a; } else if (!ipa_is_link_local(a->ip)) { if (!a6 || ipa_equal(a->ip, ic->pref_v6)) a6 = a; } else { if (!ll || ipa_equal(a->ip, ic->pref_ll)) ll = a; } } if ((a4 != i->addr4) || (i->flags & IF_LOST_ADDR4)) { if_set_preferred(&i->addr4, a4); change |= IF_CHANGE_ADDR4; } if ((a6 != i->addr6) || (i->flags & IF_LOST_ADDR6)) { if_set_preferred(&i->addr6, a6); change |= IF_CHANGE_ADDR6; } if ((ll != i->llv6) || (i->flags & IF_LOST_LLV6)) { if_set_preferred(&i->llv6, ll); change |= IF_CHANGE_LLV6; } i->flags &= ~(IF_NEEDS_RECALC | IF_LOST_ADDR4 | IF_LOST_ADDR6 | IF_LOST_LLV6); if (change) if_notify_change(change, i); } void if_recalc_all_preferred_addresses(void) { struct iface *i; WALK_LIST(i, iface_list) { if_recalc_preferred(i); if (i->flags & IF_TMP_DOWN) if_change_flags(i, i->flags & ~IF_TMP_DOWN); } } static inline int ifa_same(struct ifa *a, struct ifa *b) { return ipa_equal(a->ip, b->ip) && net_equal(&a->prefix, &b->prefix); } /** * ifa_update - update interface address * @a: new interface address * * This function adds address information to a network * interface. It's called by the platform dependent code during * the interface update process described under if_update(). */ struct ifa * ifa_update(struct ifa *a) { struct iface *i = a->iface; struct ifa *b; WALK_LIST(b, i->addrs) if (ifa_same(b, a)) { if (ipa_equal(b->brd, a->brd) && ipa_equal(b->opposite, a->opposite) && b->scope == a->scope && !((b->flags ^ a->flags) & IA_PEER)) { b->flags |= IA_UPDATED; return b; } ifa_delete(b); break; } if ((a->prefix.type == NET_IP4) && (i->flags & IF_BROADCAST) && ipa_zero(a->brd)) log(L_WARN "Missing broadcast address for interface %s", i->name); b = mb_alloc(if_pool, sizeof(struct ifa)); memcpy(b, a, sizeof(struct ifa)); add_tail(&i->addrs, &b->n); b->flags |= IA_UPDATED; i->flags |= IF_NEEDS_RECALC; if (i->flags & IF_UP) ifa_notify_change(IF_CHANGE_CREATE | IF_CHANGE_UP, b); return b; } /** * ifa_delete - remove interface address * @a: interface address * * This function removes address information from a network * interface. It's called by the platform dependent code during * the interface update process described under if_update(). */ void ifa_delete(struct ifa *a) { struct iface *i = a->iface; struct ifa *b; WALK_LIST(b, i->addrs) if (ifa_same(b, a)) { rem_node(&b->n); if (b->flags & IA_PRIMARY) { /* * We unlink deleted preferred address and mark for recalculation. * FIXME: This could break if we make iface scan non-atomic, as * protocols still could use the freed address until they get * if_notify from preferred route recalculation. We should fix and * simplify this in the future by having struct ifa refcounted */ if (b == i->addr4) { i->addr4 = NULL; i->flags |= IF_LOST_ADDR4; } if (b == i->addr6) { i->addr6 = NULL; i->flags |= IF_LOST_ADDR6; } if (b == i->llv6) { i->llv6 = NULL; i->flags |= IF_LOST_LLV6; } i->flags |= IF_NEEDS_RECALC; } if (i->flags & IF_UP) ifa_notify_change(IF_CHANGE_DOWN, b); mb_free(b); return; } } u32 if_choose_router_id(struct iface_patt *mask, u32 old_id) { struct iface *i; struct ifa *a, *b; b = NULL; WALK_LIST(i, iface_list) { if (!(i->flags & IF_ADMIN_UP) || (i->flags & IF_SHUTDOWN)) continue; WALK_LIST(a, i->addrs) { if (a->prefix.type != NET_IP4) continue; if (a->flags & IA_SECONDARY) continue; if (a->scope <= SCOPE_LINK) continue; /* Check pattern if specified */ if (mask && !iface_patt_match(mask, i, a)) continue; /* No pattern or pattern matched */ if (!b || ipa_to_u32(a->ip) < ipa_to_u32(b->ip)) b = a; } } if (!b) return 0; u32 id = ipa_to_u32(b->ip); if (id != old_id) log(L_INFO "Chosen router ID %R according to interface %s", id, b->iface->name); return id; } /** * if_init - initialize interface module * * This function is called during BIRD startup to initialize * all data structures of the interface module. */ void if_init(void) { if_pool = rp_new(&root_pool, "Interfaces"); init_list(&iface_list); neigh_init(if_pool); } /* * Interface Pattern Lists */ int iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a) { struct iface_patt_node *p; WALK_LIST(p, ifp->ipn_list) { const char *t = p->pattern; int pos = p->positive; if (t) { if (*t == '-') { t++; pos = !pos; } if (!patmatch(t, i->name)) continue; } if (p->prefix.pxlen == 0) return pos; if (!a) continue; if (ipa_in_netX(a->ip, &p->prefix)) return pos; if ((a->flags & IA_PEER) && ipa_in_netX(a->opposite, &p->prefix)) return pos; continue; } return 0; } struct iface_patt * iface_patt_find(list *l, struct iface *i, struct ifa *a) { struct iface_patt *p; WALK_LIST(p, *l) if (iface_patt_match(p, i, a)) return p; return NULL; } static int iface_plists_equal(struct iface_patt *pa, struct iface_patt *pb) { struct iface_patt_node *x, *y; x = HEAD(pa->ipn_list); y = HEAD(pb->ipn_list); while (x->n.next && y->n.next) { if ((x->positive != y->positive) || (!x->pattern && y->pattern) || /* This nasty lines where written by me... :-( Feela */ (!y->pattern && x->pattern) || ((x->pattern != y->pattern) && strcmp(x->pattern, y->pattern)) || !net_equal(&x->prefix, &y->prefix)) return 0; x = (void *) x->n.next; y = (void *) y->n.next; } return (!x->n.next && !y->n.next); } int iface_patts_equal(list *a, list *b, int (*comp)(struct iface_patt *, struct iface_patt *)) { struct iface_patt *x, *y; x = HEAD(*a); y = HEAD(*b); while (x->n.next && y->n.next) { if (!iface_plists_equal(x, y) || (comp && !comp(x, y))) return 0; x = (void *) x->n.next; y = (void *) y->n.next; } return (!x->n.next && !y->n.next); } /* * CLI commands. */ static void if_show_addr(struct ifa *a) { byte *flg, opp[IPA_MAX_TEXT_LENGTH + 16]; flg = (a->flags & IA_PRIMARY) ? "Preferred, " : (a->flags & IA_SECONDARY) ? "Secondary, " : ""; if (ipa_nonzero(a->opposite)) bsprintf(opp, "opposite %I, ", a->opposite); else opp[0] = 0; cli_msg(-1003, "\t%I/%d (%s%sscope %s)", a->ip, a->prefix.pxlen, flg, opp, ip_scope_text(a->scope)); } void if_show(void) { struct iface *i; struct ifa *a; char *type; WALK_LIST(i, iface_list) { if (i->flags & IF_SHUTDOWN) continue; char mbuf[16 + sizeof(i->name)] = {}; if (i->master) bsprintf(mbuf, " master=%s", i->master->name); else if (i->master_index) bsprintf(mbuf, " master=#%u", i->master_index); cli_msg(-1001, "%s %s (index=%d%s)", i->name, (i->flags & IF_UP) ? "up" : "down", i->index, mbuf); if (!(i->flags & IF_MULTIACCESS)) type = "PtP"; else type = "MultiAccess"; cli_msg(-1004, "\t%s%s%s Admin%s Link%s%s%s MTU=%d", type, (i->flags & IF_BROADCAST) ? " Broadcast" : "", (i->flags & IF_MULTICAST) ? " Multicast" : "", (i->flags & IF_ADMIN_UP) ? "Up" : "Down", (i->flags & IF_LINK_UP) ? "Up" : "Down", (i->flags & IF_LOOPBACK) ? " Loopback" : "", (i->flags & IF_IGNORE) ? " Ignored" : "", i->mtu); WALK_LIST(a, i->addrs) if (a->prefix.type == NET_IP4) if_show_addr(a); WALK_LIST(a, i->addrs) if (a->prefix.type == NET_IP6) if_show_addr(a); } cli_msg(0, ""); } void if_show_summary(void) { struct iface *i; cli_msg(-2005, "%-10s %-6s %-18s %s", "Interface", "State", "IPv4 address", "IPv6 address"); WALK_LIST(i, iface_list) { byte a4[IPA_MAX_TEXT_LENGTH + 17]; byte a6[IPA_MAX_TEXT_LENGTH + 17]; if (i->flags & IF_SHUTDOWN) continue; if (i->addr4) bsprintf(a4, "%I/%d", i->addr4->ip, i->addr4->prefix.pxlen); else a4[0] = 0; if (i->addr6) bsprintf(a6, "%I/%d", i->addr6->ip, i->addr6->prefix.pxlen); else a6[0] = 0; cli_msg(-1005, "%-10s %-6s %-18s %s", i->name, (i->flags & IF_UP) ? "up" : "down", a4, a6); } cli_msg(0, ""); } bird-2.0.8/nest/config.Y0000664000175000017500000006133514025744326013744 0ustar feelafeela/* * BIRD -- Core Configuration * * (c) 1998--2000 Martin Mares * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #include "nest/rt-dev.h" #include "nest/password.h" #include "nest/cmds.h" #include "lib/lists.h" #include "lib/mac.h" CF_DEFINES static struct proto_config *this_proto; static struct channel_config *this_channel; static struct iface_patt *this_ipatt; static struct iface_patt_node *this_ipn; /* static struct roa_table_config *this_roa_table; */ static list *this_p_list; static struct password_item *this_p_item; static int password_id; static struct bfd_options *this_bfd_opts; static void iface_patt_check(void) { struct iface_patt_node *pn; WALK_LIST(pn, this_ipatt->ipn_list) if (!pn->pattern || pn->prefix.type) cf_error("Interface name/mask expected, not IP prefix"); } static inline void reset_passwords(void) { this_p_list = NULL; } static inline list * get_passwords(void) { list *rv = this_p_list; this_p_list = NULL; return rv; } static inline void init_bfd_opts(struct bfd_options **opts) { cf_check_bfd(1); if (! *opts) *opts = bfd_new_options(); } static inline void open_bfd_opts(struct bfd_options **opts) { init_bfd_opts(opts); this_bfd_opts = *opts; } static inline void close_bfd_opts(void) { this_bfd_opts = NULL; } static void proto_postconfig(void) { CALL(this_proto->protocol->postconfig, this_proto); this_channel = NULL; this_proto = NULL; } #define DIRECT_CFG ((struct rt_dev_config *) this_proto) CF_DECLS CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS) CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED, RPKI) CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, CHANNELS, INTERFACES) CF_KEYWORDS(ALGORITHM, KEYED, HMAC, MD5, SHA1, SHA256, SHA384, SHA512) CF_KEYWORDS(PRIMARY, STATS, COUNT, BY, FOR, COMMANDS, PREEXPORT, NOEXPORT, EXPORTED, GENERATE) CF_KEYWORDS(BGP, PASSWORDS, DESCRIPTION, SORTED) CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP) CF_KEYWORDS(TIMEFORMAT, ISO, SHORT, LONG, ROUTE, PROTOCOL, BASE, LOG, S, MS, US) CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS) CF_KEYWORDS(MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE) CF_KEYWORDS(CHECK, LINK) /* For r_args_channel */ CF_KEYWORDS(IPV4, IPV4_MC, IPV4_MPLS, IPV6, IPV6_MC, IPV6_MPLS, IPV6_SADR, VPN4, VPN4_MC, VPN4_MPLS, VPN6, VPN6_MC, VPN6_MPLS, ROA4, ROA6, FLOW4, FLOW6, MPLS, PRI, SEC) CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT, RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE, BABEL) CF_ENUM(T_ENUM_SCOPE, SCOPE_, HOST, LINK, SITE, ORGANIZATION, UNIVERSE, UNDEFINED) CF_ENUM(T_ENUM_RTD, RTD_, UNICAST, BLACKHOLE, UNREACHABLE, PROHIBIT) CF_ENUM(T_ENUM_ROA, ROA_, UNKNOWN, VALID, INVALID) CF_ENUM_PX(T_ENUM_AF, AF_, AFI_, IPV4, IPV6) %type idval %type imexport %type rtable %type optproto %type r_args %type sym_args %type proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_mode limit_action net_type table_sorted tos password_algorithm %type proto_patt proto_patt2 %type channel_start proto_channel %type limit_spec %type r_args_for_val %type r_args_for %type channel_sym %type channel_arg CF_GRAMMAR /* Setting of router ID */ conf: rtrid ; rtrid: ROUTER ID idval ';' { new_config->router_id = $3; } | ROUTER ID FROM iface_patt ';' { new_config->router_id_from = this_ipatt; } ; idval: NUM { $$ = $1; } | '(' term ')' { $$ = f_eval_int(f_linearize($2)); } | IP4 { $$ = ip4_to_u32($1); } | CF_SYM_KNOWN { if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD)) $$ = SYM_VAL($1).i; else if (($1->class == (SYM_CONSTANT | T_IP)) && ipa_is_ip4(SYM_VAL($1).ip)) $$ = ipa_to_u32(SYM_VAL($1).ip); else cf_error("Number or IPv4 address constant expected"); } ; conf: hostname_override ; hostname_override: HOSTNAME text ';' { new_config->hostname = $2; } ; conf: gr_opts ; gr_opts: GRACEFUL RESTART WAIT expr ';' { new_config->gr_wait = $4; } ; /* Network types (for tables, channels) */ net_type: IPV4 { $$ = NET_IP4; } | IPV6 { $$ = NET_IP6; } | IPV6 SADR { $$ = NET_IP6_SADR; } | VPN4 { $$ = NET_VPN4; } | VPN6 { $$ = NET_VPN6; } | ROA4 { $$ = NET_ROA4; } | ROA6 { $$ = NET_ROA6; } | FLOW4{ $$ = NET_FLOW4; } | FLOW6{ $$ = NET_FLOW6; } | MPLS { $$ = NET_MPLS; } ; CF_ENUM(T_ENUM_NETTYPE, NET_, IP4, IP6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, IP6_SADR) /* Creation of routing tables */ conf: table ; table_sorted: { $$ = 0; } | SORTED { $$ = 1; } ; table: net_type TABLE symbol table_sorted { struct rtable_config *cf; cf = rt_new_table($3, $1); cf->sorted = $4; } ; /* Definition of protocols */ conf: proto { proto_postconfig(); } ; proto_start: PROTOCOL { $$ = SYM_PROTO; } | TEMPLATE { $$ = SYM_TEMPLATE; } ; proto_name: /* EMPTY */ { struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter); s->class = this_proto->class; s->proto = this_proto; this_proto->name = s->name; } | symbol { cf_define_symbol($1, this_proto->class, proto, this_proto); this_proto->name = $1->name; } | FROM CF_SYM_KNOWN { if (($2->class != SYM_TEMPLATE) && ($2->class != SYM_PROTO)) cf_error("Template or protocol name expected"); struct symbol *s = cf_default_name(this_proto->protocol->template, &this_proto->protocol->name_counter); s->class = this_proto->class; s->proto = this_proto; this_proto->name = s->name; proto_copy_config(this_proto, $2->proto); } | symbol FROM CF_SYM_KNOWN { if (($3->class != SYM_TEMPLATE) && ($3->class != SYM_PROTO)) cf_error("Template or protocol name expected"); cf_define_symbol($1, this_proto->class, proto, this_proto); this_proto->name = $1->name; proto_copy_config(this_proto, $3->proto); } ; proto_item: /* EMPTY */ | DISABLED bool { this_proto->disabled = $2; } | DEBUG debug_mask { this_proto->debug = $2; } | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; } | ROUTER ID idval { this_proto->router_id = $3; } | DESCRIPTION text { this_proto->dsc = $2; } | VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; } | VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; } ; channel_start: net_type { $$ = this_channel = channel_config_get(NULL, net_label[$1], $1, this_proto); }; channel_item_: TABLE rtable { if (this_channel->net_type && ($2->addr_type != this_channel->net_type)) cf_error("Incompatible table type"); this_channel->table = $2; } | IMPORT imexport { this_channel->in_filter = $2; } | EXPORT imexport { this_channel->out_filter = $2; } | RECEIVE LIMIT limit_spec { this_channel->rx_limit = $3; } | IMPORT LIMIT limit_spec { this_channel->in_limit = $3; } | EXPORT LIMIT limit_spec { this_channel->out_limit = $3; } | PREFERENCE expr { this_channel->preference = $2; check_u16($2); } | IMPORT KEEP FILTERED bool { this_channel->in_keep_filtered = $4; } | RPKI RELOAD bool { this_channel->rpki_reload = $3; } ; /* To avoid grammar collision in Pipe protocol */ channel_item: channel_item_ | DEBUG debug_mask { this_channel->debug = $2; } ; channel_opts: /* empty */ | channel_opts channel_item ';' ; channel_opt_list: /* empty */ | '{' channel_opts '}' ; channel_end: { if (!this_channel->table) cf_error("Routing table not specified"); this_channel = NULL; }; proto_channel: channel_start channel_opt_list channel_end; rtable: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_TABLE); $$ = $1->table; } ; imexport: FILTER filter { $$ = $2; } | where_filter | ALL { $$ = FILTER_ACCEPT; } | NONE { $$ = FILTER_REJECT; } ; limit_action: /* default */ { $$ = PLA_DISABLE; } | ACTION WARN { $$ = PLA_WARN; } | ACTION BLOCK { $$ = PLA_BLOCK; } | ACTION RESTART { $$ = PLA_RESTART; } | ACTION DISABLE { $$ = PLA_DISABLE; } ; limit_spec: expr limit_action { $$ = (struct channel_limit){ .limit = $1, $$.action = $2 }; } | OFF { $$ = (struct channel_limit){}; } ; conf: debug_default ; debug_default: DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; } | DEBUG CHANNELS debug_mask { new_config->channel_default_debug = $3; } | DEBUG COMMANDS expr { new_config->cli_debug = $3; } ; /* MRTDUMP PROTOCOLS is in systep/unix/config.Y */ conf: timeformat_base ; timeformat_which: ROUTE { $$ = &new_config->tf_route; } | PROTOCOL { $$ = &new_config->tf_proto; } | BASE { $$ = &new_config->tf_base; } | LOG { $$ = &new_config->tf_log; } ; timeformat_spec: timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; } | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, (s64) $3 S_}; } | timeformat_which ISO SHORT { *$1 = TM_ISO_SHORT_S; } | timeformat_which ISO SHORT MS { *$1 = TM_ISO_SHORT_MS; } | timeformat_which ISO SHORT US { *$1 = TM_ISO_SHORT_US; } | timeformat_which ISO LONG { *$1 = TM_ISO_LONG_S; } | timeformat_which ISO LONG MS { *$1 = TM_ISO_LONG_MS; } | timeformat_which ISO LONG US { *$1 = TM_ISO_LONG_US; } ; timeformat_base: TIMEFORMAT timeformat_spec ';' ; /* Interface patterns */ iface_patt_node_init: /* EMPTY */ { struct iface_patt_node *ipn = cfg_allocz(sizeof(struct iface_patt_node)); add_tail(&this_ipatt->ipn_list, NODE ipn); this_ipn = ipn; } ; iface_patt_node_body: TEXT { this_ipn->pattern = $1; /* this_ipn->prefix stays zero */ } | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2; } ; iface_negate: { this_ipn->positive = 1; } | '-' { this_ipn->positive = 0; } ; iface_patt_node: iface_patt_node_init iface_negate iface_patt_node_body ; iface_patt_list: iface_patt_node | iface_patt_list ',' iface_patt_node ; /* For name/mask-only iface patterns */ iface_patt_list_nopx: iface_patt_list { iface_patt_check(); } iface_patt_init: { /* Generic this_ipatt init */ this_ipatt = cfg_allocz(sizeof(struct iface_patt)); init_list(&this_ipatt->ipn_list); } ; iface_patt: iface_patt_init iface_patt_list ; tos: CLASS expr { $$ = $2 & 0xfc; if ($2 > 255) cf_error("TX class must be in range 0-255"); } | DSCP expr { $$ = ($2 & 0x3f) << 2; if ($2 > 63) cf_error("TX DSCP must be in range 0-63"); } ; /* Direct device route protocol */ proto: dev_proto '}' ; dev_proto_start: proto_start DIRECT { this_proto = proto_config_new(&proto_device, $1); init_list(&DIRECT_CFG->iface_list); } ; dev_proto: dev_proto_start proto_name '{' | dev_proto proto_item ';' | dev_proto proto_channel ';' | dev_proto dev_iface_patt ';' | dev_proto CHECK LINK bool ';' { DIRECT_CFG->check_link = $4; } ; dev_iface_init: /* EMPTY */ { this_ipatt = cfg_allocz(sizeof(struct iface_patt)); add_tail(&DIRECT_CFG->iface_list, NODE this_ipatt); init_list(&this_ipatt->ipn_list); } ; dev_iface_patt: INTERFACE dev_iface_init iface_patt_list ; /* Debug flags */ debug_mask: ALL { $$ = ~0; } | OFF { $$ = 0; } | '{' debug_list '}' { $$ = $2; } ; debug_list: debug_flag | debug_list ',' debug_flag { $$ = $1 | $3; } ; debug_flag: STATES { $$ = D_STATES; } | ROUTES { $$ = D_ROUTES; } | FILTERS { $$ = D_FILTERS; } | INTERFACES { $$ = D_IFACES; } | EVENTS { $$ = D_EVENTS; } | PACKETS { $$ = D_PACKETS; } ; /* MRTDump flags */ mrtdump_mask: ALL { $$ = ~0; } | OFF { $$ = 0; } | '{' mrtdump_list '}' { $$ = $2; } ; mrtdump_list: mrtdump_flag | mrtdump_list ',' mrtdump_flag { $$ = $1 | $3; } ; mrtdump_flag: STATES { $$ = MD_STATES; } | MESSAGES { $$ = MD_MESSAGES; } ; /* Password lists */ password_list: PASSWORDS '{' password_items '}' | password_item ; password_items: /* empty */ | password_item ';' password_items ; password_item: password_item_begin '{' password_item_params '}' | password_item_begin ; password_item_begin: PASSWORD text { if (!this_p_list) { this_p_list = cfg_allocz(sizeof(list)); init_list(this_p_list); password_id = 1; } this_p_item = cfg_allocz(sizeof(struct password_item)); this_p_item->password = $2; this_p_item->length = strlen($2); this_p_item->genfrom = 0; this_p_item->gento = TIME_INFINITY; this_p_item->accfrom = 0; this_p_item->accto = TIME_INFINITY; this_p_item->id = password_id++; this_p_item->alg = ALG_UNDEFINED; add_tail(this_p_list, &this_p_item->n); } ; password_item_params: /* empty */ { } | GENERATE FROM time ';' password_item_params { this_p_item->genfrom = $3; } | GENERATE TO time ';' password_item_params { this_p_item->gento = $3; } | ACCEPT FROM time ';' password_item_params { this_p_item->accfrom = $3; } | ACCEPT TO time ';' password_item_params { this_p_item->accto = $3; } | FROM time ';' password_item_params { this_p_item->genfrom = this_p_item->accfrom = $2; } | TO time ';' password_item_params { this_p_item->gento = this_p_item->accto = $2; } | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 > 255) cf_error("Password ID must be in range 0-255"); } | ALGORITHM password_algorithm ';' password_item_params { this_p_item->alg = $2; } ; password_algorithm: KEYED MD5 { $$ = ALG_MD5; } | KEYED SHA1 { $$ = ALG_SHA1; } | KEYED SHA256 { $$ = ALG_SHA256; } | KEYED SHA384 { $$ = ALG_SHA384; } | KEYED SHA512 { $$ = ALG_SHA512; } | HMAC MD5 { $$ = ALG_HMAC_MD5; } | HMAC SHA1 { $$ = ALG_HMAC_SHA1; } | HMAC SHA256 { $$ = ALG_HMAC_SHA256; } | HMAC SHA384 { $$ = ALG_HMAC_SHA384; } | HMAC SHA512 { $$ = ALG_HMAC_SHA512; } ; /* BFD options */ bfd_item: INTERVAL expr_us { this_bfd_opts->min_rx_int = this_bfd_opts->min_tx_int = $2; } | MIN RX INTERVAL expr_us { this_bfd_opts->min_rx_int = $4; } | MIN TX INTERVAL expr_us { this_bfd_opts->min_tx_int = $4; } | IDLE TX INTERVAL expr_us { this_bfd_opts->idle_tx_int = $4; } | MULTIPLIER expr { this_bfd_opts->multiplier = $2; } | PASSIVE bool { this_bfd_opts->passive = $2; this_bfd_opts->passive_set = 1; } | GRACEFUL { this_bfd_opts->mode = BGP_BFD_GRACEFUL; } ; bfd_items: /* empty */ | bfd_items bfd_item ';' ; bfd_opts: '{' bfd_items '}' ; /* Core commands */ CF_CLI_HELP(SHOW, ..., [[Show status information]]) CF_CLI(SHOW STATUS,,, [[Show router status]]) { cmd_show_status(); } ; CF_CLI(SHOW MEMORY,,, [[Show memory usage]]) { cmd_show_memory(); } ; CF_CLI(SHOW PROTOCOLS, proto_patt2, [ | \"\"], [[Show routing protocols]]) { proto_apply_cmd($3, proto_cmd_show, 0, 0); } ; CF_CLI(SHOW PROTOCOLS ALL, proto_patt2, [ | \"\"], [[Show routing protocol details]]) { proto_apply_cmd($4, proto_cmd_show, 0, 1); } ; optproto: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$ = $1; } | /* empty */ { $$ = NULL; } ; CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]]) { if_show(); } ; CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]]) { if_show_summary(); } ; CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]]) CF_CLI(SHOW ROUTE, r_args, [[[|for |for ] [table ] [filter |where ] [all] [primary] [filtered] [(export|preexport|noexport)

] [protocol

] [stats|count]]], [[Show routing table]]) { rt_show($3); } ; r_args: /* empty */ { $$ = cfg_allocz(sizeof(struct rt_show_data)); init_list(&($$->tables)); $$->filter = FILTER_ACCEPT; $$->running_on_config = new_config->fallback; } | r_args net_any { $$ = $1; if ($$->addr) cf_error("Only one prefix expected"); $$->addr = $2; } | r_args FOR r_args_for { $$ = $1; if ($$->addr) cf_error("Only one prefix expected"); $$->show_for = 1; $$->addr = $3; } | r_args TABLE CF_SYM_KNOWN { cf_assert_symbol($3, SYM_TABLE); $$ = $1; rt_show_add_table($$, $3->table->table); $$->tables_defined_by = RSD_TDB_DIRECT; } | r_args TABLE ALL { struct rtable_config *t; $$ = $1; WALK_LIST(t, config->tables) rt_show_add_table($$, t->table); $$->tables_defined_by = RSD_TDB_ALL; } | r_args IMPORT TABLE channel_arg { if (!$4->in_table) cf_error("No import table in channel %s.%s", $4->proto->name, $4->name); rt_show_add_table($$, $4->in_table); $$->tables_defined_by = RSD_TDB_DIRECT; } | r_args EXPORT TABLE channel_arg { if (!$4->out_table) cf_error("No export table in channel %s.%s", $4->proto->name, $4->name); rt_show_add_table($$, $4->out_table); $$->tables_defined_by = RSD_TDB_DIRECT; } | r_args FILTER filter { $$ = $1; if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); $$->filter = $3; } | r_args where_filter { $$ = $1; if ($$->filter != FILTER_ACCEPT) cf_error("Filter specified twice"); $$->filter = $2; } | r_args ALL { $$ = $1; $$->verbose = 1; } | r_args PRIMARY { $$ = $1; $$->primary_only = 1; } | r_args FILTERED { $$ = $1; $$->filtered = 1; } | r_args export_mode CF_SYM_KNOWN { cf_assert_symbol($3, SYM_PROTO); struct proto_config *c = (struct proto_config *) $3->proto; $$ = $1; if ($$->export_mode) cf_error("Export specified twice"); if (!c->proto) cf_error("%s is not a protocol", $3->name); $$->export_mode = $2; $$->export_protocol = c->proto; $$->tables_defined_by = RSD_TDB_INDIRECT; } | r_args export_mode channel_arg { $$ = $1; if ($$->export_mode) cf_error("Export specified twice"); $$->export_mode = $2; $$->export_channel = $3; $$->tables_defined_by = RSD_TDB_INDIRECT; } | r_args PROTOCOL CF_SYM_KNOWN { cf_assert_symbol($3, SYM_PROTO); struct proto_config *c = (struct proto_config *) $3->proto; $$ = $1; if ($$->show_protocol) cf_error("Protocol specified twice"); if (!c->proto) cf_error("%s is not a protocol", $3->name); $$->show_protocol = c->proto; $$->tables_defined_by = RSD_TDB_INDIRECT; } | r_args STATS { $$ = $1; $$->stats = 1; } | r_args COUNT { $$ = $1; $$->stats = 2; } ; r_args_for: r_args_for_val { $$ = cfg_alloc($1.length); net_copy($$, &$1); } | net_vpn4_ | net_vpn6_ | net_ip6_sadr_ | VPN_RD IP4 { $$ = cfg_alloc(sizeof(net_addr_vpn4)); net_fill_vpn4($$, $2, IP4_MAX_PREFIX_LENGTH, $1); } | VPN_RD IP6 { $$ = cfg_alloc(sizeof(net_addr_vpn6)); net_fill_vpn6($$, $2, IP6_MAX_PREFIX_LENGTH, $1); } | IP6 FROM IP6 { $$ = cfg_alloc(sizeof(net_addr_ip6_sadr)); net_fill_ip6_sadr($$, $1, IP6_MAX_PREFIX_LENGTH, $3, IP6_MAX_PREFIX_LENGTH); } | CF_SYM_KNOWN { if ($1->class == (SYM_CONSTANT | T_IP)) { $$ = cfg_alloc(ipa_is_ip4(SYM_VAL($1).ip) ? sizeof(net_addr_ip4) : sizeof(net_addr_ip6)); net_fill_ip_host($$, SYM_VAL($1).ip); } else if (($1->class == (SYM_CONSTANT | T_NET)) && net_type_match(SYM_VAL($1).net, NB_IP | NB_VPN)) $$ = (net_addr *) SYM_VAL($1).net; /* Avoid const warning */ else cf_error("IP address or network constant expected"); } ; r_args_for_val: net_ip4_ | net_ip6_ | IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); } | IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); } export_mode: PREEXPORT { $$ = RSEM_PREEXPORT; } | EXPORT { $$ = RSEM_EXPORT; } | NOEXPORT { $$ = RSEM_NOEXPORT; } | EXPORTED { $$ = RSEM_EXPORTED; } ; /* This is ugly hack */ channel_sym: IPV4 { $$ = "ipv4"; } | IPV4_MC { $$ = "ipv4-mc"; } | IPV4_MPLS { $$ = "ipv4-mpls"; } | IPV6 { $$ = "ipv6"; } | IPV6_MC { $$ = "ipv6-mc"; } | IPV6_MPLS { $$ = "ipv6-mpls"; } | IPV6_SADR { $$ = "ipv6-sadr"; } | VPN4 { $$ = "vpn4"; } | VPN4_MC { $$ = "vpn4-mc"; } | VPN4_MPLS { $$ = "vpn4-mpls"; } | VPN6 { $$ = "vpn6"; } | VPN6_MC { $$ = "vpn6-mc"; } | VPN6_MPLS { $$ = "vpn6-mpls"; } | ROA4 { $$ = "roa4"; } | ROA6 { $$ = "roa6"; } | FLOW4 { $$ = "flow4"; } | FLOW6 { $$ = "flow6"; } | MPLS { $$ = "mpls"; } | PRI { $$ = "pri"; } | SEC { $$ = "sec"; } ; channel_arg: CF_SYM_KNOWN '.' channel_sym { cf_assert_symbol($1, SYM_PROTO); struct proto *p = $1->proto->proto; if (!p) cf_error("%s is not a protocol", $1->name); $$ = proto_find_channel_by_name(p, $3); if (!$$) cf_error("Channel %s.%s not found", $1->name, $3); } ; CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]]) CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|], [[Show all known symbolic names]]) { cmd_show_symbols($3); } ; sym_args: /* empty */ { $$ = cfg_allocz(sizeof(struct sym_show_data)); } | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; } | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; } | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; } | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; } | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; } | sym_args symbol { $$ = $1; $$->sym = $2; } ; CF_CLI_HELP(DUMP, ..., [[Dump debugging information]]) CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]]) { rdump(&root_pool); cli_msg(0, ""); } ; CF_CLI(DUMP SOCKETS,,, [[Dump open sockets]]) { sk_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP EVENTS,,, [[Dump event log]]) { io_log_dump(); cli_msg(0, ""); } ; CF_CLI(DUMP INTERFACES,,, [[Dump interface information]]) { if_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP NEIGHBORS,,, [[Dump neighbor cache]]) { neigh_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP ATTRIBUTES,,, [[Dump attribute cache]]) { rta_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP ROUTES,,, [[Dump routing table]]) { rt_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]]) { protos_dump_all(); cli_msg(0, ""); } ; CF_CLI(DUMP FILTER ALL,,, [[Dump all filters in linearized form]]) { filters_dump_all(); cli_msg(0, ""); } ; CF_CLI(EVAL, term, , [[Evaluate an expression]]) { cmd_eval(f_linearize($2)); } ; CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]]) CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug|trace|info|remote|warning|error|auth [, ...] }) [], [[Control echoing of log messages]]) { cli_set_log_echo(this_cli, $2, $3); cli_msg(0, ""); } ; echo_mask: ALL { $$ = ~0; } | OFF { $$ = 0; } | '{' log_mask_list '}' { $$ = $2; } ; echo_size: /* empty */ { $$ = 4096; } | NUM { if ($1 < 256 || $1 > 65536) cf_error("Invalid log buffer size"); $$ = $1; } ; CF_CLI(DISABLE, proto_patt opttext, ( | \"\" | all) [message], [[Disable protocol]]) { proto_apply_cmd($2, proto_cmd_disable, 1, (uintptr_t) $3); } ; CF_CLI(ENABLE, proto_patt opttext, ( | \"\" | all) [message], [[Enable protocol]]) { proto_apply_cmd($2, proto_cmd_enable, 1, (uintptr_t) $3); } ; CF_CLI(RESTART, proto_patt opttext, ( | \"\" | all) [message], [[Restart protocol]]) { proto_apply_cmd($2, proto_cmd_restart, 1, (uintptr_t) $3); } ; CF_CLI(RELOAD, proto_patt, | \"\" | all, [[Reload protocol]]) { proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ; CF_CLI(RELOAD IN, proto_patt, | \"\" | all, [[Reload protocol (just imported routes)]]) { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ; CF_CLI(RELOAD OUT, proto_patt, | \"\" | all, [[Reload protocol (just exported routes)]]) { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ; CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]]) CF_CLI(DEBUG, debug_args, ( | | \"\" | all) (all | off | { states|routes|filters|interfaces|events|packets [, ...] }), [[Control protocol debugging via BIRD logs]]) { /* Done in debug_args */ }; debug_args: proto_patt debug_mask { proto_apply_cmd($1, proto_cmd_debug, 1, $2); } | channel_arg debug_mask { channel_cmd_debug($1, $2); } ; CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]]) CF_CLI(MRTDUMP, proto_patt mrtdump_mask, ( | \"\" | all) (all | off | { states|messages [, ...] }), [[Control protocol debugging via MRTdump format]]) { proto_apply_cmd($2, proto_cmd_mrtdump, 1, $3); } ; CF_CLI(RESTRICT,,,[[Restrict current CLI session to safe commands]]) { this_cli->restricted = 1; cli_msg(16, "Access restricted"); } ; proto_patt: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$.ptr = $1; $$.patt = 0; } | ALL { $$.ptr = NULL; $$.patt = 1; } | TEXT { $$.ptr = $1; $$.patt = 1; } ; proto_patt2: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_PROTO); $$.ptr = $1; $$.patt = 0; } | { $$.ptr = NULL; $$.patt = 1; } | TEXT { $$.ptr = $1; $$.patt = 1; } ; dynamic_attr: IGP_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); } ; CF_CODE CF_END bird-2.0.8/nest/cmds.h0000664000175000017500000000072114025744326013434 0ustar feelafeela/* * BIRD Internet Routing Daemon -- CLI Commands Which Don't Fit Anywhere Else * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ struct sym_show_data { int type; /* Symbols type to show */ struct symbol *sym; }; struct f_inst; void cmd_show_status(void); void cmd_show_symbols(struct sym_show_data *sym); void cmd_show_memory(void); struct f_line; void cmd_eval(const struct f_line *expr); bird-2.0.8/nest/cmds.c0000664000175000017500000000467714025744326013445 0ustar feelafeela/* * BIRD Internet Routing Daemon -- CLI Commands Which Don't Fit Anywhere Else * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "nest/protocol.h" #include "nest/route.h" #include "nest/cli.h" #include "conf/conf.h" #include "nest/cmds.h" #include "lib/string.h" #include "lib/resource.h" #include "filter/filter.h" extern int shutting_down; extern int configuring; void cmd_show_status(void) { byte tim[TM_DATETIME_BUFFER_SIZE]; cli_msg(-1000, "BIRD " BIRD_VERSION); tm_format_time(tim, &config->tf_base, current_time()); cli_msg(-1011, "Router ID is %R", config->router_id); cli_msg(-1011, "Hostname is %s", config->hostname); cli_msg(-1011, "Current server time is %s", tim); tm_format_time(tim, &config->tf_base, boot_time); cli_msg(-1011, "Last reboot on %s", tim); tm_format_time(tim, &config->tf_base, config->load_time); cli_msg(-1011, "Last reconfiguration on %s", tim); graceful_restart_show_status(); if (shutting_down) cli_msg(13, "Shutdown in progress"); else if (configuring) cli_msg(13, "Reconfiguration in progress"); else cli_msg(13, "Daemon is up and running"); } void cmd_show_symbols(struct sym_show_data *sd) { if (sd->sym) cli_msg(1010, "%-8s\t%s", sd->sym->name, cf_symbol_class_name(sd->sym)); else { HASH_WALK(config->sym_hash, next, sym) { if (!sym->scope->active) continue; if (sd->type && (sym->class != sd->type)) continue; cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym)); } HASH_WALK_END; cli_msg(0, ""); } } static void print_size(char *dsc, size_t val) { char *px = " kMG"; int i = 0; while ((val >= 10000) && (i < 3)) { val = (val + 512) / 1024; i++; } cli_msg(-1018, "%-17s %4u %cB", dsc, (unsigned) val, px[i]); } extern pool *rt_table_pool; extern pool *rta_pool; void cmd_show_memory(void) { cli_msg(-1018, "BIRD memory usage"); print_size("Routing tables:", rmemsize(rt_table_pool)); print_size("Route attributes:", rmemsize(rta_pool)); print_size("Protocols:", rmemsize(proto_pool)); print_size("Total:", rmemsize(&root_pool)); cli_msg(0, ""); } void cmd_eval(const struct f_line *expr) { buffer buf; LOG_BUFFER_INIT(buf); if (f_eval_buf(expr, this_cli->parser_pool, &buf) > F_RETURN) { cli_msg(8008, "runtime error"); return; } cli_msg(23, "%s", buf.start); } bird-2.0.8/nest/cli.h0000664000175000017500000000452114025744326013257 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Command-Line Interface * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_CLI_H_ #define _BIRD_CLI_H_ #include "lib/resource.h" #include "lib/event.h" #define CLI_RX_BUF_SIZE 4096 #define CLI_TX_BUF_SIZE 4096 #define CLI_MAX_ASYNC_QUEUE 4096 #define CLI_MSG_SIZE 500 #define CLI_LINE_SIZE 512 struct cli_out { struct cli_out *next; byte *wpos, *outpos, *end; byte buf[0]; }; typedef struct cli { node n; /* Node in list of all log hooks */ pool *pool; void *priv; /* Private to sysdep layer */ byte *rx_buf, *rx_pos, *rx_aux; /* sysdep */ struct cli_out *tx_buf, *tx_pos, *tx_write; event *event; void (*cont)(struct cli *c); void (*cleanup)(struct cli *c); void *rover; /* Private to continuation routine */ int last_reply; int restricted; /* CLI is restricted to read-only commands */ struct linpool *parser_pool; /* Pool used during parsing */ struct linpool *show_pool; /* Pool used during route show */ byte *ring_buf; /* Ring buffer for asynchronous messages */ byte *ring_end, *ring_read, *ring_write; /* Pointers to the ring buffer */ uint ring_overflow; /* Counter of ring overflows */ uint log_mask; /* Mask of allowed message levels */ uint log_threshold; /* When free < log_threshold, store only important messages */ uint async_msg_size; /* Total size of async messages queued in tx_buf */ } cli; extern pool *cli_pool; extern struct cli *this_cli; /* Used during parsing */ #define CLI_ASYNC_CODE 10000 /* Functions to be called by command handlers */ void cli_printf(cli *, int, char *, ...); #define cli_msg(x...) cli_printf(this_cli, x) void cli_set_log_echo(cli *, uint mask, uint size); static inline void cli_separator(cli *c) { if (c->last_reply) cli_printf(c, -c->last_reply, ""); }; /* Functions provided to sysdep layer */ cli *cli_new(void *); void cli_init(void); void cli_free(cli *); void cli_kick(cli *); void cli_written(cli *); void cli_echo(uint class, byte *msg); static inline int cli_access_restricted(void) { if (this_cli && this_cli->restricted) return (cli_printf(this_cli, 8007, "Access denied"), 1); else return 0; } /* Functions provided by sysdep layer */ void cli_write_trigger(cli *); int cli_get_command(cli *); #endif bird-2.0.8/nest/cli.c0000664000175000017500000002446414025744326013262 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Command-Line Interface * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Command line interface * * This module takes care of the BIRD's command-line interface (CLI). * The CLI exists to provide a way to control BIRD remotely and to inspect * its status. It uses a very simple textual protocol over a stream * connection provided by the platform dependent code (on UNIX systems, * it's a UNIX domain socket). * * Each session of the CLI consists of a sequence of request and replies, * slightly resembling the FTP and SMTP protocols. * Requests are commands encoded as a single line of text, replies are * sequences of lines starting with a four-digit code followed by either * a space (if it's the last line of the reply) or a minus sign (when the * reply is going to continue with the next line), the rest of the line * contains a textual message semantics of which depends on the numeric * code. If a reply line has the same code as the previous one and it's * a continuation line, the whole prefix can be replaced by a single * white space character. * * Reply codes starting with 0 stand for `action successfully completed' messages, * 1 means `table entry', 8 `runtime error' and 9 `syntax error'. * * Each CLI session is internally represented by a &cli structure and a * resource pool containing all resources associated with the connection, * so that it can be easily freed whenever the connection gets closed, not depending * on the current state of command processing. * * The CLI commands are declared as a part of the configuration grammar * by using the |CF_CLI| macro. When a command is received, it is processed * by the same lexical analyzer and parser as used for the configuration, but * it's switched to a special mode by prepending a fake token to the text, * so that it uses only the CLI command rules. Then the parser invokes * an execution routine corresponding to the command, which either constructs * the whole reply and returns it back or (in case it expects the reply will be long) * it prints a partial reply and asks the CLI module (using the @cont hook) * to call it again when the output is transferred to the user. * * The @this_cli variable points to a &cli structure of the session being * currently parsed, but it's of course available only in command handlers * not entered using the @cont hook. * * TX buffer management works as follows: At cli.tx_buf there is a * list of TX buffers (struct cli_out), cli.tx_write is the buffer * currently used by the producer (cli_printf(), cli_alloc_out()) and * cli.tx_pos is the buffer currently used by the consumer * (cli_write(), in system dependent code). The producer uses * cli_out.wpos ptr as the current write position and the consumer * uses cli_out.outpos ptr as the current read position. When the * producer produces something, it calls cli_write_trigger(). If there * is not enough space in the current buffer, the producer allocates * the new one. When the consumer processes everything in the buffer * queue, it calls cli_written(), tha frees all buffers (except the * first one) and schedules cli.event . * */ #include "nest/bird.h" #include "nest/cli.h" #include "conf/conf.h" #include "lib/string.h" pool *cli_pool; static byte * cli_alloc_out(cli *c, int size) { struct cli_out *o; if (!(o = c->tx_write) || o->wpos + size > o->end) { if (!o && c->tx_buf) o = c->tx_buf; else { o = mb_alloc(c->pool, sizeof(struct cli_out) + CLI_TX_BUF_SIZE); if (c->tx_write) c->tx_write->next = o; else c->tx_buf = o; o->wpos = o->outpos = o->buf; o->end = o->buf + CLI_TX_BUF_SIZE; } c->tx_write = o; if (!c->tx_pos) c->tx_pos = o; o->next = NULL; } o->wpos += size; return o->wpos - size; } /** * cli_printf - send reply to a CLI connection * @c: CLI connection * @code: numeric code of the reply, negative for continuation lines * @msg: a printf()-like formatting string. * * This function send a single line of reply to a given CLI connection. * In works in all aspects like bsprintf() except that it automatically * prepends the reply line prefix. * * Please note that if the connection can be already busy sending some * data in which case cli_printf() stores the output to a temporary buffer, * so please avoid sending a large batch of replies without waiting * for the buffers to be flushed. * * If you want to write to the current CLI output, you can use the cli_msg() * macro instead. */ void cli_printf(cli *c, int code, char *msg, ...) { va_list args; byte buf[CLI_LINE_SIZE]; int cd = code; int errcode; int size, cnt; if (cd < 0) { cd = -cd; if (cd == c->last_reply) size = bsprintf(buf, " "); else size = bsprintf(buf, "%04d-", cd); errcode = -8000; } else if (cd == CLI_ASYNC_CODE) { size = 1; buf[0] = '+'; errcode = cd; } else { size = bsprintf(buf, "%04d ", cd); errcode = 8000; cd = 0; /* Final message - no more continuation lines */ } c->last_reply = cd; va_start(args, msg); cnt = bvsnprintf(buf+size, sizeof(buf)-size-1, msg, args); va_end(args); if (cnt < 0) { cli_printf(c, errcode, ""); return; } size += cnt; buf[size++] = '\n'; memcpy(cli_alloc_out(c, size), buf, size); } static void cli_copy_message(cli *c) { byte *p, *q; uint cnt = 2; if (c->ring_overflow) { byte buf[64]; int n = bsprintf(buf, "<%d messages lost>\n", c->ring_overflow); c->ring_overflow = 0; memcpy(cli_alloc_out(c, n), buf, n); } p = c->ring_read; while (*p) { cnt++; p++; if (p == c->ring_end) p = c->ring_buf; ASSERT(p != c->ring_write); } c->async_msg_size += cnt; q = cli_alloc_out(c, cnt); *q++ = '+'; p = c->ring_read; do { *q = *p++; if (p == c->ring_end) p = c->ring_buf; } while (*q++); c->ring_read = p; q[-1] = '\n'; } static void cli_hello(cli *c) { cli_printf(c, 1, "BIRD " BIRD_VERSION " ready."); c->cont = NULL; } static void cli_free_out(cli *c) { struct cli_out *o, *p; if (o = c->tx_buf) { o->wpos = o->outpos = o->buf; while (p = o->next) { o->next = p->next; mb_free(p); } } c->tx_write = c->tx_pos = NULL; c->async_msg_size = 0; } void cli_written(cli *c) { cli_free_out(c); ev_schedule(c->event); } static byte *cli_rh_pos; static uint cli_rh_len; static int cli_rh_trick_flag; struct cli *this_cli; static int cli_cmd_read_hook(byte *buf, uint max, UNUSED int fd) { if (!cli_rh_trick_flag) { cli_rh_trick_flag = 1; buf[0] = '!'; return 1; } if (max > cli_rh_len) max = cli_rh_len; memcpy(buf, cli_rh_pos, max); cli_rh_pos += max; cli_rh_len -= max; return max; } static void cli_command(struct cli *c) { struct config f; int res; if (config->cli_debug > 1) log(L_TRACE "CLI: %s", c->rx_buf); bzero(&f, sizeof(f)); f.mem = c->parser_pool; f.pool = rp_new(c->pool, "Config"); init_list(&f.symbols); cf_read_hook = cli_cmd_read_hook; cli_rh_pos = c->rx_buf; cli_rh_len = strlen(c->rx_buf); cli_rh_trick_flag = 0; this_cli = c; lp_flush(c->parser_pool); res = cli_parse(&f); if (!res) cli_printf(c, 9001, f.err_msg); config_free(&f); } static void cli_event(void *data) { cli *c = data; int err; while (c->ring_read != c->ring_write && c->async_msg_size < CLI_MAX_ASYNC_QUEUE) cli_copy_message(c); if (c->tx_pos) ; else if (c->cont) c->cont(c); else { err = cli_get_command(c); if (!err) return; if (err < 0) cli_printf(c, 9000, "Command too long"); else cli_command(c); } cli_write_trigger(c); } cli * cli_new(void *priv) { pool *p = rp_new(cli_pool, "CLI"); cli *c = mb_alloc(p, sizeof(cli)); bzero(c, sizeof(cli)); c->pool = p; c->priv = priv; c->event = ev_new(p); c->event->hook = cli_event; c->event->data = c; c->cont = cli_hello; c->parser_pool = lp_new_default(c->pool); c->show_pool = lp_new_default(c->pool); c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE); ev_schedule(c->event); return c; } void cli_kick(cli *c) { if (!c->cont && !c->tx_pos) ev_schedule(c->event); } static list cli_log_hooks; static int cli_log_inited; void cli_set_log_echo(cli *c, uint mask, uint size) { if (c->ring_buf) { mb_free(c->ring_buf); c->ring_buf = c->ring_end = c->ring_read = c->ring_write = NULL; rem_node(&c->n); } c->log_mask = mask; if (mask && size) { c->ring_buf = mb_alloc(c->pool, size); c->ring_end = c->ring_buf + size; c->ring_read = c->ring_write = c->ring_buf; add_tail(&cli_log_hooks, &c->n); c->log_threshold = size / 8; } c->ring_overflow = 0; } void cli_echo(uint class, byte *msg) { unsigned len, free, i, l; cli *c; byte *m; if (!cli_log_inited || EMPTY_LIST(cli_log_hooks)) return; len = strlen(msg) + 1; WALK_LIST(c, cli_log_hooks) { if (!(c->log_mask & (1 << class))) continue; if (c->ring_read <= c->ring_write) free = (c->ring_end - c->ring_buf) - (c->ring_write - c->ring_read + 1); else free = c->ring_read - c->ring_write - 1; if ((len > free) || (free < c->log_threshold && class < (unsigned) L_INFO[0])) { c->ring_overflow++; continue; } if (c->ring_read == c->ring_write) ev_schedule(c->event); m = msg; l = len; while (l) { if (c->ring_read <= c->ring_write) i = c->ring_end - c->ring_write; else i = c->ring_read - c->ring_write; if (i > l) i = l; memcpy(c->ring_write, m, i); m += i; l -= i; c->ring_write += i; if (c->ring_write == c->ring_end) c->ring_write = c->ring_buf; } } } /* Hack for scheduled undo notification */ extern cli *cmd_reconfig_stored_cli; void cli_free(cli *c) { cli_set_log_echo(c, 0, 0); if (c->cleanup) c->cleanup(c); if (c == cmd_reconfig_stored_cli) cmd_reconfig_stored_cli = NULL; rfree(c->pool); } /** * cli_init - initialize the CLI module * * This function is called during BIRD startup to initialize * the internal data structures of the CLI module. */ void cli_init(void) { cli_pool = rp_new(&root_pool, "CLI"); init_list(&cli_log_hooks); cli_log_inited = 1; } bird-2.0.8/nest/bird.h0000664000175000017500000000050714025744326013430 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Basic Declarations * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_BIRD_H_ #define _BIRD_BIRD_H_ #include "sysdep/config.h" #include "lib/birdlib.h" #include "lib/ip.h" #include "lib/net.h" #endif bird-2.0.8/nest/bfd.h0000664000175000017500000000354414025744326013247 0ustar feelafeela/* * BIRD -- Bidirectional Forwarding Detection (BFD) * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_NBFD_H_ #define _BIRD_NBFD_H_ #include "lib/lists.h" #include "lib/resource.h" #include "conf/conf.h" struct bfd_session; struct bfd_options { u32 min_rx_int; u32 min_tx_int; u32 idle_tx_int; u8 multiplier; u8 passive; u8 passive_set; u8 mode; }; struct bfd_request { resource r; node n; ip_addr addr; ip_addr local; struct iface *iface; struct iface *vrf; struct bfd_options opts; void (*hook)(struct bfd_request *); void *data; struct bfd_session *session; u8 state; u8 diag; u8 old_state; u8 down; }; #define BGP_BFD_GRACEFUL 2 /* BFD down triggers graceful restart */ #define BFD_STATE_ADMIN_DOWN 0 #define BFD_STATE_DOWN 1 #define BFD_STATE_INIT 2 #define BFD_STATE_UP 3 static inline struct bfd_options * bfd_new_options(void) { return cfg_allocz(sizeof(struct bfd_options)); } #ifdef CONFIG_BFD struct bfd_request * bfd_request_session(pool *p, ip_addr addr, ip_addr local, struct iface *iface, struct iface *vrf, void (*hook)(struct bfd_request *), void *data, const struct bfd_options *opts); void bfd_update_request(struct bfd_request *req, const struct bfd_options *opts); static inline void cf_check_bfd(int use UNUSED) { } #else static inline struct bfd_request * bfd_request_session(pool *p UNUSED, ip_addr addr UNUSED, ip_addr local UNUSED, struct iface *iface UNUSED, struct iface *vrf UNUSED, void (*hook)(struct bfd_request *) UNUSED, void *data UNUSED, const struct bfd_options *opts UNUSED) { return NULL; } static inline void bfd_update_request(struct bfd_request *req UNUSED, const struct bfd_options *opts UNUSED) { }; static inline void cf_check_bfd(int use) { if (use) cf_error("BFD not available"); } #endif /* CONFIG_BFD */ #endif /* _BIRD_NBFD_H_ */ bird-2.0.8/nest/attrs.h0000664000175000017500000001644514025744326013655 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Attribute Operations * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_ATTRS_H_ #define _BIRD_ATTRS_H_ #include #include "lib/unaligned.h" #include "nest/route.h" /* a-path.c */ #define AS_PATH_SET 1 /* Types of path segments */ #define AS_PATH_SEQUENCE 2 #define AS_PATH_CONFED_SEQUENCE 3 #define AS_PATH_CONFED_SET 4 #define AS_PATH_MAXLEN 10000 #define AS_TRANS 23456 /* AS_TRANS is used when we need to store 32bit ASN larger than 0xFFFF * to 16bit slot (like in 16bit AS_PATH). See RFC 4893 for details */ struct f_tree; int as_path_valid(byte *data, uint len, int bs, int sets, int confed, char *err, uint elen); int as_path_16to32(byte *dst, const byte *src, uint len); int as_path_32to16(byte *dst, const byte *src, uint len); int as_path_contains_as4(const struct adata *path); int as_path_contains_confed(const struct adata *path); struct adata *as_path_strip_confed(struct linpool *pool, const struct adata *op); struct adata *as_path_prepend2(struct linpool *pool, const struct adata *op, int seq, u32 as); struct adata *as_path_to_old(struct linpool *pool, const struct adata *path); struct adata *as_path_cut(struct linpool *pool, const struct adata *path, uint num); const struct adata *as_path_merge(struct linpool *pool, const struct adata *p1, const struct adata *p2); void as_path_format(const struct adata *path, byte *buf, uint size); int as_path_getlen(const struct adata *path); int as_path_getlen_int(const struct adata *path, int bs); int as_path_get_first(const struct adata *path, u32 *orig_as); int as_path_get_first_regular(const struct adata *path, u32 *last_as); int as_path_get_last(const struct adata *path, u32 *last_as); u32 as_path_get_last_nonaggregated(const struct adata *path); int as_path_contains(const struct adata *path, u32 as, int min); int as_path_match_set(const struct adata *path, const struct f_tree *set); const struct adata *as_path_filter(struct linpool *pool, const struct adata *path, const struct f_tree *set, u32 key, int pos); static inline struct adata *as_path_prepend(struct linpool *pool, const struct adata *path, u32 as) { return as_path_prepend2(pool, path, AS_PATH_SEQUENCE, as); } #define PM_ASN 0 #define PM_QUESTION 1 #define PM_ASTERISK 2 #define PM_ASN_EXPR 3 #define PM_ASN_RANGE 4 #define PM_ASN_SET 5 #define PM_LOOP 6 struct f_path_mask_item { union { u32 asn; /* PM_ASN */ const struct f_line *expr; /* PM_ASN_EXPR */ const struct f_tree *set; /* PM_ASN_SET */ struct { /* PM_ASN_RANGE */ u32 from; u32 to; }; }; int kind; }; struct f_path_mask { uint len; struct f_path_mask_item item[0]; }; int as_path_match(const struct adata *path, const struct f_path_mask *mask); /* Counterparts to appropriate as_path_* functions */ static inline int aggregator_16to32(byte *dst, const byte *src) { put_u32(dst, get_u16(src)); memcpy(dst+4, src+2, 4); return 8; } static inline int aggregator_32to16(byte *dst, const byte *src) { put_u16(dst, get_u32(src)); memcpy(dst+2, src+4, 4); return 6; } static inline int aggregator_contains_as4(const struct adata *a) { return get_u32(a->data) > 0xFFFF; } static inline struct adata * aggregator_to_old(struct linpool *pool, const struct adata *a) { struct adata *d = lp_alloc_adata(pool, 8); put_u32(d->data, AS_TRANS); memcpy(d->data + 4, a->data + 4, 4); return d; } /* a-set.c */ /* Extended Community subtypes (kinds) */ enum ec_subtype { EC_RT = 0x0002, EC_RO = 0x0003, EC_GENERIC = 0xFFFF, }; static inline const char *ec_subtype_str(const enum ec_subtype ecs) { switch (ecs) { case EC_RT: return "rt"; case EC_RO: return "ro"; default: return NULL; } } /* Transitive bit (for first u32 half of EC) */ #define EC_TBIT 0x40000000 #define ECOMM_LENGTH 8 static inline int int_set_get_size(const struct adata *list) { return list->length / 4; } static inline int ec_set_get_size(const struct adata *list) { return list->length / 8; } static inline int lc_set_get_size(const struct adata *list) { return list->length / 12; } static inline u32 *int_set_get_data(const struct adata *list) { return (u32 *) list->data; } static inline u32 ec_hi(u64 ec) { return ec >> 32; } static inline u32 ec_lo(u64 ec) { return ec; } static inline u64 ec_get(const u32 *l, int i) { return (((u64) l[i]) << 32) | l[i+1]; } /* RFC 4360 3.1. Two-Octet AS Specific Extended Community */ static inline u64 ec_as2(enum ec_subtype kind, u64 key, u64 val) { return (((u64) kind | 0x0000) << 48) | (key << 32) | val; } /* RFC 5668 4-Octet AS Specific BGP Extended Community */ static inline u64 ec_as4(enum ec_subtype kind, u64 key, u64 val) { return (((u64) kind | 0x0200) << 48) | (key << 16) | val; } /* RFC 4360 3.2. IPv4 Address Specific Extended Community */ static inline u64 ec_ip4(enum ec_subtype kind, u64 key, u64 val) { return (((u64) kind | 0x0100) << 48) | (key << 16) | val; } static inline u64 ec_generic(u64 key, u64 val) { return (key << 32) | val; } /* Large community value */ typedef struct lcomm { u32 asn; u32 ldp1; u32 ldp2; } lcomm; #define LCOMM_LENGTH 12 static inline lcomm lc_get(const u32 *l, int i) { return (lcomm) { l[i], l[i+1], l[i+2] }; } static inline void lc_put(u32 *l, lcomm v) { l[0] = v.asn; l[1] = v.ldp1; l[2] = v.ldp2; } static inline int lc_match(const u32 *l, int i, lcomm v) { return (l[i] == v.asn && l[i+1] == v.ldp1 && l[i+2] == v.ldp2); } static inline u32 *lc_copy(u32 *dst, const u32 *src) { memcpy(dst, src, LCOMM_LENGTH); return dst + 3; } int int_set_format(const struct adata *set, int way, int from, byte *buf, uint size); int ec_format(byte *buf, u64 ec); int ec_set_format(const struct adata *set, int from, byte *buf, uint size); int lc_format(byte *buf, lcomm lc); int lc_set_format(const struct adata *set, int from, byte *buf, uint size); int int_set_contains(const struct adata *list, u32 val); int ec_set_contains(const struct adata *list, u64 val); int lc_set_contains(const struct adata *list, lcomm val); const struct adata *int_set_prepend(struct linpool *pool, const struct adata *list, u32 val); const struct adata *int_set_add(struct linpool *pool, const struct adata *list, u32 val); const struct adata *ec_set_add(struct linpool *pool, const struct adata *list, u64 val); const struct adata *lc_set_add(struct linpool *pool, const struct adata *list, lcomm val); const struct adata *int_set_del(struct linpool *pool, const struct adata *list, u32 val); const struct adata *ec_set_del(struct linpool *pool, const struct adata *list, u64 val); const struct adata *lc_set_del(struct linpool *pool, const struct adata *list, lcomm val); const struct adata *int_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2); const struct adata *ec_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2); const struct adata *lc_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2); struct adata *ec_set_del_nontrans(struct linpool *pool, const struct adata *set); struct adata *int_set_sort(struct linpool *pool, const struct adata *src); struct adata *ec_set_sort(struct linpool *pool, const struct adata *src); struct adata *lc_set_sort(struct linpool *pool, const struct adata *src); void ec_set_sort_x(struct adata *set); /* Sort in place */ #endif bird-2.0.8/nest/a-set_test.c0000664000175000017500000001652314025744326014560 0ustar feelafeela/* * BIRD -- Set/Community-list Operations Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" #include "lib/net.h" #include "nest/route.h" #include "nest/attrs.h" #include "lib/resource.h" #define SET_SIZE 10 static const struct adata *set_sequence; /* <0; SET_SIZE) */ static const struct adata *set_sequence_same; /* <0; SET_SIZE) */ static const struct adata *set_sequence_higher; /* * (c) 2000 Pavel Machek * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "nest/bird.h" #include "nest/route.h" #include "nest/attrs.h" #include "lib/resource.h" #include "lib/string.h" /** * int_set_format - format an &set for printing * @set: set attribute to be formatted * @way: style of format (0 for router ID list, 1 for community list) * @from: starting position in set * @buf: destination buffer * @size: size of buffer * * This function takes a set attribute and formats it. @way specifies * the style of format (router ID / community). @from argument can be * used to specify the first printed value for the purpose of printing * untruncated sets even with smaller buffers. If the output fits in * the buffer, 0 is returned, otherwise the position of the first not * printed item is returned. This value can be used as @from argument * in subsequent calls. If truncated output suffices, -1 can be * instead used as @from, in that case " ..." is eventually added at * the buffer to indicate truncation. */ int int_set_format(const struct adata *set, int way, int from, byte *buf, uint size) { u32 *z = (u32 *) set->data; byte *end = buf + size - 24; int from2 = MAX(from, 0); int to = set->length / 4; int i; for (i = from2; i < to; i++) { if (buf > end) { if (from < 0) strcpy(buf, " ..."); else *buf = 0; return i; } if (i > from2) *buf++ = ' '; if (way) buf += bsprintf(buf, "(%d,%d)", z[i] >> 16, z[i] & 0xffff); else buf += bsprintf(buf, "%R", z[i]); } *buf = 0; return 0; } int ec_format(byte *buf, u64 ec) { u32 type, key, val; char tbuf[16]; const char *kind; type = ec >> 48; kind = ec_subtype_str(type & 0xf0ff); if (!kind) { bsprintf(tbuf, "unknown 0x%x", type); kind = tbuf; } switch (ec >> 56) { /* RFC 4360 3.1. Two-Octet AS Specific Extended Community */ case 0x00: case 0x40: key = (ec >> 32) & 0xFFFF; val = ec; return bsprintf(buf, "(%s, %u, %u)", kind, key, val); /* RFC 4360 3.2. IPv4 Address Specific Extended Community */ case 0x01: case 0x41: key = ec >> 16; val = ec & 0xFFFF; return bsprintf(buf, "(%s, %R, %u)", kind, key, val); /* RFC 5668 4-Octet AS Specific BGP Extended Community */ case 0x02: case 0x42: key = ec >> 16; val = ec & 0xFFFF; return bsprintf(buf, "(%s, %u, %u)", kind, key, val); /* Generic format for unknown kinds of extended communities */ default: key = ec >> 32; val = ec; return bsprintf(buf, "(generic, 0x%x, 0x%x)", key, val); } } int ec_set_format(const struct adata *set, int from, byte *buf, uint size) { u32 *z = int_set_get_data(set); byte *end = buf + size - 64; int from2 = MAX(from, 0); int to = int_set_get_size(set); int i; for (i = from2; i < to; i += 2) { if (buf > end) { if (from < 0) strcpy(buf, " ..."); else *buf = 0; return i; } if (i > from2) *buf++ = ' '; buf += ec_format(buf, ec_get(z, i)); } *buf = 0; return 0; } int lc_format(byte *buf, lcomm lc) { return bsprintf(buf, "(%u, %u, %u)", lc.asn, lc.ldp1, lc.ldp2); } int lc_set_format(const struct adata *set, int from, byte *buf, uint bufsize) { u32 *d = (u32 *) set->data; byte *end = buf + bufsize - 64; int from2 = MAX(from, 0); int to = set->length / 4; int i; for (i = from2; i < to; i += 3) { if (buf > end) { if (from < 0) strcpy(buf, "..."); else buf[-1] = 0; return i; } buf += bsprintf(buf, "(%u, %u, %u)", d[i], d[i+1], d[i+2]); *buf++ = ' '; } if (i != from2) buf--; *buf = 0; return 0; } int int_set_contains(const struct adata *list, u32 val) { if (!list) return 0; u32 *l = (u32 *) list->data; int len = int_set_get_size(list); int i; for (i = 0; i < len; i++) if (*l++ == val) return 1; return 0; } int ec_set_contains(const struct adata *list, u64 val) { if (!list) return 0; u32 *l = int_set_get_data(list); int len = int_set_get_size(list); u32 eh = ec_hi(val); u32 el = ec_lo(val); int i; for (i=0; i < len; i += 2) if (l[i] == eh && l[i+1] == el) return 1; return 0; } int lc_set_contains(const struct adata *list, lcomm val) { if (!list) return 0; u32 *l = int_set_get_data(list); int len = int_set_get_size(list); int i; for (i = 0; i < len; i += 3) if (lc_match(l, i, val)) return 1; return 0; } const struct adata * int_set_prepend(struct linpool *pool, const struct adata *list, u32 val) { struct adata *res; int len; if (int_set_contains(list, val)) return list; len = list ? list->length : 0; res = lp_alloc(pool, sizeof(struct adata) + len + 4); res->length = len + 4; if (list) memcpy(res->data + 4, list->data, list->length); * (u32 *) res->data = val; return res; } const struct adata * int_set_add(struct linpool *pool, const struct adata *list, u32 val) { struct adata *res; int len; if (int_set_contains(list, val)) return list; len = list ? list->length : 0; res = lp_alloc(pool, sizeof(struct adata) + len + 4); res->length = len + 4; if (list) memcpy(res->data, list->data, list->length); * (u32 *) (res->data + len) = val; return res; } const struct adata * ec_set_add(struct linpool *pool, const struct adata *list, u64 val) { if (ec_set_contains(list, val)) return list; int olen = list ? list->length : 0; struct adata *res = lp_alloc(pool, sizeof(struct adata) + olen + 8); res->length = olen + 8; if (list) memcpy(res->data, list->data, list->length); u32 *l = (u32 *) (res->data + olen); l[0] = ec_hi(val); l[1] = ec_lo(val); return res; } const struct adata * lc_set_add(struct linpool *pool, const struct adata *list, lcomm val) { if (lc_set_contains(list, val)) return list; int olen = list ? list->length : 0; struct adata *res = lp_alloc(pool, sizeof(struct adata) + olen + LCOMM_LENGTH); res->length = olen + LCOMM_LENGTH; if (list) memcpy(res->data, list->data, list->length); lc_put((u32 *) (res->data + olen), val); return res; } const struct adata * int_set_del(struct linpool *pool, const struct adata *list, u32 val) { if (!int_set_contains(list, val)) return list; struct adata *res; res = lp_alloc(pool, sizeof(struct adata) + list->length - 4); res->length = list->length - 4; u32 *l = int_set_get_data(list); u32 *k = int_set_get_data(res); int len = int_set_get_size(list); int i; for (i = 0; i < len; i++) if (l[i] != val) *k++ = l[i]; return res; } const struct adata * ec_set_del(struct linpool *pool, const struct adata *list, u64 val) { if (!ec_set_contains(list, val)) return list; struct adata *res; res = lp_alloc(pool, sizeof(struct adata) + list->length - 8); res->length = list->length - 8; u32 *l = int_set_get_data(list); u32 *k = int_set_get_data(res); int len = int_set_get_size(list); u32 eh = ec_hi(val); u32 el = ec_lo(val); int i; for (i=0; i < len; i += 2) if (! (l[i] == eh && l[i+1] == el)) { *k++ = l[i]; *k++ = l[i+1]; } return res; } const struct adata * lc_set_del(struct linpool *pool, const struct adata *list, lcomm val) { if (!lc_set_contains(list, val)) return list; struct adata *res; res = lp_alloc(pool, sizeof(struct adata) + list->length - LCOMM_LENGTH); res->length = list->length - LCOMM_LENGTH; u32 *l = int_set_get_data(list); u32 *k = int_set_get_data(res); int len = int_set_get_size(list); int i; for (i=0; i < len; i += 3) if (! lc_match(l, i, val)) k = lc_copy(k, l+i); return res; } const struct adata * int_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2) { if (!l1) return l2; if (!l2) return l1; struct adata *res; int len = int_set_get_size(l2); u32 *l = int_set_get_data(l2); u32 tmp[len]; u32 *k = tmp; int i; for (i = 0; i < len; i++) if (!int_set_contains(l1, l[i])) *k++ = l[i]; if (k == tmp) return l1; len = (k - tmp) * 4; res = lp_alloc(pool, sizeof(struct adata) + l1->length + len); res->length = l1->length + len; memcpy(res->data, l1->data, l1->length); memcpy(res->data + l1->length, tmp, len); return res; } const struct adata * ec_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2) { if (!l1) return l2; if (!l2) return l1; struct adata *res; int len = int_set_get_size(l2); u32 *l = int_set_get_data(l2); u32 tmp[len]; u32 *k = tmp; int i; for (i = 0; i < len; i += 2) if (!ec_set_contains(l1, ec_get(l, i))) { *k++ = l[i]; *k++ = l[i+1]; } if (k == tmp) return l1; len = (k - tmp) * 4; res = lp_alloc(pool, sizeof(struct adata) + l1->length + len); res->length = l1->length + len; memcpy(res->data, l1->data, l1->length); memcpy(res->data + l1->length, tmp, len); return res; } const struct adata * lc_set_union(struct linpool *pool, const struct adata *l1, const struct adata *l2) { if (!l1) return l2; if (!l2) return l1; struct adata *res; int len = int_set_get_size(l2); u32 *l = int_set_get_data(l2); u32 tmp[len]; u32 *k = tmp; int i; for (i = 0; i < len; i += 3) if (!lc_set_contains(l1, lc_get(l, i))) k = lc_copy(k, l+i); if (k == tmp) return l1; len = (k - tmp) * 4; res = lp_alloc(pool, sizeof(struct adata) + l1->length + len); res->length = l1->length + len; memcpy(res->data, l1->data, l1->length); memcpy(res->data + l1->length, tmp, len); return res; } struct adata * ec_set_del_nontrans(struct linpool *pool, const struct adata *set) { adata *res = lp_alloc_adata(pool, set->length); u32 *src = int_set_get_data(set); u32 *dst = int_set_get_data(res); int len = int_set_get_size(set); int i; /* Remove non-transitive communities (EC_TBIT set) */ for (i = 0; i < len; i += 2) { if (src[i] & EC_TBIT) continue; *dst++ = src[i]; *dst++ = src[i+1]; } res->length = ((byte *) dst) - res->data; return res; } static int int_set_cmp(const void *X, const void *Y) { const u32 *x = X, *y = Y; return (*x < *y) ? -1 : (*x > *y) ? 1 : 0; } struct adata * int_set_sort(struct linpool *pool, const struct adata *src) { struct adata *dst = lp_alloc_adata(pool, src->length); memcpy(dst->data, src->data, src->length); qsort(dst->data, dst->length / 4, 4, int_set_cmp); return dst; } static int ec_set_cmp(const void *X, const void *Y) { u64 x = ec_get(X, 0); u64 y = ec_get(Y, 0); return (x < y) ? -1 : (x > y) ? 1 : 0; } struct adata * ec_set_sort(struct linpool *pool, const struct adata *src) { struct adata *dst = lp_alloc_adata(pool, src->length); memcpy(dst->data, src->data, src->length); qsort(dst->data, dst->length / 8, 8, ec_set_cmp); return dst; } void ec_set_sort_x(struct adata *set) { /* Sort in place */ qsort(set->data, set->length / 8, 8, ec_set_cmp); } static int lc_set_cmp(const void *X, const void *Y) { const u32 *x = X, *y = Y; if (x[0] != y[0]) return (x[0] > y[0]) ? 1 : -1; if (x[1] != y[1]) return (x[1] > y[1]) ? 1 : -1; if (x[2] != y[2]) return (x[2] > y[2]) ? 1 : -1; return 0; } struct adata * lc_set_sort(struct linpool *pool, const struct adata *src) { struct adata *dst = lp_alloc_adata(pool, src->length); memcpy(dst->data, src->data, src->length); qsort(dst->data, dst->length / LCOMM_LENGTH, LCOMM_LENGTH, lc_set_cmp); return dst; } bird-2.0.8/nest/a-path_test.c0000664000175000017500000001357714025744326014727 0ustar feelafeela/* * BIRD -- Path Operations Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" #include "nest/route.h" #include "nest/attrs.h" #include "lib/resource.h" #define TESTS_NUM 30 #define AS_PATH_LENGTH 1000 #if AS_PATH_LENGTH > AS_PATH_MAXLEN #warning "AS_PATH_LENGTH should be <= AS_PATH_MAXLEN" #endif static int t_as_path_match(void) { resource_init(); int round; for (round = 0; round < TESTS_NUM; round++) { struct adata empty_as_path = {}; struct adata *as_path = &empty_as_path; u32 first_prepended, last_prepended; first_prepended = last_prepended = 0; struct linpool *lp = lp_new_default(&root_pool); struct f_path_mask *mask = alloca(sizeof(struct f_path_mask) + AS_PATH_LENGTH * sizeof(struct f_path_mask_item)); mask->len = AS_PATH_LENGTH; for (int i = AS_PATH_LENGTH - 1; i >= 0; i--) { u32 val = bt_random(); as_path = as_path_prepend(lp, as_path, val); bt_debug("Prepending ASN: %10u \n", val); if (i == 0) last_prepended = val; if (i == AS_PATH_LENGTH-1) first_prepended = val; mask->item[i].kind = PM_ASN; mask->item[i].asn = val; } bt_assert_msg(as_path_match(as_path, mask), "Mask should match with AS path"); u32 asn; bt_assert(as_path_get_first(as_path, &asn)); bt_assert_msg(asn == last_prepended, "as_path_get_first() should return the last prepended ASN"); bt_assert(as_path_get_last(as_path, &asn)); bt_assert_msg(asn == first_prepended, "as_path_get_last() should return the first prepended ASN"); rfree(lp); } return 1; } static int t_path_format(void) { resource_init(); struct adata empty_as_path = {}; struct adata *as_path = &empty_as_path; struct linpool *lp = lp_new_default(&root_pool); uint i; for (i = 4294967285; i <= 4294967294; i++) { as_path = as_path_prepend(lp, as_path, i); bt_debug("Prepending ASN: %10u \n", i); } #define BUFFER_SIZE 120 byte buf[BUFFER_SIZE] = {}; as_path_format(&empty_as_path, buf, BUFFER_SIZE); bt_assert_msg(strcmp(buf, "") == 0, "Buffer(%zu): '%s'", strlen(buf), buf); as_path_format(as_path, buf, BUFFER_SIZE); bt_assert_msg(strcmp(buf, "4294967294 4294967293 4294967292 4294967291 4294967290 4294967289 4294967288 4294967287 4294967286 4294967285") == 0, "Buffer(%zu): '%s'", strlen(buf), buf); #define SMALL_BUFFER_SIZE 25 byte buf2[SMALL_BUFFER_SIZE] = {}; as_path_format(as_path, buf2, SMALL_BUFFER_SIZE); bt_assert_msg(strcmp(buf2, "4294967294 42...") == 0, "Small Buffer(%zu): '%s'", strlen(buf2), buf2); rfree(lp); return 1; } static int count_asn_in_array(const u32 *array, u32 asn) { int counts_of_contains = 0; int u; for (u = 0; u < AS_PATH_LENGTH; u++) if (array[u] == asn) counts_of_contains++; return counts_of_contains; } static int t_path_include(void) { resource_init(); struct adata empty_as_path = {}; struct adata *as_path = &empty_as_path; struct linpool *lp = lp_new_default(&root_pool); u32 as_nums[AS_PATH_LENGTH] = {}; int i; for (i = 0; i < AS_PATH_LENGTH; i++) { u32 val = bt_random(); as_nums[i] = val; as_path = as_path_prepend(lp, as_path, val); } for (i = 0; i < AS_PATH_LENGTH; i++) { int counts_of_contains = count_asn_in_array(as_nums, as_nums[i]); bt_assert_msg(as_path_contains(as_path, as_nums[i], counts_of_contains), "AS Path should contains %d-times number %d", counts_of_contains, as_nums[i]); bt_assert(as_path_filter(lp, as_path, NULL, as_nums[i], 0) != NULL); bt_assert(as_path_filter(lp, as_path, NULL, as_nums[i], 1) != NULL); } for (i = 0; i < 10000; i++) { u32 test_val = bt_random(); int counts_of_contains = count_asn_in_array(as_nums, test_val); int result = as_path_contains(as_path, test_val, (counts_of_contains == 0 ? 1 : counts_of_contains)); if (counts_of_contains) bt_assert_msg(result, "As path should contain %d-times the number %u", counts_of_contains, test_val); else bt_assert_msg(result == 0, "As path should not contain the number %u", test_val); } rfree(lp); return 1; } #if 0 static int t_as_path_converting(void) { resource_init(); struct adata empty_as_path = {}; struct adata *as_path = &empty_as_path; struct linpool *lp = lp_new_default(&root_pool); #define AS_PATH_LENGTH_FOR_CONVERTING_TEST 10 int i; for (i = 0; i < AS_PATH_LENGTH_FOR_CONVERTING_TEST; i++) as_path = as_path_prepend(lp, as_path, i); bt_debug("data length: %u \n", as_path->length); byte buffer[100] = {}; int used_size = as_path_convert_to_new(as_path, buffer, AS_PATH_LENGTH_FOR_CONVERTING_TEST-1); bt_debug("as_path_convert_to_new: len %d \n%s\n", used_size, buffer); for (i = 0; i < used_size; i++) { bt_debug("\\03%d", buffer[i]); } bt_debug("\n"); bt_assert(memcmp(buffer, "\032\039\030\030\030\030\030\030\030\039\030\030\030\030\030\030\030\038\030\030\030\030\030\030" "\030\037\030\030\030\030\030\030\030\036\030\030\030\030", 38)); bzero(buffer, sizeof(buffer)); int new_used; used_size = as_path_convert_to_old(as_path, buffer, &new_used); bt_debug("as_path_convert_to_old: len %d, new_used: %d \n", used_size, new_used); for (i = 0; i < used_size; i++) { bt_debug("\\03%d", buffer[i]); } bt_debug("\n"); bt_assert(memcmp(buffer, "\032\0310\030\039\030\038\030\037\030\036\030\035\030\034\030\033\030\032\030\031\030\030", 22)); return 1; } #endif int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_as_path_match, "Testing AS path matching and some a-path utilities."); bt_test_suite(t_path_format, "Testing formating as path into byte buffer"); bt_test_suite(t_path_include, "Testing including a AS number in AS path"); // bt_test_suite(t_as_path_converting, "Testing as_path_convert_to_*() output constancy"); return bt_exit_value(); } bird-2.0.8/nest/a-path.c0000664000175000017500000004103414025744326013655 0ustar feelafeela/* * BIRD -- Path Operations * * (c) 2000 Martin Mares * (c) 2000 Pavel Machek * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "nest/route.h" #include "nest/attrs.h" #include "lib/resource.h" #include "lib/unaligned.h" #include "lib/string.h" #include "filter/data.h" // static inline void put_as(byte *data, u32 as) { put_u32(data, as); } // static inline u32 get_as(byte *data) { return get_u32(data); } #define put_as put_u32 #define get_as get_u32 #define BS 4 /* Default block size of ASN (autonomous system number) */ #define BAD(DSC, VAL) ({ err_dsc = DSC; err_val = VAL; goto bad; }) int as_path_valid(byte *data, uint len, int bs, int sets, int confed, char *err, uint elen) { byte *pos = data; char *err_dsc = NULL; uint err_val = 0; while (len) { if (len < 2) BAD("segment framing error", 0); /* Process one AS path segment */ uint type = pos[0]; uint slen = 2 + bs * pos[1]; if (len < slen) BAD("segment framing error", len); switch (type) { case AS_PATH_SET: if (!sets) BAD("AS_SET segment", type); break; case AS_PATH_SEQUENCE: break; case AS_PATH_CONFED_SEQUENCE: if (!confed) BAD("AS_CONFED_SEQUENCE segment", type); break; case AS_PATH_CONFED_SET: if (!sets || !confed) BAD("AS_CONFED_SET segment", type); break; default: BAD("unknown segment", type); } if (pos[1] == 0) BAD("zero-length segment", type); pos += slen; len -= slen; } return 1; bad: if (err) if (bsnprintf(err, elen, "%s (%u) at %d", err_dsc, err_val, (int) (pos - data)) < 0) err[0] = 0; return 0; } int as_path_16to32(byte *dst, const byte *src, uint len) { byte *dst0 = dst; const byte *end = src + len; uint i, n; while (src < end) { n = src[1]; *dst++ = *src++; *dst++ = *src++; for (i = 0; i < n; i++) { put_u32(dst, get_u16(src)); src += 2; dst += 4; } } return dst - dst0; } int as_path_32to16(byte *dst, const byte *src, uint len) { byte *dst0 = dst; const byte *end = src + len; uint i, n; while (src < end) { n = src[1]; *dst++ = *src++; *dst++ = *src++; for (i = 0; i < n; i++) { put_u16(dst, get_u32(src)); src += 4; dst += 2; } } return dst - dst0; } int as_path_contains_as4(const struct adata *path) { const byte *pos = path->data; const byte *end = pos + path->length; uint i, n; while (pos < end) { n = pos[1]; pos += 2; for (i = 0; i < n; i++) { if (get_as(pos) > 0xFFFF) return 1; pos += BS; } } return 0; } int as_path_contains_confed(const struct adata *path) { const byte *pos = path->data; const byte *end = pos + path->length; while (pos < end) { uint type = pos[0]; uint slen = 2 + BS * pos[1]; if ((type == AS_PATH_CONFED_SEQUENCE) || (type == AS_PATH_CONFED_SET)) return 1; pos += slen; } return 0; } struct adata * as_path_strip_confed(struct linpool *pool, const struct adata *path) { struct adata *res = lp_alloc_adata(pool, path->length); const byte *src = path->data; const byte *end = src + path->length; byte *dst = res->data; while (src < end) { uint type = src[0]; uint slen = 2 + BS * src[1]; /* Copy regular segments */ if ((type == AS_PATH_SET) || (type == AS_PATH_SEQUENCE)) { memcpy(dst, src, slen); dst += slen; } src += slen; } /* Fix the result length */ res->length = dst - res->data; return res; } struct adata * as_path_prepend2(struct linpool *pool, const struct adata *op, int seq, u32 as) { struct adata *np; const byte *pos = op->data; uint len = op->length; if (len && (pos[0] == seq) && (pos[1] < 255)) { /* Starting with matching segment => just prepend the AS number */ np = lp_alloc_adata(pool, len + BS); np->data[0] = seq; np->data[1] = pos[1] + 1; put_as(np->data + 2, as); uint dlen = BS * pos[1]; memcpy(np->data + 2 + BS, pos + 2, dlen); ADVANCE(pos, len, 2 + dlen); } else { /* Create a new path segment */ np = lp_alloc_adata(pool, len + 2 + BS); np->data[0] = seq; np->data[1] = 1; put_as(np->data + 2, as); } if (len) { byte *dst = np->data + 2 + BS * np->data[1]; memcpy(dst, pos, len); } return np; } struct adata * as_path_to_old(struct linpool *pool, const struct adata *path) { struct adata *res = lp_alloc_adata(pool, path->length); byte *pos = res->data; byte *end = pos + res->length; uint i, n; u32 as; /* Copy the whole path */ memcpy(res->data, path->data, path->length); /* Replace 32-bit AS numbers with AS_TRANS */ while (pos < end) { n = pos[1]; pos += 2; for (i = 0; i < n; i++) { as = get_as(pos); if (as > 0xFFFF) put_as(pos, AS_TRANS); pos += BS; } } return res; } /* * Cut the path to the length @num, measured to the usual path metric. Note that * AS_CONFED_* segments have zero length and must be added if they are on edge. */ struct adata * as_path_cut(struct linpool *pool, const struct adata *path, uint num) { const byte *pos = path->data; const byte *end = pos + path->length; while (pos < end) { uint t = pos[0]; uint l = pos[1]; uint n = 0; switch (t) { case AS_PATH_SET: n = 1; break; case AS_PATH_SEQUENCE: n = l; break; case AS_PATH_CONFED_SEQUENCE: n = 0; break; case AS_PATH_CONFED_SET: n = 0; break; default: bug("as_path_cut: Invalid path segment"); } /* Cannot add whole segment, so try partial one and finish */ if (num < n) { const byte *nend = pos; if (num) nend += 2 + BS * num; struct adata *res = lp_alloc_adata(pool, path->length); res->length = nend - (const byte *) path->data; memcpy(res->data, path->data, res->length); if (num) { byte *dpos = ((byte *) res->data) + (pos - (const byte *) path->data); dpos[1] = num; } return res; } num -= n; pos += 2 + BS * l; } struct adata *res = lp_alloc_adata(pool, path->length); res->length = path->length; memcpy(res->data, path->data, res->length); return res; } /* * Merge (concatenate) paths @p1 and @p2 and return the result. * In contrast to other as_path_* functions, @p1 and @p2 may be reused. */ const struct adata * as_path_merge(struct linpool *pool, const struct adata *p1, const struct adata *p2) { if (p1->length == 0) return p2; if (p2->length == 0) return p1; struct adata *res = lp_alloc_adata(pool, p1->length + p2->length); memcpy(res->data, p1->data, p1->length); memcpy(res->data + p1->length, p2->data, p2->length); return res; } void as_path_format(const struct adata *path, byte *bb, uint size) { buffer buf = { .start = bb, .pos = bb, .end = bb + size }, *b = &buf; const byte *pos = path->data; const byte *end = pos + path->length; const char *ops, *cls; b->pos[0] = 0; while (pos < end) { uint type = pos[0]; uint len = pos[1]; pos += 2; switch (type) { case AS_PATH_SET: ops = "{"; cls = "}"; break; case AS_PATH_SEQUENCE: ops = NULL; cls = NULL; break; case AS_PATH_CONFED_SEQUENCE: ops = "("; cls = ")"; break; case AS_PATH_CONFED_SET: ops = "({"; cls = "})"; break; default: bug("Invalid path segment"); } if (ops) buffer_puts(b, ops); while (len--) { buffer_print(b, len ? "%u " : "%u", get_as(pos)); pos += BS; } if (cls) buffer_puts(b, cls); if (pos < end) buffer_puts(b, " "); } /* Handle overflow */ if (b->pos == b->end) strcpy(b->end - 12, "..."); } int as_path_getlen(const struct adata *path) { const byte *pos = path->data; const byte *end = pos + path->length; uint res = 0; while (pos < end) { uint t = pos[0]; uint l = pos[1]; uint n = 0; switch (t) { case AS_PATH_SET: n = 1; break; case AS_PATH_SEQUENCE: n = l; break; case AS_PATH_CONFED_SEQUENCE: n = 0; break; case AS_PATH_CONFED_SET: n = 0; break; default: bug("as_path_getlen: Invalid path segment"); } res += n; pos += 2 + BS * l; } return res; } int as_path_get_last(const struct adata *path, u32 *orig_as) { const byte *pos = path->data; const byte *end = pos + path->length; int found = 0; u32 val = 0; while (pos < end) { uint type = pos[0]; uint len = pos[1]; pos += 2; if (!len) continue; switch (type) { case AS_PATH_SET: case AS_PATH_CONFED_SET: found = 0; break; case AS_PATH_SEQUENCE: case AS_PATH_CONFED_SEQUENCE: val = get_as(pos + BS * (len - 1)); found = 1; break; default: bug("Invalid path segment"); } pos += BS * len; } if (found) *orig_as = val; return found; } u32 as_path_get_last_nonaggregated(const struct adata *path) { const byte *pos = path->data; const byte *end = pos + path->length; u32 val = 0; while (pos < end) { uint type = pos[0]; uint len = pos[1]; pos += 2; if (!len) continue; switch (type) { case AS_PATH_SET: case AS_PATH_CONFED_SET: return val; case AS_PATH_SEQUENCE: case AS_PATH_CONFED_SEQUENCE: val = get_as(pos + BS * (len - 1)); break; default: bug("Invalid path segment"); } pos += BS * len; } return val; } int as_path_get_first(const struct adata *path, u32 *last_as) { const u8 *p = path->data; if ((path->length == 0) || (p[0] != AS_PATH_SEQUENCE) || (p[1] == 0)) return 0; *last_as = get_as(p+2); return 1; } int as_path_get_first_regular(const struct adata *path, u32 *last_as) { const byte *pos = path->data; const byte *end = pos + path->length; while (pos < end) { uint type = pos[0]; uint len = pos[1]; pos += 2; switch (type) { case AS_PATH_SET: return 0; case AS_PATH_SEQUENCE: if (len == 0) return 0; *last_as = get_as(pos); return 1; case AS_PATH_CONFED_SEQUENCE: case AS_PATH_CONFED_SET: break; default: bug("Invalid path segment"); } pos += BS * len; } return 0; } int as_path_contains(const struct adata *path, u32 as, int min) { const u8 *p = path->data; const u8 *q = p+path->length; int num = 0; int i, n; while (pdata; const u8 *q = p+path->length; int i, n; while (plength; const u8 *p = path->data; const u8 *q = path->data + len; u8 *d, *d2; int i, bt, sn, dn; u8 buf[len]; d = buf; while (p 0) { /* Nonempty block, set block header and advance */ d[0] = bt; d[1] = dn; d = d2; } } uint nl = d - buf; if (nl == path->length) return path; struct adata *res = lp_alloc(pool, sizeof(struct adata) + nl); res->length = nl; memcpy(res->data, buf, nl); return res; } struct pm_pos { u8 set; u8 mark; union { const char *sp; u32 asn; } val; }; static int parse_path(const struct adata *path, struct pm_pos *pp) { const byte *pos = path->data; const byte *end = pos + path->length; struct pm_pos *op = pp; uint i; while (pos < end) { uint type = pos[0]; uint len = pos[1]; pos += 2; switch (type) { case AS_PATH_SET: case AS_PATH_CONFED_SET: pp->set = 1; pp->mark = 0; pp->val.sp = pos - 1; pp++; pos += BS * len; break; case AS_PATH_SEQUENCE: case AS_PATH_CONFED_SEQUENCE: for (i = 0; i < len; i++) { pp->set = 0; pp->mark = 0; pp->val.asn = get_as(pos); pp++; pos += BS; } break; default: bug("Invalid path segment"); } } return pp - op; } static int pm_match_val(const struct pm_pos *pos, u32 asn, u32 asn2) { u32 gas; if (! pos->set) return ((pos->val.asn >= asn) && (pos->val.asn <= asn2)); const u8 *p = pos->val.sp; int len = *p++; int i; for (i = 0; i < len; i++) { gas = get_as(p + i * BS); if ((gas >= asn) && (gas <= asn2)) return 1; } return 0; } static int pm_match_set(const struct pm_pos *pos, const struct f_tree *set) { struct f_val asn = { .type = T_INT }; if (! pos->set) { asn.val.i = pos->val.asn; return !!find_tree(set, &asn); } const u8 *p = pos->val.sp; int len = *p++; int i; for (i = 0; i < len; i++) { asn.val.i = get_as(p + i * BS); if (find_tree(set, &asn)) return 1; } return 0; } static inline int pm_match(const struct pm_pos *pos, const struct f_path_mask_item *mask, u32 asn, u32 asn2) { return ((mask->kind == PM_QUESTION) || ((mask->kind != PM_ASN_SET) ? pm_match_val(pos, asn, asn2) : pm_match_set(pos, mask->set))); } static void pm_mark(struct pm_pos *pos, int *i, int plen, int *nl, int *nh) { int j = *i; if (pos[j].set) do { pos[j].mark = 1; j++; } while ((j < plen) && pos[j].set); else j++; pos[j].mark = 1; /* Update low, high based on first and last marked pos */ int l = pos[*i].set ? *i : j; *nl = (*nl < 0) ? l : MIN(*nl, l); *nh = MAX(*nh, j); *i = j; } /* AS path matching is nontrivial. Because AS path can * contain sets, it is not a plain wildcard matching. A set * in an AS path is interpreted as it might represent any * sequence of AS numbers from that set (possibly with * repetitions). So it is also a kind of a pattern, * more complicated than a path mask. * * The algorithm for AS path matching is a variant * of nondeterministic finite state machine, where * positions in AS path are states, and items in * path mask are input for that finite state machine. * During execution of the algorithm we maintain a set * of marked states - a state is marked if it can be * reached by any walk through NFSM with regard to * currently processed part of input. When we process * next part of mask, we advance each marked state. * We start with marked first position, when we * run out of marked positions, we reject. When * we process the whole mask, we accept if final position * (auxiliary position after last real position in AS path) * is marked. */ int as_path_match(const struct adata *path, const struct f_path_mask *mask) { struct pm_pos pos[2048 + 1]; int plen = parse_path(path, pos); int l, h, i, nh, nl, last, loop; u32 val = 0; u32 val2 = 0; /* l and h are bound of interval of positions where are marked states */ pos[plen].set = 0; pos[plen].mark = 0; l = h = loop = 0; pos[0].mark = 1; for (uint m=0; m < mask->len; m++) { /* We remove this mark to not step after pos[plen] */ pos[plen].mark = 0; switch (mask->item[m].kind) { case PM_ASTERISK: for (i = l; i <= plen; i++) pos[i].mark = 1; h = plen; break; case PM_LOOP: loop = 1; break; case PM_ASN: /* Define single ASN as ASN..ASN - very narrow interval */ val2 = val = mask->item[m].asn; goto step; case PM_ASN_EXPR: bug("Expressions should be evaluated on AS path mask construction."); case PM_ASN_RANGE: val = mask->item[m].from; val2 = mask->item[m].to; goto step; case PM_QUESTION: case PM_ASN_SET: step: nh = nl = -1; last = plen; for (i = h; i >= l; i--) if (pos[i].mark) { pos[i].mark = 0; int j = i; match: if (pm_match(pos + j, &mask->item[m], val, val2)) { pm_mark(pos, &j, plen, &nl, &nh); if (loop && (j < last)) goto match; } last = i; } if (nh < 0) return 0; h = nh; l = nl; loop = 0; break; } } return pos[plen].mark; } bird-2.0.8/nest/Makefile0000664000175000017500000000050014025744326013770 0ustar feelafeelasrc := a-path.c a-set.c cli.c cmds.c iface.c locks.c neighbor.c password.c proto.c rt-attr.c rt-dev.c rt-fib.c rt-show.c rt-table.c obj := $(src-o-files) $(all-daemon) $(cf-local) tests_src := a-set_test.c a-path_test.c tests_targets := $(tests_targets) $(tests-target-files) tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/nest/Doc0000664000175000017500000000024614025744326012767 0ustar feelafeelaH Core S rt-fib.c S rt-table.c S rt-attr.c D proto.sgml S proto.c S proto-hooks.c S iface.c S neighbor.c S cli.c S locks.c # rt-dev.c documented in Protocols chapter bird-2.0.8/lib/0000775000175000017500000000000014025744326012132 5ustar feelafeelabird-2.0.8/lib/xmalloc.c0000664000175000017500000000221214025744326013732 0ustar feelafeela/* * BIRD Library -- malloc() With Checking * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "nest/bird.h" #include "lib/resource.h" #ifndef HAVE_LIBDMALLOC /** * xmalloc - malloc with checking * @size: block size * * This function is equivalent to malloc() except that in case of * failure it calls die() to quit the program instead of returning * a %NULL pointer. * * Wherever possible, please use the memory resources instead. */ void * xmalloc(uint size) { void *p = malloc(size); if (p) return p; die("Unable to allocate %d bytes of memory", size); } /** * xrealloc - realloc with checking * @ptr: original memory block * @size: block size * * This function is equivalent to realloc() except that in case of * failure it calls die() to quit the program instead of returning * a %NULL pointer. * * Wherever possible, please use the memory resources instead. */ void * xrealloc(void *ptr, uint size) { void *p = realloc(ptr, size); if (p) return p; die("Unable to allocate %d bytes of memory", size); } #endif bird-2.0.8/lib/unaligned.h0000664000175000017500000000354414025744326014257 0ustar feelafeela/* * Unaligned Data Accesses -- Generic Version, Network Order * * (c) 2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_UNALIGNED_H_ #define _BIRD_UNALIGNED_H_ /* * We don't do any clever tricks with unaligned accesses since it's * virtually impossible to figure out what alignment does the CPU want * (unaligned accesses can be emulated by the OS which makes them work, * but unusably slow). We use memcpy and hope GCC will optimize it out * if possible. */ #include "sysdep/unix/endian.h" #include "lib/string.h" static inline u8 get_u8(const void *p) { return * (u8 *) p; } static inline u16 get_u16(const void *p) { u16 x; memcpy(&x, p, 2); return ntohs(x); } static inline u32 get_u24(const void *P) { const byte *p = P; return (p[0] << 16) + (p[1] << 8) + p[2]; } static inline u32 get_u32(const void *p) { u32 x; memcpy(&x, p, 4); return ntohl(x); } static inline u64 get_u64(const void *p) { u32 xh, xl; memcpy(&xh, p, 4); memcpy(&xl, p+4, 4); return (((u64) ntohl(xh)) << 32) | ntohl(xl); } static inline void put_u8(void *p, u8 x) { memcpy(p, &x, 1); } static inline void put_u16(void *p, u16 x) { x = htons(x); memcpy(p, &x, 2); } static inline void put_u24(void *p, u32 x) { x = htonl(x); memcpy(p, ((char *) &x) + 1, 3); } static inline void put_u32(void *p, u32 x) { x = htonl(x); memcpy(p, &x, 4); } static inline void put_u64(void *p, u64 x) { u32 xh, xl; xh = htonl(x >> 32); xl = htonl((u32) x); memcpy(p, &xh, 4); memcpy(p+4, &xl, 4); } static inline void get_u32s(const void *p, u32 *x, int n) { int i; memcpy(x, p, 4*n); for (i = 0; i < n; i++) x[i] = ntohl(x[i]); } static inline void put_u32s(void *p, const u32 *x, int n) { int i; for (i = 0; i < n; i++) put_u32((byte *) p + 4*i, x[i]); } #endif bird-2.0.8/lib/timer.h0000664000175000017500000000551214025744326013426 0ustar feelafeela/* * BIRD -- Timers * * (c) 2013--2017 Ondrej Zajicek * (c) 2013--2017 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_TIMER_H_ #define _BIRD_TIMER_H_ #include "nest/bird.h" #include "lib/buffer.h" #include "lib/resource.h" typedef struct timer { resource r; void (*hook)(struct timer *); void *data; btime expires; /* 0=inactive */ uint randomize; /* Amount of randomization */ uint recurrent; /* Timer recurrence */ int index; } timer; struct timeloop { BUFFER_(timer *) timers; btime last_time; btime real_time; }; static inline uint timers_count(struct timeloop *loop) { return loop->timers.used - 1; } static inline timer *timers_first(struct timeloop *loop) { return (loop->timers.used > 1) ? loop->timers.data[1] : NULL; } extern struct timeloop main_timeloop; btime current_time(void); btime current_real_time(void); //#define now (current_time() TO_S) //#define now_real (current_real_time() TO_S) extern btime boot_time; timer *tm_new(pool *p); void tm_set(timer *t, btime when); void tm_start(timer *t, btime after); void tm_stop(timer *t); static inline int tm_active(timer *t) { return t->expires != 0; } static inline btime tm_remains(timer *t) { btime now_ = current_time(); return (t->expires > now_) ? (t->expires - now_) : 0; } static inline timer * tm_new_init(pool *p, void (*hook)(struct timer *), void *data, uint rec, uint rand) { timer *t = tm_new(p); t->hook = hook; t->data = data; t->recurrent = rec; t->randomize = rand; return t; } static inline void tm_set_max(timer *t, btime when) { if (when > t->expires) tm_set(t, when); } static inline void tm_start_max(timer *t, btime after) { btime rem = tm_remains(t); tm_start(t, MAX_(rem, after)); } /* In sysdep code */ void times_init(struct timeloop *loop); void times_update(struct timeloop *loop); void times_update_real_time(struct timeloop *loop); /* For I/O loop */ void timers_init(struct timeloop *loop, pool *p); void timers_fire(struct timeloop *loop); void timer_init(void); struct timeformat { const char *fmt1, *fmt2; btime limit; }; #define TM_ISO_SHORT_S (struct timeformat){"%T", "%F", (s64) (20*3600) S_} #define TM_ISO_SHORT_MS (struct timeformat){"%T.%3f", "%F", (s64) (20*3600) S_} #define TM_ISO_SHORT_US (struct timeformat){"%T.%6f", "%F", (s64) (20*3600) S_} #define TM_ISO_LONG_S (struct timeformat){"%F %T", NULL, 0} #define TM_ISO_LONG_MS (struct timeformat){"%F %T.%3f", NULL, 0} #define TM_ISO_LONG_US (struct timeformat){"%F %T.%6f", NULL, 0} #define TM_DATETIME_BUFFER_SIZE 32 /* Buffer size required by tm_format_time() */ btime tm_parse_time(const char *x); void tm_format_time(char *x, struct timeformat *fmt, btime t); int tm_format_real_time(char *x, size_t max, const char *fmt, btime t); #endif bird-2.0.8/lib/timer.c0000664000175000017500000001744014025744326013424 0ustar feelafeela/* * BIRD -- Timers * * (c) 2013--2017 Ondrej Zajicek * (c) 2013--2017 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Timers * * Timers are resources which represent a wish of a module to call a function at * the specified time. The timer code does not guarantee exact timing, only that * a timer function will not be called before the requested time. * * In BIRD, time is represented by values of the &btime type which is signed * 64-bit integer interpreted as a relative number of microseconds since some * fixed time point in past. The current time can be obtained by current_time() * function with reasonable accuracy and is monotonic. There is also a current * 'wall-clock' real time obtainable by current_real_time() reported by OS. * * Each timer is described by a &timer structure containing a pointer to the * handler function (@hook), data private to this function (@data), time the * function should be called at (@expires, 0 for inactive timers), for the other * fields see |timer.h|. */ #include #include #include #include "nest/bird.h" #include "lib/heap.h" #include "lib/resource.h" #include "lib/timer.h" struct timeloop main_timeloop; #ifdef USE_PTHREADS #include /* Data accessed and modified from proto/bfd/io.c */ pthread_key_t current_time_key; static inline struct timeloop * timeloop_current(void) { return pthread_getspecific(current_time_key); } static inline void timeloop_init_current(void) { pthread_key_create(¤t_time_key, NULL); pthread_setspecific(current_time_key, &main_timeloop); } void wakeup_kick_current(void); #else /* Just use main timelooop */ static inline struct timeloop * timeloop_current(void) { return &main_timeloop; } static inline void timeloop_init_current(void) { } #endif btime current_time(void) { return timeloop_current()->last_time; } btime current_real_time(void) { struct timeloop *loop = timeloop_current(); if (!loop->real_time) times_update_real_time(loop); return loop->real_time; } #define TIMER_LESS(a,b) ((a)->expires < (b)->expires) #define TIMER_SWAP(heap,a,b,t) (t = heap[a], heap[a] = heap[b], heap[b] = t, \ heap[a]->index = (a), heap[b]->index = (b)) static void tm_free(resource *r) { timer *t = (void *) r; tm_stop(t); } static void tm_dump(resource *r) { timer *t = (void *) r; debug("(code %p, data %p, ", t->hook, t->data); if (t->randomize) debug("rand %d, ", t->randomize); if (t->recurrent) debug("recur %d, ", t->recurrent); if (t->expires) debug("expires in %d ms)\n", (t->expires - current_time()) TO_MS); else debug("inactive)\n"); } static struct resclass tm_class = { "Timer", sizeof(timer), tm_free, tm_dump, NULL, NULL }; timer * tm_new(pool *p) { timer *t = ralloc(p, &tm_class); t->index = -1; return t; } void tm_set(timer *t, btime when) { struct timeloop *loop = timeloop_current(); uint tc = timers_count(loop); if (!t->expires) { t->index = ++tc; t->expires = when; BUFFER_PUSH(loop->timers) = t; HEAP_INSERT(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP); } else if (t->expires < when) { t->expires = when; HEAP_INCREASE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index); } else if (t->expires > when) { t->expires = when; HEAP_DECREASE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index); } #ifdef CONFIG_BFD /* Hack to notify BFD loops */ if ((loop != &main_timeloop) && (t->index == 1)) wakeup_kick_current(); #endif } void tm_start(timer *t, btime after) { tm_set(t, current_time() + MAX(after, 0)); } void tm_stop(timer *t) { if (!t->expires) return; struct timeloop *loop = timeloop_current(); uint tc = timers_count(loop); HEAP_DELETE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index); BUFFER_POP(loop->timers); t->index = -1; t->expires = 0; } void timers_init(struct timeloop *loop, pool *p) { times_init(loop); BUFFER_INIT(loop->timers, p, 4); BUFFER_PUSH(loop->timers) = NULL; } void io_log_event(void *hook, void *data); void timers_fire(struct timeloop *loop) { btime base_time; timer *t; times_update(loop); base_time = loop->last_time; while (t = timers_first(loop)) { if (t->expires > base_time) return; if (t->recurrent) { btime when = t->expires + t->recurrent; if (when <= loop->last_time) when = loop->last_time + t->recurrent; if (t->randomize) when += random() % (t->randomize + 1); tm_set(t, when); } else tm_stop(t); /* This is ugly hack, we want to log just timers executed from the main I/O loop */ if (loop == &main_timeloop) io_log_event(t->hook, t->data); t->hook(t); } } void timer_init(void) { timers_init(&main_timeloop, &root_pool); timeloop_init_current(); } /** * tm_parse_time - parse a date and time * @x: time string * * tm_parse_time() takes a textual representation of a date and time * (yyyy-mm-dd[ hh:mm:ss[.sss]]) and converts it to the corresponding value of * type &btime. */ btime tm_parse_time(const char *x) { struct tm tm = {}; int usec, n1, n2, n3, r; r = sscanf(x, "%d-%d-%d%n %d:%d:%d%n.%d%n", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &n1, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &n2, &usec, &n3); if ((r == 3) && !x[n1]) tm.tm_hour = tm.tm_min = tm.tm_sec = usec = 0; else if ((r == 6) && !x[n2]) usec = 0; else if ((r == 7) && !x[n3]) { /* Convert subsecond digits to proper precision */ int digits = n3 - n2 - 1; if ((usec < 0) || (usec > 999999) || (digits < 1) || (digits > 6)) return 0; while (digits++ < 6) usec *= 10; } else return 0; tm.tm_mon--; tm.tm_year -= 1900; s64 ts = mktime(&tm); if ((ts == (s64) (time_t) -1) || (ts < 0) || (ts > ((s64) 1 << 40))) return 0; return ts S + usec; } /** * tm_format_time - convert date and time to textual representation * @x: destination buffer of size %TM_DATETIME_BUFFER_SIZE * @fmt: specification of resulting textual representation of the time * @t: time * * This function formats the given relative time value @t to a textual * date/time representation (dd-mm-yyyy hh:mm:ss) in real time. */ void tm_format_time(char *x, struct timeformat *fmt, btime t) { btime dt = current_time() - t; btime rt = current_real_time() - dt; int v1 = !fmt->limit || (dt < fmt->limit); if (!tm_format_real_time(x, TM_DATETIME_BUFFER_SIZE, v1 ? fmt->fmt1 : fmt->fmt2, rt)) strcpy(x, ""); } /* Replace %f in format string with usec scaled to requested precision */ static int strfusec(char *buf, int size, const char *fmt, uint usec) { char *str = buf; int parity = 0; while (*fmt) { if (!size) return 0; if ((fmt[0] == '%') && (!parity) && ((fmt[1] == 'f') || (fmt[1] >= '1') && (fmt[1] <= '6') && (fmt[2] == 'f'))) { int digits = (fmt[1] == 'f') ? 6 : (fmt[1] - '0'); uint d = digits, u = usec; /* Convert microseconds to requested precision */ while (d++ < 6) u /= 10; int num = bsnprintf(str, size, "%0*u", digits, u); if (num < 0) return 0; fmt += (fmt[1] == 'f') ? 2 : 3; ADVANCE(str, size, num); } else { /* Handle '%%' expression */ parity = (*fmt == '%') ? !parity : 0; *str++ = *fmt++; size--; } } if (!size) return 0; *str = 0; return str - buf; } int tm_format_real_time(char *x, size_t max, const char *fmt, btime t) { s64 t1 = t TO_S; s64 t2 = t - t1 S; time_t ts = t1; struct tm tm; if (!localtime_r(&ts, &tm)) return 0; byte tbuf[TM_DATETIME_BUFFER_SIZE]; if (!strfusec(tbuf, max, fmt, t2)) return 0; if (!strftime(x, max, tbuf, &tm)) return 0; return 1; } bird-2.0.8/lib/tbf.c0000664000175000017500000000117014025744326013050 0ustar feelafeela/* * BIRD Library -- Token Bucket Filter * * (c) 2014 Ondrej Zajicek * (c) 2014 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "lib/timer.h" int tbf_limit(struct tbf *f) { btime delta = current_time() - f->timestamp; if (delta > 0) { u64 next = f->count + delta * f->rate; u64 burst = (u64) f->burst << 20; f->count = MIN(next, burst); f->timestamp += delta; } if (f->count < 1000000) { f->drop++; return 1; } else { f->count -= 1000000; f->drop = 0; return 0; } } bird-2.0.8/lib/strtoul.c0000664000175000017500000000212414025744326014011 0ustar feelafeela/* * BIRD Library -- Parse numbers * * (c) 2019 Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "lib/string.h" #include #define ULI_MAX_DIV10 (UINT64_MAX / 10) #define ULI_MAX_MOD10 (UINT64_MAX % 10) u64 bstrtoul10(const char *str, char **end) { u64 out = 0; for (*end = (char *) str; (**end >= '0') && (**end <= '9'); (*end)++) { u64 digit = **end - '0'; if ((out > ULI_MAX_DIV10) || (out == ULI_MAX_DIV10) && (digit > ULI_MAX_MOD10)) { errno = ERANGE; return UINT64_MAX; } out *= 10; out += (**end) - '0'; } return out; } u64 bstrtoul16(const char *str, char **end) { u64 out = 0; for (int i=0; i<=(64/4); i++) { switch (str[i]) { case '0' ... '9': out *= 16; out += str[i] - '0'; break; case 'a' ... 'f': out *= 16; out += str[i] + 10 - 'a'; break; case 'A' ... 'F': out *= 16; out += str[i] + 10 - 'A'; break; default: *end = (char *) &(str[i]); return out; } } errno = ERANGE; return UINT64_MAX; } bird-2.0.8/lib/string.h0000664000175000017500000000321314025744326013610 0ustar feelafeela/* * BIRD Library -- String Functions * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_STRING_H_ #define _BIRD_STRING_H_ #include #include #include #include "lib/resource.h" int bsprintf(char *str, const char *fmt, ...); int bvsprintf(char *str, const char *fmt, va_list args); int bsnprintf(char *str, int size, const char *fmt, ...); int bvsnprintf(char *str, int size, const char *fmt, va_list args); int buffer_vprint(buffer *buf, const char *fmt, va_list args); int buffer_print(buffer *buf, const char *fmt, ...); void buffer_puts(buffer *buf, const char *str); u64 bstrtoul10(const char *str, char **end); u64 bstrtoul16(const char *str, char **end); int patmatch(const byte *pat, const byte *str); static inline char *xbasename(const char *str) { char *s = strrchr(str, '/'); return s ? s+1 : (char *) str; } static inline char * xstrdup(const char *c) { size_t l = strlen(c) + 1; char *z = xmalloc(l); memcpy(z, c, l); return z; } static inline char * lp_strdup(linpool *lp, const char *c) { size_t l = strlen(c) + 1; char *z = lp_allocu(lp, l); memcpy(z, c, l); return z; } static inline void memset32(void *D, u32 val, uint n) { u32 *dst = D; uint i; for (i = 0; i < n; i++) dst[i] = val; } static inline int bstrcmp(const char *s1, const char *s2) { if (s1 && s2) return strcmp(s1, s2); else return !s2 - !s1; } static inline void * bmemcpy(void *dest, const void *src, size_t n) { if (n) return memcpy(dest, src, n); else return dest; } #define ROUTER_ID_64_LENGTH 23 #endif bird-2.0.8/lib/socket.h0000664000175000017500000001577314025744326013610 0ustar feelafeela/* * BIRD Socket Interface * * (c) 1998--2004 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_SOCKET_H_ #define _BIRD_SOCKET_H_ #include #include "lib/resource.h" #ifdef HAVE_LIBSSH #define LIBSSH_LEGACY_0_4 #include #endif #ifdef HAVE_LIBSSH struct ssh_sock { const char *username; /* (Required) SSH user name */ const char *server_hostkey_path; /* (Optional) Filepath to the SSH public key of remote side, can be knownhost file */ const char *client_privkey_path; /* (Optional) Filepath to the SSH private key of BIRD */ const char *subsystem; /* (Optional) Name of SSH subsytem */ ssh_session session; /* Internal */ ssh_channel channel; /* Internal */ int state; /* Internal */ #define SK_SSH_CONNECT 0 /* Start state */ #define SK_SSH_SERVER_KNOWN 1 /* Internal */ #define SK_SSH_USERAUTH 2 /* Internal */ #define SK_SSH_CHANNEL 3 /* Internal */ #define SK_SSH_SESSION 4 /* Internal */ #define SK_SSH_SUBSYSTEM 5 /* Internal */ #define SK_SSH_ESTABLISHED 6 /* Final state */ }; #endif typedef struct birdsock { resource r; pool *pool; /* Pool where incoming connections should be allocated (for SK_xxx_PASSIVE) */ int type; /* Socket type */ int subtype; /* Socket subtype */ void *data; /* User data */ ip_addr saddr, daddr; /* IPA_NONE = unspecified */ const char *host; /* Alternative to daddr, NULL = unspecified */ uint sport, dport; /* 0 = unspecified (for IP: protocol type) */ int tos; /* TOS / traffic class, -1 = default */ int priority; /* Local socket priority, -1 = default */ int ttl; /* Time To Live, -1 = default */ u32 flags; struct iface *iface; /* Interface; specify this for broad/multicast sockets */ struct iface *vrf; /* Related VRF instance, NULL if global */ byte *rbuf, *rpos; /* NULL=allocate automatically */ uint fast_rx; /* RX has higher priority in event loop */ uint rbsize; int (*rx_hook)(struct birdsock *, uint size); /* NULL=receiving turned off, returns 1 to clear rx buffer */ byte *tbuf, *tpos; /* NULL=allocate automatically */ byte *ttx; /* Internal */ uint tbsize; void (*tx_hook)(struct birdsock *); void (*err_hook)(struct birdsock *, int); /* errno or zero if EOF */ /* Information about received datagrams (UDP, RAW), valid in rx_hook */ ip_addr faddr, laddr; /* src (From) and dst (Local) address of the datagram */ uint fport; /* src port of the datagram */ uint lifindex; /* local interface that received the datagram */ /* laddr and lifindex are valid only if SKF_LADDR_RX flag is set to request it */ int af; /* System-dependend adress family (e.g. AF_INET) */ int fd; /* System-dependent data */ int index; /* Index in poll buffer */ int rcv_ttl; /* TTL of last received datagram */ node n; void *rbuf_alloc, *tbuf_alloc; const char *password; /* Password for MD5 authentication */ const char *err; /* Error message */ struct ssh_sock *ssh; /* Used in SK_SSH */ } sock; sock *sock_new(pool *); /* Allocate new socket */ #define sk_new(X) sock_new(X) /* Wrapper to avoid name collision with OpenSSL */ int sk_open(sock *); /* Open socket */ int sk_rx_ready(sock *s); int sk_send(sock *, uint len); /* Send data, <0=err, >0=ok, 0=sleep */ int sk_send_to(sock *, uint len, ip_addr to, uint port); /* sk_send to given destination */ void sk_reallocate(sock *); /* Free and allocate tbuf & rbuf */ void sk_set_rbsize(sock *s, uint val); /* Resize RX buffer */ void sk_set_tbsize(sock *s, uint val); /* Resize TX buffer, keeping content */ void sk_set_tbuf(sock *s, void *tbuf); /* Switch TX buffer, NULL-> return to internal */ void sk_dump_all(void); int sk_is_ipv4(sock *s); /* True if socket is IPv4 */ int sk_is_ipv6(sock *s); /* True if socket is IPv6 */ static inline int sk_tx_buffer_empty(sock *sk) { return sk->tbuf == sk->tpos; } int sk_setup_multicast(sock *s); /* Prepare UDP or IP socket for multicasting */ int sk_join_group(sock *s, ip_addr maddr); /* Join multicast group on sk iface */ int sk_leave_group(sock *s, ip_addr maddr); /* Leave multicast group on sk iface */ int sk_setup_broadcast(sock *s); int sk_set_ttl(sock *s, int ttl); /* Set transmit TTL for given socket */ int sk_set_min_ttl(sock *s, int ttl); /* Set minimal accepted TTL for given socket */ int sk_set_md5_auth(sock *s, ip_addr local, ip_addr remote, int pxlen, struct iface *ifa, const char *passwd, int setkey); int sk_set_ipv6_checksum(sock *s, int offset); int sk_set_icmp6_filter(sock *s, int p1, int p2); void sk_log_error(sock *s, const char *p); byte * sk_rx_buffer(sock *s, int *len); /* Temporary */ extern int sk_priority_control; /* Suggested priority for control traffic, should be sysdep define */ /* Socket flags */ #define SKF_V6ONLY 0x02 /* Use IPV6_V6ONLY socket option */ #define SKF_LADDR_RX 0x04 /* Report local address for RX packets */ #define SKF_TTL_RX 0x08 /* Report TTL / Hop Limit for RX packets */ #define SKF_BIND 0x10 /* Bind datagram socket to given source address */ #define SKF_HIGH_PORT 0x20 /* Choose port from high range if possible */ #define SKF_THREAD 0x100 /* Socked used in thread, Do not add to main loop */ #define SKF_TRUNCATED 0x200 /* Received packet was truncated, set by IO layer */ #define SKF_HDRINCL 0x400 /* Used internally */ #define SKF_PKTINFO 0x800 /* Used internally */ /* * Socket types SA SP DA DP IF TTL SendTo (?=may, -=must not, *=must) */ #define SK_TCP_PASSIVE 0 /* ? * - - - ? - */ #define SK_TCP_ACTIVE 1 /* ? ? * * - ? - */ #define SK_TCP 2 #define SK_UDP 3 /* ? ? ? ? ? ? ? */ #define SK_IP 5 /* ? - ? * ? ? ? */ #define SK_MAGIC 7 /* Internal use by sysdep code */ #define SK_UNIX_PASSIVE 8 #define SK_UNIX 9 #define SK_SSH_ACTIVE 10 /* - - * * - ? - DA = host */ #define SK_SSH 11 /* * Socket subtypes */ #define SK_IPV4 1 #define SK_IPV6 2 /* * For TCP/IP sockets, Address family (IPv4 or IPv6) can be specified either * explicitly (SK_IPV4 or SK_IPV6) or implicitly (based on saddr, daddr). But * these specifications must be consistent. * * For SK_UDP or SK_IP sockets setting DA/DP allows to use sk_send(), otherwise * sk_send_to() must be used. * * For SK_IP sockets setting DP specifies protocol number, which is used for * both receiving and sending. * * For multicast on SK_UDP or SK_IP sockets set IF and TTL, call * sk_setup_multicast() to enable multicast on that socket, and then use * sk_join_group() and sk_leave_group() to manage a set of received multicast * groups. * * For datagram (SK_UDP, SK_IP) sockets, there are two ways to handle source * address. The socket could be bound to it using bind() syscall, but that also * forbids the reception of multicast packets, or the address could be set on * per-packet basis using platform dependent options (but these are not * available in some corner cases). The first way is used when SKF_BIND is * specified, the second way is used otherwise. */ #endif bird-2.0.8/lib/slists.h0000664000175000017500000000526314025744326013632 0ustar feelafeela/* * BIRD Library -- Safe Linked Lists * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_SLISTS_H_ #define _BIRD_SLISTS_H_ /* * These linked lists work in a way similar to standard lists defined * in lib/lists.h, but in addition to all usual list functions they * provide fast deletion/insertion/everything-safe asynchronous * walking. * * Example: * slist l; * siterator i; * snode *n; * * s_init(&i, &l); // Initialize iteration * ... * n = s_get(&i); // Some time later, fetch present * // value of the iterator and unlink it * // from the list. * while (n->next) { * ... * if (decided_to_stop) { * s_put(&i, n); // Store current position (maybe even * // that we stay at list end) * return; // and return * } * ... * } * // After finishing, don't link the iterator back */ typedef struct snode { struct snode *next, *prev; struct siterator *readers; } snode; typedef struct slist { /* In fact two overlayed snodes */ struct snode *head, *null, *tail; struct siterator *tail_readers; } slist; typedef struct siterator { /* * Caution: Layout of this structure depends hard on layout of the * snode. Our `next' must be at position of snode `readers' * field, our `null' must be at position of `prev' and it must * contain NULL in order to distinguish between siterator * and snode (snodes with NULL `prev' field never carry * iterators). You are not expected to understand this. */ struct siterator *prev, *null, *next; /* * For recently merged nodes this can be NULL, but then it's NULL * for all successors as well. This is done to speed up iterator * merging when there are lots of deletions. */ snode *node; } siterator; #define SNODE (snode *) #define SHEAD(list) ((void *)((list).head)) #define STAIL(list) ((void *)((list).tail)) #define SNODE_NEXT(n) ((void *)((SNODE (n))->next)) #define SNODE_VALID(n) ((SNODE (n))->next) #define WALK_SLIST(n,list) for(n=SHEAD(list); SNODE_VALID(n); n=SNODE_NEXT(n)) #define WALK_SLIST_DELSAFE(n,nxt,list) \ for(n=SHEAD(list); nxt=SNODE_NEXT(n); n=(void *) nxt) #define EMPTY_SLIST(list) (!(list).head->next) void s_add_tail(slist *, snode *); void s_add_head(slist *, snode *); void s_rem_node(snode *); void s_add_tail_list(slist *, slist *); void s_init_list(slist *); void s_insert_node(snode *, snode *); snode *s_get(siterator *); void s_put(siterator *, snode *n); static inline void s_init(siterator *i, slist *l) { s_put(i, SHEAD(*l)); } static inline int s_is_used(siterator *i) { return (i->prev != NULL); } #endif bird-2.0.8/lib/slists.c0000664000175000017500000000436214025744326013624 0ustar feelafeela/* * BIRD Library -- Safe Linked Lists * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #define _BIRD_SLISTS_C_ #include "nest/bird.h" #include "lib/slists.h" static inline void s_merge(snode *from, snode *to) { siterator *f, *g; if (!(f = from->readers)) return; if (!(g = to->readers)) { /* Fast path */ to->readers = f; f->prev = (siterator *) to; fixup: while (f && f->node) { f->node = NULL; f = f->next; } return; } /* Really merging */ while (g->next) g = g->next; g->next = f; f->prev = g; goto fixup; } snode * s_get(siterator *i) { siterator *f, *g; snode *n; if (!(n = i->node)) { /* * No node found. We have to walk the iterator list backwards * to find where are we linked. */ f = i; while (!f->null) f = f->prev; n = (snode *) f; } f = i->prev; /* Maybe the snode itself */ g = i->next; f->next = g; if (g) g->prev = f; i->prev = NULL; i->next = NULL; return n; } void s_put(siterator *i, snode *n) { siterator *f; i->node = n; if (f = n->readers) f->prev = i; i->next = f; n->readers = i; i->prev = (siterator *) n; i->null = NULL; } void s_add_tail(slist *l, snode *n) { snode *z = l->tail; n->next = (snode *) &l->null; n->prev = z; z->next = n; l->tail = n; n->readers = NULL; } void s_add_head(slist *l, snode *n) { snode *z = l->head; n->next = z; n->prev = (snode *) &l->head; z->prev = n; l->head = n; n->readers = NULL; } void s_insert_node(snode *n, snode *after) { snode *z = after->next; n->next = z; n->prev = after; after->next = n; z->prev = n; n->readers = NULL; } void s_rem_node(snode *n) { snode *z = n->prev; snode *x = n->next; z->next = x; x->prev = z; s_merge(n, x); } void s_init_list(slist *l) { l->head = (snode *) &l->null; l->null = NULL; l->tail = (snode *) &l->head; l->tail_readers = NULL; } void s_add_tail_list(slist *to, slist *l) { snode *p = to->tail; snode *q = l->head; p->next = q; q->prev = p; q = l->tail; q->next = (snode *) &to->null; to->tail = q; s_merge((snode *) &l->null, (snode *) &to->null); } bird-2.0.8/lib/slist_test.c0000664000175000017500000001647114025744326014504 0ustar feelafeela/* * BIRD Library -- Safe Linked Lists Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/slists.h" #define MAX_NUM 1000 static snode nodes[MAX_NUM]; static slist lst; static void show_list(void) { bt_debug("\n"); bt_debug("list.null is at %p and point to %p \n", &lst.null, lst.null); bt_debug("list.head is at %p and point to %p \n", &lst.head, lst.head); bt_debug("list.tail is at %p and point to %p \n", &lst.tail, lst.tail); bt_debug("list.tail_readers is at %p and point to %p \n", &lst.tail_readers, lst.tail_readers); int i; for (i = 0; i < MAX_NUM; i++) bt_debug("n[%3i] is at %p, .prev (%p) points to %p, .next (%p) points to %p, .readers (%p) points to %p \n", i, &nodes[i], &(nodes[i].prev), nodes[i].prev, &(nodes[i].next), nodes[i].next, &(nodes[i].readers), nodes[i].readers); } static int is_filled_list_well_linked(void) { int i; bt_assert(lst.head == &nodes[0]); bt_assert(lst.tail == &nodes[MAX_NUM-1]); bt_assert((void *) nodes[0].prev == (void *) &lst.head); bt_assert((void *) nodes[MAX_NUM-1].next == (void *) &lst.null); for (i = 0; i < MAX_NUM; i++) { if (i < (MAX_NUM-1)) bt_assert(nodes[i].next == &nodes[i+1]); if (i > 0) bt_assert(nodes[i].prev == &nodes[i-1]); } return 1; } static int is_empty_list_well_unlinked(void) { bt_assert(lst.head == SNODE &lst.null); bt_assert(lst.tail == SNODE &lst.head); bt_assert(EMPTY_SLIST(lst)); return 1; } static void init_list__(slist *l, struct snode nodes[]) { s_init_list(l); int i; for (i = 0; i < MAX_NUM; i++) { nodes[i].next = NULL; nodes[i].prev = NULL; } } static void init_list_(void) { init_list__(&lst, nodes); } static int t_add_tail(void) { int i; init_list_(); for (i = 0; i < MAX_NUM; i++) { s_add_tail(&lst, &nodes[i]); bt_debug("."); bt_assert(lst.tail == &nodes[i]); bt_assert(lst.head == &nodes[0]); bt_assert((void *) nodes[i].next == (void *) &lst.null); if (i > 0) { bt_assert(nodes[i-1].next == &nodes[i]); bt_assert(nodes[i].prev == &nodes[i-1]); } } bt_assert(is_filled_list_well_linked()); return 1; } static int t_add_head(void) { int i; init_list_(); for (i = MAX_NUM-1; i >= 0; i--) { s_add_head(&lst, &nodes[i]); bt_debug("."); bt_assert(lst.head == &nodes[i]); bt_assert(lst.tail == &nodes[MAX_NUM-1]); if (i < MAX_NUM-1) { bt_assert(nodes[i+1].prev == &nodes[i]); bt_assert(nodes[i].next == &nodes[i+1]); } } bt_assert(is_filled_list_well_linked()); return 1; } static void insert_node_(snode *n, snode *after) { s_insert_node(n, after); bt_debug("."); } static int t_insert_node(void) { int i; init_list_(); // add first node insert_node_(&nodes[0], SNODE &lst.head); // add odd nodes for (i = 2; i < MAX_NUM; i+=2) insert_node_(&nodes[i], &nodes[i-2]); // add even nodes for (i = 1; i < MAX_NUM; i+=2) insert_node_(&nodes[i], &nodes[i-1]); bt_debug("\n"); bt_assert(is_filled_list_well_linked()); return 1; } static void fill_list2(slist *l, snode nodes[]) { int i; for (i = 0; i < MAX_NUM; i++) s_add_tail(l, &nodes[i]); } static void fill_list(void) { fill_list2(&lst, SNODE nodes); } static int t_remove_node(void) { int i; init_list_(); /* Fill & Remove & Check */ fill_list(); for (i = 0; i < MAX_NUM; i++) s_rem_node(&nodes[i]); bt_assert(is_empty_list_well_unlinked()); /* Fill & Remove the half of nodes & Check & Remove the rest nodes & Check */ fill_list(); for (i = 0; i < MAX_NUM; i+=2) s_rem_node(&nodes[i]); int tail_node_index = (MAX_NUM % 2) ? MAX_NUM - 2 : MAX_NUM - 1; bt_assert(lst.head == &nodes[1]); bt_assert(lst.tail == &nodes[tail_node_index]); bt_assert(nodes[tail_node_index].next == SNODE &lst.null); for (i = 1; i < MAX_NUM; i+=2) { if (i > 1) bt_assert(nodes[i].prev == &nodes[i-2]); if (i < tail_node_index) bt_assert(nodes[i].next == &nodes[i+2]); } for (i = 1; i < MAX_NUM; i+=2) s_rem_node(&nodes[i]); bt_assert(is_empty_list_well_unlinked()); return 1; } static int t_add_tail_list(void) { snode nodes2[MAX_NUM]; slist l2; init_list__(&lst, SNODE &nodes); fill_list2(&lst, SNODE &nodes); init_list__(&l2, SNODE &nodes2); fill_list2(&l2, SNODE &nodes2); s_add_tail_list(&lst, &l2); bt_assert(nodes[MAX_NUM-1].next == &nodes2[0]); bt_assert(nodes2[0].prev == &nodes[MAX_NUM-1]); bt_assert(lst.tail == &nodes2[MAX_NUM-1]); return 1; } void dump(const char *str, slist *a) { snode *x; bt_debug("%s \n", str); for (x = SHEAD(*a); x; x = x->next) { siterator *i, *j; bt_debug("%p", x); j = (siterator *) x; for (i = x->readers; i; i = i->next) { if (i->prev != j) bt_debug(" ???"); j = i; bt_debug(" [%p:%p]", i, i->node); } bt_debug("\n"); } bt_debug("---\n"); } static int t_iterator_walk(void) { snode *node; siterator iter; init_list_(); fill_list(); int k; int i = 0; show_list(); s_init(&iter, &lst); WALK_SLIST(node, lst) { s_get(&iter); s_put(&iter, node); bt_debug("node->readers: %p, iter: %p, nodes[%d].readers: %p, node: %p, nodes[i]: %p, node->next: %p \n", node->readers, &iter, i, nodes[i].readers, node, &(nodes[i]), node->next); bt_assert(node->readers == &iter); bt_assert(node->readers == nodes[i].readers); bt_assert(node == &(nodes[i])); for (k = 0; k < MAX_NUM; k++) if (k != i) bt_assert(nodes[k].readers == NULL); dump("",&lst); i++; } return 1; } static int t_original(void) { slist a, b; snode *x, *y; siterator i, j; s_init_list(&a); s_init_list(&b); x = xmalloc(sizeof(*x)); s_add_tail(&a, x); x = xmalloc(sizeof(*x)); s_add_tail(&a, x); x = xmalloc(sizeof(*x)); s_add_tail(&a, x); dump("1", &a); s_init(&i, &a); s_init(&j, &a); dump("2", &a); x = s_get(&i); bt_debug("Got %p\n", x); dump("3", &a); s_put(&i, x->next); dump("4", &a); y = s_get(&j); while (y) { s_put(&j, y); dump("5*", &a); y = s_get(&j)->next; } dump("5 done", &a); s_rem_node(a.head->next); dump("6 (deletion)", &a); s_put(&i, s_get(&i)->next); dump("6 (relink)", &a); x = xmalloc(sizeof(*x)); s_add_tail(&b, x); dump("7 (second list)", &b); s_add_tail_list(&b, &a); dump("8 (after merge)", &b); return 1; } static int t_safe_del_walk(void) { init_list_(); fill_list(); show_list(); snode *node, *node_next; WALK_SLIST_DELSAFE(node,node_next, lst) { bt_debug("Will remove node %p \n", node); s_rem_node(SNODE node); } bt_assert(is_empty_list_well_unlinked()); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_add_tail, "Adding nodes to tail of list"); bt_test_suite(t_add_head, "Adding nodes to head of list"); bt_test_suite(t_insert_node, "Inserting nodes to list"); bt_test_suite(t_remove_node, "Removing nodes from list"); bt_test_suite(t_add_tail_list, "At the tail of a list adding the another list"); bt_test_suite(t_iterator_walk, "Iterator walk"); bt_test_suite(t_safe_del_walk, "WALK_SLIST_DELSAFE and s_rem_node all nodes"); bt_test_suite(t_original, "The original BIRD test suit for SLIST"); return bt_exit_value(); } bird-2.0.8/lib/slab.c0000664000175000017500000001746514025744326013234 0ustar feelafeela/* * BIRD Resource Manager -- A SLAB-like Memory Allocator * * Heavily inspired by the original SLAB paper by Jeff Bonwick. * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Slabs * * Slabs are collections of memory blocks of a fixed size. * They support very fast allocation and freeing of such blocks, prevent memory * fragmentation and optimize L2 cache usage. Slabs have been invented by Jeff Bonwick * and published in USENIX proceedings as `The Slab Allocator: An Object-Caching Kernel * Memory Allocator'. Our implementation follows this article except that we don't use * constructors and destructors. * * When the |DEBUGGING| switch is turned on, we automatically fill all * newly allocated and freed blocks with a special pattern to make detection * of use of uninitialized or already freed memory easier. * * Example: Nodes of a FIB are allocated from a per-FIB Slab. */ #include #include #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" #undef FAKE_SLAB /* Turn on if you want to debug memory allocations */ #ifdef DEBUGGING #define POISON /* Poison all regions after they are freed */ #endif static void slab_free(resource *r); static void slab_dump(resource *r); static resource *slab_lookup(resource *r, unsigned long addr); static size_t slab_memsize(resource *r); #ifdef FAKE_SLAB /* * Fake version used for debugging. */ struct slab { resource r; uint size; list objs; }; static struct resclass sl_class = { "FakeSlab", sizeof(struct slab), slab_free, slab_dump, NULL, slab_memsize }; struct sl_obj { node n; uintptr_t data_align[0]; byte data[0]; }; slab * sl_new(pool *p, uint size) { slab *s = ralloc(p, &sl_class); s->size = size; init_list(&s->objs); return s; } void * sl_alloc(slab *s) { struct sl_obj *o = xmalloc(sizeof(struct sl_obj) + s->size); add_tail(&s->objs, &o->n); return o->data; } void * sl_allocz(slab *s) { void *obj = sl_alloc(s); memset(obj, 0, s->size); return obj; } void sl_free(slab *s, void *oo) { struct sl_obj *o = SKIP_BACK(struct sl_obj, data, oo); rem_node(&o->n); xfree(o); } static void slab_free(resource *r) { slab *s = (slab *) r; struct sl_obj *o, *p; for(o = HEAD(s->objs); p = (struct sl_obj *) o->n.next; o = p) xfree(o); } static void slab_dump(resource *r) { slab *s = (slab *) r; int cnt = 0; struct sl_obj *o; WALK_LIST(o, s->objs) cnt++; debug("(%d objects per %d bytes)\n", cnt, s->size); } static size_t slab_memsize(resource *r) { slab *s = (slab *) r; size_t cnt = 0; struct sl_obj *o; WALK_LIST(o, s->objs) cnt++; return ALLOC_OVERHEAD + sizeof(struct slab) + cnt * (ALLOC_OVERHEAD + s->size); } #else /* * Real efficient version. */ #define SLAB_SIZE 4096 #define MAX_EMPTY_HEADS 1 struct slab { resource r; uint obj_size, head_size, objs_per_slab, num_empty_heads, data_size; list empty_heads, partial_heads, full_heads; }; static struct resclass sl_class = { "Slab", sizeof(struct slab), slab_free, slab_dump, slab_lookup, slab_memsize }; struct sl_head { node n; struct sl_obj *first_free; int num_full; }; struct sl_obj { struct sl_head *slab; union { struct sl_obj *next; byte data[0]; } u; }; struct sl_alignment { /* Magic structure for testing of alignment */ byte data; int x[0]; }; /** * sl_new - create a new Slab * @p: resource pool * @size: block size * * This function creates a new Slab resource from which * objects of size @size can be allocated. */ slab * sl_new(pool *p, uint size) { slab *s = ralloc(p, &sl_class); uint align = sizeof(struct sl_alignment); if (align < sizeof(int)) align = sizeof(int); s->data_size = size; size += OFFSETOF(struct sl_obj, u.data); if (size < sizeof(struct sl_obj)) size = sizeof(struct sl_obj); size = (size + align - 1) / align * align; s->obj_size = size; s->head_size = (sizeof(struct sl_head) + align - 1) / align * align; s->objs_per_slab = (SLAB_SIZE - s->head_size) / size; if (!s->objs_per_slab) bug("Slab: object too large"); s->num_empty_heads = 0; init_list(&s->empty_heads); init_list(&s->partial_heads); init_list(&s->full_heads); return s; } static struct sl_head * sl_new_head(slab *s) { struct sl_head *h = xmalloc(SLAB_SIZE); struct sl_obj *o = (struct sl_obj *)((byte *)h+s->head_size); struct sl_obj *no; uint n = s->objs_per_slab; *h = (struct sl_head) { .first_free = o, .num_full = 0, }; while (n--) { o->slab = h; no = (struct sl_obj *)((char *) o+s->obj_size); o->u.next = n ? no : NULL; o = no; } return h; } /** * sl_alloc - allocate an object from Slab * @s: slab * * sl_alloc() allocates space for a single object from the * Slab and returns a pointer to the object. */ void * sl_alloc(slab *s) { struct sl_head *h; struct sl_obj *o; redo: h = HEAD(s->partial_heads); if (!h->n.next) goto no_partial; okay: o = h->first_free; if (!o) goto full_partial; h->first_free = o->u.next; h->num_full++; #ifdef POISON memset(o->u.data, 0xcd, s->data_size); #endif return o->u.data; full_partial: rem_node(&h->n); add_tail(&s->full_heads, &h->n); goto redo; no_partial: h = HEAD(s->empty_heads); if (h->n.next) { rem_node(&h->n); add_head(&s->partial_heads, &h->n); s->num_empty_heads--; goto okay; } h = sl_new_head(s); add_head(&s->partial_heads, &h->n); goto okay; } /** * sl_allocz - allocate an object from Slab and zero it * @s: slab * * sl_allocz() allocates space for a single object from the * Slab and returns a pointer to the object after zeroing out * the object memory. */ void * sl_allocz(slab *s) { void *obj = sl_alloc(s); memset(obj, 0, s->data_size); return obj; } /** * sl_free - return a free object back to a Slab * @s: slab * @oo: object returned by sl_alloc() * * This function frees memory associated with the object @oo * and returns it back to the Slab @s. */ void sl_free(slab *s, void *oo) { struct sl_obj *o = SKIP_BACK(struct sl_obj, u.data, oo); struct sl_head *h = o->slab; #ifdef POISON memset(oo, 0xdb, s->data_size); #endif o->u.next = h->first_free; h->first_free = o; if (!--h->num_full) { rem_node(&h->n); if (s->num_empty_heads >= MAX_EMPTY_HEADS) xfree(h); else { add_head(&s->empty_heads, &h->n); s->num_empty_heads++; } } else if (!o->u.next) { rem_node(&h->n); add_head(&s->partial_heads, &h->n); } } static void slab_free(resource *r) { slab *s = (slab *) r; struct sl_head *h, *g; WALK_LIST_DELSAFE(h, g, s->empty_heads) xfree(h); WALK_LIST_DELSAFE(h, g, s->partial_heads) xfree(h); WALK_LIST_DELSAFE(h, g, s->full_heads) xfree(h); } static void slab_dump(resource *r) { slab *s = (slab *) r; int ec=0, pc=0, fc=0; struct sl_head *h; WALK_LIST(h, s->empty_heads) ec++; WALK_LIST(h, s->partial_heads) pc++; WALK_LIST(h, s->full_heads) fc++; debug("(%de+%dp+%df blocks per %d objs per %d bytes)\n", ec, pc, fc, s->objs_per_slab, s->obj_size); } static size_t slab_memsize(resource *r) { slab *s = (slab *) r; size_t heads = 0; struct sl_head *h; WALK_LIST(h, s->empty_heads) heads++; WALK_LIST(h, s->partial_heads) heads++; WALK_LIST(h, s->full_heads) heads++; return ALLOC_OVERHEAD + sizeof(struct slab) + heads * (ALLOC_OVERHEAD + SLAB_SIZE); } static resource * slab_lookup(resource *r, unsigned long a) { slab *s = (slab *) r; struct sl_head *h; WALK_LIST(h, s->partial_heads) if ((unsigned long) h < a && (unsigned long) h + SLAB_SIZE < a) return r; WALK_LIST(h, s->full_heads) if ((unsigned long) h < a && (unsigned long) h + SLAB_SIZE < a) return r; return NULL; } #endif bird-2.0.8/lib/sha512.h0000664000175000017500000000200214025744326013300 0ustar feelafeela/* * BIRD Library -- SHA-512 and SHA-384 Hash Functions * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libgcrypt-1.6.0, which is * (c) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_SHA512_H_ #define _BIRD_SHA512_H_ #include "nest/bird.h" #define SHA384_SIZE 48 #define SHA384_HEX_SIZE 97 #define SHA384_BLOCK_SIZE 128 #define SHA512_SIZE 64 #define SHA512_HEX_SIZE 129 #define SHA512_BLOCK_SIZE 128 struct hash_context; struct sha512_context { u64 h0, h1, h2, h3, h4, h5, h6, h7; byte buf[SHA512_BLOCK_SIZE]; uint nblocks; uint count; }; #define sha384_context sha512_context void sha512_init(struct hash_context *ctx); void sha384_init(struct hash_context *ctx); void sha512_update(struct hash_context *ctx, const byte *buf, uint len); #define sha384_update sha512_update byte *sha512_final(struct hash_context *ctx); #define sha384_final sha512_final #endif /* _BIRD_SHA512_H_ */ bird-2.0.8/lib/sha512.c0000664000175000017500000003010714025744326013302 0ustar feelafeela/* * BIRD Library -- SHA-512 and SHA-384 Hash Functions * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libgcrypt-1.6.0, which is * (c) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/sha512.h" #include "lib/unaligned.h" // #define SHA512_UNROLLED void sha512_init(struct hash_context *CTX) { struct sha512_context *ctx = (void *) CTX; ctx->h0 = U64(0x6a09e667f3bcc908); ctx->h1 = U64(0xbb67ae8584caa73b); ctx->h2 = U64(0x3c6ef372fe94f82b); ctx->h3 = U64(0xa54ff53a5f1d36f1); ctx->h4 = U64(0x510e527fade682d1); ctx->h5 = U64(0x9b05688c2b3e6c1f); ctx->h6 = U64(0x1f83d9abfb41bd6b); ctx->h7 = U64(0x5be0cd19137e2179); ctx->nblocks = 0; ctx->count = 0; } void sha384_init(struct hash_context *CTX) { struct sha384_context *ctx = (void *) CTX; ctx->h0 = U64(0xcbbb9d5dc1059ed8); ctx->h1 = U64(0x629a292a367cd507); ctx->h2 = U64(0x9159015a3070dd17); ctx->h3 = U64(0x152fecd8f70e5939); ctx->h4 = U64(0x67332667ffc00b31); ctx->h5 = U64(0x8eb44a8768581511); ctx->h6 = U64(0xdb0c2e0d64f98fa7); ctx->h7 = U64(0x47b5481dbefa4fa4); ctx->nblocks = 0; ctx->count = 0; } static inline u64 ROTR(u64 x, u64 n) { return ((x >> n) | (x << (64 - n))); } static inline u64 Ch(u64 x, u64 y, u64 z) { return ((x & y) ^ ( ~x & z)); } static inline u64 Maj(u64 x, u64 y, u64 z) { return ((x & y) ^ (x & z) ^ (y & z)); } static inline u64 sum0(u64 x) { return (ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39)); } static inline u64 sum1(u64 x) { return (ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41)); } static const u64 k[] = { U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd), U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc), U64(0x3956c25bf348b538), U64(0x59f111f1b605d019), U64(0x923f82a4af194f9b), U64(0xab1c5ed5da6d8118), U64(0xd807aa98a3030242), U64(0x12835b0145706fbe), U64(0x243185be4ee4b28c), U64(0x550c7dc3d5ffb4e2), U64(0x72be5d74f27b896f), U64(0x80deb1fe3b1696b1), U64(0x9bdc06a725c71235), U64(0xc19bf174cf692694), U64(0xe49b69c19ef14ad2), U64(0xefbe4786384f25e3), U64(0x0fc19dc68b8cd5b5), U64(0x240ca1cc77ac9c65), U64(0x2de92c6f592b0275), U64(0x4a7484aa6ea6e483), U64(0x5cb0a9dcbd41fbd4), U64(0x76f988da831153b5), U64(0x983e5152ee66dfab), U64(0xa831c66d2db43210), U64(0xb00327c898fb213f), U64(0xbf597fc7beef0ee4), U64(0xc6e00bf33da88fc2), U64(0xd5a79147930aa725), U64(0x06ca6351e003826f), U64(0x142929670a0e6e70), U64(0x27b70a8546d22ffc), U64(0x2e1b21385c26c926), U64(0x4d2c6dfc5ac42aed), U64(0x53380d139d95b3df), U64(0x650a73548baf63de), U64(0x766a0abb3c77b2a8), U64(0x81c2c92e47edaee6), U64(0x92722c851482353b), U64(0xa2bfe8a14cf10364), U64(0xa81a664bbc423001), U64(0xc24b8b70d0f89791), U64(0xc76c51a30654be30), U64(0xd192e819d6ef5218), U64(0xd69906245565a910), U64(0xf40e35855771202a), U64(0x106aa07032bbd1b8), U64(0x19a4c116b8d2d0c8), U64(0x1e376c085141ab53), U64(0x2748774cdf8eeb99), U64(0x34b0bcb5e19b48a8), U64(0x391c0cb3c5c95a63), U64(0x4ed8aa4ae3418acb), U64(0x5b9cca4f7763e373), U64(0x682e6ff3d6b2b8a3), U64(0x748f82ee5defb2fc), U64(0x78a5636f43172f60), U64(0x84c87814a1f0ab72), U64(0x8cc702081a6439ec), U64(0x90befffa23631e28), U64(0xa4506cebde82bde9), U64(0xbef9a3f7b2c67915), U64(0xc67178f2e372532b), U64(0xca273eceea26619c), U64(0xd186b8c721c0c207), U64(0xeada7dd6cde0eb1e), U64(0xf57d4f7fee6ed178), U64(0x06f067aa72176fba), U64(0x0a637dc5a2c898a6), U64(0x113f9804bef90dae), U64(0x1b710b35131c471b), U64(0x28db77f523047d84), U64(0x32caab7b40c72493), U64(0x3c9ebe0a15c9bebc), U64(0x431d67c49c100d4c), U64(0x4cc5d4becb3e42b6), U64(0x597f299cfc657e2a), U64(0x5fcb6fab3ad6faec), U64(0x6c44198c4a475817) }; /* * Transform the message W which consists of 16 64-bit-words */ static uint sha512_transform(struct sha512_context *ctx, const byte *data) { u64 a, b, c, d, e, f, g, h; u64 w[16]; uint t; /* get values from the chaining vars */ a = ctx->h0; b = ctx->h1; c = ctx->h2; d = ctx->h3; e = ctx->h4; f = ctx->h5; g = ctx->h6; h = ctx->h7; for (t = 0; t < 16; t++) w[t] = get_u64(data + t * 8); #define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) #define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) for (t = 0; t < 80 - 16; ) { u64 t1, t2; /* Performance on a AMD Athlon(tm) Dual Core Processor 4050e with gcc 4.3.3 using gcry_md_hash_buffer of each 10000 bytes initialized to 0,1,2,3...255,0,... and 1000 iterations: Not unrolled with macros: 440ms Unrolled with macros: 350ms Unrolled with inline: 330ms */ #ifndef SHA512_UNROLLED t1 = h + sum1(e) + Ch(e, f, g) + k[t] + w[t%16]; w[t%16] += S1(w[(t - 2)%16]) + w[(t - 7)%16] + S0(w[(t - 15)%16]); t2 = sum0(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + t1; d = c; c = b; b = a; a = t1 + t2; t++; #else /* Unrolled */ t1 = h + sum1(e) + Ch(e, f, g) + k[t] + w[0]; w[0] += S1(w[14]) + w[9] + S0(w[1]); t2 = sum0(a) + Maj(a, b, c); d += t1; h = t1 + t2; t1 = g + sum1(d) + Ch(d, e, f) + k[t+1] + w[1]; w[1] += S1(w[15]) + w[10] + S0(w[2]); t2 = sum0(h) + Maj(h, a, b); c += t1; g = t1 + t2; t1 = f + sum1(c) + Ch(c, d, e) + k[t+2] + w[2]; w[2] += S1(w[0]) + w[11] + S0(w[3]); t2 = sum0(g) + Maj(g, h, a); b += t1; f = t1 + t2; t1 = e + sum1(b) + Ch(b, c, d) + k[t+3] + w[3]; w[3] += S1(w[1]) + w[12] + S0(w[4]); t2 = sum0(f) + Maj(f, g, h); a += t1; e = t1 + t2; t1 = d + sum1(a) + Ch(a, b, c) + k[t+4] + w[4]; w[4] += S1(w[2]) + w[13] + S0(w[5]); t2 = sum0(e) + Maj(e, f, g); h += t1; d = t1 + t2; t1 = c + sum1(h) + Ch(h, a, b) + k[t+5] + w[5]; w[5] += S1(w[3]) + w[14] + S0(w[6]); t2 = sum0(d) + Maj(d, e, f); g += t1; c = t1 + t2; t1 = b + sum1(g) + Ch(g, h, a) + k[t+6] + w[6]; w[6] += S1(w[4]) + w[15] + S0(w[7]); t2 = sum0(c) + Maj(c, d, e); f += t1; b = t1 + t2; t1 = a + sum1(f) + Ch(f, g, h) + k[t+7] + w[7]; w[7] += S1(w[5]) + w[0] + S0(w[8]); t2 = sum0(b) + Maj(b, c, d); e += t1; a = t1 + t2; t1 = h + sum1(e) + Ch(e, f, g) + k[t+8] + w[8]; w[8] += S1(w[6]) + w[1] + S0(w[9]); t2 = sum0(a) + Maj(a, b, c); d += t1; h = t1 + t2; t1 = g + sum1(d) + Ch(d, e, f) + k[t+9] + w[9]; w[9] += S1(w[7]) + w[2] + S0(w[10]); t2 = sum0(h) + Maj(h, a, b); c += t1; g = t1 + t2; t1 = f + sum1(c) + Ch(c, d, e) + k[t+10] + w[10]; w[10] += S1(w[8]) + w[3] + S0(w[11]); t2 = sum0(g) + Maj(g, h, a); b += t1; f = t1 + t2; t1 = e + sum1(b) + Ch(b, c, d) + k[t+11] + w[11]; w[11] += S1(w[9]) + w[4] + S0(w[12]); t2 = sum0(f) + Maj(f, g, h); a += t1; e = t1 + t2; t1 = d + sum1(a) + Ch(a, b, c) + k[t+12] + w[12]; w[12] += S1(w[10]) + w[5] + S0(w[13]); t2 = sum0(e) + Maj(e, f, g); h += t1; d = t1 + t2; t1 = c + sum1(h) + Ch(h, a, b) + k[t+13] + w[13]; w[13] += S1(w[11]) + w[6] + S0(w[14]); t2 = sum0(d) + Maj(d, e, f); g += t1; c = t1 + t2; t1 = b + sum1(g) + Ch(g, h, a) + k[t+14] + w[14]; w[14] += S1(w[12]) + w[7] + S0(w[15]); t2 = sum0(c) + Maj(c, d, e); f += t1; b = t1 + t2; t1 = a + sum1(f) + Ch(f, g, h) + k[t+15] + w[15]; w[15] += S1(w[13]) + w[8] + S0(w[0]); t2 = sum0(b) + Maj(b, c, d); e += t1; a = t1 + t2; t += 16; #endif } for (; t < 80; ) { u64 t1, t2; #ifndef SHA512_UNROLLED t1 = h + sum1(e) + Ch(e, f, g) + k[t] + w[t%16]; t2 = sum0(a) + Maj(a, b, c); h = g; g = f; f = e; e = d + t1; d = c; c = b; b = a; a = t1 + t2; t++; #else /* Unrolled */ t1 = h + sum1(e) + Ch(e, f, g) + k[t] + w[0]; t2 = sum0(a) + Maj(a, b, c); d += t1; h = t1 + t2; t1 = g + sum1(d) + Ch(d, e, f) + k[t+1] + w[1]; t2 = sum0(h) + Maj(h, a, b); c += t1; g = t1 + t2; t1 = f + sum1(c) + Ch(c, d, e) + k[t+2] + w[2]; t2 = sum0(g) + Maj(g, h, a); b += t1; f = t1 + t2; t1 = e + sum1(b) + Ch(b, c, d) + k[t+3] + w[3]; t2 = sum0(f) + Maj(f, g, h); a += t1; e = t1 + t2; t1 = d + sum1(a) + Ch(a, b, c) + k[t+4] + w[4]; t2 = sum0(e) + Maj(e, f, g); h += t1; d = t1 + t2; t1 = c + sum1(h) + Ch(h, a, b) + k[t+5] + w[5]; t2 = sum0(d) + Maj(d, e, f); g += t1; c = t1 + t2; t1 = b + sum1(g) + Ch(g, h, a) + k[t+6] + w[6]; t2 = sum0(c) + Maj(c, d, e); f += t1; b = t1 + t2; t1 = a + sum1(f) + Ch(f, g, h) + k[t+7] + w[7]; t2 = sum0(b) + Maj(b, c, d); e += t1; a = t1 + t2; t1 = h + sum1(e) + Ch(e, f, g) + k[t+8] + w[8]; t2 = sum0(a) + Maj(a, b, c); d += t1; h = t1 + t2; t1 = g + sum1(d) + Ch(d, e, f) + k[t+9] + w[9]; t2 = sum0(h) + Maj(h, a, b); c += t1; g = t1 + t2; t1 = f + sum1(c) + Ch(c, d, e) + k[t+10] + w[10]; t2 = sum0(g) + Maj(g, h, a); b += t1; f = t1 + t2; t1 = e + sum1(b) + Ch(b, c, d) + k[t+11] + w[11]; t2 = sum0(f) + Maj(f, g, h); a += t1; e = t1 + t2; t1 = d + sum1(a) + Ch(a, b, c) + k[t+12] + w[12]; t2 = sum0(e) + Maj(e, f, g); h += t1; d = t1 + t2; t1 = c + sum1(h) + Ch(h, a, b) + k[t+13] + w[13]; t2 = sum0(d) + Maj(d, e, f); g += t1; c = t1 + t2; t1 = b + sum1(g) + Ch(g, h, a) + k[t+14] + w[14]; t2 = sum0(c) + Maj(c, d, e); f += t1; b = t1 + t2; t1 = a + sum1(f) + Ch(f, g, h) + k[t+15] + w[15]; t2 = sum0(b) + Maj(b, c, d); e += t1; a = t1 + t2; t += 16; #endif } /* Update chaining vars. */ ctx->h0 += a; ctx->h1 += b; ctx->h2 += c; ctx->h3 += d; ctx->h4 += e; ctx->h5 += f; ctx->h6 += g; ctx->h7 += h; return /* burn_stack */ (8 + 16) * sizeof(u64) + sizeof(u32) + 3 * sizeof(void*); } void sha512_update(struct hash_context *CTX, const byte *buf, uint len) { struct sha512_context *ctx = (void *) CTX; if (ctx->count) { /* Fill rest of internal buffer */ for (; len && ctx->count < SHA512_BLOCK_SIZE; len--) ctx->buf[ctx->count++] = *buf++; if (ctx->count < SHA512_BLOCK_SIZE) return; /* Process data from internal buffer */ sha512_transform(ctx, ctx->buf); ctx->nblocks++; ctx->count = 0; } if (!len) return; /* Process data from input buffer */ while (len >= SHA512_BLOCK_SIZE) { sha512_transform(ctx, buf); ctx->nblocks++; buf += SHA512_BLOCK_SIZE; len -= SHA512_BLOCK_SIZE; } /* Copy remaining data to internal buffer */ memcpy(ctx->buf, buf, len); ctx->count = len; } /* * The routine final terminates the computation and returns the digest. The * handle is prepared for a new cycle, but adding bytes to the handle will the * destroy the returned buffer. * * Returns: 64 bytes representing the digest. When used for sha384, we take the * first 48 of those bytes. */ byte * sha512_final(struct hash_context *CTX) { struct sha512_context *ctx = (void *) CTX; u64 t, th, msb, lsb; sha512_update(CTX, NULL, 0); /* flush */ t = ctx->nblocks; th = 0; /* multiply by 128 to make a byte count */ lsb = t << 7; msb = (th << 7) | (t >> 57); /* add the count */ t = lsb; if ((lsb += ctx->count) < t) msb++; /* multiply by 8 to make a bit count */ t = lsb; lsb <<= 3; msb <<= 3; msb |= t >> 61; if (ctx->count < 112) { /* enough room */ ctx->buf[ctx->count++] = 0x80; /* pad */ while(ctx->count < 112) ctx->buf[ctx->count++] = 0; /* pad */ } else { /* need one extra block */ ctx->buf[ctx->count++] = 0x80; /* pad character */ while(ctx->count < 128) ctx->buf[ctx->count++] = 0; sha512_update(CTX, NULL, 0); /* flush */ memset(ctx->buf, 0, 112); /* fill next block with zeroes */ } /* append the 128 bit count */ put_u64(ctx->buf + 112, msb); put_u64(ctx->buf + 120, lsb); sha512_transform(ctx, ctx->buf); byte *p = ctx->buf; #define X(a) do { put_u64(p, ctx->h##a); p += 8; } while(0) X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); #undef X return ctx->buf; } bird-2.0.8/lib/sha256.h0000664000175000017500000000200114025744326013304 0ustar feelafeela/* * BIRD Library -- SHA-256 and SHA-224 Hash Functions * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libgcrypt-1.6.0, which is * (c) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_SHA256_H_ #define _BIRD_SHA256_H_ #include "nest/bird.h" #define SHA224_SIZE 28 #define SHA224_HEX_SIZE 57 #define SHA224_BLOCK_SIZE 64 #define SHA256_SIZE 32 #define SHA256_HEX_SIZE 65 #define SHA256_BLOCK_SIZE 64 struct hash_context; struct sha256_context { u32 h0, h1, h2, h3, h4, h5, h6, h7; byte buf[SHA256_BLOCK_SIZE]; uint nblocks; uint count; }; #define sha224_context sha256_context void sha256_init(struct hash_context *ctx); void sha224_init(struct hash_context *ctx); void sha256_update(struct hash_context *ctx, const byte *buf, uint len); #define sha224_update sha256_update byte *sha256_final(struct hash_context *ctx); #define sha224_final sha256_final #endif /* _BIRD_SHA256_H_ */ bird-2.0.8/lib/sha256.c0000664000175000017500000001651514025744326013316 0ustar feelafeela/* * BIRD Library -- SHA-256 and SHA-224 Hash Functions * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libgcrypt-1.6.0, which is * (c) 2003, 2006, 2008, 2009 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/sha256.h" #include "lib/unaligned.h" // #define SHA256_UNROLLED void sha256_init(struct hash_context *CTX) { struct sha256_context *ctx = (void *) CTX; ctx->h0 = 0x6a09e667; ctx->h1 = 0xbb67ae85; ctx->h2 = 0x3c6ef372; ctx->h3 = 0xa54ff53a; ctx->h4 = 0x510e527f; ctx->h5 = 0x9b05688c; ctx->h6 = 0x1f83d9ab; ctx->h7 = 0x5be0cd19; ctx->nblocks = 0; ctx->count = 0; } void sha224_init(struct hash_context *CTX) { struct sha224_context *ctx = (void *) CTX; ctx->h0 = 0xc1059ed8; ctx->h1 = 0x367cd507; ctx->h2 = 0x3070dd17; ctx->h3 = 0xf70e5939; ctx->h4 = 0xffc00b31; ctx->h5 = 0x68581511; ctx->h6 = 0x64f98fa7; ctx->h7 = 0xbefa4fa4; ctx->nblocks = 0; ctx->count = 0; } /* (4.2) same as SHA-1's F1. */ static inline u32 f1(u32 x, u32 y, u32 z) { return (z ^ (x & (y ^ z))); } /* (4.3) same as SHA-1's F3 */ static inline u32 f3(u32 x, u32 y, u32 z) { return ((x & y) | (z & (x|y))); } /* Bitwise rotation of an uint to the right */ static inline u32 ror(u32 x, int n) { return ((x >> (n&(32-1))) | (x << ((32-n)&(32-1)))); } /* (4.4) */ static inline u32 sum0(u32 x) { return (ror(x, 2) ^ ror(x, 13) ^ ror(x, 22)); } /* (4.5) */ static inline u32 sum1(u32 x) { return (ror(x, 6) ^ ror(x, 11) ^ ror(x, 25)); } /* Transform the message X which consists of 16 32-bit-words. See FIPS 180-2 for details. */ #define S0(x) (ror((x), 7) ^ ror((x), 18) ^ ((x) >> 3)) /* (4.6) */ #define S1(x) (ror((x), 17) ^ ror((x), 19) ^ ((x) >> 10)) /* (4.7) */ #define R(a,b,c,d,e,f,g,h,k,w) \ do \ { \ t1 = (h) + sum1((e)) + f1((e),(f),(g)) + (k) + (w); \ t2 = sum0((a)) + f3((a),(b),(c)); \ h = g; \ g = f; \ f = e; \ e = d + t1; \ d = c; \ c = b; \ b = a; \ a = t1 + t2; \ } while (0) /* The SHA-256 core: Transform the message X which consists of 16 32-bit-words. See FIPS 180-2 for details. */ static uint sha256_transform(struct sha256_context *ctx, const byte *data) { static const u32 K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; u32 a,b,c,d,e,f,g,h,t1,t2; u32 w[64]; int i; a = ctx->h0; b = ctx->h1; c = ctx->h2; d = ctx->h3; e = ctx->h4; f = ctx->h5; g = ctx->h6; h = ctx->h7; for (i = 0; i < 16; i++) w[i] = get_u32(data + i * 4); for (; i < 64; i++) w[i] = S1(w[i-2]) + w[i-7] + S0(w[i-15]) + w[i-16]; for (i = 0; i < 64;) { #ifndef SHA256_UNROLLED R(a,b,c,d,e,f,g,h,K[i],w[i]); i++; #else /* Unrolled */ t1 = h + sum1(e) + f1(e, f, g) + K[i] + w[i]; t2 = sum0(a) + f3(a, b, c); d += t1; h = t1 + t2; t1 = g + sum1(d) + f1(d, e, f) + K[i+1] + w[i+1]; t2 = sum0(h) + f3(h, a, b); c += t1; g = t1 + t2; t1 = f + sum1(c) + f1(c, d, e) + K[i+2] + w[i+2]; t2 = sum0(g) + f3(g, h, a); b += t1; f = t1 + t2; t1 = e + sum1(b) + f1(b, c, d) + K[i+3] + w[i+3]; t2 = sum0(f) + f3(f, g, h); a += t1; e = t1 + t2; t1 = d + sum1(a) + f1(a, b, c) + K[i+4] + w[i+4]; t2 = sum0(e) + f3(e, f, g); h += t1; d = t1 + t2; t1 = c + sum1(h) + f1(h, a, b) + K[i+5] + w[i+5]; t2 = sum0(d) + f3(d, e, f); g += t1; c = t1 + t2; t1 = b + sum1(g) + f1(g, h, a) + K[i+6] + w[i+6]; t2 = sum0(c) + f3(c, d, e); f += t1; b = t1 + t2; t1 = a + sum1(f) + f1(f, g, h) + K[i+7] + w[i+7]; t2 = sum0(b) + f3(b, c, d); e += t1; a = t1 + t2; i += 8; #endif } ctx->h0 += a; ctx->h1 += b; ctx->h2 += c; ctx->h3 += d; ctx->h4 += e; ctx->h5 += f; ctx->h6 += g; ctx->h7 += h; return /*burn_stack*/ 74*4+32; } #undef S0 #undef S1 #undef R /* Common function to write a chunk of data to the transform function of a hash algorithm. Note that the use of the term "block" does not imply a fixed size block. Note that we explicitly allow to use this function after the context has been finalized; the result does not have any meaning but writing after finalize is sometimes helpful to mitigate timing attacks. */ void sha256_update(struct hash_context *CTX, const byte *buf, uint len) { struct sha256_context *ctx = (void *) CTX; if (ctx->count) { /* Fill rest of internal buffer */ for (; len && ctx->count < SHA256_BLOCK_SIZE; len--) ctx->buf[ctx->count++] = *buf++; if (ctx->count < SHA256_BLOCK_SIZE) return; /* Process data from internal buffer */ sha256_transform(ctx, ctx->buf); ctx->nblocks++; ctx->count = 0; } if (!len) return; /* Process data from input buffer */ while (len >= SHA256_BLOCK_SIZE) { sha256_transform(ctx, buf); ctx->nblocks++; buf += SHA256_BLOCK_SIZE; len -= SHA256_BLOCK_SIZE; } /* Copy remaining data to internal buffer */ memcpy(ctx->buf, buf, len); ctx->count = len; } /* * The routine finally terminates the computation and returns the digest. The * handle is prepared for a new cycle, but adding bytes to the handle will the * destroy the returned buffer. * * Returns: 32 bytes with the message the digest. 28 bytes for SHA-224. */ byte * sha256_final(struct hash_context *CTX) { struct sha256_context *ctx = (void *) CTX; u32 t, th, msb, lsb; sha256_update(CTX, NULL, 0); /* flush */ t = ctx->nblocks; th = 0; /* multiply by 64 to make a byte count */ lsb = t << 6; msb = (th << 6) | (t >> 26); /* add the count */ t = lsb; if ((lsb += ctx->count) < t) msb++; /* multiply by 8 to make a bit count */ t = lsb; lsb <<= 3; msb <<= 3; msb |= t >> 29; if (ctx->count < 56) { /* enough room */ ctx->buf[ctx->count++] = 0x80; /* pad */ while (ctx->count < 56) ctx->buf[ctx->count++] = 0; /* pad */ } else { /* need one extra block */ ctx->buf[ctx->count++] = 0x80; /* pad character */ while (ctx->count < 64) ctx->buf[ctx->count++] = 0; sha256_update(CTX, NULL, 0); /* flush */; memset(ctx->buf, 0, 56 ); /* fill next block with zeroes */ } /* append the 64 bit count */ put_u32(ctx->buf + 56, msb); put_u32(ctx->buf + 60, lsb); sha256_transform(ctx, ctx->buf); byte *p = ctx->buf; #define X(a) do { put_u32(p, ctx->h##a); p += 4; } while(0) X(0); X(1); X(2); X(3); X(4); X(5); X(6); X(7); #undef X return ctx->buf; } bird-2.0.8/lib/sha1.h0000664000175000017500000000372314025744326013144 0ustar feelafeela/* * BIRD Library -- SHA-1 Hash Function (FIPS 180-1, RFC 3174) * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libucw-6.4 * (c) 2008--2009 Martin Mares * * Based on the code from libgcrypt-1.2.3, which is * (c) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_SHA1_H_ #define _BIRD_SHA1_H_ #include "nest/bird.h" #define SHA1_SIZE 20 /* Size of the SHA1 hash in its binary representation */ #define SHA1_HEX_SIZE 41 /* Buffer length for a string containing SHA1 in hexadecimal format. */ #define SHA1_BLOCK_SIZE 64 /* SHA1 splits input to blocks of this size. */ /* * Internal SHA1 state. * You should use it just as an opaque handle only. */ struct hash_context; struct sha1_context { u32 h0, h1, h2, h3, h4; byte buf[SHA1_BLOCK_SIZE]; uint nblocks; uint count; }; void sha1_init(struct hash_context *ctx); /* Initialize new algorithm run in the @ctx context. **/ /* * Push another @len bytes of data pointed to by @buf onto the SHA1 hash * currently in @ctx. You can call this any times you want on the same hash (and * you do not need to reinitialize it by @sha1_init()). It has the same effect * as concatenating all the data together and passing them at once. */ void sha1_update(struct hash_context *ctx, const byte *buf, uint len); /* * No more @sha1_update() calls will be done. This terminates the hash and * returns a pointer to it. * * Note that the pointer points into data in the @ctx context. If it ceases to * exist, the pointer becomes invalid. */ byte *sha1_final(struct hash_context *ctx); /* * A convenience one-shot function for SHA1 hash. It is equivalent to this * snippet of code: * * sha1_context ctx; * sha1_init(&ctx); * sha1_update(&ctx, buffer, length); * memcpy(outbuf, sha1_final(&ctx), SHA1_SIZE); */ void sha1_hash_buffer(byte *outbuf, const byte *buffer, uint length); #endif /* _BIRD_SHA1_H_ */ bird-2.0.8/lib/sha1.c0000664000175000017500000001603714025744326013141 0ustar feelafeela/* * BIRD Library -- SHA-1 Hash Function (FIPS 180-1, RFC 3174) * * (c) 2015 CZ.NIC z.s.p.o. * * Based on the code from libucw-6.4 * (c) 2008--2009 Martin Mares * * Based on the code from libgcrypt-1.2.3, which is * (c) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/sha1.h" #include "lib/unaligned.h" void sha1_init(struct hash_context *CTX) { struct sha1_context *ctx = (void *) CTX; ctx->h0 = 0x67452301; ctx->h1 = 0xefcdab89; ctx->h2 = 0x98badcfe; ctx->h3 = 0x10325476; ctx->h4 = 0xc3d2e1f0; ctx->nblocks = 0; ctx->count = 0; } /* * Transform the message X which consists of 16 32-bit-words */ static void sha1_transform(struct sha1_context *ctx, const byte *data) { u32 a,b,c,d,e,tm; u32 x[16]; /* Get values from the chaining vars. */ a = ctx->h0; b = ctx->h1; c = ctx->h2; d = ctx->h3; e = ctx->h4; #ifdef CPU_BIG_ENDIAN memcpy(x, data, 64); #else int i; for (i = 0; i < 16; i++) x[i] = get_u32(data+4*i); #endif #define K1 0x5A827999L #define K2 0x6ED9EBA1L #define K3 0x8F1BBCDCL #define K4 0xCA62C1D6L #define F1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) #define F2(x,y,z) ( x ^ y ^ z ) #define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) #define F4(x,y,z) ( x ^ y ^ z ) #define M(i) (tm = x[i&0x0f] ^ x[(i-14)&0x0f] ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f], (x[i&0x0f] = ROL(tm, 1))) /* Bitwise rotation of an unsigned int to the left **/ #define ROL(x, bits) (((x) << (bits)) | ((uint)(x) >> (sizeof(uint)*8 - (bits)))) #define R(a, b, c, d, e, f, k, m) \ do \ { \ e += ROL(a, 5) + f(b, c, d) + k + m; \ b = ROL(b, 30); \ } while(0) R( a, b, c, d, e, F1, K1, x[ 0] ); R( e, a, b, c, d, F1, K1, x[ 1] ); R( d, e, a, b, c, F1, K1, x[ 2] ); R( c, d, e, a, b, F1, K1, x[ 3] ); R( b, c, d, e, a, F1, K1, x[ 4] ); R( a, b, c, d, e, F1, K1, x[ 5] ); R( e, a, b, c, d, F1, K1, x[ 6] ); R( d, e, a, b, c, F1, K1, x[ 7] ); R( c, d, e, a, b, F1, K1, x[ 8] ); R( b, c, d, e, a, F1, K1, x[ 9] ); R( a, b, c, d, e, F1, K1, x[10] ); R( e, a, b, c, d, F1, K1, x[11] ); R( d, e, a, b, c, F1, K1, x[12] ); R( c, d, e, a, b, F1, K1, x[13] ); R( b, c, d, e, a, F1, K1, x[14] ); R( a, b, c, d, e, F1, K1, x[15] ); R( e, a, b, c, d, F1, K1, M(16) ); R( d, e, a, b, c, F1, K1, M(17) ); R( c, d, e, a, b, F1, K1, M(18) ); R( b, c, d, e, a, F1, K1, M(19) ); R( a, b, c, d, e, F2, K2, M(20) ); R( e, a, b, c, d, F2, K2, M(21) ); R( d, e, a, b, c, F2, K2, M(22) ); R( c, d, e, a, b, F2, K2, M(23) ); R( b, c, d, e, a, F2, K2, M(24) ); R( a, b, c, d, e, F2, K2, M(25) ); R( e, a, b, c, d, F2, K2, M(26) ); R( d, e, a, b, c, F2, K2, M(27) ); R( c, d, e, a, b, F2, K2, M(28) ); R( b, c, d, e, a, F2, K2, M(29) ); R( a, b, c, d, e, F2, K2, M(30) ); R( e, a, b, c, d, F2, K2, M(31) ); R( d, e, a, b, c, F2, K2, M(32) ); R( c, d, e, a, b, F2, K2, M(33) ); R( b, c, d, e, a, F2, K2, M(34) ); R( a, b, c, d, e, F2, K2, M(35) ); R( e, a, b, c, d, F2, K2, M(36) ); R( d, e, a, b, c, F2, K2, M(37) ); R( c, d, e, a, b, F2, K2, M(38) ); R( b, c, d, e, a, F2, K2, M(39) ); R( a, b, c, d, e, F3, K3, M(40) ); R( e, a, b, c, d, F3, K3, M(41) ); R( d, e, a, b, c, F3, K3, M(42) ); R( c, d, e, a, b, F3, K3, M(43) ); R( b, c, d, e, a, F3, K3, M(44) ); R( a, b, c, d, e, F3, K3, M(45) ); R( e, a, b, c, d, F3, K3, M(46) ); R( d, e, a, b, c, F3, K3, M(47) ); R( c, d, e, a, b, F3, K3, M(48) ); R( b, c, d, e, a, F3, K3, M(49) ); R( a, b, c, d, e, F3, K3, M(50) ); R( e, a, b, c, d, F3, K3, M(51) ); R( d, e, a, b, c, F3, K3, M(52) ); R( c, d, e, a, b, F3, K3, M(53) ); R( b, c, d, e, a, F3, K3, M(54) ); R( a, b, c, d, e, F3, K3, M(55) ); R( e, a, b, c, d, F3, K3, M(56) ); R( d, e, a, b, c, F3, K3, M(57) ); R( c, d, e, a, b, F3, K3, M(58) ); R( b, c, d, e, a, F3, K3, M(59) ); R( a, b, c, d, e, F4, K4, M(60) ); R( e, a, b, c, d, F4, K4, M(61) ); R( d, e, a, b, c, F4, K4, M(62) ); R( c, d, e, a, b, F4, K4, M(63) ); R( b, c, d, e, a, F4, K4, M(64) ); R( a, b, c, d, e, F4, K4, M(65) ); R( e, a, b, c, d, F4, K4, M(66) ); R( d, e, a, b, c, F4, K4, M(67) ); R( c, d, e, a, b, F4, K4, M(68) ); R( b, c, d, e, a, F4, K4, M(69) ); R( a, b, c, d, e, F4, K4, M(70) ); R( e, a, b, c, d, F4, K4, M(71) ); R( d, e, a, b, c, F4, K4, M(72) ); R( c, d, e, a, b, F4, K4, M(73) ); R( b, c, d, e, a, F4, K4, M(74) ); R( a, b, c, d, e, F4, K4, M(75) ); R( e, a, b, c, d, F4, K4, M(76) ); R( d, e, a, b, c, F4, K4, M(77) ); R( c, d, e, a, b, F4, K4, M(78) ); R( b, c, d, e, a, F4, K4, M(79) ); /* Update chaining vars. */ ctx->h0 += a; ctx->h1 += b; ctx->h2 += c; ctx->h3 += d; ctx->h4 += e; } /* * Update the message digest with the contents of BUF with length LEN. */ void sha1_update(struct hash_context *CTX, const byte *buf, uint len) { struct sha1_context *ctx = (void *) CTX; if (ctx->count) { /* Fill rest of internal buffer */ for (; len && ctx->count < SHA1_BLOCK_SIZE; len--) ctx->buf[ctx->count++] = *buf++; if (ctx->count < SHA1_BLOCK_SIZE) return; /* Process data from internal buffer */ sha1_transform(ctx, ctx->buf); ctx->nblocks++; ctx->count = 0; } if (!len) return; /* Process data from input buffer */ while (len >= SHA1_BLOCK_SIZE) { sha1_transform(ctx, buf); ctx->nblocks++; buf += SHA1_BLOCK_SIZE; len -= SHA1_BLOCK_SIZE; } /* Copy remaining data to internal buffer */ memcpy(ctx->buf, buf, len); ctx->count = len; } /* * The routine final terminates the computation and returns the digest. The * handle is prepared for a new cycle, but adding bytes to the handle will the * destroy the returned buffer. * * Returns: 20 bytes representing the digest. */ byte * sha1_final(struct hash_context *CTX) { struct sha1_context *ctx = (void *) CTX; u32 t, msb, lsb; sha1_update(CTX, NULL, 0); /* flush */ t = ctx->nblocks; /* multiply by 64 to make a byte count */ lsb = t << 6; msb = t >> 26; /* add the count */ t = lsb; if ((lsb += ctx->count) < t) msb++; /* multiply by 8 to make a bit count */ t = lsb; lsb <<= 3; msb <<= 3; msb |= t >> 29; if (ctx->count < 56) { /* enough room */ ctx->buf[ctx->count++] = 0x80; /* pad */ while (ctx->count < 56) ctx->buf[ctx->count++] = 0; /* pad */ } else { /* need one extra block */ ctx->buf[ctx->count++] = 0x80; /* pad character */ while (ctx->count < 64) ctx->buf[ctx->count++] = 0; sha1_update(CTX, NULL, 0); /* flush */ memset(ctx->buf, 0, 56); /* fill next block with zeroes */ } /* append the 64 bit count */ ctx->buf[56] = msb >> 24; ctx->buf[57] = msb >> 16; ctx->buf[58] = msb >> 8; ctx->buf[59] = msb; ctx->buf[60] = lsb >> 24; ctx->buf[61] = lsb >> 16; ctx->buf[62] = lsb >> 8; ctx->buf[63] = lsb; sha1_transform(ctx, ctx->buf); byte *p = ctx->buf; #define X(a) do { put_u32(p, ctx->h##a); p += 4; } while(0) X(0); X(1); X(2); X(3); X(4); #undef X return ctx->buf; } bird-2.0.8/lib/resource.sgml0000664000175000017500000000303314025744326014644 0ustar feelafeela Resources Introduction

Most large software projects implemented in classical procedural programming languages usually end up with lots of code taking care of resource allocation and deallocation. Bugs in such code are often very difficult to find, because they cause only `resource leakage', that is keeping a lot of memory and other resources which nobody references to.

We've tried to solve this problem by employing a resource tracking system which keeps track of all the resources allocated by all the modules of BIRD, deallocates everything automatically when a module shuts down and it is able to print out the list of resources and the corresponding modules they are allocated by.

Each allocated resource (from now we'll speak about allocated resources only) is represented by a structure starting with a standard header (struct There exist the following types of resources: bird-2.0.8/lib/resource.h0000664000175000017500000000701214025744326014132 0ustar feelafeela/* * BIRD Resource Manager * * (c) 1998--1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_RESOURCE_H_ #define _BIRD_RESOURCE_H_ #include "lib/lists.h" /* Resource */ typedef struct resource { node n; /* Inside resource pool */ struct resclass *class; /* Resource class */ } resource; /* Resource class */ struct resclass { char *name; /* Resource class name */ unsigned size; /* Standard size of single resource */ void (*free)(resource *); /* Freeing function */ void (*dump)(resource *); /* Dump to debug output */ resource *(*lookup)(resource *, unsigned long); /* Look up address (only for debugging) */ size_t (*memsize)(resource *); /* Return size of memory used by the resource, may be NULL */ }; /* Estimate of system allocator overhead per item, for memory consumtion stats */ #define ALLOC_OVERHEAD 8 /* Generic resource manipulation */ typedef struct pool pool; void resource_init(void); pool *rp_new(pool *, const char *); /* Create new pool */ void rfree(void *); /* Free single resource */ void rdump(void *); /* Dump to debug output */ size_t rmemsize(void *res); /* Return size of memory used by the resource */ void rlookup(unsigned long); /* Look up address (only for debugging) */ void rmove(void *, pool *); /* Move to a different pool */ void *ralloc(pool *, struct resclass *); extern pool root_pool; /* Normal memory blocks */ void *mb_alloc(pool *, unsigned size); void *mb_allocz(pool *, unsigned size); void *mb_realloc(void *m, unsigned size); void mb_free(void *); /* Memory pools with linear allocation */ typedef struct linpool linpool; typedef struct lp_state { void *current, *large; byte *ptr; } lp_state; linpool *lp_new(pool *, unsigned blk); void *lp_alloc(linpool *, unsigned size); /* Aligned */ void *lp_allocu(linpool *, unsigned size); /* Unaligned */ void *lp_allocz(linpool *, unsigned size); /* With clear */ void lp_flush(linpool *); /* Free everything, but leave linpool */ void lp_save(linpool *m, lp_state *p); /* Save state */ void lp_restore(linpool *m, lp_state *p); /* Restore state */ extern const int lp_chunk_size; #define LP_GAS 1024 #define LP_GOOD_SIZE(x) (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size) #define lp_new_default(p) lp_new(p, LP_GOOD_SIZE(LP_GAS*4)) /* Slabs */ typedef struct slab slab; slab *sl_new(pool *, unsigned size); void *sl_alloc(slab *); void *sl_allocz(slab *); void sl_free(slab *, void *); /* * Low-level memory allocation functions, please don't use * outside resource manager and possibly sysdep code. */ void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_size); #ifdef HAVE_LIBDMALLOC /* * The standard dmalloc macros tend to produce lots of namespace * conflicts and we use only xmalloc, xrealloc and xfree, so we * can define the stubs ourselves. */ #define DMALLOC_DISABLE #include #define xmalloc(size) \ dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 1) #define xrealloc(ptr, size) \ dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 1) #define xfree(ptr) \ dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE) #else /* * Unfortunately, several libraries we might want to link to define * their own xmalloc and we don't want to interfere with them, hence * the renaming. */ #define xmalloc bird_xmalloc #define xrealloc bird_xrealloc void *xmalloc(unsigned); void *xrealloc(void *, unsigned); #define xfree(x) free(x) #endif #endif bird-2.0.8/lib/resource.c0000664000175000017500000002074014025744326014130 0ustar feelafeela/* * BIRD Resource Manager * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include #include #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" /** * DOC: Resource pools * * Resource pools (&pool) are just containers holding a list of * other resources. Freeing a pool causes all the listed resources * to be freed as well. Each existing &resource is linked to some pool * except for a root pool which isn't linked anywhere, so all the * resources form a tree structure with internal nodes corresponding * to pools and leaves being the other resources. * * Example: Almost all modules of BIRD have their private pool which * is freed upon shutdown of the module. */ struct pool { resource r; list inside; const char *name; }; static void pool_dump(resource *); static void pool_free(resource *); static resource *pool_lookup(resource *, unsigned long); static size_t pool_memsize(resource *P); static struct resclass pool_class = { "Pool", sizeof(pool), pool_free, pool_dump, pool_lookup, pool_memsize }; pool root_pool; static int indent; /** * rp_new - create a resource pool * @p: parent pool * @name: pool name (to be included in debugging dumps) * * rp_new() creates a new resource pool inside the specified * parent pool. */ pool * rp_new(pool *p, const char *name) { pool *z = ralloc(p, &pool_class); z->name = name; init_list(&z->inside); return z; } static void pool_free(resource *P) { pool *p = (pool *) P; resource *r, *rr; r = HEAD(p->inside); while (rr = (resource *) r->n.next) { r->class->free(r); xfree(r); r = rr; } } static void pool_dump(resource *P) { pool *p = (pool *) P; resource *r; debug("%s\n", p->name); indent += 3; WALK_LIST(r, p->inside) rdump(r); indent -= 3; } static size_t pool_memsize(resource *P) { pool *p = (pool *) P; resource *r; size_t sum = sizeof(pool) + ALLOC_OVERHEAD; WALK_LIST(r, p->inside) sum += rmemsize(r); return sum; } static resource * pool_lookup(resource *P, unsigned long a) { pool *p = (pool *) P; resource *r, *q; WALK_LIST(r, p->inside) if (r->class->lookup && (q = r->class->lookup(r, a))) return q; return NULL; } /** * rmove - move a resource * @res: resource * @p: pool to move the resource to * * rmove() moves a resource from one pool to another. */ void rmove(void *res, pool *p) { resource *r = res; if (r) { if (r->n.next) rem_node(&r->n); add_tail(&p->inside, &r->n); } } /** * rfree - free a resource * @res: resource * * rfree() frees the given resource and all information associated * with it. In case it's a resource pool, it also frees all the objects * living inside the pool. * * It works by calling a class-specific freeing function. */ void rfree(void *res) { resource *r = res; if (!r) return; if (r->n.next) rem_node(&r->n); r->class->free(r); r->class = NULL; xfree(r); } /** * rdump - dump a resource * @res: resource * * This function prints out all available information about the given * resource to the debugging output. * * It works by calling a class-specific dump function. */ void rdump(void *res) { char x[16]; resource *r = res; bsprintf(x, "%%%ds%%p ", indent); debug(x, "", r); if (r) { debug("%s ", r->class->name); r->class->dump(r); } else debug("NULL\n"); } size_t rmemsize(void *res) { resource *r = res; if (!r) return 0; if (!r->class->memsize) return r->class->size + ALLOC_OVERHEAD; return r->class->memsize(r); } /** * ralloc - create a resource * @p: pool to create the resource in * @c: class of the new resource * * This function is called by the resource classes to create a new * resource of the specified class and link it to the given pool. * Allocated memory is zeroed. Size of the resource structure is taken * from the @size field of the &resclass. */ void * ralloc(pool *p, struct resclass *c) { resource *r = xmalloc(c->size); bzero(r, c->size); r->class = c; if (p) add_tail(&p->inside, &r->n); return r; } /** * rlookup - look up a memory location * @a: memory address * * This function examines all existing resources to see whether * the address @a is inside any resource. It's used for debugging * purposes only. * * It works by calling a class-specific lookup function for each * resource. */ void rlookup(unsigned long a) { resource *r; debug("Looking up %08lx\n", a); if (r = pool_lookup(&root_pool.r, a)) rdump(r); else debug("Not found.\n"); } /** * resource_init - initialize the resource manager * * This function is called during BIRD startup. It initializes * all data structures of the resource manager and creates the * root pool. */ void resource_init(void) { root_pool.r.class = &pool_class; root_pool.name = "Root"; init_list(&root_pool.inside); } /** * DOC: Memory blocks * * Memory blocks are pieces of contiguous allocated memory. * They are a bit non-standard since they are represented not by a pointer * to &resource, but by a void pointer to the start of data of the * memory block. All memory block functions know how to locate the header * given the data pointer. * * Example: All "unique" data structures such as hash tables are allocated * as memory blocks. */ struct mblock { resource r; unsigned size; uintptr_t data_align[0]; byte data[0]; }; static void mbl_free(resource *r UNUSED) { } static void mbl_debug(resource *r) { struct mblock *m = (struct mblock *) r; debug("(size=%d)\n", m->size); } static resource * mbl_lookup(resource *r, unsigned long a) { struct mblock *m = (struct mblock *) r; if ((unsigned long) m->data <= a && (unsigned long) m->data + m->size > a) return r; return NULL; } static size_t mbl_memsize(resource *r) { struct mblock *m = (struct mblock *) r; return ALLOC_OVERHEAD + sizeof(struct mblock) + m->size; } static struct resclass mb_class = { "Memory", 0, mbl_free, mbl_debug, mbl_lookup, mbl_memsize }; /** * mb_alloc - allocate a memory block * @p: pool * @size: size of the block * * mb_alloc() allocates memory of a given size and creates * a memory block resource representing this memory chunk * in the pool @p. * * Please note that mb_alloc() returns a pointer to the memory * chunk, not to the resource, hence you have to free it using * mb_free(), not rfree(). */ void * mb_alloc(pool *p, unsigned size) { struct mblock *b = xmalloc(sizeof(struct mblock) + size); b->r.class = &mb_class; b->r.n = (node) {}; add_tail(&p->inside, &b->r.n); b->size = size; return b->data; } /** * mb_allocz - allocate and clear a memory block * @p: pool * @size: size of the block * * mb_allocz() allocates memory of a given size, initializes it to * zeroes and creates a memory block resource representing this memory * chunk in the pool @p. * * Please note that mb_allocz() returns a pointer to the memory * chunk, not to the resource, hence you have to free it using * mb_free(), not rfree(). */ void * mb_allocz(pool *p, unsigned size) { void *x = mb_alloc(p, size); bzero(x, size); return x; } /** * mb_realloc - reallocate a memory block * @m: memory block * @size: new size of the block * * mb_realloc() changes the size of the memory block @m to a given size. * The contents will be unchanged to the minimum of the old and new sizes; * newly allocated memory will be uninitialized. Contrary to realloc() * behavior, @m must be non-NULL, because the resource pool is inherited * from it. * * Like mb_alloc(), mb_realloc() also returns a pointer to the memory * chunk, not to the resource, hence you have to free it using * mb_free(), not rfree(). */ void * mb_realloc(void *m, unsigned size) { struct mblock *b = SKIP_BACK(struct mblock, data, m); b = xrealloc(b, sizeof(struct mblock) + size); update_node(&b->r.n); b->size = size; return b->data; } /** * mb_free - free a memory block * @m: memory block * * mb_free() frees all memory associated with the block @m. */ void mb_free(void *m) { if (!m) return; struct mblock *b = SKIP_BACK(struct mblock, data, m); rfree(b); } #define STEP_UP(x) ((x) + (x)/2 + 4) void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_size) { unsigned nsize = MIN(*size, need); while (nsize < need) nsize = STEP_UP(nsize); *buf = mb_realloc(*buf, nsize * item_size); *size = nsize; } bird-2.0.8/lib/printf_test.c0000664000175000017500000000702314025744326014641 0ustar feelafeela/* * BIRD Library -- String Functions Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/string.h" #define BSPRINTF(nw, res, buf, fmt, ...) \ do { \ int n = bsprintf(buf, fmt, ##__VA_ARGS__); \ bt_assert_msg(n == nw, "fmt=\"%s\" returns n=%d, want %d", fmt, n, nw); \ bt_assert_msg(buf[n] == 0, "fmt=\"%s\" buf[%d] should be \'\\0\', found 0x%02x", fmt, n, buf[n]); \ bt_assert_msg(memcmp(buf, res, nw) == 0, "fmt=\"%s\" writes \"%*s\", want \"%*s\"", fmt, (n < nw ? n : nw), buf, nw, res); \ } while (0) static int t_simple(void) { char buf[256]; memset(buf, 0xa5, 256); BSPRINTF(0, "", buf, "", NULL); BSPRINTF(1, "%", buf, "%%", NULL); BSPRINTF(2, "%%", buf, "%%%%", NULL); BSPRINTF(1, "\x00", buf, "%c", 0); BSPRINTF(1, "@", buf, "@", 64); BSPRINTF(1, "\xff", buf, "%c", 0xff); errno = 5; BSPRINTF(18, "Input/output error", buf, "%m"); errno = 0; BSPRINTF(18, "Input/output error", buf, "%M", 5); BSPRINTF(11, "TeSt%StRiNg", buf, "%s", "TeSt%StRiNg"); if (sizeof(void *) == 4) BSPRINTF(8, "1a15600d", buf, "%p", (void *) 0x1a15600d); else BSPRINTF(16, "00000fee1a15600d", buf, "%p", (void *) 0xfee1a15600d); s64 ln = 0; BSPRINTF(10, "TeStStRiNg", buf, "TeStS%lntRiNg", &ln); bt_assert_msg(ln == 5, "fmt=\"TeStS%%lntRiNg\", &ln makes ln=%ld, want 5", ln); BSPRINTF(2, "%d", buf, "%%d", 1); BSPRINTF(1, "1", buf, "%d", 1); BSPRINTF(2, "+1", buf, "%+d", 1); BSPRINTF(2, " 1", buf, "% d", 1); BSPRINTF(2, "-1", buf, "%d", -1); BSPRINTF(11, "-2147483648", buf, "%d", INT32_MIN); BSPRINTF(10, "2147483647", buf, "%d", INT32_MAX); BSPRINTF(1, "0", buf, "%u", 0x0); BSPRINTF(10, "4294967295", buf, "%u", 0xFFFFFFFF); BSPRINTF(4, "-100", buf, "%ld", (s64) -100); BSPRINTF(3, "100", buf, "%ld", (s64) 100); BSPRINTF(20, "-9223372036854775808", buf, "%ld", INT64_MIN); BSPRINTF(19, "9223372036854775807", buf, "%ld", INT64_MAX); BSPRINTF(3, "0 8", buf, "%lu %lu", U64(0), U64(8)); BSPRINTF(20, "18446744073709551615", buf, "%lu", UINT64_MAX); return 1; } static int t_router_id(void) { char buf[256]; BSPRINTF(7, "1.2.3.4", buf, "%R", (u32) 0x01020304); BSPRINTF(15, "240.224.208.192", buf, "%R", (u32) 0xF0E0D0C0); BSPRINTF(23, "01:02:03:04:05:06:07:08", buf, "%lR", (u64) 0x0102030405060708); BSPRINTF(23, "f0:e0:d0:c0:b0:a0:90:80", buf, "%lR", (u64) 0xF0E0D0C0B0A09080); return 1; } static int t_time(void) { char buf[256]; BSPRINTF(7, "123.456", buf, "%t", (btime) 123456789); BSPRINTF(7, "123.456", buf, "%2t", (btime) 123456789); BSPRINTF(8, " 123.456", buf, "%8t", (btime) 123456789); BSPRINTF(4, " 123", buf, "%4.0t", (btime) 123456789); BSPRINTF(8, "123.4567", buf, "%8.4t", (btime) 123456789); BSPRINTF(9, "0123.4567", buf, "%09.4t", (btime) 123456789); BSPRINTF(12, " 123.456789", buf, "%12.10t", (btime) 123456789); BSPRINTF(8, " 123.004", buf, "%8t", (btime) 123004 MS); return 1; } static int t_bstrcmp(void) { bt_assert(bstrcmp("aa", "aa") == 0); bt_assert(bstrcmp("aa", "bb") == -1); bt_assert(bstrcmp("bb", "aa") == 1); bt_assert(bstrcmp(NULL, NULL) == 0); bt_assert(bstrcmp(NULL, "bb") == -1); bt_assert(bstrcmp("bb", NULL) == 1); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_simple, "printf without varargs"); bt_test_suite(t_router_id, "print router id"); bt_test_suite(t_time, "print time"); bt_test_suite(t_bstrcmp, "bstrcmp"); return bt_exit_value(); } bird-2.0.8/lib/printf.c0000664000175000017500000003003514025744326013601 0ustar feelafeela/* * BIRD Library -- Formatted Output * * (c) 1991, 1992 Lars Wirzenius & Linus Torvalds * * Hacked up for BIRD by Martin Mares * Buffer size limitation implemented by Martin Mares. */ #include "nest/bird.h" #include "string.h" #include #include "nest/iface.h" /* we use this so that we can do without the ctype library */ #define is_digit(c) ((c) >= '0' && (c) <= '9') static int skip_atoi(const char **s) { int i=0; while (is_digit(**s)) i = i*10 + *((*s)++) - '0'; return i; } #define ZEROPAD 1 /* pad with zero */ #define SIGN 2 /* unsigned/signed long */ #define PLUS 4 /* show plus */ #define SPACE 8 /* space if plus */ #define LEFT 16 /* left justified */ #define SPECIAL 32 /* 0x */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ static char * number(char * str, u64 num, uint base, int size, int precision, int type, int remains) { char c,sign,tmp[66]; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; int i; if (size >= 0 && (remains -= size) < 0) return NULL; if (type & LARGE) digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (type & LEFT) type &= ~ZEROPAD; if (base < 2 || base > 36) return 0; c = (type & ZEROPAD) ? '0' : ' '; sign = 0; if (type & SIGN) { if (num > (u64) INT64_MAX) { sign = '-'; num = -num; size--; } else if (type & PLUS) { sign = '+'; size--; } else if (type & SPACE) { sign = ' '; size--; } } if (type & SPECIAL) { if (base == 16) size -= 2; else if (base == 8) size--; } i = 0; if (num == 0) tmp[i++]='0'; else while (num != 0) { uint res = num % base; num = num / base; tmp[i++] = digits[res]; } if (i > precision) precision = i; size -= precision; if (size < 0 && -size > remains) return NULL; if (!(type&(ZEROPAD+LEFT))) while(size-->0) *str++ = ' '; if (sign) *str++ = sign; if (type & SPECIAL) { if (base==8) *str++ = '0'; else if (base==16) { *str++ = '0'; *str++ = digits[33]; } } if (!(type & LEFT)) while (size-- > 0) *str++ = c; while (i < precision--) *str++ = '0'; while (i-- > 0) *str++ = tmp[i]; while (size-- > 0) *str++ = ' '; return str; } /** * bvsnprintf - BIRD's vsnprintf() * @buf: destination buffer * @size: size of the buffer * @fmt: format string * @args: a list of arguments to be formatted * * This functions acts like ordinary sprintf() except that it checks available * space to avoid buffer overflows and it allows some more format specifiers: * |%I| for formatting of IP addresses (width of 1 is automatically replaced by * standard IP address width which depends on whether we use IPv4 or IPv6; |%I4| * or |%I6| can be used for explicit ip4_addr / ip6_addr arguments, |%N| for * generic network addresses (net_addr *), |%R| for Router / Network ID (u32 * value printed as IPv4 address), |%lR| for 64bit Router / Network ID (u64 * value printed as eight :-separated octets), |%t| for time values (btime) with * specified subsecond precision, and |%m| resp. |%M| for error messages (uses * strerror() to translate @errno code to message text). On the other hand, it * doesn't support floating point numbers. The bvsnprintf() supports |%h| and * |%l| qualifiers, but |%l| is used for s64/u64 instead of long/ulong. * * Result: number of characters of the output string or -1 if * the buffer space was insufficient. */ int bvsnprintf(char *buf, int size, const char *fmt, va_list args) { int len, i; u64 num; uint base; u32 x; u64 X; btime t; s64 t1, t2; char *str, *start; const char *s; char ipbuf[NET_MAX_TEXT_LENGTH+1]; struct iface *iface; int flags; /* flags to number() */ int field_width; /* width of output field */ int precision; /* min. # of digits for integers; max number of chars for from string */ int qualifier; /* 'h' or 'l' for integer fields */ for (start=str=buf ; *fmt ; ++fmt, size-=(str-start), start=str) { if (*fmt != '%') { if (!size) return -1; *str++ = *fmt; continue; } /* process flags */ flags = 0; repeat: ++fmt; /* this also skips first '%' */ switch (*fmt) { case '-': flags |= LEFT; goto repeat; case '+': flags |= PLUS; goto repeat; case ' ': flags |= SPACE; goto repeat; case '#': flags |= SPECIAL; goto repeat; case '0': flags |= ZEROPAD; goto repeat; } /* get field width */ field_width = -1; if (is_digit(*fmt)) field_width = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt; /* it's the next argument */ field_width = va_arg(args, int); if (field_width < 0) { field_width = -field_width; flags |= LEFT; } } /* get the precision */ precision = -1; if (*fmt == '.') { ++fmt; if (is_digit(*fmt)) precision = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt; /* it's the next argument */ precision = va_arg(args, int); } if (precision < 0) precision = 0; } /* get the conversion qualifier */ qualifier = -1; if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { qualifier = *fmt; ++fmt; } /* default base */ base = 10; if (field_width > size) return -1; switch (*fmt) { case 'c': if (!(flags & LEFT)) while (--field_width > 0) *str++ = ' '; *str++ = (byte) va_arg(args, int); while (--field_width > 0) *str++ = ' '; continue; case 'm': if (flags & SPECIAL) { if (!errno) continue; if (size < 2) return -1; *str++ = ':'; *str++ = ' '; start += 2; size -= 2; } s = strerror(errno); goto str; case 'M': s = strerror(va_arg(args, int)); goto str; case 'N': { net_addr *n = va_arg(args, net_addr *); if (field_width == 1) field_width = net_max_text_length[n->type]; net_format(n, ipbuf, sizeof(ipbuf)); s = ipbuf; goto str; } case 's': s = va_arg(args, char *); if (!s) s = ""; str: len = strlen(s); if (precision >= 0 && len > precision) len = precision; if (len > size) return -1; if (!(flags & LEFT)) while (len < field_width--) *str++ = ' '; for (i = 0; i < len; ++i) *str++ = *s++; while (len < field_width--) *str++ = ' '; continue; case 'V': { const char *vfmt = va_arg(args, const char *); va_list *vargs = va_arg(args, va_list *); int res = bvsnprintf(str, size, vfmt, *vargs); if (res < 0) return -1; str += res; size -= res; continue; } case 'p': if (field_width == -1) { field_width = 2*sizeof(void *); flags |= ZEROPAD; } str = number(str, (uintptr_t) va_arg(args, void *), 16, field_width, precision, flags, size); if (!str) return -1; continue; case 'n': if (qualifier == 'l') { s64 * ip = va_arg(args, s64 *); *ip = (str - buf); } else { int * ip = va_arg(args, int *); *ip = (str - buf); } continue; /* IP address */ case 'I': if (fmt[1] == '4') { /* Explicit IPv4 address */ ip4_addr a = va_arg(args, ip4_addr); ip4_ntop(a, ipbuf); i = IP4_MAX_TEXT_LENGTH; fmt++; } else if (fmt[1] == '6') { /* Explicit IPv6 address */ ip6_addr a = va_arg(args, ip6_addr); ip6_ntop(a, ipbuf); i = IP6_MAX_TEXT_LENGTH; fmt++; } else { /* Just IP address */ ip_addr a = va_arg(args, ip_addr); if (ipa_is_ip4(a)) { ip4_ntop(ipa_to_ip4(a), ipbuf); i = IP4_MAX_TEXT_LENGTH; } else { ip6_ntop(ipa_to_ip6(a), ipbuf); i = IP6_MAX_TEXT_LENGTH; } } s = ipbuf; if (field_width == 1) field_width = i; goto str; /* Interface scope after link-local IP address */ case 'J': iface = va_arg(args, struct iface *); if (!iface) continue; if (!size) return -1; *str++ = '%'; start++; size--; s = iface->name; goto str; /* Router/Network ID - essentially IPv4 address in u32 value */ case 'R': if (qualifier == 'l') { X = va_arg(args, u64); bsprintf(ipbuf, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", (uint) ((X >> 56) & 0xff), (uint) ((X >> 48) & 0xff), (uint) ((X >> 40) & 0xff), (uint) ((X >> 32) & 0xff), (uint) ((X >> 24) & 0xff), (uint) ((X >> 16) & 0xff), (uint) ((X >> 8) & 0xff), (uint) (X & 0xff)); } else { x = va_arg(args, u32); ip4_ntop(ip4_from_u32(x), ipbuf); } s = ipbuf; goto str; case 't': t = va_arg(args, btime); t1 = t TO_S; t2 = t - t1 S; if (precision < 0) precision = 3; if (precision > 6) precision = 6; /* Compute field_width for second part */ if ((precision > 0) && (field_width > 0)) field_width -= (1 + precision); if (field_width < 0) field_width = 0; /* Print seconds */ flags |= SIGN; str = number(str, (u64) t1, 10, field_width, 0, flags, size); if (!str) return -1; if (precision > 0) { size -= (str-start); start = str; if ((1 + precision) > size) return -1; /* Convert microseconds to requested precision */ for (i = precision; i < 6; i++) t2 /= 10; /* Print sub-seconds */ *str++ = '.'; str = number(str, (u64) t2, 10, precision, 0, ZEROPAD, size - 1); if (!str) return -1; } goto done; /* integer number formats - set up the flags and "break" */ case 'o': base = 8; break; case 'X': flags |= LARGE; /* fallthrough */ case 'x': base = 16; break; case 'd': case 'i': flags |= SIGN; case 'u': break; default: if (size < 2) return -1; if (*fmt != '%') *str++ = '%'; if (*fmt) *str++ = *fmt; else --fmt; continue; } if (flags & SIGN) { /* Conversions valid per ISO C99 6.3.1.3 (2) */ if (qualifier == 'l') num = (u64) va_arg(args, s64); else if (qualifier == 'h') num = (u64) (short) va_arg(args, int); else num = (u64) va_arg(args, int); } else { if (qualifier == 'l') num = va_arg(args, u64); else if (qualifier == 'h') num = (unsigned short) va_arg(args, int); else num = va_arg(args, uint); } str = number(str, num, base, field_width, precision, flags, size); if (!str) return -1; done: ; } if (!size) return -1; *str = '\0'; return str-buf; } /** * bvsprintf - BIRD's vsprintf() * @buf: buffer * @fmt: format string * @args: a list of arguments to be formatted * * This function is equivalent to bvsnprintf() with an infinite * buffer size. Please use carefully only when you are absolutely * sure the buffer won't overflow. */ int bvsprintf(char *buf, const char *fmt, va_list args) { return bvsnprintf(buf, 1000000000, fmt, args); } /** * bsprintf - BIRD's sprintf() * @buf: buffer * @fmt: format string * * This function is equivalent to bvsnprintf() with an infinite * buffer size and variable arguments instead of a &va_list. * Please use carefully only when you are absolutely * sure the buffer won't overflow. */ int bsprintf(char * buf, const char *fmt, ...) { va_list args; int i; va_start(args, fmt); i=bvsnprintf(buf, 1000000000, fmt, args); va_end(args); return i; } /** * bsnprintf - BIRD's snprintf() * @buf: buffer * @size: buffer size * @fmt: format string * * This function is equivalent to bsnprintf() with variable arguments instead of a &va_list. */ int bsnprintf(char * buf, int size, const char *fmt, ...) { va_list args; int i; va_start(args, fmt); i=bvsnprintf(buf, size, fmt, args); va_end(args); return i; } int buffer_vprint(buffer *buf, const char *fmt, va_list args) { int i = bvsnprintf((char *) buf->pos, buf->end - buf->pos, fmt, args); if ((i < 0) && (buf->pos < buf->end)) *buf->pos = 0; buf->pos = (i >= 0) ? (buf->pos + i) : buf->end; return i; } int buffer_print(buffer *buf, const char *fmt, ...) { va_list args; int i; va_start(args, fmt); i = bvsnprintf((char *) buf->pos, buf->end - buf->pos, fmt, args); va_end(args); if ((i < 0) && (buf->pos < buf->end)) *buf->pos = 0; buf->pos = (i >= 0) ? (buf->pos + i) : buf->end; return i; } void buffer_puts(buffer *buf, const char *str) { byte *bp = buf->pos; byte *be = buf->end - 1; while (bp < be && *str) *bp++ = *str++; if (bp <= be) *bp = 0; buf->pos = (bp < be) ? bp : buf->end; } bird-2.0.8/lib/patmatch_test.c0000664000175000017500000000566314025744326015150 0ustar feelafeela/* * BIRD Library -- Pattern Matching Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "nest/bird.h" #include "lib/string.h" #define MATCH (int) { 1 } #define NOMATCH (int) { 0 } struct match_pair { byte *pattern; byte *data; }; static int test_matching(void *out_, const void *in_, const void *expected_out_) { int *out = out_; const struct match_pair *in = in_; const int *expected_out = expected_out_; *out = patmatch(in->pattern, in->data); return *out == *expected_out; } static void fmt_match_pair(char *buf, size_t size, const void *data) { const struct match_pair *mp = data; snprintf(buf, size, "pattern: '%s', subject: '%s'", mp->pattern, mp->data); } static void fmt_match_result(char *buf, size_t size, const void *data) { const int *result = data; snprintf(buf, size, *result ? "match" : "no-match"); } static int t_matching(void) { struct bt_pair test_vectors[] = { { .in = & (struct match_pair) { .pattern = "", .data = "", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "*", .data = "", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "\\*", .data = "*", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "\\*", .data = "a", }, .out = & NOMATCH, }, { .in = & (struct match_pair) { .pattern = "?", .data = "", }, .out = & NOMATCH, }, { .in = & (struct match_pair) { .pattern = "abcdefghijklmnopqrstuvwxyz", .data = "abcdefghijklmnopqrstuvwxyz", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "??????????????????????????", .data = "abcdefghijklmnopqrstuvwxyz", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "*abcdefghijklmnopqrstuvwxyz*", .data = "abcdefghijklmnopqrstuvwxyz", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "ab?defg*jklmnop*stu*wxy*z", .data = "abcdefghijklmnopqrstuvwxyz", }, .out = & MATCH, }, { .in = & (struct match_pair) { .pattern = "abcdefghijklmnopqrstuvwxyz", .data = "abcdefghijklmnopqrtuvwxyz", }, .out = & NOMATCH, }, { .in = & (struct match_pair) { .pattern = "abcdefghijklmnopqr?uvwxyz", .data = "abcdefghijklmnopqrstuvwxyz", }, .out = & NOMATCH, }, { .in = & (struct match_pair) { .pattern = "aa*aaaaa?aaaaaaaaaaaaaaaaaaa", .data = "aaaaaaaaaaaaaaaaaaaaaaaaaa", }, .out = & NOMATCH, }, }; return bt_assert_batch(test_vectors, test_matching, fmt_match_pair, fmt_match_result); } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_matching, "Pattern matching"); return bt_exit_value(); } bird-2.0.8/lib/patmatch.c0000664000175000017500000000270214025744326014100 0ustar feelafeela/* * BIRD Library -- Generic Shell-Like Pattern Matching (currently only '?' and '*') * * (c) 1998--2000 Martin Mares */ #include "nest/bird.h" #include "lib/string.h" #ifndef MATCH_FUNC_NAME #define MATCH_FUNC_NAME patmatch #endif #ifndef Convert #define Convert(x) x #endif int MATCH_FUNC_NAME(const byte *p, const byte *s) { while (*p) { if (*p == '?' && *s) p++, s++; else if (*p == '*') { int z = p[1]; if (!z) return 1; if (z == '\\' && p[2]) z = p[2]; z = Convert(z); for(;;) { while (*s && Convert(*s) != z) s++; if (!*s) return 0; if (MATCH_FUNC_NAME(p+1, s)) return 1; s++; } } else { if (*p == '\\' && p[1]) p++; if (Convert(*p++) != Convert(*s++)) return 0; } } return !*s; } #if 0 /** * patmatch - match shell-like patterns * @p: pattern * @s: string * * patmatch() returns whether given string @s matches the given shell-like * pattern @p. The patterns consist of characters (which are matched literally), * question marks which match any single character, asterisks which match any * (possibly empty) string of characters and backslashes which are used to * escape any special characters and force them to be treated literally. * * The matching process is not optimized with respect to time, so please * avoid using this function for complex patterns. */ int patmatch(byte *p, byte *s) { DUMMY; } #endif bird-2.0.8/lib/net.h0000664000175000017500000004751714025744326013107 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Network addresses * * (c) 2015 Ondrej Zajicek * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_NET_H_ #define _BIRD_NET_H_ #include "lib/ip.h" #define NET_IP4 1 #define NET_IP6 2 #define NET_VPN4 3 #define NET_VPN6 4 #define NET_ROA4 5 #define NET_ROA6 6 #define NET_FLOW4 7 #define NET_FLOW6 8 #define NET_IP6_SADR 9 #define NET_MPLS 10 #define NET_MAX 11 #define NB_IP4 (1 << NET_IP4) #define NB_IP6 (1 << NET_IP6) #define NB_VPN4 (1 << NET_VPN4) #define NB_VPN6 (1 << NET_VPN6) #define NB_ROA4 (1 << NET_ROA4) #define NB_ROA6 (1 << NET_ROA6) #define NB_FLOW4 (1 << NET_FLOW4) #define NB_FLOW6 (1 << NET_FLOW6) #define NB_IP6_SADR (1 << NET_IP6_SADR) #define NB_MPLS (1 << NET_MPLS) #define NB_IP (NB_IP4 | NB_IP6) #define NB_VPN (NB_VPN4 | NB_VPN6) #define NB_FLOW (NB_FLOW4 | NB_FLOW6) #define NB_DEST (NB_IP | NB_IP6_SADR | NB_VPN | NB_MPLS) #define NB_ANY 0xffffffff typedef struct net_addr { u8 type; u8 pxlen; u16 length; u8 data[20]; u64 align[0]; } net_addr; typedef struct net_addr_ip4 { u8 type; u8 pxlen; u16 length; ip4_addr prefix; } net_addr_ip4; typedef struct net_addr_ip6 { u8 type; u8 pxlen; u16 length; ip6_addr prefix; } net_addr_ip6; typedef struct net_addr_vpn4 { u8 type; u8 pxlen; u16 length; ip4_addr prefix; u64 rd; } net_addr_vpn4; typedef struct net_addr_vpn6 { u8 type; u8 pxlen; u16 length; ip6_addr prefix; u32 padding; u64 rd; } net_addr_vpn6; typedef struct net_addr_roa4 { u8 type; u8 pxlen; u16 length; ip4_addr prefix; u32 max_pxlen; u32 asn; } net_addr_roa4; typedef struct net_addr_roa6 { u8 type; u8 pxlen; u16 length; ip6_addr prefix; u32 max_pxlen; u32 asn; } net_addr_roa6; typedef struct net_addr_flow4 { u8 type; u8 pxlen; u16 length; ip4_addr prefix; byte data[0]; } net_addr_flow4; typedef struct net_addr_flow6 { u8 type; u8 pxlen; u16 length; ip6_addr prefix; byte data[0]; } net_addr_flow6; typedef struct net_addr_mpls { u8 type; u8 pxlen; u16 length; u32 label; } net_addr_mpls; typedef struct net_addr_ip6_sadr { u8 type; u8 dst_pxlen; u16 length; ip6_addr dst_prefix; s32 src_pxlen; /* s32 to avoid padding */ ip6_addr src_prefix; } net_addr_ip6_sadr; typedef union net_addr_union { net_addr n; net_addr_ip4 ip4; net_addr_ip6 ip6; net_addr_vpn4 vpn4; net_addr_vpn6 vpn6; net_addr_roa4 roa4; net_addr_roa6 roa6; net_addr_flow4 flow4; net_addr_flow6 flow6; net_addr_ip6_sadr ip6_sadr; net_addr_mpls mpls; } net_addr_union; extern const char * const net_label[]; extern const u16 net_addr_length[]; extern const u8 net_max_prefix_length[]; extern const u16 net_max_text_length[]; #define NET_MAX_TEXT_LENGTH 256 #define NET_ADDR_IP4(prefix,pxlen) \ ((net_addr_ip4) { NET_IP4, pxlen, sizeof(net_addr_ip4), prefix }) #define NET_ADDR_IP6(prefix,pxlen) \ ((net_addr_ip6) { NET_IP6, pxlen, sizeof(net_addr_ip6), prefix }) #define NET_ADDR_VPN4(prefix,pxlen,rd) \ ((net_addr_vpn4) { NET_VPN4, pxlen, sizeof(net_addr_vpn4), prefix, rd }) #define NET_ADDR_VPN6(prefix,pxlen,rd) \ ((net_addr_vpn6) { NET_VPN6, pxlen, sizeof(net_addr_vpn6), prefix, 0, rd }) #define NET_ADDR_ROA4(prefix,pxlen,max_pxlen,asn) \ ((net_addr_roa4) { NET_ROA4, pxlen, sizeof(net_addr_roa4), prefix, max_pxlen, asn }) #define NET_ADDR_ROA6(prefix,pxlen,max_pxlen,asn) \ ((net_addr_roa6) { NET_ROA6, pxlen, sizeof(net_addr_roa6), prefix, max_pxlen, asn }) #define NET_ADDR_FLOW4(prefix,pxlen,dlen) \ ((net_addr_flow4) { NET_FLOW4, pxlen, sizeof(net_addr_flow4) + dlen, prefix }) #define NET_ADDR_FLOW6(prefix,pxlen,dlen) \ ((net_addr_flow6) { NET_FLOW6, pxlen, sizeof(net_addr_flow6) + dlen, prefix }) #define NET_ADDR_IP6_SADR(dst_prefix,dst_pxlen,src_prefix,src_pxlen) \ ((net_addr_ip6_sadr) { NET_IP6_SADR, dst_pxlen, sizeof(net_addr_ip6_sadr), dst_prefix, src_pxlen, src_prefix }) #define NET_ADDR_MPLS(label) \ ((net_addr_mpls) { NET_MPLS, 20, sizeof(net_addr_mpls), label }) static inline void net_fill_ip4(net_addr *a, ip4_addr prefix, uint pxlen) { *(net_addr_ip4 *)a = NET_ADDR_IP4(prefix, pxlen); } static inline void net_fill_ip6(net_addr *a, ip6_addr prefix, uint pxlen) { *(net_addr_ip6 *)a = NET_ADDR_IP6(prefix, pxlen); } static inline void net_fill_vpn4(net_addr *a, ip4_addr prefix, uint pxlen, u64 rd) { *(net_addr_vpn4 *)a = NET_ADDR_VPN4(prefix, pxlen, rd); } static inline void net_fill_vpn6(net_addr *a, ip6_addr prefix, uint pxlen, u64 rd) { *(net_addr_vpn6 *)a = NET_ADDR_VPN6(prefix, pxlen, rd); } static inline void net_fill_roa4(net_addr *a, ip4_addr prefix, uint pxlen, uint max_pxlen, u32 asn) { *(net_addr_roa4 *)a = NET_ADDR_ROA4(prefix, pxlen, max_pxlen, asn); } static inline void net_fill_roa6(net_addr *a, ip6_addr prefix, uint pxlen, uint max_pxlen, u32 asn) { *(net_addr_roa6 *)a = NET_ADDR_ROA6(prefix, pxlen, max_pxlen, asn); } static inline void net_fill_ip6_sadr(net_addr *a, ip6_addr dst_prefix, uint dst_pxlen, ip6_addr src_prefix, uint src_pxlen) { *(net_addr_ip6_sadr *)a = NET_ADDR_IP6_SADR(dst_prefix, dst_pxlen, src_prefix, src_pxlen); } static inline void net_fill_mpls(net_addr *a, u32 label) { *(net_addr_mpls *)a = NET_ADDR_MPLS(label); } static inline void net_fill_ipa(net_addr *a, ip_addr prefix, uint pxlen) { if (ipa_is_ip4(prefix)) net_fill_ip4(a, ipa_to_ip4(prefix), pxlen); else net_fill_ip6(a, ipa_to_ip6(prefix), pxlen); } static inline void net_fill_ip_host(net_addr *a, ip_addr prefix) { if (ipa_is_ip4(prefix)) net_fill_ip4(a, ipa_to_ip4(prefix), IP4_MAX_PREFIX_LENGTH); else net_fill_ip6(a, ipa_to_ip6(prefix), IP6_MAX_PREFIX_LENGTH); } static inline void net_fill_flow4(net_addr *a, ip4_addr prefix, uint pxlen, byte *data, uint dlen) { net_addr_flow4 *f = (void *) a; *f = NET_ADDR_FLOW4(prefix, pxlen, dlen); memcpy(f->data, data, dlen); } static inline void net_fill_flow6(net_addr *a, ip6_addr prefix, uint pxlen, byte *data, uint dlen) { net_addr_flow6 *f = (void *) a; *f = NET_ADDR_FLOW6(prefix, pxlen, dlen); memcpy(f->data, data, dlen); } /* Make NET_IP6_SADR from NET_IP6, assuming there is enough space */ static inline void net_make_ip6_sadr(net_addr *a) { net_addr_ip6_sadr *n = (void *) a; n->type = NET_IP6_SADR; n->length = sizeof(net_addr_ip6_sadr); n->src_pxlen = 0; n->src_prefix = IP6_NONE; } static inline int net_val_match(u8 type, u32 mask) { return !!((1 << type) & mask); } static inline int net_type_match(const net_addr *a, u32 mask) { return net_val_match(a->type, mask); } static inline int net_is_ip(const net_addr *a) { return (a->type == NET_IP4) || (a->type == NET_IP6); } static inline int net_is_vpn(const net_addr *a) { return (a->type == NET_VPN4) || (a->type == NET_VPN6); } static inline int net_is_roa(const net_addr *a) { return (a->type == NET_ROA4) || (a->type == NET_ROA6); } static inline int net_is_flow(const net_addr *a) { return (a->type == NET_FLOW4) || (a->type == NET_FLOW6); } static inline int net_is_sadr(const net_addr *a) { return (a->type == NET_IP6_SADR); } static inline ip4_addr net4_prefix(const net_addr *a) { return ((net_addr_ip4 *) a)->prefix; } static inline ip6_addr net6_prefix(const net_addr *a) { return ((net_addr_ip6 *) a)->prefix; } static inline ip_addr net_prefix(const net_addr *a) { switch (a->type) { case NET_IP4: case NET_VPN4: case NET_ROA4: case NET_FLOW4: return ipa_from_ip4(net4_prefix(a)); case NET_IP6: case NET_VPN6: case NET_ROA6: case NET_FLOW6: case NET_IP6_SADR: return ipa_from_ip6(net6_prefix(a)); case NET_MPLS: default: return IPA_NONE; } } static inline u32 net_mpls(const net_addr *a) { if (a->type == NET_MPLS) return ((net_addr_mpls *) a)->label; bug("Can't call net_mpls on non-mpls net_addr"); } static inline uint net4_pxlen(const net_addr *a) { return a->pxlen; } static inline uint net6_pxlen(const net_addr *a) { return a->pxlen; } static inline uint net_pxlen(const net_addr *a) { return a->pxlen; } ip_addr net_pxmask(const net_addr *a); static inline u64 net_rd(const net_addr *a) { switch (a->type) { case NET_VPN4: return ((net_addr_vpn4 *)a)->rd; case NET_VPN6: return ((net_addr_vpn6 *)a)->rd; } return 0; } static inline int net_equal(const net_addr *a, const net_addr *b) { return (a->length == b->length) && !memcmp(a, b, a->length); } static inline int net_equal_ip4(const net_addr_ip4 *a, const net_addr_ip4 *b) { return !memcmp(a, b, sizeof(net_addr_ip4)); } static inline int net_equal_ip6(const net_addr_ip6 *a, const net_addr_ip6 *b) { return !memcmp(a, b, sizeof(net_addr_ip6)); } static inline int net_equal_vpn4(const net_addr_vpn4 *a, const net_addr_vpn4 *b) { return !memcmp(a, b, sizeof(net_addr_vpn4)); } static inline int net_equal_vpn6(const net_addr_vpn6 *a, const net_addr_vpn6 *b) { return !memcmp(a, b, sizeof(net_addr_vpn6)); } static inline int net_equal_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b) { return !memcmp(a, b, sizeof(net_addr_roa4)); } static inline int net_equal_roa6(const net_addr_roa6 *a, const net_addr_roa6 *b) { return !memcmp(a, b, sizeof(net_addr_roa6)); } static inline int net_equal_flow4(const net_addr_flow4 *a, const net_addr_flow4 *b) { return net_equal((const net_addr *) a, (const net_addr *) b); } static inline int net_equal_flow6(const net_addr_flow6 *a, const net_addr_flow6 *b) { return net_equal((const net_addr *) a, (const net_addr *) b); } static inline int net_equal_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return !memcmp(a, b, sizeof(net_addr_ip6_sadr)); } static inline int net_equal_mpls(const net_addr_mpls *a, const net_addr_mpls *b) { return !memcmp(a, b, sizeof(net_addr_mpls)); } static inline int net_equal_prefix_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b) { return ip4_equal(a->prefix, b->prefix) && (a->pxlen == b->pxlen); } static inline int net_equal_prefix_roa6(const net_addr_roa6 *a, const net_addr_roa6 *b) { return ip6_equal(a->prefix, b->prefix) && (a->pxlen == b->pxlen); } static inline int net_equal_dst_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return ip6_equal(a->dst_prefix, b->dst_prefix) && (a->dst_pxlen == b->dst_pxlen); } static inline int net_equal_src_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return ip6_equal(a->src_prefix, b->src_prefix) && (a->src_pxlen == b->src_pxlen); } static inline int net_zero_ip4(const net_addr_ip4 *a) { return !a->pxlen && ip4_zero(a->prefix); } static inline int net_zero_ip6(const net_addr_ip6 *a) { return !a->pxlen && ip6_zero(a->prefix); } static inline int net_zero_vpn4(const net_addr_vpn4 *a) { return !a->pxlen && ip4_zero(a->prefix) && !a->rd; } static inline int net_zero_vpn6(const net_addr_vpn6 *a) { return !a->pxlen && ip6_zero(a->prefix) && !a->rd; } static inline int net_zero_roa4(const net_addr_roa4 *a) { return !a->pxlen && ip4_zero(a->prefix) && !a->max_pxlen && !a->asn; } static inline int net_zero_roa6(const net_addr_roa6 *a) { return !a->pxlen && ip6_zero(a->prefix) && !a->max_pxlen && !a->asn; } static inline int net_zero_flow4(const net_addr_flow4 *a) { return !a->pxlen && ip4_zero(a->prefix) && (a->length == sizeof(net_addr_flow4)); } static inline int net_zero_flow6(const net_addr_flow6 *a) { return !a->pxlen && ip6_zero(a->prefix) && (a->length == sizeof(net_addr_flow6)); } static inline int net_zero_mpls(const net_addr_mpls *a) { return !a->label; } static inline int net_compare_ip4(const net_addr_ip4 *a, const net_addr_ip4 *b) { return ip4_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen); } static inline int net_compare_ip6(const net_addr_ip6 *a, const net_addr_ip6 *b) { return ip6_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen); } static inline int net_compare_vpn4(const net_addr_vpn4 *a, const net_addr_vpn4 *b) { return u64_cmp(a->rd, b->rd) ?: ip4_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen); } static inline int net_compare_vpn6(const net_addr_vpn6 *a, const net_addr_vpn6 *b) { return u64_cmp(a->rd, b->rd) ?: ip6_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen); } static inline int net_compare_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b) { return ip4_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen) ?: uint_cmp(a->max_pxlen, b->max_pxlen) ?: uint_cmp(a->asn, b->asn); } static inline int net_compare_roa6(const net_addr_roa6 *a, const net_addr_roa6 *b) { return ip6_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen) ?: uint_cmp(a->max_pxlen, b->max_pxlen) ?: uint_cmp(a->asn, b->asn); } static inline int net_compare_flow4(const net_addr_flow4 *a, const net_addr_flow4 *b) { return ip4_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen) ?: uint_cmp(a->length, b->length) ?: memcmp(a->data, b->data, a->length - sizeof(net_addr_flow4)); } static inline int net_compare_flow6(const net_addr_flow6 *a, const net_addr_flow6 *b) { return ip6_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen) ?: uint_cmp(a->length, b->length) ?: memcmp(a->data, b->data, a->length - sizeof(net_addr_flow6)); } static inline int net_compare_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return ip6_compare(a->dst_prefix, b->dst_prefix) ?: uint_cmp(a->dst_pxlen, b->dst_pxlen) ?: ip6_compare(a->src_prefix, b->src_prefix) ?: uint_cmp(a->src_pxlen, b->src_pxlen); } static inline int net_compare_mpls(const net_addr_mpls *a, const net_addr_mpls *b) { return uint_cmp(a->label, b->label); } int net_compare(const net_addr *a, const net_addr *b); static inline void net_copy(net_addr *dst, const net_addr *src) { memcpy(dst, src, src->length); } static inline void net_copy_ip4(net_addr_ip4 *dst, const net_addr_ip4 *src) { memcpy(dst, src, sizeof(net_addr_ip4)); } static inline void net_copy_ip6(net_addr_ip6 *dst, const net_addr_ip6 *src) { memcpy(dst, src, sizeof(net_addr_ip6)); } static inline void net_copy_vpn4(net_addr_vpn4 *dst, const net_addr_vpn4 *src) { memcpy(dst, src, sizeof(net_addr_vpn4)); } static inline void net_copy_vpn6(net_addr_vpn6 *dst, const net_addr_vpn6 *src) { memcpy(dst, src, sizeof(net_addr_vpn6)); } static inline void net_copy_roa4(net_addr_roa4 *dst, const net_addr_roa4 *src) { memcpy(dst, src, sizeof(net_addr_roa4)); } static inline void net_copy_roa6(net_addr_roa6 *dst, const net_addr_roa6 *src) { memcpy(dst, src, sizeof(net_addr_roa6)); } static inline void net_copy_flow4(net_addr_flow4 *dst, const net_addr_flow4 *src) { memcpy(dst, src, src->length); } static inline void net_copy_flow6(net_addr_flow6 *dst, const net_addr_flow6 *src) { memcpy(dst, src, src->length); } static inline void net_copy_ip6_sadr(net_addr_ip6_sadr *dst, const net_addr_ip6_sadr *src) { memcpy(dst, src, sizeof(net_addr_ip6_sadr)); } static inline void net_copy_mpls(net_addr_mpls *dst, const net_addr_mpls *src) { memcpy(dst, src, sizeof(net_addr_mpls)); } /* XXXX */ static inline u32 u64_hash(u64 a) { return u32_hash(a); } static inline u32 net_hash_ip4(const net_addr_ip4 *n) { return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_ip6(const net_addr_ip6 *n) { return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_vpn4(const net_addr_vpn4 *n) { return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); } static inline u32 net_hash_vpn6(const net_addr_vpn6 *n) { return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); } static inline u32 net_hash_roa4(const net_addr_roa4 *n) { return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_roa6(const net_addr_roa6 *n) { return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_flow4(const net_addr_flow4 *n) { return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_flow6(const net_addr_flow6 *n) { return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); } static inline u32 net_hash_ip6_sadr(const net_addr_ip6_sadr *n) { return net_hash_ip6((net_addr_ip6 *) n); } static inline u32 net_hash_mpls(const net_addr_mpls *n) { return n->label; } u32 net_hash(const net_addr *a); static inline int net_validate_px4(const ip4_addr prefix, uint pxlen) { return (pxlen <= IP4_MAX_PREFIX_LENGTH) && ip4_zero(ip4_and(prefix, ip4_not(ip4_mkmask(pxlen)))); } static inline int net_validate_px6(const ip6_addr prefix, uint pxlen) { return (pxlen <= IP6_MAX_PREFIX_LENGTH) && ip6_zero(ip6_and(prefix, ip6_not(ip6_mkmask(pxlen)))); } static inline int net_validate_ip4(const net_addr_ip4 *n) { return net_validate_px4(n->prefix, n->pxlen); } static inline int net_validate_ip6(const net_addr_ip6 *n) { return net_validate_px6(n->prefix, n->pxlen); } static inline int net_validate_vpn4(const net_addr_vpn4 *n) { return net_validate_px4(n->prefix, n->pxlen); } static inline int net_validate_vpn6(const net_addr_vpn6 *n) { return net_validate_px6(n->prefix, n->pxlen); } static inline int net_validate_roa4(const net_addr_roa4 *n) { return net_validate_px4(n->prefix, n->pxlen) && (n->pxlen <= n->max_pxlen) && (n->max_pxlen <= IP4_MAX_PREFIX_LENGTH); } static inline int net_validate_roa6(const net_addr_roa6 *n) { return net_validate_px6(n->prefix, n->pxlen) && (n->pxlen <= n->max_pxlen) && (n->max_pxlen <= IP6_MAX_PREFIX_LENGTH); } // FIXME: Better check, call flow_validate? static inline int net_validate_flow4(const net_addr_flow4 *n) { return net_validate_px4(n->prefix, n->pxlen); } static inline int net_validate_flow6(const net_addr_flow6 *n) { return net_validate_px6(n->prefix, n->pxlen); } static inline int net_validate_mpls(const net_addr_mpls *n) { return n->label < (1 << 20); } static inline int net_validate_ip6_sadr(const net_addr_ip6_sadr *n) { return net_validate_px6(n->dst_prefix, n->dst_pxlen) && net_validate_px6(n->src_prefix, n->src_pxlen); } int net_validate(const net_addr *N); static inline void net_normalize_ip4(net_addr_ip4 *n) { n->prefix = ip4_and(n->prefix, ip4_mkmask(n->pxlen)); } static inline void net_normalize_ip6(net_addr_ip6 *n) { n->prefix = ip6_and(n->prefix, ip6_mkmask(n->pxlen)); } static inline void net_normalize_vpn4(net_addr_vpn4 *n) { net_normalize_ip4((net_addr_ip4 *) n); } static inline void net_normalize_vpn6(net_addr_vpn6 *n) { net_normalize_ip6((net_addr_ip6 *) n); } static inline void net_normalize_ip6_sadr(net_addr_ip6_sadr *n) { n->dst_prefix = ip6_and(n->dst_prefix, ip6_mkmask(n->dst_pxlen)); n->src_prefix = ip6_and(n->src_prefix, ip6_mkmask(n->src_pxlen)); } void net_normalize(net_addr *N); int net_classify(const net_addr *N); int net_format(const net_addr *N, char *buf, int buflen); int rd_format(const u64 rd, char *buf, int buflen); static inline int ipa_in_px4(ip4_addr a, ip4_addr prefix, uint pxlen) { return ip4_zero(ip4_and(ip4_xor(a, prefix), ip4_mkmask(pxlen))); } static inline int ipa_in_px6(ip6_addr a, ip6_addr prefix, uint pxlen) { return ip6_zero(ip6_and(ip6_xor(a, prefix), ip6_mkmask(pxlen))); } static inline int ipa_in_net_ip4(ip4_addr a, const net_addr_ip4 *n) { return ipa_in_px4(a, n->prefix, n->pxlen); } static inline int ipa_in_net_ip6(ip6_addr a, const net_addr_ip6 *n) { return ipa_in_px6(a, n->prefix, n->pxlen); } static inline int net_in_net_ip4(const net_addr_ip4 *a, const net_addr_ip4 *b) { return (a->pxlen >= b->pxlen) && ipa_in_px4(a->prefix, b->prefix, b->pxlen); } static inline int net_in_net_ip6(const net_addr_ip6 *a, const net_addr_ip6 *b) { return (a->pxlen >= b->pxlen) && ipa_in_px6(a->prefix, b->prefix, b->pxlen); } static inline int net_in_net_dst_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return (a->dst_pxlen >= b->dst_pxlen) && ipa_in_px6(a->dst_prefix, b->dst_prefix, b->dst_pxlen); } static inline int net_in_net_src_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_ip6_sadr *b) { return (a->src_pxlen >= b->src_pxlen) && ipa_in_px6(a->src_prefix, b->src_prefix, b->src_pxlen); } int ipa_in_netX(const ip_addr A, const net_addr *N); int net_in_netX(const net_addr *A, const net_addr *N); void net_init(void); #endif bird-2.0.8/lib/net.c0000664000175000017500000002166314025744326013074 0ustar feelafeela #include "nest/bird.h" #include "lib/ip.h" #include "lib/net.h" #include "lib/flowspec.h" const char * const net_label[] = { [NET_IP4] = "ipv4", [NET_IP6] = "ipv6", [NET_VPN4] = "vpn4", [NET_VPN6] = "vpn6", [NET_ROA4] = "roa4", [NET_ROA6] = "roa6", [NET_FLOW4] = "flow4", [NET_FLOW6] = "flow6", [NET_IP6_SADR]= "ipv6-sadr", [NET_MPLS] = "mpls", }; const u16 net_addr_length[] = { [NET_IP4] = sizeof(net_addr_ip4), [NET_IP6] = sizeof(net_addr_ip6), [NET_VPN4] = sizeof(net_addr_vpn4), [NET_VPN6] = sizeof(net_addr_vpn6), [NET_ROA4] = sizeof(net_addr_roa4), [NET_ROA6] = sizeof(net_addr_roa6), [NET_FLOW4] = 0, [NET_FLOW6] = 0, [NET_IP6_SADR]= sizeof(net_addr_ip6_sadr), [NET_MPLS] = sizeof(net_addr_mpls), }; const u8 net_max_prefix_length[] = { [NET_IP4] = IP4_MAX_PREFIX_LENGTH, [NET_IP6] = IP6_MAX_PREFIX_LENGTH, [NET_VPN4] = IP4_MAX_PREFIX_LENGTH, [NET_VPN6] = IP6_MAX_PREFIX_LENGTH, [NET_ROA4] = IP4_MAX_PREFIX_LENGTH, [NET_ROA6] = IP6_MAX_PREFIX_LENGTH, [NET_FLOW4] = IP4_MAX_PREFIX_LENGTH, [NET_FLOW6] = IP6_MAX_PREFIX_LENGTH, [NET_IP6_SADR]= IP6_MAX_PREFIX_LENGTH, [NET_MPLS] = 0, }; const u16 net_max_text_length[] = { [NET_IP4] = 18, /* "255.255.255.255/32" */ [NET_IP6] = 43, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */ [NET_VPN4] = 40, /* "4294967296:4294967296 255.255.255.255/32" */ [NET_VPN6] = 65, /* "4294967296:4294967296 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */ [NET_ROA4] = 34, /* "255.255.255.255/32-32 AS4294967295" */ [NET_ROA6] = 60, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128-128 AS4294967295" */ [NET_FLOW4] = 0, /* "flow4 { ... }" */ [NET_FLOW6] = 0, /* "flow6 { ... }" */ [NET_IP6_SADR]= 92, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128 from ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */ [NET_MPLS] = 7, /* "1048575" */ }; int rd_format(const u64 rd, char *buf, int buflen) { switch (rd >> 48) { case 0: return bsnprintf(buf, buflen, "%u:%u", (u32) (rd >> 32), (u32) rd); case 1: return bsnprintf(buf, buflen, "%I4:%u", ip4_from_u32(rd >> 16), (u32) (rd & 0xffff)); case 2: if (((u32) (rd >> 16)) >> 16) return bsnprintf(buf, buflen, "%u:%u", (u32) (rd >> 16), (u32) (rd & 0xffff)); else return bsnprintf(buf, buflen, "2:%u:%u", (u32) (rd >> 16), (u32) (rd & 0xffff)); default: return bsnprintf(buf, buflen, "X:%08x:%08x", (u32) (rd >> 32), (u32) rd); } } int net_format(const net_addr *N, char *buf, int buflen) { net_addr_union *n = (void *) N; buf[0] = 0; switch (n->n.type) { case NET_IP4: return bsnprintf(buf, buflen, "%I4/%d", n->ip4.prefix, n->ip4.pxlen); case NET_IP6: return bsnprintf(buf, buflen, "%I6/%d", n->ip6.prefix, n->ip6.pxlen); case NET_VPN4: { int c = rd_format(n->vpn4.rd, buf, buflen); ADVANCE(buf, buflen, c); return bsnprintf(buf, buflen, " %I4/%d", n->vpn4.prefix, n->vpn4.pxlen); } case NET_VPN6: { /* XXX: RD format is specified for VPN4; not found any for VPN6, reusing the same as for VPN4 */ int c = rd_format(n->vpn6.rd, buf, buflen); ADVANCE(buf, buflen, c); return bsnprintf(buf, buflen, " %I6/%d", n->vpn6.prefix, n->vpn6.pxlen); } case NET_ROA4: return bsnprintf(buf, buflen, "%I4/%u-%u AS%u", n->roa4.prefix, n->roa4.pxlen, n->roa4.max_pxlen, n->roa4.asn); case NET_ROA6: return bsnprintf(buf, buflen, "%I6/%u-%u AS%u", n->roa6.prefix, n->roa6.pxlen, n->roa6.max_pxlen, n->roa6.asn); case NET_FLOW4: return flow4_net_format(buf, buflen, &n->flow4); case NET_FLOW6: return flow6_net_format(buf, buflen, &n->flow6); case NET_IP6_SADR: return bsnprintf(buf, buflen, "%I6/%d from %I6/%d", n->ip6_sadr.dst_prefix, n->ip6_sadr.dst_pxlen, n->ip6_sadr.src_prefix, n->ip6_sadr.src_pxlen); case NET_MPLS: return bsnprintf(buf, buflen, "%u", n->mpls.label); } bug("unknown network type"); } ip_addr net_pxmask(const net_addr *a) { switch (a->type) { case NET_IP4: case NET_VPN4: case NET_ROA4: case NET_FLOW4: return ipa_from_ip4(ip4_mkmask(net4_pxlen(a))); case NET_IP6: case NET_VPN6: case NET_ROA6: case NET_FLOW6: case NET_IP6_SADR: return ipa_from_ip6(ip6_mkmask(net6_pxlen(a))); case NET_MPLS: default: return IPA_NONE; } } int net_compare(const net_addr *a, const net_addr *b) { if (a->type != b->type) return uint_cmp(a->type, b->type); switch (a->type) { case NET_IP4: return net_compare_ip4((const net_addr_ip4 *) a, (const net_addr_ip4 *) b); case NET_IP6: return net_compare_ip6((const net_addr_ip6 *) a, (const net_addr_ip6 *) b); case NET_VPN4: return net_compare_vpn4((const net_addr_vpn4 *) a, (const net_addr_vpn4 *) b); case NET_VPN6: return net_compare_vpn6((const net_addr_vpn6 *) a, (const net_addr_vpn6 *) b); case NET_ROA4: return net_compare_roa4((const net_addr_roa4 *) a, (const net_addr_roa4 *) b); case NET_ROA6: return net_compare_roa6((const net_addr_roa6 *) a, (const net_addr_roa6 *) b); case NET_FLOW4: return net_compare_flow4((const net_addr_flow4 *) a, (const net_addr_flow4 *) b); case NET_FLOW6: return net_compare_flow6((const net_addr_flow6 *) a, (const net_addr_flow6 *) b); case NET_IP6_SADR: return net_compare_ip6_sadr((const net_addr_ip6_sadr *) a, (const net_addr_ip6_sadr *) b); case NET_MPLS: return net_compare_mpls((const net_addr_mpls *) a, (const net_addr_mpls *) b); } return 0; } #define NET_HASH(a,t) net_hash_##t((const net_addr_##t *) a) u32 net_hash(const net_addr *n) { switch (n->type) { case NET_IP4: return NET_HASH(n, ip4); case NET_IP6: return NET_HASH(n, ip6); case NET_VPN4: return NET_HASH(n, vpn4); case NET_VPN6: return NET_HASH(n, vpn6); case NET_ROA4: return NET_HASH(n, roa4); case NET_ROA6: return NET_HASH(n, roa6); case NET_FLOW4: return NET_HASH(n, flow4); case NET_FLOW6: return NET_HASH(n, flow6); case NET_IP6_SADR: return NET_HASH(n, ip6_sadr); case NET_MPLS: return NET_HASH(n, mpls); default: bug("invalid type"); } } #define NET_VALIDATE(a,t) net_validate_##t((const net_addr_##t *) a) int net_validate(const net_addr *n) { switch (n->type) { case NET_IP4: return NET_VALIDATE(n, ip4); case NET_IP6: return NET_VALIDATE(n, ip6); case NET_VPN4: return NET_VALIDATE(n, vpn4); case NET_VPN6: return NET_VALIDATE(n, vpn6); case NET_ROA4: return NET_VALIDATE(n, roa4); case NET_ROA6: return NET_VALIDATE(n, roa6); case NET_FLOW4: return NET_VALIDATE(n, flow4); case NET_FLOW6: return NET_VALIDATE(n, flow6); case NET_IP6_SADR: return NET_VALIDATE(n, ip6_sadr); case NET_MPLS: return NET_VALIDATE(n, mpls); default: return 0; } } void net_normalize(net_addr *N) { net_addr_union *n = (void *) N; switch (n->n.type) { case NET_IP4: case NET_VPN4: case NET_ROA4: case NET_FLOW4: return net_normalize_ip4(&n->ip4); case NET_IP6: case NET_VPN6: case NET_ROA6: case NET_FLOW6: return net_normalize_ip6(&n->ip6); case NET_IP6_SADR: return net_normalize_ip6_sadr(&n->ip6_sadr); case NET_MPLS: return; } } int net_classify(const net_addr *N) { net_addr_union *n = (void *) N; switch (n->n.type) { case NET_IP4: case NET_VPN4: case NET_ROA4: case NET_FLOW4: return ip4_zero(n->ip4.prefix) ? (IADDR_HOST | SCOPE_UNIVERSE) : ip4_classify(n->ip4.prefix); case NET_IP6: case NET_VPN6: case NET_ROA6: case NET_FLOW6: return ip6_zero(n->ip6.prefix) ? (IADDR_HOST | SCOPE_UNIVERSE) : ip6_classify(&n->ip6.prefix); case NET_IP6_SADR: return ip6_zero(n->ip6_sadr.dst_prefix) ? (IADDR_HOST | SCOPE_UNIVERSE) : ip6_classify(&n->ip6_sadr.dst_prefix); case NET_MPLS: return IADDR_HOST | SCOPE_UNIVERSE; } return IADDR_INVALID; } int ipa_in_netX(const ip_addr a, const net_addr *n) { switch (n->type) { case NET_IP4: case NET_VPN4: case NET_ROA4: case NET_FLOW4: if (!ipa_is_ip4(a)) return 0; return ip4_zero(ip4_and(ip4_xor(ipa_to_ip4(a), net4_prefix(n)), ip4_mkmask(net4_pxlen(n)))); case NET_IP6: case NET_VPN6: case NET_ROA6: case NET_FLOW6: if (ipa_is_ip4(a)) return 0; return ip6_zero(ip6_and(ip6_xor(ipa_to_ip6(a), net6_prefix(n)), ip6_mkmask(net6_pxlen(n)))); case NET_IP6_SADR: if (ipa_is_ip4(a)) return 0; return ip6_zero(ip6_and(ip6_xor(ipa_to_ip6(a), net6_prefix(n)), ip6_mkmask(net6_pxlen(n)))); case NET_MPLS: default: return 0; } } int net_in_netX(const net_addr *a, const net_addr *n) { if (a->type != n->type) return 0; return (net_pxlen(n) <= net_pxlen(a)) && ipa_in_netX(net_prefix(a), n); } #define CHECK_NET(T,S) \ ({ if (sizeof(T) != S) die("sizeof %s is %d/%d", #T, (int) sizeof(T), S); }) void net_init(void) { CHECK_NET(net_addr, 24); CHECK_NET(net_addr_ip4, 8); CHECK_NET(net_addr_ip6, 20); CHECK_NET(net_addr_vpn4, 16); CHECK_NET(net_addr_vpn6, 32); CHECK_NET(net_addr_roa4, 16); CHECK_NET(net_addr_roa6, 28); CHECK_NET(net_addr_flow4, 8); CHECK_NET(net_addr_flow6, 20); CHECK_NET(net_addr_ip6_sadr, 40); CHECK_NET(net_addr_mpls, 8); } bird-2.0.8/lib/mempool.c0000664000175000017500000001617614025744326013761 0ustar feelafeela/* * BIRD Resource Manager -- Memory Pools * * (c) 1998--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Linear memory pools * * Linear memory pools are collections of memory blocks which * support very fast allocation of new blocks, but are able to free only * the whole collection at once (or in stack order). * * Example: Each configuration is described by a complex system of structures, * linked lists and function trees which are all allocated from a single linear * pool, thus they can be freed at once when the configuration is no longer used. */ #include #include #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" struct lp_chunk { struct lp_chunk *next; uint size; uintptr_t data_align[0]; byte data[0]; }; const int lp_chunk_size = sizeof(struct lp_chunk); struct linpool { resource r; byte *ptr, *end; struct lp_chunk *first, *current; /* Normal (reusable) chunks */ struct lp_chunk *first_large; /* Large chunks */ uint chunk_size, threshold, total, total_large; }; static void lp_free(resource *); static void lp_dump(resource *); static resource *lp_lookup(resource *, unsigned long); static size_t lp_memsize(resource *r); static struct resclass lp_class = { "LinPool", sizeof(struct linpool), lp_free, lp_dump, lp_lookup, lp_memsize }; /** * lp_new - create a new linear memory pool * @p: pool * @blk: block size * * lp_new() creates a new linear memory pool resource inside the pool @p. * The linear pool consists of a list of memory chunks of size at least * @blk. */ linpool *lp_new(pool *p, uint blk) { linpool *m = ralloc(p, &lp_class); m->chunk_size = blk; m->threshold = 3*blk/4; return m; } /** * lp_alloc - allocate memory from a &linpool * @m: linear memory pool * @size: amount of memory * * lp_alloc() allocates @size bytes of memory from a &linpool @m * and it returns a pointer to the allocated memory. * * It works by trying to find free space in the last memory chunk * associated with the &linpool and creating a new chunk of the standard * size (as specified during lp_new()) if the free space is too small * to satisfy the allocation. If @size is too large to fit in a standard * size chunk, an "overflow" chunk is created for it instead. */ void * lp_alloc(linpool *m, uint size) { byte *a = (byte *) BIRD_ALIGN((unsigned long) m->ptr, CPU_STRUCT_ALIGN); byte *e = a + size; if (e <= m->end) { m->ptr = e; return a; } else { struct lp_chunk *c; if (size >= m->threshold) { /* Too large => allocate large chunk */ c = xmalloc(sizeof(struct lp_chunk) + size); m->total_large += size; c->next = m->first_large; m->first_large = c; c->size = size; } else { if (m->current && m->current->next) { /* Still have free chunks from previous incarnation (before lp_flush()) */ c = m->current->next; } else { /* Need to allocate a new chunk */ c = xmalloc(sizeof(struct lp_chunk) + m->chunk_size); m->total += m->chunk_size; c->next = NULL; c->size = m->chunk_size; if (m->current) m->current->next = c; else m->first = c; } m->current = c; m->ptr = c->data + size; m->end = c->data + m->chunk_size; } return c->data; } } /** * lp_allocu - allocate unaligned memory from a &linpool * @m: linear memory pool * @size: amount of memory * * lp_allocu() allocates @size bytes of memory from a &linpool @m * and it returns a pointer to the allocated memory. It doesn't * attempt to align the memory block, giving a very efficient way * how to allocate strings without any space overhead. */ void * lp_allocu(linpool *m, uint size) { byte *a = m->ptr; byte *e = a + size; if (e <= m->end) { m->ptr = e; return a; } return lp_alloc(m, size); } /** * lp_allocz - allocate cleared memory from a &linpool * @m: linear memory pool * @size: amount of memory * * This function is identical to lp_alloc() except that it * clears the allocated memory block. */ void * lp_allocz(linpool *m, uint size) { void *z = lp_alloc(m, size); bzero(z, size); return z; } /** * lp_flush - flush a linear memory pool * @m: linear memory pool * * This function frees the whole contents of the given &linpool @m, * but leaves the pool itself. */ void lp_flush(linpool *m) { struct lp_chunk *c; /* Move ptr to the first chunk and free all large chunks */ m->current = c = m->first; m->ptr = c ? c->data : NULL; m->end = c ? c->data + m->chunk_size : NULL; while (c = m->first_large) { m->first_large = c->next; xfree(c); } m->total_large = 0; } /** * lp_save - save the state of a linear memory pool * @m: linear memory pool * @p: state buffer * * This function saves the state of a linear memory pool. Saved state can be * used later to restore the pool (to free memory allocated since). */ void lp_save(linpool *m, lp_state *p) { p->current = m->current; p->large = m->first_large; p->ptr = m->ptr; } /** * lp_restore - restore the state of a linear memory pool * @m: linear memory pool * @p: saved state * * This function restores the state of a linear memory pool, freeing all memory * allocated since the state was saved. Note that the function cannot un-free * the memory, therefore the function also invalidates other states that were * saved between (on the same pool). */ void lp_restore(linpool *m, lp_state *p) { struct lp_chunk *c; /* Move ptr to the saved pos and free all newer large chunks */ m->current = c = p->current; m->ptr = p->ptr; m->end = c ? c->data + m->chunk_size : NULL; while ((c = m->first_large) && (c != p->large)) { m->first_large = c->next; m->total_large -= c->size; xfree(c); } } static void lp_free(resource *r) { linpool *m = (linpool *) r; struct lp_chunk *c, *d; for(d=m->first; d; d = c) { c = d->next; xfree(d); } for(d=m->first_large; d; d = c) { c = d->next; xfree(d); } } static void lp_dump(resource *r) { linpool *m = (linpool *) r; struct lp_chunk *c; int cnt, cntl; for(cnt=0, c=m->first; c; c=c->next, cnt++) ; for(cntl=0, c=m->first_large; c; c=c->next, cntl++) ; debug("(chunk=%d threshold=%d count=%d+%d total=%d+%d)\n", m->chunk_size, m->threshold, cnt, cntl, m->total, m->total_large); } static size_t lp_memsize(resource *r) { linpool *m = (linpool *) r; struct lp_chunk *c; int cnt = 0; for(c=m->first; c; c=c->next) cnt++; for(c=m->first_large; c; c=c->next) cnt++; return ALLOC_OVERHEAD + sizeof(struct linpool) + cnt * (ALLOC_OVERHEAD + sizeof(struct lp_chunk)) + m->total + m->total_large; } static resource * lp_lookup(resource *r, unsigned long a) { linpool *m = (linpool *) r; struct lp_chunk *c; for(c=m->first; c; c=c->next) if ((unsigned long) c->data <= a && (unsigned long) c->data + c->size > a) return r; for(c=m->first_large; c; c=c->next) if ((unsigned long) c->data <= a && (unsigned long) c->data + c->size > a) return r; return NULL; } bird-2.0.8/lib/md5.h0000664000175000017500000000117714025744326012776 0ustar feelafeela/* * BIRD Library -- MD5 Hash Function and HMAC-MD5 Function * * (c) 2015 CZ.NIC z.s.p.o. * * Adapted for BIRD by Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_MD5_H_ #define _BIRD_MD5_H_ #include "nest/bird.h" #define MD5_SIZE 16 #define MD5_HEX_SIZE 33 #define MD5_BLOCK_SIZE 64 struct hash_context; struct md5_context { u32 buf[4]; u32 bits[2]; byte in[64]; }; void md5_init(struct hash_context *ctx); void md5_update(struct hash_context *ctx, const byte *buf, uint len); byte *md5_final(struct hash_context *ctx); #endif /* _BIRD_MD5_H_ */ bird-2.0.8/lib/md5.c0000664000175000017500000001637314025744326012775 0ustar feelafeela/* * BIRD Library -- MD5 Hash Function and HMAC-MD5 Function * * (c) 2015 CZ.NIC z.s.p.o. * * The code was written by Colin Plumb in 1993, no copyright is claimed. * * Adapted for BIRD by Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/md5.h" #ifdef CPU_LITTLE_ENDIAN #define byteReverse(buf, len) /* Nothing */ #else void byteReverse(byte *buf, uint longs); /* * Note: this code is harmless on little-endian machines. */ void byteReverse(byte *buf, uint longs) { u32 t; do { t = (u32) ((uint) buf[3] << 8 | buf[2]) << 16 | ((uint) buf[1] << 8 | buf[0]); *(u32 *) buf = t; buf += 4; } while (--longs); } #endif static void md5_transform(u32 buf[4], u32 const in[16]); /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void md5_init(struct hash_context *CTX) { struct md5_context *ctx = (void *) CTX; ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bits[0] = 0; ctx->bits[1] = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void md5_update(struct hash_context *CTX, const byte *buf, uint len) { struct md5_context *ctx = (void *) CTX; u32 t; /* Update bitcount */ t = ctx->bits[0]; if ((ctx->bits[0] = t + ((u32) len << 3)) < t) ctx->bits[1]++; /* Carry from low to high */ ctx->bits[1] += len >> 29; t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ /* Handle any leading odd-sized chunks */ if (t) { byte *p = (byte *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); byteReverse(ctx->in, 16); md5_transform(ctx->buf, (u32 *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); md5_transform(ctx->buf, (u32 *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ byte * md5_final(struct hash_context *CTX) { struct md5_context *ctx = (void *) CTX; uint count; byte *p; /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ p = ctx->in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); md5_transform(ctx->buf, (u32 *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((u32 *) ctx->in)[14] = ctx->bits[0]; ((u32 *) ctx->in)[15] = ctx->bits[1]; md5_transform(ctx->buf, (u32 *) ctx->in); byteReverse((byte *) ctx->buf, 4); return (byte*) ctx->buf; } /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ void md5_transform(u32 buf[4], u32 const in[16]) { register u32 a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } bird-2.0.8/lib/macro.h0000664000175000017500000000710414025744326013406 0ustar feelafeela/* * BIRD Macro Tricks * * (c) 2018 Jan Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. * * Contains useful but dirty macro tricks: * MACRO_CONCAT(a, b) -> concatenates a##b * MACRO_BOOL(x) -> convert 0 to 0, anything else to 1 * MACRO_IFELSE(b)(true-branch)(false-branch) * -> b shall be 0 or 1; expands to the appropriate branch * MACRO_ISEMPTY(...) -> 1 for empty argument list, 0 otherwise * MACRO_FOREACH(func, ...) * -> calling FOREACH(func, a, b, c, d) expands to * func(a) func(b) func(c) func(d) * MACRO_RPACK(func, terminator, ...) * -> packs the list into recursive calls: * func(func(func(func(terminator, a), b), c), d) */ #ifndef _BIRD_MACRO_H_ #define _BIRD_MACRO_H_ /* What to do with args */ #define MACRO_DROP(...) #define MACRO_UNPAREN(...) __VA_ARGS__ #define MACRO_SEP(a, b, sep) a sep b /* Aliases for some special chars */ #define MACRO_COMMA , #define MACRO_LPAREN ( #define MACRO_RPAREN ) #define MACRO_LPAREN_() ( #define MACRO_RPAREN_() ) /* Multiple expansion trick */ #define MACRO_EXPAND0(...) __VA_ARGS__ #define MACRO_EXPAND1(...) MACRO_EXPAND0(MACRO_EXPAND0(__VA_ARGS__)) #define MACRO_EXPAND2(...) MACRO_EXPAND1(MACRO_EXPAND1(__VA_ARGS__)) #define MACRO_EXPAND3(...) MACRO_EXPAND2(MACRO_EXPAND2(__VA_ARGS__)) #define MACRO_EXPAND(...) MACRO_EXPAND3(MACRO_EXPAND3(__VA_ARGS__)) /* Deferring expansion in the expansion trick */ #define MACRO_EMPTY() #define MACRO_DEFER(t) t MACRO_EMPTY() #define MACRO_DEFER2(t) t MACRO_EMPTY MACRO_EMPTY()() #define MACRO_DEFER3(t) t MACRO_EMPTY MACRO_EMPTY MACRO_EMPTY()()() /* Token concatenation */ #define MACRO_CONCAT(prefix, ...) prefix##__VA_ARGS__ #define MACRO_CONCAT_AFTER(...) MACRO_CONCAT(__VA_ARGS__) /* Get first or second argument only */ #define MACRO_FIRST(a, ...) a #define MACRO_SECOND(a, b, ...) b #define MACRO_SECOND_OR_ZERO(...) MACRO_SECOND(__VA_ARGS__, 0,) /* Macro Boolean auxiliary macros */ #define MACRO_BOOL_CHECK_0 ~, 1 #define MACRO_BOOL_NEG(x) MACRO_SECOND_OR_ZERO(MACRO_CONCAT(MACRO_BOOL_CHECK_, x)) #define MACRO_BOOL_NOT_0 1 #define MACRO_BOOL_NOT_1 0 /* Macro Boolean negation */ #define MACRO_NOT(x) MACRO_CONCAT(MACRO_BOOL_NOT_, x) /* Convert anything to bool (anything -> 1, 0 -> 0) */ #define MACRO_BOOL(x) MACRO_NOT(MACRO_BOOL_NEG(x)) /* * Macro If/Else condition * Usage: MACRO_IFELSE(condition)(true-branch)(false-branch) * Expands to true-branch if condition is true, otherwise to false-branch. */ #define MACRO_IFELSE(b) MACRO_CONCAT(MACRO_IFELSE_, b) #define MACRO_IFELSE_0(...) MACRO_UNPAREN #define MACRO_IFELSE_1(...) __VA_ARGS__ MACRO_DROP /* Auxiliary macros for MACRO_FOREACH */ #define MACRO_ISLAST(...) MACRO_BOOL_NEG(MACRO_FIRST(MACRO_ISLAST_CHECK __VA_ARGS__)()) #define MACRO_ISLAST_CHECK() 0 #define MACRO_FOREACH_EXPAND(call, a, ...) MACRO_IFELSE(MACRO_ISLAST(__VA_ARGS__))(call(a))(call(a) MACRO_DEFER2(MACRO_FOREACH_PAREN)()(call, __VA_ARGS__)) #define MACRO_FOREACH_PAREN() MACRO_FOREACH_EXPAND #define MACRO_RPACK_EXPAND(call, terminator, a, ...) MACRO_IFELSE(MACRO_ISLAST(__VA_ARGS__))(call(terminator, a))(call(MACRO_DEFER2(MACRO_RPACK_PAREN)()(call, terminator, __VA_ARGS__), a)) #define MACRO_RPACK_PAREN() MACRO_RPACK_EXPAND /* * Call the first argument for each following: * MACRO_FOREACH(func, a, b, c, d) expands to func(a) func(b) func(c) func(d). * It supports also macros as func. */ #define MACRO_FOREACH(call, ...) MACRO_EXPAND(MACRO_FOREACH_EXPAND(call, __VA_ARGS__)) #define MACRO_RPACK(call, terminator, ...) MACRO_EXPAND(MACRO_RPACK_EXPAND(call, terminator, __VA_ARGS__)) #endif bird-2.0.8/lib/mac_test.c0000664000175000017500000011600314025744326014076 0ustar feelafeela/* * BIRD Library -- SHA and HMAC-SHA functions tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" #include "lib/mac.h" #define define_test_hash_fn(name,id) \ static int \ test_##name(void *out_, const void *in_, const void *expected_out_) \ { \ char *out = out_; \ const char *in = in_; \ const char *expected_out = expected_out_; \ \ struct mac_context ctx; \ mac_init(&ctx, id, NULL, 0); \ mac_update(&ctx, in, strlen(in)); \ byte *out_bin = mac_final(&ctx); \ \ uint len = mac_type_length(id); \ bt_bytes_to_hex(out, out_bin, len); \ \ return strncmp(out, expected_out, 2*len+1) == 0; \ } define_test_hash_fn(md5, ALG_MD5) define_test_hash_fn(sha1, ALG_SHA1) define_test_hash_fn(sha224, ALG_SHA224) define_test_hash_fn(sha256, ALG_SHA256) define_test_hash_fn(sha384, ALG_SHA384) define_test_hash_fn(sha512, ALG_SHA512) static int t_md5(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "d41d8cd98f00b204e9800998ecf8427e", }, { .in = "a", .out = "0cc175b9c0f1b6a831c399e269772661", }, { .in = "abc", .out = "900150983cd24fb0d6963f7d28e17f72", }, { .in = "message digest", .out = "f96b697d7cb7938d525a2f31aaf161d0", }, { .in = "abcdefghijklmnopqrstuvwxyz", .out = "c3fcd3d76192e4007dfb496cca67e13b", }, { .in = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", .out = "d174ab98d277d9f5a5611c2c9f419d9f", }, { .in = "12345678901234567890123456789012345678901234567890123456789012345678901234567890", .out = "57edf4a22be3c955ac49da2e2107b67a", }, }; return bt_assert_batch(test_vectors, test_md5, bt_fmt_str, bt_fmt_str); } /* * Testing SHAxxx functions */ static int t_sha1(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "da39a3ee5e6b4b0d3255bfef95601890afd80709", }, { .in = "a", .out = "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8", }, { .in = "abc", .out = "a9993e364706816aba3e25717850c26c9cd0d89d", }, { .in = "message digest", .out = "c12252ceda8be8994d5fa0290a47231c1d16aae3", }, { .in = "abcdefghijklmnopqrstuvwxyz", .out = "32d10c7b8cf96570ca04ce37f2a19d84240d3a89", }, { .in = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", .out = "761c457bf73b14d27e9e9265c46f4b4dda11f940", }, { .in = "12345678901234567890123456789012345678901234567890123456789012345678901234567890", .out = "50abf5706a150990a08b2c5ea40fa0e585554732", }, { .in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", .out = "6a64fcc1fb970f7339ce886601775d2efea5cd4b", }, }; return bt_assert_batch(test_vectors, test_sha1, bt_fmt_str, bt_fmt_str); } static int t_sha224(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f", }, { .in = "a", .out = "abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5", }, { .in = "abc", .out = "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7", }, { .in = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", .out = "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525", }, { .in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", .out = "cca7dd1a332a17775d8b0429bdb45055c2d4368ebaab0c7cf385586e", }, }; return bt_assert_batch(test_vectors, test_sha224, bt_fmt_str, bt_fmt_str); } static int t_sha256(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", }, { .in = "a", .out = "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", }, { .in = "abc", .out = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", }, { .in = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", .out = "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1", }, { .in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", .out = "bf18b43b61652b5d73f41ebf3d72e5e43aebf5076f497dde31ea3de9de4998ef", }, }; return bt_assert_batch(test_vectors, test_sha256, bt_fmt_str, bt_fmt_str); } static int t_sha384(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b", }, { .in = "a", .out = "54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31", }, { .in = "abc", .out = "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7", }, { .in = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", .out = "3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b", }, { .in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", .out = "6452928a62ca915a60f2d16ea22cc832d8ecb35443d78a3ff6986e7def9174a1dc16ce2ff65d3ed1666db98357f3c05e", }, }; return bt_assert_batch(test_vectors, test_sha384, bt_fmt_str, bt_fmt_str); } static int t_sha512(void) { struct bt_pair test_vectors[] = { { .in = "", .out = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e", }, { .in = "a", .out = "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75", }, { .in = "abc", .out = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f", }, { .in = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", .out = "204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445", }, { .in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", .out = "415509a1c345371acb3e27a88b3835e3b6dfebcbbab5134850596f4db64d7bb22ac42c3cd179446a80c92b8be955460eb536eac01389a7e1fdf09d1dca83922f", }, }; return bt_assert_batch(test_vectors, test_sha512, bt_fmt_str, bt_fmt_str); } /* * Testing SHAxxx HMAC functions */ #define HMAC_BUFFER_SIZE 160 struct hmac_data_in { byte key[HMAC_BUFFER_SIZE]; uint key_len; byte data[HMAC_BUFFER_SIZE]; uint data_len; }; static void hmac_in_fmt(char *buf, size_t size, const void *data_) { uint i; const struct hmac_data_in *data = data_; snprintf(buf, size, "data: '"); for (i = 0; i < data->data_len; i++) snprintf(buf+strlen(buf), size-strlen(buf), bt_is_char(data->data[i]) ? "%c" : " 0x%02x", data->data[i]); snprintf(buf+strlen(buf), size-strlen(buf), "', key: '"); for (i = 0; i < data->key_len; i++) snprintf(buf+strlen(buf), size-strlen(buf), bt_is_char(data->key[i]) ? "%c" : " 0x%02x", data->key[i]); snprintf(buf+strlen(buf), size-strlen(buf), "'"); } #define define_test_hmac_fn(name,id) \ static int \ test_##name##_hmac(void *out_, const void *in_, const void *expected_out_) \ { \ char *out = out_; \ const struct hmac_data_in *in = in_; \ const char *expected_out = expected_out_; \ \ struct mac_context ctx; \ mac_init(&ctx, id, in->key, in->key_len); \ mac_update(&ctx, in->data, in->data_len); \ byte *out_bin = mac_final(&ctx); \ \ uint len = mac_type_length(id); \ bt_bytes_to_hex(out, out_bin, len); \ \ return strncmp(out, expected_out, 2*len+1) == 0; \ } define_test_hmac_fn(md5, ALG_HMAC_MD5) define_test_hmac_fn(sha1, ALG_HMAC_SHA1) define_test_hmac_fn(sha224, ALG_HMAC_SHA224) define_test_hmac_fn(sha256, ALG_HMAC_SHA256) define_test_hmac_fn(sha384, ALG_HMAC_SHA384) define_test_hmac_fn(sha512, ALG_HMAC_SHA512) static int t_md5_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 16, .data = "Hi There", .data_len = 8, }, .out = "9294727a3638bb1c13f48ef8158bfc9d", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "750c783e6ab0b503eaa86e310a5db738", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 16, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "56be34521d144c88dbb8c733f0e8b3f6", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "697eaf0aca3a3aea3a75164746ffaa79", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 16, .data = "Test With Truncation", .data_len = 20, }, .out = "56461ef2342edc00f9bab995690efd4c", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 80, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 80, .data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", .data_len = 73, }, .out = "6f630fad67cda0ee1fb1f562db3aa53e", }, }; return bt_assert_batch(test_vectors, test_md5_hmac, hmac_in_fmt, bt_fmt_str); } static int t_sha1_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 20, .data = "Hi There", .data_len = 8, }, .out = "b617318655057264e28bc0b6fb378c8ef146be00", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 20, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "125d7342b9ac11cd91a39af48aa17b4f63f175d3", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "4c9007f4026250c6bc8414f9bf50c86c2d7235da", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 20, .data = "Test With Truncation", .data_len = 20, }, .out = "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 80, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "aa4ae5e15272d00e95705637ce8a3b55ed402112", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 80, .data = "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", .data_len = 73, }, .out = "e8e99d0f45237d786d6bbaa7965c7808bbff1a91", }, { .in = & (struct hmac_data_in) { .key = { 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, }, .key_len = 64, .data = "Test Using key 64 bytes sized", .data_len = 29, }, .out = "a55d4fb80962a6b3d2e720705314bee417d68cf6", }, }; return bt_assert_batch(test_vectors, test_sha1_hmac, hmac_in_fmt, bt_fmt_str); } static int t_sha224_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 20, .data = "Hi There", .data_len = 8, }, .out = "896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 20, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 20, .data = "Test With Truncation", .data_len = 20, }, .out = "0e2aea68a90c8d37c988bcdb9fca6fa8099cd857c7ec4a1815cac54c", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", .data_len = 152, }, .out = "3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1", }, }; return bt_assert_batch(test_vectors, test_sha224_hmac, hmac_in_fmt, bt_fmt_str); } static int t_sha256_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 20, .data = "Hi There", .data_len = 8, }, .out = "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 20, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 20, .data = "Test With Truncation", .data_len = 20, }, .out = "a3b6167473100ee06e0c796c2955552bfa6f7c0a6a8aef8b93f860aab0cd20c5", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", .data_len = 152, }, .out = "9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2", }, }; return bt_assert_batch(test_vectors, test_sha256_hmac, hmac_in_fmt, bt_fmt_str); } static int t_sha384_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 20, .data = "Hi There", .data_len = 8, }, .out = "afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 20, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 20, .data = "Test With Truncation", .data_len = 20, }, .out = "3abf34c3503b2a23a46efc619baef897f4c8e42c934ce55ccbae9740fcbc1af4ca62269e2a37cd88ba926341efe4aeea", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", .data_len = 152, }, .out = "6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e", }, }; return bt_assert_batch(test_vectors, test_sha384_hmac, hmac_in_fmt, bt_fmt_str); } static int t_sha512_hmac(void) { struct bt_pair test_vectors[] = { { .in = & (struct hmac_data_in) { .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, }, .key_len = 20, .data = "Hi There", .data_len = 8, }, .out = "87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854", }, { .in = & (struct hmac_data_in) { .key = "Jefe", .key_len = 4, .data = "what do ya want for nothing?", .data_len = 28, }, .out = "164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 20, .data = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, }, .data_len = 50, }, .out = "fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb", }, { .in = & (struct hmac_data_in) { .key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, }, .key_len = 25, .data = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, }, .data_len = 50, }, .out = "b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd", }, { .in = & (struct hmac_data_in) { .key = { 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, }, .key_len = 20, .data = "Test With Truncation", .data_len = 20, }, .out = "415fad6271580a531d4179bc891d87a650188707922a4fbb36663a1eb16da008711c5b50ddd0fc235084eb9d3364a1454fb2ef67cd1d29fe6773068ea266e96b", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "Test Using Larger Than Block-Size Key - Hash Key First", .data_len = 54, }, .out = "80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598", }, { .in = & (struct hmac_data_in) { .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }, .key_len = 131, .data = "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", .data_len = 152, }, .out = "e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58", }, }; return bt_assert_batch(test_vectors, test_sha512_hmac, hmac_in_fmt, bt_fmt_str); } /* * Testing SHAxxx concating independence */ #include "lib/sha256.h" #include "lib/sha512.h" static int t_sha256_concating(void) { char hash_a[SHA256_HEX_SIZE]; char hash_b[SHA256_HEX_SIZE]; char *str_a = "a" "bb" "ccc" "dddd" "eeeee" "ffffff"; char *str_b1 = "a" ; char *str_b2 = "bb" ; char *str_b3 = "ccc" ; char *str_b4 = "dddd" ; char *str_b5 = "eeeee" ; char *str_b6 = "ffffff"; struct hash_context ctx_a; sha256_init(&ctx_a); sha256_update(&ctx_a, str_a, strlen(str_a)); byte *hash_a_ = sha256_final(&ctx_a); bt_bytes_to_hex(hash_a, hash_a_, SHA256_SIZE); struct hash_context ctx_b; sha256_init(&ctx_b); sha256_update(&ctx_b, str_b1, strlen(str_b1)); sha256_update(&ctx_b, str_b2, strlen(str_b2)); sha256_update(&ctx_b, str_b3, strlen(str_b3)); sha256_update(&ctx_b, str_b4, strlen(str_b4)); sha256_update(&ctx_b, str_b5, strlen(str_b5)); sha256_update(&ctx_b, str_b6, strlen(str_b6)); byte *hash_b_ = sha256_final(&ctx_b); bt_bytes_to_hex(hash_b, hash_b_, SHA256_SIZE); int are_hash_a_b_equal = (strncmp(hash_a, hash_b, sizeof(hash_a)) == 0); bt_assert_msg(are_hash_a_b_equal, "Hashes A: %s, B: %s should be same", hash_a, hash_b); return 1; } static int t_sha512_concating(void) { char hash_a[SHA512_HEX_SIZE]; char hash_b[SHA512_HEX_SIZE]; char *str_a = "a" "bb" "ccc" "dddd" "eeeee" "ffffff"; char *str_b1 = "a" ; char *str_b2 = "bb" ; char *str_b3 = "ccc" ; char *str_b4 = "dddd" ; char *str_b5 = "eeeee" ; char *str_b6 = "ffffff"; struct hash_context ctx_a; sha512_init(&ctx_a); sha512_update(&ctx_a, str_a, strlen(str_a)); byte *hash_a_ = sha512_final(&ctx_a); bt_bytes_to_hex(hash_a, hash_a_, SHA512_SIZE); struct hash_context ctx_b; sha512_init(&ctx_b); sha512_update(&ctx_b, str_b1, strlen(str_b1)); sha512_update(&ctx_b, str_b2, strlen(str_b2)); sha512_update(&ctx_b, str_b3, strlen(str_b3)); sha512_update(&ctx_b, str_b4, strlen(str_b4)); sha512_update(&ctx_b, str_b5, strlen(str_b5)); sha512_update(&ctx_b, str_b6, strlen(str_b6)); byte *hash_b_ = sha512_final(&ctx_b); bt_bytes_to_hex(hash_b, hash_b_, SHA512_SIZE); int are_hash_a_b_equal = (strncmp(hash_a, hash_b, sizeof(hash_a)) == 0); bt_assert_msg(are_hash_a_b_equal, "Hashes A: %s, B: %s should be same", hash_a, hash_b); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_md5, "Testing MD5 by RFC 1321"); bt_test_suite(t_sha1, "Testing SHA-1"); bt_test_suite(t_sha224, "Testing SHA-224"); bt_test_suite(t_sha256, "Testing SHA-256"); bt_test_suite(t_sha384, "Testing SHA-384"); bt_test_suite(t_sha512, "Testing SHA-512"); bt_test_suite(t_md5_hmac, "Testing HMAC-MD5 by RFC 2202"); bt_test_suite(t_sha1_hmac, "Testing HMAC-SHA-1 by RFC 2202"); bt_test_suite(t_sha224_hmac, "Testing HMAC-SHA-224 by RFC 4231"); bt_test_suite(t_sha256_hmac, "Testing HMAC-SHA-256 by RFC 4231"); bt_test_suite(t_sha384_hmac, "Testing HMAC-SHA-384 by RFC 4231"); bt_test_suite(t_sha512_hmac, "Testing HMAC-SHA-512 by RFC 4231"); bt_test_suite(t_sha256_concating, "Testing concatenation input string to hash using sha256_update"); bt_test_suite(t_sha512_concating, "Testing concatenation input string to hash using sha512_update"); return bt_exit_value(); } bird-2.0.8/lib/mac.h0000664000175000017500000000653514025744326013054 0ustar feelafeela/* * BIRD Library -- Message Authentication Codes * * (c) 2016 Ondrej Zajicek * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_MAC_H_ #define _BIRD_MAC_H_ #include "nest/bird.h" #include "lib/sha512.h" #define ALG_UNDEFINED 0 #define ALG_MD5 0x01 #define ALG_SHA1 0x02 #define ALG_SHA224 0x03 #define ALG_SHA256 0x04 #define ALG_SHA384 0x05 #define ALG_SHA512 0x06 #define ALG_HMAC 0x10 #define ALG_HMAC_MD5 0x11 #define ALG_HMAC_SHA1 0x12 #define ALG_HMAC_SHA224 0x13 #define ALG_HMAC_SHA256 0x14 #define ALG_HMAC_SHA384 0x15 #define ALG_HMAC_SHA512 0x16 #define ALG_MAX 0x17 /* These are maximums for HASH/MAC lengths and required context space */ #define MAX_HASH_SIZE SHA512_SIZE #define HASH_STORAGE sizeof(struct sha512_context) #define MAC_STORAGE sizeof(struct hmac_context) /* This value is used by several IETF protocols for padding */ #define HMAC_MAGIC htonl(0x878FE1F3) /* Generic context used by hash functions */ struct hash_context { u8 data[HASH_STORAGE]; u64 align[0]; }; /* Context for embedded hash (not-really-MAC hash) */ struct nrmh_context { const struct mac_desc *type; struct hash_context ictx; }; /* Context for hash based HMAC */ struct hmac_context { const struct mac_desc *type; struct hash_context ictx; struct hash_context octx; }; /* Generic context used by MAC functions */ struct mac_context { const struct mac_desc *type; u8 data[MAC_STORAGE - sizeof(void *)]; u64 align[0]; }; /* Union to satisfy C aliasing rules */ union mac_context_union { struct mac_context mac; struct nrmh_context nrmh; struct hmac_context hmac; }; struct mac_desc { const char *name; /* Name of MAC algorithm */ uint mac_length; /* Length of authentication code */ uint ctx_length; /* Length of algorithm context */ void (*init)(struct mac_context *ctx, const byte *key, uint keylen); void (*update)(struct mac_context *ctx, const byte *data, uint datalen); byte *(*final)(struct mac_context *ctx); uint hash_size; /* Hash length, for hash-based MACs */ uint block_size; /* Hash block size, for hash-based MACs */ void (*hash_init)(struct hash_context *ctx); void (*hash_update)(struct hash_context *ctx, const byte *data, uint datalen); byte *(*hash_final)(struct hash_context *ctx); }; extern const struct mac_desc mac_table[ALG_MAX]; static inline const char *mac_type_name(uint id) { return mac_table[id].name; } static inline uint mac_type_length(uint id) { return mac_table[id].mac_length; } static inline const char *mac_get_name(struct mac_context *ctx) { return ctx->type->name; } static inline uint mac_get_length(struct mac_context *ctx) { return ctx->type->mac_length; } void mac_init(struct mac_context *ctx, uint id, const byte *key, uint keylen); static inline void mac_update(struct mac_context *ctx, const byte *data, uint datalen) { ctx->type->update(ctx, data, datalen); } static inline byte *mac_final(struct mac_context *ctx) { return ctx->type->final(ctx); } static inline void mac_cleanup(struct mac_context *ctx) { memset(ctx, 0, ctx->type->ctx_length); } void mac_fill(uint id, const byte *key, uint keylen, const byte *data, uint datalen, byte *mac); int mac_verify(uint id, const byte *key, uint keylen, const byte *data, uint datalen, const byte *mac); #endif /* _BIRD_MAC_H_ */ bird-2.0.8/lib/mac.c0000664000175000017500000002005514025744326013040 0ustar feelafeela/* * BIRD Library -- Message Authentication Codes * * (c) 2016 Ondrej Zajicek * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Message authentication codes * * MAC algorithms are simple cryptographic tools for message authentication. * They use shared a secret key a and message text to generate authentication * code, which is then passed with the message to the other side, where the code * is verified. There are multiple families of MAC algorithms based on different * cryptographic primitives, BIRD implements two MAC families which use hash * functions. * * The first family is simply a cryptographic hash camouflaged as MAC algorithm. * Originally supposed to be (m|k)-hash (message is concatenated with key, and * that is hashed), but later it turned out that a raw hash is more practical. * This is used for cryptographic authentication in OSPFv2, RIP and BFD. * * The second family is the standard HMAC (RFC 2104), using inner and outer hash * to process key and message. HMAC (with SHA) is used in advanced OSPF and RIP * authentication (RFC 5709, RFC 4822). */ #include "lib/mac.h" #include "lib/md5.h" #include "lib/sha1.h" #include "lib/sha256.h" #include "lib/sha512.h" /* * Internal hash calls */ static inline void hash_init(struct mac_context *mctx, struct hash_context *hctx) { mctx->type->hash_init(hctx); } static inline void hash_update(struct mac_context *mctx, struct hash_context *hctx, const byte *buf, uint len) { mctx->type->hash_update(hctx, buf, len); } static inline byte * hash_final(struct mac_context *mctx, struct hash_context *hctx) { return mctx->type->hash_final(hctx); } static inline void hash_buffer(struct mac_context *mctx, byte *outbuf, const byte *buffer, uint length) { struct hash_context hctx; hash_init(mctx, &hctx); hash_update(mctx, &hctx, buffer, length); memcpy(outbuf, hash_final(mctx, &hctx), mctx->type->hash_size); } /* * (not-really-MAC) Hash */ static void nrmh_init(struct mac_context *ctx, const byte *key UNUSED, uint keylen UNUSED) { struct nrmh_context *ct = (void *) ctx; hash_init(ctx, &ct->ictx); } static void nrmh_update(struct mac_context *ctx, const byte *data, uint datalen) { struct nrmh_context *ct = (void *) ctx; hash_update(ctx, &ct->ictx, data, datalen); } static byte * nrmh_final(struct mac_context *ctx) { struct nrmh_context *ct = (void *) ctx; return hash_final(ctx, &ct->ictx); } /* * HMAC */ static void hmac_init(struct mac_context *ctx, const byte *key, uint keylen) { struct hmac_context *ct = (void *) ctx; uint block_size = ctx->type->block_size; uint hash_size = ctx->type->hash_size; byte *keybuf = alloca(block_size); byte *buf = alloca(block_size); uint i; /* Hash the key if necessary */ if (keylen <= block_size) { memcpy(keybuf, key, keylen); memset(keybuf + keylen, 0, block_size - keylen); } else { hash_buffer(ctx, keybuf, key, keylen); memset(keybuf + hash_size, 0, block_size - hash_size); } /* Initialize the inner digest */ hash_init(ctx, &ct->ictx); for (i = 0; i < block_size; i++) buf[i] = keybuf[i] ^ 0x36; hash_update(ctx, &ct->ictx, buf, block_size); /* Initialize the outer digest */ hash_init(ctx, &ct->octx); for (i = 0; i < block_size; i++) buf[i] = keybuf[i] ^ 0x5c; hash_update(ctx, &ct->octx, buf, block_size); } static void hmac_update(struct mac_context *ctx, const byte *data, uint datalen) { struct hmac_context *ct = (void *) ctx; /* Just update the inner digest */ hash_update(ctx, &ct->ictx, data, datalen); } static byte * hmac_final(struct mac_context *ctx) { struct hmac_context *ct = (void *) ctx; /* Finish the inner digest */ byte *isha = hash_final(ctx, &ct->ictx); /* Finish the outer digest */ hash_update(ctx, &ct->octx, isha, ctx->type->hash_size); return hash_final(ctx, &ct->octx); } /* * Common code */ #define HASH_DESC(name, px, PX) \ { name, PX##_SIZE, sizeof(struct nrmh_context), nrmh_init, nrmh_update, nrmh_final, \ PX##_SIZE, PX##_BLOCK_SIZE, px##_init, px##_update, px##_final } #define HMAC_DESC(name, px, PX) \ { name, PX##_SIZE, sizeof(struct hmac_context), hmac_init, hmac_update, hmac_final, \ PX##_SIZE, PX##_BLOCK_SIZE, px##_init, px##_update, px##_final } const struct mac_desc mac_table[ALG_MAX] = { [ALG_MD5] = HASH_DESC("Keyed MD5", md5, MD5), [ALG_SHA1] = HASH_DESC("Keyed SHA-1", sha1, SHA1), [ALG_SHA224] = HASH_DESC("Keyed SHA-224", sha224, SHA224), [ALG_SHA256] = HASH_DESC("Keyed SHA-256", sha256, SHA256), [ALG_SHA384] = HASH_DESC("Keyed SHA-384", sha384, SHA384), [ALG_SHA512] = HASH_DESC("Keyed SHA-512", sha512, SHA512), [ALG_HMAC_MD5] = HMAC_DESC("HMAC-MD5", md5, MD5), [ALG_HMAC_SHA1] = HMAC_DESC("HMAC-SHA-1", sha1, SHA1), [ALG_HMAC_SHA224] = HMAC_DESC("HMAC-SHA-224", sha224, SHA224), [ALG_HMAC_SHA256] = HMAC_DESC("HMAC-SHA-256", sha256, SHA256), [ALG_HMAC_SHA384] = HMAC_DESC("HMAC-SHA-384", sha384, SHA384), [ALG_HMAC_SHA512] = HMAC_DESC("HMAC-SHA-512", sha512, SHA512), }; /** * mac_init - initialize MAC algorithm * @ctx: context to initialize * @id: MAC algorithm ID * @key: MAC key * @keylen: MAC key length * * Initialize MAC context @ctx for algorithm @id (e.g., %ALG_HMAC_SHA1), with * key @key of length @keylen. After that, message data could be added using * mac_update() function. */ void mac_init(struct mac_context *ctx, uint id, const byte *key, uint keylen) { ctx->type = &mac_table[id]; ctx->type->init(ctx, key, keylen); } #if 0 /** * mac_update - add more data to MAC algorithm * @ctx: MAC context * @data: data to add * @datalen: length of data * * Push another @datalen bytes of data pointed to by @data into the MAC * algorithm currently in @ctx. Can be called multiple times for the same MAC * context. It has the same effect as concatenating all the data together and * passing them at once. */ void mac_update(struct mac_context *ctx, const byte *data, uint datalen) { DUMMY; } /** * mac_final - finalize MAC algorithm * @ctx: MAC context * * Finish MAC computation and return a pointer to the result. No more * @mac_update() calls could be done, but the context may be reinitialized * later. * * Note that the returned pointer points into data in the @ctx context. If it * ceases to exist, the pointer becomes invalid. */ byte *mac_final(struct mac_context *ctx) { DUMMY; } /** * mac_cleanup - cleanup MAC context * @ctx: MAC context * * Cleanup MAC context after computation (by filling with zeros). Not strictly * necessary, just to erase sensitive data from stack. This also invalidates the * pointer returned by @mac_final(). */ void mac_cleanup(struct mac_context *ctx) { DUMMY; } #endif /** * mac_fill - compute and fill MAC * @id: MAC algorithm ID * @key: secret key * @keylen: key length * @data: message data * @datalen: message length * @mac: place to fill MAC * * Compute MAC for specified key @key and message @data using algorithm @id and * copy it to buffer @mac. mac_fill() is a shortcut function doing all usual * steps for transmitted messages. */ void mac_fill(uint id, const byte *key, uint keylen, const byte *data, uint datalen, byte *mac) { struct mac_context ctx; mac_init(&ctx, id, key, keylen); mac_update(&ctx, data, datalen); memcpy(mac, mac_final(&ctx), mac_get_length(&ctx)); mac_cleanup(&ctx); } /** * mac_verify - compute and verify MAC * @id: MAC algorithm ID * @key: secret key * @keylen: key length * @data: message data * @datalen: message length * @mac: received MAC * * Compute MAC for specified key @key and message @data using algorithm @id and * compare it with received @mac, return whether they are the same. mac_verify() * is a shortcut function doing all usual steps for received messages. */ int mac_verify(uint id, const byte *key, uint keylen, const byte *data, uint datalen, const byte *mac) { struct mac_context ctx; mac_init(&ctx, id, key, keylen); mac_update(&ctx, data, datalen); int res = !memcmp(mac, mac_final(&ctx), mac_get_length(&ctx)); mac_cleanup(&ctx); return res; } bird-2.0.8/lib/lists_test.c0000664000175000017500000001331614025744326014477 0ustar feelafeela/* * BIRD Library -- Linked Lists Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/lists.h" #define MAX_NUM 1000 static node nodes[MAX_NUM]; static list l; static void show_list(void) { bt_debug("\n"); bt_debug("list.null is at %p and point to %p\n", &l.null, l.null); bt_debug("list.head is at %p and point to %p\n", &l.head, l.head); bt_debug("list.tail is at %p and point to %p\n", &l.tail, l.tail); int i; for (i = 0; i < MAX_NUM; i++) { bt_debug("n[%3i] is at %p\n", i, &nodes[i]); bt_debug(" prev is at %p and point to %p\n", &(nodes[i].prev), nodes[i].prev); bt_debug(" next is at %p and point to %p\n", &(nodes[i].next), nodes[i].next); } } static int is_filled_list_well_linked(void) { int i; bt_assert(l.head == &nodes[0]); bt_assert(l.tail == &nodes[MAX_NUM-1]); bt_assert((void *) nodes[0].prev == (void *) &l.head); bt_assert((void *) nodes[MAX_NUM-1].next == (void *) &l.null); for (i = 0; i < MAX_NUM; i++) { if (i < (MAX_NUM-1)) bt_assert(nodes[i].next == &nodes[i+1]); if (i > 0) bt_assert(nodes[i].prev == &nodes[i-1]); } return 1; } static int is_empty_list_well_unlinked(void) { int i; bt_assert(l.head == NODE &l.null); bt_assert(l.tail == NODE &l.head); bt_assert(EMPTY_LIST(l)); for (i = 0; i < MAX_NUM; i++) { bt_assert(nodes[i].next == NULL); bt_assert(nodes[i].prev == NULL); } return 1; } static void init_list__(list *l, struct node nodes[]) { init_list(l); int i; for (i = 0; i < MAX_NUM; i++) { nodes[i].next = NULL; nodes[i].prev = NULL; } } static void init_list_(void) { init_list__(&l, (node *) nodes); } static int t_add_tail(void) { int i; init_list_(); for (i = 0; i < MAX_NUM; i++) { add_tail(&l, &nodes[i]); bt_debug("."); bt_assert(l.tail == &nodes[i]); bt_assert(l.head == &nodes[0]); bt_assert((void *) nodes[i].next == (void *) &l.null); if (i > 0) { bt_assert(nodes[i-1].next == &nodes[i]); bt_assert(nodes[i].prev == &nodes[i-1]); } } show_list(); bt_assert(is_filled_list_well_linked()); return 1; } static int t_add_head(void) { int i; init_list_(); for (i = MAX_NUM-1; i >= 0; i--) { add_head(&l, &nodes[i]); bt_debug("."); bt_assert(l.head == &nodes[i]); bt_assert(l.tail == &nodes[MAX_NUM-1]); if (i < MAX_NUM-1) { bt_assert(nodes[i+1].prev == &nodes[i]); bt_assert(nodes[i].next == &nodes[i+1]); } } show_list(); bt_assert(is_filled_list_well_linked()); return 1; } static void insert_node_(node *n, node *after) { insert_node(n, after); bt_debug("."); } static int t_insert_node(void) { int i; init_list_(); // add first node insert_node_(&nodes[0], NODE &l.head); // add odd nodes for (i = 2; i < MAX_NUM; i+=2) insert_node_(&nodes[i], &nodes[i-2]); // add even nodes for (i = 1; i < MAX_NUM; i+=2) insert_node_(&nodes[i], &nodes[i-1]); bt_debug("\n"); bt_assert(is_filled_list_well_linked()); return 1; } static void fill_list2(list *l, node nodes[]) { int i; for (i = 0; i < MAX_NUM; i++) add_tail(l, &nodes[i]); } static void fill_list(void) { fill_list2(&l, (node *) nodes); } static int t_remove_node(void) { int i; init_list_(); /* Fill & Remove & Check */ fill_list(); for (i = 0; i < MAX_NUM; i++) rem_node(&nodes[i]); bt_assert(is_empty_list_well_unlinked()); /* Fill & Remove the half of nodes & Check & Remove the rest nodes & Check */ fill_list(); for (i = 0; i < MAX_NUM; i+=2) rem_node(&nodes[i]); int tail_node_index = (MAX_NUM % 2) ? MAX_NUM - 2 : MAX_NUM - 1; bt_assert(l.head == &nodes[1]); bt_assert(l.tail == &nodes[tail_node_index]); bt_assert(nodes[tail_node_index].next == NODE &l.null); for (i = 1; i < MAX_NUM; i+=2) { if (i > 1) bt_assert(nodes[i].prev == &nodes[i-2]); if (i < tail_node_index) bt_assert(nodes[i].next == &nodes[i+2]); } for (i = 1; i < MAX_NUM; i+=2) rem_node(&nodes[i]); bt_assert(is_empty_list_well_unlinked()); return 1; } static int t_update_node(void) { node head, inside, tail; init_list_(); fill_list(); head = nodes[0]; update_node(&head); bt_assert(l.head == &head); bt_assert(head.prev == NODE &l.head); bt_assert(head.next == &nodes[1]); bt_assert(nodes[1].prev == &head); inside = nodes[MAX_NUM/2]; update_node(&inside); bt_assert(nodes[MAX_NUM/2-1].next == &inside); bt_assert(nodes[MAX_NUM/2+1].prev == &inside); bt_assert(inside.prev == &nodes[MAX_NUM/2-1]); bt_assert(inside.next == &nodes[MAX_NUM/2+1]); tail = nodes[MAX_NUM-1]; update_node(&tail); bt_assert(l.tail == &tail); bt_assert(tail.prev == &nodes[MAX_NUM-2]); bt_assert(tail.next == NODE &l.null); bt_assert(nodes[MAX_NUM-2].next == &tail); return 1; } static int t_add_tail_list(void) { node nodes2[MAX_NUM]; list l2; init_list__(&l, (node *) nodes); fill_list2(&l, (node *) nodes); init_list__(&l2, (node *) nodes2); fill_list2(&l2, (node *) nodes2); add_tail_list(&l, &l2); bt_assert(nodes[MAX_NUM-1].next == &nodes2[0]); bt_assert(nodes2[0].prev == &nodes[MAX_NUM-1]); bt_assert(l.tail == &nodes2[MAX_NUM-1]); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_add_tail, "Adding nodes to tail of list"); bt_test_suite(t_add_head, "Adding nodes to head of list"); bt_test_suite(t_insert_node, "Inserting nodes to list"); bt_test_suite(t_remove_node, "Removing nodes from list"); bt_test_suite(t_update_node, "Updating nodes in list"); bt_test_suite(t_add_tail_list, "At the tail of a list adding the another list"); return bt_exit_value(); } bird-2.0.8/lib/lists.h0000664000175000017500000000501314025744326013440 0ustar feelafeela/* * BIRD Library -- Linked Lists * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_LISTS_H_ #define _BIRD_LISTS_H_ /* * I admit the list structure is very tricky and also somewhat awkward, * but it's both efficient and easy to manipulate once one understands the * basic trick: The list head always contains two synthetic nodes which are * always present in the list: the head and the tail. But as the `next' * entry of the tail and the `prev' entry of the head are both NULL, the * nodes can overlap each other: * * head head_node.next * null head_node.prev tail_node.next * tail tail_node.prev */ typedef struct node { struct node *next, *prev; } node; typedef union list { /* In fact two overlayed nodes */ struct { /* Head node */ struct node head_node; void *head_padding; }; struct { /* Tail node */ void *tail_padding; struct node tail_node; }; struct { /* Split to separate pointers */ struct node *head; struct node *null; struct node *tail; }; } list; #define NODE (node *) #define HEAD(list) ((void *)((list).head)) #define TAIL(list) ((void *)((list).tail)) #define NODE_NEXT(n) ((void *)((NODE (n))->next)) #define NODE_VALID(n) ((NODE (n))->next) #define WALK_LIST(n,list) for(n=HEAD(list); NODE_VALID(n); n=NODE_NEXT(n)) #define WALK_LIST2(n,nn,list,pos) \ for(nn=(list).head; NODE_VALID(nn) && (n=SKIP_BACK(typeof(*n),pos,nn)); nn=nn->next) #define WALK_LIST_DELSAFE(n,nxt,list) \ for(n=HEAD(list); nxt=NODE_NEXT(n); n=(void *) nxt) #define WALK_LIST2_DELSAFE(n,nn,nxt,list,pos) \ for(nn=HEAD(list); (nxt=nn->next) && (n=SKIP_BACK(typeof(*n),pos,nn)); nn=nxt) /* WALK_LIST_FIRST supposes that called code removes each processed node */ #define WALK_LIST_FIRST(n,list) \ while(n=HEAD(list), (NODE (n))->next) #define WALK_LIST_BACKWARDS(n,list) for(n=TAIL(list);(NODE (n))->prev; \ n=(void *)((NODE (n))->prev)) #define WALK_LIST_BACKWARDS_DELSAFE(n,prv,list) \ for(n=TAIL(list); prv=(void *)((NODE (n))->prev); n=(void *) prv) #define EMPTY_LIST(list) (!(list).head->next) #ifndef _BIRD_LISTS_C_ #define LIST_INLINE static inline #include "lib/lists.c" #undef LIST_INLINE #else /* _BIRD_LISTS_C_ */ #define LIST_INLINE void add_tail(list *, node *); void add_head(list *, node *); void rem_node(node *); void add_tail_list(list *, list *); void init_list(list *); void insert_node(node *, node *); uint list_length(list *); #endif #endif bird-2.0.8/lib/lists.c0000664000175000017500000001063114025744326013435 0ustar feelafeela/* * BIRD Library -- Linked Lists * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Linked lists * * The BIRD library provides a set of functions for operating on linked * lists. The lists are internally represented as standard doubly linked * lists with synthetic head and tail which makes all the basic operations * run in constant time and contain no extra end-of-list checks. Each list * is described by a &list structure, nodes can have any format as long * as they start with a &node structure. If you want your nodes to belong * to multiple lists at once, you can embed multiple &node structures in them * and use the SKIP_BACK() macro to calculate a pointer to the start of the * structure from a &node pointer, but beware of obscurity. * * There also exist safe linked lists (&slist, &snode and all functions * being prefixed with |s_|) which support asynchronous walking very * similar to that used in the &fib structure. */ #define _BIRD_LISTS_C_ #include "nest/bird.h" #include "lib/lists.h" LIST_INLINE int check_list(list *l, node *n) { if (!l) { ASSERT_DIE(n); ASSERT_DIE(n->prev); do { n = n->prev; } while (n->prev); l = SKIP_BACK(list, head_node, n); } int seen = 0; ASSERT_DIE(l->null == NULL); ASSERT_DIE(l->head != NULL); ASSERT_DIE(l->tail != NULL); node *prev = &l->head_node, *cur = l->head, *next = l->head->next; while (next) { if (cur == n) seen++; ASSERT_DIE(cur->prev == prev); prev = cur; cur = next; next = next->next; } ASSERT_DIE(cur == &(l->tail_node)); ASSERT_DIE(!n || (seen == 1)); return 1; } /** * add_tail - append a node to a list * @l: linked list * @n: list node * * add_tail() takes a node @n and appends it at the end of the list @l. */ LIST_INLINE void add_tail(list *l, node *n) { EXPENSIVE_CHECK(check_list(l, NULL)); ASSUME(n->prev == NULL); ASSUME(n->next == NULL); node *z = l->tail; n->next = &l->tail_node; n->prev = z; z->next = n; l->tail = n; } /** * add_head - prepend a node to a list * @l: linked list * @n: list node * * add_head() takes a node @n and prepends it at the start of the list @l. */ LIST_INLINE void add_head(list *l, node *n) { EXPENSIVE_CHECK(check_list(l, NULL)); ASSUME(n->prev == NULL); ASSUME(n->next == NULL); node *z = l->head; n->next = z; n->prev = &l->head_node; z->prev = n; l->head = n; } /** * insert_node - insert a node to a list * @n: a new list node * @after: a node of a list * * Inserts a node @n to a linked list after an already inserted * node @after. */ LIST_INLINE void insert_node(node *n, node *after) { EXPENSIVE_CHECK(check_list(l, after)); ASSUME(n->prev == NULL); ASSUME(n->next == NULL); node *z = after->next; n->next = z; n->prev = after; after->next = n; z->prev = n; } /** * rem_node - remove a node from a list * @n: node to be removed * * Removes a node @n from the list it's linked in. Afterwards, node @n is cleared. */ LIST_INLINE void rem_node(node *n) { EXPENSIVE_CHECK(check_list(NULL, n)); node *z = n->prev; node *x = n->next; z->next = x; x->prev = z; n->next = NULL; n->prev = NULL; } /** * update_node - update node after calling realloc on it * @n: node to be updated * * Fixes neighbor pointers. */ LIST_INLINE void update_node(node *n) { ASSUME(n->next->prev == n->prev->next); n->next->prev = n; n->prev->next = n; EXPENSIVE_CHECK(check_list(NULL, n)); } /** * init_list - create an empty list * @l: list * * init_list() takes a &list structure and initializes its * fields, so that it represents an empty list. */ LIST_INLINE void init_list(list *l) { l->head = &l->tail_node; l->null = NULL; l->tail = &l->head_node; } /** * add_tail_list - concatenate two lists * @to: destination list * @l: source list * * This function appends all elements of the list @l to * the list @to in constant time. */ LIST_INLINE void add_tail_list(list *to, list *l) { EXPENSIVE_CHECK(check_list(to, NULL)); EXPENSIVE_CHECK(check_list(l, NULL)); node *p = to->tail; node *q = l->head; p->next = q; q->prev = p; q = l->tail; q->next = &to->tail_node; to->tail = q; EXPENSIVE_CHECK(check_list(to, NULL)); } LIST_INLINE uint list_length(list *l) { uint len = 0; node *n; EXPENSIVE_CHECK(check_list(l, NULL)); WALK_LIST(n, *l) len++; return len; } bird-2.0.8/lib/ip_test.c0000664000175000017500000001000314025744326013737 0ustar feelafeela/* * BIRD Library -- IP address functions Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/ip.h" #define IP4_MAX_LEN 16 static int test_ip4_pton(void *out_, const void *in_, const void *expected_out_) { ip_addr *out = out_; const char *in = in_; const ip_addr *expected_out = expected_out_; ip4_addr ip4; if (expected_out) { bt_assert(ip4_pton(in, &ip4)); *out = ipa_from_ip4(ip4); return ipa_equal(*out, *expected_out); } else return !ip4_pton(in, &ip4); } static int test_ip6_pton(void *out_, const void *in_, const void *expected_out_) { ip_addr *out = out_; const char *in = in_; const ip_addr *expected_out = expected_out_; if (expected_out) { bt_assert(ip6_pton(in, out)); return ipa_equal(*out, *expected_out); } else return !ip6_pton(in, out); } static int t_ip4_pton(void) { struct bt_pair test_vectors[] = { { .in = "192.168.1.128", .out = & ipa_build4(192, 168, 1, 128), }, { .in = "255.255.255.255", .out = & ipa_build4(255, 255, 255, 255), }, { .in = "0.0.0.0", .out = & ipa_build4(0, 0, 0, 0), }, }; return bt_assert_batch(test_vectors, test_ip4_pton, bt_fmt_str, bt_fmt_ipa); } static int t_ip6_pton(void) { struct bt_pair test_vectors[] = { { .in = "2001:0db8:0000:0000:0000:0000:1428:57ab", .out = & ipa_build6(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB), }, { .in = "2001:0db8:0000:0000:0000::1428:57ab", .out = & ipa_build6(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB), }, { .in = "2001:0db8::1428:57ab", .out = & ipa_build6(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB), }, { .in = "2001:db8::1428:57ab", .out = & ipa_build6(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB), }, { .in = "::1", .out = & ipa_build6(0x00000000, 0x00000000, 0x00000000, 0x00000001), }, { .in = "::", .out = & ipa_build6(0x00000000, 0x00000000, 0x00000000, 0x00000000), }, { .in = "2605:2700:0:3::4713:93e3", .out = & ipa_build6(0x26052700, 0x00000003, 0x00000000, 0x471393E3), }, { .in = "2605:2700:0:3:4713:93e3", .out = NULL, }, { .in = "2", .out = NULL, }, }; return bt_assert_batch(test_vectors, test_ip6_pton, bt_fmt_str, bt_fmt_ipa); } static int test_ipa_ntop(void *out_, const void *in_, const void *expected_out_) { char *out = out_; const ip_addr *in = in_; const char *expected_out = expected_out_; if (ipa_is_ip4(*in)) ip4_ntop(ipa_to_ip4(*in), out); else ip6_ntop(ipa_to_ip6(*in), out); int result = strncmp(out, expected_out, ipa_is_ip4(*in) ? IP4_MAX_TEXT_LENGTH : IP6_MAX_TEXT_LENGTH) == 0; return result; } static int t_ip4_ntop(void) { struct bt_pair test_vectors[] = { { .in = & ipa_build4(192, 168, 1, 128), .out = "192.168.1.128", }, { .in = & ipa_build4(255, 255, 255, 255), .out = "255.255.255.255", }, { .in = & ipa_build4(0, 0, 0, 1), .out = "0.0.0.1", }, }; return bt_assert_batch(test_vectors, test_ipa_ntop, bt_fmt_ipa, bt_fmt_str); } static int t_ip6_ntop(void) { struct bt_pair test_vectors[] = { { .in = & ipa_build6(0x20010DB8, 0x00000000, 0x00000000, 0x142857AB), .out = "2001:db8::1428:57ab", }, { .in = & ipa_build6(0x26052700, 0x00000003, 0x00000000, 0x471393E3), .out = "2605:2700:0:3::4713:93e3", }, }; return bt_assert_batch(test_vectors, test_ipa_ntop, bt_fmt_ipa, bt_fmt_str); } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_ip4_pton, "Converting IPv4 string to ip4_addr struct"); bt_test_suite(t_ip6_pton, "Converting IPv6 string to ip6_addr struct"); bt_test_suite(t_ip4_ntop, "Converting ip4_addr struct to IPv4 string"); bt_test_suite(t_ip6_ntop, "Converting ip6_addr struct to IPv6 string"); return bt_exit_value(); } bird-2.0.8/lib/ip.h0000664000175000017500000002411114025744326012712 0ustar feelafeela/* * BIRD Internet Routing Daemon -- The Internet Protocol * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_IP_H_ #define _BIRD_IP_H_ #include "sysdep/unix/endian.h" #include "lib/string.h" #include "lib/bitops.h" #include "lib/unaligned.h" #define IP4_ALL_NODES ipa_build4(224, 0, 0, 1) #define IP4_ALL_ROUTERS ipa_build4(224, 0, 0, 2) #define IP4_OSPF_ALL_ROUTERS ipa_build4(224, 0, 0, 5) #define IP4_OSPF_DES_ROUTERS ipa_build4(224, 0, 0, 6) #define IP4_RIP_ROUTERS ipa_build4(224, 0, 0, 9) #define IP6_ALL_NODES ipa_build6(0xFF020000, 0, 0, 1) #define IP6_ALL_ROUTERS ipa_build6(0xFF020000, 0, 0, 2) #define IP6_OSPF_ALL_ROUTERS ipa_build6(0xFF020000, 0, 0, 5) #define IP6_OSPF_DES_ROUTERS ipa_build6(0xFF020000, 0, 0, 6) #define IP6_RIP_ROUTERS ipa_build6(0xFF020000, 0, 0, 9) #define IP6_BABEL_ROUTERS ipa_build6(0xFF020000, 0, 0, 0x00010006) #define IP4_NONE _MI4(0) #define IP6_NONE _MI6(0,0,0,0) #define IP4_MAX_PREFIX_LENGTH 32 #define IP6_MAX_PREFIX_LENGTH 128 #define IP4_MAX_TEXT_LENGTH 15 /* "255.255.255.255" */ #define IP6_MAX_TEXT_LENGTH 39 /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" */ #define IPA_MAX_TEXT_LENGTH 39 #define IP4_MIN_MTU 576 #define IP6_MIN_MTU 1280 #define IP_PREC_INTERNET_CONTROL 0xc0 #define IP4_HEADER_LENGTH 20 #define IP6_HEADER_LENGTH 40 #define UDP_HEADER_LENGTH 8 /* IANA Address Family Numbers */ /* https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml */ /* Would use AF_ prefix, but that collides with POSIX address family numbers */ #define AFI_IPV4 1 #define AFI_IPV6 2 #ifdef DEBUGGING typedef struct ip4_addr { u32 addr; } ip4_addr; #define _MI4(x) ((struct ip4_addr) { x }) #define _I(x) (x).addr #else typedef u32 ip4_addr; #define _MI4(x) ((u32) (x)) #define _I(x) (x) #endif typedef struct ip6_addr { u32 addr[4]; } ip6_addr; #define _MI6(a,b,c,d) ((struct ip6_addr) {{ a, b, c, d }}) #define _I0(a) ((a).addr[0]) #define _I1(a) ((a).addr[1]) #define _I2(a) ((a).addr[2]) #define _I3(a) ((a).addr[3]) /* Structure ip_addr may contain both IPv4 and IPv6 addresses */ typedef ip6_addr ip_addr; #define IPA_NONE IP6_NONE #define ipa_from_ip4(x) _MI6(0,0,0xffff,_I(x)) #define ipa_from_ip6(x) x #define ipa_from_u32(x) ipa_from_ip4(ip4_from_u32(x)) #define ipa_to_ip4(x) _MI4(_I3(x)) #define ipa_to_ip6(x) x #define ipa_to_u32(x) ip4_to_u32(ipa_to_ip4(x)) #define ipa_is_ip4(a) ip6_is_v4mapped(a) #define ipa_is_ip6(a) (! ip6_is_v4mapped(a)) #define IPA_NONE4 ipa_from_ip4(IP4_NONE) #define IPA_NONE6 ipa_from_ip6(IP6_NONE) /* * Public constructors */ #define ip4_from_u32(x) _MI4(x) #define ip4_to_u32(x) _I(x) #define ip4_build(a,b,c,d) _MI4(((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) #define ip6_build(a,b,c,d) _MI6(a,b,c,d) #define ipa_build4(a,b,c,d) ipa_from_ip4(ip4_build(a,b,c,d)) #define ipa_build6(a,b,c,d) ipa_from_ip6(ip6_build(a,b,c,d)) /* * Basic algebraic functions */ static inline int ip4_equal(ip4_addr a, ip4_addr b) { return _I(a) == _I(b); } static inline int ip4_zero(ip4_addr a) { return _I(a) == 0; } static inline int ip4_nonzero(ip4_addr a) { return _I(a) != 0; } static inline ip4_addr ip4_and(ip4_addr a, ip4_addr b) { return _MI4(_I(a) & _I(b)); } static inline ip4_addr ip4_or(ip4_addr a, ip4_addr b) { return _MI4(_I(a) | _I(b)); } static inline ip4_addr ip4_xor(ip4_addr a, ip4_addr b) { return _MI4(_I(a) ^ _I(b)); } static inline ip4_addr ip4_not(ip4_addr a) { return _MI4(~_I(a)); } static inline int ip6_equal(ip6_addr a, ip6_addr b) { return _I0(a) == _I0(b) && _I1(a) == _I1(b) && _I2(a) == _I2(b) && _I3(a) == _I3(b); } static inline int ip6_zero(ip6_addr a) { return !_I0(a) && !_I1(a) && !_I2(a) && !_I3(a); } static inline int ip6_nonzero(ip6_addr a) { return _I0(a) || _I1(a) || _I2(a) || _I3(a); } static inline ip6_addr ip6_and(ip6_addr a, ip6_addr b) { return _MI6(_I0(a) & _I0(b), _I1(a) & _I1(b), _I2(a) & _I2(b), _I3(a) & _I3(b)); } static inline ip6_addr ip6_or(ip6_addr a, ip6_addr b) { return _MI6(_I0(a) | _I0(b), _I1(a) | _I1(b), _I2(a) | _I2(b), _I3(a) | _I3(b)); } static inline ip6_addr ip6_xor(ip6_addr a, ip6_addr b) { return _MI6(_I0(a) ^ _I0(b), _I1(a) ^ _I1(b), _I2(a) ^ _I2(b), _I3(a) ^ _I3(b)); } static inline ip6_addr ip6_not(ip6_addr a) { return _MI6(~_I0(a), ~_I1(a), ~_I2(a), ~_I3(a)); } #define ipa_equal(x,y) ip6_equal(x,y) #define ipa_zero(x) ip6_zero(x) #define ipa_nonzero(x) ip6_nonzero(x) #define ipa_and(x,y) ip6_and(x,y) #define ipa_or(x,y) ip6_or(x,y) #define ipa_xor(x,y) ip6_xor(x,y) #define ipa_not(x) ip6_not(x) /* * A zero address is either a token for invalid/unused, or the prefix of default * routes. These functions should be used in the second case, where both IPv4 * and IPv6 zero addresses should be checked. */ static inline int ipa_zero2(ip_addr a) { return !_I0(a) && !_I1(a) && ((_I2(a) == 0) || (_I2(a) == 0xffff)) && !_I3(a); } static inline int ipa_nonzero2(ip_addr a) { return _I0(a) || _I1(a) || ((_I2(a) != 0) && (_I2(a) != 0xffff)) || _I3(a); } /* * Hash and compare functions */ static inline u32 ip4_hash(ip4_addr a) { return u32_hash(_I(a)); } static inline u32 ip6_hash(ip6_addr a) { /* Returns a 32-bit hash key, although low-order bits are not mixed */ u32 x = _I0(a) ^ _I1(a) ^ _I2(a) ^ _I3(a); return x ^ (x << 16) ^ (x << 24); } static inline int ip4_compare(ip4_addr a, ip4_addr b) { return (_I(a) > _I(b)) - (_I(a) < _I(b)); } int ip6_compare(ip6_addr a, ip6_addr b); #define ipa_hash(x) ip6_hash(x) #define ipa_compare(x,y) ip6_compare(x,y) /* * IP address classification */ /* Address class */ #define IADDR_INVALID -1 #define IADDR_SCOPE_MASK 0xfff #define IADDR_HOST 0x1000 #define IADDR_BROADCAST 0x2000 #define IADDR_MULTICAST 0x4000 /* Address scope */ #define SCOPE_HOST 0 #define SCOPE_LINK 1 #define SCOPE_SITE 2 #define SCOPE_ORGANIZATION 3 #define SCOPE_UNIVERSE 4 #define SCOPE_UNDEFINED 5 int ip4_classify(ip4_addr ad); int ip6_classify(ip6_addr *a); static inline int ip6_is_link_local(ip6_addr a) { return (_I0(a) & 0xffc00000) == 0xfe800000; } static inline int ip6_is_v4mapped(ip6_addr a) { return _I0(a) == 0 && _I1(a) == 0 && _I2(a) == 0xffff; } #define ipa_classify(x) ip6_classify(&(x)) #define ipa_is_link_local(x) ip6_is_link_local(x) static inline int ip4_is_unicast(ip4_addr a) { return _I(a) < 0xe0000000; } /* XXXX remove */ static inline int ipa_classify_net(ip_addr a) { return ipa_zero2(a) ? (IADDR_HOST | SCOPE_UNIVERSE) : ipa_classify(a); } /* * Miscellaneous IP prefix manipulation */ static inline ip4_addr ip4_mkmask(uint n) { return _MI4(u32_mkmask(n)); } static inline uint ip4_masklen(ip4_addr a) { return u32_masklen(_I(a)); } ip6_addr ip6_mkmask(uint n); uint ip6_masklen(ip6_addr *a); /* ipX_pxlen() requires that x != y */ static inline uint ip4_pxlen(ip4_addr a, ip4_addr b) { return 31 - u32_log2(_I(a) ^ _I(b)); } static inline uint ip6_pxlen(ip6_addr a, ip6_addr b) { int i = 0; i += (a.addr[i] == b.addr[i]); i += (a.addr[i] == b.addr[i]); i += (a.addr[i] == b.addr[i]); i += (a.addr[i] == b.addr[i]); return 32 * i + 31 - u32_log2(a.addr[i] ^ b.addr[i]); } static inline u32 ip4_getbit(ip4_addr a, uint pos) { return _I(a) & (0x80000000 >> pos); } static inline u32 ip6_getbit(ip6_addr a, uint pos) { return a.addr[pos / 32] & (0x80000000 >> (pos % 32)); } static inline u32 ip4_setbit(ip4_addr *a, uint pos) { return _I(*a) |= (0x80000000 >> pos); } static inline u32 ip6_setbit(ip6_addr *a, uint pos) { return a->addr[pos / 32] |= (0x80000000 >> (pos % 32)); } static inline u32 ip4_clrbit(ip4_addr *a, uint pos) { return _I(*a) &= ~(0x80000000 >> pos); } static inline u32 ip6_clrbit(ip6_addr *a, uint pos) { return a->addr[pos / 32] &= ~(0x80000000 >> (pos % 32)); } static inline ip4_addr ip4_opposite_m1(ip4_addr a) { return _MI4(_I(a) ^ 1); } static inline ip4_addr ip4_opposite_m2(ip4_addr a) { return _MI4(_I(a) ^ 3); } static inline ip6_addr ip6_opposite_m1(ip6_addr a) { return _MI6(_I0(a), _I1(a), _I2(a), _I3(a) ^ 1); } static inline ip6_addr ip6_opposite_m2(ip6_addr a) { return _MI6(_I0(a), _I1(a), _I2(a), _I3(a) ^ 3); } ip4_addr ip4_class_mask(ip4_addr ad); #define ipa_opposite_m1(x) ip6_opposite_m1(x) #define ipa_opposite_m2(x) ip6_opposite_m2(x) /* * Host/network order conversions */ static inline ip4_addr ip4_hton(ip4_addr a) { return _MI4(htonl(_I(a))); } static inline ip4_addr ip4_ntoh(ip4_addr a) { return _MI4(ntohl(_I(a))); } static inline ip6_addr ip6_hton(ip6_addr a) { return _MI6(htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a))); } static inline ip6_addr ip6_ntoh(ip6_addr a) { return _MI6(ntohl(_I0(a)), ntohl(_I1(a)), ntohl(_I2(a)), ntohl(_I3(a))); } #define MPLS_MAX_LABEL_STACK 8 typedef struct mpls_label_stack { uint len; u32 stack[MPLS_MAX_LABEL_STACK]; } mpls_label_stack; static inline int mpls_get(const char *buf, int buflen, u32 *stack) { for (int i=0; (i> 12; if (s & 0x100) return i+1; } return -1; } static inline int mpls_put(char *buf, int len, u32 *stack) { for (int i=0; i * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: IP addresses * * BIRD uses its own abstraction of IP address in order to share the same * code for both IPv4 and IPv6. IP addresses are represented as entities * of type &ip_addr which are never to be treated as numbers and instead * they must be manipulated using the following functions and macros. */ #include #include "nest/bird.h" #include "lib/ip.h" int ip6_compare(ip6_addr a, ip6_addr b) { int i; for (i=0; i<4; i++) if (a.addr[i] > b.addr[i]) return 1; else if (a.addr[i] < b.addr[i]) return -1; return 0; } ip6_addr ip6_mkmask(uint n) { ip6_addr a; int i; for (i=0; i<4; i++) { if (!n) a.addr[i] = 0; else if (n >= 32) { a.addr[i] = ~0; n -= 32; } else { a.addr[i] = u32_mkmask(n); n = 0; } } return a; } uint ip6_masklen(ip6_addr *a) { int i, j, n; for (i=0, n=0; i<4; i++, n+=32) if (a->addr[i] != ~0U) { j = u32_masklen(a->addr[i]); if (j == 255) return j; n += j; while (++i < 4) if (a->addr[i]) return 255; break; } return n; } int ip4_classify(ip4_addr ad) { u32 a = _I(ad); u32 b = a >> 24U; if (b && b <= 0xdf) { if (b == 0x7f) return IADDR_HOST | SCOPE_HOST; else if ((b == 0x0a) || ((a & 0xffff0000) == 0xc0a80000) || ((a & 0xfff00000) == 0xac100000)) return IADDR_HOST | SCOPE_SITE; else return IADDR_HOST | SCOPE_UNIVERSE; } if (b >= 0xe0 && b <= 0xef) return IADDR_MULTICAST | SCOPE_UNIVERSE; if (a == 0xffffffff) return IADDR_BROADCAST | SCOPE_LINK; return IADDR_INVALID; } int ip6_classify(ip6_addr *a) { u32 x = a->addr[0]; if ((x & 0xe0000000) == 0x20000000) /* 2000::/3 Aggregatable Global Unicast Address */ return IADDR_HOST | SCOPE_UNIVERSE; if ((x & 0xffc00000) == 0xfe800000) /* fe80::/10 Link-Local Address */ return IADDR_HOST | SCOPE_LINK; if ((x & 0xffc00000) == 0xfec00000) /* fec0::/10 Site-Local Address */ return IADDR_HOST | SCOPE_SITE; if ((x & 0xfe000000) == 0xfc000000) /* fc00::/7 Unique Local Unicast Address (RFC 4193) */ return IADDR_HOST | SCOPE_SITE; if ((x & 0xff000000) == 0xff000000) /* ff00::/8 Multicast Address */ { uint scope = (x >> 16) & 0x0f; switch (scope) { case 1: return IADDR_MULTICAST | SCOPE_HOST; case 2: return IADDR_MULTICAST | SCOPE_LINK; case 5: return IADDR_MULTICAST | SCOPE_SITE; case 8: return IADDR_MULTICAST | SCOPE_ORGANIZATION; case 14: return IADDR_MULTICAST | SCOPE_UNIVERSE; default: return IADDR_MULTICAST | SCOPE_UNDEFINED; } } if (!x && !a->addr[1]) { u32 a2 = a->addr[2]; u32 a3 = a->addr[3]; if (a2 == 0 && a3 == 1) return IADDR_HOST | SCOPE_HOST; /* Loopback address */ if (a2 == 0) return ip4_classify(_MI4(a3)); /* IPv4 compatible addresses */ if (a2 == 0xffff) return ip4_classify(_MI4(a3)); /* IPv4 mapped addresses */ return IADDR_INVALID; } return IADDR_HOST | SCOPE_UNDEFINED; } /* * Conversion of IPv6 address to presentation format and vice versa. * Heavily inspired by routines written by Paul Vixie for the BIND project * and of course by RFC 2373. */ char * ip4_ntop(ip4_addr a, char *b) { u32 x = _I(a); return b + bsprintf(b, "%d.%d.%d.%d", (x >> 24) & 0xff, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); } char * ip6_ntop(ip6_addr a, char *b) { u16 words[8]; int bestpos, bestlen, curpos, curlen, i; /* First of all, preprocess the address and find the longest run of zeros */ bestlen = bestpos = curpos = curlen = 0; for (i=0; i<8; i++) { u32 x = a.addr[i/2]; words[i] = ((i%2) ? x : (x >> 16)) & 0xffff; if (words[i]) curlen = 0; else { if (!curlen) curpos = i; curlen++; if (curlen > bestlen) { bestpos = curpos; bestlen = curlen; } } } if (bestlen < 2) bestpos = -1; /* Is it an encapsulated IPv4 address? */ if (!bestpos && ((bestlen == 5 && a.addr[2] == 0xffff) || (bestlen == 6))) { u32 x = a.addr[3]; b += bsprintf(b, "::%s%d.%d.%d.%d", a.addr[2] ? "ffff:" : "", (x >> 24) & 0xff, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff); return b; } /* Normal IPv6 formatting, compress the largest sequence of zeros */ for (i=0; i<8; i++) { if (i == bestpos) { i += bestlen - 1; *b++ = ':'; if (i == 7) *b++ = ':'; } else { if (i) *b++ = ':'; b += bsprintf(b, "%x", words[i]); } } *b = 0; return b; } int ip4_pton(const char *a, ip4_addr *o) { int i; unsigned long int l; u32 ia = 0; i=4; while (i--) { char *d, *c = strchr(a, '.'); if (!c != !i) return 0; l = bstrtoul10(a, &d); if (((d != c) && *d) || (l > 255)) return 0; ia = (ia << 8) | l; if (c) c++; a = c; } *o = ip4_from_u32(ia); return 1; } int ip6_pton(const char *a, ip6_addr *o) { u16 words[8]; int i, j, k, l, hfil; const char *start; if (!a[0]) /* Empty string check */ return 0; if (a[0] == ':') /* Leading :: */ { if (a[1] != ':') return 0; a++; } hfil = -1; i = 0; while (*a) { if (*a == ':') /* :: */ { if (hfil >= 0) return 0; hfil = i; a++; continue; } j = 0; l = 0; start = a; for (;;) { if (*a >= '0' && *a <= '9') k = *a++ - '0'; else if (*a >= 'A' && *a <= 'F') k = *a++ - 'A' + 10; else if (*a >= 'a' && *a <= 'f') k = *a++ - 'a' + 10; else break; j = (j << 4) + k; if (j >= 0x10000 || ++l > 4) return 0; } if (*a == ':' && a[1]) a++; else if (*a == '.' && (i == 6 || (i < 6 && hfil >= 0))) { /* Embedded IPv4 address */ ip4_addr x; if (!ip4_pton(start, &x)) return 0; words[i++] = _I(x) >> 16; words[i++] = _I(x); break; } else if (*a) return 0; if (i >= 8) return 0; words[i++] = j; } /* Replace :: with an appropriate number of zeros */ if (hfil >= 0) { j = 8 - i; for (i=7; i-j >= hfil; i--) words[i] = words[i-j]; for (; i>=hfil; i--) words[i] = 0; } else if (i != 8) /* Incomplete address */ return 0; /* Convert the address to ip6_addr format */ for (i=0; i<4; i++) o->addr[i] = (words[2*i] << 16) | words[2*i+1]; return 1; } /** * ip_scope_text - get textual representation of address scope * @scope: scope (%SCOPE_xxx) * * Returns a pointer to a textual name of the scope given. */ char * ip_scope_text(uint scope) { static char *scope_table[] = { "host", "link", "site", "org", "univ", "undef" }; if (scope > SCOPE_UNDEFINED) return "?"; else return scope_table[scope]; } ip4_addr ip4_class_mask(ip4_addr ad) { u32 m, a = _I(ad); if (a == 0x00000000) m = 0x00000000; else if (a < 0x80000000) m = 0xff000000; else if (a < 0xc0000000) m = 0xffff0000; else m = 0xffffff00; if (a & ~m) m = 0xffffffff; return _MI4(m); } #if 0 /** * ipa_equal - compare two IP addresses for equality * @x: IP address * @y: IP address * * ipa_equal() returns 1 if @x and @y represent the same IP address, else 0. */ int ipa_equal(ip_addr x, ip_addr y) { DUMMY } /** * ipa_nonzero - test if an IP address is defined * @x: IP address * * ipa_nonzero returns 1 if @x is a defined IP address (not all bits are zero), * else 0. * * The undefined all-zero address is reachable as a |IPA_NONE| macro. */ int ipa_nonzero(ip_addr x) { DUMMY } /** * ipa_and - compute bitwise and of two IP addresses * @x: IP address * @y: IP address * * This function returns a bitwise and of @x and @y. It's primarily * used for network masking. */ ip_addr ipa_and(ip_addr x, ip_addr y) { DUMMY } /** * ipa_or - compute bitwise or of two IP addresses * @x: IP address * @y: IP address * * This function returns a bitwise or of @x and @y. */ ip_addr ipa_or(ip_addr x, ip_addr y) { DUMMY } /** * ipa_xor - compute bitwise xor of two IP addresses * @x: IP address * @y: IP address * * This function returns a bitwise xor of @x and @y. */ ip_addr ipa_xor(ip_addr x, ip_addr y) { DUMMY } /** * ipa_not - compute bitwise negation of two IP addresses * @x: IP address * * This function returns a bitwise negation of @x. */ ip_addr ipa_not(ip_addr x) { DUMMY } /** * ipa_mkmask - create a netmask * @x: prefix length * * This function returns an &ip_addr corresponding of a netmask * of an address prefix of size @x. */ ip_addr ipa_mkmask(int x) { DUMMY } /** * ipa_masklen - calculate netmask length * @x: IP address * * This function checks whether @x represents a valid netmask and * returns the size of the associate network prefix or -1 for invalid * mask. */ int ipa_masklen(ip_addr x) { DUMMY } /** * ipa_hash - hash IP addresses * @x: IP address * * ipa_hash() returns a 16-bit hash value of the IP address @x. */ int ipa_hash(ip_addr x) { DUMMY } /** * ipa_hton - convert IP address to network order * @x: IP address * * Converts the IP address @x to the network byte order. * * Beware, this is a macro and it alters the argument! */ void ipa_hton(ip_addr x) { DUMMY } /** * ipa_ntoh - convert IP address to host order * @x: IP address * * Converts the IP address @x from the network byte order. * * Beware, this is a macro and it alters the argument! */ void ipa_ntoh(ip_addr x) { DUMMY } /** * ipa_classify - classify an IP address * @x: IP address * * ipa_classify() returns an address class of @x, that is a bitwise or * of address type (%IADDR_INVALID, %IADDR_HOST, %IADDR_BROADCAST, %IADDR_MULTICAST) * with address scope (%SCOPE_HOST to %SCOPE_UNIVERSE) or -1 (%IADDR_INVALID) * for an invalid address. */ int ipa_classify(ip_addr x) { DUMMY } /** * ip4_class_mask - guess netmask according to address class * @x: IPv4 address * * This function (available in IPv4 version only) returns a * network mask according to the address class of @x. Although * classful addressing is nowadays obsolete, there still live * routing protocols transferring no prefix lengths nor netmasks * and this function could be useful to them. */ ip4_addr ip4_class_mask(ip4_addr x) { DUMMY } /** * ipa_from_u32 - convert IPv4 address to an integer * @x: IP address * * This function takes an IPv4 address and returns its numeric * representation. */ u32 ipa_from_u32(ip_addr x) { DUMMY } /** * ipa_to_u32 - convert integer to IPv4 address * @x: a 32-bit integer * * ipa_to_u32() takes a numeric representation of an IPv4 address * and converts it to the corresponding &ip_addr. */ ip_addr ipa_to_u32(u32 x) { DUMMY } /** * ipa_compare - compare two IP addresses for order * @x: IP address * @y: IP address * * The ipa_compare() function takes two IP addresses and returns * -1 if @x is less than @y in canonical ordering (lexicographical * order of the bit strings), 1 if @x is greater than @y and 0 * if they are the same. */ int ipa_compare(ip_addr x, ip_addr y) { DUMMY } /** * ipa_build6 - build an IPv6 address from parts * @a1: part #1 * @a2: part #2 * @a3: part #3 * @a4: part #4 * * ipa_build() takes @a1 to @a4 and assembles them to a single IPv6 * address. It's used for example when a protocol wants to bind its * socket to a hard-wired multicast address. */ ip_addr ipa_build6(u32 a1, u32 a2, u32 a3, u32 a4) { DUMMY } /** * ip_ntop - convert IP address to textual representation * @a: IP address * @buf: buffer of size at least %STD_ADDRESS_P_LENGTH * * This function takes an IP address and creates its textual * representation for presenting to the user. */ char *ip_ntop(ip_addr a, char *buf) { DUMMY } /** * ip_ntox - convert IP address to hexadecimal representation * @a: IP address * @buf: buffer of size at least %STD_ADDRESS_P_LENGTH * * This function takes an IP address and creates its hexadecimal * textual representation. Primary use: debugging dumps. */ char *ip_ntox(ip_addr a, char *buf) { DUMMY } /** * ip_pton - parse textual representation of IP address * @a: textual representation * @o: where to put the resulting address * * This function parses a textual IP address representation and * stores the decoded address to a variable pointed to by @o. * Returns 0 if a parse error has occurred, else 0. */ int ip_pton(char *a, ip_addr *o) { DUMMY } #endif bird-2.0.8/lib/idm.h0000664000175000017500000000066414025744326013062 0ustar feelafeela/* * BIRD Library -- ID Map * * (c) 2013--2015 Ondrej Zajicek * (c) 2013--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_IDM_H_ #define _BIRD_IDM_H_ struct idm { u32 *data; u32 pos; u32 used; u32 size; }; void idm_init(struct idm *m, pool *p, uint size); u32 idm_alloc(struct idm *m); void idm_free(struct idm *m, u32 id); #endif bird-2.0.8/lib/idm.c0000664000175000017500000000250714025744326013053 0ustar feelafeela/* * BIRD Library -- ID Map * * (c) 2013--2015 Ondrej Zajicek * (c) 2013--2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "nest/bird.h" #include "lib/idm.h" #include "lib/resource.h" #include "lib/string.h" void idm_init(struct idm *m, pool *p, uint size) { m->pos = 0; m->used = 1; m->size = size; m->data = mb_allocz(p, m->size * sizeof(u32)); /* ID 0 is reserved */ m->data[0] = 1; } static inline int u32_cto(uint x) { return ffs(~x) - 1; } u32 idm_alloc(struct idm *m) { uint i, j; for (i = m->pos; i < m->size; i++) if (m->data[i] != 0xffffffff) goto found; /* If we are at least 7/8 full, expand */ if (m->used > (m->size * 28)) { m->size *= 2; m->data = mb_realloc(m->data, m->size * sizeof(u32)); memset(m->data + i, 0, (m->size - i) * sizeof(u32)); goto found; } for (i = 0; i < m->pos; i++) if (m->data[i] != 0xffffffff) goto found; ASSERT(0); found: ASSERT(i < 0x8000000); m->pos = i; j = u32_cto(m->data[i]); m->data[i] |= (1 << j); m->used++; return 32 * i + j; } void idm_free(struct idm *m, u32 id) { uint i = id / 32; uint j = id % 32; ASSERT((i < m->size) && (m->data[i] & (1 << j))); m->data[i] &= ~(1 << j); m->used--; } bird-2.0.8/lib/heap_test.c0000664000175000017500000000652014025744326014255 0ustar feelafeela/* * BIRD Library -- Universal Heap Macros Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "sysdep/config.h" #include "lib/heap.h" #define MAX_NUM 1000 #define SPECIAL_KEY -3213 #define MY_CMP(x, y) ((x) < (y)) #define MY_HEAP_SWAP(heap,a,b,t) \ do { \ bt_debug("swap(%u %u) ", a, b); \ HEAP_SWAP(heap,a,b,t); \ } while(0) static int heap[MAX_NUM+1]; static uint num; /* * A valid heap must follow these rules: * - `num >= 0` * - `heap[i] >= heap[i / 2]` for each `i` in `[2, num]` */ static int is_heap_valid(int heap[], uint num) { uint i; if (num > MAX_NUM) return 0; for (i = 2; i <= num; i++) if (heap[i] < heap[i / 2]) return 0; return 1; } static void show_heap(void) { uint i; bt_debug("\n"); bt_debug("numbers %u; ", num); for (i = 0; i <= num; i++) bt_debug("%d ", heap[i]); bt_debug(is_heap_valid(heap, num) ? "OK" : "NON-VALID HEAP!"); bt_debug("\n"); } static void init_heap(void) { uint i; num = 0; heap[0] = SPECIAL_KEY; /* heap[0] should be unused */ for (i = 1; i <= MAX_NUM; i++) heap[i] = 0; } static int t_heap_insert(void) { uint i; init_heap(); for (i = MAX_NUM; i >= 1; i--) { bt_debug("ins %u at pos %u ", i, MAX_NUM - i); heap[MAX_NUM - i + 1] = i; HEAP_INSERT(heap, ++num, int, MY_CMP, MY_HEAP_SWAP); show_heap(); bt_assert(is_heap_valid(heap, num)); } return 1; } static int t_heap_increase_decrease(void) { uint i; t_heap_insert(); for (i = 1; i <= MAX_NUM; i++) { if ((int)i > heap[i]) { bt_debug("inc %u ", i); heap[i] = i; HEAP_INCREASE(heap, num, int, MY_CMP, MY_HEAP_SWAP, i); } else if ((int)i < heap[i]) { bt_debug("dec %u ", i); heap[i] = i; HEAP_INCREASE(heap, num, int, MY_CMP, MY_HEAP_SWAP, i); } show_heap(); bt_assert(is_heap_valid(heap, num)); } return 1; } static int t_heap_delete(void) { uint i; t_heap_insert(); for (i = 1; i <= num; i++) { bt_debug("del at pos %u ", i); HEAP_DELETE(heap, num, int, MY_CMP, MY_HEAP_SWAP, i); show_heap(); bt_assert(is_heap_valid(heap, num)); } return 1; } static int t_heap_0(void) { init_heap(); t_heap_insert(); t_heap_increase_decrease(); t_heap_delete(); return heap[0] == SPECIAL_KEY; } static int t_heap_insert_random(void) { int i, j; int expected[MAX_NUM+1]; init_heap(); for (i = 1; i <= MAX_NUM; i++) { heap[i] = expected[i] = bt_random(); HEAP_INSERT(heap, ++num, int, MY_CMP, MY_HEAP_SWAP); show_heap(); bt_assert(is_heap_valid(heap, num)); } for (i = 1; i <= MAX_NUM; i++) for (j = 1; j <= MAX_NUM; j++) if(expected[i] == heap[j]) break; else if (j == MAX_NUM) { show_heap(); bt_abort_msg("Did not find a number %d in heap.", expected[i]); } return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_heap_insert, "Inserting a descending sequence of numbers (the worst case)"); bt_test_suite(t_heap_insert_random, "Inserting pseudo-random numbers"); bt_test_suite(t_heap_increase_decrease, "Increasing/Decreasing"); bt_test_suite(t_heap_delete, "Deleting"); bt_test_suite(t_heap_0, "Is a heap[0] really unused?"); return bt_exit_value(); } bird-2.0.8/lib/heap.h0000664000175000017500000001156414025744326013227 0ustar feelafeela/* * UCW Library -- Universal Heap Macros * * (c) 2001 Martin Mares * (c) 2005 Tomas Valla * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. */ /** * [[intro]] * Introduction * ------------ * * Binary heap is a simple data structure, which for example supports efficient insertions, deletions * and access to the minimal inserted item. We define several macros for such operations. * Note that because of simplicity of heaps, we have decided to define direct macros instead * of a <> as for several other data structures in the Libucw. * * A heap is represented by a number of elements and by an array of values. Beware that we * index this array from one, not from zero as do the standard C arrays. * * Most macros use these parameters: * * - @type - the type of elements * - @num - a variable (signed or unsigned integer) with the number of elements * - @heap - a C array of type @type; the heap is stored in `heap[1] .. heap[num]`; `heap[0]` is unused * - @less - a callback to compare two element values; `less(x, y)` shall return a non-zero value iff @x is lower than @y * - @swap - a callback to swap two array elements; `swap(heap, i, j, t)` must swap `heap[i]` with `heap[j]` with possible help of temporary variable @t (type @type). * * A valid heap must follow these rules: * * - `num >= 0` * - `heap[i] >= heap[i / 2]` for each `i` in `[2, num]` * * The first element `heap[1]` is always lower or equal to all other elements. * * [[macros]] * Macros * ------ */ /* For internal usage. */ #define HEAP_BUBBLE_DOWN_J(heap,num,less,swap) \ for (;;) \ { \ _l = 2*_j; \ if (_l > num) \ break; \ if (less(heap[_j],heap[_l]) && (_l == num || less(heap[_j],heap[_l+1]))) \ break; \ if (_l != num && less(heap[_l+1],heap[_l])) \ _l++; \ swap(heap,_j,_l,x); \ _j = _l; \ } /* For internal usage. */ #define HEAP_BUBBLE_UP_J(heap,num,less,swap) \ while (_j > 1) \ { \ _u = _j/2; \ if (less(heap[_u], heap[_j])) \ break; \ swap(heap,_u,_j,x); \ _j = _u; \ } /** * Shuffle the unordered array @heap of @num elements to become a valid heap. The time complexity is linear. **/ #define HEAP_INIT(heap,num,type,less,swap) \ do { \ uint _i = num; \ uint _j, _l; \ type x; \ while (_i >= 1) \ { \ _j = _i; \ HEAP_BUBBLE_DOWN_J(heap,num,less,swap) \ _i--; \ } \ } while(0) /** * Delete the minimum element `heap[1]` in `O(log(n))` time. * The removed value is moved just after the resulting heap (`heap[num + 1]`). **/ #define HEAP_DELMIN(heap,num,type,less,swap) \ do { \ uint _j, _l; \ type x; \ swap(heap,1,num,x); \ num--; \ _j = 1; \ HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \ } while(0) /** * Insert `heap[num]` in `O(log(n))` time. The value of @num must be increased before. **/ #define HEAP_INSERT(heap,num,type,less,swap) \ do { \ uint _j, _u; \ type x; \ _j = num; \ HEAP_BUBBLE_UP_J(heap,num,less,swap); \ } while(0) /** * If you need to increase the value of `heap[pos]`, just do it and then call this macro to rebuild the heap. * Only `heap[pos]` can be changed, the rest of the array must form a valid heap. * The time complexity is `O(log(n))`. **/ #define HEAP_INCREASE(heap,num,type,less,swap,pos) \ do { \ uint _j, _l; \ type x; \ _j = pos; \ HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \ } while(0) /** * If you need to decrease the value of `heap[pos]`, just do it and then call this macro to rebuild the heap. * Only `heap[pos]` can be changed, the rest of the array must form a valid heap. * The time complexity is `O(log(n))`. **/ #define HEAP_DECREASE(heap,num,type,less,swap,pos) \ do { \ uint _j, _u; \ type x; \ _j = pos; \ HEAP_BUBBLE_UP_J(heap,num,less,swap); \ } while(0) /** * Delete `heap[pos]` in `O(log(n))` time. **/ #define HEAP_DELETE(heap,num,type,less,swap,pos) \ do { \ uint _j, _l, _u; \ type x; \ _j = pos; \ swap(heap,_j,num,x); \ num--; \ if (less(heap[_j], heap[num+1])) \ HEAP_BUBBLE_UP_J(heap,num,less,swap) \ else \ HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \ } while(0) /** * Default swapping macro. **/ #define HEAP_SWAP(heap,a,b,t) (t=heap[a], heap[a]=heap[b], heap[b]=t) bird-2.0.8/lib/hash_test.c0000664000175000017500000001305314025744326014262 0ustar feelafeela/* * BIRD Library -- Hash Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #undef LOCAL_DEBUG #include "test/birdtest.h" #include "lib/hash.h" struct test_node { struct test_node *next; /* Hash chain */ u32 key; }; #define TEST_KEY(n) n->key #define TEST_NEXT(n) n->next #define TEST_EQ(n1,n2) n1 == n2 #define TEST_FN(n) (n) ^ u32_hash((n)) #define TEST_ORDER 13 #define TEST_PARAMS /TEST_ORDER, *2, 2, 2, TEST_ORDER, 20 #define TEST_REHASH test_rehash HASH_DEFINE_REHASH_FN(TEST, struct test_node); HASH(struct test_node) hash; struct pool *my_pool; #define MAX_NUM (1 << TEST_ORDER) struct test_node nodes[MAX_NUM]; static void print_rate_of_fulfilment(void) { int i; int num_stacked_items = 0; for (i = 0; i < MAX_NUM; i++) if (!hash.data[i]) num_stacked_items++; double percent_stacked_items = ((double)num_stacked_items/(double)MAX_NUM)*100.; bt_debug("%d (%.2f %%) chained of %d hashes \n", num_stacked_items, percent_stacked_items, MAX_NUM); } #ifdef LOCAL_DEBUG static void dump_nodes(void) { int i; for (i = 0; i < MAX_NUM; i++) bt_debug("nodes[%3d] is at address %14p has .key %3d, .next %14p \n", i, &nodes[i], nodes[i].key, nodes[i].next); } #endif static void init_hash_(uint order) { resource_init(); my_pool = rp_new(&root_pool, "Test pool"); HASH_INIT(hash, my_pool, order); int i; for (i = 0; i < MAX_NUM; i++) { nodes[i].key = i; nodes[i].next = NULL; } bt_debug("MAX_NUM %d \n", MAX_NUM); } static void init_hash(void) { init_hash_(TEST_ORDER); } static void validate_filled_hash(void) { int i; struct test_node *node; for (i = 0; i < MAX_NUM; i++) { node = HASH_FIND(hash, TEST, nodes[i].key); bt_assert_msg(node->key == nodes[i].key, "Hash should be filled, to find (%p) the node[%d] (%p) with .key = %u, .next %p", node, i, &nodes[i], nodes[i].key, nodes[i].next); } print_rate_of_fulfilment(); } static void validate_empty_hash(void) { int i; struct test_node *node; for (i = 0; i < MAX_NUM; i++) { node = HASH_FIND(hash, TEST, nodes[i].key); bt_assert_msg(node == NULL, "Hash should be empty, to find (%p) the node[%d] (%p) with .key %u, .next %p", node, i, &nodes[i], nodes[i].key, nodes[i].next); } } static void fill_hash(void) { int i; struct test_node *node; for (i = 0; i < MAX_NUM; i++) { nodes[i].key = i; node = &nodes[i]; HASH_INSERT(hash, TEST, node); } } static int t_insert_find(void) { init_hash(); fill_hash(); validate_filled_hash(); return 1; } static int t_insert_find_random(void) { init_hash(); int i; struct test_node *node; for (i = 0; i < MAX_NUM; i++) { nodes[i].key = bt_random(); node = &nodes[i]; HASH_INSERT(hash, TEST, node); } validate_filled_hash(); return 1; } static int t_insert2_find(void) { init_hash_(1); int i; struct test_node *node; for (i = 0; i < MAX_NUM; i++) { nodes[i].key = i; node = &nodes[i]; HASH_INSERT2(hash, TEST, my_pool, node); } bt_assert_msg(hash.order != 1, "The hash should auto-resize from order 2^1. The order of the hash is 2^%u.", hash.order); validate_filled_hash(); return 1; } static int t_walk(void) { init_hash(); fill_hash(); uint i; uint check[MAX_NUM]; for (i = 0; i < MAX_NUM; i++) check[i] = 0; HASH_WALK(hash, next, n) { check[n->key]++; } HASH_WALK_END; for (i = 0; i < MAX_NUM; i++) bt_assert(check[i] == 1); return 1; } static int t_walk_delsafe_delete(void) { init_hash(); fill_hash(); HASH_WALK_DELSAFE(hash, next, n) { HASH_DELETE(hash, TEST, n->key); } HASH_WALK_DELSAFE_END; validate_empty_hash(); return 1; } static int t_walk_delsafe_remove(void) { init_hash(); fill_hash(); HASH_WALK_DELSAFE(hash, next, n) { HASH_REMOVE(hash, TEST, n); } HASH_WALK_DELSAFE_END; validate_empty_hash(); return 1; } static int t_walk_delsafe_delete2(void) { init_hash(); fill_hash(); HASH_WALK_DELSAFE(hash, next, n) { HASH_DELETE2(hash, TEST, my_pool, n->key); } HASH_WALK_DELSAFE_END; validate_empty_hash(); return 1; } static int t_walk_delsafe_remove2(void) { init_hash(); fill_hash(); HASH_WALK_DELSAFE(hash, next, n) { HASH_REMOVE2(hash, TEST, my_pool, n); } HASH_WALK_DELSAFE_END; validate_empty_hash(); return 1; } static int t_walk_filter(void) { init_hash(); fill_hash(); uint i; uint check[MAX_NUM]; for (i = 0; i < MAX_NUM; i++) check[i] = 0; HASH_WALK_FILTER(hash, next, n, m) { bt_assert(n == *m); check[n->key]++; } HASH_WALK_FILTER_END; for (i = 0; i < MAX_NUM; i++) bt_assert(check[i] == 1); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_insert_find, "HASH_INSERT and HASH_FIND"); bt_test_suite(t_insert_find_random, "HASH_INSERT pseudo-random keys and HASH_FIND"); bt_test_suite(t_insert2_find, "HASH_INSERT2 and HASH_FIND. HASH_INSERT2 is HASH_INSERT and a smart auto-resize function"); bt_test_suite(t_walk, "HASH_WALK"); bt_test_suite(t_walk_delsafe_delete, "HASH_WALK_DELSAFE and HASH_DELETE"); bt_test_suite(t_walk_delsafe_delete2, "HASH_WALK_DELSAFE and HASH_DELETE2. HASH_DELETE2 is HASH_DELETE and smart auto-resize function"); bt_test_suite(t_walk_delsafe_remove, "HASH_WALK_DELSAFE and HASH_REMOVE"); bt_test_suite(t_walk_delsafe_remove2, "HASH_WALK_DELSAFE and HASH_REMOVE2. HASH_REMOVE2 is HASH_REMOVE and smart auto-resize function"); bt_test_suite(t_walk_filter, "HASH_WALK_FILTER"); return bt_exit_value(); } bird-2.0.8/lib/hash.h0000664000175000017500000001445414025744326013236 0ustar feelafeela/* * BIRD Library -- Generic Hash Table * * (c) 2013 Ondrej Zajicek * (c) 2013 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_HASH_H_ #define _BIRD_HASH_H_ #define HASH(type) struct { type **data; uint count, order; } #define HASH_TYPE(v) typeof(** (v).data) #define HASH_SIZE(v) (1U << (v).order) #define HASH_EQ(v,id,k1,k2...) (id##_EQ(k1, k2)) #define HASH_FN(v,id,key...) ((u32) (id##_FN(key)) >> (32 - (v).order)) #define HASH_INIT(v,pool,init_order) \ ({ \ (v).count = 0; \ (v).order = (init_order); \ (v).data = mb_allocz(pool, HASH_SIZE(v) * sizeof(* (v).data)); \ }) #define HASH_FREE(v) \ ({ \ mb_free((v).data); \ (v) = (typeof(v)){ }; \ }) #define HASH_FIND(v,id,key...) \ ({ \ u32 _h = HASH_FN(v, id, key); \ HASH_TYPE(v) *_n = (v).data[_h]; \ while (_n && !HASH_EQ(v, id, id##_KEY(_n), key)) \ _n = id##_NEXT(_n); \ _n; \ }) #define HASH_INSERT(v,id,node) \ ({ \ u32 _h = HASH_FN(v, id, id##_KEY((node))); \ HASH_TYPE(v) **_nn = (v).data + _h; \ id##_NEXT(node) = *_nn; \ *_nn = node; \ (v).count++; \ }) #define HASH_DO_REMOVE(v,id,_nn) \ ({ \ *_nn = id##_NEXT((*_nn)); \ (v).count--; \ }) #define HASH_DELETE(v,id,key...) \ ({ \ u32 _h = HASH_FN(v, id, key); \ HASH_TYPE(v) *_n, **_nn = (v).data + _h; \ \ while ((*_nn) && !HASH_EQ(v, id, id##_KEY((*_nn)), key)) \ _nn = &(id##_NEXT((*_nn))); \ \ if (_n = *_nn) \ HASH_DO_REMOVE(v,id,_nn); \ _n; \ }) #define HASH_REMOVE(v,id,node) \ ({ \ u32 _h = HASH_FN(v, id, id##_KEY((node))); \ HASH_TYPE(v) *_n, **_nn = (v).data + _h; \ \ while ((*_nn) && (*_nn != (node))) \ _nn = &(id##_NEXT((*_nn))); \ \ if (_n = *_nn) \ HASH_DO_REMOVE(v,id,_nn); \ _n; \ }) #define HASH_REHASH(v,id,pool,step) \ ({ \ HASH_TYPE(v) *_n, *_n2, **_od; \ uint _i, _os; \ \ _os = HASH_SIZE(v); \ _od = (v).data; \ (v).count = 0; \ (v).order += (step); \ (v).data = mb_allocz(pool, HASH_SIZE(v) * sizeof(* (v).data)); \ \ for (_i = 0; _i < _os; _i++) \ for (_n = _od[_i]; _n && (_n2 = id##_NEXT(_n), 1); _n = _n2) \ HASH_INSERT(v, id, _n); \ \ mb_free(_od); \ }) #define REHASH_LO_MARK(a,b,c,d,e,f) a #define REHASH_HI_MARK(a,b,c,d,e,f) b #define REHASH_LO_STEP(a,b,c,d,e,f) c #define REHASH_HI_STEP(a,b,c,d,e,f) d #define REHASH_LO_BOUND(a,b,c,d,e,f) e #define REHASH_HI_BOUND(a,b,c,d,e,f) f #define HASH_DEFINE_REHASH_FN(id,type) \ static void id##_REHASH(void *v, pool *p, int step) \ { HASH_REHASH(* (HASH(type) *) v, id, p, step); } #define HASH_MAY_STEP_UP(v,id,pool) HASH_MAY_STEP_UP_(v,pool, id##_REHASH, id##_PARAMS) #define HASH_MAY_STEP_DOWN(v,id,pool) HASH_MAY_STEP_DOWN_(v,pool, id##_REHASH, id##_PARAMS) #define HASH_MAY_RESIZE_DOWN(v,id,pool) HASH_MAY_RESIZE_DOWN_(v,pool, id##_REHASH, id##_PARAMS) #define HASH_MAY_STEP_UP_(v,pool,rehash_fn,args) \ ({ \ if (((v).count > (HASH_SIZE(v) REHASH_HI_MARK(args))) && \ ((v).order < (REHASH_HI_BOUND(args)))) \ rehash_fn(&(v), pool, REHASH_HI_STEP(args)); \ }) #define HASH_MAY_STEP_DOWN_(v,pool,rehash_fn,args) \ ({ \ if (((v).count < (HASH_SIZE(v) REHASH_LO_MARK(args))) && \ ((v).order > (REHASH_LO_BOUND(args)))) \ rehash_fn(&(v), pool, -(REHASH_LO_STEP(args))); \ }) #define HASH_MAY_RESIZE_DOWN_(v,pool,rehash_fn,args) \ ({ \ uint _o = (v).order; \ while (((v).count < ((1U << _o) REHASH_LO_MARK(args))) && \ (_o > (REHASH_LO_BOUND(args)))) \ _o -= (REHASH_LO_STEP(args)); \ if (_o < (v).order) \ rehash_fn(&(v), pool, _o - (v).order); \ }) #define HASH_INSERT2(v,id,pool,node) \ ({ \ HASH_INSERT(v, id, node); \ HASH_MAY_STEP_UP(v, id, pool); \ }) #define HASH_DELETE2(v,id,pool,key...) \ ({ \ HASH_TYPE(v) *_n = HASH_DELETE(v, id, key); \ if (_n) HASH_MAY_STEP_DOWN(v, id, pool); \ _n; \ }) #define HASH_REMOVE2(v,id,pool,node) \ ({ \ HASH_TYPE(v) *_n = HASH_REMOVE(v, id, node); \ if (_n) HASH_MAY_STEP_DOWN(v, id, pool); \ _n; \ }) #define HASH_WALK(v,next,n) \ do { \ HASH_TYPE(v) *n; \ uint _i; \ uint _s = HASH_SIZE(v); \ for (_i = 0; _i < _s; _i++) \ for (n = (v).data[_i]; n; n = n->next) #define HASH_WALK_END } while (0) #define HASH_WALK_DELSAFE(v,next,n) \ do { \ HASH_TYPE(v) *n, *_next; \ uint _i; \ uint _s = HASH_SIZE(v); \ for (_i = 0; _i < _s; _i++) \ for (n = (v).data[_i]; n && (_next = n->next, 1); n = _next) #define HASH_WALK_DELSAFE_END } while (0) #define HASH_WALK_FILTER(v,next,n,nn) \ do { \ HASH_TYPE(v) *n, **nn; \ uint _i; \ uint _s = HASH_SIZE(v); \ for (_i = 0; _i < _s; _i++) \ for (nn = (v).data + _i; n = *nn; (*nn == n) ? (nn = &n->next) : NULL) #define HASH_WALK_FILTER_END } while (0) static inline void mem_hash_init(u64 *h) { *h = 0x001047d54778bcafULL; } static inline void mem_hash_mix(u64 *h, const void *p, uint s) { const u64 multiplier = 0xb38bc09a61202731ULL; const char *pp = p; uint i; for (i=0; i> 32) ^ (*h & 0xffffffff)); } static inline uint mem_hash(const void *p, uint s) { static u64 h; mem_hash_init(&h); mem_hash_mix(&h, p, s); return mem_hash_value(&h); } static inline uint ptr_hash(void *ptr) { uintptr_t p = (uintptr_t) ptr; return p ^ (p << 8) ^ (p >> 16); } #endif bird-2.0.8/lib/flowspec_test.c0000664000175000017500000004572214025744326015171 0ustar feelafeela/* * BIRD Library -- Flow specification (RFC 5575) Tests * * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/flowspec.h" #define NET_ADDR_FLOW4_(what,prefix,pxlen,data_) \ do \ { \ what = alloca(sizeof(net_addr_flow4) + 128); \ *what = NET_ADDR_FLOW4(prefix, pxlen, sizeof(data_)); \ memcpy(what->data, &(data_), sizeof(data_)); \ } while(0) #define NET_ADDR_FLOW6_(what,prefix,pxlen,data_) \ do \ { \ what = alloca(sizeof(net_addr_flow6) + 128); \ *what = NET_ADDR_FLOW6(prefix, pxlen, sizeof(data_)); \ memcpy(what->data, &(data_), sizeof(data_)); \ } while(0) static int t_read_length(void) { byte data[] = { 0xcc, 0xcc, 0xcc }; for (uint expect = 0; expect < 0xf0; expect++) { *data = expect; uint get = flow_read_length(data); bt_assert_msg(get == expect, "Testing get length 0x%02x (get 0x%02x)", expect, get); } for (uint expect = 0; expect <= 0xfff; expect++) { put_u16(data, expect | 0xf000); uint get = flow_read_length(data); bt_assert_msg(get == expect, "Testing get length 0x%03x (get 0x%03x)", expect, get); } return 1; } static int t_write_length(void) { byte data[] = { 0xcc, 0xcc, 0xcc }; for (uint expect = 0; expect <= 0xfff; expect++) { uint offset = flow_write_length(data, expect); uint set = (expect < 0xf0) ? *data : (get_u16(data) & 0x0fff); bt_assert_msg(set == expect, "Testing set length 0x%03x (set 0x%03x)", expect, set); bt_assert(offset == (expect < 0xf0 ? 1 : 2)); } return 1; } static int t_first_part(void) { net_addr_flow4 *f; NET_ADDR_FLOW4_(f, ip4_build(10,0,0,1), 24, ((byte[]) { 0x00, 0x00, 0xab })); const byte *under240 = &f->data[1]; const byte *above240 = &f->data[2]; /* Case 0x00 0x00 */ bt_assert(flow4_first_part(f) == NULL); /* Case 0x01 0x00 */ f->data[0] = 0x01; bt_assert(flow4_first_part(f) == under240); /* Case 0xef 0x00 */ f->data[0] = 0xef; bt_assert(flow4_first_part(f) == under240); /* Case 0xf0 0x00 */ f->data[0] = 0xf0; bt_assert(flow4_first_part(f) == NULL); /* Case 0xf0 0x01 */ f->data[1] = 0x01; bt_assert(flow4_first_part(f) == above240); /* Case 0xff 0xff */ f->data[0] = 0xff; f->data[1] = 0xff; bt_assert(flow4_first_part(f) == above240); return 1; } static int t_iterators4(void) { net_addr_flow4 *f; NET_ADDR_FLOW4_(f, ip4_build(5,6,7,0), 24, ((byte[]) { 25, /* Length */ FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_SRC_PREFIX, 32, 10, 11, 12, 13, FLOW_TYPE_IP_PROTOCOL, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_TCP_FLAGS, 0x80, 0x55, })); const byte *start = f->data; const byte *p1_dst_pfx = &f->data[1]; const byte *p2_src_pfx = &f->data[6]; const byte *p3_ip_proto = &f->data[12]; const byte *p4_port = &f->data[15]; const byte *p5_tcp_flags = &f->data[23]; const byte *end = &f->data[25]; bt_assert(flow_read_length(f->data) == (end-start)); bt_assert(flow4_first_part(f) == p1_dst_pfx); bt_assert(flow4_next_part(p1_dst_pfx, end) == p2_src_pfx); bt_assert(flow4_next_part(p2_src_pfx, end) == p3_ip_proto); bt_assert(flow4_next_part(p3_ip_proto, end) == p4_port); bt_assert(flow4_next_part(p4_port, end) == p5_tcp_flags); bt_assert(flow4_next_part(p5_tcp_flags, end) == NULL); return 1; } static int t_iterators6(void) { net_addr_flow6 *f; NET_ADDR_FLOW6_(f, ip6_build(0,0,0x12345678,0x9a000000), 0x68, ((byte[]) { 26, /* Length */ FLOW_TYPE_DST_PREFIX, 0x68, 0x40, 0x12, 0x34, 0x56, 0x78, 0x9a, FLOW_TYPE_SRC_PREFIX, 0x08, 0x0, 0xc0, FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_LABEL, 0x80, 0x55, })); const byte *start = f->data; const byte *p1_dst_pfx = &f->data[1]; const byte *p2_src_pfx = &f->data[9]; const byte *p3_next_header = &f->data[13]; const byte *p4_port = &f->data[16]; const byte *p5_label = &f->data[24]; const byte *end = &f->data[26]; bt_assert(flow_read_length(f->data) == (end-start)); bt_assert(flow6_first_part(f) == p1_dst_pfx); bt_assert(flow6_next_part(p1_dst_pfx, end) == p2_src_pfx); bt_assert(flow6_next_part(p2_src_pfx, end) == p3_next_header); bt_assert(flow6_next_part(p3_next_header, end) == p4_port); bt_assert(flow6_next_part(p4_port, end) == p5_label); bt_assert(flow6_next_part(p5_label, end) == NULL); return 1; } static int t_accessors4(void) { net_addr_flow4 *f; NET_ADDR_FLOW4_(f, ip4_build(5,6,7,0), 24, ((byte[]) { 25, /* Length */ FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_SRC_PREFIX, 32, 10, 11, 12, 13, FLOW_TYPE_IP_PROTOCOL, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_TCP_FLAGS, 0x80, 0x55, })); const byte *p1_dst_px = &f->data[1]; const ip4_addr p1_dst_addr = ip4_build(5,6,7,0); const byte *p2_src_px = &f->data[6]; const ip4_addr p2_src_addr = ip4_build(10,11,12,13); bt_assert(ip4_equal(flow_read_ip4_part(p1_dst_px), p1_dst_addr)); bt_assert(ip4_equal(flow_read_ip4_part(p2_src_px), p2_src_addr)); return 1; } static int t_accessors6(void) { net_addr_flow6 *f; NET_ADDR_FLOW6_(f, ip6_build(0,0,0x12345678,0x9a000000), 0x68, ((byte[]) { 26, /* Length */ FLOW_TYPE_DST_PREFIX, 0x68, 0x40, 0x12, 0x34, 0x56, 0x78, 0x9a, FLOW_TYPE_SRC_PREFIX, 0x08, 0x0, 0xc0, FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_LABEL, 0x80, 0x55, })); const byte *p1_dst_px = &f->data[1]; const ip6_addr p1_dst_addr = ip6_build(0,0,0x12345678,0x9a000000); const byte *p2_src_px = &f->data[9]; const ip6_addr p2_src_addr = ip6_build(0xc0000000, 0, 0, 0); bt_assert(ip6_equal(flow_read_ip6_part(p1_dst_px), p1_dst_addr)); bt_assert(ip6_equal(flow_read_ip6_part(p2_src_px), p2_src_addr)); return 1; } static int t_validation4(void) { enum flow_validated_state res; byte nlri1[] = { FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_SRC_PREFIX, 32, 10, 11, 12, 13, FLOW_TYPE_IP_PROTOCOL, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_TCP_FLAGS, 0x80, 0x55, }; /* Empty NLRI */ res = flow4_validate(nlri1, 0); bt_assert(res == FLOW_ST_VALID); /* Valid / Not Complete testing */ uint valid_sizes[] = {5, 11, 14, 22, 25, 0}; uint valid_idx = 0; for (uint size = 1; size <= sizeof(nlri1); size++) { res = flow4_validate(nlri1, size); bt_debug("size %u, result: %s\n", size, flow_validated_state_str(res)); if (size == valid_sizes[valid_idx]) { valid_idx++; bt_assert(res == FLOW_ST_VALID); } else { bt_assert(res == FLOW_ST_NOT_COMPLETE); } } /* Misc err tests */ struct tset { enum flow_validated_state expect; char *description; u16 size; byte *nlri; }; #define TS(type, msg, data) ((struct tset) {type, msg, sizeof(data), (data)}) struct tset tset[] = { TS( FLOW_ST_EXCEED_MAX_PREFIX_LENGTH, "33-length IPv4 prefix", ((byte []) { FLOW_TYPE_DST_PREFIX, 33, 5, 6, 7, 8, 9 }) ), TS( FLOW_ST_BAD_TYPE_ORDER, "Bad flowspec component type order", ((byte []) { FLOW_TYPE_SRC_PREFIX, 32, 10, 11, 12, 13, FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, }) ), TS( FLOW_ST_BAD_TYPE_ORDER, "Doubled destination prefix component", ((byte []) { FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, }) ), TS( FLOW_ST_AND_BIT_SHOULD_BE_UNSET, "The first numeric operator has set the AND bit", ((byte []) { FLOW_TYPE_PORT, 0x43, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, }) ), TS( FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED, "Set zero bit in operand to one", ((byte []) { FLOW_TYPE_IP_PROTOCOL, 0x89, 0x06, }) ), TS( FLOW_ST_UNKNOWN_COMPONENT, "Unknown component of type number 13", ((byte []) { FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_TCP_FLAGS, 0x80, 0x55, 13 /*something new*/, 0x80, 0x55, }) ), }; #undef TS for (uint tcase = 0; tcase < ARRAY_SIZE(tset); tcase++) { res = flow4_validate(tset[tcase].nlri, tset[tcase].size); bt_assert_msg(res == tset[tcase].expect, "Assertion (%s == %s) %s", flow_validated_state_str(res), flow_validated_state_str(tset[tcase].expect), tset[tcase].description); } return 1; } static int t_validation6(void) { enum flow_validated_state res; byte nlri1[] = { FLOW_TYPE_DST_PREFIX, 103, 61, 0x01, 0x12, 0x34, 0x56, 0x78, 0x98, FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0, FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_LABEL, 0x80, 0x55, }; /* Isn't included destination prefix */ res = flow6_validate(nlri1, 0); bt_assert(res == FLOW_ST_VALID); /* Valid / Not Complete testing */ uint valid_sizes[] = {0, 9, 13, 16, 24, 27, 0}; uint valid_idx = 0; for (uint size = 0; size <= sizeof(nlri1); size++) { res = flow6_validate(nlri1, size); bt_debug("size %u, result: %s\n", size, flow_validated_state_str(res)); if (size == valid_sizes[valid_idx]) { valid_idx++; bt_assert(res == FLOW_ST_VALID); } else { bt_assert(res == FLOW_ST_NOT_COMPLETE); } } /* Misc err tests */ struct tset { enum flow_validated_state expect; char *description; u16 size; byte *nlri; }; #define TS(type, msg, data) ((struct tset) {type, msg, sizeof(data), (data)}) struct tset tset[] = { TS( FLOW_ST_EXCEED_MAX_PREFIX_LENGTH, "129-length IPv6 prefix", ((byte []) { FLOW_TYPE_DST_PREFIX, 129, 64, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12 }) ), TS( FLOW_ST_EXCEED_MAX_PREFIX_OFFSET, "Prefix offset is higher than prefix length", ((byte []) { FLOW_TYPE_DST_PREFIX, 48, 64, 0x40, 0x12, 0x34 }) ), TS( FLOW_ST_BAD_TYPE_ORDER, "Bad flowspec component type order", ((byte []) { FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0, }) ), TS( FLOW_ST_BAD_TYPE_ORDER, "Doubled destination prefix component", ((byte []) { FLOW_TYPE_DST_PREFIX, 103, 61, 0x01, 0x12, 0x34, 0x56, 0x78, 0x98, FLOW_TYPE_DST_PREFIX, 103, 61, 0x01, 0x12, 0x34, 0x56, 0x78, 0x98, }) ), TS( FLOW_ST_AND_BIT_SHOULD_BE_UNSET, "The first numeric operator has set the AND bit", ((byte []) { FLOW_TYPE_PORT, 0x43, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90 }) ), TS( FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED, "Set zero bit in operand to one", ((byte []) { FLOW_TYPE_NEXT_HEADER, 0x89, 0x06 }) ), TS( FLOW_ST_VALID, "Component of type number 13 (Label) is well-known in IPv6", ((byte []) { FLOW_TYPE_LABEL, 0x80, 0x55 }) ), TS( FLOW_ST_UNKNOWN_COMPONENT, "Unknown component of type number 14", ((byte []) { FLOW_TYPE_LABEL, 0x80, 0x55, 14 /*something new*/, 0x80, 0x55, }) ) }; #undef TS for (uint tcase = 0; tcase < ARRAY_SIZE(tset); tcase++) { res = flow6_validate(tset[tcase].nlri, tset[tcase].size); bt_assert_msg(res == tset[tcase].expect, "Assertion (%s == %s) %s", flow_validated_state_str(res), flow_validated_state_str(tset[tcase].expect), tset[tcase].description); } return 1; } /* * Builder tests */ static int t_builder4(void) { resource_init(); struct flow_builder *fb = flow_builder_init(&root_pool); linpool *lp = lp_new_default(&root_pool); /* Expectation */ static byte nlri[] = { 25, FLOW_TYPE_DST_PREFIX, 24, 5, 6, 7, FLOW_TYPE_SRC_PREFIX, 32, 10, 11, 12, 13, FLOW_TYPE_IP_PROTOCOL, 0x80, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_TCP_FLAGS, 0x80, 0x55 }; net_addr_flow4 *expect; NET_ADDR_FLOW4_(expect, ip4_build(5, 6, 7, 0), 24, nlri); /* Normal order */ net_addr_ip4 n1; net_fill_ip4((net_addr *) &n1, ip4_build(5,6,7,0), 24); flow_builder_set_type(fb, FLOW_TYPE_DST_PREFIX); flow_builder4_add_pfx(fb, &n1); net_addr_ip4 n2; net_fill_ip4((net_addr *) &n2, ip4_build(10,11,12,13), 32); flow_builder_set_type(fb, FLOW_TYPE_SRC_PREFIX); flow_builder4_add_pfx(fb, &n2); flow_builder_set_type(fb, FLOW_TYPE_IP_PROTOCOL); flow_builder_add_op_val(fb, 0, 0x06); flow_builder_set_type(fb, FLOW_TYPE_PORT); flow_builder_add_op_val(fb, 0x03, 0x89); flow_builder_add_op_val(fb, 0x45, 0x8b); flow_builder_add_op_val(fb, 0x01, 0x1f90); /* Try put a component twice time */ flow_builder_set_type(fb, FLOW_TYPE_IP_PROTOCOL); flow_builder_add_op_val(fb, 0, 0x06); flow_builder_set_type(fb, FLOW_TYPE_TCP_FLAGS); flow_builder_add_op_val(fb, 0, 0x55); net_addr_flow4 *res = flow_builder4_finalize(fb, lp); bt_assert(memcmp(res, expect, expect->length) == 0); /* Reverse order */ flow_builder_clear(fb); flow_builder_set_type(fb, FLOW_TYPE_TCP_FLAGS); flow_builder_add_op_val(fb, 0, 0x55); flow_builder_set_type(fb, FLOW_TYPE_PORT); flow_builder_add_op_val(fb, 0x03, 0x89); flow_builder_add_op_val(fb, 0x45, 0x8b); flow_builder_add_op_val(fb, 0x01, 0x1f90); flow_builder_set_type(fb, FLOW_TYPE_IP_PROTOCOL); flow_builder_add_op_val(fb, 0, 0x06); net_fill_ip4((net_addr *) &n2, ip4_build(10,11,12,13), 32); flow_builder_set_type(fb, FLOW_TYPE_SRC_PREFIX); flow_builder4_add_pfx(fb, &n2); net_fill_ip4((net_addr *) &n1, ip4_build(5,6,7,0), 24); flow_builder_set_type(fb, FLOW_TYPE_DST_PREFIX); flow_builder4_add_pfx(fb, &n1); bt_assert(memcmp(res, expect, expect->length) == 0); return 1; } static int t_builder6(void) { net_addr_ip6 ip; resource_init(); linpool *lp = lp_new_default(&root_pool); struct flow_builder *fb = flow_builder_init(&root_pool); fb->ipv6 = 1; /* Expectation */ byte nlri[] = { 27, FLOW_TYPE_DST_PREFIX, 103, 61, 0x01, 0x12, 0x34, 0x56, 0x78, 0x98, FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0, FLOW_TYPE_NEXT_HEADER, 0x80, 0x06, FLOW_TYPE_PORT, 0x03, 0x89, 0x45, 0x8b, 0x91, 0x1f, 0x90, FLOW_TYPE_LABEL, 0x80, 0x55, }; net_addr_flow6 *expect; NET_ADDR_FLOW6_(expect, ip6_build(0, 1, 0x12345678, 0x98000000), 103, nlri); /* Normal order */ net_fill_ip6((net_addr *) &ip, ip6_build(0, 1, 0x12345678, 0x98000000), 103); flow_builder_set_type(fb, FLOW_TYPE_DST_PREFIX); flow_builder6_add_pfx(fb, &ip, 61); /* Try put a component twice time */ net_fill_ip6((net_addr *) &ip, ip6_build(0, 1, 0x12345678, 0x98000000), 103); flow_builder_set_type(fb, FLOW_TYPE_DST_PREFIX); bt_assert(flow_builder6_add_pfx(fb, &ip, 61) == 0); net_fill_ip6((net_addr *) &ip, ip6_build(0xc0000000,0,0,0), 8); flow_builder_set_type(fb, FLOW_TYPE_SRC_PREFIX); flow_builder6_add_pfx(fb, &ip, 0); flow_builder_set_type(fb, FLOW_TYPE_NEXT_HEADER); flow_builder_add_op_val(fb, 0, 0x06); flow_builder_set_type(fb, FLOW_TYPE_PORT); flow_builder_add_op_val(fb, 0x03, 0x89); flow_builder_add_op_val(fb, 0x45, 0x8b); flow_builder_add_op_val(fb, 0x01, 0x1f90); flow_builder_set_type(fb, FLOW_TYPE_LABEL); flow_builder_add_op_val(fb, 0, 0x55); net_addr_flow6 *res = flow_builder6_finalize(fb, lp); bt_assert(memcmp(res, expect, expect->length) == 0); /* Reverse order */ flow_builder_clear(fb); fb->ipv6 = 1; flow_builder_set_type(fb, FLOW_TYPE_LABEL); flow_builder_add_op_val(fb, 0, 0x55); flow_builder_set_type(fb, FLOW_TYPE_PORT); flow_builder_add_op_val(fb, 0x03, 0x89); flow_builder_add_op_val(fb, 0x45, 0x8b); flow_builder_add_op_val(fb, 0x01, 0x1f90); flow_builder_set_type(fb, FLOW_TYPE_NEXT_HEADER); flow_builder_add_op_val(fb, 0, 0x06); net_fill_ip6((net_addr *) &ip, ip6_build(0xc0000000,0,0,0), 8); flow_builder_set_type(fb, FLOW_TYPE_SRC_PREFIX); flow_builder6_add_pfx(fb, &ip, 0); net_fill_ip6((net_addr *) &ip, ip6_build(0, 1, 0x12345678, 0x98000000), 103); flow_builder_set_type(fb, FLOW_TYPE_DST_PREFIX); flow_builder6_add_pfx(fb, &ip, 61); res = flow_builder6_finalize(fb, lp); bt_assert(memcmp(res, expect, expect->length) == 0); return 1; } static int t_formatting4(void) { char b[1024]; byte nlri[] = { 0, FLOW_TYPE_DST_PREFIX, 0x08, 10, FLOW_TYPE_IP_PROTOCOL, 0x81, 23, FLOW_TYPE_DST_PORT, 0x02, 24, 0x44, 30, 0x03, 40, 0x45, 50, 0x03, 60, 0x45, 70, 0x01, 80, 0xc3, 90, FLOW_TYPE_SRC_PORT, 0x02, 24, 0x44, 0x1e, 0x01, 0x28, 0x01, 0x32, 0x03, 0x3c, 0x45, 0x46, 0x81, 0x50, FLOW_TYPE_ICMP_TYPE, 0x81, 0x50, FLOW_TYPE_ICMP_CODE, 0x81, 0x5a, FLOW_TYPE_TCP_FLAGS, 0x01, 0x03, 0xc2, 0x0c, FLOW_TYPE_PACKET_LENGTH, 0x03, 0, 0xd5, 0xff, 0xff, FLOW_TYPE_DSCP, 0x81, 63, FLOW_TYPE_FRAGMENT, 0x01, 0x01, 0x82, 0x02 }; *nlri = (u8) sizeof(nlri); net_addr_flow4 *input; NET_ADDR_FLOW4_(input, ip4_build(5, 6, 7, 0), 24, nlri); const char *expect = "flow4 { dst 10.0.0.0/8; proto 23; dport > 24 && < 30 || 40..50,60..70,80 && >= 90; sport > 24 && < 30 || 40,50,60..70,80; icmp type 80; icmp code 90; tcp flags 0x3/0x3,0x0/0xc; length 0..65535; dscp 63; fragment dont_fragment || !is_fragment; }"; bt_assert(flow4_net_format(b, sizeof(b), input) == strlen(expect)); bt_debug(" expect: '%s',\n output: '%s'\n", expect, b); bt_assert(strcmp(b, expect) == 0); return 1; } static int t_formatting6(void) { char b[1024]; byte nlri[] = { 0, FLOW_TYPE_DST_PREFIX, 103, 61, 0x01, 0x12, 0x34, 0x56, 0x78, 0x98, FLOW_TYPE_SRC_PREFIX, 8, 0, 0xc0, FLOW_TYPE_NEXT_HEADER, 0x81, 0x06, FLOW_TYPE_PORT, 0x03, 20, 0x45, 40, 0x91, 0x01, 0x11, FLOW_TYPE_LABEL, 0xa0, 0x12, 0x34, 0x56, 0x78, }; *nlri = (u8) sizeof(nlri); net_addr_flow6 *input; NET_ADDR_FLOW6_(input, ip6_build(0, 1, 0x12345678, 0x98000000), 103, nlri); const char *expect = "flow6 { dst ::1:1234:5678:9800:0/103 offset 61; src c000::/8; next header 6; port 20..40,273; label !0x0/0x12345678; }"; bt_assert(flow6_net_format(b, sizeof(b), input) == strlen(expect)); bt_debug(" expect: '%s',\n output: '%s'\n", expect, b); bt_assert(strcmp(b, expect) == 0); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_read_length, "Testing get NLRI length"); bt_test_suite(t_write_length, "Testing set NLRI length"); bt_test_suite(t_first_part, "Searching first part in net_addr_flow"); bt_test_suite(t_iterators4, "Testing iterators (IPv4)"); bt_test_suite(t_iterators6, "Testing iterators (IPv6)"); bt_test_suite(t_accessors4, "Testing accessors (IPv4)"); bt_test_suite(t_accessors6, "Testing accessors (IPv6)"); bt_test_suite(t_validation4, "Testing validation (IPv4)"); bt_test_suite(t_validation6, "Testing validation (IPv6)"); bt_test_suite(t_builder4, "Inserting components into existing Flow Specification (IPv4)"); bt_test_suite(t_builder6, "Inserting components into existing Flow Specification (IPv6)"); bt_test_suite(t_formatting4, "Formatting Flow Specification (IPv4) into text representation"); bt_test_suite(t_formatting6, "Formatting Flow Specification (IPv6) into text representation"); return bt_exit_value(); } bird-2.0.8/lib/flowspec.h0000664000175000017500000001137614025744326014135 0ustar feelafeela/* * BIRD Library -- Flow specification (RFC 5575) * * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_FLOWSPEC_H_ #define _BIRD_FLOWSPEC_H_ #include "nest/bird.h" #include "lib/buffer.h" #include "lib/net.h" /* Flow component operators */ #define FLOW_OP_TRUE 0x00 /* 0b000 */ #define FLOW_OP_EQ 0x01 /* 0b001 */ #define FLOW_OP_GT 0x02 /* 0b010 */ #define FLOW_OP_GEQ 0x03 /* 0b011 */ #define FLOW_OP_LT 0x04 /* 0b100 */ #define FLOW_OP_LEQ 0x05 /* 0b101 */ #define FLOW_OP_NEQ 0x06 /* 0b110 */ #define FLOW_OP_FALSE 0x07 /* 0b111 */ #define FLOW_OP_OR 0x00 #define FLOW_OP_AND 0x40 /* Types of components in flowspec */ enum flow_type { FLOW_TYPE_DST_PREFIX = 1, FLOW_TYPE_SRC_PREFIX = 2, FLOW_TYPE_IP_PROTOCOL = 3, FLOW_TYPE_NEXT_HEADER = 3, /* IPv6 */ FLOW_TYPE_PORT = 4, FLOW_TYPE_DST_PORT = 5, FLOW_TYPE_SRC_PORT = 6, FLOW_TYPE_ICMP_TYPE = 7, FLOW_TYPE_ICMP_CODE = 8, FLOW_TYPE_TCP_FLAGS = 9, FLOW_TYPE_PACKET_LENGTH = 10, FLOW_TYPE_DSCP = 11, /* DiffServ Code Point */ FLOW_TYPE_FRAGMENT = 12, FLOW_TYPE_LABEL = 13, /* IPv6 */ FLOW_TYPE_MAX }; const char *flow_type_str(enum flow_type type, int ipv6); /* * Length */ uint flow_write_length(byte *data, u16 len); static inline u16 flow_hdr_length(const byte *data) { return ((*data & 0xf0) == 0xf0) ? 2 : 1; } static inline u16 flow_read_length(const byte *data) { return ((*data & 0xf0) == 0xf0) ? get_u16(data) & 0x0fff : *data; } static inline u16 flow4_get_length(const net_addr_flow4 *f) { return f->length - sizeof(net_addr_flow4); } static inline u16 flow6_get_length(const net_addr_flow6 *f) { return f->length - sizeof(net_addr_flow6); } static inline void flow4_set_length(net_addr_flow4 *f, u16 len) { f->length = sizeof(net_addr_flow4) + flow_write_length(f->data, len) + len; } static inline void flow6_set_length(net_addr_flow6 *f, u16 len) { f->length = sizeof(net_addr_flow6) + flow_write_length(f->data, len) + len; } /* * Iterators */ const byte *flow4_first_part(const net_addr_flow4 *f); const byte *flow6_first_part(const net_addr_flow6 *f); const byte *flow4_next_part(const byte *pos, const byte *end); const byte *flow6_next_part(const byte *pos, const byte *end); const byte *flow4_get_part(const net_addr_flow4 *f, uint type); const byte *flow6_get_part(const net_addr_flow6 *f, uint type); /* * Flowspec accessors */ ip4_addr flow_read_ip4_part(const byte *part); ip6_addr flow_read_ip6_part(const byte *part); static inline int flow_read_pxlen(const byte *part) { return part[1]; } /* * Flowspec Builder */ /* A data structure for keep a state of flow builder */ struct flow_builder { BUFFER_(byte) data; enum flow_type this_type; enum flow_type last_type; u16 last_op_offset; /* Position of last operator in data.data */ int ipv6; struct { u16 offset; /* Beginning of a component */ u16 length; /* Length of a component */ } parts[FLOW_TYPE_MAX]; /* Indexing all components */ }; struct flow_builder *flow_builder_init(pool *pool); void flow_builder_clear(struct flow_builder *fb); void flow_builder_set_type(struct flow_builder *fb, enum flow_type p); int flow_builder4_add_pfx(struct flow_builder *fb, const net_addr_ip4 *n4); int flow_builder6_add_pfx(struct flow_builder *fb, const net_addr_ip6 *n6, u32 offset); int flow_builder_add_op_val(struct flow_builder *fb, byte op, u32 value); int flow_builder_add_val_mask(struct flow_builder *fb, byte op, u32 value, u32 mask); net_addr_flow4 *flow_builder4_finalize(struct flow_builder *fb, linpool *lpool); net_addr_flow6 *flow_builder6_finalize(struct flow_builder *fb, linpool *lpool); /* * Validation */ /* Results of validation Flow specification */ enum flow_validated_state { FLOW_ST_UNKNOWN_COMPONENT, FLOW_ST_VALID, FLOW_ST_NOT_COMPLETE, FLOW_ST_EXCEED_MAX_PREFIX_LENGTH, FLOW_ST_EXCEED_MAX_PREFIX_OFFSET, FLOW_ST_EXCEED_MAX_VALUE_LENGTH, FLOW_ST_BAD_TYPE_ORDER, FLOW_ST_AND_BIT_SHOULD_BE_UNSET, FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED, FLOW_ST_DEST_PREFIX_REQUIRED, FLOW_ST_INVALID_TCP_FLAGS, FLOW_ST_CANNOT_USE_DONT_FRAGMENT }; const char *flow_validated_state_str(enum flow_validated_state code); enum flow_validated_state flow4_validate(const byte *nlri, uint len); enum flow_validated_state flow6_validate(const byte *nlri, uint len); void flow_check_cf_value_length(struct flow_builder *fb, u32 expr); void flow_check_cf_bmk_values(struct flow_builder *fb, u8 neg, u32 val, u32 mask); void flow4_validate_cf(net_addr_flow4 *f); void flow6_validate_cf(net_addr_flow6 *f); /* * Net Formatting */ uint flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f); uint flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f); #endif /* _BIRD_FLOWSPEC_H_ */ bird-2.0.8/lib/flowspec.c0000664000175000017500000007361414025744326014133 0ustar feelafeela/* * BIRD Library -- Flow specification (RFC 5575) * * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Flow specification (flowspec) * * Flowspec are rules (RFC 5575) for firewalls disseminated using BGP protocol. * The |flowspec.c| is a library for handling flowspec binary streams and * flowspec data structures. You will find there functions for validation * incoming flowspec binary streams, iterators for jumping over components, * functions for handling a length and functions for formatting flowspec data * structure into user-friendly text representation. * * In this library, you will find also flowspec builder. In |confbase.Y|, there * are grammar's rules for parsing and building new flowspec data structure * from BIRD's configuration files and from BIRD's command line interface. * Finalize function will assemble final &net_addr_flow4 or &net_addr_flow6 * data structure. * * The data structures &net_addr_flow4 and &net_addr_flow6 are defined in * |net.h| file. The attribute length is size of whole data structure plus * binary stream representation of flowspec including a compressed encoded * length of flowspec. * * Sometimes in code, it is used expression flowspec type, it should mean * flowspec component type. */ #include "nest/bird.h" #include "lib/flowspec.h" #include "conf/conf.h" static const char* flow4_type_str[] = { [FLOW_TYPE_DST_PREFIX] = "dst", [FLOW_TYPE_SRC_PREFIX] = "src", [FLOW_TYPE_IP_PROTOCOL] = "proto", [FLOW_TYPE_PORT] = "port", [FLOW_TYPE_DST_PORT] = "dport", [FLOW_TYPE_SRC_PORT] = "sport", [FLOW_TYPE_ICMP_TYPE] = "icmp type", [FLOW_TYPE_ICMP_CODE] = "icmp code", [FLOW_TYPE_TCP_FLAGS] = "tcp flags", [FLOW_TYPE_PACKET_LENGTH] = "length", [FLOW_TYPE_DSCP] = "dscp", [FLOW_TYPE_FRAGMENT] = "fragment" }; static const char* flow6_type_str[] = { [FLOW_TYPE_DST_PREFIX] = "dst", [FLOW_TYPE_SRC_PREFIX] = "src", [FLOW_TYPE_NEXT_HEADER] = "next header", [FLOW_TYPE_PORT] = "port", [FLOW_TYPE_DST_PORT] = "dport", [FLOW_TYPE_SRC_PORT] = "sport", [FLOW_TYPE_ICMP_TYPE] = "icmp type", [FLOW_TYPE_ICMP_CODE] = "icmp code", [FLOW_TYPE_TCP_FLAGS] = "tcp flags", [FLOW_TYPE_PACKET_LENGTH] = "length", [FLOW_TYPE_DSCP] = "dscp", [FLOW_TYPE_FRAGMENT] = "fragment", [FLOW_TYPE_LABEL] = "label" }; /** * flow_type_str - get stringified flowspec name of component * @type: flowspec component type * @ipv6: IPv4/IPv6 decide flag, use zero for IPv4 and one for IPv6 * * This function returns flowspec name of component @type in string. */ const char * flow_type_str(enum flow_type type, int ipv6) { return ipv6 ? flow6_type_str[type] : flow4_type_str[type]; } /* * Length */ /** * flow_write_length - write compressed length value * @data: destination buffer to write * @len: the value of the length (0 to 0xfff) for writing * * This function writes appropriate as (1- or 2-bytes) the value of @len into * buffer @data. The function returns number of written bytes, thus 1 or 2 bytes. */ uint flow_write_length(byte *data, u16 len) { if (len >= 0xf0) { put_u16(data, len | 0xf000); return 2; } *data = len; return 1; } inline static uint get_value_length(const byte *op) { return (1 << ((*op & 0x30) >> 4)); } /* * Flowspec iterators */ static inline u8 num_op(const byte *op) { return (*op & 0x07); } static inline int isset_and(const byte *op) { return ((*op & 0x40) == 0x40); } static inline int isset_end(const byte *op) { return ((*op & 0x80) == 0x80); } static const byte * flow_first_part(const byte *data) { if (!data || flow_read_length(data) == 0) return NULL; /* It is allowed to encode the value of length less then 240 into 2-bytes too */ if ((data[0] & 0xf0) == 0xf0) return data + 2; return data + 1; } /** * flow4_first_part - get position of the first flowspec component * @f: flowspec data structure &net_addr_flow4 * * This function return a position to the beginning of the first flowspec * component in IPv4 flowspec @f. */ inline const byte * flow4_first_part(const net_addr_flow4 *f) { return f ? flow_first_part(f->data) : NULL; } /** * flow6_first_part - get position of the first flowspec component * @f: flowspec data structure &net_addr_flow6 * * This function return a position to the beginning of the first flowspec * component in IPv6 flowspec @f. */ inline const byte * flow6_first_part(const net_addr_flow6 *f) { return f ? flow_first_part(f->data) : NULL; } static const byte * flow_next_part(const byte *pos, const byte *end, int ipv6) { switch (*pos++) { case FLOW_TYPE_DST_PREFIX: case FLOW_TYPE_SRC_PREFIX: { uint pxlen = *pos++; uint bytes = BYTES(pxlen); if (ipv6) { uint offset = *pos++ / 8; pos += bytes - offset; } else { pos += bytes; } break; } case FLOW_TYPE_IP_PROTOCOL: /* == FLOW_TYPE_NEXT_HEADER */ case FLOW_TYPE_PORT: case FLOW_TYPE_DST_PORT: case FLOW_TYPE_SRC_PORT: case FLOW_TYPE_ICMP_TYPE: case FLOW_TYPE_ICMP_CODE: case FLOW_TYPE_TCP_FLAGS: case FLOW_TYPE_PACKET_LENGTH: case FLOW_TYPE_DSCP: case FLOW_TYPE_FRAGMENT: case FLOW_TYPE_LABEL: { /* Is this the end of list operator-value pair? */ uint last = 0; while (!last) { last = isset_end(pos); /* Value length of operator */ uint len = get_value_length(pos); pos += 1+len; } break; } default: return NULL; } return (pos < end) ? pos : NULL; } /** * flow4_next_part - an iterator over flowspec components in flowspec binary stream * @pos: the beginning of a previous or the first component in flowspec binary * stream * @end: the last valid byte in scanned flowspec binary stream * * This function returns a position to the beginning of the next component * (to a component type byte) in flowspec binary stream or %NULL for the end. */ inline const byte * flow4_next_part(const byte *pos, const byte *end) { return flow_next_part(pos, end, 0); } /** * flow6_next_part - an iterator over flowspec components in flowspec binary stream * @pos: the beginning of a previous or the first component in flowspec binary * stream * @end: the last valid byte in scanned flowspec binary stream * * This function returns a position to the beginning of the next component * (to a component type byte) in flowspec binary stream or %NULL for the end. */ inline const byte * flow6_next_part(const byte *pos, const byte *end) { return flow_next_part(pos, end, 1); } static const byte * flow_get_part(const byte *data, uint dlen, uint type, int ipv6) { const byte *part; for (part = flow_first_part(data); part && (part[0] <= type); part = flow_next_part(part, data+dlen, ipv6)) if (part[0] == type) return part; return NULL; } const byte * flow4_get_part(const net_addr_flow4 *f, uint type) { return flow_get_part(f->data, f->length - sizeof(net_addr_flow4), type, 0); } const byte * flow6_get_part(const net_addr_flow6 *f, uint type) { return flow_get_part(f->data, f->length - sizeof(net_addr_flow6), type, 1); } /* * Flowspec accessors */ static inline ip4_addr flow_read_ip4(const byte *px, uint pxlen) { ip4_addr ip = IP4_NONE; memcpy(&ip, px, BYTES(pxlen)); return ip4_ntoh(ip); } ip4_addr flow_read_ip4_part(const byte *part) { return flow_read_ip4(part + 2, part[1]); } static inline ip6_addr flow_read_ip6(const byte *px, uint pxlen, uint pxoffset) { uint floor_offset = BYTES(pxoffset - (pxoffset % 8)); uint ceil_len = BYTES(pxlen); ip6_addr ip = IP6_NONE; memcpy(((byte *) &ip) + floor_offset, px, ceil_len - floor_offset); return ip6_ntoh(ip); } ip6_addr flow_read_ip6_part(const byte *part) { return flow_read_ip6(part + 3, part[1], part[2]); } /* * Flowspec validation */ static const char* flow_validated_state_str_[] = { [FLOW_ST_UNKNOWN_COMPONENT] = "Unknown component", [FLOW_ST_VALID] = "Valid", [FLOW_ST_NOT_COMPLETE] = "Not complete", [FLOW_ST_EXCEED_MAX_PREFIX_LENGTH] = "Exceed maximal prefix length", [FLOW_ST_EXCEED_MAX_PREFIX_OFFSET] = "Exceed maximal prefix offset", [FLOW_ST_EXCEED_MAX_VALUE_LENGTH] = "Exceed maximal value length", [FLOW_ST_BAD_TYPE_ORDER] = "Bad component order", [FLOW_ST_AND_BIT_SHOULD_BE_UNSET] = "The AND-bit should be unset", [FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED] = "The Zero-bit should be unset", [FLOW_ST_DEST_PREFIX_REQUIRED] = "Destination prefix is missing", [FLOW_ST_INVALID_TCP_FLAGS] = "TCP flags exceeding 0xfff", [FLOW_ST_CANNOT_USE_DONT_FRAGMENT] = "Cannot use Don't fragment flag in IPv6 flow" }; /** * flow_validated_state_str - return a textual description of validation process * @code: validation result * * This function return well described validation state in string. */ const char * flow_validated_state_str(enum flow_validated_state code) { return flow_validated_state_str_[code]; } static const u8 flow4_max_value_length[] = { [FLOW_TYPE_DST_PREFIX] = 0, [FLOW_TYPE_SRC_PREFIX] = 0, [FLOW_TYPE_IP_PROTOCOL] = 1, [FLOW_TYPE_PORT] = 2, [FLOW_TYPE_DST_PORT] = 2, [FLOW_TYPE_SRC_PORT] = 2, [FLOW_TYPE_ICMP_TYPE] = 1, [FLOW_TYPE_ICMP_CODE] = 1, [FLOW_TYPE_TCP_FLAGS] = 2, [FLOW_TYPE_PACKET_LENGTH] = 2, [FLOW_TYPE_DSCP] = 1, [FLOW_TYPE_FRAGMENT] = 1 /* XXX */ }; static const u8 flow6_max_value_length[] = { [FLOW_TYPE_DST_PREFIX] = 0, [FLOW_TYPE_SRC_PREFIX] = 0, [FLOW_TYPE_NEXT_HEADER] = 1, [FLOW_TYPE_PORT] = 2, [FLOW_TYPE_DST_PORT] = 2, [FLOW_TYPE_SRC_PORT] = 2, [FLOW_TYPE_ICMP_TYPE] = 1, [FLOW_TYPE_ICMP_CODE] = 1, [FLOW_TYPE_TCP_FLAGS] = 2, [FLOW_TYPE_PACKET_LENGTH] = 2, [FLOW_TYPE_DSCP] = 1, [FLOW_TYPE_FRAGMENT] = 1, /* XXX */ [FLOW_TYPE_LABEL] = 4 }; static u8 flow_max_value_length(enum flow_type type, int ipv6) { return ipv6 ? flow6_max_value_length[type] : flow4_max_value_length[type]; } /** * flow_check_cf_bmk_values - check value/bitmask part of flowspec component * @fb: flow builder instance * @neg: negation operand * @val: value from value/mask pair * @mask: bitmap mask from value/mask pair * * This function checks value/bitmask pair. If some problem will appear, the * function calls cf_error() function with a textual description of reason * to failing of validation. */ void flow_check_cf_bmk_values(struct flow_builder *fb, u8 neg, u32 val, u32 mask) { flow_check_cf_value_length(fb, val); flow_check_cf_value_length(fb, mask); if (neg && !(val == 0 || val == mask)) cf_error("For negation, value must be zero or bitmask"); if ((fb->this_type == FLOW_TYPE_TCP_FLAGS) && (mask & 0xf000)) cf_error("Invalid mask 0x%x, must not exceed 0xfff", mask); if ((fb->this_type == FLOW_TYPE_FRAGMENT) && fb->ipv6 && (mask & 0x01)) cf_error("Invalid mask 0x%x, bit 0 must be 0", mask); if (val & ~mask) cf_error("Value 0x%x outside bitmask 0x%x", val, mask); } /** * flow_check_cf_value_length - check value by flowspec component type * @fb: flow builder instance * @val: value * * This function checks if the value is in range of component's type support. * If some problem will appear, the function calls cf_error() function with * a textual description of reason to failing of validation. */ void flow_check_cf_value_length(struct flow_builder *fb, u32 val) { enum flow_type t = fb->this_type; u8 max = flow_max_value_length(t, fb->ipv6); if (t == FLOW_TYPE_DSCP && val > 0x3f) cf_error("%s value %u out of range (0-63)", flow_type_str(t, fb->ipv6), val); if (max == 1 && (val > 0xff)) cf_error("%s value %u out of range (0-255)", flow_type_str(t, fb->ipv6), val); if (max == 2 && (val > 0xffff)) cf_error("%s value %u out of range (0-65535)", flow_type_str(t, fb->ipv6), val); } static enum flow_validated_state flow_validate(const byte *nlri, uint len, int ipv6) { enum flow_type type = 0; const byte *pos = nlri; const byte *end = nlri + len; while (pos < end) { /* Check increasing type ordering */ if (*pos <= type) return FLOW_ST_BAD_TYPE_ORDER; type = *pos++; switch (type) { case FLOW_TYPE_DST_PREFIX: case FLOW_TYPE_SRC_PREFIX: { uint pxlen = *pos++; if (pxlen > (ipv6 ? IP6_MAX_PREFIX_LENGTH : IP4_MAX_PREFIX_LENGTH)) return FLOW_ST_EXCEED_MAX_PREFIX_LENGTH; uint bytes = BYTES(pxlen); if (ipv6) { uint pxoffset = *pos++; if (pxoffset > IP6_MAX_PREFIX_LENGTH || pxoffset > pxlen) return FLOW_ST_EXCEED_MAX_PREFIX_OFFSET; bytes -= pxoffset / 8; } pos += bytes; break; } case FLOW_TYPE_LABEL: if (!ipv6) return FLOW_ST_UNKNOWN_COMPONENT; /* fall through */ case FLOW_TYPE_IP_PROTOCOL: /* == FLOW_TYPE_NEXT_HEADER */ case FLOW_TYPE_PORT: case FLOW_TYPE_DST_PORT: case FLOW_TYPE_SRC_PORT: case FLOW_TYPE_ICMP_TYPE: case FLOW_TYPE_ICMP_CODE: case FLOW_TYPE_TCP_FLAGS: case FLOW_TYPE_PACKET_LENGTH: case FLOW_TYPE_DSCP: case FLOW_TYPE_FRAGMENT: { uint last = 0; uint first = 1; while (!last) { /* * 0 1 2 3 4 5 6 7 * +---+---+---+---+---+---+---+---+ * | e | a | len | 0 |lt |gt |eq | * +---+---+---+---+---+---+---+---+ * * Numeric operator */ last = isset_end(pos); /* The AND bit should in the first operator byte of a sequence */ if (first && isset_and(pos)) return FLOW_ST_AND_BIT_SHOULD_BE_UNSET; /* This bit should be zero */ if (*pos & 0x08) return FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED; if (type == FLOW_TYPE_TCP_FLAGS || type == FLOW_TYPE_FRAGMENT) { /* * 0 1 2 3 4 5 6 7 * +---+---+---+---+---+---+---+---+ * | e | a | len | 0 | 0 |not| m | * +---+---+---+---+---+---+---+---+ * * Bitmask operand */ if (*pos & 0x04) return FLOW_ST_ZERO_BIT_SHOULD_BE_UNSED; } /* Value length of operator */ uint len = get_value_length(pos); if (len > flow_max_value_length(type, ipv6)) return FLOW_ST_EXCEED_MAX_VALUE_LENGTH; /* TCP Flags component must not check highest nibble (just 12 valid bits) */ if ((type == FLOW_TYPE_TCP_FLAGS) && (len == 2) && (pos[1] & 0xf0)) return FLOW_ST_INVALID_TCP_FLAGS; /* Bit-7 must be 0 [draft-ietf-idr-flow-spec-v6] */ if ((type == FLOW_TYPE_FRAGMENT) && ipv6 && (pos[1] & 0x01)) return FLOW_ST_CANNOT_USE_DONT_FRAGMENT; /* XXX: Could be a fragment component encoded in 2-bytes? */ pos += 1+len; if (pos > end && !last) return FLOW_ST_NOT_COMPLETE; if (pos > (end+1)) return FLOW_ST_NOT_COMPLETE; first = 0; } break; } default: return FLOW_ST_UNKNOWN_COMPONENT; } } if (pos != end) return FLOW_ST_NOT_COMPLETE; return FLOW_ST_VALID; } /** * flow4_validate - check untrustworthy IPv4 flowspec data stream * @nlri: flowspec data stream without compressed encoded length value * @len: length of @nlri * * This function checks meaningfulness of binary flowspec. It should return * %FLOW_ST_VALID or %FLOW_ST_UNKNOWN_COMPONENT. If some problem appears, it * returns some other %FLOW_ST_xxx state. */ inline enum flow_validated_state flow4_validate(const byte *nlri, uint len) { return flow_validate(nlri, len, 0); } /** * flow6_validate - check untrustworthy IPv6 flowspec data stream * @nlri: flowspec binary stream without encoded length value * @len: length of @nlri * * This function checks meaningfulness of binary flowspec. It should return * %FLOW_ST_VALID or %FLOW_ST_UNKNOWN_COMPONENT. If some problem appears, it * returns some other %FLOW_ST_xxx state. */ inline enum flow_validated_state flow6_validate(const byte *nlri, uint len) { return flow_validate(nlri, len, 1); } /** * flow4_validate_cf - validate flowspec data structure &net_addr_flow4 in parsing time * @f: flowspec data structure &net_addr_flow4 * * Check if @f is valid flowspec data structure. Can call cf_error() function * with a textual description of reason to failing of validation. */ void flow4_validate_cf(net_addr_flow4 *f) { enum flow_validated_state r = flow4_validate(flow4_first_part(f), flow_read_length(f->data)); if (r != FLOW_ST_VALID) cf_error("Invalid flow route: %s", flow_validated_state_str(r)); } /** * flow6_validate_cf - validate flowspec data structure &net_addr_flow6 in parsing time * @f: flowspec data structure &net_addr_flow6 * * Check if @f is valid flowspec data structure. Can call cf_error() function * with a textual description of reason to failing of validation. */ void flow6_validate_cf(net_addr_flow6 *f) { enum flow_validated_state r = flow6_validate(flow6_first_part(f), flow_read_length(f->data)); if (r != FLOW_ST_VALID) cf_error("Invalid flow route: %s", flow_validated_state_str(r)); } /* * Flowspec Builder */ /** * flow_builder_init - constructor for flowspec builder instance * @pool: memory pool * * This function prepares flowspec builder instance using memory pool @pool. */ struct flow_builder * flow_builder_init(pool *pool) { struct flow_builder *fb = mb_allocz(pool, sizeof(struct flow_builder)); BUFFER_INIT(fb->data, pool, 4); return fb; } static int is_stackable_type(enum flow_type type) { switch (type) { case FLOW_TYPE_IP_PROTOCOL: case FLOW_TYPE_PORT: case FLOW_TYPE_DST_PORT: case FLOW_TYPE_SRC_PORT: case FLOW_TYPE_ICMP_TYPE: case FLOW_TYPE_ICMP_CODE: case FLOW_TYPE_TCP_FLAGS: case FLOW_TYPE_PACKET_LENGTH: case FLOW_TYPE_DSCP: case FLOW_TYPE_FRAGMENT: case FLOW_TYPE_LABEL: return 1; default: /* The unknown components are not stack-able in default */ return 0; } } static int builder_add_prepare(struct flow_builder *fb) { if (fb->parts[fb->this_type].length) { if (fb->last_type != fb->this_type) return 0; if (!is_stackable_type(fb->this_type)) return 0; } else { fb->parts[fb->this_type].offset = fb->data.used; } return 1; } static void builder_add_finish(struct flow_builder *fb) { fb->parts[fb->this_type].length = fb->data.used - fb->parts[fb->this_type].offset; flow_builder_set_type(fb, fb->this_type); } static void push_pfx_to_buffer(struct flow_builder *fb, u8 pxlen_bytes, byte *ip) { for (int i = 0; i < pxlen_bytes; i++) BUFFER_PUSH(fb->data) = *ip++; } /** * flow_builder4_add_pfx - add IPv4 prefix * @fb: flowspec builder instance * @n4: net address of type IPv4 * * This function add IPv4 prefix into flowspec builder instance. */ int flow_builder4_add_pfx(struct flow_builder *fb, const net_addr_ip4 *n4) { if (!builder_add_prepare(fb)) return 0; ip4_addr ip4 = ip4_hton(n4->prefix); BUFFER_PUSH(fb->data) = fb->this_type; BUFFER_PUSH(fb->data) = n4->pxlen; push_pfx_to_buffer(fb, BYTES(n4->pxlen), (byte *) &ip4); builder_add_finish(fb); return 1; } /** * flow_builder6_add_pfx - add IPv6 prefix * @fb: flowspec builder instance * @n6: net address of type IPv4 * @pxoffset: prefix offset for @n6 * * This function add IPv4 prefix into flowspec builder instance. This function * should return 1 for successful adding, otherwise returns %0. */ int flow_builder6_add_pfx(struct flow_builder *fb, const net_addr_ip6 *n6, u32 pxoffset) { if (!builder_add_prepare(fb)) return 0; ip6_addr ip6 = ip6_hton(n6->prefix); BUFFER_PUSH(fb->data) = fb->this_type; BUFFER_PUSH(fb->data) = n6->pxlen; BUFFER_PUSH(fb->data) = pxoffset; push_pfx_to_buffer(fb, BYTES(n6->pxlen) - (pxoffset / 8), ((byte *) &ip6) + (pxoffset / 8)); builder_add_finish(fb); return 1; } /** * flow_builder_add_op_val - add operator/value pair * @fb: flowspec builder instance * @op: operator * @value: value * * This function add operator/value pair as a part of a flowspec component. It * is required to set appropriate flowspec component type using function * flow_builder_set_type(). This function should return 1 for successful * adding, otherwise returns 0. */ int flow_builder_add_op_val(struct flow_builder *fb, byte op, u32 value) { if (!builder_add_prepare(fb)) return 0; if (fb->this_type == fb->last_type) { /* Remove the end-bit from last operand-value pair of the component */ fb->data.data[fb->last_op_offset] &= 0x7f; } else { BUFFER_PUSH(fb->data) = fb->this_type; } fb->last_op_offset = fb->data.used; /* Set the end-bit for operand-value pair of the component */ op |= 0x80; if (value & 0xff00) { BUFFER_PUSH(fb->data) = op | 0x10; put_u16(BUFFER_INC(fb->data, 2), value); } else { BUFFER_PUSH(fb->data) = op; BUFFER_PUSH(fb->data) = (u8) value; } builder_add_finish(fb); return 1; } /** * flow_builder_add_val_mask - add value/bitmask pair * @fb: flowspec builder instance * @op: operator * @value: value * @mask: bitmask * * It is required to set appropriate flowspec component type using function * flow_builder_set_type(). This function should return 1 for successful adding, * otherwise returns 0. */ int flow_builder_add_val_mask(struct flow_builder *fb, byte op, u32 value, u32 mask) { u32 a = value & mask; u32 b = ~value & mask; if (a) { flow_builder_add_op_val(fb, op ^ 0x01, a); op |= FLOW_OP_AND; } if (b) flow_builder_add_op_val(fb, op ^ 0x02, b); return 1; } /** * flow_builder_set_type - set type of next flowspec component * @fb: flowspec builder instance * @type: flowspec component type * * This function sets type of next flowspec component. It is necessary to call * this function before each changing of adding flowspec component. */ void flow_builder_set_type(struct flow_builder *fb, enum flow_type type) { fb->last_type = fb->this_type; fb->this_type = type; } static void builder_write_parts(struct flow_builder *fb, byte *buf) { for (int i = 1; i < FLOW_TYPE_MAX; i++) { if (fb->parts[i].length) { memcpy(buf, fb->data.data + fb->parts[i].offset, fb->parts[i].length); buf += fb->parts[i].length; } } } /** * flow_builder4_finalize - assemble final flowspec data structure &net_addr_flow4 * @fb: flowspec builder instance * @lpool: linear memory pool * * This function returns final flowspec data structure &net_addr_flow4 allocated * onto @lpool linear memory pool. */ net_addr_flow4 * flow_builder4_finalize(struct flow_builder *fb, linpool *lpool) { uint data_len = fb->data.used + (fb->data.used < 0xf0 ? 1 : 2); net_addr_flow4 *f = lp_alloc(lpool, sizeof(struct net_addr_flow4) + data_len); ip4_addr prefix = IP4_NONE; uint pxlen = 0; if (fb->parts[FLOW_TYPE_DST_PREFIX].length) { byte *part = fb->data.data + fb->parts[FLOW_TYPE_DST_PREFIX].offset; prefix = flow_read_ip4_part(part); pxlen = flow_read_pxlen(part); } *f = NET_ADDR_FLOW4(prefix, pxlen, data_len); builder_write_parts(fb, f->data + flow_write_length(f->data, fb->data.used)); return f; } /** * flow_builder6_finalize - assemble final flowspec data structure &net_addr_flow6 * @fb: flowspec builder instance * @lpool: linear memory pool for allocation of * * This function returns final flowspec data structure &net_addr_flow6 allocated * onto @lpool linear memory pool. */ net_addr_flow6 * flow_builder6_finalize(struct flow_builder *fb, linpool *lpool) { uint data_len = fb->data.used + (fb->data.used < 0xf0 ? 1 : 2); net_addr_flow6 *n = lp_alloc(lpool, sizeof(net_addr_flow6) + data_len); ip6_addr prefix = IP6_NONE; uint pxlen = 0; if (fb->parts[FLOW_TYPE_DST_PREFIX].length) { byte *part = fb->data.data + fb->parts[FLOW_TYPE_DST_PREFIX].offset; prefix = flow_read_ip6_part(part); pxlen = flow_read_pxlen(part); } *n = NET_ADDR_FLOW6(prefix, pxlen, data_len); builder_write_parts(fb, n->data + flow_write_length(n->data, fb->data.used)); return n; } /** * flow_builder_clear - flush flowspec builder instance for another flowspec creation * @fb: flowspec builder instance * * This function flushes all data from builder but it maintains pre-allocated * buffer space. */ void flow_builder_clear(struct flow_builder *fb) { BUFFER(byte) data; BUFFER_FLUSH(fb->data); BUFFER_SHALLOW_COPY(data, fb->data); memset(fb, 0, sizeof(struct flow_builder)); BUFFER_SHALLOW_COPY(fb->data, data); } /* * Net Formatting */ /* Flowspec operators for [op, value]+ pairs */ static const char * num_op_str(const byte *op) { switch (*op & 0x07) { case FLOW_OP_TRUE: return "true"; case FLOW_OP_EQ: return "="; case FLOW_OP_GT: return ">"; case FLOW_OP_GEQ: return ">="; case FLOW_OP_LT: return "<"; case FLOW_OP_LEQ: return "<="; case FLOW_OP_NEQ: return "!="; case FLOW_OP_FALSE: return "false"; } return NULL; } static uint get_value(const byte *val, u8 len) { switch (len) { case 1: return *val; case 2: return get_u16(val); case 4: return get_u32(val); // No component may have length 8 // case 8: return get_u64(val); } return 0; } static const char * fragment_val_str(u8 val) { switch (val) { case 1: return "dont_fragment"; case 2: return "is_fragment"; case 4: return "first_fragment"; case 8: return "last_fragment"; } return "???"; } static void net_format_flow_ip(buffer *b, const byte *part, int ipv6) { uint pxlen = part[1]; if (ipv6) { uint pxoffset = part[2]; if (pxoffset) buffer_print(b, "%I6/%u offset %u; ", flow_read_ip6_part(part), pxlen, pxoffset); else buffer_print(b, "%I6/%u; ", flow_read_ip6_part(part), pxlen); } else { buffer_print(b, "%I4/%u; ", flow_read_ip4_part(part), pxlen); } } static void net_format_flow_num(buffer *b, const byte *part) { const byte *last_op = NULL; const byte *op = part+1; uint val; uint len; uint first = 1; while (1) { if (!first) { /* XXX: I don't like this so complicated if-tree */ if (!isset_and(op) && ((num_op( op) == FLOW_OP_EQ) || (num_op( op) == FLOW_OP_GEQ)) && ((num_op(last_op) == FLOW_OP_EQ) || (num_op(last_op) == FLOW_OP_LEQ))) { b->pos--; /* Remove last char (it is a space) */ buffer_puts(b, ","); } else { buffer_puts(b, isset_and(op) ? "&& " : "|| "); } } first = 0; len = get_value_length(op); val = get_value(op+1, len); if (!isset_end(op) && !isset_and(op) && isset_and(op+1+len) && (num_op(op) == FLOW_OP_GEQ) && (num_op(op+1+len) == FLOW_OP_LEQ)) { /* Display interval */ buffer_print(b, "%u..", val); op += 1 + len; len = get_value_length(op); val = get_value(op+1, len); buffer_print(b, "%u", val); } else if (num_op(op) == FLOW_OP_EQ) { buffer_print(b, "%u", val); } else { buffer_print(b, "%s %u", num_op_str(op), val); } if (isset_end(op)) { buffer_puts(b, "; "); break; } else { buffer_puts(b, " "); } last_op = op; op += 1 + len; } } static void net_format_flow_bitmask(buffer *b, const byte *part) { const byte *op = part+1; uint val; uint len; uint first = 1; while (1) { if (!first) { if (isset_and(op)) { b->pos--; /* Remove last char (it is a space) */ buffer_puts(b, ","); } else { buffer_puts(b, "|| "); } } first = 0; len = get_value_length(op); val = get_value(op+1, len); /* * Not Match Show * ------------------ * 0 0 !0/B * 0 1 B/B * 1 0 0/B * 1 1 !B/B */ if ((*op & 0x3) == 0x3 || (*op & 0x3) == 0) buffer_puts(b, "!"); if (*part == FLOW_TYPE_FRAGMENT && (val == 1 || val == 2 || val == 4 || val == 8)) buffer_print(b, "%s%s", ((*op & 0x1) ? "" : "!"), fragment_val_str(val)); else buffer_print(b, "0x%x/0x%x", ((*op & 0x1) ? val : 0), val); if (isset_end(op)) { buffer_puts(b, "; "); break; } else { buffer_puts(b, " "); } op += 1 + len; } } static uint net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6) { buffer b = { .start = buf, .pos = buf, .end = buf + blen, }; const byte *part = flow_first_part(data); *buf = 0; if (ipv6) buffer_puts(&b, "flow6 { "); else buffer_puts(&b, "flow4 { "); while (part) { buffer_print(&b, "%s ", flow_type_str(*part, ipv6)); switch (*part) { case FLOW_TYPE_DST_PREFIX: case FLOW_TYPE_SRC_PREFIX: net_format_flow_ip(&b, part, ipv6); break; case FLOW_TYPE_IP_PROTOCOL: /* == FLOW_TYPE_NEXT_HEADER */ case FLOW_TYPE_PORT: case FLOW_TYPE_DST_PORT: case FLOW_TYPE_SRC_PORT: case FLOW_TYPE_ICMP_TYPE: case FLOW_TYPE_ICMP_CODE: case FLOW_TYPE_PACKET_LENGTH: case FLOW_TYPE_DSCP: net_format_flow_num(&b, part); break; case FLOW_TYPE_TCP_FLAGS: case FLOW_TYPE_FRAGMENT: case FLOW_TYPE_LABEL: net_format_flow_bitmask(&b, part); break; } part = flow_next_part(part, data+dlen, ipv6); } buffer_puts(&b, "}"); if (b.pos == b.end) { b.pos = b.start + MIN(blen - 6, strlen(b.start)); buffer_puts(&b, " ...}"); } return b.pos - b.start; } /** * flow4_net_format - stringify flowspec data structure &net_addr_flow4 * @buf: pre-allocated buffer for writing a stringify net address flowspec * @blen: free allocated space in @buf * @f: flowspec data structure &net_addr_flow4 for stringify * * This function writes stringified @f into @buf. The function returns number * of written chars. If final string is too large, the string will ends the with * ' ...}' sequence and zero-terminator. */ uint flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f) { return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow4), 0); } /** * flow6_net_format - stringify flowspec data structure &net_addr_flow6 * @buf: pre-allocated buffer for writing a stringify net address flowspec * @blen: free allocated space in @buf * @f: flowspec data structure &net_addr_flow4 for stringify * * This function writes stringified @f into @buf. The function returns number * of written chars. If final string is too large, the string will ends the with * ' ...}' sequence and zero-terminator. */ uint flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f) { return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow6), 1); } bird-2.0.8/lib/fletcher16_test.c0000664000175000017500000001121114025744326015274 0ustar feelafeela/* * BIRD Library -- Fletcher-16 Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/fletcher16.h" static u16 straightforward_fletcher16_compute(const char *data) { int count = strlen(data); u16 sum1 = 0; u16 sum2 = 0; int index; for (index = 0; index < count; ++index) { sum1 = (sum1 + data[index]) % 255; sum2 = (sum2 + sum1) % 255; } sum2 = (sum2 + sum1) % 255; sum2 = (sum2 + sum1) % 255; return (sum1 << 8) | sum2; } static u16 straightforward_fletcher16_checksum(const char *data) { u16 csum; u16 c0,c1,x,y; csum = straightforward_fletcher16_compute(data); c0 = (csum >> 8) & 0xff; c1 = csum & 0xff; x = (255 + c0 - c1) % 255; y = (510 - 2*c0 + c1) % 255; if (!x) x = 255; if (!y) y = 255; return (x << 8) | y; } const u8 zero16[2] = {}; static int test_fletcher16(void *out_, const void *in_, const void *expected_out_) { u16 *out = out_; const char *in = in_; const u16 *expected_out = expected_out_; struct fletcher16_context ctxt; fletcher16_init(&ctxt); fletcher16_update(&ctxt, in, strlen(in)); fletcher16_update(&ctxt, zero16, 2); *out = fletcher16_compute(&ctxt); return *out == *expected_out; } static int test_fletcher16_checksum(void *out_, const void *in_, const void *expected_out_) { u16 *out = out_; const char *in = in_; const u16 *expected_out = expected_out_; struct fletcher16_context ctxt; int len = strlen(in); fletcher16_init(&ctxt); fletcher16_update(&ctxt, in, len); fletcher16_update(&ctxt, zero16, 2); *out = fletcher16_final(&ctxt, len+2, len); return *out == *expected_out; } static int t_fletcher16_compute(void) { struct bt_pair test_vectors[] = { { .in = "\001\002", .out = & ((const u16) { straightforward_fletcher16_compute("\001\002") }), }, { .in = "", .out = & ((const u16) { straightforward_fletcher16_compute("") }), }, { .in = "a", .out = & ((const u16) { straightforward_fletcher16_compute("a") }), }, { .in = "abcd", .out = & ((const u16) { straightforward_fletcher16_compute("abcd") }), }, { .in = "message digest", .out = & ((const u16) { straightforward_fletcher16_compute("message digest") }), }, { .in = "abcdefghijklmnopqrstuvwxyz", .out = & ((const u16) { straightforward_fletcher16_compute("abcdefghijklmnopqrstuvwxyz") }), }, { .in = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", .out = & ((const u16) { straightforward_fletcher16_compute("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") }), }, { .in = "12345678901234567890123456789012345678901234567890123456789012345678901234567890", .out = & ((const u16) { straightforward_fletcher16_compute("12345678901234567890123456789012345678901234567890123456789012345678901234567890") }), }, }; return bt_assert_batch(test_vectors, test_fletcher16, bt_fmt_str, bt_fmt_unsigned); } static int t_fletcher16_checksum(void) { struct bt_pair test_vectors[] = { { .in = "\001\002", .out = & ((const u16) { straightforward_fletcher16_checksum("\001\002") }), }, { .in = "", .out = & ((const u16) { straightforward_fletcher16_checksum("") }), }, { .in = "a", .out = & ((const u16) { straightforward_fletcher16_checksum("a") }), }, { .in = "abcd", .out = & ((const u16) { straightforward_fletcher16_checksum("abcd") }), }, { .in = "message digest", .out = & ((const u16) { straightforward_fletcher16_checksum("message digest") }), }, { .in = "abcdefghijklmnopqrstuvwxyz", .out = & ((const u16) { straightforward_fletcher16_checksum("abcdefghijklmnopqrstuvwxyz") }), }, { .in = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", .out = & ((const u16) { straightforward_fletcher16_checksum("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") }), }, { .in = "12345678901234567890123456789012345678901234567890123456789012345678901234567890", .out = & ((const u16) { straightforward_fletcher16_checksum("12345678901234567890123456789012345678901234567890123456789012345678901234567890") }), }, }; return bt_assert_batch(test_vectors, test_fletcher16_checksum, bt_fmt_str, bt_fmt_unsigned); } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_fletcher16_compute, "Fletcher-16 Compute Tests"); bt_test_suite(t_fletcher16_checksum, "Fletcher-16 Checksum Tests"); return bt_exit_value(); } bird-2.0.8/lib/fletcher16.h0000664000175000017500000001233314025744326014250 0ustar feelafeela/* * BIRD Library -- Fletcher-16 checksum * * (c) 2015 Ondrej Zajicek * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Fletcher-16 checksum * * Fletcher-16 checksum is a position-dependent checksum algorithm used for * error-detection e.g. in OSPF LSAs. * * To generate Fletcher-16 checksum, zero the checksum field in data, initialize * the context by fletcher16_init(), process the data by fletcher16_update(), * compute the checksum value by fletcher16_final() and store it to the checksum * field in data by put_u16() (or other means involving htons() conversion). * * To verify Fletcher-16 checksum, initialize the context by fletcher16_init(), * process the data by fletcher16_update(), compute a passing checksum by * fletcher16_compute() and check if it is zero. */ #ifndef _BIRD_FLETCHER16_H_ #define _BIRD_FLETCHER16_H_ #include "nest/bird.h" struct fletcher16_context { int c0, c1; }; /** * fletcher16_init - initialize Fletcher-16 context * @ctx: the context */ static inline void fletcher16_init(struct fletcher16_context *ctx) { ctx->c0 = ctx->c1 = 0; } /** * fletcher16_update - process data to Fletcher-16 context * @ctx: the context * @buf: data buffer * @len: data length * * fletcher16_update() reads data from the buffer @buf and updates passing sums * in the context @ctx. It may be used multiple times for multiple blocks of * checksummed data. */ static inline void fletcher16_update(struct fletcher16_context *ctx, const u8* buf, int len) { /* * The Fletcher-16 sum is essentially a sequence of * ctx->c1 += ctx->c0 += *buf++, modulo 255. * * In the inner loop, we eliminate modulo operation and we do some loop * unrolling. MODX is the maximal number of steps that can be done without * modulo before overflow, see RFC 1008 for details. We use a bit smaller * value to cover for initial steps due to loop unrolling. */ #define MODX 4096 int blen, i; blen = len % 4; len -= blen; for (i = 0; i < blen; i++) ctx->c1 += ctx->c0 += *buf++; do { blen = MIN(len, MODX); len -= blen; for (i = 0; i < blen; i += 4) { ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; } ctx->c0 %= 255; ctx->c1 %= 255; } while (len); } /** * fletcher16_update_n32 - process data to Fletcher-16 context, with endianity adjustment * @ctx: the context * @buf: data buffer * @len: data length * * fletcher16_update_n32() works like fletcher16_update(), except it applies * 32-bit host/network endianity swap to the data before they are processed. * I.e., it assumes that the data is a sequence of u32 that must be converted by * ntohl() or htonl() before processing. The @buf need not to be aligned, but * its length (@len) must be multiple of 4. Note that on big endian systems the * host endianity is the same as the network endianity, therefore there is no * endianity swap. */ static inline void fletcher16_update_n32(struct fletcher16_context *ctx, const u8* buf, int len) { /* See fletcher16_update() for details */ int blen, i; do { blen = MIN(len, MODX); len -= blen; for (i = 0; i < blen; i += 4) { #ifdef CPU_BIG_ENDIAN ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; ctx->c1 += ctx->c0 += *buf++; #else ctx->c1 += ctx->c0 += buf[3]; ctx->c1 += ctx->c0 += buf[2]; ctx->c1 += ctx->c0 += buf[1]; ctx->c1 += ctx->c0 += buf[0]; buf += 4; #endif } ctx->c0 %= 255; ctx->c1 %= 255; } while (len); } /** * fletcher16_final - compute final Fletcher-16 checksum value * @ctx: the context * @len: total data length * @pos: offset in data where the checksum will be stored * * fletcher16_final() computes the final checksum value and returns it. * The caller is responsible for storing it in the appropriate position. * The checksum value depends on @len and @pos, but only their difference * (i.e. the offset from the end) is significant. * * The checksum value is represented as u16, although it is defined as two * consecutive bytes. We treat them as one u16 in big endian / network order. * I.e., the returned value is in the form that would be returned by get_u16() * from the checksum field in the data buffer, therefore the caller should use * put_u16() or an explicit host-to-network conversion when storing it to the * checksum field in the data buffer. * * Note that the returned checksum value is always nonzero. */ static inline u16 fletcher16_final(struct fletcher16_context *ctx, int len, int pos) { int x = ((len - pos - 1) * ctx->c0 - ctx->c1) % 255; if (x <= 0) x += 255; int y = 510 - ctx->c0 - x; if (y > 255) y -= 255; return (x << 8) | y; } /** * fletcher16_compute - compute Fletcher-16 sum for verification * @ctx: the context * * fletcher16_compute() returns a passing Fletcher-16 sum for processed data. * If the data contains the proper Fletcher-16 checksum value, the returned * value is zero. */ static inline u16 fletcher16_compute(struct fletcher16_context *ctx) { return (ctx->c0 << 8) | ctx->c1; } #endif bird-2.0.8/lib/event_test.c0000664000175000017500000000335014025744326014457 0ustar feelafeela/* * BIRD Library -- Event Processing Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "lib/net.h" #include "lib/event.h" #include "conf/conf.h" #include "nest/locks.h" #include "sysdep/unix/unix.h" #include "nest/iface.h" #include "nest/route.h" #define MAX_NUM 4 int event_check_points[MAX_NUM]; #define event_hook_body(num) \ do { \ bt_debug("Event Hook " #num "\n"); \ event_check_points[num] = 1; \ bt_assert_msg(event_check_points[num-1], "Events should be run in right order"); \ } while (0) static void event_hook_1(void *data UNUSED) { event_hook_body(1); } static void event_hook_2(void *data UNUSED) { event_hook_body(2); } static void event_hook_3(void *data UNUSED) { event_hook_body(3); } #define schedule_event(num) \ do { \ struct event *event_##num = ev_new(&root_pool); \ event_##num->hook = event_hook_##num; \ ev_schedule(event_##num); \ } while (0) static void init_event_check_points(void) { int i; event_check_points[0] = 1; for (i = 1; i < MAX_NUM; i++) event_check_points[i] = 0; } static int t_ev_run_list(void) { int i; resource_init(); olock_init(); timer_init(); io_init(); rt_init(); if_init(); // roa_init(); config_init(); config = config_alloc(""); init_event_check_points(); schedule_event(1); schedule_event(2); schedule_event(3); ev_run_list(&global_event_list); for (i = 1; i < MAX_NUM; i++) bt_assert(event_check_points[i]); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_ev_run_list, "Schedule and run 3 events in right order."); return bt_exit_value(); } bird-2.0.8/lib/event.h0000664000175000017500000000171014025744326013423 0ustar feelafeela/* * BIRD Library -- Event Processing * * (c) 1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_EVENT_H_ #define _BIRD_EVENT_H_ #include "lib/resource.h" typedef struct event { resource r; void (*hook)(void *); void *data; node n; /* Internal link */ } event; typedef list event_list; extern event_list global_event_list; extern event_list global_work_list; event *ev_new(pool *); void ev_run(event *); #define ev_init_list(el) init_list(el) void ev_enqueue(event_list *, event *); void ev_schedule(event *); void ev_schedule_work(event *); void ev_postpone(event *); int ev_run_list(event_list *); int ev_run_list_limited(event_list *, uint); static inline int ev_active(event *e) { return e->n.next != NULL; } static inline event* ev_new_init(pool *p, void (*hook)(void *), void *data) { event *e = ev_new(p); e->hook = hook; e->data = data; return e; } #endif bird-2.0.8/lib/event.c0000664000175000017500000001020014025744326013410 0ustar feelafeela/* * BIRD Library -- Event Processing * * (c) 1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Events * * Events are there to keep track of deferred execution. * Since BIRD is single-threaded, it requires long lasting tasks to be split to smaller * parts, so that no module can monopolize the CPU. To split such a task, just create * an &event resource, point it to the function you want to have called and call ev_schedule() * to ask the core to run the event when nothing more important requires attention. * * You can also define your own event lists (the &event_list structure), enqueue your * events in them and explicitly ask to run them. */ #include "nest/bird.h" #include "lib/event.h" event_list global_event_list; event_list global_work_list; inline void ev_postpone(event *e) { if (ev_active(e)) { rem_node(&e->n); e->n.next = NULL; } } static void ev_dump(resource *r) { event *e = (event *) r; debug("(code %p, data %p, %s)\n", e->hook, e->data, e->n.next ? "scheduled" : "inactive"); } static struct resclass ev_class = { "Event", sizeof(event), (void (*)(resource *)) ev_postpone, ev_dump, NULL, NULL }; /** * ev_new - create a new event * @p: resource pool * * This function creates a new event resource. To use it, * you need to fill the structure fields and call ev_schedule(). */ event * ev_new(pool *p) { event *e = ralloc(p, &ev_class); return e; } /** * ev_run - run an event * @e: an event * * This function explicitly runs the event @e (calls its hook * function) and removes it from an event list if it's linked to any. * * From the hook function, you can call ev_enqueue() or ev_schedule() * to re-add the event. */ inline void ev_run(event *e) { ev_postpone(e); e->hook(e->data); } /** * ev_enqueue - enqueue an event * @l: an event list * @e: an event * * ev_enqueue() stores the event @e to the specified event * list @l which can be run by calling ev_run_list(). */ inline void ev_enqueue(event_list *l, event *e) { ev_postpone(e); add_tail(l, &e->n); } /** * ev_schedule - schedule an event * @e: an event * * This function schedules an event by enqueueing it to a system-wide * event list which is run by the platform dependent code whenever * appropriate. */ void ev_schedule(event *e) { ev_enqueue(&global_event_list, e); } /** * ev_schedule_work - schedule a work-event. * @e: an event * * This function schedules an event by enqueueing it to a system-wide work-event * list which is run by the platform dependent code whenever appropriate. This * is designated for work-events instead of regular events. They are executed * less often in order to not clog I/O loop. */ void ev_schedule_work(event *e) { if (!ev_active(e)) add_tail(&global_work_list, &e->n); } void io_log_event(void *hook, void *data); /** * ev_run_list - run an event list * @l: an event list * * This function calls ev_run() for all events enqueued in the list @l. */ int ev_run_list(event_list *l) { node *n; list tmp_list; init_list(&tmp_list); add_tail_list(&tmp_list, l); init_list(l); WALK_LIST_FIRST(n, tmp_list) { event *e = SKIP_BACK(event, n, n); /* This is ugly hack, we want to log just events executed from the main I/O loop */ if ((l == &global_event_list) || (l == &global_work_list)) io_log_event(e->hook, e->data); ev_run(e); } return !EMPTY_LIST(*l); } int ev_run_list_limited(event_list *l, uint limit) { node *n; list tmp_list; init_list(&tmp_list); add_tail_list(&tmp_list, l); init_list(l); WALK_LIST_FIRST(n, tmp_list) { event *e = SKIP_BACK(event, n, n); if (!limit) break; /* This is ugly hack, we want to log just events executed from the main I/O loop */ if ((l == &global_event_list) || (l == &global_work_list)) io_log_event(e->hook, e->data); ev_run(e); limit--; } if (!EMPTY_LIST(tmp_list)) { /* Attach new items after the unprocessed old items */ add_tail_list(&tmp_list, l); init_list(l); add_tail_list(l, &tmp_list); } return !EMPTY_LIST(*l); } bird-2.0.8/lib/checksum_test.c0000664000175000017500000000334114025744326015140 0ustar feelafeela/* * BIRD Library -- IP One-Complement Checksum Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "test/birdtest.h" #include "lib/checksum.h" #define MAX_NUM 10000 static u16 ipsum_calculate_expected(u32 *a) { int i; u32 sum = 0; for(i = 0; i < MAX_NUM; i++) { sum += a[i] & 0xffff; bt_debug("low) \t0x%08X \n", sum); sum += a[i] >> 16; bt_debug("high) \t0x%08X \n", sum); u16 carry = sum >> 16; sum = (sum & 0xffff) + carry; bt_debug("carry) \t0x%08X \n\n", sum); } bt_debug("sum) \t0x%08X \n", sum); sum = sum ^ 0xffff; bt_debug("~sum) \t0x%08X \n", sum); return sum; } static int t_calculate(void) { u32 a[MAX_NUM]; int i; for (i = 0; i < MAX_NUM; i++) a[i] = bt_random(); u16 sum_calculated = ipsum_calculate(a, sizeof(a), NULL); u16 sum_calculated_2 = ipsum_calculate(&a[0], sizeof(u32)*(MAX_NUM/2), &a[MAX_NUM/2], sizeof(u32)*(MAX_NUM - MAX_NUM/2), NULL); bt_assert(sum_calculated == sum_calculated_2); u16 sum_expected = ipsum_calculate_expected(a); bt_debug("sum_calculated: %08X \n", sum_calculated); bt_debug("sum_expected: %08X \n", sum_expected); bt_assert(sum_calculated == sum_expected); return 1; } static int t_verify(void) { u32 a[MAX_NUM+1]; int i; for (i = 0; i < MAX_NUM; i++) a[i] = bt_random(); u16 sum = ipsum_calculate_expected(a); a[MAX_NUM] = sum; bt_assert(ipsum_verify(a, sizeof(a), NULL)); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_calculate, "Checksum of pseudo-random data"); bt_test_suite(t_verify, "Verification of pseudo-random data."); return bt_exit_value(); } bird-2.0.8/lib/checksum.h0000664000175000017500000000065614025744326014114 0ustar feelafeela/* * BIRD Library -- IP One-Complement Checksum * * (c) 1999 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_CHECKSUM_H_ #define _BIRD_CHECKSUM_H_ /* * Both checksumming functions accept a vararg list of packet * fragments finished by NULL pointer. */ int ipsum_verify(void *frag, uint len, ...); u16 ipsum_calculate(void *frag, uint len, ...); #endif bird-2.0.8/lib/checksum.c0000664000175000017500000000462214025744326014104 0ustar feelafeela/* * BIRD Library -- IP One-Complement Checksum * * (c) 1999--2000 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Miscellaneous functions. */ #include #include "nest/bird.h" #include "checksum.h" static inline u32 add32(u32 sum, u32 x) { u32 z = sum + x; // return z + (z < sum); /* add carry */ if (z < x) z++; return z; } static u16 ipsum_calc_block(u32 *buf, uint len, u16 isum) { /* * A few simple facts about the IP checksum (see RFC 1071 for detailed * discussion): * * o It's associative and commutative. * o It's byte order independent. * o It's word size independent. * * This gives us a neat 32-bits-at-a-time algorithm which respects * usual alignment requirements and is reasonably fast. */ ASSERT(!(len % 4)); if (!len) return isum; u32 *end = buf + (len >> 2); u32 sum = isum; while (buf < end) sum = add32(sum, *buf++); sum = (sum >> 16) + (sum & 0xffff); /* add high-16 to low-16 */ sum += (sum >> 16); /* add carry */ return sum; } static u16 ipsum_calc(void *frag, uint len, va_list args) { u16 sum = 0; for(;;) { sum = ipsum_calc_block(frag, len, sum); frag = va_arg(args, void *); if (!frag) break; len = va_arg(args, uint); } return sum; } /** * ipsum_verify - verify an IP checksum * @frag: first packet fragment * @len: length in bytes * * This function verifies whether a given fragmented packet * has correct one's complement checksum as used by the IP * protocol. * * It uses all the clever tricks described in RFC 1071 to speed * up checksum calculation as much as possible. * * Result: 1 if the checksum is correct, 0 else. */ int ipsum_verify(void *frag, uint len, ...) { va_list args; u16 sum; va_start(args, len); sum = ipsum_calc(frag, len, args); va_end(args); return sum == 0xffff; } /** * ipsum_calculate - compute an IP checksum * @frag: first packet fragment * @len: length in bytes * * This function calculates a one's complement checksum of a given fragmented * packet. * * It uses all the clever tricks described in RFC 1071 to speed * up checksum calculation as much as possible. */ u16 ipsum_calculate(void *frag, uint len, ...) { va_list args; u16 sum; va_start(args, len); sum = ipsum_calc(frag, len, args); va_end(args); return 0xffff - sum; } bird-2.0.8/lib/buffer_test.c0000664000175000017500000000574314025744326014617 0ustar feelafeela/* * BIRD Library -- Buffer Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "test/birdtest.h" #include "lib/buffer.h" #define MAX_NUM 33 typedef BUFFER(int) buffer_int; static int expected[MAX_NUM]; static buffer_int buf; static struct pool *buffer_pool; static void show_buf(buffer_int *b) { uint i; bt_debug(".used = %d, .size = %d\n", b->used, b->size); for (i = 0; i < b->used; i++) bt_debug(" .data[%3u] = %-16d expected %-16d %s\n", i, b->data[i], expected[i], (b->data[i] == expected[i] ? "OK" : "FAIL!")); } static void fill_expected_array(void) { int i; for (i = 0; i < MAX_NUM; i++) expected[i] = bt_random(); } static void init_buffer(void) { resource_init(); buffer_pool = &root_pool; BUFFER_INIT(buf, buffer_pool, MAX_NUM); } static int is_buffer_as_expected(buffer_int *b) { show_buf(b); int i; for (i = 0; i < MAX_NUM; i++) bt_assert(b->data[i] == expected[i]); return 1; } static int t_buffer_push(void) { int i; init_buffer(); fill_expected_array(); for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; is_buffer_as_expected(&buf); return 1; } static int t_buffer_pop(void) { int i; init_buffer(); fill_expected_array(); /* POP a half of elements */ for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; for (i = MAX_NUM-1; i >= MAX_NUM/2; i--) BUFFER_POP(buf); for (i = MAX_NUM/2; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i] = bt_random(); is_buffer_as_expected(&buf); /* POP all of elements */ for (i = MAX_NUM-1; i >= 0; i--) BUFFER_POP(buf); bt_assert(buf.used == 0); for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; is_buffer_as_expected(&buf); return 1; } static int t_buffer_resize(void) { int i; init_buffer(); BUFFER_INIT(buf, buffer_pool, 0); fill_expected_array(); for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; is_buffer_as_expected(&buf); bt_assert(buf.size >= MAX_NUM); return 1; } static int t_buffer_flush(void) { int i; init_buffer(); fill_expected_array(); for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; BUFFER_FLUSH(buf); bt_assert(buf.used == 0); return 1; } static int t_buffer_walk(void) { int i; init_buffer(); fill_expected_array(); for (i = 0; i < MAX_NUM; i++) BUFFER_PUSH(buf) = expected[i]; i = 0; BUFFER_WALK(buf, v) bt_assert(v == expected[i++]); bt_assert(i == MAX_NUM); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_buffer_push, "Pushing new elements"); bt_test_suite(t_buffer_pop, "Fill whole buffer (PUSH), a half of elements POP and PUSH new elements"); bt_test_suite(t_buffer_resize, "Init a small buffer and try overfill"); bt_test_suite(t_buffer_flush, "Fill and flush all elements"); bt_test_suite(t_buffer_walk, "Fill and walk through buffer"); return bt_exit_value(); } bird-2.0.8/lib/buffer.h0000664000175000017500000000314014025744326013552 0ustar feelafeela/* * BIRD Library -- Generic Buffer Structure * * (c) 2013 Ondrej Zajicek * (c) 2013 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_BUFFER_H_ #define _BIRD_BUFFER_H_ #include "lib/resource.h" #include "sysdep/config.h" #define BUFFER_(type) struct { type *data; uint used, size; } #define BUFFER_TYPE(v) typeof(* (v).data) #define BUFFER_SIZE(v) ((v).size * sizeof(* (v).data)) #ifndef PARSER #define BUFFER(type) BUFFER_(type) #endif #define BUFFER_INIT(v,pool,isize) \ ({ \ (v).used = 0; \ (v).size = (isize); \ (v).data = mb_alloc(pool, BUFFER_SIZE(v)); \ }) #define BUFFER_SET(v,nsize) \ ({ \ (v).used = (nsize); \ if ((v).used > (v).size) \ buffer_realloc((void **) &((v).data), &((v).size), (v).used, sizeof(* (v).data)); \ }) #define BUFFER_INC(v,step) \ ({ \ uint _o = (v).used; \ BUFFER_SET(v, (v).used + (step)); \ (v).data + _o; \ }) #define BUFFER_DEC(v,step) ({ (v).used -= (step); }) #define BUFFER_PUSH(v) (*BUFFER_INC(v,1)) #define BUFFER_POP(v) BUFFER_DEC(v,1) #define BUFFER_FLUSH(v) ({ (v).used = 0; }) #define BUFFER_EMPTY(v) ({ (v).used == 0; }) #define BUFFER_WALK(v,n) \ for (BUFFER_TYPE(v) *_n = (v).data, n; _n < ((v).data + (v).used) && (n = *_n, 1); _n++) #define BUFFER_SHALLOW_COPY(dst, src) \ ({ \ (dst).used = (src).used; \ (dst).size = (src).size; \ (dst).data = (src).data; \ }) #endif /* _BIRD_BUFFER_H_ */ bird-2.0.8/lib/bitops_test.c0000664000175000017500000000457714025744326014652 0ustar feelafeela/* * BIRD Library -- Generic Bit Operations Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" /* naive_pow() */ #include "lib/bitops.h" #define MAX_NUM 1000 #define CHECK_BIT(var,pos) ((var) & (u32)(1<<(pos))) static int t_mkmask(void) { int i; u32 compute, expect; bt_assert(u32_mkmask(0) == 0x00000000); for (i = 1; i <= 32; i++) { compute = u32_mkmask(i); expect = (u32) (0xffffffff << (32-i)); bt_assert_msg(compute == expect, "u32_mkmask(%d) = 0x%08X, expected 0x%08X", i, compute, expect); } return 1; } static int u32_masklen_expected(u32 mask) { int j, expect = 0; int valid = 0; for (j = 0; j <= 32; j++) if (mask == (j ? (0xffffffff << (32-j)) : 0)) /* Shifting 32-bit value by 32 bits is undefined behavior */ valid = 1; if (!valid && mask != 0) expect = 255; else for (j = 0; j <= 31; j++) if (CHECK_BIT(mask, (31-j))) expect = j+1; else break; return expect; } static void check_mask(u32 mask) { int expected, masklen; expected = u32_masklen_expected(mask); masklen = u32_masklen(mask); int ok = (expected == masklen); bt_debug("u32_masklen(Ox%08x) = %d, expected %d %s\n", mask, masklen, expected, ok ? "OK" : "FAIL!"); bt_assert(ok); } static int t_masklen(void) { u32 i; check_mask(0x82828282); check_mask(0x00000000); for (i = 0; i <= 32; i++) check_mask(((u32) (i ? (0xffffffff << (32-i)) : 0)) & 0xffffffff); /* Shifting 32-bit value by 32 bits is undefined behavior */ for (i = 0; i <= MAX_NUM; i++) check_mask(bt_random()); return 1; } static void check_log2(u32 n) { u32 log = u32_log2(n); u32 low = bt_naive_pow(2, log); u32 high = bt_naive_pow(2, log+1); bt_assert_msg(n >= low && n < high, "u32_log2(%u) = %u, %u should be in the range <%u, %u)", n, log, n, low, high); } static int t_log2(void) { u32 i; for (i = 0; i < 31; i++) bt_assert(u32_log2(bt_naive_pow(2, i+1)) == i+1); for (i = 1; i < MAX_NUM; i++) check_log2(i); for (i = 1; i < MAX_NUM; i++) check_log2(((u32) bt_random()) % 0x0fffffff); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_mkmask, "u32_mkmask()"); bt_test_suite(t_masklen, "u32_masklen()"); bt_test_suite(t_log2, "u32_log2()"); return bt_exit_value(); } bird-2.0.8/lib/bitops.h0000664000175000017500000000161514025744326013606 0ustar feelafeela/* * BIRD Library -- Generic Bit Operations * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_BITOPTS_H_ #define _BIRD_BITOPTS_H_ #include "sysdep/config.h" /* * Bit mask operations: * * u32_mkmask Make bit mask consisting of consecutive ones * from the left and the rest filled with zeroes. * E.g., u32_mkmask(5) = 0xf8000000. * u32_masklen Inverse operation to u32_mkmask, -1 if not a bitmask. */ u32 u32_mkmask(uint n); uint u32_masklen(u32 x); u32 u32_log2(u32 v); static inline u32 u32_hash(u32 v) { return v * 2902958171u; } static inline u8 u32_popcount(u32 v) { return __builtin_popcount(v); } static inline int u32_clz(u32 v) { return __builtin_clz(v); } static inline int u32_ctz(u32 v) { return __builtin_ctz(v); } static inline int uint_is_pow2(uint n) { return n && !(n & (n-1)); } #endif bird-2.0.8/lib/bitops.c0000664000175000017500000000325214025744326013600 0ustar feelafeela/* * BIRD Library -- Generic Bit Operations * * (c) 1998 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "bitops.h" /** * u32_mkmask - create a bit mask * @n: number of bits * * u32_mkmask() returns an unsigned 32-bit integer which binary * representation consists of @n ones followed by zeroes. */ u32 u32_mkmask(uint n) { return n ? ~((1 << (32 - n)) - 1) : 0; } /** * u32_masklen - calculate length of a bit mask * @x: bit mask * * This function checks whether the given integer @x represents * a valid bit mask (binary representation contains first ones, then * zeroes) and returns the number of ones or 255 if the mask is invalid. */ uint u32_masklen(u32 x) { int l = 0; u32 n = ~x; if (n & (n+1)) return 255; if (x & 0x0000ffff) { x &= 0x0000ffff; l += 16; } if (x & 0x00ff00ff) { x &= 0x00ff00ff; l += 8; } if (x & 0x0f0f0f0f) { x &= 0x0f0f0f0f; l += 4; } if (x & 0x33333333) { x &= 0x33333333; l += 2; } if (x & 0x55555555) l++; if (x & 0xaaaaaaaa) l++; return l; } /** * u32_log2 - compute a binary logarithm. * @v: number * * This function computes a integral part of binary logarithm of given * integer @v and returns it. The computed value is also an index of the * most significant non-zero bit position. */ u32 u32_log2(u32 v) { /* The code from http://www-graphics.stanford.edu/~seander/bithacks.html */ u32 r, shift; r = (v > 0xFFFF) << 4; v >>= r; shift = (v > 0xFF ) << 3; v >>= shift; r |= shift; shift = (v > 0xF ) << 2; v >>= shift; r |= shift; shift = (v > 0x3 ) << 1; v >>= shift; r |= shift; r |= (v >> 1); return r; } bird-2.0.8/lib/bitmap_test.c0000664000175000017500000000654414025744326014622 0ustar feelafeela/* * BIRD Library -- Bitmap Tests * * (c) 2019 Ondrej Zajicek * (c) 2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "sysdep/config.h" #include "lib/bitmap.h" #define MAX_NUM (1 << 20) #define MAX_SET (1 << 19) #define MAX_CLR (1 << 17) #define STEP_NUM 1000 #define STEP_SET 1000 #define STEP_CLR 500 static int t_bmap_set_clear_random(void) { struct bmap b; resource_init(); bmap_init(&b, &root_pool, 1024); char expected[MAX_NUM] = {}; uint i, n; for (i = 0; i < MAX_SET; i++) { do n = bt_random() % MAX_NUM; while (expected[n]); bmap_set(&b, n); expected[n] = 1; } for (i = 0; i < MAX_CLR; i++) { do n = bt_random() % MAX_NUM; while (!expected[n]); bmap_clear(&b, n); expected[n] = 0; } for (i = 0; i < MAX_NUM; i++) if (bmap_test(&b, i) != expected[i]) bt_abort_msg("Bitmap mismatch on %d (should be %d %d)", i, bmap_test(&b, i), expected[i]); return 1; } static int t_hmap_set_clear_random(void) { struct hmap b; resource_init(); hmap_init(&b, &root_pool, 1024); char expected[MAX_NUM] = {}; uint i, n; for (i = 0; i < MAX_SET; i++) { do n = bt_random() % MAX_NUM; while (expected[n]); hmap_set(&b, n); expected[n] = 1; } hmap_check(&b); for (i = 0; i < MAX_CLR; i++) { do n = bt_random() % MAX_NUM; while (!expected[n]); hmap_clear(&b, n); expected[n] = 0; } hmap_check(&b); for (i = 0; i < MAX_NUM; i++) if (hmap_test(&b, i) != expected[i]) bt_abort_msg("Bitmap mismatch on %d (should be %d %d)", i, hmap_test(&b, i), expected[i]); for (i = 0; 1; i++) { n = hmap_first_zero(&b); bt_assert(n >= i); bt_assert(n <= MAX_NUM); for (; i < n; i++) bt_assert(expected[i]); if (n == MAX_NUM) break; bt_assert(!expected[i]); hmap_set(&b, n); } hmap_check(&b); return 1; } static int t_hmap_set_clear_fill(void) { struct hmap b; resource_init(); hmap_init(&b, &root_pool, 1024); char expected[MAX_NUM] = {}; uint i, j, n, max = 0; for (i = 0; i < STEP_NUM; i++) { uint last = 0; uint step_set = bt_random() % STEP_SET; uint step_clr = bt_random() % STEP_CLR; for (j = 0; j < step_set; j++) { n = hmap_first_zero(&b); bt_assert(n > last || !last); bt_assert(n < MAX_NUM); if (!last) last = n; for (; last < n; last++) bt_assert(expected[last]); bt_assert(!expected[n]); hmap_set(&b, n); expected[n] = 1; max = MAX(max, n); } for (j = 0; j < step_clr; j++) { uint k = 0; do n = bt_random() % max; while (!expected[n] && (k++ < 8)); if (!expected[n]) continue; hmap_clear(&b, n); expected[n] = 0; } } for (i = 0; i < MAX_NUM; i++) if (hmap_test(&b, i) != expected[i]) bt_abort_msg("Bitmap mismatch on %d (should be %d %d)", i, hmap_test(&b, i), expected[i]); hmap_check(&b); return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_bmap_set_clear_random, "BMap - random sequence of sets / clears"); bt_test_suite(t_hmap_set_clear_random, "HMap - random sequence of sets / clears"); bt_test_suite(t_hmap_set_clear_fill, "HMap - linear sets and random clears"); return bt_exit_value(); } bird-2.0.8/lib/bitmap.h0000664000175000017500000000253114025744326013560 0ustar feelafeela/* * BIRD Library -- Bitmaps * * (c) 2019 Ondrej Zajicek * (c) 2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_BITMAP_H_ #define _BIRD_BITMAP_H_ struct bmap { u32 size; u32 *data; }; void bmap_init(struct bmap *b, pool *p, uint size); void bmap_reset(struct bmap *b, uint size); void bmap_grow(struct bmap *b, uint need); void bmap_free(struct bmap *b); static inline uint bmap_max(struct bmap *b) { return 8 * b->size; } static inline int bmap_test(struct bmap *b, uint n) { return (n < bmap_max(b)) && BIT32_TEST(b->data, n); } static inline void bmap_set(struct bmap *b, uint n) { if (n >= bmap_max(b)) bmap_grow(b, n/8 + 1); BIT32_SET(b->data, n); } static inline void bmap_clear(struct bmap *b, uint n) { if (n >= bmap_max(b)) return; BIT32_CLR(b->data, n); } struct hmap { u32 size[4]; u32 *data[4]; u32 root[8]; }; static inline uint hmap_max(struct hmap *b) { return 8 * b->size[0]; } static inline int hmap_test(struct hmap *b, uint n) { return (n < hmap_max(b)) && BIT32_TEST(b->data[0], n); } void hmap_init(struct hmap *b, pool *p, uint size); void hmap_free(struct hmap *b); void hmap_set(struct hmap *b, uint n); void hmap_clear(struct hmap *b, uint n); u32 hmap_first_zero(struct hmap *b); void hmap_check(struct hmap *b); #endif bird-2.0.8/lib/bitmap.c0000664000175000017500000000625214025744326013557 0ustar feelafeela/* * BIRD Library -- Bitmaps * * (c) 2019 Ondrej Zajicek * (c) 2019 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include #include "nest/bird.h" #include "lib/bitmap.h" #include "lib/bitops.h" #include "lib/resource.h" /* * Basic bitmap */ void bmap_init(struct bmap *b, pool *p, uint size) { b->size = BIRD_ALIGN(size, 4); b->data = mb_allocz(p, b->size); } void bmap_reset(struct bmap *b, uint size) { b->size = BIRD_ALIGN(size, 4); memset(b->data, 0, b->size); } void bmap_grow(struct bmap *b, uint need) { uint size = b->size * 2; while (size < need) size *= 2; uint old_size = b->size; b->size = size; b->data = mb_realloc(b->data, b->size); ASSERT(size >= old_size); memset(b->data + (old_size / 4), 0, size - old_size); } void bmap_free(struct bmap *b) { mb_free(b->data); b->size = 0; b->data = NULL; } /* * Hierarchical bitmap */ #define B256_SIZE(b) BIRD_ALIGN(b, 32) #define B256_STEP(b) (BIRD_ALIGN(b, 8192) >> 8) void hmap_init(struct hmap *b, pool *p, uint size) { b->size[0] = B256_SIZE(size); b->size[1] = B256_STEP(b->size[0]); b->size[2] = B256_STEP(b->size[1]); b->size[3] = sizeof(b->root); b->data[0] = mb_allocz(p, b->size[0]); b->data[1] = mb_allocz(p, b->size[1]); b->data[2] = mb_allocz(p, b->size[2]); b->data[3] = b->root; memset(b->root, 0, sizeof(b->root)); } static void hmap_grow(struct hmap *b, uint need) { uint size = b->size[0] * 2; while (size < need) size *= 2; for (uint i = 0; i < 3; i++) { uint old_size = b->size[i]; b->size[i] = size; b->data[i] = mb_realloc(b->data[i], b->size[i]); ASSERT(size >= old_size); memset(b->data[i] + (old_size / 4), 0, size - old_size); size = B256_STEP(size); } } void hmap_free(struct hmap *b) { mb_free(b->data[0]); mb_free(b->data[1]); mb_free(b->data[2]); memset(b, 0, sizeof(struct hmap)); } static inline int b256_and(u32 *p) { for (int i = 0; i < 8; i++) if (~p[i]) return 0; return 1; } void hmap_set(struct hmap *b, uint n) { if (n >= hmap_max(b)) hmap_grow(b, n/8 + 1); for (int i = 0; i < 4; i++) { BIT32_SET(b->data[i], n); n = n >> 8; /* Continue if all bits in 256-bit block are set */ if (! b256_and(b->data[i] + 8*n)) break; } } void hmap_clear(struct hmap *b, uint n) { if (n >= hmap_max(b)) return; for (int i = 0; i < 4; i++) { BIT32_CLR(b->data[i], n); n = n >> 8; } } static inline int b256_first_zero(u32 *p) { for (int i = 0; i < 8; i++) if (~p[i]) return 32*i + u32_ctz(~p[i]); return 256; } u32 hmap_first_zero(struct hmap *b) { u32 n = 0; for (int i = 3; i >= 0; i--) { if (32*n >= b->size[i]) return hmap_max(b); u32 *p = b->data[i] + 8*n; n = (n << 8) + b256_first_zero(p); } return n; } void hmap_check(struct hmap *b) { for (int i = 0; i < 2; i++) { int max = b->size[i] / 32; for (int j = 0; j < max; j++) { int x = b256_and(b->data[i] + 8*j); int y = !!BIT32_TEST(b->data[i+1], j); if (x != y) bug("Inconsistent data on %d:%d (%d vs %d)", i, j, x, y); } } } bird-2.0.8/lib/birdlib.h0000664000175000017500000001161014025744326013711 0ustar feelafeela/* * BIRD Library * * (c) 1998--2004 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_BIRDLIB_H_ #define _BIRD_BIRDLIB_H_ #include "lib/alloca.h" /* Ugly structure offset handling macros */ struct align_probe { char x; long int y; }; #define OFFSETOF(s, i) ((size_t) &((s *)0)->i) #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1)) #define CPU_STRUCT_ALIGN (sizeof(struct align_probe)) /* Utility macros */ #define MIN_(a,b) (((a)<(b))?(a):(b)) #define MAX_(a,b) (((a)>(b))?(a):(b)) #ifndef PARSER #undef MIN #undef MAX #define MIN(a,b) MIN_(a,b) #define MAX(a,b) MAX_(a,b) #endif #define U64(c) UINT64_C(c) #define ABS(a) ((a)>=0 ? (a) : -(a)) #define DELTA(a,b) (((a)>=(b))?(a)-(b):(b)-(a)) #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) #define BYTES(n) ((((uint) (n)) + 7) / 8) #define CALL(fn, args...) ({ if (fn) fn(args); }) #define ADVANCE(w, r, l) ({ r -= (l); w += (l); }) static inline int uint_cmp(uint i1, uint i2) { return (int)(i1 > i2) - (int)(i1 < i2); } static inline int u64_cmp(u64 i1, u64 i2) { return (int)(i1 > i2) - (int)(i1 < i2); } /* Bitfield macros */ /* b is u32 array (or ptr), l is size of it in bits (multiple of 32), p is 0..(l-1) */ #define BIT32_VAL(p) (((u32) 1) << ((p) % 32)) #define BIT32_TEST(b,p) ((b)[(p)/32] & BIT32_VAL(p)) #define BIT32_SET(b,p) ((b)[(p)/32] |= BIT32_VAL(p)) #define BIT32_CLR(b,p) ((b)[(p)/32] &= ~BIT32_VAL(p)) #define BIT32_ZERO(b,l) memset((b), 0, (l)/8) /* The same, but counting bits from MSB */ #define BIT32R_VAL(p) ((((u32) 1) << 31) >> ((p) % 32)) #define BIT32R_TEST(b,p) ((b)[(p)/32] & BIT32R_VAL(p)) #define BIT32R_SET(b,p) ((b)[(p)/32] |= BIT32R_VAL(p)) #define BIT32R_CLR(b,p) ((b)[(p)/32] &= ~BIT32R_VAL(p)) #define BIT32R_ZERO(b,l) memset((b), 0, (l)/8) #ifndef NULL #define NULL ((void *) 0) #endif /* Macros for gcc attributes */ #define NORET __attribute__((noreturn)) #define UNUSED __attribute__((unused)) #define PACKED __attribute__((packed)) #define NONNULL(...) __attribute__((nonnull((__VA_ARGS__)))) #ifndef HAVE_THREAD_LOCAL #define _Thread_local #endif /* Microsecond time */ typedef s64 btime; //typedef s64 bird_clock_t; #define S_ * (btime) 1000000 #define MS_ * (btime) 1000 #define US_ * (btime) 1 #define TO_S /1000000 #define TO_MS /1000 #define TO_US /1 #ifndef PARSER #define S S_ #define MS MS_ #define US US_ #define NS /1000 #endif #define TIME_INFINITY ((s64) 0x7fffffffffffffff) /* Rate limiting */ struct tbf { btime timestamp; /* Last update */ u64 count; /* Available micro-tokens */ u16 burst; /* Max number of tokens */ u16 rate; /* Rate of replenishment (tokens / sec) */ u32 drop; /* Number of failed request since last successful */ }; /* Default TBF values for rate limiting log messages */ #define TBF_DEFAULT_LOG_LIMITS { .rate = 1, .burst = 5 } int tbf_limit(struct tbf *f); /* Logging and dying */ typedef struct buffer { byte *start; byte *pos; byte *end; } buffer; #define STACK_BUFFER_INIT(buf,size) \ do { \ buf.start = alloca(size); \ buf.pos = buf.start; \ buf.end = buf.start + size; \ } while(0) #define LOG_BUFFER_INIT(buf) \ STACK_BUFFER_INIT(buf, LOG_BUFFER_SIZE) #define LOG_BUFFER_SIZE 1024 #define log log_msg void log_commit(int class, buffer *buf); void log_msg(const char *msg, ...); void log_rl(struct tbf *rl, const char *msg, ...); void die(const char *msg, ...) NORET; void bug(const char *msg, ...) NORET; #define L_DEBUG "\001" /* Debugging messages */ #define L_TRACE "\002" /* Protocol tracing */ #define L_INFO "\003" /* Informational messages */ #define L_REMOTE "\004" /* Remote protocol errors */ #define L_WARN "\005" /* Local warnings */ #define L_ERR "\006" /* Local errors */ #define L_AUTH "\007" /* Authorization failed etc. */ #define L_FATAL "\010" /* Fatal errors */ #define L_BUG "\011" /* BIRD bugs */ void debug(const char *msg, ...); /* Printf to debug output */ /* Debugging */ #if defined(LOCAL_DEBUG) || defined(GLOBAL_DEBUG) #define DBG(x, y...) debug(x, ##y) #else #define DBG(x, y...) do { } while(0) #endif #define ASSERT_DIE(x) do { if (!(x)) bug("Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) #define EXPENSIVE_CHECK(x) /* intentionally left blank */ #ifdef DEBUGGING #define ASSERT(x) ASSERT_DIE(x) #define ASSUME(x) ASSERT_DIE(x) #ifdef ENABLE_EXPENSIVE_CHECKS #undef EXPENSIVE_CHECK #define EXPENSIVE_CHECK(x) ASSERT_DIE(x) #endif #else #define ASSERT(x) do { if (!(x)) log(L_BUG "Assertion '%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) #define ASSUME(x) /* intentionally left blank */ #endif #ifdef DEBUGGING asm( ".pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n" ".byte 1\n" /* Python */ ".asciz \"bird-gdb.py\"\n" ".popsection\n" ); #endif /* Pseudorandom numbers */ u32 random_u32(void); #endif bird-2.0.8/lib/alloca.h0000664000175000017500000000055214025744326013540 0ustar feelafeela/* * BIRD Library -- Alloca.h * * (c) 2004 Ondrej Filip * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_ALLOCA_H_ #define _BIRD_ALLOCA_H_ #ifdef HAVE_ALLOCA_H #include #else #include #endif #define allocz(len) ({ void *_x = alloca(len); memset(_x, 0, len); _x; }) #endif bird-2.0.8/lib/Makefile0000664000175000017500000000106314025744326013572 0ustar feelafeelasrc := bitmap.c bitops.c checksum.c event.c flowspec.c idm.c ip.c lists.c mac.c md5.c mempool.c net.c patmatch.c printf.c resource.c sha1.c sha256.c sha512.c slab.c slists.c strtoul.c tbf.c timer.c xmalloc.c obj := $(src-o-files) $(all-daemon) tests_src := bitmap_test.c heap_test.c buffer_test.c event_test.c flowspec_test.c bitops_test.c patmatch_test.c fletcher16_test.c slist_test.c checksum_test.c lists_test.c mac_test.c ip_test.c hash_test.c printf_test.c tests_targets := $(tests_targets) $(tests-target-files) tests_objs := $(tests_objs) $(src-o-files) bird-2.0.8/lib/Doc0000664000175000017500000000030614025744326012561 0ustar feelafeelaH Library functions S ip.c S lists.c S checksum.c bitops.c patmatch.c printf.c xmalloc.c tbf.c S mac.c S flowspec.c D resource.sgml S resource.c S mempool.c S slab.c S event.c S ../sysdep/unix/io.c bird-2.0.8/filter/0000775000175000017500000000000014025744326012651 5ustar feelafeelabird-2.0.8/filter/trie_test.c0000664000175000017500000001036214025744326015021 0ustar feelafeela/* * Filters: Utility Functions Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" #include "filter/filter.h" #include "filter/data.h" #include "conf/conf.h" #define TESTS_NUM 10 #define PREFIXES_NUM 10 #define PREFIX_TESTS_NUM 10000 #define BIG_BUFFER_SIZE 10000 /* Wrapping structure for storing f_prefixes structures in list */ struct f_prefix_node { node n; struct f_prefix prefix; }; static u32 xrandom(u32 max) { return (bt_random() % max); } static int is_prefix_included(list *prefixes, struct f_prefix *needle) { struct f_prefix_node *n; WALK_LIST(n, *prefixes) { ip6_addr cmask = ip6_mkmask(MIN(n->prefix.net.pxlen, needle->net.pxlen)); ip6_addr ip = net6_prefix(&n->prefix.net); ip6_addr needle_ip = net6_prefix(&needle->net); if ((ipa_compare(ipa_and(ip, cmask), ipa_and(needle_ip, cmask)) == 0) && (n->prefix.lo <= needle->net.pxlen) && (needle->net.pxlen <= n->prefix.hi)) { bt_debug("FOUND\t" PRIip6 "/%d %d-%d\n", ARGip6(net6_prefix(&n->prefix.net)), n->prefix.net.pxlen, n->prefix.lo, n->prefix.hi); return 1; /* OK */ } } return 0; /* FAIL */ } static struct f_prefix get_random_ip6_prefix(void) { struct f_prefix p; u8 pxlen = xrandom(120)+8; ip6_addr ip6 = ip6_build(bt_random(),bt_random(),bt_random(),bt_random()); net_addr_ip6 net6 = NET_ADDR_IP6(ip6, pxlen); p.net = *((net_addr*) &net6); if (bt_random() % 2) { p.lo = 0; p.hi = p.net.pxlen; } else { p.lo = p.net.pxlen; p.hi = net_max_prefix_length[p.net.type]; } return p; } static void generate_random_ipv6_prefixes(list *prefixes) { int i; for (i = 0; i < PREFIXES_NUM; i++) { struct f_prefix f = get_random_ip6_prefix(); struct f_prefix_node *px = calloc(1, sizeof(struct f_prefix_node)); px->prefix = f; bt_debug("ADD\t" PRIip6 "/%d %d-%d\n", ARGip6(net6_prefix(&px->prefix.net)), px->prefix.net.pxlen, px->prefix.lo, px->prefix.hi); add_tail(prefixes, &px->n); } } static int t_match_net(void) { bt_bird_init(); bt_config_parse(BT_CONFIG_SIMPLE); uint round; for (round = 0; round < TESTS_NUM; round++) { list prefixes; /* of structs f_extended_prefix */ init_list(&prefixes); struct f_trie *trie = f_new_trie(config->mem, 0); generate_random_ipv6_prefixes(&prefixes); struct f_prefix_node *n; WALK_LIST(n, prefixes) { trie_add_prefix(trie, &n->prefix.net, n->prefix.lo, n->prefix.hi); } int i; for (i = 0; i < PREFIX_TESTS_NUM; i++) { struct f_prefix f = get_random_ip6_prefix(); bt_debug("TEST\t" PRIip6 "/%d\n", ARGip6(net6_prefix(&f.net)), f.net.pxlen); int should_be = is_prefix_included(&prefixes, &f); int is_there = trie_match_net(trie, &f.net); bt_assert_msg(should_be == is_there, "Prefix " PRIip6 "/%d %s", ARGip6(net6_prefix(&f.net)), f.net.pxlen, (should_be ? "should be found in trie" : "should not be found in trie")); } struct f_prefix_node *nxt; WALK_LIST_DELSAFE(n, nxt, prefixes) { free(n); } } bt_bird_cleanup(); return 1; } static int t_trie_same(void) { bt_bird_init(); bt_config_parse(BT_CONFIG_SIMPLE); int round; for (round = 0; round < TESTS_NUM*4; round++) { struct f_trie * trie1 = f_new_trie(config->mem, 0); struct f_trie * trie2 = f_new_trie(config->mem, 0); list prefixes; /* a list of f_extended_prefix structures */ init_list(&prefixes); int i; for (i = 0; i < 100; i++) generate_random_ipv6_prefixes(&prefixes); struct f_prefix_node *n; WALK_LIST(n, prefixes) { trie_add_prefix(trie1, &n->prefix.net, n->prefix.lo, n->prefix.hi); } WALK_LIST_BACKWARDS(n, prefixes) { trie_add_prefix(trie2, &n->prefix.net, n->prefix.lo, n->prefix.hi); } bt_assert(trie_same(trie1, trie2)); struct f_prefix_node *nxt; WALK_LIST_DELSAFE(n, nxt, prefixes) { free(n); } } return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_match_net, "Testing random prefix matching"); bt_test_suite(t_trie_same, "A trie filled forward should be same with a trie filled backward."); return bt_exit_value(); } bird-2.0.8/filter/trie.c0000664000175000017500000003242014025744326013761 0ustar feelafeela/* * Filters: Trie for prefix sets * * Copyright 2009 Ondrej Zajicek * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Trie for prefix sets * * We use a (compressed) trie to represent prefix sets. Every node * in the trie represents one prefix (&addr/&plen) and &plen also * indicates the index of the bit in the address that is used to * branch at the node. If we need to represent just a set of * prefixes, it would be simple, but we have to represent a * set of prefix patterns. Each prefix pattern consists of * &ppaddr/&pplen and two integers: &low and &high, and a prefix * &paddr/&plen matches that pattern if the first MIN(&plen, &pplen) * bits of &paddr and &ppaddr are the same and &low <= &plen <= &high. * * We use a bitmask (&accept) to represent accepted prefix lengths * at a node. As there are 33 prefix lengths (0..32 for IPv4), but * there is just one prefix of zero length in the whole trie so we * have &zero flag in &f_trie (indicating whether the trie accepts * prefix 0.0.0.0/0) as a special case, and &accept bitmask * represents accepted prefix lengths from 1 to 32. * * There are two cases in prefix matching - a match when the length * of the prefix is smaller that the length of the prefix pattern, * (&plen < &pplen) and otherwise. The second case is simple - we * just walk through the trie and look at every visited node * whether that prefix accepts our prefix length (&plen). The * first case is tricky - we don't want to examine every descendant * of a final node, so (when we create the trie) we have to propagate * that information from nodes to their ascendants. * * Suppose that we have two masks (M1 and M2) for a node. Mask M1 * represents accepted prefix lengths by just the node and mask M2 * represents accepted prefix lengths by the node or any of its * descendants. Therefore M2 is a bitwise or of M1 and children's * M2 and this is a maintained invariant during trie building. * Basically, when we want to match a prefix, we walk through the trie, * check mask M1 for our prefix length and when we came to * final node, we check mask M2. * * There are two differences in the real implementation. First, * we use a compressed trie so there is a case that we skip our * final node (if it is not in the trie) and we came to node that * is either extension of our prefix, or completely out of path * In the first case, we also have to check M2. * * Second, we really need not to maintain two separate bitmasks. * Checks for mask M1 are always larger than &applen and we need * just the first &pplen bits of mask M2 (if trie compression * hadn't been used it would suffice to know just $applen-th bit), * so we have to store them together in &accept mask - the first * &pplen bits of mask M2 and then mask M1. * * There are four cases when we walk through a trie: * * - we are in NULL * - we are out of path (prefixes are inconsistent) * - we are in the wanted (final) node (node length == &plen) * - we are beyond the end of path (node length > &plen) * - we are still on path and keep walking (node length < &plen) * * The walking code in trie_match_prefix() is structured according to * these cases. */ #include "nest/bird.h" #include "lib/string.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/data.h" /* * In the trie_add_prefix(), we use ip_addr (assuming that it is the same as * ip6_addr) to handle both IPv4 and IPv6 prefixes. In contrast to rest of the * BIRD, IPv4 addresses are just zero-padded from right. That is why we have * ipt_from_ip4() and ipt_to_ip4() macros below. */ #define ipa_mkmask(x) ip6_mkmask(x) #define ipa_masklen(x) ip6_masklen(&x) #define ipa_pxlen(x,y) ip6_pxlen(x,y) #define ipa_getbit(x,n) ip6_getbit(x,n) #define ipt_from_ip4(x) _MI6(_I(x), 0, 0, 0) #define ipt_to_ip4(x) _MI4(_I0(x)) /** * f_new_trie - allocates and returns a new empty trie * @lp: linear pool to allocate items from * @data_size: user data attached to node */ struct f_trie * f_new_trie(linpool *lp, uint data_size) { struct f_trie * ret; ret = lp_allocz(lp, sizeof(struct f_trie) + data_size); ret->lp = lp; ret->ipv4 = -1; ret->data_size = data_size; return ret; } static inline struct f_trie_node4 * new_node4(struct f_trie *t, int plen, ip4_addr paddr, ip4_addr pmask, ip4_addr amask) { struct f_trie_node4 *n = lp_allocz(t->lp, sizeof(struct f_trie_node4) + t->data_size); n->plen = plen; n->addr = paddr; n->mask = pmask; n->accept = amask; return n; } static inline struct f_trie_node6 * new_node6(struct f_trie *t, int plen, ip6_addr paddr, ip6_addr pmask, ip6_addr amask) { struct f_trie_node6 *n = lp_allocz(t->lp, sizeof(struct f_trie_node6) + t->data_size); n->plen = plen; n->addr = paddr; n->mask = pmask; n->accept = amask; return n; } static inline struct f_trie_node * new_node(struct f_trie *t, int plen, ip_addr paddr, ip_addr pmask, ip_addr amask) { if (t->ipv4) return (struct f_trie_node *) new_node4(t, plen, ipt_to_ip4(paddr), ipt_to_ip4(pmask), ipt_to_ip4(amask)); else return (struct f_trie_node *) new_node6(t, plen, ipa_to_ip6(paddr), ipa_to_ip6(pmask), ipa_to_ip6(amask)); } static inline void attach_node4(struct f_trie_node4 *parent, struct f_trie_node4 *child) { parent->c[ip4_getbit(child->addr, parent->plen) ? 1 : 0] = child; } static inline void attach_node6(struct f_trie_node6 *parent, struct f_trie_node6 *child) { parent->c[ip6_getbit(child->addr, parent->plen) ? 1 : 0] = child; } static inline void attach_node(struct f_trie_node *parent, struct f_trie_node *child, int v4) { if (v4) attach_node4(&parent->v4, &child->v4); else attach_node6(&parent->v6, &child->v6); } #define GET_ADDR(N,F,X) ((X) ? ipt_from_ip4((N)->v4.F) : ipa_from_ip6((N)->v6.F)) #define SET_ADDR(N,F,X,V) ({ if (X) (N)->v4.F =ipt_to_ip4(V); else (N)->v6.F =ipa_to_ip6(V); }) #define GET_CHILD(N,F,X,I) ((X) ? (struct f_trie_node *) (N)->v4.c[I] : (struct f_trie_node *) (N)->v6.c[I]) /** * trie_add_prefix * @t: trie to add to * @net: IP network prefix * @l: prefix lower bound * @h: prefix upper bound * * Adds prefix (prefix pattern) @n to trie @t. @l and @h are lower * and upper bounds on accepted prefix lengths, both inclusive. * 0 <= l, h <= 32 (128 for IPv6). * * Returns a pointer to the allocated node. The function can return a pointer to * an existing node if @px and @plen are the same. If px/plen == 0/0 (or ::/0), * a pointer to the root node is returned. Returns NULL when called with * mismatched IPv4/IPv6 net type. */ void * trie_add_prefix(struct f_trie *t, const net_addr *net, uint l, uint h) { uint plen = net_pxlen(net); ip_addr px; int v4; switch (net->type) { case NET_IP4: px = ipt_from_ip4(net4_prefix(net)); v4 = 1; break; case NET_IP6: px = ipa_from_ip6(net6_prefix(net)); v4 = 0; break; default: bug("invalid type"); } if (t->ipv4 != v4) { if (t->ipv4 < 0) t->ipv4 = v4; else return NULL; } if (l == 0) t->zero = 1; else l--; if (h < plen) plen = h; ip_addr amask = ipa_xor(ipa_mkmask(l), ipa_mkmask(h)); ip_addr pmask = ipa_mkmask(plen); ip_addr paddr = ipa_and(px, pmask); struct f_trie_node *o = NULL; struct f_trie_node *n = &t->root; while (n) { ip_addr naddr = GET_ADDR(n, addr, v4); ip_addr nmask = GET_ADDR(n, mask, v4); ip_addr accept = GET_ADDR(n, accept, v4); ip_addr cmask = ipa_and(nmask, pmask); uint nlen = v4 ? n->v4.plen : n->v6.plen; if (ipa_compare(ipa_and(paddr, cmask), ipa_and(naddr, cmask))) { /* We are out of path - we have to add branching node 'b' between node 'o' and node 'n', and attach new node 'a' as the other child of 'b'. */ int blen = ipa_pxlen(paddr, naddr); ip_addr bmask = ipa_mkmask(blen); ip_addr baddr = ipa_and(px, bmask); /* Merge accept masks from children to get accept mask for node 'b' */ ip_addr baccm = ipa_and(ipa_or(amask, accept), bmask); struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask); struct f_trie_node *b = new_node(t, blen, baddr, bmask, baccm); attach_node(o, b, v4); attach_node(b, n, v4); attach_node(b, a, v4); return a; } if (plen < nlen) { /* We add new node 'a' between node 'o' and node 'n' */ amask = ipa_or(amask, ipa_and(accept, pmask)); struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask); attach_node(o, a, v4); attach_node(a, n, v4); return a; } if (plen == nlen) { /* We already found added node in trie. Just update accept mask */ accept = ipa_or(accept, amask); SET_ADDR(n, accept, v4, accept); return n; } /* Update accept mask part M2 and go deeper */ accept = ipa_or(accept, ipa_and(amask, nmask)); SET_ADDR(n, accept, v4, accept); /* n->plen < plen and plen <= 32 (128) */ o = n; n = GET_CHILD(n, c, v4, ipa_getbit(paddr, nlen) ? 1 : 0); } /* We add new tail node 'a' after node 'o' */ struct f_trie_node *a = new_node(t, plen, paddr, pmask, amask); attach_node(o, a, v4); return a; } static int trie_match_net4(const struct f_trie *t, ip4_addr px, uint plen) { ip4_addr pmask = ip4_mkmask(plen); ip4_addr paddr = ip4_and(px, pmask); if (plen == 0) return t->zero; int plentest = plen - 1; const struct f_trie_node4 *n = &t->root.v4; while (n) { ip4_addr cmask = ip4_and(n->mask, pmask); /* We are out of path */ if (ip4_compare(ip4_and(paddr, cmask), ip4_and(n->addr, cmask))) return 0; /* Check accept mask */ if (ip4_getbit(n->accept, plentest)) return 1; /* We finished trie walk and still no match */ if (plen <= n->plen) return 0; /* Choose children */ n = n->c[(ip4_getbit(paddr, n->plen)) ? 1 : 0]; } return 0; } static int trie_match_net6(const struct f_trie *t, ip6_addr px, uint plen) { ip6_addr pmask = ip6_mkmask(plen); ip6_addr paddr = ip6_and(px, pmask); if (plen == 0) return t->zero; int plentest = plen - 1; const struct f_trie_node6 *n = &t->root.v6; while (n) { ip6_addr cmask = ip6_and(n->mask, pmask); /* We are out of path */ if (ip6_compare(ip6_and(paddr, cmask), ip6_and(n->addr, cmask))) return 0; /* Check accept mask */ if (ip6_getbit(n->accept, plentest)) return 1; /* We finished trie walk and still no match */ if (plen <= n->plen) return 0; /* Choose children */ n = n->c[(ip6_getbit(paddr, n->plen)) ? 1 : 0]; } return 0; } /** * trie_match_net * @t: trie * @n: net address * * Tries to find a matching net in the trie such that * prefix @n matches that prefix pattern. Returns 1 if there * is such prefix pattern in the trie. */ int trie_match_net(const struct f_trie *t, const net_addr *n) { switch (n->type) { case NET_IP4: case NET_VPN4: case NET_ROA4: return t->ipv4 ? trie_match_net4(t, net4_prefix(n), net_pxlen(n)) : 0; case NET_IP6: case NET_VPN6: case NET_ROA6: return !t->ipv4 ? trie_match_net6(t, net6_prefix(n), net_pxlen(n)) : 0; default: return 0; } } static int trie_node_same4(const struct f_trie_node4 *t1, const struct f_trie_node4 *t2) { if ((t1 == NULL) && (t2 == NULL)) return 1; if ((t1 == NULL) || (t2 == NULL)) return 0; if ((t1->plen != t2->plen) || (! ip4_equal(t1->addr, t2->addr)) || (! ip4_equal(t1->accept, t2->accept))) return 0; return trie_node_same4(t1->c[0], t2->c[0]) && trie_node_same4(t1->c[1], t2->c[1]); } static int trie_node_same6(const struct f_trie_node6 *t1, const struct f_trie_node6 *t2) { if ((t1 == NULL) && (t2 == NULL)) return 1; if ((t1 == NULL) || (t2 == NULL)) return 0; if ((t1->plen != t2->plen) || (! ip6_equal(t1->addr, t2->addr)) || (! ip6_equal(t1->accept, t2->accept))) return 0; return trie_node_same6(t1->c[0], t2->c[0]) && trie_node_same6(t1->c[1], t2->c[1]); } /** * trie_same * @t1: first trie to be compared * @t2: second one * * Compares two tries and returns 1 if they are same */ int trie_same(const struct f_trie *t1, const struct f_trie *t2) { if ((t1->zero != t2->zero) || (t1->ipv4 != t2->ipv4)) return 0; if (t1->ipv4) return trie_node_same4(&t1->root.v4, &t2->root.v4); else return trie_node_same6(&t1->root.v6, &t2->root.v6); } static void trie_node_format4(const struct f_trie_node4 *t, buffer *buf) { if (t == NULL) return; if (ip4_nonzero(t->accept)) buffer_print(buf, "%I4/%d{%I4}, ", t->addr, t->plen, t->accept); trie_node_format4(t->c[0], buf); trie_node_format4(t->c[1], buf); } static void trie_node_format6(const struct f_trie_node6 *t, buffer *buf) { if (t == NULL) return; if (ip6_nonzero(t->accept)) buffer_print(buf, "%I6/%d{%I6}, ", t->addr, t->plen, t->accept); trie_node_format6(t->c[0], buf); trie_node_format6(t->c[1], buf); } /** * trie_format * @t: trie to be formatted * @buf: destination buffer * * Prints the trie to the supplied buffer. */ void trie_format(const struct f_trie *t, buffer *buf) { buffer_puts(buf, "["); if (t->zero) buffer_print(buf, "%I/%d, ", t->ipv4 ? IPA_NONE4 : IPA_NONE6, 0); if (t->ipv4) trie_node_format4(&t->root.v4, buf); else trie_node_format6(&t->root.v6, buf); if (buf->pos == buf->end) return; /* Undo last separator */ if (buf->pos[-1] != '[') buf->pos -= 2; buffer_puts(buf, "]"); } bird-2.0.8/filter/tree_test.c0000664000175000017500000001552114025744326015017 0ustar feelafeela/* * Filters: Utility Functions Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "test/birdtest.h" #include "test/bt-utils.h" #include "filter/filter.h" #include "filter/data.h" #include "conf/conf.h" #define MAX_TREE_HEIGHT 13 static void start_conf_env(void) { bt_bird_init(); pool *p = rp_new(&root_pool, "helper_pool"); linpool *l = lp_new_default(p); cfg_mem = l; } static struct f_tree * new_tree(uint id) { struct f_tree *tree = f_new_tree(); tree->from.type = tree->to.type = T_INT; tree->from.val.i = tree->to.val.i = id; return tree; } /* * Show subtree in infix notation */ static void show_subtree(struct f_tree *node) { if (!node) return; show_subtree(node->left); if (node->from.val.i == node->to.val.i) bt_debug("%u ", node->from.val.i); else bt_debug("%u..%u ", node->from.val.i, node->to.val.i); show_subtree(node->right); } static void show_tree2(struct f_tree *root_node, const char *tree_name) { bt_debug("%s: \n", tree_name); bt_debug("[ "); show_subtree(root_node); bt_debug("]\n\n"); } #define show_tree(tree) show_tree2(tree, #tree); static uint get_nodes_count_full_bin_tree(uint height) { return (bt_naive_pow(2, height+1) - 1); } static struct f_tree * get_balanced_full_subtree(uint height, uint idx) { struct f_tree *node = new_tree(idx); if (height > 0) { uint nodes_in_subtree = get_nodes_count_full_bin_tree(--height); node->left = get_balanced_full_subtree(height, idx - nodes_in_subtree/2 - 1); node->right = get_balanced_full_subtree(height, idx + nodes_in_subtree/2 + 1); } return node; } static struct f_tree * get_balanced_full_tree(uint height) { return get_balanced_full_subtree(height, get_nodes_count_full_bin_tree(height)/2); } static struct f_tree * get_degenerated_left_tree(uint nodes_count) { struct f_tree *old = NULL; struct f_tree *new = NULL; uint i; for (i = 0; i < nodes_count; i++) { old = new; new = new_tree(nodes_count-1-i); new->left = old; } return new; } static struct f_tree * get_random_degenerated_left_tree(uint nodes_count) { struct f_tree *tree = get_degenerated_left_tree(nodes_count); size_t avaible_indexes_size = nodes_count * sizeof(byte); byte *avaible_indexes = malloc(avaible_indexes_size); memset(avaible_indexes, 0, avaible_indexes_size); struct f_tree *n; for (n = tree; n; n = n->left) { uint selected_idx; do { selected_idx = bt_random() % nodes_count; } while(avaible_indexes[selected_idx] != 0); avaible_indexes[selected_idx] = 1; n->from.type = n->to.type = T_INT; n->from.val.i = n->to.val.i = selected_idx; } free(avaible_indexes); return tree; } static struct f_tree * get_balanced_tree_with_ranged_values(uint nodes_count) { struct f_tree *tree = get_degenerated_left_tree(nodes_count); uint idx = 0; struct f_tree *n; for (n = tree; n; n = n->left) { n->from.type = n->to.type = T_INT; n->from.val.i = idx; idx += (uint)bt_random() / nodes_count; /* (... / nodes_count) preventing overflow an uint idx */ n->to.val.i = idx++; } return build_tree(tree); } static int t_balancing(void) { start_conf_env(); uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { uint nodes_count = get_nodes_count_full_bin_tree(height); struct f_tree *simple_degenerated_tree = get_degenerated_left_tree(nodes_count); show_tree(simple_degenerated_tree); struct f_tree *expected_balanced_tree = get_balanced_full_tree(height); show_tree(expected_balanced_tree); struct f_tree *balanced_tree_from_simple = build_tree(simple_degenerated_tree); show_tree(balanced_tree_from_simple); bt_assert(same_tree(balanced_tree_from_simple, expected_balanced_tree)); } return 1; } static int t_balancing_random(void) { start_conf_env(); uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { uint nodes_count = get_nodes_count_full_bin_tree(height); struct f_tree *expected_balanced_tree = get_balanced_full_tree(height); uint i; for(i = 0; i < 10; i++) { struct f_tree *random_degenerated_tree = get_random_degenerated_left_tree(nodes_count); show_tree(random_degenerated_tree); struct f_tree *balanced_tree_from_random = build_tree(random_degenerated_tree); show_tree(expected_balanced_tree); show_tree(balanced_tree_from_random); bt_assert(same_tree(balanced_tree_from_random, expected_balanced_tree)); } } return 1; } static int t_find(void) { start_conf_env(); uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { uint nodes_count = get_nodes_count_full_bin_tree(height); struct f_tree *tree = get_balanced_full_tree(height); show_tree(tree); struct f_val looking_up_value = { .type = T_INT }; for(looking_up_value.val.i = 0; looking_up_value.val.i < nodes_count; looking_up_value.val.i++) { const struct f_tree *found_tree = find_tree(tree, &looking_up_value); bt_assert((val_compare(&looking_up_value, &(found_tree->from)) == 0) && (val_compare(&looking_up_value, &(found_tree->to)) == 0)); } } return 1; } static uint get_max_value_in_unbalanced_tree(struct f_tree *node, uint max) { if (!node) return max; if (node->to.val.i > max) max = node->to.val.i; uint max_left = get_max_value_in_unbalanced_tree(node->left, max); if (max_left > max) max = max_left; uint max_right = get_max_value_in_unbalanced_tree(node->right, max); if (max_right > max) max = max_right; return max; } static int t_find_ranges(void) { start_conf_env(); uint height; for (height = 1; height < MAX_TREE_HEIGHT; height++) { uint nodes_count = get_nodes_count_full_bin_tree(height); struct f_tree *tree = get_balanced_tree_with_ranged_values(nodes_count); uint max_value = get_max_value_in_unbalanced_tree(tree, 0); show_tree(tree); bt_debug("max_value: %u \n", max_value); struct f_val needle = { .type = T_INT }; uint *i = &needle.val.i; for(*i = 0; *i <= max_value; *i += (uint)bt_random()/nodes_count) { const struct f_tree *found_tree = find_tree(tree, &needle); bt_debug("searching: %u \n", *i); bt_assert( (val_compare(&needle, &(found_tree->from)) == 0) || (val_compare(&needle, &(found_tree->to)) == 0) || ((val_compare(&needle, &(found_tree->from)) == 1) && (val_compare(&needle, &(found_tree->to)) == -1)) ); } } return 1; } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_test_suite(t_balancing, "Balancing strong unbalanced trees"); bt_test_suite(t_balancing_random, "Balancing random unbalanced trees"); bt_test_suite(t_find, "Finding values in trees"); bt_test_suite(t_find_ranges, "Finding values in trees with random ranged values"); return bt_exit_value(); } bird-2.0.8/filter/tree.c0000664000175000017500000000727314025744326013765 0ustar feelafeela/* * Filters: utility functions * * Copyright 1998 Pavel Machek * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "lib/alloca.h" #include "nest/bird.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/data.h" /** * find_tree * @t: tree to search in * @val: value to find * * Search for given value in the tree. I relies on fact that sorted tree is populated * by &f_val structures (that can be compared by val_compare()). In each node of tree, * either single value (then t->from==t->to) or range is present. * * Both set matching and |switch() { }| construction is implemented using this function, * thus both are as fast as they can be. */ const struct f_tree * find_tree(const struct f_tree *t, const struct f_val *val) { if (!t) return NULL; if ((val_compare(&(t->from), val) != 1) && (val_compare(&(t->to), val) != -1)) return t; if (val_compare(&(t->from), val) == -1) return find_tree(t->right, val); else return find_tree(t->left, val); } static struct f_tree * build_tree_rec(struct f_tree **buf, int l, int h) { struct f_tree *n; int pos; if (l >= h) return NULL; pos = (l+h)/2; n = buf[pos]; n->left = build_tree_rec(buf, l, pos); n->right = build_tree_rec(buf, pos+1, h); return n; } static int tree_compare(const void *p1, const void *p2) { return val_compare(&((* (struct f_tree **) p1)->from), &((* (struct f_tree **) p2)->from)); } /** * build_tree * @from: degenerated tree (linked by @tree->left) to be transformed into form suitable for find_tree() * * Transforms degenerated tree into balanced tree. */ struct f_tree * build_tree(struct f_tree *from) { struct f_tree *tmp, *root; struct f_tree **buf; int len, i; if (from == NULL) return NULL; len = 0; for (tmp = from; tmp != NULL; tmp = tmp->left) len++; if (len <= 1024) buf = alloca(len * sizeof(struct f_tree *)); else buf = xmalloc(len * sizeof(struct f_tree *)); /* Convert a degenerated tree into an sorted array */ i = 0; for (tmp = from; tmp != NULL; tmp = tmp->left) buf[i++] = tmp; qsort(buf, len, sizeof(struct f_tree *), tree_compare); root = build_tree_rec(buf, 0, len); if (len > 1024) xfree(buf); return root; } struct f_tree * f_new_tree(void) { struct f_tree *ret = cfg_allocz(sizeof(struct f_tree)); return ret; } /** * same_tree * @t1: first tree to be compared * @t2: second one * * Compares two trees and returns 1 if they are same */ int same_tree(const struct f_tree *t1, const struct f_tree *t2) { if ((!!t1) != (!!t2)) return 0; if (!t1) return 1; if (val_compare(&(t1->from), &(t2->from))) return 0; if (val_compare(&(t1->to), &(t2->to))) return 0; if (!same_tree(t1->left, t2->left)) return 0; if (!same_tree(t1->right, t2->right)) return 0; if (!f_same(t1->data, t2->data)) return 0; return 1; } static void tree_node_format(const struct f_tree *t, buffer *buf) { if (t == NULL) return; tree_node_format(t->left, buf); val_format(&(t->from), buf); if (val_compare(&(t->from), &(t->to)) != 0) { buffer_puts(buf, ".."); val_format(&(t->to), buf); } buffer_puts(buf, ", "); tree_node_format(t->right, buf); } void tree_format(const struct f_tree *t, buffer *buf) { buffer_puts(buf, "["); tree_node_format(t, buf); if (buf->pos == buf->end) return; /* Undo last separator */ if (buf->pos[-1] != '[') buf->pos -= 2; buffer_puts(buf, "]"); } void tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data) { if (!t) return; tree_walk(t->left, hook, data); hook(t, data); tree_walk(t->right, hook, data); } bird-2.0.8/filter/test.conf20000664000175000017500000000306714025744326014567 0ustar feelafeela/* * This is an example configuration file. */ # Yet another comment router id 62.168.0.1; define xyzzy = (120+10); protocol device { # disabled; # interface "eth*", "ppp*"; } protocol direct { } protocol kernel { disabled; ipv4; # Must be specified at least one channel # learn; # Learn all routes from the kernel # scan time 10; # Scan kernel tables every 10 seconds } protocol static { # disabled; ipv4 { export all; import filter { print "ahoj"; print source; if source = RTS_STATIC then { print "It is from static"; } print from; from = 1.2.3.4; print from; print scope; scope = SCOPE_HOST; print scope; if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then { print "Failed in test"; } preference = 15; print preference; preference = 29; print preference; rip_metric = 1; print rip_metric; rip_metric = rip_metric + 5; print rip_metric; bgp_community = -empty-; print "hi"; bgp_community = add(bgp_community, (1,2)); print "hello"; bgp_community = add(bgp_community, (2,3)); bgp_community.add((4,5)); print "community = ", bgp_community; bgp_community.delete((2,3)); print "community = ", bgp_community; bgp_community.empty; print "community = ", bgp_community; print "done"; accept; }; }; route 0.0.0.0/0 via 195.113.31.113; route 62.168.0.0/25 reject; route 1.2.3.4/32 via 195.113.31.124; route 10.0.0.0/8 reject; route 10.1.1.0/24 via 62.168.0.3; route 10.1.2.0/24 via 62.168.0.3; route 10.1.3.0/24 via 62.168.0.4; route 10.2.0.0/24 via "arc0"; } bird-2.0.8/filter/test.conf.inc0000664000175000017500000000003514025744326015245 0ustar feelafeela bt_assert(1+1 = 2); i = 42; bird-2.0.8/filter/test.conf0000664000175000017500000007550014025744326014506 0ustar feelafeela/* * This is unit testing configuration file for testing filters * * FIXME: add all examples from docs here. */ router id 62.168.0.1; /* We have to setup any protocol */ protocol device { } /* * Common definitions and functions * -------------------------------- */ define one = 1; define ten = 10; function onef(int a) { return 1; } function twof(int a) { return 2; } function oneg(int a) { return 1; } bt_test_same(onef, onef, 1); bt_test_same(onef, oneg, 1); bt_test_same(onef, twof, 0); /* * Testing boolean expressions * --------------------------- */ function t_bool() bool b; { b = true; bt_assert(b); bt_assert(!!b); bt_assert(format(true) = "TRUE"); bt_assert(format(false) = "FALSE"); if ( b = true ) then bt_assert(b); else bt_assert(false); bt_assert(true && true); bt_assert(true || false); bt_assert(! false && ! false && true); bt_assert(1 < 2 && 1 != 3); bt_assert(true && true && ! false); # bt_assert(true || 1+"a"); # bt_assert(!(false && 1+"a")); bt_assert(!(true && false)); } bt_test_suite(t_bool, "Testing boolean expressions"); /* * Testing integers * ---------------- */ define four = 4; define xyzzy = (120+10); define '1a-a1' = (xyzzy-100); function t_int() int i; { bt_assert(xyzzy = 130); bt_assert('1a-a1' = 30); i = four; i = 12*100 + 60/2 + i; i = (i + 0); bt_assert(i = 1234); bt_assert(format(i) = "1234"); i = 4200000000; bt_assert(i = 4200000000); bt_assert(i > 4100000000); bt_assert(!(i > 4250000000)); bt_assert(1 = 1); bt_assert(!(1 != 1)); bt_assert(1 != 2); bt_assert(1 <= 2); bt_assert(1 != "a"); bt_assert(1 != (0,1)); bt_assert(!(i = 4)); bt_assert(1 <= 1); bt_assert(!(1234 < 1234)); } bt_test_suite(t_int, "Testing integers"); /* * Testing sets of integers * ------------------------ */ define is1 = [ one, (2+1), (6-one), 8, 11, 15, 17, 19]; define is2 = [(17+2), 17, 15, 11, 8, 5, 3, 2]; define is3 = [5, 17, 2, 11, 8, 15, 3, 19]; function t_int_set() int set is; { bt_assert(1 ~ [1,2,3]); bt_assert(5 ~ [1..20]); bt_assert(2 ~ [ 1, 2, 3 ]); bt_assert(5 ~ [ 4 .. 7 ]); bt_assert(1 !~ [ 2, 3, 4 ]); bt_assert(999 !~ [ 666, 333 ]); is = [ 2, 3, 4, 7..11 ]; bt_assert(10 ~ is); bt_assert(5 !~ is); bt_assert(1 ~ is1); bt_assert(3 ~ is1); bt_assert(5 ~ is1); bt_assert((one+2) ~ is1); bt_assert(2 ~ is2); bt_assert(2 ~ is3); bt_assert(4 !~ is1); bt_assert(4 !~ is2); bt_assert(4 !~ is3); bt_assert(10 !~ is1); bt_assert(10 !~ is2); bt_assert(10 !~ is3); bt_assert(15 ~ is1); bt_assert(15 ~ is2); bt_assert(15 ~ is3); bt_assert(18 !~ is1); bt_assert(18 !~ is2); bt_assert(18 !~ is3); bt_assert(19 ~ is1); bt_assert(19 ~ is2); bt_assert(19 ~ is3); bt_assert(20 !~ is1); bt_assert(20 !~ is2); bt_assert(20 !~ is3); bt_assert([1,2] != [1,3]); bt_assert([1,4..10,20] = [1,4..10,20]); bt_assert(format([ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]) = "[1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]"); } bt_test_suite(t_int_set, "Testing sets of integers"); /* * Testing string matching * ----------------------- */ function t_string() string st; { st = "Hello"; bt_assert(format(st) = "Hello"); bt_assert(st ~ "Hell*"); bt_assert(st ~ "?ello"); bt_assert(st ~ "Hello"); bt_assert(st ~ "Hell?"); bt_assert(st !~ "ell*"); } bt_test_suite(t_string, "Testing string matching"); /* * Testing pairs * ------------- */ function 'mkpair-a'(int a) { return (1, a); } function t_pair() pair pp; { pp = (1, 2); bt_assert(format(pp) = "(1,2)"); bt_assert((1,2) = pp); bt_assert((1,1+1) = pp); bt_assert('mkpair-a'(2) = pp); bt_assert((1,2) = (1,1+1)); bt_assert(((1,2) < (2,2))); bt_assert(!((1,1) > (1,1))); } bt_test_suite(t_pair, "Testing pairs"); /* * Testing sets of pairs * --------------------- */ function t_pair_set() pair pp; pair set ps; { pp = (1, 2); ps = [(1,(one+one)), (3,4)..(4,8), (5,*), (6,3..6)]; bt_assert(format(ps) = "[(1,2), (3,4)..(4,8), (5,0)..(5,65535), (6,3)..(6,6)]"); bt_assert(pp ~ ps); bt_assert((3,5) ~ ps); bt_assert((4,1) ~ ps); bt_assert((5,4) ~ ps); bt_assert((5,65535) ~ ps); bt_assert((6,4) ~ ps); bt_assert((3, 10000) ~ ps); bt_assert((3,3) !~ ps); bt_assert((4,9) !~ ps); bt_assert((4,65535) !~ ps); bt_assert((6,2) !~ ps); bt_assert((6,6+one) !~ ps); bt_assert(((one+6),2) !~ ps); bt_assert((1,1) !~ ps); ps = [(20..150, 200..300), (50100..50200, 1000..50000), (*, 5+5)]; bt_assert((100,200) ~ ps); bt_assert((150,300) ~ ps); bt_assert((50180,1200) ~ ps); bt_assert((50110,49000) ~ ps); bt_assert((0,10) ~ ps); bt_assert((64000,10) ~ ps); bt_assert((20,199) !~ ps); bt_assert((151,250) !~ ps); bt_assert((50050,2000) !~ ps); bt_assert((50150,50050) !~ ps); bt_assert((10,9) !~ ps); bt_assert((65535,11) !~ ps); } bt_test_suite(t_pair_set, "Testing sets of pairs"); /* * Testing quads * ------------- */ function t_quad() quad qq; { qq = 1.2.3.4; bt_assert(format(qq) = "1.2.3.4"); bt_assert(qq = 1.2.3.4); bt_assert(qq != 4.3.2.1); } bt_test_suite(t_quad, "Testing quads"); /* * Testing sets of quads * --------------------- */ function t_quad_set() quad qq; { qq = 1.2.3.4; bt_assert(qq ~ [1.2.3.4, 5.6.7.8]); bt_assert(qq !~ [1.2.1.1, 1.2.3.5]); } bt_test_suite(t_quad_set, "Testing sets of quads"); /* * Testing ip address * ------------------ */ define onetwo = 1.2.3.4; function t_ip() ip p; { p = 127.1.2.3; bt_assert(p.is_v4); bt_assert(p.mask(8) = 127.0.0.0); bt_assert(1.2.3.4 = 1.2.3.4); bt_assert(1.2.3.4 = onetwo); bt_assert(format(p) = "127.1.2.3"); p = ::fffe:6:c0c:936d:88c7:35d3; bt_assert(!p.is_v4); bt_assert(format(p) = "::fffe:6:c0c:936d:88c7:35d3"); p = 1234:5678::; bt_assert(!p.is_v4); bt_assert(p.mask(24) = 1234:5600::); } bt_test_suite(t_ip, "Testing ip address"); /* * Testing sets of ip address * -------------------------- */ define ip1222 = 1.2.2.2; function t_ip_set() ip set ips; { ips = [ 1.1.1.0 .. 1.1.1.255, ip1222]; bt_assert(format(ips) = "[1.1.1.0..1.1.1.255, 1.2.2.2]"); bt_assert(1.1.1.0 ~ ips); bt_assert(1.1.1.100 ~ ips); bt_assert(1.2.2.2 ~ ips); bt_assert(1.1.0.255 !~ ips); bt_assert(1.1.2.0 !~ ips); bt_assert(1.2.2.3 !~ ips); bt_assert(192.168.1.1 !~ ips); bt_assert(1.2.3.4 !~ [ 1.2.3.3, 1.2.3.5 ]); bt_assert(1.2.3.4 ~ [ 1.2.3.3..1.2.3.5 ]); } bt_test_suite(t_ip_set, "Testing sets of ip address"); /* * Testing enums * ------------- */ function t_enum() { bt_assert(format(RTS_DUMMY) = "(enum 30)0"); bt_assert(format(RTS_STATIC) = "(enum 30)1"); bt_assert(format(NET_IP4) = "(enum 36)1"); bt_assert(format(NET_VPN6) = "(enum 36)4"); bt_assert(RTS_STATIC ~ [RTS_STATIC, RTS_DEVICE]); bt_assert(RTS_BGP !~ [RTS_STATIC, RTS_DEVICE]); } bt_test_suite(t_enum, "Testing enums"); /* * Testing prefixes * ---------------- */ define netdoc = 2001:db8::/32; function t_prefix() prefix px; { px = 1.2.0.0/18; bt_assert(format(px) = "1.2.0.0/18"); bt_assert(192.168.0.0/16 ~ 192.168.0.0/16); bt_assert(192.168.0.0/17 ~ 192.168.0.0/16); bt_assert(192.168.254.0/24 ~ 192.168.0.0/16); bt_assert(netdoc ~ 2001::/16); bt_assert(192.168.0.0/15 !~ 192.168.0.0/16); bt_assert(192.160.0.0/17 !~ 192.168.0.0/16); bt_assert(px !~ netdoc); bt_assert(1.2.3.4 ~ 1.0.0.0/8); bt_assert(1.0.0.0/8 ~ 1.0.0.0/8); } bt_test_suite(t_prefix, "Testing prefixes"); /* * Testing prefix sets * ------------------- */ define net10 = 10.0.0.0/8; define pxs2 = [ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]; function test_pxset(prefix set pxs) { bt_assert(net10 ~ pxs); bt_assert(10.0.0.0/10 ~ pxs); bt_assert(10.0.0.0/12 ~ pxs); bt_assert(20.0.0.0/24 ~ pxs); bt_assert(20.0.40.0/24 ~ pxs); bt_assert(20.0.0.0/26 ~ pxs); bt_assert(20.0.100.0/26 ~ pxs); bt_assert(20.0.0.0/28 ~ pxs); bt_assert(20.0.255.0/28 ~ pxs); bt_assert(10.0.0.0/7 !~ pxs); bt_assert(10.0.0.0/13 !~ pxs); bt_assert(10.0.0.0/16 !~ pxs); bt_assert(20.0.0.0/16 !~ pxs); bt_assert(20.0.0.0/23 !~ pxs); bt_assert(20.0.0.0/29 !~ pxs); bt_assert(11.0.0.0/10 !~ pxs); bt_assert(20.1.0.0/26 !~ pxs); bt_assert(1.0.0.0/8 ~ [ 1.0.0.0/8+ ]); bt_assert(1.0.0.0/9 !~ [ 1.0.0.0/8- ]); bt_assert(1.2.0.0/17 !~ [ 1.0.0.0/8{ 15 , 16 } ]); bt_assert([ 10.0.0.0/8{ 15 , 17 } ] = [ 10.0.0.0/8{ 15 , 17 } ]); } function t_prefix_set() prefix set pxs; { pxs = [ 1.2.0.0/16, 1.4.0.0/16+, 44.66.88.64/30{24,28}, 12.34.56.0/24{8,16} ]; bt_assert(format(pxs) = "[1.2.0.0/16{0.1.0.0}, 1.4.0.0/16{0.1.255.255}, 12.34.0.0/16{1.255.0.0}, 44.66.88.64/28{0.0.1.240}]"); bt_assert(1.2.0.0/16 ~ pxs); bt_assert(1.4.0.0/16 ~ pxs); bt_assert(1.4.0.0/18 ~ pxs); bt_assert(1.4.0.0/32 ~ pxs); bt_assert(1.1.0.0/16 !~ pxs); bt_assert(1.3.0.0/16 !~ pxs); bt_assert(1.2.0.0/15 !~ pxs); bt_assert(1.2.0.0/17 !~ pxs); bt_assert(1.2.0.0/32 !~ pxs); bt_assert(1.4.0.0/15 !~ pxs); test_pxset(pxs2); test_pxset([ 10.0.0.0/16{8,12}, 20.0.0.0/16{24,28} ]); bt_assert(1.2.0.0/16 ~ [ 1.0.0.0/8{ 15 , 17 } ]); bt_assert([ 10.0.0.0/8{ 15 , 17 } ] != [ 11.0.0.0/8{ 15 , 17 } ]); } bt_test_suite(t_prefix_set, "Testing prefix sets"); /* * Testing Prefix IPv6 * ------------------- */ function t_prefix6() prefix px; { px = 1020::/18; bt_assert(format(px) = "1020::/18"); bt_assert(1020:3040:5060:: ~ 1020:3040:5000::/40); bt_assert(1020:3040::/32 ~ 1020:3040::/32); bt_assert(1020:3040::/33 ~ 1020:3040::/32); bt_assert(1020:3040:5060::/48 ~ 1020:3040::/32); bt_assert(1020:3040::/31 !~ 1020:3040::/32); bt_assert(1020:3041::/33 !~ 1020:3040::/32); } bt_test_suite(t_prefix6, "Testing prefix IPv6"); /* * Testing prefix IPv6 sets * ------------------------ */ function t_prefix6_set() prefix set pxs; { bt_assert(1180::/16 ~ [ 1100::/8{15, 17} ]); bt_assert(12::34 = 12::34); bt_assert(12::34 ~ [ 12::33..12::35 ]); bt_assert(1020::34 ~ 1000::/8); bt_assert(1000::/8 ~ 1000::/8); bt_assert(1000::/8 ~ [ 1000::/8+ ]); bt_assert(12::34 !~ [ 12::33, 12::35 ]); bt_assert(1000::/9 !~ [ 1000::/8- ]); bt_assert(1000::/17 !~ [ 1000::/8{15, 16} ]); pxs = [ 1102::/16, 1104::/16+]; bt_assert(1102::/16 ~ pxs); bt_assert(1104::/16 ~ pxs); bt_assert(1104::/18 ~ pxs); bt_assert(1104::/32 ~ pxs); bt_assert(1101::/16 !~ pxs); bt_assert(1103::/16 !~ pxs); bt_assert(1102::/15 !~ pxs); bt_assert(1102::/17 !~ pxs); bt_assert(1102::/32 !~ pxs); bt_assert(1104::/15 !~ pxs); pxs = ([ 1000::/16{8,12}, 2000::/16{24,28} ]); bt_assert(format(pxs) = "[1000::/12{1f0::}, 2000::/16{0:1f0::}]"); bt_assert(1000::/8 ~ pxs); bt_assert(1000::/10 ~ pxs); bt_assert(1000::/12 ~ pxs); bt_assert(2000::/24 ~ pxs); bt_assert(2000:4000::/24 ~ pxs); bt_assert(2000::/26 ~ pxs); bt_assert(2000:8000::/26 ~ pxs); bt_assert(2000::/28 ~ pxs); bt_assert(2000:FFF0::/28 ~ pxs); bt_assert(1000::/7 !~ pxs); bt_assert(1000::/13 !~ pxs); bt_assert(1000::/16 !~ pxs); bt_assert(2000::/16 !~ pxs); bt_assert(2000::/23 !~ pxs); bt_assert(2000::/29 !~ pxs); bt_assert(1100::/10 !~ pxs); bt_assert(2010::/26 !~ pxs); } bt_test_suite(t_prefix6_set, "Testing prefix IPv6 sets"); function t_flowspec() prefix p; { p = flow4 { dst 10.0.0.0/8; }; bt_assert(p !~ [ 10.0.0.0/8 ] ); bt_assert(format(flow4 { dst 10.0.0.0/8; proto = 23; }) = "flow4 { dst 10.0.0.0/8; proto 23; }"); bt_assert(format(flow6 { dst ::1/128; src ::2/127; }) = "flow6 { dst ::1/128; src ::2/127; }"); bt_assert(format(flow6 { next header false 42; }) = "flow6 { next header false 42; }"); bt_assert(format(flow6 { port 80; }) = "flow6 { port 80; }"); bt_assert(format(flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }) = "flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }"); bt_assert(format(flow6 { sport 0..0x400; }) = "flow6 { sport 0..1024; }"); bt_assert(format(flow6 { icmp type 80; }) = "flow6 { icmp type 80; }"); bt_assert(format(flow6 { icmp code 90; }) = "flow6 { icmp code 90; }"); bt_assert(format(flow6 { tcp flags 0x03/0x0f; }) = "flow6 { tcp flags 0x3/0x3,0x0/0xc; }"); bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }"); bt_assert(format(flow6 { dscp = 63; }) = "flow6 { dscp 63; }"); bt_assert(format(flow6 { fragment is_fragment || !first_fragment; }) = "flow6 { fragment is_fragment || !first_fragment; }"); bt_assert(format(flow6 { }) = "flow6 { }"); } bt_test_suite(t_flowspec, "Testing flowspec routes"); /* * Testing Paths * ------------- */ function mkpath(int a; int b) { return [= a b 3 2 1 =]; } define set35 = [3 .. 5]; function t_path() bgpmask pm1; bgppath p2; int set set12; { pm1 = [= 4 3 2 1 =]; set12 = [1, 2]; bt_assert(format(pm1) = "[= 4 3 2 1 =]"); bt_assert(+empty+ = +empty+); bt_assert(10 !~ +empty+); p2 = prepend( + empty +, 1 ); p2 = prepend( p2, 2 ); p2 = prepend( p2, 3 ); p2 = prepend( p2, 4 ); bt_assert(format(p2) = "(path 4 3 2 1)"); bt_assert(p2.len = 4); bt_assert(p2 ~ pm1); bt_assert(3 ~ p2); bt_assert(p2 ~ [2, 10..20]); bt_assert(p2 ~ [4, 10..20]); p2 = prepend(p2, 5); bt_assert(p2 !~ pm1); bt_assert(10 !~ p2); bt_assert(p2 !~ [8, ten..(2*ten)]); bt_assert(p2 ~ [= * 4 3 * 1 =]); bt_assert(p2 ~ [= (3+2) (2*2) 3 2 1 =]); bt_assert(p2 ~ [= 5 [2, 4, 6] 3 [1..2] 1 =]); bt_assert(p2 ~ [= 5 set35 3 set12 set12 =]); bt_assert(p2 ~ mkpath(5, 4)); bt_assert(p2.len = 5); bt_assert(p2.first = 5); bt_assert(p2.last = 1); bt_assert(p2.len = 5); bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 1), 2), 4), 5)); bt_assert(filter(p2, [1..3]) = prepend(prepend(prepend(+empty+, 1), 2), 3)); p2 = prepend( + empty +, 5 ); p2 = prepend( p2, 4 ); p2 = prepend( p2, 3 ); p2 = prepend( p2, 3 ); p2 = prepend( p2, 2 ); p2 = prepend( p2, 1 ); bt_assert(p2 !~ [= 1 2 3 4 5 =]); bt_assert(p2 ~ [= 1 2 * 4 5 =]); bt_assert(p2 ~ [= 1 2 * 3 4 5 =]); bt_assert(p2 ~ [= 1 2 3+ 4 5 =]); bt_assert(p2 ~ [= 1 2 3+ 4+ 5 =]); bt_assert(p2 !~ [= 1 2 3+ 5+ 4 5 =]); bt_assert(p2 !~ [= 1 2 3 3 5+ 4 5 =]); bt_assert(delete(p2, 3) = prepend(prepend(prepend(prepend(+empty+, 5), 4), 2), 1)); bt_assert(delete(p2, [4..5]) = prepend(prepend(prepend(prepend(+empty+, 3), 3), 2), 1)); bt_assert(format([= 1 2+ 3 =]) = "[= 1 2 + 3 =]"); } bt_test_suite(t_path, "Testing paths"); /* * Testing Community List * ---------------------- */ define p23 = (2, 3); function t_clist() clist l; clist l2; clist r; { l = - empty -; bt_assert(l !~ [(*,*)]); bt_assert((l ~ [(*,*)]) != (l !~ [(*,*)])); bt_assert(-empty- = -empty-); l = add( l, (one,2) ); bt_assert(l ~ [(*,*)]); l = add( l, (2,one+2) ); bt_assert(format(l) = "(clist (1,2) (2,3))"); bt_assert((2,3) ~ l); bt_assert(l ~ [(1,*)]); bt_assert(l ~ [p23]); bt_assert(l ~ [(2,2..3)]); bt_assert(l ~ [(1,1..2)]); bt_assert(l ~ [(1,1)..(1,2)]); l = add(l, (2,5)); l = add(l, (5,one)); l = add(l, (6,one)); l = add(l, (one,one)); l = delete(l, [(5,1),(6,one),(one,1)]); l = delete(l, [(5,one),(6,one)]); l = filter(l, [(1,*)]); bt_assert(l = add(-empty-, (1,2))); bt_assert((2,3) !~ l); bt_assert(l !~ [(2,*)]); bt_assert(l !~ [(one,3..6)]); bt_assert(l ~ [(*,*)]); l = add(l, (3,one)); l = add(l, (one+one+one,one+one)); l = add(l, (3,3)); l = add(l, (3,4)); l = add(l, (3,5)); l2 = filter(l, [(3,*)]); l = delete(l, [(3,2..4)]); bt_assert(l = add(add(add(-empty-, (1,2)), (3,1)), (3,5))); bt_assert(l.len = 3); l = add(l, (3,2)); l = add(l, (4,5)); bt_assert(l = add(add(add(add(add(-empty-, (1,2)), (3,1)), (3,5)), (3,2)), (4,5))); bt_assert(l.len = 5); bt_assert(l ~ [(*,2)]); bt_assert(l ~ [(*,5)]); bt_assert(l ~ [(*, one)]); bt_assert(l !~ [(*,3)]); bt_assert(l !~ [(*,(one+6))]); bt_assert(l !~ [(*, (one+one+one))]); l = delete(l, [(*,(one+onef(3)))]); l = delete(l, [(*,(4+one))]); bt_assert(l = add(-empty-, (3,1))); l = delete(l, [(*,(onef(5)))]); bt_assert(l = -empty-); l2 = add(l2, (3,6)); l = filter(l2, [(3,1..4)]); l2 = filter(l2, [(3,3..6)]); # clist A (10,20,30) bt_assert(l = add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4))); bt_assert(format(l) = "(clist (3,1) (3,2) (3,3) (3,4))"); # clist B (30,40,50) bt_assert(l2 = add(add(add(add(-empty-, (3,3)), (3,4)), (3,5)), (3,6))); bt_assert(format(l2) = "(clist (3,3) (3,4) (3,5) (3,6))"); # clist A union B r = add(l, l2); bt_assert(r = add(add(add(add(add(add(-empty-, (3,1)), (3,2)), (3,3)), (3,4)), (3,5)), (3,6))); bt_assert(format(r) = "(clist (3,1) (3,2) (3,3) (3,4) (3,5) (3,6))"); # clist A isect B r = filter(l, l2); bt_assert(r = add(add(-empty-, (3,3)), (3,4))); bt_assert(format(r) = "(clist (3,3) (3,4))"); # clist A \ B r = delete(l, l2); bt_assert(r = add(add(-empty-, (3,1)), (3,2))); bt_assert(format(r) = "(clist (3,1) (3,2))"); # clist in c set r = filter(l, [(3,1), (*,2)]); bt_assert(r = add(add(-empty-, (3,1)), (3,2))); bt_assert(format(r) = "(clist (3,1) (3,2))"); } bt_test_suite(t_clist, "Testing lists of communities"); /* * Testing Extended Communities * ---------------------------- */ function t_ec() ec cc; { cc = (rt, 12345, 200000); bt_assert(format(cc) = "(rt, 12345, 200000)"); bt_assert(cc = (rt, 12345, 200000)); bt_assert(cc < (rt, 12345, 200010)); bt_assert(cc != (rt, 12346, 200000)); bt_assert(cc != (ro, 12345, 200000)); bt_assert(!(cc > (rt, 12345, 200010))); bt_assert(format((ro, 100000, 20000)) = "(ro, 100000, 20000)"); } bt_test_suite(t_ec, "Testing extended communities"); /* * Testing Extended Community List * ------------------------------- */ function t_eclist() eclist el; eclist el2; eclist r; { el = -- empty --; el = add(el, (rt, 10, 20)); el = add(el, (ro, 10.20.30.40, 100)); el = add(el, (ro, 11.21.31.41.mask(16), 200)); bt_assert(--empty-- = --empty--); bt_assert(((rt, 10, 20)) !~ --empty--); bt_assert(format(el) = "(eclist (rt, 10, 20) (ro, 10.20.30.40, 100) (ro, 11.21.0.0, 200))"); bt_assert(el.len = 3); el = delete(el, (rt, 10, 20)); el = delete(el, (rt, 10, 30)); bt_assert(el = add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200))); el = add(el, (unknown 2, ten, 1)); el = add(el, (unknown 5, ten, 1)); el = add(el, (rt, ten, one+one)); el = add(el, (rt, 10, 3)); el = add(el, (rt, 10, 4)); el = add(el, (rt, 10, 5)); el = add(el, (generic, 0x2000a, 3*ten)); el = delete(el, [(rt, 10, 2..ten)]); bt_assert(el = add(add(add(add(add(--empty--, (ro, 10.20.30.40, 100)), (ro, 11.21.0.0, 200)), (rt, 10, 1)), (unknown 5, 10, 1)), (rt, 10, 30))); el = filter(el, [(rt, 10, *)]); bt_assert(el = add(add(--empty--, (rt, 10, 1)), (rt, 10, 30))); bt_assert((rt, 10, 1) ~ el); bt_assert(el ~ [(rt, 10, ten..40)]); bt_assert((rt, 10, 20) !~ el); bt_assert((ro, 10.20.30.40, 100) !~ el); bt_assert(el !~ [(rt, 10, 35..40)]); bt_assert(el !~ [(ro, 10, *)]); el = add(el, (rt, 10, 40)); el2 = filter(el, [(rt, 10, 20..40)] ); el2 = add(el2, (rt, 10, 50)); # eclist A (1,30,40) bt_assert(el = add(add(add(--empty--, (rt, 10, 1)), (rt, 10, 30)), (rt, 10, 40))); bt_assert(format(el) = "(eclist (rt, 10, 1) (rt, 10, 30) (rt, 10, 40))"); # eclist B (30,40,50) bt_assert(el2 = add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50))); bt_assert(format(el2) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50))"); # eclist A union B r = add(el2, el); bt_assert(r = add(add(add(add(--empty--, (rt, 10, 30)), (rt, 10, 40)), (rt, 10, 50)), (rt, 10, 1))); bt_assert(format(r) = "(eclist (rt, 10, 30) (rt, 10, 40) (rt, 10, 50) (rt, 10, 1))"); # eclist A isect B r = filter(el, el2); bt_assert(r = add(add(--empty--, (rt, 10, 30)), (rt, 10, 40))); bt_assert(format(r) = "(eclist (rt, 10, 30) (rt, 10, 40))"); # eclist A \ B r = delete(el, el2); bt_assert(r = add(--empty--, (rt, 10, 1))); bt_assert(format(r) = "(eclist (rt, 10, 1))"); # eclist in ec set r = filter(el, [(rt, 10, 1), (rt, 10, 25..30), (ro, 10, 40)]); bt_assert(r = add(add(--empty--, (rt, 10, 1)), (rt, 10, 30))); bt_assert(format(r) = "(eclist (rt, 10, 1) (rt, 10, 30))"); } bt_test_suite(t_eclist, "Testing lists of extended communities"); /* * Testing sets of Extended Communities * ------------------------------------ */ define ecs2 = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)]; function t_ec_set() ec set ecs; { ecs = [(rt, ten, (one+onef(0))*10), (ro, 100000, 100..200), (rt, 12345, *)]; bt_assert(format(ecs) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]"); bt_assert(format(ecs2) = "[(rt, 10, 20), (rt, 12345, 0)..(rt, 12345, 4294967295), (ro, 100000, 100)..(ro, 100000, 200)]"); bt_assert((rt, 10, 20) ~ ecs); bt_assert((ro, 100000, 100) ~ ecs); bt_assert((ro, 100000, 128) ~ ecs); bt_assert((ro, 100000, 200) ~ ecs); bt_assert((rt, 12345, 0) ~ ecs); bt_assert((rt, 12345, 200000) ~ ecs); bt_assert((rt, 12345, 4000000) ~ ecs); bt_assert((ro, 10, 20) !~ ecs); bt_assert((rt, 10, 21) !~ ecs); bt_assert((ro, 100000, 99) !~ ecs); bt_assert((ro, 12345, 10) !~ ecs); bt_assert((rt, 12346, 0) !~ ecs); bt_assert((ro, 0.1.134.160, 150) !~ ecs); } bt_test_suite(t_ec_set, "Testing sets of extended communities"); /* * Testing Large Communities * ------------------------- */ function mktrip(int a) { return (a, 2*a, 3*a); } function t_lclist() lclist ll; lclist ll2; lclist r; { bt_assert(---empty--- = ---empty---); bt_assert((10, 20, 30) !~ ---empty---); ll = --- empty ---; ll = add(ll, (ten, 20, 30)); ll = add(ll, (1000, 2000, 3000)); ll = add(ll, mktrip(100000)); bt_assert(format(ll) = "(lclist (10, 20, 30) (1000, 2000, 3000) (100000, 200000, 300000))"); bt_assert(ll.len = 3); bt_assert(ll = add(add(add(---empty---, (10, 20, 30)), (1000, 2000, 3000)), (100000, 200000, 300000))); bt_assert(mktrip(1000) ~ ll); bt_assert(mktrip(100) !~ ll); ll = --- empty ---; ll = add(ll, (10, 10, 10)); ll = add(ll, (20, 20, 20)); ll = add(ll, (30, 30, 30)); ll2 = --- empty ---; ll2 = add(ll2, (20, 20, 20)); ll2 = add(ll2, (30, 30, 30)); ll2 = add(ll2, (40, 40, 40)); # lclist A (10, 20, 30) bt_assert(format(ll) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30))"); # lclist B (20, 30, 40) bt_assert(format(ll2) = "(lclist (20, 20, 20) (30, 30, 30) (40, 40, 40))"); # lclist A union B r = add(ll, ll2); bt_assert(r = add(add(add(add(---empty---, (10,10,10)), (20,20,20)), (30,30,30)), (40,40,40))); bt_assert(format(r) = "(lclist (10, 10, 10) (20, 20, 20) (30, 30, 30) (40, 40, 40))"); # lclist A isect B r = filter(ll, ll2); bt_assert(r = add(add(---empty---, (20, 20, 20)), (30, 30, 30))); bt_assert(format(r) = "(lclist (20, 20, 20) (30, 30, 30))"); # lclist A \ B r = delete(ll, ll2); bt_assert(r = add(---empty---, (10, 10, 10))); bt_assert(format(r) = "(lclist (10, 10, 10))"); # lclist in lc set r = filter(ll, [(5..15, *, *), (20, 15..25, *)]); bt_assert(r = add(add(---empty---, (10, 10, 10)), (20, 20, 20))); bt_assert(format(r) = "(lclist (10, 10, 10) (20, 20, 20))"); } bt_test_suite(t_lclist, "Testing lists of large communities"); /* * Testing sets of Large Communities * --------------------------------- */ function t_lclist_set() lclist ll; lc set lls; { ll = --- empty ---; ll = add(ll, (10, 20, 30)); ll = add(ll, (1000, 2000, 3000)); ll = add(ll, mktrip(100000)); bt_assert(ll ~ [(5,10,15), (10,20,30)]); bt_assert(ll ~ [(10,15..25,*)]); bt_assert(ll ~ [(ten, *, *)]); bt_assert(ll !~ [(5,10,15), (10,21,30)]); bt_assert(ll !~ [(10,21..25,*)]); bt_assert(ll !~ [(11, *, *)]); lls = [(10, 10, 10), (20, 20, 15..25), (30, 30, *), (40, 35..45, *), (50, *, *), (55..65, *, *)]; bt_assert(format(lls) = "[(10, 10, 10), (20, 20, 15)..(20, 20, 25), (30, 30, 0)..(30, 30, 4294967295), (40, 35, 0)..(40, 45, 4294967295), (50, 0, 0)..(50, 4294967295, 4294967295), (55, 0, 0)..(65, 4294967295, 4294967295)]"); bt_assert((10, 10, 10) ~ lls); bt_assert((20, 20, 25) ~ lls); bt_assert((20, 20, 26) !~ lls); bt_assert((30, 30, 0) ~ lls); bt_assert((40, 35, 40) ~ lls); bt_assert((40, 34, 40) !~ lls); bt_assert((50, 0, 0) ~ lls); bt_assert((60, 60, 60) ~ lls); bt_assert((70, 60, 60) !~ lls); } bt_test_suite(t_lclist_set, "Testing sets of large communities"); /* * Testing Route Distinguishers * ---------------------------- */ function t_rd() rd x; { x = 12345:20000; bt_assert(format(x) = "12345:20000"); bt_assert(x = 12345:20000); bt_assert(x < 12345:20010); bt_assert(x != 12346:20000); bt_assert(x != 2:12345:20000); bt_assert(!(x > 12345:200010)); bt_assert(format(0:1:2) = "1:2"); bt_assert(format(10.0.0.1:1000) = "10.0.0.1:1000"); bt_assert(format(100000:20000) = "100000:20000"); bt_assert(format(2:100000:20000) = "100000:20000"); bt_assert(format(2:1000:1000) = "2:1000:1000"); } bt_test_suite(t_rd, "Testing route distinguishers"); /* * Testing sets of Route Distinguishers * ------------------------------------ */ function t_rd_set() rd set rds; { rds = [10:20, 100000:100..100000:200]; bt_assert(format(rds) = "[10:20, 100000:100..100000:200]"); bt_assert(10:20 ~ rds); bt_assert(10:21 !~ rds); bt_assert(100000:90 !~ rds); bt_assert(100000:100 ~ rds); bt_assert(100000:128 ~ rds); bt_assert(100000:200 ~ rds); bt_assert(100010:150 !~ rds); } bt_test_suite(t_rd_set, "Testing sets of route distinguishers"); /* * Testing defined() function * -------------------------- */ function test_undef(int a) int b; { if a = 3 then { b = 4; bt_assert(defined(b)); } else { bt_assert(!defined(b)); } } function t_define() int i; { test_undef(2); test_undef(3); test_undef(2); bt_assert(defined(1)); bt_assert(defined(1.2.3.4)); } bt_test_suite(t_define, "Testing defined() function"); /* * Testing calling functions * ------------------------- */ function callme(int arg1; int arg2) int i; { case arg1 { 1, 42: return 42; else: return arg1 * arg2; } return 0; } function callmeagain(int a; int b; int c) { return a + b + c; } function fifteen() { return 15; } function t_call_function() { bt_assert(fifteen() = 15); bt_assert(callme(1, 2) = 42); bt_assert(callme(42, 2) = 42); bt_assert(callme(2, 2) = 4); bt_assert(callme(3, 2) = 6); bt_assert(callme(4, 4) = 16); bt_assert(callme(7, 2) = 14); bt_assert(callmeagain(1, 2, 3) = 6); } bt_test_suite(t_call_function, "Testing calling functions"); /* * Test including another config file * ---------------------------------- */ function t_include() int i; { i = 1; include "test.conf.inc"; bt_assert(i = 42); } bt_test_suite(t_include, "Testing including another config file"); /* * Test if-else statement * ---------------------- */ function t_if_else() int i; { /* Empty blocks regression test */ if true then {} else {} if true then bt_assert(true); if false then bt_assert(false); else if true then bt_assert(true); else bt_assert(false); /* Empty blocks regression test */ if true then {} else {} } bt_test_suite(t_if_else, "Testing if-else statement"); /* * Unused functions -- testing only parsing * ---------------------------------------- */ function __test1() { if source ~ [ RTS_BGP, RTS_STATIC ] then { # ospf_metric1 = 65535; # ospf_metric2 = 1000; ospf_tag = 0x12345678; accept; } reject; } function __test2() { if source ~ [ RTS_BGP, RTS_STATIC ] then { # ospf_metric1 = 65535; # ospf_metric2 = 1000; ospf_tag = 0x12345678; accept; } reject; } filter testf int j; { print "Heya, filtering route to ", net.ip, " prefixlen ", net.len, " source ", source; print "This route was from ", from; j = 7; j = 17; if rip_metric > 15 then { reject "RIP Metric is more than infinity"; } rip_metric = 14; unset(rip_metric); accept "ok I take that"; } filter roa_filter { if net ~ [ 10.0.0.0/8{16,24} ] || net ~ [ 2000::/3{16,96} ] then { accept; } reject; } roa4 table r4; roa6 table r6; protocol static { roa4 { table r4; import filter roa_filter; }; route 10.110.0.0/16 max 16 as 1000; route 10.120.0.0/16 max 24 as 1000; route 10.130.0.0/16 max 24 as 2000; route 10.130.128.0/18 max 24 as 3000; } protocol static { roa6 { table r6; import filter roa_filter; }; route 2001:0db8:85a3:8a2e::/64 max 96 as 1000; } function t_roa_check() prefix pfx; { bt_assert(roa_check(r4, 10.10.0.0/16, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 10.0.0.0/8, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 10.110.0.0/16, 1000) = ROA_VALID); bt_assert(roa_check(r4, 10.110.0.0/16, 2000) = ROA_INVALID); bt_assert(roa_check(r4, 10.110.32.0/20, 1000) = ROA_INVALID); bt_assert(roa_check(r4, 10.120.32.0/20, 1000) = ROA_VALID); bt_assert(roa_check(r4, 10.120.32.0/20, 2000) = ROA_INVALID); bt_assert(roa_check(r4, 10.120.32.32/28, 1000) = ROA_INVALID); bt_assert(roa_check(r4, 10.130.130.0/24, 1000) = ROA_INVALID); bt_assert(roa_check(r4, 10.130.130.0/24, 2000) = ROA_VALID); bt_assert(roa_check(r4, 10.130.30.0/24, 3000) = ROA_INVALID); bt_assert(roa_check(r4, 10.130.130.0/24, 3000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e::/64, 1000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 10.10.0.0/16, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 10.0.0.0/8, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 10.110.0.0/16, 1000) = ROA_VALID); bt_assert(roa_check(r4, 10.110.0.0/16, 2000) = ROA_INVALID); bt_assert(roa_check(r4, 10.110.32.0/20, 1000) = ROA_INVALID); bt_assert(roa_check(r4, 10.120.32.0/20, 1000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e::/64, 1000) = ROA_VALID); bt_assert(roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r4, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/97, 1000) = ROA_INVALID); bt_assert(roa_check(r4, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r6, 2001:0db8:85a3:8a2e:1234::/80, 1000) = ROA_VALID); bt_assert(roa_check(r4, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN); bt_assert(roa_check(r6, 2001:0db8:85a3::/48, 1000) = ROA_UNKNOWN); bt_assert(10.130.130.0/24 ~ 0.0.0.0/0); bt_assert(2001:0db8:85a3:8a2e::/64 ~ ::/0); bt_assert(10.130.130.0/24 !~ ::/0); bt_assert(2001:0db8:85a3:8a2e::/64 !~ 0.0.0.0/0); pfx = 12.13.0.0/16 max 24 as 1234; bt_assert(pfx.len = 16); bt_assert(pfx.maxlen = 24); bt_assert(pfx.asn = 1234); pfx = 1000::/8 max 32 as 1234; bt_assert(pfx.len = 8); bt_assert(pfx.maxlen = 32); bt_assert(pfx.asn = 1234); } bt_test_suite(t_roa_check, "Testing ROA"); filter vpn_filter { bt_assert(format(net) = "1:2 10.1.10.0/24"); bt_assert(net.type = NET_VPN4); bt_assert(net.type != NET_IP4); bt_assert(net.type != NET_IP6); bt_assert(net.rd = 0:1:2); case (net.type) { NET_IP4: print "IPV4"; NET_IP6: print "IPV6"; } bt_check_assign(from, 10.20.30.40); bt_check_assign(gw, 55.55.55.44); bgp_community.add((3,5)); bgp_ext_community.add((ro, 135, 999)); bgp_large_community.add((6464156, 89646354, 8675643)); accept; } vpn4 table v4; vpn4 table v6; protocol static { vpn4 { table v4; import filter vpn_filter; }; route 0:1:2 10.1.10.0/24 unreachable; } protocol static { ipv6 { import where false; }; route fd01::/48 unreachable; } bird-2.0.8/filter/test-reconf-end.conf0000664000175000017500000000041414025744326016514 0ustar feelafeelarouter id 1.1.1.1; protocol device {} function a() { return false; } function b() { return a(); } function c() { return b(); } filter d { if c() then accept; else reject; } protocol static { ipv4 { import filter d; }; route 10.0.0.0/24 unreachable; } bird-2.0.8/filter/test-reconf-begin.conf0000664000175000017500000000041314025744326017031 0ustar feelafeelarouter id 1.1.1.1; protocol device {} function a() { return true; } function b() { return a(); } function c() { return b(); } filter d { if c() then accept; else reject; } protocol static { ipv4 { import filter d; }; route 10.0.0.0/24 unreachable; } bird-2.0.8/filter/filter_test.c0000664000175000017500000000345014025744326015343 0ustar feelafeela/* * Filters: Tests * * (c) 2015 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include "test/birdtest.h" #include "test/bt-utils.h" #include "filter/filter.h" #include "filter/data.h" #include "filter/f-inst.h" #include "conf/conf.h" #define BT_CONFIG_FILE "filter/test.conf" static int t_reconfig(void) { if (!bt_config_file_parse(BT_CONFIG_FILE)) return 0; struct symbol *s; WALK_LIST(s, config->symbols) if ((s->class == SYM_FUNCTION) || (s->class == SYM_FILTER)) bt_assert_msg((s->flags & SYM_FLAG_SAME), "Symbol %s same check", s->name); return 1; } static int run_function(const void *arg) { const struct f_bt_test_suite *t = arg; if (t->cmp) return t->result == f_same(t->fn, t->cmp); linpool *tmp = lp_new_default(&root_pool); enum filter_return fret = f_eval(t->fn, tmp, NULL); rfree(tmp); return (fret < F_REJECT); } static void bt_assert_filter(int result, const struct f_line_item *assert) { int bt_suit_case_result = 1; if (!result) { bt_result = 0; bt_suite_result = 0; bt_suit_case_result = 0; } bt_log_suite_case_result(bt_suit_case_result, "Assertion at line %d (%s)", assert->lineno, assert->i_FI_ASSERT.s); } int main(int argc, char *argv[]) { bt_init(argc, argv); bt_bird_init(); bt_assert_hook = bt_assert_filter; /* Initial test.conf parsing, must be done here */ if (!bt_config_file_parse(BT_CONFIG_FILE)) abort(); bt_test_suite(t_reconfig, "Testing reconfiguration"); struct f_bt_test_suite *t; WALK_LIST(t, config->tests) bt_test_suite_base(run_function, t->fn_name, t, BT_FORKING, BT_TIMEOUT, "%s", t->dsc); bt_bird_cleanup(); return bt_exit_value(); } bird-2.0.8/filter/filter.h0000664000175000017500000000404014025744326014305 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Filters * * (c) 1999 Pavel Machek * (c) 2018--2019 Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_FILT_H_ #define _BIRD_FILT_H_ #include "lib/resource.h" #include "lib/ip.h" #include "lib/macro.h" #include "nest/route.h" #include "nest/attrs.h" /* Possible return values of filter execution */ enum filter_return { F_NOP = 0, F_NONL, F_RETURN, F_ACCEPT, /* Need to preserve ordering: accepts < rejects! */ F_REJECT, F_ERROR, }; static inline const char *filter_return_str(const enum filter_return fret) { switch (fret) { #define FRS(x) case x: return #x FRS(F_NOP); FRS(F_NONL); FRS(F_RETURN); FRS(F_ACCEPT); FRS(F_REJECT); FRS(F_ERROR); #undef FRS default: bug("This shall not happen"); } } struct f_val; /* The filter encapsulating structure to be pointed-to from outside */ struct f_line; struct filter { struct symbol *sym; const struct f_line *root; }; struct rte; enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags); enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool); uint f_eval_int(const struct f_line *expr); enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf); const char *filter_name(const struct filter *filter); int filter_same(const struct filter *new, const struct filter *old); int f_same(const struct f_line *f1, const struct f_line *f2); void filter_commit(struct config *new, struct config *old); void filters_dump_all(void); #define FILTER_ACCEPT NULL #define FILTER_REJECT ((struct filter *) 1) #define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */ #define FF_SILENT 2 /* Silent filter execution */ /* Custom route attributes */ struct custom_attribute { resource r; struct f_dynamic_attr *fda; const char *name; }; struct custom_attribute *ca_lookup(pool *p, const char *name, int ea_type); #endif bird-2.0.8/filter/filter.c0000664000175000017500000003352614025744326014313 0ustar feelafeela/* * Filters: utility functions * * Copyright 1998 Pavel Machek * * Can be freely distributed and used under the terms of the GNU GPL. * */ /** * DOC: Filters * * You can find sources of the filter language in |filter/| * directory. File |filter/config.Y| contains filter grammar and basically translates * the source from user into a tree of &f_inst structures. These trees are * later interpreted using code in |filter/filter.c|. * * A filter is represented by a tree of &f_inst structures, later translated * into lists called &f_line. All the instructions are defined and documented * in |filter/f-inst.c| definition file. * * Filters use a &f_val structure for their data. Each &f_val * contains type and value (types are constants prefixed with %T_). * Look into |filter/data.h| for more information and appropriate calls. */ #undef LOCAL_DEBUG #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/string.h" #include "lib/unaligned.h" #include "lib/ip.h" #include "lib/net.h" #include "lib/flowspec.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "nest/attrs.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/f-inst.h" #include "filter/data.h" /* Exception bits */ enum f_exception { FE_RETURN = 0x1, }; struct filter_stack { /* Value stack for execution */ #define F_VAL_STACK_MAX 4096 uint vcnt; /* Current value stack size; 0 for empty */ uint ecnt; /* Current execute stack size; 0 for empty */ struct f_val vstk[F_VAL_STACK_MAX]; /* The stack itself */ /* Instruction stack for execution */ #define F_EXEC_STACK_MAX 4096 struct { const struct f_line *line; /* The line that is being executed */ uint pos; /* Instruction index in the line */ uint ventry; /* Value stack depth on entry */ uint vbase; /* Where to index variable positions from */ enum f_exception emask; /* Exception mask */ } estk[F_EXEC_STACK_MAX]; }; /* Internal filter state, to be allocated on stack when executing filters */ struct filter_state { /* Stacks needed for execution */ struct filter_stack *stack; /* The route we are processing. This may be NULL to indicate no route available. */ struct rte **rte; /* The old rta to be freed after filters are done. */ struct rta *old_rta; /* Cached pointer to ea_list */ struct ea_list **eattrs; /* Linpool for adata allocation */ struct linpool *pool; /* Buffer for log output */ struct buffer buf; /* Filter execution flags */ int flags; }; _Thread_local static struct filter_state filter_state; _Thread_local static struct filter_stack filter_stack; void (*bt_assert_hook)(int result, const struct f_line_item *assert); static inline void f_cache_eattrs(struct filter_state *fs) { fs->eattrs = &((*fs->rte)->attrs->eattrs); } static inline void f_rte_cow(struct filter_state *fs) { if (!((*fs->rte)->flags & REF_COW)) return; *fs->rte = rte_cow(*fs->rte); } /* * rta_cow - prepare rta for modification by filter */ static void f_rta_cow(struct filter_state *fs) { if (!rta_is_cached((*fs->rte)->attrs)) return; /* Prepare to modify rte */ f_rte_cow(fs); /* Store old rta to free it later, it stores reference from rte_cow() */ fs->old_rta = (*fs->rte)->attrs; /* * Get shallow copy of rta. Fields eattrs and nexthops of rta are shared * with fs->old_rta (they will be copied when the cached rta will be obtained * at the end of f_run()), also the lock of hostentry is inherited (we * suppose hostentry is not changed by filters). */ (*fs->rte)->attrs = rta_do_cow((*fs->rte)->attrs, fs->pool); /* Re-cache the ea_list */ f_cache_eattrs(fs); } static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS; /** * interpret * @fs: filter state * @what: filter to interpret * * Interpret given tree of filter instructions. This is core function * of filter system and does all the hard work. * * Each instruction has 4 fields: code (which is instruction code), * aux (which is extension to instruction code, typically type), * arg1 and arg2 - arguments. Depending on instruction, arguments * are either integers, or pointers to instruction trees. Common * instructions like +, that have two expressions as arguments use * TWOARGS macro to get both of them evaluated. */ static enum filter_return interpret(struct filter_state *fs, const struct f_line *line, struct f_val *val) { /* No arguments allowed */ ASSERT(line->args == 0); /* Initialize the filter stack */ struct filter_stack *fstk = fs->stack; fstk->vcnt = line->vars; memset(fstk->vstk, 0, sizeof(struct f_val) * line->vars); /* The same as with the value stack. Not resetting the stack for performance reasons. */ fstk->ecnt = 1; fstk->estk[0].line = line; fstk->estk[0].pos = 0; #define curline fstk->estk[fstk->ecnt-1] #ifdef LOCAL_DEBUG debug("Interpreting line."); f_dump_line(line, 1); #endif while (fstk->ecnt > 0) { while (curline.pos < curline.line->len) { const struct f_line_item *what = &(curline.line->items[curline.pos++]); switch (what->fi_code) { #define res fstk->vstk[fstk->vcnt] #define vv(i) fstk->vstk[fstk->vcnt + (i)] #define v1 vv(0) #define v2 vv(1) #define v3 vv(2) #define runtime(fmt, ...) do { \ if (!(fs->flags & FF_SILENT)) \ log_rl(&rl_runtime_err, L_ERR "filters, line %d: " fmt, what->lineno, ##__VA_ARGS__); \ return F_ERROR; \ } while(0) #define falloc(size) lp_alloc(fs->pool, size) #define fpool fs->pool #define ACCESS_EATTRS do { if (!fs->eattrs) f_cache_eattrs(fs); } while (0) #include "filter/inst-interpret.c" #undef res #undef v1 #undef v2 #undef v3 #undef runtime #undef falloc #undef fpool #undef ACCESS_EATTRS } } /* End of current line. Drop local variables before exiting. */ fstk->vcnt -= curline.line->vars; fstk->vcnt -= curline.line->args; fstk->ecnt--; } if (fstk->vcnt == 0) { if (val) { log_rl(&rl_runtime_err, L_ERR "filters: No value left on stack"); return F_ERROR; } return F_NOP; } if (val && (fstk->vcnt == 1)) { *val = fstk->vstk[0]; return F_NOP; } log_rl(&rl_runtime_err, L_ERR "Too many items left on stack: %u", fstk->vcnt); return F_ERROR; } /** * f_run - run a filter for a route * @filter: filter to run * @rte: route being filtered, may be modified * @tmp_pool: all filter allocations go from this pool * @flags: flags * * If filter needs to modify the route, there are several * posibilities. @rte might be read-only (with REF_COW flag), in that * case rw copy is obtained by rte_cow() and @rte is replaced. If * @rte is originally rw, it may be directly modified (and it is never * copied). * * The returned rte may reuse the (possibly cached, cloned) rta, or * (if rta was modified) contains a modified uncached rta, which * uses parts allocated from @tmp_pool and parts shared from original * rta. There is one exception - if @rte is rw but contains a cached * rta and that is modified, rta in returned rte is also cached. * * Ownership of cached rtas is consistent with rte, i.e. * if a new rte is returned, it has its own clone of cached rta * (and cached rta of read-only source rte is intact), if rte is * modified in place, old cached rta is possibly freed. */ enum filter_return f_run(const struct filter *filter, struct rte **rte, struct linpool *tmp_pool, int flags) { if (filter == FILTER_ACCEPT) return F_ACCEPT; if (filter == FILTER_REJECT) return F_REJECT; int rte_cow = ((*rte)->flags & REF_COW); DBG( "Running filter `%s'...", filter->name ); /* Initialize the filter state */ filter_state = (struct filter_state) { .stack = &filter_stack, .rte = rte, .pool = tmp_pool, .flags = flags, }; LOG_BUFFER_INIT(filter_state.buf); /* Run the interpreter itself */ enum filter_return fret = interpret(&filter_state, filter->root, NULL); if (filter_state.old_rta) { /* * Cached rta was modified and filter_state->rte contains now an uncached one, * sharing some part with the cached one. The cached rta should * be freed (if rte was originally COW, filter_state->old_rta is a clone * obtained during rte_cow()). * * This also implements the exception mentioned in f_run() * description. The reason for this is that rta reuses parts of * filter_state->old_rta, and these may be freed during rta_free(filter_state->old_rta). * This is not the problem if rte was COW, because original rte * also holds the same rta. */ if (!rte_cow) { /* Cache the new attrs */ (*filter_state.rte)->attrs = rta_lookup((*filter_state.rte)->attrs); /* Drop cached ea_list pointer */ filter_state.eattrs = NULL; } /* Uncache the old attrs and drop the pointer as it is invalid now. */ rta_free(filter_state.old_rta); filter_state.old_rta = NULL; } /* Process the filter output, log it and return */ if (fret < F_ACCEPT) { if (!(filter_state.flags & FF_SILENT)) log_rl(&rl_runtime_err, L_ERR "Filter %s did not return accept nor reject. Make up your mind", filter_name(filter)); return F_ERROR; } DBG( "done (%u)\n", res.val.i ); return fret; } /** * f_eval_rte - run a filter line for an uncached route * @expr: filter line to run * @rte: route being filtered, may be modified * @tmp_pool: all filter allocations go from this pool * * This specific filter entry point runs the given filter line * (which must not have any arguments) on the given route. * * The route MUST NOT have REF_COW set and its attributes MUST NOT * be cached by rta_lookup(). */ enum filter_return f_eval_rte(const struct f_line *expr, struct rte **rte, struct linpool *tmp_pool) { filter_state = (struct filter_state) { .stack = &filter_stack, .rte = rte, .pool = tmp_pool, }; LOG_BUFFER_INIT(filter_state.buf); ASSERT(!((*rte)->flags & REF_COW)); ASSERT(!rta_is_cached((*rte)->attrs)); return interpret(&filter_state, expr, NULL); } /* * f_eval - get a value of a term * @expr: filter line containing the term * @tmp_pool: long data may get allocated from this pool * @pres: here the output will be stored */ enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres) { filter_state = (struct filter_state) { .stack = &filter_stack, .pool = tmp_pool, }; LOG_BUFFER_INIT(filter_state.buf); enum filter_return fret = interpret(&filter_state, expr, pres); return fret; } /* * f_eval_int - get an integer value of a term * Called internally from the config parser, uses its internal memory pool * for allocations. Do not call in other cases. */ uint f_eval_int(const struct f_line *expr) { /* Called independently in parse-time to eval expressions */ filter_state = (struct filter_state) { .stack = &filter_stack, .pool = cfg_mem, }; struct f_val val; LOG_BUFFER_INIT(filter_state.buf); if (interpret(&filter_state, expr, &val) > F_RETURN) cf_error("Runtime error while evaluating expression; see log for details"); if (val.type != T_INT) cf_error("Integer expression expected"); return val.val.i; } /* * f_eval_buf - get a value of a term and print it to the supplied buffer */ enum filter_return f_eval_buf(const struct f_line *expr, struct linpool *tmp_pool, buffer *buf) { struct f_val val; enum filter_return fret = f_eval(expr, tmp_pool, &val); if (fret <= F_RETURN) val_format(&val, buf); return fret; } /** * filter_same - compare two filters * @new: first filter to be compared * @old: second filter to be compared * * Returns 1 in case filters are same, otherwise 0. If there are * underlying bugs, it will rather say 0 on same filters than say * 1 on different. */ int filter_same(const struct filter *new, const struct filter *old) { if (old == new) /* Handle FILTER_ACCEPT and FILTER_REJECT */ return 1; if (old == FILTER_ACCEPT || old == FILTER_REJECT || new == FILTER_ACCEPT || new == FILTER_REJECT) return 0; if ((!old->sym) && (!new->sym)) return f_same(new->root, old->root); if ((!old->sym) || (!new->sym)) return 0; if (strcmp(old->sym->name, new->sym->name)) return 0; return new->sym->flags & SYM_FLAG_SAME; } /** * filter_commit - do filter comparisons on all the named functions and filters */ void filter_commit(struct config *new, struct config *old) { if (!old) return; struct symbol *sym, *osym; WALK_LIST(sym, new->symbols) switch (sym->class) { case SYM_FUNCTION: if ((osym = cf_find_symbol(old, sym->name)) && (osym->class == SYM_FUNCTION) && f_same(sym->function, osym->function)) sym->flags |= SYM_FLAG_SAME; else sym->flags &= ~SYM_FLAG_SAME; break; case SYM_FILTER: if ((osym = cf_find_symbol(old, sym->name)) && (osym->class == SYM_FILTER) && f_same(sym->filter->root, osym->filter->root)) sym->flags |= SYM_FLAG_SAME; else sym->flags &= ~SYM_FLAG_SAME; break; } } void filters_dump_all(void) { struct symbol *sym; WALK_LIST(sym, config->symbols) { switch (sym->class) { case SYM_FILTER: debug("Named filter %s:\n", sym->name); f_dump_line(sym->filter->root, 1); break; case SYM_FUNCTION: debug("Function %s:\n", sym->name); f_dump_line(sym->function, 1); break; case SYM_PROTO: { debug("Protocol %s:\n", sym->name); struct channel *c; WALK_LIST(c, sym->proto->proto->channels) { debug(" Channel %s (%s) IMPORT", c->name, net_label[c->net_type]); if (c->in_filter == FILTER_ACCEPT) debug(" ALL\n"); else if (c->in_filter == FILTER_REJECT) debug(" NONE\n"); else if (c->in_filter == FILTER_UNDEF) debug(" UNDEF\n"); else if (c->in_filter->sym) { ASSERT(c->in_filter->sym->filter == c->in_filter); debug(" named filter %s\n", c->in_filter->sym->name); } else { debug("\n"); f_dump_line(c->in_filter->root, 2); } } } } } } bird-2.0.8/filter/f-util.c0000664000175000017500000000765614025744326014233 0ustar feelafeela/* * Filters: utility functions * * Copyright 1998 Pavel Machek * 2017 Jan Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. */ #include "nest/bird.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/f-inst.h" #include "lib/idm.h" #include "nest/protocol.h" #include "nest/route.h" #define P(a,b) ((a<<8) | b) const char * filter_name(const struct filter *filter) { if (!filter) return "ACCEPT"; else if (filter == FILTER_REJECT) return "REJECT"; else if (!filter->sym) return "(unnamed)"; else return filter->sym->name; } struct filter *f_new_where(struct f_inst *where) { struct f_inst *cond = f_new_inst(FI_CONDITION, where, f_new_inst(FI_DIE, F_ACCEPT), f_new_inst(FI_DIE, F_REJECT)); struct filter *f = cfg_allocz(sizeof(struct filter)); f->root = f_linearize(cond); return f; } #define CA_KEY(n) n->name, n->fda.type #define CA_NEXT(n) n->next #define CA_EQ(na,ta,nb,tb) (!strcmp(na,nb) && (ta == tb)) #define CA_FN(n,t) (mem_hash(n, strlen(n)) ^ (t*0xaae99453U)) #define CA_ORDER 8 /* Fixed */ struct ca_storage { struct ca_storage *next; struct f_dynamic_attr fda; u32 uc; char name[0]; }; HASH(struct ca_storage) ca_hash; static struct idm ca_idm; static struct ca_storage **ca_storage; static uint ca_storage_max; static void ca_free(resource *r) { struct custom_attribute *ca = (void *) r; struct ca_storage *cas = HASH_FIND(ca_hash, CA, ca->name, ca->fda->type); ASSERT(cas); ca->name = NULL; ca->fda = NULL; if (!--cas->uc) { uint id = EA_CUSTOM_ID(cas->fda.ea_code); idm_free(&ca_idm, id); HASH_REMOVE(ca_hash, CA, cas); ca_storage[id] = NULL; mb_free(cas); } } static void ca_dump(resource *r) { struct custom_attribute *ca = (void *) r; debug("name \"%s\" id 0x%04x ea_type 0x%02x f_type 0x%02x\n", ca->name, ca->fda->ea_code, ca->fda->type, ca->fda->f_type); } static struct resclass ca_class = { .name = "Custom attribute", .size = sizeof(struct custom_attribute), .free = ca_free, .dump = ca_dump, .lookup = NULL, .memsize = NULL, }; struct custom_attribute * ca_lookup(pool *p, const char *name, int f_type) { int ea_type; switch (f_type) { case T_INT: ea_type = EAF_TYPE_INT; break; case T_IP: ea_type = EAF_TYPE_IP_ADDRESS; break; case T_QUAD: ea_type = EAF_TYPE_ROUTER_ID; break; case T_PATH: ea_type = EAF_TYPE_AS_PATH; break; case T_CLIST: ea_type = EAF_TYPE_INT_SET; break; case T_ECLIST: ea_type = EAF_TYPE_EC_SET; break; case T_LCLIST: ea_type = EAF_TYPE_LC_SET; break; default: cf_error("Custom route attribute of unsupported type"); } static int inited = 0; if (!inited) { idm_init(&ca_idm, &root_pool, 8); HASH_INIT(ca_hash, &root_pool, CA_ORDER); ca_storage_max = 256; ca_storage = mb_allocz(&root_pool, sizeof(struct ca_storage *) * ca_storage_max); inited++; } struct ca_storage *cas = HASH_FIND(ca_hash, CA, name, ea_type); if (cas) { cas->uc++; } else { uint id = idm_alloc(&ca_idm); if (id >= EA_CUSTOM_BIT) cf_error("Too many custom attributes."); if (id >= ca_storage_max) { ca_storage_max *= 2; ca_storage = mb_realloc(ca_storage, sizeof(struct ca_storage *) * ca_storage_max * 2); } cas = mb_allocz(&root_pool, sizeof(struct ca_storage) + strlen(name) + 1); cas->fda = f_new_dynamic_attr(ea_type, f_type, EA_CUSTOM(id)); cas->uc = 1; strcpy(cas->name, name); ca_storage[id] = cas; HASH_INSERT(ca_hash, CA, cas); } struct custom_attribute *ca = ralloc(p, &ca_class); ca->fda = &(cas->fda); ca->name = cas->name; return ca; } const char * ea_custom_name(uint ea) { uint id = EA_CUSTOM_ID(ea); if (id >= ca_storage_max) return NULL; if (!ca_storage[id]) return NULL; return ca_storage[id]->name; } bird-2.0.8/filter/f-inst.h0000664000175000017500000001015614025744326014225 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Filter instructions * * (c) 1999 Pavel Machek * (c) 2018--2019 Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. * * Filter interpreter data structures and internal API. * See filter/f-inst.c for documentation. */ #ifndef _BIRD_F_INST_H_ #define _BIRD_F_INST_H_ #include "nest/bird.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/data.h" #include "lib/buffer.h" #include "lib/flowspec.h" /* Flags for instructions */ enum f_instruction_flags { FIF_PRINTED = 1, /* FI_PRINT_AND_DIE: message put in buffer */ } PACKED; /* Include generated filter instruction declarations */ #include "filter/inst-gen.h" #define f_new_inst(...) MACRO_CONCAT_AFTER(f_new_inst_, MACRO_FIRST(__VA_ARGS__))(__VA_ARGS__) /* Convert the instruction back to the enum name */ const char *f_instruction_name_(enum f_instruction_code fi); static inline const char *f_instruction_name(enum f_instruction_code fi) { return f_instruction_name_(fi) + 3; } /* Filter structures for execution */ /* Line of instructions to be unconditionally executed one after another */ struct f_line { uint len; /* Line length */ u8 args; /* Function: Args required */ u8 vars; struct f_line_item items[0]; /* The items themselves */ }; /* Convert the f_inst infix tree to the f_line structures */ struct f_line *f_linearize_concat(const struct f_inst * const inst[], uint count); static inline struct f_line *f_linearize(const struct f_inst *root) { return f_linearize_concat(&root, 1); } void f_dump_line(const struct f_line *, uint indent); /* Recursive iteration over filter instructions */ struct filter_iterator { BUFFER_(const struct f_line *) lines; }; void f_add_lines(const struct f_line_item *what, struct filter_iterator *fit); #define FILTER_ITERATE_INIT(fit, filter, pool) \ ({ \ BUFFER_INIT((fit)->lines, (pool), 32); \ BUFFER_PUSH((fit)->lines) = (filter)->root; \ }) #define FILTER_ITERATE(fit, fi) ({ \ const struct f_line *fl_; \ while (!BUFFER_EMPTY((fit)->lines)) \ { \ BUFFER_POP((fit)->lines); \ fl_ = (fit)->lines.data[(fit)->lines.used]; \ for (uint i_ = 0; i_ < fl_->len; i_++) \ { \ const struct f_line_item *fi = &fl_->items[i_]; \ f_add_lines(fi, (fit)); #define FILTER_ITERATE_END } } }) #define FILTER_ITERATE_CLEANUP(fit) \ ({ \ mb_free((fit)->lines.data); \ memset((fit), 0, sizeof(struct filter_iterator)); \ }) struct filter *f_new_where(struct f_inst *); static inline struct f_dynamic_attr f_new_dynamic_attr(u8 type, enum f_type f_type, uint code) /* Type as core knows it, type as filters know it, and code of dynamic attribute */ { return (struct f_dynamic_attr) { .type = type, .f_type = f_type, .ea_code = code }; } /* f_type currently unused; will be handy for static type checking */ static inline struct f_dynamic_attr f_new_dynamic_attr_bit(u8 bit, enum f_type f_type, uint code) /* Type as core knows it, type as filters know it, and code of dynamic attribute */ { return (struct f_dynamic_attr) { .type = EAF_TYPE_BITFIELD, .bit = bit, .f_type = f_type, .ea_code = code }; } /* f_type currently unused; will be handy for static type checking */ static inline struct f_static_attr f_new_static_attr(int f_type, int code, int readonly) { return (struct f_static_attr) { .f_type = f_type, .sa_code = code, .readonly = readonly }; } struct f_inst *f_generate_complex(enum f_instruction_code fi_code, struct f_dynamic_attr da, struct f_inst *argument); struct f_inst *f_generate_roa_check(struct rtable_config *table, struct f_inst *prefix, struct f_inst *asn); /* Hook for call bt_assert() function in configuration */ extern void (*bt_assert_hook)(int result, const struct f_line_item *assert); /* Bird Tests */ struct f_bt_test_suite { node n; /* Node in config->tests */ const struct f_line *fn; /* Root of function */ const struct f_line *cmp; /* Compare to this function */ const char *fn_name; /* Name of test */ const char *dsc; /* Description */ int result; /* Desired result */ }; #endif bird-2.0.8/filter/f-inst.c0000664000175000017500000010744714025744326014232 0ustar feelafeela/* * Filters: Instructions themselves * * Copyright 1998 Pavel Machek * Copyright 2018 Maria Matejka * Copyright 2018 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. * * The filter code goes through several phases: * * 1 Parsing * Flex- and Bison-generated parser decodes the human-readable data into * a struct f_inst tree. This is an infix tree that was interpreted by * depth-first search execution in previous versions of the interpreter. * All instructions have their constructor: f_new_inst(FI_EXAMPLE, ...) * translates into f_new_inst_FI_EXAMPLE(...) and the types are checked in * compile time. If the result of the instruction is always the same, * it's reduced to FI_CONSTANT directly in constructor. This phase also * counts how many instructions are underlying in means of f_line_item * fields to know how much we have to allocate in the next phase. * * 2 Linearize before interpreting * The infix tree is always interpreted in the same order. Therefore we * sort the instructions one after another into struct f_line. Results * and arguments of these instructions are implicitly put on a value * stack; e.g. the + operation just takes two arguments from the value * stack and puts the result on there. * * 3 Interpret * The given line is put on a custom execution stack. If needed (FI_CALL, * FI_SWITCH, FI_AND, FI_OR, FI_CONDITION, ...), another line is put on top * of the stack; when that line finishes, the execution continues on the * older lines on the stack where it stopped before. * * 4 Same * On config reload, the filters have to be compared whether channel * reload is needed or not. The comparison is done by comparing the * struct f_line's recursively. * * The main purpose of this rework was to improve filter performance * by making the interpreter non-recursive. * * The other outcome is concentration of instruction definitions to * one place -- right here. You shall define your instruction only here * and nowhere else. * * Beware. This file is interpreted by M4 macros. These macros * may be more stupid than you could imagine. If something strange * happens after changing this file, compare the results before and * after your change (see the Makefile to find out where the results are) * and see what really happened. * * This file is not directly a C source code -> it is a generator input * for several C sources; every instruction block gets expanded into many * different places. * * All the arguments are processed literally; if you need an argument including comma, * you have to quote it by [[ ... ]] * * What is the syntax here? * m4_dnl INST(FI_NOP, in, out) { enum value, input args, output args * m4_dnl ARG(num, type); argument, its id (in data fields) and type accessible by v1, v2, v3 * m4_dnl ARG_ANY(num); argument with no type check accessible by v1, v2, v3 * m4_dnl VARARG; variable-length argument list; accessible by vv(i) and whati->varcount * m4_dnl LINE(num, unused); this argument has to be converted to its own f_line * m4_dnl SYMBOL; symbol handed from config * m4_dnl STATIC_ATTR; static attribute definition * m4_dnl DYNAMIC_ATTR; dynamic attribute definition * m4_dnl RTC; route table config * m4_dnl ACCESS_RTE; this instruction needs route * m4_dnl ACCESS_EATTRS; this instruction needs extended attributes * * m4_dnl FID_MEMBER( custom instruction member * m4_dnl C type, for storage in structs * m4_dnl name, how the member is named * m4_dnl comparator for same(), if different, this should be TRUE (CAVEAT) * m4_dnl dump format string debug -> format string for bvsnprintf * m4_dnl dump format args appropriate args * m4_dnl ) * * m4_dnl RESULT(type, union-field, value); putting this on value stack * m4_dnl RESULT_VAL(value-struct); pass the struct f_val directly * m4_dnl RESULT_VOID; return undef * m4_dnl } * * Also note that the { ... } blocks are not respected by M4 at all. * If you get weird unmatched-brace-pair errors, check what it generated and why. * What is really considered as one instruction is not the { ... } block * after m4_dnl INST() but all the code between them. * * Other code is just copied into the interpreter part. * * If you are satisfied with this, you don't need to read the following * detailed description of what is really done with the instruction definitions. * * m4_dnl Now let's look under the cover. The code between each INST() * m4_dnl is copied to several places, namely these (numbered by the M4 diversions * m4_dnl used in filter/decl.m4): * * m4_dnl (102) struct f_inst *f_new_inst(FI_EXAMPLE [[ put it here ]]) * m4_dnl { * m4_dnl ... (common code) * m4_dnl (103) [[ put it here ]] * m4_dnl ... * m4_dnl if (all arguments are constant) * m4_dnl (108) [[ put it here ]] * m4_dnl } * m4_dnl For writing directly to constructor argument list, use FID_NEW_ARGS. * m4_dnl For computing something in constructor (103), use FID_NEW_BODY. * m4_dnl For constant pre-interpretation (108), see below at FID_INTERPRET_BODY. * * m4_dnl struct f_inst { * m4_dnl ... (common fields) * m4_dnl union { * m4_dnl struct { * m4_dnl (101) [[ put it here ]] * m4_dnl } i_FI_EXAMPLE; * m4_dnl ... * m4_dnl }; * m4_dnl }; * m4_dnl This structure is returned from constructor. * m4_dnl For writing directly to this structure, use FID_STRUCT_IN. * * m4_dnl linearize(struct f_line *dest, const struct f_inst *what, uint pos) { * m4_dnl ... * m4_dnl switch (what->fi_code) { * m4_dnl case FI_EXAMPLE: * m4_dnl (105) [[ put it here ]] * m4_dnl break; * m4_dnl } * m4_dnl } * m4_dnl This is called when translating from struct f_inst to struct f_line_item. * m4_dnl For accessing your custom instruction data, use following macros: * m4_dnl whati -> for accessing (struct f_inst).i_FI_EXAMPLE * m4_dnl item -> for accessing (struct f_line)[pos].i_FI_EXAMPLE * m4_dnl For writing directly here, use FID_LINEARIZE_BODY. * * m4_dnl (107) struct f_line_item { * m4_dnl ... (common fields) * m4_dnl union { * m4_dnl struct { * m4_dnl (101) [[ put it here ]] * m4_dnl } i_FI_EXAMPLE; * m4_dnl ... * m4_dnl }; * m4_dnl }; * m4_dnl The same as FID_STRUCT_IN (101) but for the other structure. * m4_dnl This structure is returned from the linearizer (105). * m4_dnl For writing directly to this structure, use FID_LINE_IN. * * m4_dnl f_dump_line_item_FI_EXAMPLE(const struct f_line_item *item, const int indent) * m4_dnl { * m4_dnl (104) [[ put it here ]] * m4_dnl } * m4_dnl This code dumps the instruction on debug. Note that the argument * m4_dnl is the linearized instruction; if the instruction has arguments, * m4_dnl their code has already been linearized and their value is taken * m4_dnl from the value stack. * m4_dnl For writing directly here, use FID_DUMP_BODY. * * m4_dnl f_same(...) * m4_dnl { * m4_dnl switch (f1_->fi_code) { * m4_dnl case FI_EXAMPLE: * m4_dnl (106) [[ put it here ]] * m4_dnl break; * m4_dnl } * m4_dnl } * m4_dnl This code compares the two given instrucions (f1_ and f2_) * m4_dnl on reconfigure. For accessing your custom instruction data, * m4_dnl use macros f1 and f2. * m4_dnl For writing directly here, use FID_SAME_BODY. * * m4_dnl f_add_lines(...) * m4_dnl { * m4_dnl switch (what_->fi_code) { * m4_dnl case FI_EXAMPLE: * m4_dnl (109) [[ put it here ]] * m4_dnl break; * m4_dnl } * m4_dnl } * m4_dnl This code adds new filter lines reachable from the instruction * m4_dnl to the filter iterator line buffer. This is for instructions * m4_dnl that changes conrol flow, like FI_CONDITION or FI_CALL, most * m4_dnl instructions do not need to update it. It is used in generic * m4_dnl filter iteration code (FILTER_ITERATE*). For accessing your * m4_dnl custom instruction data, use macros f1 and f2. For writing * m4_dnl directly here, use FID_ITERATE_BODY. * * m4_dnl interpret(...) * m4_dnl { * m4_dnl switch (what->fi_code) { * m4_dnl case FI_EXAMPLE: * m4_dnl (108) [[ put it here ]] * m4_dnl break; * m4_dnl } * m4_dnl } * m4_dnl This code executes the instruction. Every pre-defined macro * m4_dnl resets the output here. For setting it explicitly, * m4_dnl use FID_INTERPRET_BODY. * m4_dnl This code is put on two places; one is the interpreter, the other * m4_dnl is instruction constructor. If you need to distinguish between * m4_dnl these two, use FID_INTERPRET_EXEC or FID_INTERPRET_NEW respectively. * m4_dnl To address the difference between interpreter and constructor * m4_dnl environments, there are several convenience macros defined: * m4_dnl runtime() -> for spitting out runtime error like division by zero * m4_dnl RESULT(...) -> declare result; may overwrite arguments * m4_dnl v1, v2, v3 -> positional arguments, may be overwritten by RESULT() * m4_dnl falloc(size) -> allocate memory from the appropriate linpool * m4_dnl fpool -> the current linpool * m4_dnl NEVER_CONSTANT-> don't generate pre-interpretation code at all * m4_dnl ACCESS_RTE -> check that route is available, also NEVER_CONSTANT * m4_dnl ACCESS_EATTRS -> pre-cache the eattrs; use only with ACCESS_RTE * m4_dnl f_rta_cow(fs) -> function to call before any change to route should be done * * m4_dnl If you are stymied, see FI_CALL or FI_CONSTANT or just search for * m4_dnl the mentioned macros in this file to see what is happening there in wild. */ /* Binary operators */ INST(FI_ADD, 2, 1) { ARG(1,T_INT); ARG(2,T_INT); RESULT(T_INT, i, v1.val.i + v2.val.i); } INST(FI_SUBTRACT, 2, 1) { ARG(1,T_INT); ARG(2,T_INT); RESULT(T_INT, i, v1.val.i - v2.val.i); } INST(FI_MULTIPLY, 2, 1) { ARG(1,T_INT); ARG(2,T_INT); RESULT(T_INT, i, v1.val.i * v2.val.i); } INST(FI_DIVIDE, 2, 1) { ARG(1,T_INT); ARG(2,T_INT); if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" ); RESULT(T_INT, i, v1.val.i / v2.val.i); } INST(FI_AND, 1, 1) { ARG(1,T_BOOL); ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (v1.val.i) LINE(2,0); else RESULT_VAL(v1); } INST(FI_OR, 1, 1) { ARG(1,T_BOOL); ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (!v1.val.i) LINE(2,0); else RESULT_VAL(v1); } INST(FI_PAIR_CONSTRUCT, 2, 1) { ARG(1,T_INT); ARG(2,T_INT); uint u1 = v1.val.i; uint u2 = v2.val.i; if ((u1 > 0xFFFF) || (u2 > 0xFFFF)) runtime( "Can't operate with value out of bounds in pair constructor" ); RESULT(T_PAIR, i, (u1 << 16) | u2); } INST(FI_EC_CONSTRUCT, 2, 1) { ARG_ANY(1); ARG(2, T_INT); FID_MEMBER(enum ec_subtype, ecs, f1->ecs != f2->ecs, "ec subtype %s", ec_subtype_str(item->ecs)); int ipv4_used; u32 key, val; if (v1.type == T_INT) { ipv4_used = 0; key = v1.val.i; } else if (v1.type == T_QUAD) { ipv4_used = 1; key = v1.val.i; } /* IP->Quad implicit conversion */ else if (val_is_ip4(&v1)) { ipv4_used = 1; key = ipa_to_u32(v1.val.ip); } else runtime("Argument 1 of EC constructor must be integer or IPv4 address, got 0x%02x", v1.type); val = v2.val.i; if (ecs == EC_GENERIC) RESULT(T_EC, ec, ec_generic(key, val)); else if (ipv4_used) if (val <= 0xFFFF) RESULT(T_EC, ec, ec_ip4(ecs, key, val)); else runtime("4-byte value %u can't be used with IP-address key in extended community", val); else if (key < 0x10000) RESULT(T_EC, ec, ec_as2(ecs, key, val)); else if (val <= 0xFFFF) RESULT(T_EC, ec, ec_as4(ecs, key, val)); else runtime("4-byte value %u can't be used with 4-byte ASN in extended community", val); } INST(FI_LC_CONSTRUCT, 3, 1) { ARG(1, T_INT); ARG(2, T_INT); ARG(3, T_INT); RESULT(T_LC, lc, [[(lcomm) { v1.val.i, v2.val.i, v3.val.i }]]); } INST(FI_PATHMASK_CONSTRUCT, 0, 1) { VARARG; struct f_path_mask *pm = falloc(sizeof(struct f_path_mask) + whati->varcount * sizeof(struct f_path_mask_item)); pm->len = whati->varcount; for (uint i=0; ivarcount; i++) { switch (vv(i).type) { case T_PATH_MASK_ITEM: if (vv(i).val.pmi.kind == PM_LOOP) { if (i == 0) runtime("Path mask iterator '+' cannot be first"); /* We want PM_LOOP as prefix operator */ pm->item[i] = pm->item[i - 1]; pm->item[i - 1] = vv(i).val.pmi; break; } pm->item[i] = vv(i).val.pmi; break; case T_INT: pm->item[i] = (struct f_path_mask_item) { .asn = vv(i).val.i, .kind = PM_ASN, }; break; case T_SET: if (vv(i).val.t->from.type != T_INT) runtime("Only integer sets allowed in path mask"); pm->item[i] = (struct f_path_mask_item) { .set = vv(i).val.t, .kind = PM_ASN_SET, }; break; default: runtime( "Error resolving path mask template: value not an integer" ); } } RESULT(T_PATH_MASK, path_mask, pm); } /* Relational operators */ INST(FI_NEQ, 2, 1) { ARG_ANY(1); ARG_ANY(2); RESULT(T_BOOL, i, !val_same(&v1, &v2)); } INST(FI_EQ, 2, 1) { ARG_ANY(1); ARG_ANY(2); RESULT(T_BOOL, i, val_same(&v1, &v2)); } INST(FI_LT, 2, 1) { ARG_ANY(1); ARG_ANY(2); ARG_SAME_TYPE(1, 2); int i = val_compare(&v1, &v2); if (i == F_CMP_ERROR) runtime( "Can't compare values of incompatible types" ); RESULT(T_BOOL, i, (i == -1)); } INST(FI_LTE, 2, 1) { ARG_ANY(1); ARG_ANY(2); ARG_SAME_TYPE(1, 2); int i = val_compare(&v1, &v2); if (i == F_CMP_ERROR) runtime( "Can't compare values of incompatible types" ); RESULT(T_BOOL, i, (i != 1)); } INST(FI_NOT, 1, 1) { ARG(1,T_BOOL); RESULT(T_BOOL, i, !v1.val.i); } INST(FI_MATCH, 2, 1) { ARG_ANY(1); ARG_ANY(2); int i = val_in_range(&v1, &v2); if (i == F_CMP_ERROR) runtime( "~ applied on unknown type pair" ); RESULT(T_BOOL, i, !!i); } INST(FI_NOT_MATCH, 2, 1) { ARG_ANY(1); ARG_ANY(2); int i = val_in_range(&v1, &v2); if (i == F_CMP_ERROR) runtime( "!~ applied on unknown type pair" ); RESULT(T_BOOL, i, !i); } INST(FI_DEFINED, 1, 1) { ARG_ANY(1); RESULT(T_BOOL, i, (v1.type != T_VOID) && !undef_value(v1)); } INST(FI_TYPE, 1, 1) { ARG_ANY(1); /* There may be more types supporting this operation */ switch (v1.type) { case T_NET: RESULT(T_ENUM_NETTYPE, i, v1.val.net->type); break; default: runtime( "Can't determine type of this item" ); } } INST(FI_IS_V4, 1, 1) { ARG(1, T_IP); RESULT(T_BOOL, i, ipa_is_ip4(v1.val.ip)); } /* Set to indirect value prepared in v1 */ INST(FI_VAR_SET, 1, 0) { NEVER_CONSTANT; ARG_ANY(1); SYMBOL; ARG_TYPE(1, sym->class & 0xff); fstk->vstk[curline.vbase + sym->offset] = v1; } INST(FI_VAR_GET, 0, 1) { SYMBOL; NEVER_CONSTANT; RESULT_TYPE(sym->class & 0xff); RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]); } INST(FI_CONSTANT, 0, 1) { FID_MEMBER( struct f_val, val, [[ !val_same(&(f1->val), &(f2->val)) ]], "value %s", val_dump(&(item->val)) ); RESULT_TYPE(val.type); RESULT_VAL(val); } INST(FI_CONDITION, 1, 0) { ARG(1, T_BOOL); if (v1.val.i) LINE(2,0); else LINE(3,1); } INST(FI_PRINT, 0, 0) { NEVER_CONSTANT; VARARG; if (whati->varcount && !(fs->flags & FF_SILENT)) for (uint i=0; ivarcount; i++) val_format(&(vv(i)), &fs->buf); } INST(FI_FLUSH, 0, 0) { NEVER_CONSTANT; if (!(fs->flags & FF_SILENT)) /* After log_commit, the buffer is reset */ log_commit(*L_INFO, &fs->buf); } INST(FI_DIE, 0, 0) { NEVER_CONSTANT; FID_MEMBER(enum filter_return, fret, f1->fret != f2->fret, "%s", filter_return_str(item->fret)); switch (whati->fret) { case F_ACCEPT: /* Should take care about turning ACCEPT into MODIFY */ case F_ERROR: case F_REJECT: /* Maybe print complete route along with reason to reject route? */ return fret; /* We have to return now, no more processing. */ default: bug( "unknown return type: Can't happen"); } } INST(FI_RTA_GET, 0, 1) { { STATIC_ATTR; ACCESS_RTE; struct rta *rta = (*fs->rte)->attrs; switch (sa.sa_code) { case SA_FROM: RESULT(sa.f_type, ip, rta->from); break; case SA_GW: RESULT(sa.f_type, ip, rta->nh.gw); break; case SA_NET: RESULT(sa.f_type, net, (*fs->rte)->net->n.addr); break; case SA_PROTO: RESULT(sa.f_type, s, rta->src->proto->name); break; case SA_SOURCE: RESULT(sa.f_type, i, rta->source); break; case SA_SCOPE: RESULT(sa.f_type, i, rta->scope); break; case SA_DEST: RESULT(sa.f_type, i, rta->dest); break; case SA_IFNAME: RESULT(sa.f_type, s, rta->nh.iface ? rta->nh.iface->name : ""); break; case SA_IFINDEX: RESULT(sa.f_type, i, rta->nh.iface ? rta->nh.iface->index : 0); break; case SA_WEIGHT: RESULT(sa.f_type, i, rta->nh.weight + 1); break; default: bug("Invalid static attribute access (%u/%u)", sa.f_type, sa.sa_code); } } } INST(FI_RTA_SET, 1, 0) { ACCESS_RTE; ARG_ANY(1); STATIC_ATTR; ARG_TYPE(1, sa.f_type); f_rta_cow(fs); { struct rta *rta = (*fs->rte)->attrs; switch (sa.sa_code) { case SA_FROM: rta->from = v1.val.ip; break; case SA_GW: { ip_addr ip = v1.val.ip; struct iface *ifa = ipa_is_link_local(ip) ? rta->nh.iface : NULL; neighbor *n = neigh_find(rta->src->proto, ip, ifa, 0); if (!n || (n->scope == SCOPE_HOST)) runtime( "Invalid gw address" ); rta->dest = RTD_UNICAST; rta->nh.gw = ip; rta->nh.iface = n->iface; rta->nh.next = NULL; rta->hostentry = NULL; } break; case SA_SCOPE: rta->scope = v1.val.i; break; case SA_DEST: { int i = v1.val.i; if ((i != RTD_BLACKHOLE) && (i != RTD_UNREACHABLE) && (i != RTD_PROHIBIT)) runtime( "Destination can be changed only to blackhole, unreachable or prohibit" ); rta->dest = i; rta->nh.gw = IPA_NONE; rta->nh.iface = NULL; rta->nh.next = NULL; rta->hostentry = NULL; } break; case SA_IFNAME: { struct iface *ifa = if_find_by_name(v1.val.s); if (!ifa) runtime( "Invalid iface name" ); rta->dest = RTD_UNICAST; rta->nh.gw = IPA_NONE; rta->nh.iface = ifa; rta->nh.next = NULL; rta->hostentry = NULL; } break; case SA_WEIGHT: { int i = v1.val.i; if (i < 1 || i > 256) runtime( "Setting weight value out of bounds" ); if (rta->dest != RTD_UNICAST) runtime( "Setting weight needs regular nexthop " ); /* Set weight on all next hops */ for (struct nexthop *nh = &rta->nh; nh; nh = nh->next) nh->weight = i - 1; } break; default: bug("Invalid static attribute access (%u/%u)", sa.f_type, sa.sa_code); } } } INST(FI_EA_GET, 0, 1) { /* Access to extended attributes */ DYNAMIC_ATTR; ACCESS_RTE; ACCESS_EATTRS; RESULT_TYPE(da.f_type); { eattr *e = ea_find(*fs->eattrs, da.ea_code); if (!e) { /* A special case: undefined as_path looks like empty as_path */ if (da.type == EAF_TYPE_AS_PATH) { RESULT_(T_PATH, ad, &null_adata); break; } /* The same special case for int_set */ if (da.type == EAF_TYPE_INT_SET) { RESULT_(T_CLIST, ad, &null_adata); break; } /* The same special case for ec_set */ if (da.type == EAF_TYPE_EC_SET) { RESULT_(T_ECLIST, ad, &null_adata); break; } /* The same special case for lc_set */ if (da.type == EAF_TYPE_LC_SET) { RESULT_(T_LCLIST, ad, &null_adata); break; } /* Undefined value */ RESULT_VOID; break; } switch (e->type & EAF_TYPE_MASK) { case EAF_TYPE_INT: RESULT_(da.f_type, i, e->u.data); break; case EAF_TYPE_ROUTER_ID: RESULT_(T_QUAD, i, e->u.data); break; case EAF_TYPE_OPAQUE: RESULT_(T_ENUM_EMPTY, i, 0); break; case EAF_TYPE_IP_ADDRESS: RESULT_(T_IP, ip, *((ip_addr *) e->u.ptr->data)); break; case EAF_TYPE_AS_PATH: RESULT_(T_PATH, ad, e->u.ptr); break; case EAF_TYPE_BITFIELD: RESULT_(T_BOOL, i, !!(e->u.data & (1u << da.bit))); break; case EAF_TYPE_INT_SET: RESULT_(T_CLIST, ad, e->u.ptr); break; case EAF_TYPE_EC_SET: RESULT_(T_ECLIST, ad, e->u.ptr); break; case EAF_TYPE_LC_SET: RESULT_(T_LCLIST, ad, e->u.ptr); break; case EAF_TYPE_UNDEF: RESULT_VOID; break; default: bug("Unknown dynamic attribute type"); } } } INST(FI_EA_SET, 1, 0) { ACCESS_RTE; ACCESS_EATTRS; ARG_ANY(1); DYNAMIC_ATTR; ARG_TYPE(1, da.f_type); { struct ea_list *l = lp_alloc(fs->pool, sizeof(struct ea_list) + sizeof(eattr)); l->next = NULL; l->flags = EALF_SORTED; l->count = 1; l->attrs[0].id = da.ea_code; l->attrs[0].flags = 0; l->attrs[0].type = da.type | EAF_ORIGINATED | EAF_FRESH; switch (da.type) { case EAF_TYPE_INT: case EAF_TYPE_ROUTER_ID: l->attrs[0].u.data = v1.val.i; break; case EAF_TYPE_OPAQUE: runtime( "Setting opaque attribute is not allowed" ); break; case EAF_TYPE_IP_ADDRESS:; int len = sizeof(ip_addr); struct adata *ad = lp_alloc(fs->pool, sizeof(struct adata) + len); ad->length = len; (* (ip_addr *) ad->data) = v1.val.ip; l->attrs[0].u.ptr = ad; break; case EAF_TYPE_AS_PATH: case EAF_TYPE_INT_SET: case EAF_TYPE_EC_SET: case EAF_TYPE_LC_SET: l->attrs[0].u.ptr = v1.val.ad; break; case EAF_TYPE_BITFIELD: { /* First, we have to find the old value */ eattr *e = ea_find(*fs->eattrs, da.ea_code); u32 data = e ? e->u.data : 0; if (v1.val.i) l->attrs[0].u.data = data | (1u << da.bit); else l->attrs[0].u.data = data & ~(1u << da.bit); } break; default: bug("Unknown dynamic attribute type"); } f_rta_cow(fs); l->next = *fs->eattrs; *fs->eattrs = l; } } INST(FI_EA_UNSET, 0, 0) { DYNAMIC_ATTR; ACCESS_RTE; ACCESS_EATTRS; { struct ea_list *l = lp_alloc(fs->pool, sizeof(struct ea_list) + sizeof(eattr)); l->next = NULL; l->flags = EALF_SORTED; l->count = 1; l->attrs[0].id = da.ea_code; l->attrs[0].flags = 0; l->attrs[0].type = EAF_TYPE_UNDEF | EAF_ORIGINATED | EAF_FRESH; l->attrs[0].u.data = 0; f_rta_cow(fs); l->next = *fs->eattrs; *fs->eattrs = l; } } INST(FI_PREF_GET, 0, 1) { ACCESS_RTE; RESULT(T_INT, i, (*fs->rte)->pref); } INST(FI_PREF_SET, 1, 0) { ACCESS_RTE; ARG(1,T_INT); if (v1.val.i > 0xFFFF) runtime( "Setting preference value out of bounds" ); f_rte_cow(fs); (*fs->rte)->pref = v1.val.i; } INST(FI_LENGTH, 1, 1) { /* Get length of */ ARG_ANY(1); switch(v1.type) { case T_NET: RESULT(T_INT, i, net_pxlen(v1.val.net)); break; case T_PATH: RESULT(T_INT, i, as_path_getlen(v1.val.ad)); break; case T_CLIST: RESULT(T_INT, i, int_set_get_size(v1.val.ad)); break; case T_ECLIST: RESULT(T_INT, i, ec_set_get_size(v1.val.ad)); break; case T_LCLIST: RESULT(T_INT, i, lc_set_get_size(v1.val.ad)); break; default: runtime( "Prefix, path, clist or eclist expected" ); } } INST(FI_NET_SRC, 1, 1) { /* Get src prefix */ ARG(1, T_NET); net_addr_union *net = (void *) v1.val.net; net_addr *src = falloc(sizeof(net_addr_ip6)); const byte *part; switch(v1.val.net->type) { case NET_FLOW4: part = flow4_get_part(&net->flow4, FLOW_TYPE_SRC_PREFIX); if (part) net_fill_ip4(src, flow_read_ip4_part(part), flow_read_pxlen(part)); else net_fill_ip4(src, IP4_NONE, 0); break; case NET_FLOW6: part = flow6_get_part(&net->flow6, FLOW_TYPE_SRC_PREFIX); if (part) net_fill_ip6(src, flow_read_ip6_part(part), flow_read_pxlen(part)); else net_fill_ip6(src, IP6_NONE, 0); break; case NET_IP6_SADR: net_fill_ip6(src, net->ip6_sadr.src_prefix, net->ip6_sadr.src_pxlen); break; default: runtime( "Flow or SADR expected" ); } RESULT(T_NET, net, src); } INST(FI_NET_DST, 1, 1) { /* Get dst prefix */ ARG(1, T_NET); net_addr_union *net = (void *) v1.val.net; net_addr *dst = falloc(sizeof(net_addr_ip6)); const byte *part; switch(v1.val.net->type) { case NET_FLOW4: part = flow4_get_part(&net->flow4, FLOW_TYPE_DST_PREFIX); if (part) net_fill_ip4(dst, flow_read_ip4_part(part), flow_read_pxlen(part)); else net_fill_ip4(dst, IP4_NONE, 0); break; case NET_FLOW6: part = flow6_get_part(&net->flow6, FLOW_TYPE_DST_PREFIX); if (part) net_fill_ip6(dst, flow_read_ip6_part(part), flow_read_pxlen(part)); else net_fill_ip6(dst, IP6_NONE, 0); break; case NET_IP6_SADR: net_fill_ip6(dst, net->ip6_sadr.dst_prefix, net->ip6_sadr.dst_pxlen); break; default: runtime( "Flow or SADR expected" ); } RESULT(T_NET, net, dst); } INST(FI_ROA_MAXLEN, 1, 1) { /* Get ROA max prefix length */ ARG(1, T_NET); if (!net_is_roa(v1.val.net)) runtime( "ROA expected" ); RESULT(T_INT, i, (v1.val.net->type == NET_ROA4) ? ((net_addr_roa4 *) v1.val.net)->max_pxlen : ((net_addr_roa6 *) v1.val.net)->max_pxlen); } INST(FI_ROA_ASN, 1, 1) { /* Get ROA ASN */ ARG(1, T_NET); if (!net_is_roa(v1.val.net)) runtime( "ROA expected" ); RESULT(T_INT, i, (v1.val.net->type == NET_ROA4) ? ((net_addr_roa4 *) v1.val.net)->asn : ((net_addr_roa6 *) v1.val.net)->asn); } INST(FI_IP, 1, 1) { /* Convert prefix to ... */ ARG(1, T_NET); RESULT(T_IP, ip, net_prefix(v1.val.net)); } INST(FI_ROUTE_DISTINGUISHER, 1, 1) { ARG(1, T_NET); if (!net_is_vpn(v1.val.net)) runtime( "VPN address expected" ); RESULT(T_RD, ec, net_rd(v1.val.net)); } INST(FI_AS_PATH_FIRST, 1, 1) { /* Get first ASN from AS PATH */ ARG(1, T_PATH); u32 as = 0; as_path_get_first(v1.val.ad, &as); RESULT(T_INT, i, as); } INST(FI_AS_PATH_LAST, 1, 1) { /* Get last ASN from AS PATH */ ARG(1, T_PATH); u32 as = 0; as_path_get_last(v1.val.ad, &as); RESULT(T_INT, i, as); } INST(FI_AS_PATH_LAST_NAG, 1, 1) { /* Get last ASN from non-aggregated part of AS PATH */ ARG(1, T_PATH); RESULT(T_INT, i, as_path_get_last_nonaggregated(v1.val.ad)); } INST(FI_RETURN, 1, 1) { NEVER_CONSTANT; /* Acquire the return value */ ARG_ANY(1); uint retpos = fstk->vcnt; /* Drop every sub-block including ourselves */ do fstk->ecnt--; while ((fstk->ecnt > 0) && !(fstk->estk[fstk->ecnt].emask & FE_RETURN)); /* Now we are at the caller frame; if no such, try to convert to accept/reject. */ if (!fstk->ecnt) { if (fstk->vstk[retpos].type == T_BOOL) return (fstk->vstk[retpos].val.i) ? F_ACCEPT : F_REJECT; else runtime("Can't return non-bool from non-function"); } /* Set the value stack position, overwriting the former implicit void */ fstk->vcnt = fstk->estk[fstk->ecnt].ventry - 1; /* Copy the return value */ RESULT_VAL(fstk->vstk[retpos]); } INST(FI_CALL, 0, 1) { NEVER_CONSTANT; SYMBOL; FID_SAME_BODY() if (!(f1->sym->flags & SYM_FLAG_SAME)) return 0; FID_ITERATE_BODY() BUFFER_PUSH(fit->lines) = whati->sym->function; FID_INTERPRET_BODY() /* Push the body on stack */ LINEX(sym->function); curline.emask |= FE_RETURN; /* Before this instruction was called, there was the T_VOID * automatic return value pushed on value stack and also * sym->function->args function arguments. Setting the * vbase to point to first argument. */ ASSERT(curline.ventry >= sym->function->args); curline.ventry -= sym->function->args; curline.vbase = curline.ventry; /* Storage for local variables */ memset(&(fstk->vstk[fstk->vcnt]), 0, sizeof(struct f_val) * sym->function->vars); fstk->vcnt += sym->function->vars; } INST(FI_DROP_RESULT, 1, 0) { NEVER_CONSTANT; ARG_ANY(1); } INST(FI_SWITCH, 1, 0) { ARG_ANY(1); FID_MEMBER(struct f_tree *, tree, [[!same_tree(f1->tree, f2->tree)]], "tree %p", item->tree); FID_ITERATE_BODY() tree_walk(whati->tree, f_add_tree_lines, fit); FID_INTERPRET_BODY() const struct f_tree *t = find_tree(tree, &v1); if (!t) { v1.type = T_VOID; t = find_tree(tree, &v1); if (!t) { debug( "No else statement?\n"); FID_HIC(,break,return NULL); } } /* It is actually possible to have t->data NULL */ LINEX(t->data); } INST(FI_IP_MASK, 2, 1) { /* IP.MASK(val) */ ARG(1, T_IP); ARG(2, T_INT); RESULT(T_IP, ip, [[ ipa_is_ip4(v1.val.ip) ? ipa_from_ip4(ip4_and(ipa_to_ip4(v1.val.ip), ip4_mkmask(v2.val.i))) : ipa_from_ip6(ip6_and(ipa_to_ip6(v1.val.ip), ip6_mkmask(v2.val.i))) ]]); } INST(FI_PATH_PREPEND, 2, 1) { /* Path prepend */ ARG(1, T_PATH); ARG(2, T_INT); RESULT(T_PATH, ad, [[ as_path_prepend(fpool, v1.val.ad, v2.val.i) ]]); } INST(FI_CLIST_ADD, 2, 1) { /* (Extended) Community list add */ ARG_ANY(1); ARG_ANY(2); RESULT_TYPE(f1->type); if (v1.type == T_PATH) runtime("Can't add to path"); else if (v1.type == T_CLIST) { /* Community (or cluster) list */ struct f_val dummy; if ((v2.type == T_PAIR) || (v2.type == T_QUAD)) RESULT_(T_CLIST, ad, [[ int_set_add(fpool, v1.val.ad, v2.val.i) ]]); /* IP->Quad implicit conversion */ else if (val_is_ip4(&v2)) RESULT_(T_CLIST, ad, [[ int_set_add(fpool, v1.val.ad, ipa_to_u32(v2.val.ip)) ]]); else if ((v2.type == T_SET) && clist_set_type(v2.val.t, &dummy)) runtime("Can't add set"); else if (v2.type == T_CLIST) RESULT_(T_CLIST, ad, [[ int_set_union(fpool, v1.val.ad, v2.val.ad) ]]); else runtime("Can't add non-pair"); } else if (v1.type == T_ECLIST) { /* v2.val is either EC or EC-set */ if ((v2.type == T_SET) && eclist_set_type(v2.val.t)) runtime("Can't add set"); else if (v2.type == T_ECLIST) RESULT_(T_ECLIST, ad, [[ ec_set_union(fpool, v1.val.ad, v2.val.ad) ]]); else if (v2.type != T_EC) runtime("Can't add non-ec"); else RESULT_(T_ECLIST, ad, [[ ec_set_add(fpool, v1.val.ad, v2.val.ec) ]]); } else if (v1.type == T_LCLIST) { /* v2.val is either LC or LC-set */ if ((v2.type == T_SET) && lclist_set_type(v2.val.t)) runtime("Can't add set"); else if (v2.type == T_LCLIST) RESULT_(T_LCLIST, ad, [[ lc_set_union(fpool, v1.val.ad, v2.val.ad) ]]); else if (v2.type != T_LC) runtime("Can't add non-lc"); else RESULT_(T_LCLIST, ad, [[ lc_set_add(fpool, v1.val.ad, v2.val.lc) ]]); } else runtime("Can't add to non-[e|l]clist"); } INST(FI_CLIST_DEL, 2, 1) { /* (Extended) Community list add or delete */ ARG_ANY(1); ARG_ANY(2); RESULT_TYPE(f1->type); if (v1.type == T_PATH) { const struct f_tree *set = NULL; u32 key = 0; if (v2.type == T_INT) key = v2.val.i; else if ((v2.type == T_SET) && (v2.val.t->from.type == T_INT)) set = v2.val.t; else runtime("Can't delete non-integer (set)"); RESULT_(T_PATH, ad, [[ as_path_filter(fpool, v1.val.ad, set, key, 0) ]]); } else if (v1.type == T_CLIST) { /* Community (or cluster) list */ struct f_val dummy; if ((v2.type == T_PAIR) || (v2.type == T_QUAD)) RESULT_(T_CLIST, ad, [[ int_set_del(fpool, v1.val.ad, v2.val.i) ]]); /* IP->Quad implicit conversion */ else if (val_is_ip4(&v2)) RESULT_(T_CLIST, ad, [[ int_set_del(fpool, v1.val.ad, ipa_to_u32(v2.val.ip)) ]]); else if ((v2.type == T_SET) && clist_set_type(v2.val.t, &dummy) || (v2.type == T_CLIST)) RESULT_(T_CLIST, ad, [[ clist_filter(fpool, v1.val.ad, &v2, 0) ]]); else runtime("Can't delete non-pair"); } else if (v1.type == T_ECLIST) { /* v2.val is either EC or EC-set */ if ((v2.type == T_SET) && eclist_set_type(v2.val.t) || (v2.type == T_ECLIST)) RESULT_(T_ECLIST, ad, [[ eclist_filter(fpool, v1.val.ad, &v2, 0) ]]); else if (v2.type != T_EC) runtime("Can't delete non-ec"); else RESULT_(T_ECLIST, ad, [[ ec_set_del(fpool, v1.val.ad, v2.val.ec) ]]); } else if (v1.type == T_LCLIST) { /* v2.val is either LC or LC-set */ if ((v2.type == T_SET) && lclist_set_type(v2.val.t) || (v2.type == T_LCLIST)) RESULT_(T_LCLIST, ad, [[ lclist_filter(fpool, v1.val.ad, &v2, 0) ]]); else if (v2.type != T_LC) runtime("Can't delete non-lc"); else RESULT_(T_LCLIST, ad, [[ lc_set_del(fpool, v1.val.ad, v2.val.lc) ]]); } else runtime("Can't delete in non-[e|l]clist"); } INST(FI_CLIST_FILTER, 2, 1) { /* (Extended) Community list add or delete */ ARG_ANY(1); ARG_ANY(2); RESULT_TYPE(f1->type); if (v1.type == T_PATH) { u32 key = 0; if ((v2.type == T_SET) && (v2.val.t->from.type == T_INT)) RESULT_(T_PATH, ad, [[ as_path_filter(fpool, v1.val.ad, v2.val.t, key, 1) ]]); else runtime("Can't filter integer"); } else if (v1.type == T_CLIST) { /* Community (or cluster) list */ struct f_val dummy; if ((v2.type == T_SET) && clist_set_type(v2.val.t, &dummy) || (v2.type == T_CLIST)) RESULT_(T_CLIST, ad, [[ clist_filter(fpool, v1.val.ad, &v2, 1) ]]); else runtime("Can't filter pair"); } else if (v1.type == T_ECLIST) { /* v2.val is either EC or EC-set */ if ((v2.type == T_SET) && eclist_set_type(v2.val.t) || (v2.type == T_ECLIST)) RESULT_(T_ECLIST, ad, [[ eclist_filter(fpool, v1.val.ad, &v2, 1) ]]); else runtime("Can't filter ec"); } else if (v1.type == T_LCLIST) { /* v2.val is either LC or LC-set */ if ((v2.type == T_SET) && lclist_set_type(v2.val.t) || (v2.type == T_LCLIST)) RESULT_(T_LCLIST, ad, [[ lclist_filter(fpool, v1.val.ad, &v2, 1) ]]); else runtime("Can't filter lc"); } else runtime("Can't filter non-[e|l]clist"); } INST(FI_ROA_CHECK_IMPLICIT, 0, 1) { /* ROA Check */ NEVER_CONSTANT; RTC(1); struct rtable *table = rtc->table; ACCESS_RTE; ACCESS_EATTRS; const net_addr *net = (*fs->rte)->net->n.addr; /* We ignore temporary attributes, probably not a problem here */ /* 0x02 is a value of BA_AS_PATH, we don't want to include BGP headers */ eattr *e = ea_find(*fs->eattrs, EA_CODE(PROTOCOL_BGP, 0x02)); if (!e || ((e->type & EAF_TYPE_MASK) != EAF_TYPE_AS_PATH)) runtime("Missing AS_PATH attribute"); u32 as = 0; as_path_get_last(e->u.ptr, &as); if (!table) runtime("Missing ROA table"); if (table->addr_type != NET_ROA4 && table->addr_type != NET_ROA6) runtime("Table type must be either ROA4 or ROA6"); if (table->addr_type != (net->type == NET_IP4 ? NET_ROA4 : NET_ROA6)) RESULT(T_ENUM_ROA, i, ROA_UNKNOWN); /* Prefix and table type mismatch */ else RESULT(T_ENUM_ROA, i, [[ net_roa_check(table, net, as) ]]); } INST(FI_ROA_CHECK_EXPLICIT, 2, 1) { /* ROA Check */ NEVER_CONSTANT; ARG(1, T_NET); ARG(2, T_INT); RTC(3); struct rtable *table = rtc->table; u32 as = v2.val.i; if (!table) runtime("Missing ROA table"); if (table->addr_type != NET_ROA4 && table->addr_type != NET_ROA6) runtime("Table type must be either ROA4 or ROA6"); if (table->addr_type != (v1.val.net->type == NET_IP4 ? NET_ROA4 : NET_ROA6)) RESULT(T_ENUM_ROA, i, ROA_UNKNOWN); /* Prefix and table type mismatch */ else RESULT(T_ENUM_ROA, i, [[ net_roa_check(table, v1.val.net, as) ]]); } INST(FI_FORMAT, 1, 0) { /* Format */ ARG_ANY(1); RESULT(T_STRING, s, val_format_str(fpool, &v1)); } INST(FI_ASSERT, 1, 0) { /* Birdtest Assert */ NEVER_CONSTANT; ARG(1, T_BOOL); FID_MEMBER(char *, s, [[strcmp(f1->s, f2->s)]], "string %s", item->s); ASSERT(s); if (!bt_assert_hook) runtime("No bt_assert hook registered, can't assert"); bt_assert_hook(v1.val.i, what); } bird-2.0.8/filter/decl.m40000664000175000017500000005075714025744326014040 0ustar feelafeelam4_divert(-1)m4_dnl # # BIRD -- Construction of per-instruction structures # # (c) 2018 Maria Matejka # # Can be freely distributed and used under the terms of the GNU GPL. # # THIS IS A M4 MACRO FILE GENERATING 3 FILES ALTOGETHER. # KEEP YOUR HANDS OFF UNLESS YOU KNOW WHAT YOU'RE DOING. # EDITING AND DEBUGGING THIS FILE MAY DAMAGE YOUR BRAIN SERIOUSLY. # # But you're welcome to read and edit and debug if you aren't scared. # # Uncomment the following line to get exhaustive debug output. # m4_debugmode(aceflqtx) # # How it works: # 1) Instruction to code conversion (uses diversions 100..199) # 2) Code wrapping (uses diversions 1..99) # 3) Final preparation (uses diversions 200..299) # 4) Shipout # # See below for detailed description. # # # 1) Instruction to code conversion # The code provided in f-inst.c between consecutive INST() calls # is interleaved for many different places. It is here processed # and split into separate instances where split-by-instruction # happens. These parts are stored in temporary diversions listed: # # 101 content of per-inst struct # 102 constructor arguments # 103 constructor body # 104 dump line item content # (there may be nothing in dump-line content and # it must be handled specially in phase 2) # 105 linearize body # 106 comparator body # 107 struct f_line_item content # 108 interpreter body # 109 iterator body # # Here are macros to allow you to _divert to the right directions. m4_define(FID_STRUCT_IN, `m4_divert(101)') m4_define(FID_NEW_ARGS, `m4_divert(102)') m4_define(FID_NEW_BODY, `m4_divert(103)') m4_define(FID_DUMP_BODY, `m4_divert(104)m4_define([[FID_DUMP_BODY_EXISTS]])') m4_define(FID_LINEARIZE_BODY, `m4_divert(105)') m4_define(FID_SAME_BODY, `m4_divert(106)') m4_define(FID_LINE_IN, `m4_divert(107)') m4_define(FID_INTERPRET_BODY, `m4_divert(108)') m4_define(FID_ITERATE_BODY, `m4_divert(109)') # Sometimes you want slightly different code versions in different # outputs. # Use FID_HIC(code for inst-gen.h, code for inst-gen.c, code for inst-interpret.c) # and put it into [[ ]] quotes if it shall contain commas. m4_define(FID_HIC, `m4_ifelse(TARGET, [[H]], [[$1]], TARGET, [[I]], [[$2]], TARGET, [[C]], [[$3]])') # In interpreter code, this is quite common. m4_define(FID_INTERPRET_EXEC, `FID_HIC(,[[FID_INTERPRET_BODY()]],[[m4_divert(-1)]])') m4_define(FID_INTERPRET_NEW, `FID_HIC(,[[m4_divert(-1)]],[[FID_INTERPRET_BODY()]])') # If the instruction is never converted to constant, the interpret # code is not produced at all for constructor m4_define(NEVER_CONSTANT, `m4_define([[INST_NEVER_CONSTANT]])') m4_define(FID_IFCONST, `m4_ifdef([[INST_NEVER_CONSTANT]],[[$2]],[[$1]])') # If the instruction has some attributes (here called members), # these are typically carried with the instruction from constructor # to interpreter. This yields a line of code everywhere on the path. # FID_MEMBER is a macro to help with this task. m4_define(FID_MEMBER, `m4_dnl FID_LINE_IN()m4_dnl $1 $2; FID_STRUCT_IN()m4_dnl $1 $2; FID_NEW_ARGS()m4_dnl , $1 $2 FID_NEW_BODY()m4_dnl whati->$2 = $2; FID_LINEARIZE_BODY()m4_dnl item->$2 = whati->$2; m4_ifelse($3,,,[[ FID_SAME_BODY()m4_dnl if ($3) return 0; ]]) m4_ifelse($4,,,[[ FID_DUMP_BODY()m4_dnl debug("%s" $4 "\n", INDENT, $5); ]]) FID_INTERPRET_EXEC()m4_dnl const $1 $2 = whati->$2 FID_INTERPRET_BODY') # Instruction arguments are needed only until linearization is done. # This puts the arguments into the filter line to be executed before # the instruction itself. # # To achieve this, ARG_ANY must be called before anything writes into # the instruction line as it moves the instruction pointer forward. m4_define(ARG_ANY, ` FID_STRUCT_IN()m4_dnl struct f_inst * f$1; FID_NEW_ARGS()m4_dnl , struct f_inst * f$1 FID_NEW_BODY()m4_dnl whati->f$1 = f$1; for (const struct f_inst *child = f$1; child; child = child->next) { what->size += child->size; FID_IFCONST([[ if (child->fi_code != FI_CONSTANT) constargs = 0; ]]) } FID_LINEARIZE_BODY pos = linearize(dest, whati->f$1, pos); FID_INTERPRET_BODY()') # Some instructions accept variable number of arguments. m4_define(VARARG, ` FID_NEW_ARGS()m4_dnl , struct f_inst * fvar FID_STRUCT_IN()m4_dnl struct f_inst * fvar; uint varcount; FID_LINE_IN()m4_dnl uint varcount; FID_NEW_BODY()m4_dnl whati->varcount = 0; whati->fvar = fvar; for (const struct f_inst *child = fvar; child; child = child->next, whati->varcount++) { what->size += child->size; FID_IFCONST([[ if (child->fi_code != FI_CONSTANT) constargs = 0; ]]) } FID_IFCONST([[ const struct f_inst **items = NULL; if (constargs && whati->varcount) { items = alloca(whati->varcount * sizeof(struct f_inst *)); const struct f_inst *child = fvar; for (uint i=0; child; i++) child = (items[i] = child)->next; } ]]) FID_LINEARIZE_BODY()m4_dnl pos = linearize(dest, whati->fvar, pos); item->varcount = whati->varcount; FID_DUMP_BODY()m4_dnl debug("%snumber of varargs %u\n", INDENT, item->varcount); FID_SAME_BODY()m4_dnl if (f1->varcount != f2->varcount) return 0; FID_INTERPRET_BODY() FID_HIC(,[[ if (fstk->vcnt < whati->varcount) runtime("Stack underflow"); fstk->vcnt -= whati->varcount; ]],) ') # Some arguments need to check their type. After that, ARG_ANY is called. m4_define(ARG, `ARG_ANY($1) ARG_TYPE($1,$2)') m4_define(ARG_TYPE, `ARG_TYPE_STATIC($1,$2) ARG_TYPE_DYNAMIC($1,$2)') m4_define(ARG_TYPE_STATIC, ` FID_NEW_BODY()m4_dnl if (f$1->type && (f$1->type != ($2)) && !f_const_promotion(f$1, ($2))) cf_error("Argument $1 of %s must be of type %s, got type %s", f_instruction_name(what->fi_code), f_type_name($2), f_type_name(f$1->type)); FID_INTERPRET_BODY()') m4_define(ARG_TYPE_DYNAMIC, ` FID_INTERPRET_EXEC()m4_dnl if (v$1.type != ($2)) runtime("Argument $1 of %s must be of type %s, got type %s", f_instruction_name(what->fi_code), f_type_name($2), f_type_name(v$1.type)); FID_INTERPRET_BODY()') m4_define(ARG_SAME_TYPE, ` FID_NEW_BODY()m4_dnl if (f$1->type && f$2->type && (f$1->type != f$2->type) && !f_const_promotion(f$2, f$1->type) && !f_const_promotion(f$1, f$2->type)) cf_error("Arguments $1 and $2 of %s must be of the same type", f_instruction_name(what->fi_code)); FID_INTERPRET_BODY()') # Executing another filter line. This replaces the recursion # that was needed in the former implementation. m4_define(LINEX, `FID_INTERPRET_EXEC()LINEX_($1)FID_INTERPRET_NEW()return $1 FID_INTERPRET_BODY()') m4_define(LINEX_, `do { fstk->estk[fstk->ecnt].pos = 0; fstk->estk[fstk->ecnt].line = $1; fstk->estk[fstk->ecnt].ventry = fstk->vcnt; fstk->estk[fstk->ecnt].vbase = fstk->estk[fstk->ecnt-1].vbase; fstk->estk[fstk->ecnt].emask = 0; fstk->ecnt++; } while (0)') m4_define(LINE, ` FID_LINE_IN()m4_dnl const struct f_line * fl$1; FID_STRUCT_IN()m4_dnl struct f_inst * f$1; FID_NEW_ARGS()m4_dnl , struct f_inst * f$1 FID_NEW_BODY()m4_dnl whati->f$1 = f$1; FID_DUMP_BODY()m4_dnl f_dump_line(item->fl$1, indent + 1); FID_LINEARIZE_BODY()m4_dnl item->fl$1 = f_linearize(whati->f$1); FID_SAME_BODY()m4_dnl if (!f_same(f1->fl$1, f2->fl$1)) return 0; FID_ITERATE_BODY()m4_dnl if (whati->fl$1) BUFFER_PUSH(fit->lines) = whati->fl$1; FID_INTERPRET_EXEC()m4_dnl do { if (whati->fl$1) { LINEX_(whati->fl$1); } } while(0) FID_INTERPRET_NEW()m4_dnl return whati->f$1 FID_INTERPRET_BODY()') # Some of the instructions have a result. These constructions # state the result and put it to the right place. m4_define(RESULT, `RESULT_TYPE([[$1]]) RESULT_([[$1]],[[$2]],[[$3]])') m4_define(RESULT_, `RESULT_VAL([[ (struct f_val) { .type = $1, .val.$2 = $3 } ]])') m4_define(RESULT_VAL, `FID_HIC(, [[do { res = $1; fstk->vcnt++; } while (0)]], [[return fi_constant(what, $1)]])') m4_define(RESULT_VOID, `RESULT_VAL([[ (struct f_val) { .type = T_VOID } ]])') m4_define(ERROR, `m4_errprint(m4___file__:m4___line__: $* )m4_m4exit(1)') # This macro specifies result type and makes there are no conflicting definitions m4_define(RESULT_TYPE, `m4_ifdef([[INST_RESULT_TYPE]], [[m4_ifelse(INST_RESULT_TYPE,$1,,[[ERROR([[Multiple type definitons]])]])]], [[m4_define(INST_RESULT_TYPE,$1) RESULT_TYPE_($1)]])') m4_define(RESULT_TYPE_, ` FID_NEW_BODY()m4_dnl what->type = $1; FID_INTERPRET_BODY()') # Some common filter instruction members m4_define(SYMBOL, `FID_MEMBER(struct symbol *, sym, [[strcmp(f1->sym->name, f2->sym->name) || (f1->sym->class != f2->sym->class)]], "symbol %s", item->sym->name)') m4_define(RTC, `FID_MEMBER(struct rtable_config *, rtc, [[strcmp(f1->rtc->name, f2->rtc->name)]], "route table %s", item->rtc->name)') m4_define(STATIC_ATTR, `FID_MEMBER(struct f_static_attr, sa, f1->sa.sa_code != f2->sa.sa_code,,)') m4_define(DYNAMIC_ATTR, `FID_MEMBER(struct f_dynamic_attr, da, f1->da.ea_code != f2->da.ea_code,,)') m4_define(ACCESS_RTE, `FID_HIC(,[[do { if (!fs->rte) runtime("No route to access"); } while (0)]],NEVER_CONSTANT())') # 2) Code wrapping # The code produced in 1xx temporary diversions is a raw code without # any auxiliary commands and syntactical structures around. When the # instruction is done, INST_FLUSH is called. More precisely, it is called # at the beginning of INST() call and at the end of file. # # INST_FLUSH picks all the temporary diversions, wraps their content # into appropriate headers and structures and saves them into global # diversions listed: # # 4 enum fi_code # 5 enum fi_code to string # 6 dump line item # 7 dump line item callers # 8 linearize # 9 same (filter comparator) # 10 iterate # 1 union in struct f_inst # 3 constructors + interpreter # # These global diversions contain blocks of code that can be directly # put into the final file, yet it still can't be written out now as # every instruction writes to all of these diversions. # Code wrapping diversion names. Here we want an explicit newline # after the C comment. m4_define(FID_ZONE, `m4_divert($1) /* $2 for INST_NAME() */ ') m4_define(FID_INST, `FID_ZONE(1, Instruction structure for config)') m4_define(FID_LINE, `FID_ZONE(2, Instruction structure for interpreter)') m4_define(FID_NEW, `FID_ZONE(3, Constructor)') m4_define(FID_ENUM, `FID_ZONE(4, Code enum)') m4_define(FID_ENUM_STR, `FID_ZONE(5, Code enum to string)') m4_define(FID_DUMP, `FID_ZONE(6, Dump line)') m4_define(FID_DUMP_CALLER, `FID_ZONE(7, Dump line caller)') m4_define(FID_LINEARIZE, `FID_ZONE(8, Linearize)') m4_define(FID_SAME, `FID_ZONE(9, Comparison)') m4_define(FID_ITERATE, `FID_ZONE(10, Iteration)') # This macro does all the code wrapping. See inline comments. m4_define(INST_FLUSH, `m4_ifdef([[INST_NAME]], [[ FID_ENUM()m4_dnl Contents of enum fi_code { ... } INST_NAME(), FID_ENUM_STR()m4_dnl Contents of const char * indexed by enum fi_code [INST_NAME()] = "INST_NAME()", FID_INST()m4_dnl Anonymous structure inside struct f_inst struct { m4_undivert(101)m4_dnl } i_[[]]INST_NAME(); FID_LINE()m4_dnl Anonymous structure inside struct f_line_item struct { m4_undivert(107)m4_dnl } i_[[]]INST_NAME(); FID_NEW()m4_dnl Constructor and interpreter code together FID_HIC( [[m4_dnl Public declaration of constructor in H file struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code m4_undivert(102)m4_dnl );]], [[m4_dnl The one case in The Big Switch inside interpreter case INST_NAME(): #define whati (&(what->i_]]INST_NAME()[[)) m4_ifelse(m4_eval(INST_INVAL() > 0), 1, [[if (fstk->vcnt < INST_INVAL()) runtime("Stack underflow"); fstk->vcnt -= INST_INVAL(); ]]) m4_undivert(108)m4_dnl #undef whati break; ]], [[m4_dnl Constructor itself struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code m4_undivert(102)m4_dnl ) { /* Allocate the structure */ struct f_inst *what = fi_new(fi_code); FID_IFCONST([[uint constargs = 1;]]) /* Initialize all the members */ #define whati (&(what->i_]]INST_NAME()[[)) m4_undivert(103)m4_dnl /* If not constant, return the instruction itself */ FID_IFCONST([[if (!constargs)]]) return what; /* Try to pre-calculate the result */ FID_IFCONST([[m4_undivert(108)]])m4_dnl #undef whati } ]]) FID_DUMP_CALLER()m4_dnl Case in another big switch used in instruction dumping (debug) case INST_NAME(): f_dump_line_item_]]INST_NAME()[[(item, indent + 1); break; FID_DUMP()m4_dnl The dumper itself m4_ifdef([[FID_DUMP_BODY_EXISTS]], [[static inline void f_dump_line_item_]]INST_NAME()[[(const struct f_line_item *item_, const int indent)]], [[static inline void f_dump_line_item_]]INST_NAME()[[(const struct f_line_item *item UNUSED, const int indent UNUSED)]]) m4_undefine([[FID_DUMP_BODY_EXISTS]]) { #define item (&(item_->i_]]INST_NAME()[[)) m4_undivert(104)m4_dnl #undef item } FID_LINEARIZE()m4_dnl The linearizer case INST_NAME(): { #define whati (&(what->i_]]INST_NAME()[[)) #define item (&(dest->items[pos].i_]]INST_NAME()[[)) m4_undivert(105)m4_dnl #undef whati #undef item dest->items[pos].fi_code = what->fi_code; dest->items[pos].lineno = what->lineno; break; } FID_SAME()m4_dnl This code compares two f_line"s while reconfiguring case INST_NAME(): #define f1 (&(f1_->i_]]INST_NAME()[[)) #define f2 (&(f2_->i_]]INST_NAME()[[)) m4_undivert(106)m4_dnl #undef f1 #undef f2 break; FID_ITERATE()m4_dnl The iterator case INST_NAME(): #define whati (&(what->i_]]INST_NAME()[[)) m4_undivert(109)m4_dnl #undef whati break; m4_divert(-1)FID_FLUSH(101,200)m4_dnl And finally this flushes all the unused diversions ]])') m4_define(INST, `m4_dnl This macro is called on beginning of each instruction. INST_FLUSH()m4_dnl First, old data is flushed m4_define([[INST_NAME]], [[$1]])m4_dnl Then we store instruction name, m4_define([[INST_INVAL]], [[$2]])m4_dnl instruction input value count, m4_undefine([[INST_NEVER_CONSTANT]])m4_dnl reset NEVER_CONSTANT trigger, m4_undefine([[INST_RESULT_TYPE]])m4_dnl and reset RESULT_TYPE value. FID_INTERPRET_BODY()m4_dnl By default, every code is interpreter code. ') # 3) Final preparation # # Now we prepare all the code around the global diversions. # It must be here, not in m4wrap, as we want M4 to mark the code # by #line directives correctly, not to claim that every single line # is at the beginning of the m4wrap directive. # # This part is split by the final file. # H for inst-gen.h # I for inst-interpret.c # C for inst-gen.c # # So we in cycle: # A. open a diversion # B. send there some code # C. close that diversion # D. flush a global diversion # E. open another diversion and goto B. # # Final diversions # 200+ completed text before it is flushed to output # This is a list of output diversions m4_define(FID_WR_PUT_LIST) # This macro does the steps C to E, see before. m4_define(FID_WR_PUT_ALSO, `m4_define([[FID_WR_PUT_LIST]],FID_WR_PUT_LIST()[[FID_WR_DPUT(]]FID_WR_DIDX[[)FID_WR_DPUT(]]$1[[)]])m4_define([[FID_WR_DIDX]],m4_eval(FID_WR_DIDX+1))m4_divert(FID_WR_DIDX)') # These macros do the splitting between H/I/C m4_define(FID_WR_DIRECT, `m4_ifelse(TARGET,[[$1]],[[FID_WR_INIT()]],[[FID_WR_STOP()]])') m4_define(FID_WR_INIT, `m4_define([[FID_WR_DIDX]],200)m4_define([[FID_WR_PUT]],[[FID_WR_PUT_ALSO($]][[@)]])m4_divert(200)') m4_define(FID_WR_STOP, `m4_define([[FID_WR_PUT]])m4_divert(-1)') # Here is the direct code to be put into the output files # together with the undiversions, being hidden under FID_WR_PUT() m4_changequote([[,]]) FID_WR_DIRECT(I) FID_WR_PUT(3) FID_WR_DIRECT(C) #if defined(__GNUC__) && __GNUC__ >= 6 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif #include "nest/bird.h" #include "filter/filter.h" #include "filter/f-inst.h" /* Instruction codes to string */ static const char * const f_instruction_name_str[] = { FID_WR_PUT(5) }; const char * f_instruction_name_(enum f_instruction_code fi) { if (fi < (sizeof(f_instruction_name_str) / sizeof(f_instruction_name_str[0]))) return f_instruction_name_str[fi]; else bug("Got unknown instruction code: %d", fi); } static inline struct f_inst * fi_new(enum f_instruction_code fi_code) { struct f_inst *what = cfg_allocz(sizeof(struct f_inst)); what->lineno = ifs->lino; what->size = 1; what->fi_code = fi_code; return what; } static inline struct f_inst * fi_constant(struct f_inst *what, struct f_val val) { what->fi_code = FI_CONSTANT; what->i_FI_CONSTANT.val = val; return what; } static int f_const_promotion(struct f_inst *arg, enum f_type want) { if (arg->fi_code != FI_CONSTANT) return 0; struct f_val *c = &arg->i_FI_CONSTANT.val; if ((c->type == T_IP) && ipa_is_ip4(c->val.ip) && (want == T_QUAD)) { *c = (struct f_val) { .type = T_QUAD, .val.i = ipa_to_u32(c->val.ip), }; return 1; } return 0; } #define v1 whati->f1->i_FI_CONSTANT.val #define v2 whati->f2->i_FI_CONSTANT.val #define v3 whati->f3->i_FI_CONSTANT.val #define vv(i) items[i]->i_FI_CONSTANT.val #define runtime(fmt, ...) cf_error("filter preevaluation, line %d: " fmt, ifs->lino, ##__VA_ARGS__) #define fpool cfg_mem #define falloc(size) cfg_alloc(size) /* Instruction constructors */ FID_WR_PUT(3) #undef v1 #undef v2 #undef v3 #undef vv /* Line dumpers */ #define INDENT (((const char *) f_dump_line_indent_str) + sizeof(f_dump_line_indent_str) - (indent) - 1) static const char f_dump_line_indent_str[] = " "; FID_WR_PUT(6) void f_dump_line(const struct f_line *dest, uint indent) { if (!dest) { debug("%sNo filter line (NULL)\n", INDENT); return; } debug("%sFilter line %p (len=%u)\n", INDENT, dest, dest->len); for (uint i=0; ilen; i++) { const struct f_line_item *item = &dest->items[i]; debug("%sInstruction %s at line %u\n", INDENT, f_instruction_name_(item->fi_code), item->lineno); switch (item->fi_code) { FID_WR_PUT(7) default: bug("Unknown instruction %x in f_dump_line", item->fi_code); } } debug("%sFilter line %p dump done\n", INDENT, dest); } /* Linearize */ static uint linearize(struct f_line *dest, const struct f_inst *what, uint pos) { for ( ; what; what = what->next) { switch (what->fi_code) { FID_WR_PUT(8) } pos++; } return pos; } struct f_line * f_linearize_concat(const struct f_inst * const inst[], uint count) { uint len = 0; for (uint i=0; inext) len += what->size; struct f_line *out = cfg_allocz(sizeof(struct f_line) + sizeof(struct f_line_item)*len); for (uint i=0; ilen = linearize(out, inst[i], out->len); #ifdef LOCAL_DEBUG f_dump_line(out, 0); #endif return out; } /* Filter line comparison */ int f_same(const struct f_line *fl1, const struct f_line *fl2) { if ((!fl1) && (!fl2)) return 1; if ((!fl1) || (!fl2)) return 0; if (fl1->len != fl2->len) return 0; for (uint i=0; ilen; i++) { #define f1_ (&(fl1->items[i])) #define f2_ (&(fl2->items[i])) if (f1_->fi_code != f2_->fi_code) return 0; if (f1_->flags != f2_->flags) return 0; switch(f1_->fi_code) { FID_WR_PUT(9) } } #undef f1_ #undef f2_ return 1; } /* Part of FI_SWITCH filter iterator */ static void f_add_tree_lines(const struct f_tree *t, void *fit_) { struct filter_iterator * fit = fit_; if (t->data) BUFFER_PUSH(fit->lines) = t->data; } /* Filter line iterator */ void f_add_lines(const struct f_line_item *what, struct filter_iterator *fit) { switch(what->fi_code) { FID_WR_PUT(10) } } #if defined(__GNUC__) && __GNUC__ >= 6 #pragma GCC diagnostic pop #endif FID_WR_DIRECT(H) /* Filter instruction codes */ enum f_instruction_code { FID_WR_PUT(4)m4_dnl } PACKED; /* Filter instruction structure for config */ struct f_inst { struct f_inst *next; /* Next instruction */ enum f_instruction_code fi_code; /* Instruction code */ enum f_type type; /* Type of returned value, if known */ int size; /* How many instructions are underneath */ int lineno; /* Line number */ union { FID_WR_PUT(1)m4_dnl }; }; /* Filter line item */ struct f_line_item { enum f_instruction_code fi_code; /* What to do */ enum f_instruction_flags flags; /* Flags, instruction-specific */ uint lineno; /* Where */ union { FID_WR_PUT(2)m4_dnl }; }; /* Instruction constructors */ FID_WR_PUT(3) m4_divert(-1) # 4) Shipout # # Everything is prepared in FID_WR_PUT_LIST now. Let's go! m4_changequote(`,') # Flusher auxiliary macro m4_define(FID_FLUSH, `m4_ifelse($1,$2,,[[m4_undivert($1)FID_FLUSH(m4_eval($1+1),$2)]])') # Defining the macro used in FID_WR_PUT_LIST m4_define(FID_WR_DPUT, `m4_undivert($1)') # After the code is read and parsed, we: m4_m4wrap(`INST_FLUSH()m4_divert(0)FID_WR_PUT_LIST()m4_divert(-1)FID_FLUSH(1,200)') m4_changequote([[,]]) # And now M4 is going to parse f-inst.c, fill the diversions # and after the file is done, the content of m4_m4wrap (see before) # is executed. bird-2.0.8/filter/data.h0000664000175000017500000001347014025744326013740 0ustar feelafeela/* * BIRD Internet Routing Daemon -- Dynamic data structures * * (c) 1999 Pavel Machek * (c) 2018--2019 Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_FILTER_DATA_H_ #define _BIRD_FILTER_DATA_H_ #include "nest/bird.h" /* Type numbers must be in 0..0xff range */ #define T_MASK 0xff /* Internal types */ enum f_type { /* Nothing. Simply nothing. */ T_VOID = 0, /* User visible types, which fit in int */ T_INT = 0x10, T_BOOL = 0x11, T_PAIR = 0x12, /* Notice that pair is stored as integer: first << 16 | second */ T_QUAD = 0x13, /* Put enumerational types in 0x30..0x3f range */ T_ENUM_LO = 0x30, T_ENUM_HI = 0x3f, T_ENUM_RTS = 0x30, T_ENUM_BGP_ORIGIN = 0x31, T_ENUM_SCOPE = 0x32, T_ENUM_RTC = 0x33, T_ENUM_RTD = 0x34, T_ENUM_ROA = 0x35, T_ENUM_NETTYPE = 0x36, T_ENUM_RA_PREFERENCE = 0x37, T_ENUM_AF = 0x38, /* new enums go here */ T_ENUM_EMPTY = 0x3f, /* Special hack for atomic_aggr */ #define T_ENUM T_ENUM_LO ... T_ENUM_HI /* Bigger ones */ T_IP = 0x20, T_NET = 0x21, T_STRING = 0x22, T_PATH_MASK = 0x23, /* mask for BGP path */ T_PATH = 0x24, /* BGP path */ T_CLIST = 0x25, /* Community list */ T_EC = 0x26, /* Extended community value, u64 */ T_ECLIST = 0x27, /* Extended community list */ T_LC = 0x28, /* Large community value, lcomm */ T_LCLIST = 0x29, /* Large community list */ T_RD = 0x2a, /* Route distinguisher for VPN addresses */ T_PATH_MASK_ITEM = 0x2b, /* Path mask item for path mask constructors */ T_SET = 0x80, T_PREFIX_SET = 0x81, } PACKED; /* Filter value; size of this affects filter memory consumption */ struct f_val { enum f_type type; /* T_* */ union { uint i; u64 ec; lcomm lc; ip_addr ip; const net_addr *net; const char *s; const struct f_tree *t; const struct f_trie *ti; const struct adata *ad; const struct f_path_mask *path_mask; struct f_path_mask_item pmi; } val; }; /* Dynamic attribute definition (eattrs) */ struct f_dynamic_attr { u8 type; /* EA type (EAF_*) */ u8 bit; /* For bitfield accessors */ enum f_type f_type; /* Filter type */ uint ea_code; /* EA code */ }; enum f_sa_code { SA_FROM = 1, SA_GW, SA_NET, SA_PROTO, SA_SOURCE, SA_SCOPE, SA_DEST, SA_IFNAME, SA_IFINDEX, SA_WEIGHT, } PACKED; /* Static attribute definition (members of struct rta) */ struct f_static_attr { enum f_type f_type; /* Filter type */ enum f_sa_code sa_code; /* Static attribute id */ int readonly:1; /* Don't allow writing */ }; /* Filter l-value type */ enum f_lval_type { F_LVAL_VARIABLE, F_LVAL_PREFERENCE, F_LVAL_SA, F_LVAL_EA, }; /* Filter l-value */ struct f_lval { enum f_lval_type type; union { struct symbol *sym; struct f_dynamic_attr da; struct f_static_attr sa; }; }; /* IP prefix range structure */ struct f_prefix { net_addr net; /* The matching prefix must match this net */ u8 lo, hi; /* And its length must fit between lo and hi */ }; struct f_tree { struct f_tree *left, *right; struct f_val from, to; void *data; }; struct f_trie_node4 { ip4_addr addr, mask, accept; uint plen; struct f_trie_node4 *c[2]; }; struct f_trie_node6 { ip6_addr addr, mask, accept; uint plen; struct f_trie_node6 *c[2]; }; struct f_trie_node { union { struct f_trie_node4 v4; struct f_trie_node6 v6; }; }; struct f_trie { linpool *lp; u8 zero; s8 ipv4; /* -1 for undefined / empty */ u16 data_size; /* Additional data for each trie node */ struct f_trie_node root; /* Root trie node */ }; struct f_tree *f_new_tree(void); struct f_tree *build_tree(struct f_tree *); const struct f_tree *find_tree(const struct f_tree *t, const struct f_val *val); int same_tree(const struct f_tree *t0, const struct f_tree *t2); void tree_format(const struct f_tree *t, buffer *buf); void tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data); struct f_trie *f_new_trie(linpool *lp, uint data_size); void *trie_add_prefix(struct f_trie *t, const net_addr *n, uint l, uint h); int trie_match_net(const struct f_trie *t, const net_addr *n); int trie_same(const struct f_trie *t1, const struct f_trie *t2); void trie_format(const struct f_trie *t, buffer *buf); #define F_CMP_ERROR 999 const char *f_type_name(enum f_type t); int val_same(const struct f_val *v1, const struct f_val *v2); int val_compare(const struct f_val *v1, const struct f_val *v2); void val_format(const struct f_val *v, buffer *buf); char *val_format_str(struct linpool *lp, const struct f_val *v); const char *val_dump(const struct f_val *v); static inline int val_is_ip4(const struct f_val *v) { return (v->type == T_IP) && ipa_is_ip4(v->val.ip); } int val_in_range(const struct f_val *v1, const struct f_val *v2); int clist_set_type(const struct f_tree *set, struct f_val *v); static inline int eclist_set_type(const struct f_tree *set) { return set->from.type == T_EC; } static inline int lclist_set_type(const struct f_tree *set) { return set->from.type == T_LC; } const struct adata *clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); /* Special undef value for paths and clists */ static inline int undef_value(struct f_val v) { return ((v.type == T_PATH) || (v.type == T_CLIST) || (v.type == T_ECLIST) || (v.type == T_LCLIST)) && (v.val.ad == &null_adata); } extern const struct f_val f_const_empty_path, f_const_empty_clist, f_const_empty_eclist, f_const_empty_lclist; enum filter_return f_eval(const struct f_line *expr, struct linpool *tmp_pool, struct f_val *pres); #endif bird-2.0.8/filter/data.c0000664000175000017500000003353714025744326013741 0ustar feelafeela/* * Filters: utility functions * * (c) 1998 Pavel Machek * (c) 2019 Maria Matejka * * Can be freely distributed and used under the terms of the GNU GPL. * */ #include "nest/bird.h" #include "lib/lists.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/string.h" #include "lib/unaligned.h" #include "lib/net.h" #include "lib/ip.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "nest/attrs.h" #include "conf/conf.h" #include "filter/filter.h" #include "filter/f-inst.h" #include "filter/data.h" static const char * const f_type_str[] = { [T_VOID] = "void", [T_INT] = "int", [T_BOOL] = "bool", [T_PAIR] = "pair", [T_QUAD] = "quad", [T_ENUM_RTS] = "enum rts", [T_ENUM_BGP_ORIGIN] = "enum bgp_origin", [T_ENUM_SCOPE] = "enum scope", [T_ENUM_RTC] = "enum rtc", [T_ENUM_RTD] = "enum rtd", [T_ENUM_ROA] = "enum roa", [T_ENUM_NETTYPE] = "enum nettype", [T_ENUM_RA_PREFERENCE] = "enum ra_preference", [T_ENUM_AF] = "enum af", [T_IP] = "ip", [T_NET] = "prefix", [T_STRING] = "string", [T_PATH_MASK] = "bgpmask", [T_PATH] = "bgppath", [T_CLIST] = "clist", [T_EC] = "ec", [T_ECLIST] = "eclist", [T_LC] = "lc", [T_LCLIST] = "lclist", [T_RD] = "rd", }; const char * f_type_name(enum f_type t) { if (t < ARRAY_SIZE(f_type_str)) return f_type_str[t] ?: "?"; if ((t == T_SET) || (t == T_PREFIX_SET)) return "set"; return "?"; } const struct f_val f_const_empty_path = { .type = T_PATH, .val.ad = &null_adata, }, f_const_empty_clist = { .type = T_CLIST, .val.ad = &null_adata, }, f_const_empty_eclist = { .type = T_ECLIST, .val.ad = &null_adata, }, f_const_empty_lclist = { .type = T_LCLIST, .val.ad = &null_adata, }; static struct adata * adata_empty(struct linpool *pool, int l) { struct adata *res = lp_alloc(pool, sizeof(struct adata) + l); res->length = l; return res; } static void pm_format(const struct f_path_mask *p, buffer *buf) { int loop = 0; buffer_puts(buf, "[= "); for (uint i=0; ilen; i++) { switch(p->item[i].kind) { case PM_ASN: buffer_print(buf, "%u ", p->item[i].asn); break; case PM_QUESTION: buffer_puts(buf, "? "); break; case PM_ASTERISK: buffer_puts(buf, "* "); break; case PM_LOOP: loop = 1; break; case PM_ASN_RANGE: buffer_print(buf, "%u..%u ", p->item[i].from, p->item[i].to); break; case PM_ASN_SET: tree_format(p->item[i].set, buf); buffer_puts(buf, " "); break; case PM_ASN_EXPR: ASSERT(0); } if (loop && (p->item[i].kind != PM_LOOP)) { buffer_puts(buf, "+ "); loop = 0; } } buffer_puts(buf, "=]"); } static inline int lcomm_cmp(lcomm v1, lcomm v2) { if (v1.asn != v2.asn) return (v1.asn > v2.asn) ? 1 : -1; if (v1.ldp1 != v2.ldp1) return (v1.ldp1 > v2.ldp1) ? 1 : -1; if (v1.ldp2 != v2.ldp2) return (v1.ldp2 > v2.ldp2) ? 1 : -1; return 0; } /** * val_compare - compare two values * @v1: first value * @v2: second value * * Compares two values and returns -1, 0, 1 on <, =, > or F_CMP_ERROR on * error. Tree module relies on this giving consistent results so * that it can be used for building balanced trees. */ int val_compare(const struct f_val *v1, const struct f_val *v2) { if (v1->type != v2->type) { if (v1->type == T_VOID) /* Hack for else */ return -1; if (v2->type == T_VOID) return 1; /* IP->Quad implicit conversion */ if ((v1->type == T_QUAD) && val_is_ip4(v2)) return uint_cmp(v1->val.i, ipa_to_u32(v2->val.ip)); if (val_is_ip4(v1) && (v2->type == T_QUAD)) return uint_cmp(ipa_to_u32(v1->val.ip), v2->val.i); debug( "Types do not match in val_compare\n" ); return F_CMP_ERROR; } switch (v1->type) { case T_VOID: return 0; case T_ENUM: case T_INT: case T_BOOL: case T_PAIR: case T_QUAD: return uint_cmp(v1->val.i, v2->val.i); case T_EC: case T_RD: return u64_cmp(v1->val.ec, v2->val.ec); case T_LC: return lcomm_cmp(v1->val.lc, v2->val.lc); case T_IP: return ipa_compare(v1->val.ip, v2->val.ip); case T_NET: return net_compare(v1->val.net, v2->val.net); case T_STRING: return strcmp(v1->val.s, v2->val.s); default: return F_CMP_ERROR; } } static inline int pmi_same(const struct f_path_mask_item *mi1, const struct f_path_mask_item *mi2) { if (mi1->kind != mi2->kind) return 0; switch (mi1->kind) { case PM_ASN: if (mi1->asn != mi2->asn) return 0; break; case PM_ASN_EXPR: if (!f_same(mi1->expr, mi2->expr)) return 0; break; case PM_ASN_RANGE: if (mi1->from != mi2->from) return 0; if (mi1->to != mi2->to) return 0; break; case PM_ASN_SET: if (!same_tree(mi1->set, mi2->set)) return 0; break; } return 1; } static int pm_same(const struct f_path_mask *m1, const struct f_path_mask *m2) { if (m1->len != m2->len) return 0; for (uint i=0; ilen; i++) if (!pmi_same(&(m1->item[i]), &(m2->item[i]))) return 0; return 1; } /** * val_same - compare two values * @v1: first value * @v2: second value * * Compares two values and returns 1 if they are same and 0 if not. * Comparison of values of different types is valid and returns 0. */ int val_same(const struct f_val *v1, const struct f_val *v2) { int rc; rc = val_compare(v1, v2); if (rc != F_CMP_ERROR) return !rc; if (v1->type != v2->type) return 0; switch (v1->type) { case T_PATH_MASK: return pm_same(v1->val.path_mask, v2->val.path_mask); case T_PATH_MASK_ITEM: return pmi_same(&(v1->val.pmi), &(v2->val.pmi)); case T_PATH: case T_CLIST: case T_ECLIST: case T_LCLIST: return adata_same(v1->val.ad, v2->val.ad); case T_SET: return same_tree(v1->val.t, v2->val.t); case T_PREFIX_SET: return trie_same(v1->val.ti, v2->val.ti); default: bug("Invalid type in val_same(): %x", v1->type); } } int clist_set_type(const struct f_tree *set, struct f_val *v) { switch (set->from.type) { case T_PAIR: v->type = T_PAIR; return 1; case T_QUAD: v->type = T_QUAD; return 1; case T_IP: if (val_is_ip4(&(set->from)) && val_is_ip4(&(set->to))) { v->type = T_QUAD; return 1; } /* Fall through */ default: v->type = T_VOID; return 0; } } static int clist_match_set(const struct adata *clist, const struct f_tree *set) { if (!clist) return 0; struct f_val v; if (!clist_set_type(set, &v)) return F_CMP_ERROR; u32 *l = (u32 *) clist->data; u32 *end = l + clist->length/4; while (l < end) { v.val.i = *l++; if (find_tree(set, &v)) return 1; } return 0; } static int eclist_match_set(const struct adata *list, const struct f_tree *set) { if (!list) return 0; if (!eclist_set_type(set)) return F_CMP_ERROR; struct f_val v; u32 *l = int_set_get_data(list); int len = int_set_get_size(list); int i; v.type = T_EC; for (i = 0; i < len; i += 2) { v.val.ec = ec_get(l, i); if (find_tree(set, &v)) return 1; } return 0; } static int lclist_match_set(const struct adata *list, const struct f_tree *set) { if (!list) return 0; if (!lclist_set_type(set)) return F_CMP_ERROR; struct f_val v; u32 *l = int_set_get_data(list); int len = int_set_get_size(list); int i; v.type = T_LC; for (i = 0; i < len; i += 3) { v.val.lc = lc_get(l, i); if (find_tree(set, &v)) return 1; } return 0; } const struct adata * clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos) { if (!list) return NULL; int tree = (set->type == T_SET); /* 1 -> set is T_SET, 0 -> set is T_CLIST */ struct f_val v; if (tree) clist_set_type(set->val.t, &v); else v.type = T_PAIR; int len = int_set_get_size(list); u32 *l = int_set_get_data(list); u32 tmp[len]; u32 *k = tmp; u32 *end = l + len; while (l < end) { v.val.i = *l++; /* pos && member(val, set) || !pos && !member(val, set), member() depends on tree */ if ((tree ? !!find_tree(set->val.t, &v) : int_set_contains(set->val.ad, v.val.i)) == pos) *k++ = v.val.i; } uint nl = (k - tmp) * sizeof(u32); if (nl == list->length) return list; struct adata *res = adata_empty(pool, nl); memcpy(res->data, tmp, nl); return res; } const struct adata * eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos) { if (!list) return NULL; int tree = (set->type == T_SET); /* 1 -> set is T_SET, 0 -> set is T_CLIST */ struct f_val v; int len = int_set_get_size(list); u32 *l = int_set_get_data(list); u32 tmp[len]; u32 *k = tmp; int i; v.type = T_EC; for (i = 0; i < len; i += 2) { v.val.ec = ec_get(l, i); /* pos && member(val, set) || !pos && !member(val, set), member() depends on tree */ if ((tree ? !!find_tree(set->val.t, &v) : ec_set_contains(set->val.ad, v.val.ec)) == pos) { *k++ = l[i]; *k++ = l[i+1]; } } uint nl = (k - tmp) * sizeof(u32); if (nl == list->length) return list; struct adata *res = adata_empty(pool, nl); memcpy(res->data, tmp, nl); return res; } const struct adata * lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos) { if (!list) return NULL; int tree = (set->type == T_SET); /* 1 -> set is T_SET, 0 -> set is T_CLIST */ struct f_val v; int len = int_set_get_size(list); u32 *l = int_set_get_data(list); u32 tmp[len]; u32 *k = tmp; int i; v.type = T_LC; for (i = 0; i < len; i += 3) { v.val.lc = lc_get(l, i); /* pos && member(val, set) || !pos && !member(val, set), member() depends on tree */ if ((tree ? !!find_tree(set->val.t, &v) : lc_set_contains(set->val.ad, v.val.lc)) == pos) k = lc_copy(k, l+i); } uint nl = (k - tmp) * sizeof(u32); if (nl == list->length) return list; struct adata *res = adata_empty(pool, nl); memcpy(res->data, tmp, nl); return res; } /** * val_in_range - implement |~| operator * @v1: element * @v2: set * * Checks if @v1 is element (|~| operator) of @v2. */ int val_in_range(const struct f_val *v1, const struct f_val *v2) { if ((v1->type == T_PATH) && (v2->type == T_PATH_MASK)) return as_path_match(v1->val.ad, v2->val.path_mask); if ((v1->type == T_INT) && (v2->type == T_PATH)) return as_path_contains(v2->val.ad, v1->val.i, 1); if (((v1->type == T_PAIR) || (v1->type == T_QUAD)) && (v2->type == T_CLIST)) return int_set_contains(v2->val.ad, v1->val.i); /* IP->Quad implicit conversion */ if (val_is_ip4(v1) && (v2->type == T_CLIST)) return int_set_contains(v2->val.ad, ipa_to_u32(v1->val.ip)); if ((v1->type == T_EC) && (v2->type == T_ECLIST)) return ec_set_contains(v2->val.ad, v1->val.ec); if ((v1->type == T_LC) && (v2->type == T_LCLIST)) return lc_set_contains(v2->val.ad, v1->val.lc); if ((v1->type == T_STRING) && (v2->type == T_STRING)) return patmatch(v2->val.s, v1->val.s); if ((v1->type == T_IP) && (v2->type == T_NET)) return ipa_in_netX(v1->val.ip, v2->val.net); if ((v1->type == T_NET) && (v2->type == T_NET)) return net_in_netX(v1->val.net, v2->val.net); if ((v1->type == T_NET) && (v2->type == T_PREFIX_SET)) return trie_match_net(v2->val.ti, v1->val.net); if (v2->type != T_SET) return F_CMP_ERROR; /* With integrated Quad<->IP implicit conversion */ if ((v1->type == v2->val.t->from.type) || ((v1->type == T_QUAD) && val_is_ip4(&(v2->val.t->from)) && val_is_ip4(&(v2->val.t->to)))) return !!find_tree(v2->val.t, v1); if (v1->type == T_CLIST) return clist_match_set(v1->val.ad, v2->val.t); if (v1->type == T_ECLIST) return eclist_match_set(v1->val.ad, v2->val.t); if (v1->type == T_LCLIST) return lclist_match_set(v1->val.ad, v2->val.t); if (v1->type == T_PATH) return as_path_match_set(v1->val.ad, v2->val.t); return F_CMP_ERROR; } /* * val_format - format filter value */ void val_format(const struct f_val *v, buffer *buf) { char buf2[1024]; switch (v->type) { case T_VOID: buffer_puts(buf, "(void)"); return; case T_BOOL: buffer_puts(buf, v->val.i ? "TRUE" : "FALSE"); return; case T_INT: buffer_print(buf, "%u", v->val.i); return; case T_STRING: buffer_print(buf, "%s", v->val.s); return; case T_IP: buffer_print(buf, "%I", v->val.ip); return; case T_NET: buffer_print(buf, "%N", v->val.net); return; case T_PAIR: buffer_print(buf, "(%u,%u)", v->val.i >> 16, v->val.i & 0xffff); return; case T_QUAD: buffer_print(buf, "%R", v->val.i); return; case T_EC: ec_format(buf2, v->val.ec); buffer_print(buf, "%s", buf2); return; case T_LC: lc_format(buf2, v->val.lc); buffer_print(buf, "%s", buf2); return; case T_RD: rd_format(v->val.ec, buf2, 1024); buffer_print(buf, "%s", buf2); return; case T_PREFIX_SET: trie_format(v->val.ti, buf); return; case T_SET: tree_format(v->val.t, buf); return; case T_ENUM: buffer_print(buf, "(enum %x)%u", v->type, v->val.i); return; case T_PATH: as_path_format(v->val.ad, buf2, 1000); buffer_print(buf, "(path %s)", buf2); return; case T_CLIST: int_set_format(v->val.ad, 1, -1, buf2, 1000); buffer_print(buf, "(clist %s)", buf2); return; case T_ECLIST: ec_set_format(v->val.ad, -1, buf2, 1000); buffer_print(buf, "(eclist %s)", buf2); return; case T_LCLIST: lc_set_format(v->val.ad, -1, buf2, 1000); buffer_print(buf, "(lclist %s)", buf2); return; case T_PATH_MASK: pm_format(v->val.path_mask, buf); return; default: buffer_print(buf, "[unknown type %x]", v->type); return; } } char * val_format_str(struct linpool *lp, const struct f_val *v) { buffer b; LOG_BUFFER_INIT(b); val_format(v, &b); return lp_strdup(lp, b.start); } static char val_dump_buffer[1024]; const char * val_dump(const struct f_val *v) { static buffer b = { .start = val_dump_buffer, .end = val_dump_buffer + 1024, }; b.pos = b.start; val_format(v, &b); return val_dump_buffer; } bird-2.0.8/filter/config.Y0000664000175000017500000006375314025744326014266 0ustar feelafeela/* * BIRD - filters * * Copyright 1998--2000 Pavel Machek * * Can be freely distributed and used under the terms of the GNU GPL. * FIXME: priority of ! should be lower */ CF_HDR #include "filter/f-inst.h" #include "filter/data.h" CF_DEFINES static inline u32 pair(u32 a, u32 b) { return (a << 16) | b; } static inline u32 pair_a(u32 p) { return p >> 16; } static inline u32 pair_b(u32 p) { return p & 0xFFFF; } #define f_generate_complex(fi_code, da, arg) \ f_new_inst(FI_EA_SET, f_new_inst(fi_code, f_new_inst(FI_EA_GET, da), arg), da) /* * Sets and their items are during parsing handled as lists, linked * through left ptr. The first item in a list also contains a pointer * to the last item in a list (right ptr). For convenience, even items * are handled as one-item lists. Lists are merged by f_merge_items(). */ static int f_valid_set_type(int type) { switch (type) { case T_INT: case T_PAIR: case T_QUAD: case T_ENUM: case T_IP: case T_EC: case T_LC: case T_RD: return 1; default: return 0; } } static inline struct f_tree * f_new_item(struct f_val from, struct f_val to) { struct f_tree *t = f_new_tree(); t->right = t; t->from = from; t->to = to; return t; } static inline struct f_tree * f_merge_items(struct f_tree *a, struct f_tree *b) { if (!a) return b; a->right->left = b; a->right = b->right; b->right = NULL; return a; } static inline struct f_tree * f_new_pair_item(int fa, int ta, int fb, int tb) { check_u16(fa); check_u16(ta); check_u16(fb); check_u16(tb); if ((ta < fa) || (tb < fb)) cf_error( "From value cannot be higher that To value in pair sets"); struct f_tree *t = f_new_tree(); t->right = t; t->from.type = t->to.type = T_PAIR; t->from.val.i = pair(fa, fb); t->to.val.i = pair(ta, tb); return t; } static inline struct f_tree * f_new_pair_set(int fa, int ta, int fb, int tb) { check_u16(fa); check_u16(ta); check_u16(fb); check_u16(tb); if ((ta < fa) || (tb < fb)) cf_error( "From value cannot be higher that To value in pair sets"); struct f_tree *lst = NULL; int i; for (i = fa; i <= ta; i++) lst = f_merge_items(lst, f_new_pair_item(i, i, fb, tb)); return lst; } #define CC_ALL 0xFFFF #define EC_ALL 0xFFFFFFFF #define LC_ALL 0xFFFFFFFF static struct f_tree * f_new_ec_item(u32 kind, u32 ipv4_used, u32 key, u32 vf, u32 vt) { u64 fm, to; if ((kind != EC_GENERIC) && (ipv4_used || (key >= 0x10000))) { check_u16(vf); if (vt == EC_ALL) vt = 0xFFFF; else check_u16(vt); } if (kind == EC_GENERIC) { fm = ec_generic(key, vf); to = ec_generic(key, vt); } else if (ipv4_used) { fm = ec_ip4(kind, key, vf); to = ec_ip4(kind, key, vt); } else if (key < 0x10000) { fm = ec_as2(kind, key, vf); to = ec_as2(kind, key, vt); } else { fm = ec_as4(kind, key, vf); to = ec_as4(kind, key, vt); } struct f_tree *t = f_new_tree(); t->right = t; t->from.type = t->to.type = T_EC; t->from.val.ec = fm; t->to.val.ec = to; return t; } static struct f_tree * f_new_lc_item(u32 f1, u32 t1, u32 f2, u32 t2, u32 f3, u32 t3) { struct f_tree *t = f_new_tree(); t->right = t; t->from.type = t->to.type = T_LC; t->from.val.lc = (lcomm) {f1, f2, f3}; t->to.val.lc = (lcomm) {t1, t2, t3}; return t; } static inline struct f_inst * f_generate_empty(struct f_dynamic_attr dyn) { struct f_val empty; switch (dyn.type & EAF_TYPE_MASK) { case EAF_TYPE_AS_PATH: empty = f_const_empty_path; break; case EAF_TYPE_INT_SET: empty = f_const_empty_clist; break; case EAF_TYPE_EC_SET: empty = f_const_empty_eclist; break; case EAF_TYPE_LC_SET: empty = f_const_empty_lclist; break; default: cf_error("Can't empty that attribute"); } return f_new_inst(FI_EA_SET, f_new_inst(FI_CONSTANT, empty), dyn); } /* * Remove all new lines and doubled whitespaces * and convert all tabulators to spaces * and return a copy of string */ char * assert_copy_expr(const char *start, size_t len) { /* XXX: Allocates maybe a little more memory than we really finally need */ char *str = cfg_alloc(len + 1); char *dst = str; const char *src = start - 1; const char *end = start + len; while (++src < end) { if (*src == '\n') continue; /* Skip doubled whitespaces */ if (src != start) { const char *prev = src - 1; if ((*src == ' ' || *src == '\t') && (*prev == ' ' || *prev == '\t')) continue; } if (*src == '\t') *dst = ' '; else *dst = *src; dst++; } *dst = '\0'; return str; } /* * assert_done - create f_instruction of bt_assert * @expr: expression in bt_assert() * @start: pointer to first char of test expression * @end: pointer to the last char of test expression */ static struct f_inst * assert_done(struct f_inst *expr, const char *start, const char *end) { return f_new_inst(FI_ASSERT, expr, (end >= start) ? assert_copy_expr(start, end - start + 1) : "???"); } static struct f_inst * assert_assign(struct f_lval *lval, struct f_inst *expr, const char *start, const char *end) { struct f_inst *setter, *getter, *checker; switch (lval->type) { case F_LVAL_VARIABLE: setter = f_new_inst(FI_VAR_SET, expr, lval->sym); getter = f_new_inst(FI_VAR_GET, lval->sym); break; case F_LVAL_PREFERENCE: setter = f_new_inst(FI_PREF_SET, expr); getter = f_new_inst(FI_PREF_GET); break; case F_LVAL_SA: setter = f_new_inst(FI_RTA_SET, expr, lval->sa); getter = f_new_inst(FI_RTA_GET, lval->sa); break; case F_LVAL_EA: setter = f_new_inst(FI_EA_SET, expr, lval->da); getter = f_new_inst(FI_EA_GET, lval->da); break; default: bug("Unknown lval type"); } checker = f_new_inst(FI_EQ, expr, getter); setter->next = checker; return assert_done(setter, start, end); } CF_DECLS CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, ACCEPT, REJECT, ERROR, INT, BOOL, IP, TYPE, PREFIX, RD, PAIR, QUAD, EC, LC, SET, STRING, BGPMASK, BGPPATH, CLIST, ECLIST, LCLIST, IF, THEN, ELSE, CASE, TRUE, FALSE, RT, RO, UNKNOWN, GENERIC, FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX, WEIGHT, PREFERENCE, ROA_CHECK, ASN, SRC, DST, IS_V4, IS_V6, LEN, MAXLEN, DEFINED, ADD, DELETE, CONTAINS, RESET, PREPEND, FIRST, LAST, LAST_NONAGGREGATED, MATCH, EMPTY, FILTER, WHERE, EVAL, ATTRIBUTE, BT_ASSERT, BT_TEST_SUITE, BT_CHECK_ASSIGN, BT_TEST_SAME, FORMAT) %nonassoc THEN %nonassoc ELSE %type cmds_int cmd_prep %type term block cmd cmds constant constructor print_list var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail %type dynamic_attr %type static_attr %type filter where_filter %type filter_body function_body %type lvalue %type type function_args function_vars %type ec_kind %type break_command %type cnum %type pair_item ec_item lc_item set_item switch_item set_items switch_items switch_body %type fprefix_set %type set_atom switch_atom fipa %type fprefix %type get_cf_position CF_GRAMMAR conf: filter_def ; filter_def: FILTER symbol { $2 = cf_define_symbol($2, SYM_FILTER, filter, NULL); cf_push_scope( $2 ); } filter_body { struct filter *f = cfg_alloc(sizeof(struct filter)); *f = (struct filter) { .sym = $2, .root = $4 }; $2->filter = f; cf_pop_scope(); } ; conf: filter_eval ; filter_eval: EVAL term { f_eval_int(f_linearize($2)); } ; conf: custom_attr ; custom_attr: ATTRIBUTE type symbol ';' { cf_define_symbol($3, SYM_ATTRIBUTE, attribute, ca_lookup(new_config->pool, $3->name, $2)->fda); }; conf: bt_test_suite ; bt_test_suite: BT_TEST_SUITE '(' CF_SYM_KNOWN ',' text ')' { cf_assert_symbol($3, SYM_FUNCTION); struct f_bt_test_suite *t = cfg_allocz(sizeof(struct f_bt_test_suite)); t->fn = $3->function; t->fn_name = $3->name; t->dsc = $5; add_tail(&new_config->tests, &t->n); } ; conf: bt_test_same ; bt_test_same: BT_TEST_SAME '(' CF_SYM_KNOWN ',' CF_SYM_KNOWN ',' NUM ')' { cf_assert_symbol($3, SYM_FUNCTION); cf_assert_symbol($5, SYM_FUNCTION); struct f_bt_test_suite *t = cfg_allocz(sizeof(struct f_bt_test_suite)); t->fn = $3->function; t->cmp = $5->function; t->result = $7; t->fn_name = $3->name; t->dsc = $5->name; add_tail(&new_config->tests, &t->n); } ; type: INT { $$ = T_INT; } | BOOL { $$ = T_BOOL; } | IP { $$ = T_IP; } | RD { $$ = T_RD; } | PREFIX { $$ = T_NET; } | PAIR { $$ = T_PAIR; } | QUAD { $$ = T_QUAD; } | EC { $$ = T_EC; } | LC { $$ = T_LC; } | STRING { $$ = T_STRING; } | BGPMASK { $$ = T_PATH_MASK; } | BGPPATH { $$ = T_PATH; } | CLIST { $$ = T_CLIST; } | ECLIST { $$ = T_ECLIST; } | LCLIST { $$ = T_LCLIST; } | type SET { switch ($1) { case T_INT: case T_PAIR: case T_QUAD: case T_EC: case T_LC: case T_RD: case T_IP: $$ = T_SET; break; case T_NET: $$ = T_PREFIX_SET; break; default: cf_error( "You can't create sets of this type." ); } } ; function_argsn: /* EMPTY */ | function_argsn type symbol ';' { if ($3->scope->slots >= 0xfe) cf_error("Too many declarations, at most 255 allowed"); cf_define_symbol($3, SYM_VARIABLE | $2, offset, $3->scope->slots++); } ; function_args: '(' ')' { $$ = 0; } | '(' function_argsn type symbol ')' { cf_define_symbol($4, SYM_VARIABLE | $3, offset, $4->scope->slots++); $$ = $4->scope->slots; } ; function_vars: /* EMPTY */ { $$ = 0; } | function_vars type symbol ';' { cf_define_symbol($3, SYM_VARIABLE | $2, offset, $3->scope->slots++); $$ = $1 + 1; } ; filter_body: function_body ; filter: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_FILTER); $$ = $1->filter; } | filter_body { struct filter *f = cfg_alloc(sizeof(struct filter)); *f = (struct filter) { .root = $1 }; $$ = f; } ; where_filter: WHERE term { /* Construct 'IF term THEN { ACCEPT; } ELSE { REJECT; }' */ $$ = f_new_where($2); } ; function_body: function_vars '{' cmds '}' { $$ = f_linearize($3); $$->vars = $1; } ; conf: function_def ; function_def: FUNCTION symbol { DBG( "Beginning of function %s\n", $2->name ); $2 = cf_define_symbol($2, SYM_FUNCTION, function, NULL); cf_push_scope($2); } function_args function_body { DBG("Definition of function %s with %u args and %u local vars.\n", $2->name, $4, $5->vars); $5->args = $4; $2->function = $5; cf_pop_scope(); } ; /* Programs */ cmds: /* EMPTY */ { $$ = NULL; } | cmds_int { $$ = $1.begin; } ; cmd_prep: cmd { $$.begin = $$.end = $1; if ($1) while ($$.end->next) $$.end = $$.end->next; } ; cmds_int: cmd_prep | cmds_int cmd_prep { if (!$1.begin) $$ = $2; else if (!$2.begin) $$ = $1; else { $$.begin = $1.begin; $$.end = $2.end; $1.end->next = $2.begin; } } ; block: cmd { $$=$1; } | '{' cmds '}' { $$=$2; } ; /* * Complex types, their bison value is struct f_val */ fipa: IP4 %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = ipa_from_ip4($1); } | IP6 %prec PREFIX_DUMMY { $$.type = T_IP; $$.val.ip = ipa_from_ip6($1); } ; /* * Set constants. They are also used in switch cases. We use separate * nonterminals for switch (set_atom/switch_atom, set_item/switch_item ...) * to elude a collision between symbol (in expr) in set_atom and symbol * as a function call in switch case cmds. */ set_atom: NUM { $$.type = T_INT; $$.val.i = $1; } | fipa { $$ = $1; } | VPN_RD { $$.type = T_RD; $$.val.ec = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } | '(' term ')' { if (f_eval(f_linearize($2), cfg_mem, &($$)) > F_RETURN) cf_error("Runtime error"); if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type"); } | CF_SYM_KNOWN { cf_assert_symbol($1, SYM_CONSTANT); if (!f_valid_set_type(SYM_TYPE($1))) cf_error("%s: set-incompatible type", $1->name); $$ = *$1->val; } ; switch_atom: NUM { $$.type = T_INT; $$.val.i = $1; } | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int(f_linearize($2)); } | fipa { $$ = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } ; cnum: term { $$ = f_eval_int(f_linearize($1)); } pair_item: '(' cnum ',' cnum ')' { $$ = f_new_pair_item($2, $2, $4, $4); } | '(' cnum ',' cnum DDOT cnum ')' { $$ = f_new_pair_item($2, $2, $4, $6); } | '(' cnum ',' '*' ')' { $$ = f_new_pair_item($2, $2, 0, CC_ALL); } | '(' cnum DDOT cnum ',' cnum ')' { $$ = f_new_pair_set($2, $4, $6, $6); } | '(' cnum DDOT cnum ',' cnum DDOT cnum ')' { $$ = f_new_pair_set($2, $4, $6, $8); } | '(' cnum DDOT cnum ',' '*' ')' { $$ = f_new_pair_item($2, $4, 0, CC_ALL); } | '(' '*' ',' cnum ')' { $$ = f_new_pair_set(0, CC_ALL, $4, $4); } | '(' '*' ',' cnum DDOT cnum ')' { $$ = f_new_pair_set(0, CC_ALL, $4, $6); } | '(' '*' ',' '*' ')' { $$ = f_new_pair_item(0, CC_ALL, 0, CC_ALL); } | '(' cnum ',' cnum ')' DDOT '(' cnum ',' cnum ')' { $$ = f_new_pair_item($2, $8, $4, $10); } ; ec_kind: RT { $$ = EC_RT; } | RO { $$ = EC_RO; } | UNKNOWN NUM { $$ = $2; } | GENERIC { $$ = EC_GENERIC; } ; ec_item: '(' ec_kind ',' cnum ',' cnum ')' { $$ = f_new_ec_item($2, 0, $4, $6, $6); } | '(' ec_kind ',' cnum ',' cnum DDOT cnum ')' { $$ = f_new_ec_item($2, 0, $4, $6, $8); } | '(' ec_kind ',' cnum ',' '*' ')' { $$ = f_new_ec_item($2, 0, $4, 0, EC_ALL); } ; lc_item: '(' cnum ',' cnum ',' cnum ')' { $$ = f_new_lc_item($2, $2, $4, $4, $6, $6); } | '(' cnum ',' cnum ',' cnum DDOT cnum ')' { $$ = f_new_lc_item($2, $2, $4, $4, $6, $8); } | '(' cnum ',' cnum ',' '*' ')' { $$ = f_new_lc_item($2, $2, $4, $4, 0, LC_ALL); } | '(' cnum ',' cnum DDOT cnum ',' '*' ')' { $$ = f_new_lc_item($2, $2, $4, $6, 0, LC_ALL); } | '(' cnum ',' '*' ',' '*' ')' { $$ = f_new_lc_item($2, $2, 0, LC_ALL, 0, LC_ALL); } | '(' cnum DDOT cnum ',' '*' ',' '*' ')' { $$ = f_new_lc_item($2, $4, 0, LC_ALL, 0, LC_ALL); } | '(' '*' ',' '*' ',' '*' ')' { $$ = f_new_lc_item(0, LC_ALL, 0, LC_ALL, 0, LC_ALL); } | '(' cnum ',' cnum ',' cnum ')' DDOT '(' cnum ',' cnum ',' cnum ')' { $$ = f_new_lc_item($2, $10, $4, $12, $6, $14); } ; set_item: pair_item | ec_item | lc_item | set_atom { $$ = f_new_item($1, $1); } | set_atom DDOT set_atom { $$ = f_new_item($1, $3); } ; switch_item: pair_item | ec_item | lc_item | switch_atom { $$ = f_new_item($1, $1); } | switch_atom DDOT switch_atom { $$ = f_new_item($1, $3); } ; set_items: set_item | set_items ',' set_item { $$ = f_merge_items($1, $3); } ; switch_items: switch_item | switch_items ',' switch_item { $$ = f_merge_items($1, $3); } ; fprefix: net_ip_ { $$.net = $1; $$.lo = $1.pxlen; $$.hi = $1.pxlen; } | net_ip_ '+' { $$.net = $1; $$.lo = $1.pxlen; $$.hi = net_max_prefix_length[$1.type]; } | net_ip_ '-' { $$.net = $1; $$.lo = 0; $$.hi = $1.pxlen; } | net_ip_ '{' NUM ',' NUM '}' { $$.net = $1; $$.lo = $3; $$.hi = $5; if (($3 > $5) || ($5 > net_max_prefix_length[$1.type])) cf_error("Invalid prefix pattern range: {%u, %u}", $3, $5); } ; fprefix_set: fprefix { $$ = f_new_trie(cfg_mem, 0); trie_add_prefix($$, &($1.net), $1.lo, $1.hi); } | fprefix_set ',' fprefix { $$ = $1; if (!trie_add_prefix($$, &($3.net), $3.lo, $3.hi)) cf_error("Mixed IPv4/IPv6 prefixes in prefix set"); } ; switch_body: /* EMPTY */ { $$ = NULL; } | switch_body switch_items ':' cmds { /* Fill data fields */ struct f_tree *t; struct f_line *line = f_linearize($4); for (t = $2; t; t = t->left) t->data = line; $$ = f_merge_items($1, $2); } | switch_body ELSECOL cmds { struct f_tree *t = f_new_tree(); t->from.type = t->to.type = T_VOID; t->right = t; t->data = f_linearize($3); $$ = f_merge_items($1, t); } ; bgp_path_expr: symbol_value { $$ = $1; } | '(' term ')' { $$ = $2; } ; bgp_path: PO bgp_path_tail PC { $$ = $2; } ; bgp_path_tail: NUM bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .asn = $1, .kind = PM_ASN, }, }); $$->next = $2; } | NUM DDOT NUM bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .from = $1, .to = $3, .kind = PM_ASN_RANGE }, }); $$->next = $4; } | '[' set_items ']' bgp_path_tail { if ($2->from.type != T_INT) cf_error("Only integer sets allowed in path mask"); $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .set = build_tree($2), .kind = PM_ASN_SET }, }); $$->next = $4; } | '*' bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .kind = PM_ASTERISK }, }); $$->next = $2; } | '?' bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .kind = PM_QUESTION }, }); $$->next = $2; } | '+' bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .kind = PM_LOOP }, }); $$->next = $2; } | bgp_path_expr bgp_path_tail { $$ = $1; $$->next = $2; } | { $$ = NULL; } ; constant: NUM { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = $1, }); } | TRUE { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_BOOL, .val.i = 1, }); } | FALSE { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_BOOL, .val.i = 0, }); } | TEXT { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_STRING, .val.s = $1, }); } | fipa { $$ = f_new_inst(FI_CONSTANT, $1); } | VPN_RD { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_RD, .val.ec = $1, }); } | net_ { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_NET, .val.net = $1, }); } | '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_SET, .val.t = build_tree($2), }); DBG( "ook\n" ); } | '[' fprefix_set ']' { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PREFIX_SET, .val.ti = $2, }); } | ENUM { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = $1 >> 16, .val.i = $1 & 0xffff, }); } ; constructor: '(' term ',' term ')' { $$ = f_new_inst(FI_PAIR_CONSTRUCT, $2, $4); } | '(' ec_kind ',' term ',' term ')' { $$ = f_new_inst(FI_EC_CONSTRUCT, $4, $6, $2); } | '(' term ',' term ',' term ')' { $$ = f_new_inst(FI_LC_CONSTRUCT, $2, $4, $6); } | bgp_path { $$ = f_new_inst(FI_PATHMASK_CONSTRUCT, $1); } ; /* This generates the function_call variable list backwards. */ var_list: /* EMPTY */ { $$ = NULL; } | term { $$ = $1; } | var_list ',' term { $$ = $3; $$->next = $1; } function_call: CF_SYM_KNOWN '(' var_list ')' { if ($1->class != SYM_FUNCTION) cf_error("You can't call something which is not a function. Really."); struct f_inst *fc = f_new_inst(FI_CALL, $1); uint args = 0; while ($3) { args++; struct f_inst *tmp = $3->next; $3->next = fc; fc = $3; $3 = tmp; } if (args != $1->function->args) cf_error("Function call '%s' got %u arguments, need %u arguments.", $1->name, args, $1->function->args); $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_VOID }); $$->next = fc; } ; symbol_value: CF_SYM_KNOWN { switch ($1->class) { case SYM_CONSTANT_RANGE: $$ = f_new_inst(FI_CONSTANT, *($1->val)); break; case SYM_VARIABLE_RANGE: $$ = f_new_inst(FI_VAR_GET, $1); break; case SYM_ATTRIBUTE: $$ = f_new_inst(FI_EA_GET, *$1->attribute); break; default: cf_error("Can't get value of symbol %s", $1->name); } } ; static_attr: FROM { $$ = f_new_static_attr(T_IP, SA_FROM, 0); } | GW { $$ = f_new_static_attr(T_IP, SA_GW, 0); } | NET { $$ = f_new_static_attr(T_NET, SA_NET, 1); } | PROTO { $$ = f_new_static_attr(T_STRING, SA_PROTO, 1); } | SOURCE { $$ = f_new_static_attr(T_ENUM_RTS, SA_SOURCE, 1); } | SCOPE { $$ = f_new_static_attr(T_ENUM_SCOPE, SA_SCOPE, 0); } | DEST { $$ = f_new_static_attr(T_ENUM_RTD, SA_DEST, 0); } | IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 0); } | IFINDEX { $$ = f_new_static_attr(T_INT, SA_IFINDEX, 1); } | WEIGHT { $$ = f_new_static_attr(T_INT, SA_WEIGHT, 0); } ; term: '(' term ')' { $$ = $2; } | term '+' term { $$ = f_new_inst(FI_ADD, $1, $3); } | term '-' term { $$ = f_new_inst(FI_SUBTRACT, $1, $3); } | term '*' term { $$ = f_new_inst(FI_MULTIPLY, $1, $3); } | term '/' term { $$ = f_new_inst(FI_DIVIDE, $1, $3); } | term AND term { $$ = f_new_inst(FI_AND, $1, $3); } | term OR term { $$ = f_new_inst(FI_OR, $1, $3); } | term '=' term { $$ = f_new_inst(FI_EQ, $1, $3); } | term NEQ term { $$ = f_new_inst(FI_NEQ, $1, $3); } | term '<' term { $$ = f_new_inst(FI_LT, $1, $3); } | term LEQ term { $$ = f_new_inst(FI_LTE, $1, $3); } | term '>' term { $$ = f_new_inst(FI_LT, $3, $1); } | term GEQ term { $$ = f_new_inst(FI_LTE, $3, $1); } | term '~' term { $$ = f_new_inst(FI_MATCH, $1, $3); } | term NMA term { $$ = f_new_inst(FI_NOT_MATCH, $1, $3); } | '!' term { $$ = f_new_inst(FI_NOT, $2); } | DEFINED '(' term ')' { $$ = f_new_inst(FI_DEFINED, $3); } | symbol_value { $$ = $1; } | constant { $$ = $1; } | constructor { $$ = $1; } | PREFERENCE { $$ = f_new_inst(FI_PREF_GET); } | static_attr { $$ = f_new_inst(FI_RTA_GET, $1); } | dynamic_attr { $$ = f_new_inst(FI_EA_GET, $1); } | term '.' IS_V4 { $$ = f_new_inst(FI_IS_V4, $1); } | term '.' TYPE { $$ = f_new_inst(FI_TYPE, $1); } | term '.' IP { $$ = f_new_inst(FI_IP, $1); } | term '.' RD { $$ = f_new_inst(FI_ROUTE_DISTINGUISHER, $1); } | term '.' LEN { $$ = f_new_inst(FI_LENGTH, $1); } | term '.' MAXLEN { $$ = f_new_inst(FI_ROA_MAXLEN, $1); } | term '.' ASN { $$ = f_new_inst(FI_ROA_ASN, $1); } | term '.' SRC { $$ = f_new_inst(FI_NET_SRC, $1); } | term '.' DST { $$ = f_new_inst(FI_NET_DST, $1); } | term '.' MASK '(' term ')' { $$ = f_new_inst(FI_IP_MASK, $1, $5); } | term '.' FIRST { $$ = f_new_inst(FI_AS_PATH_FIRST, $1); } | term '.' LAST { $$ = f_new_inst(FI_AS_PATH_LAST, $1); } | term '.' LAST_NONAGGREGATED { $$ = f_new_inst(FI_AS_PATH_LAST_NAG, $1); } /* Communities */ /* This causes one shift/reduce conflict | dynamic_attr '.' ADD '(' term ')' { } | dynamic_attr '.' DELETE '(' term ')' { } | dynamic_attr '.' CONTAINS '(' term ')' { } | dynamic_attr '.' RESET{ } */ | '+' EMPTY '+' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_path); } | '-' EMPTY '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_clist); } | '-' '-' EMPTY '-' '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_eclist); } | '-' '-' '-' EMPTY '-' '-' '-' { $$ = f_new_inst(FI_CONSTANT, f_const_empty_lclist); } | PREPEND '(' term ',' term ')' { $$ = f_new_inst(FI_PATH_PREPEND, $3, $5); } | ADD '(' term ',' term ')' { $$ = f_new_inst(FI_CLIST_ADD, $3, $5); } | DELETE '(' term ',' term ')' { $$ = f_new_inst(FI_CLIST_DEL, $3, $5); } | FILTER '(' term ',' term ')' { $$ = f_new_inst(FI_CLIST_FILTER, $3, $5); } | ROA_CHECK '(' rtable ')' { $$ = f_new_inst(FI_ROA_CHECK_IMPLICIT, $3); } | ROA_CHECK '(' rtable ',' term ',' term ')' { $$ = f_new_inst(FI_ROA_CHECK_EXPLICIT, $5, $7, $3); } | FORMAT '(' term ')' { $$ = f_new_inst(FI_FORMAT, $3); } /* | term '.' LEN { $$->code = P('P','l'); } */ | function_call ; break_command: ACCEPT { $$ = F_ACCEPT; } | REJECT { $$ = F_REJECT; } | ERROR { $$ = F_ERROR; } ; print_list: /* EMPTY */ { $$ = NULL; } | term { $$ = $1; } | term ',' print_list { ASSERT($1); ASSERT($1->next == NULL); $1->next = $3; $$ = $1; } ; cmd: IF term THEN block { $$ = f_new_inst(FI_CONDITION, $2, $4, NULL); } | IF term THEN block ELSE block { $$ = f_new_inst(FI_CONDITION, $2, $4, $6); } | CF_SYM_KNOWN '=' term ';' { switch ($1->class) { case SYM_VARIABLE_RANGE: $$ = f_new_inst(FI_VAR_SET, $3, $1); break; case SYM_ATTRIBUTE: $$ = f_new_inst(FI_EA_SET, $3, *$1->attribute); break; default: cf_error("Can't assign to symbol %s", $1->name); } } | RETURN term ';' { DBG( "Ook, we'll return the value\n" ); $$ = f_new_inst(FI_RETURN, $2); } | dynamic_attr '=' term ';' { $$ = f_new_inst(FI_EA_SET, $3, $1); } | static_attr '=' term ';' { if ($1.readonly) cf_error( "This static attribute is read-only."); $$ = f_new_inst(FI_RTA_SET, $3, $1); } | PREFERENCE '=' term ';' { $$ = f_new_inst(FI_PREF_SET, $3); } | UNSET '(' dynamic_attr ')' ';' { $$ = f_new_inst(FI_EA_UNSET, $3); } | break_command print_list ';' { struct f_inst *breaker = f_new_inst(FI_DIE, $1); if ($2) { struct f_inst *printer = f_new_inst(FI_PRINT, $2); struct f_inst *flusher = f_new_inst(FI_FLUSH); printer->next = flusher; flusher->next = breaker; $$ = printer; } else $$ = breaker; } | PRINT print_list ';' { $$ = f_new_inst(FI_PRINT, $2); $$->next = f_new_inst(FI_FLUSH); } | PRINTN print_list ';' { $$ = f_new_inst(FI_PRINT, $2); } | function_call ';' { $$ = f_new_inst(FI_DROP_RESULT, $1); } | CASE term '{' switch_body '}' { $$ = f_new_inst(FI_SWITCH, $2, build_tree($4)); } | dynamic_attr '.' EMPTY ';' { $$ = f_generate_empty($1); } | dynamic_attr '.' PREPEND '(' term ')' ';' { $$ = f_generate_complex( FI_PATH_PREPEND, $1, $5 ); } | dynamic_attr '.' ADD '(' term ')' ';' { $$ = f_generate_complex( FI_CLIST_ADD, $1, $5 ); } | dynamic_attr '.' DELETE '(' term ')' ';' { $$ = f_generate_complex( FI_CLIST_DEL, $1, $5 ); } | dynamic_attr '.' FILTER '(' term ')' ';' { $$ = f_generate_complex( FI_CLIST_FILTER, $1, $5 ); } | BT_ASSERT '(' get_cf_position term get_cf_position ')' ';' { $$ = assert_done($4, $3 + 1, $5 - 1); } | BT_CHECK_ASSIGN '(' get_cf_position lvalue get_cf_position ',' term ')' ';' { $$ = assert_assign(&$4, $7, $3 + 1, $5 - 1); } ; get_cf_position: { $$ = cf_text; }; lvalue: CF_SYM_KNOWN { cf_assert_symbol($1, SYM_VARIABLE); $$ = (struct f_lval) { .type = F_LVAL_VARIABLE, .sym = $1 }; } | PREFERENCE { $$ = (struct f_lval) { .type = F_LVAL_PREFERENCE }; } | static_attr { $$ = (struct f_lval) { .type = F_LVAL_SA, .sa = $1 }; } | dynamic_attr { $$ = (struct f_lval) { .type = F_LVAL_EA, .da = $1 }; }; CF_END bird-2.0.8/filter/Makefile0000664000175000017500000000137514025744326014317 0ustar feelafeelasrc := filter.c data.c f-util.c tree.c trie.c inst-gen.c obj := $(src-o-files) $(all-daemon) $(cf-local) #M4FLAGS_FILTERS=$(filter-out -s,$(M4FLAGS)) M4FLAGS_FILTERS=$(M4FLAGS) $(o)inst-gen.h: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp $(M4) $(M4FLAGS_FILTERS) -DTARGET=H -P $^ >$@ $(o)inst-gen.c: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp $(M4) $(M4FLAGS_FILTERS) -DTARGET=C -P $^ >$@ $(o)inst-interpret.c: $(s)decl.m4 $(s)f-inst.c $(objdir)/.dir-stamp $(M4) $(M4FLAGS_FILTERS) -DTARGET=I -P $^ >$@ prepare: $(o)inst-interpret.c $(o)inst-gen.h tests_src := tree_test.c filter_test.c trie_test.c tests_targets := $(tests_targets) $(tests-target-files) tests_objs := $(tests_objs) $(src-o-files) $(call clean,inst-gen.h inst-gen.c inst-interpret.c) bird-2.0.8/filter/Doc0000664000175000017500000000004614025744326013301 0ustar feelafeelaH Filters S filter.c S tree.c S trie.cbird-2.0.8/doc/0000775000175000017500000000000014025754401012124 5ustar feelafeelabird-2.0.8/doc/tex/0000775000175000017500000000000014025744326012731 5ustar feelafeelabird-2.0.8/doc/tex/url.sty0000664000175000017500000003320514025744326014277 0ustar feelafeela% url.sty ver 1.2 19-Oct-1996 Donald Arseneau asnd@triumf.ca % % A form of \verb that allows linebreaks at certain characters or % combinations of characters, accepts reconfiguration, and can usually % be used in the argument to another command. It is intended for email % addresses, hypertext links, directories/paths, etc., which normally % have no spaces. The font may be selected using the \urlstyle command, % and new url-like commands can be defined using \urldef. % % Usage: Conditions: % \url{ } If the argument contains any "%", "#", or "^^", or ends with % "\", it can't be used in the argument to another command. % The argument must not contain unbalanced braces. % \url| | ...where "|" is any character not used in the argument and not % "{". The same restrictions as above except that the argument % may contain unbalanced braces. % \xyz for "\xyz" a defined-url; this can be used anywhere, no matter % what characters it contains. % % See further instructions after "\endinput" % \def\Url@ttdo{% style assignments for tt fonts or T1 encoding \def\UrlBreaks{\do\.\do\@\do\\\do\/\do\!\do\_\do\|\do\%\do\;\do\>\do\]% \do\)\do\,\do\?\do\'\do\+\do\=}% \def\UrlBigBreaks{\do\:\do@url@hyp}% \def\UrlNoBreaks{\do\(\do\[\do\{\do\<}% (unnecessary) \def\UrlSpecials{\do\ {\ }}% \def\UrlOrds{\do\*\do\-\do\~}% any ordinary characters that aren't usually } \def\Url@do{% style assignments for OT1 fonts except tt \def\UrlBreaks{\do\.\do\@\do\/\do\!\do\%\do\;\do\]\do\)\do\,\do\?\do\+\do\=}% \def\UrlBigBreaks{\do\:\do@url@hyp}% \def\UrlNoBreaks{\do\(\do\[\do\{}% prevents breaks after *next* character \def\UrlSpecials{\do\<{\langle}\do\>{\mathbin{\rangle}}\do\_{\_% \penalty\@m}\do\|{\mid}\do\{{\lbrace}\do\}{\mathbin{\rbrace}}\do \\{\mathbin{\backslash}}\do\~{\mathord{{}^{\textstyle\sim}}}\do\ {\ }}% \def\UrlOrds{\do\'\do\"\do\-}% } \def\url@ttstyle{% \@ifundefined{selectfont}{\def\UrlFont{\tt}}{\def\UrlFont{\ttfamily}}\Url@ttdo } \def\url@rmstyle{% \@ifundefined{selectfont}{\def\UrlFont{\rm}}{\def\UrlFont{\rmfamily}}\Url@do } \def\url@sfstyle{% \@ifundefined{selectfont}{\def\UrlFont{\sf}}{\def\UrlFont{\sffamily}}\Url@do } \def\url@samestyle{\ifdim\fontdimen\thr@@\font=\z@ \url@ttstyle \else \url@rmstyle \fi \def\UrlFont{}} \@ifundefined{strip@prefix}{\def\strip@prefix#1>{}}{} \@ifundefined{verbatim@nolig@list}{\def\verbatim@nolig@list{\do\`}}{} \def\Url{\relax\ifmmode\@nomatherr$\fi \UrlFont $\fam\z@ \textfont\z@\font \let\do\@makeother \dospecials % verbatim catcodes \catcode`{\@ne \catcode`}\tw@ % except braces \medmuskip0mu \thickmuskip\medmuskip \thinmuskip\medmuskip \@tempcnta\fam\multiply\@tempcnta\@cclvi \let\do\set@mathcode \UrlOrds % ordinary characters that were special \advance\@tempcnta 8192 \UrlBreaks % bin \advance\@tempcnta 4096 \UrlBigBreaks % rel \advance\@tempcnta 4096 \UrlNoBreaks % open \let\do\set@mathact \UrlSpecials % active \let\do\set@mathnolig \verbatim@nolig@list % prevent ligatures \@ifnextchar\bgroup\Url@z\Url@y} \def\Url@y#1{\catcode`{11 \catcode`}11 \def\@tempa##1#1{\Url@z{##1}}\@tempa} \def\Url@z#1{\def\@tempa{#1}\expandafter\expandafter\expandafter\Url@Hook \expandafter\strip@prefix\meaning\@tempa\UrlRight\m@th$\endgroup} \def\Url@Hook{\UrlLeft} \let\UrlRight\@empty \let\UrlLeft\@empty \def\set@mathcode#1{\count@`#1\advance\count@\@tempcnta\mathcode`#1\count@} \def\set@mathact#1#2{\mathcode`#132768 \lccode`\~`#1\lowercase{\def~{#2}}} \def\set@mathnolig#1{\ifnum\mathcode`#1<32768 \lccode`\~`#1\lowercase{\edef~{\mathchar\number\mathcode`#1_{\/}}}% \mathcode`#132768 \fi} \def\urldef#1#2{\begingroup \setbox\z@\hbox\bgroup \def\Url@z{\Url@def{#1}{#2}}#2} \expandafter\ifx\csname DeclareRobustCommand\endcsname\relax \def\Url@def#1#2#3{\m@th$\endgroup\egroup\endgroup \def#1{#2{#3}}} \else \def\Url@def#1#2#3{\m@th$\endgroup\egroup\endgroup \DeclareRobustCommand{#1}{#2{#3}}} \fi \def\urlstyle#1{\csname url@#1style\endcsname} % Sample (and default) configuration: % \newcommand\url{\begingroup \Url} % \newcommand\path{\begingroup \urlstyle{tt}\Url} % % too many styles define \email like \address, so I will not define it. % \newcommand\email{\begingroup \urlstyle{rm}\Url} % Process LaTeX \package options % \urlstyle{tt} \let\Url@sppen\@M \def\do@url@hyp{}% by default, no breaks after hyphens \@ifundefined{ProvidesPackage}{}{ \ProvidesPackage{url}[1996/10/19 \space ver 1.2 \space Verb mode for urls, email addresses, and file names] \DeclareOption{hyphens}{\def\do@url@hyp{\do\-}}% allow breaks after hyphens \DeclareOption{obeyspaces}{\let\Url@Hook\relax}% a flag for later \DeclareOption{spaces}{\let\Url@sppen\relpenalty} \DeclareOption{T1}{\let\Url@do\Url@ttdo} \ProcessOptions \ifx\Url@Hook\relax % [obeyspaces] was declared \def\Url@Hook#1\UrlRight\m@th{\edef\@tempa{\noexpand\UrlLeft \Url@retain#1\Url@nosp\, }\@tempa\UrlRight\m@th} \def\Url@retain#1 {#1\penalty\Url@sppen\ \Url@retain} \def\Url@nosp\,#1\Url@retain{} \fi } \endinput % % url.sty ver 1.2 19-Oct-1996 Donald Arseneau asnd@reg.triumf.ca % % This package defines "\url", a form of "\verb" that allows linebreaks, % and can often be used in the argument to another command. It can be % configured to print in different formats, and is particularly useful for % hypertext links, email addresses, directories/paths, etc. The font may % be selected using the "\urlstyle" command and pre-defined text can be % stored with the "\urldef" command. New url-like commands can be defined, % and a "\path" command is provided this way. % % Usage: Conditions: % \url{ } If the argument contains any "%", "#", or "^^", or ends with % "\", it can't be used in the argument to another command. % The argument must not contain unbalanced braces. % \url| | ...where "|" is any character not used in the argument and not % "{". The same restrictions as above except that the argument % may contain unbalanced braces. % \xyz for "\xyz" a defined-url; this can be used anywhere, no matter % what characters it contains. % % The "\url" command is fragile, and its argument is likely to be very % fragile, but a defined-url is robust. % % Package Option: obeyspaces % Ordinarily, all spaces are ignored in the url-text. The "[obeyspaces]" % option allows spaces, but may introduce spurious spaces when a url % containing "\" characters is given in the argument to another command. % So if you need to obey spaces you can say "\usepackage[obeyspaces]{url}", % and if you need both spaces and backslashes, use a `defined-url' for % anything with "\". % % Package Option: hyphens % Ordinarily, breaks are not allowed after "-" characters because this % leads to confusion. (Is the "-" part of the address or just a hyphen?) % The package option "[hyphens]" allows breaks after explicit hyphen % characters. The "\url" command will *never ever* hyphenate words. % % Package Option: spaces % Likewise, breaks are not usually allowed after spaces under the % "[obeyspaces]" option, but giving the options "[obeyspaces,spaces]" % will allow breaks at those spaces. % % Package Option: T1 % This signifies that you will be using T1-encoded fonts which contain % some characters missing from most older (OT1) encoded TeX fonts. This % changes the default definition for "\urlstyle{rm}". % % Defining a defined-url: % Take for example the email address "myself%node@gateway.net" which could % not be given (using "\url" or "\verb") in a caption or parbox due to the % percent sign. This address can be predefined with % \urldef{\myself}\url{myself%node@gateway.net} or % \urldef{\myself}\url|myself%node@gateway.net| % and then you may use "\myself" instead of "\url{myself%node@gateway.net}" % in an argument, and even in a moving argument like a caption because a % defined-url is robust. % % Style: % You can switch the style of printing using "\urlstyle{tt}", where "tt" % can be any defined style. The pre-defined styles are "tt", "rm", "sf", % and "same" which all allow the same linebreaks but different fonts -- % the first three select a specific font and the "same" style uses the % current text font. You can define your own styles with different fonts % and/or line-breaking by following the explanations below. The "\url" % command follows whatever the currently-set style dictates. % % Alternate commands: % It may be desireable to have different things treated differently, each % in a predefined style; e.g., if you want directory paths to always be % in tt and email addresses to be rm, then you would define new url-like % commands as follows: % % \newcommand\email{\begingroup \urlstyle{rm}\Url} % \newcommand\directory{\begingroup \urlstyle{tt}\Url} % % You must follow this format closely, and NOTE that the final command is % "\Url", not "\url". In fact, the "\directory" example is exactly the % "\path" definition which is pre-defined in the package. If you look % above, you will see that "\url" is defined with % \newcommand\url{\begingroup \Url} % I.e., using whatever url-style has been selected. % % You can make a defined-url for these other styles, using the usual % "\urldef" command as in this example: % % \urldef{\myself}{\email}{myself%node.domain@gateway.net} % % which makes "\myself" act like "\email{myself%node.domain@gateway.net}", % if the "\email" command is defined as above. The "\myself" command % would then be robust. % % Defining styles: % Before describing how to customize the printing style, it is best to % mention something about the unusual implementation of "\url". Although % the material is textual in nature, and the font specification required % is a text-font command, the text is actually typeset in *math* mode. % This allows the context-sensitive linebreaking, but also accounts for % the default behavior of ignoring spaces. Now on to defining styles. % % To change the font or the list of characters that allow linebreaks, you % could redefine the commands "\UrlFont", "\UrlBreaks", "\UrlSpecials" etc. % directly in the document, but it is better to define a new `url-style' % (following the example of "\url@ttstyle" and "\url@rmstyle") which defines % all of "\UrlBigbreaks", "\UrlNoBreaks", "\UrlBreaks", "\UrlSpecials", and % "\UrlFont". % % Changing font: % The "\UrlFont" command selects the font. The definition of "\UrlFont" % done by the pre-defined styles varies to cope with a variety of LaTeX % font selection schemes, but it could be as simple as "\def\UrlFont{\tt}". % Depending on the font selected, some characters may need to be defined % in the "\UrlSpecials" list because many fonts don't contain all the % standard input characters. % % Changing linebreaks: % The list of characters that allow line-breaks is given by "\UrlBreaks" % and "\UrlBigBreaks", which have the format "\do\c" for character "c". % The differences are that `BigBreaks' have a lower penalty and have % different breakpoints when in sequence (as in "http://"): `BigBreaks' % are treated as mathrels while `Breaks' are mathbins (see The TeXbook, % p.170). In particular, a series of `BigBreak' characters will break at % the end and only at the end; a series of `Break' characters will break % after the first and after every following *pair*; there will be no % break after a `Break' character if a `BigBreak' follows. In the case % of "http://" it doesn't matter whether ":" is a `Break' or `BigBreak' -- % the breaks are the same in either case; but for DECnet nodes with "::" % it is important to prevent breaks *between* the colons, and that is why % colons are `BigBreaks'. % % It is possible for characters to prevent breaks after the next following % character (I use this for parentheses). Specify these in "\UrlNoBreaks". % % You can do arbitrarily complex things with characters by making them % active in math mode (mathcode hex-8000) and specifying the definition(s) % in "\UrlSpecials". This is used in the rm and sf styles for OT1 font % encoding to handle several characters that are not present in those % computer-modern style fonts. See the definition of "\Url@do", which % is used by both "\url@rmstyle" and "\url@sfstyle"; it handles missing % characters via "\UrlSpecials". The nominal format for setting each % special character "c" is: "\do\c{}", but you can include % other definitions too. % % % If all this sounds confusing ... well, it is! But I hope you won't need % to redefine breakpoints -- the default assignments seem to work well for % a wide variety of applications. If you do need to make changes, you can % test for breakpoints using regular math mode and the characters "+=(a". % % Yet more flexibility: % You can also customize the verbatim text by defining "\UrlRight" and/or % "\UrlLeft", e.g., for ISO formatting of urls surrounded by "< >", define % % \renewcommand\url{\begingroup \def\UrlLeft{}% % \urlstyle{tt}\Url} % % The meanings of "\UrlLeft" and "\UrlRight" are *not* reproduced verbatim. % This lets you use formatting commands there, but you must be careful not % to use TeX's special characters ("\^_%~#$&{}" etc.) improperly. % You can also define "\UrlLeft" to reprocess the verbatim text, but the % format of the definition is special: % % \def\UrlLeft#1\UrlRight{ ... do things with #1 ... } % % Yes, that is "#1" followed by "\UrlRight" then the definition. For % example, to put a hyperTeX hypertext link in the DVI file: % % \def\UrlLeft#1\UrlRight{\special{html:}#1\special{html:}} % % Revision History: % ver 1.1 6-Feb-1996: % Fix hyphens that wouldn't break and ligatures that weren't suppressed. % ver 1.2 19-Oct-1996: % Package option for T1 encoding; Hooks: "\UrlLeft" and "\UrlRight". % % The End bird-2.0.8/doc/tex/qwertz.sty0000664000175000017500000000110514025744326015023 0ustar feelafeela % qwertz TeX macros \catcode`\"=12 \sloppy \newtheorem{definition}{Definition} \newtheorem{proposition}{Proposition} \newtheorem{lemma}{Lemma} \newtheorem{corollary}{Corollary} \newtheorem{theorem}{Theorem} \newcommand{\mch}[1]{{\ifmmode#1 \else\(#1\)\fi}} \newcommand{\lt}{{\ifmmode{<}\else{\verb+<+}\fi}} \newcommand{\gt}{{\ifmmode{>}\else{\verb+>+}\fi}} \newcommand{\verbar}{{\ifmmode{|}\else{\tt|}\fi}} \newcommand{\idx}[1]{#1\index{#1}} \newcommand{\cdx}[1]{#1\index{#1@{\tt #1}}} \newcommand{\nidx}[1]{\index{#1}} \newcommand{\ncdx}[1]{\index{#1@{\tt #1}}} bird-2.0.8/doc/tex/null.sty0000664000175000017500000000000014025744326014432 0ustar feelafeelabird-2.0.8/doc/tex/birddoc.sty0000664000175000017500000000753314025744326015110 0ustar feelafeela%% This is a LaTeX style file for typesetting BIRD documentation. %% Hacked up by Martin Mares %% %% This is a modified version of linuxdoc-qwertz.sty, for use with SGML-generated LaTeX %% by Matt Welsh (mdw@sunsite.unc.edu) %% %% Based on linuxdoc.sty by Michael K. Johnson, and latex.tex by %% Leslie Lamport. \NeedsTeXFormat{LaTeX2e} \ProvidesClass{birddoc} %%% GLOBAL LAYOUT THINGS \marginparwidth 0.0 in \parindent=0 in \parskip=0.5ex %\parindent=0.5in %\parskip=0pt \topmargin -0.5 in \setlength{\textheight}{\paperheight} \addtolength{\textheight}{-2 in} %\advance\headsep 2 ex \advance\textheight -2 ex %\renewcommand{\baselinestretch}{1.14} \setcounter{tocdepth}{1} \oddsidemargin 0.15 in \evensidemargin -0.35 in \textwidth 6.5in \def\ps@headings{\let\@mkboth\markboth \def\@oddfoot{}\def\@evenfoot{}% No feet. \def\@evenhead{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth \rm \thepage\hfil \bf \leftmark} % Left heading. \def\@oddhead{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth {\bf \rightmark}\hfil \rm\thepage} % Right heading. \def\chaptermark##1{\markboth {{\ifnum \c@secnumdepth >\m@ne \@chapapp\ \thechapter. \ \fi ##1}}{}}% \def\sectionmark##1{\markright {{\ifnum \c@secnumdepth >\z@ \thesection. \ \fi ##1}}}} \def\@makechapterhead#1{% {\parindent \z@ \raggedright \normalfont \huge \bfseries \@chapapp\space\thechapter: #1\par\nobreak \vskip 20\p@ }} \def\@makeschapterhead#1{% {\parindent \z@ \raggedright \normalfont \huge \bfseries #1\par\nobreak \vskip 20\p@ }} %% Titlepage stuff \gdef\@title{} \gdef\title#1{\gdef\@title{#1}} \gdef\@date{} \gdef\date#1{\gdef\@date{#1}} \gdef\@author{} \gdef\author#1{\gdef\@author{#1}} \gdef\@abstract{} \gdef\abstract#1{\gdef\@abstract{#1}} \def\maketitle{\thispagestyle{empty}\let\footnotesize\small% \let\footnoterule\relax %\setcounter{page}{0}% %\null %\vskip 3 in \noindent {\huge\sf \@title}\\ \rule{\textwidth}{1mm}\\ \mbox{}\@author\ \hfill \@date\ \\ \vskip 1 ex \noindent{\sf \@abstract} \setcounter{footnote}{0}% \gdef\@author{}\gdef\@title{}\gdef\@years{}\gdef\@abstract{} \let\maketitle\relax} \def\birdnarrow{\advance\@totalleftmargin by 0.5in} %% Needs to be here for the previous ps@headings defs to work. \pagestyle{headings} \def\progdoc{ \raggedbottom } %%% USEFUL MACROS \newcommand{\linux}{Linux} % Always use this when % refering to the \linux\ % operating system, like that. \newcommand{\key}[1]{{\fbox{\small\tt #1}}} % Use this to mark keys, like % \key{del} for the delete key. \newcommand{\ret}{\fbox{\sf return}} % Special case for the return key. \newcommand{\st}{\small\tt} % Small typewriter -- comes in handy. %\newcommand{\lb}{{\tt\char '173}} % Left Brace '{' %\newcommand{\rb}{{\tt\char '175}} % Right Brace '}' \newcommand{\lbr}{$\langle$} % Left Bracket '<' \newcommand{\rbr}{$\rangle$} % Right Bracket '>' \newcommand{\bs}{{\tt\char '134}} % BackSlash '\' \newcommand{\tm}{${}^{\mbox{\tiny\sf TM}}$} \newcommand{\TM}{\tm} % TM trademark symbol in % either case \newcommand{\cparam}[1]{{\rm \lbr{\sl #1}\rbr}} % Metavariables. %% Define NAMEURL macro to handle the optional name argument %% This calls on the \url macro from the url.sty package so the %% URL will be hyphenated correctly. \def\nameurl#1#2{{\em #2} {\tt <\url{#1}>}} \def\onlynameurl#1{{\em #1}} %% the tscreen environment automatically goes into typewriter type, %% but is otherwise like the screen environment \newenvironment{tscreen}% {\begin{quote}\bgroup\small\tt}% {\egroup\end{quote}} %% Typesetting of function descriptions \def\function{\bigbreak\hrule\nobreak\bigskip\nobreak\leftline{\bf Function}\nobreak\smallskip\nobreak\parskip=0pt\relax} \def\funcsect#1{\medbreak\leftline{\bf #1}\nobreak} bird-2.0.8/doc/sgml2txt0000775000175000017500000000207214025744326013644 0ustar feelafeela#!/usr/bin/perl # # sgmltools.in # # $Id$ # # SGML-Tools driver. Calls all other SGML-Tools components, contains # configuration information, etcetera. # package main; sub BEGIN { require 5.004; } use strict; use vars qw($prefix $DataDir $BinDir $progs); use FindBin; $prefix = "/usr"; $DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; use lib "/usr/perl5"; use lib "/usr/lib/perl5"; use lib "/usr/share/perl5"; $progs = { "NSGMLS" => "/usr/bin/nsgmls", "SGMLSASP" => "/usr/bin/sgmlsasp", "GROFF" => "/usr/bin/groff", "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; if (! -x $progs->{"NSGMLS"}) { $progs->{"NSGMLS"} = "/usr/bin/onsgmls"; } $ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog" . (defined $ENV{SGML_CATALOG_FILES} ? ":$ENV{SGML_CATALOG_FILES}" : ""); require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("txt", @ARGV); for my $curfile (@FileList) { LinuxDocTools::process_file ($curfile); } exit 0; bird-2.0.8/doc/sgml2latex0000775000175000017500000000207414025744326014144 0ustar feelafeela#!/usr/bin/perl # # sgmltools.in # # $Id$ # # SGML-Tools driver. Calls all other SGML-Tools components, contains # configuration information, etcetera. # package main; sub BEGIN { require 5.004; } use strict; use vars qw($prefix $DataDir $BinDir $progs); use FindBin; $prefix = "/usr"; $DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; use lib "/usr/perl5"; use lib "/usr/lib/perl5"; use lib "/usr/share/perl5"; $progs = { "NSGMLS" => "/usr/bin/nsgmls", "SGMLSASP" => "/usr/bin/sgmlsasp", "GROFF" => "/usr/bin/groff", "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; if (! -x $progs->{"NSGMLS"}) { $progs->{"NSGMLS"} = "/usr/bin/onsgmls"; } $ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog" . (defined $ENV{SGML_CATALOG_FILES} ? ":$ENV{SGML_CATALOG_FILES}" : ""); require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("latex", @ARGV); for my $curfile (@FileList) { LinuxDocTools::process_file ($curfile); } exit 0; bird-2.0.8/doc/sgml2html0000775000175000017500000000207314025744326013772 0ustar feelafeela#!/usr/bin/perl # # sgmltools.in # # $Id$ # # SGML-Tools driver. Calls all other SGML-Tools components, contains # configuration information, etcetera. # package main; sub BEGIN { require 5.004; } use strict; use vars qw($prefix $DataDir $BinDir $progs); use FindBin; $prefix = "/usr"; $DataDir = "$FindBin::Bin/sbase"; $BinDir = "/usr/bin"; use lib "/usr/share/linuxdoc-tools"; use lib "/usr/perl5"; use lib "/usr/lib/perl5"; use lib "/usr/share/perl5"; $progs = { "NSGMLS" => "/usr/bin/nsgmls", "SGMLSASP" => "/usr/bin/sgmlsasp", "GROFF" => "/usr/bin/groff", "GROFFMACRO" => "-ms", "AWK" => "/usr/share/linuxdoc-tools/awkwhich" }; if (! -x $progs->{"NSGMLS"}) { $progs->{"NSGMLS"} = "/usr/bin/onsgmls"; } $ENV{"SGML_CATALOG_FILES"} = "$DataDir/dtd/catalog" . (defined $ENV{SGML_CATALOG_FILES} ? ":$ENV{SGML_CATALOG_FILES}" : ""); require "$FindBin::Bin/LinuxDocTools.pm"; &LinuxDocTools::init; my @FileList = LinuxDocTools::process_options ("html", @ARGV); for my $curfile (@FileList) { LinuxDocTools::process_file ($curfile); } exit 0; bird-2.0.8/doc/sbase/0000775000175000017500000000000014025744326013226 5ustar feelafeelabird-2.0.8/doc/sbase/dtd/0000775000175000017500000000000014025744326014001 5ustar feelafeelabird-2.0.8/doc/sbase/dtd/isoent0000664000175000017500000000355714025744326015237 0ustar feelafeela %ISOdia; %ISOgrk3; %ISOlat1; %ISOnum; %ISOpub; bird-2.0.8/doc/sbase/dtd/common0000664000175000017500000000547214025744326015224 0ustar feelafeela bird-2.0.8/doc/sbase/dtd/catalog0000664000175000017500000000413314025744326015337 0ustar feelafeela-- This is a DTD, but will be read as -*- sgml -*- -- -- ================================================= -- -- $Id$ This is dtd/catalog for SGML-Tools. Initial revision June 23st, 1997, by B. Kreimeier $Log$ Revision 1.1 2000-05-29 12:05:22 mj Renamed the DTD from linuxdoc to birddoc. Pavel, please check whether it builds in your environment as well. Revision 1.7 1998/10/13 12:12:09 cg * Clean up catalog file. (CdG) Revision 1.6 1998/03/09 21:10:14 cg * Removed sgmltool.dtd. (CdG) Revision 1.5 1998/01/08 19:59:54 cg * Add empty line, it gave problems. (CdG) Revision 1.4 1997/12/09 20:56:15 cg * Added html32.dtd (with a modified reference to ISOent) and updated catalog accordingly. You can now do sgmlcheck on HTML files. (CdG) Revision 1.3 1997/07/09 13:27:12 cg * Completely new DTD setup by Bernd (BK). -- -- ================================================= -- -- Revision Comments -- -- BK/97/06/23: added a header, changed for 0.99.12 -- -- ================================================= -- DOCTYPE "BIRDDOC" "birddoc.dtd" -- Linuxdoc96.dtd, frozen orignal Linuxdoc DTD -- DOCTYPE "LINUXDOC" "linuxdoc.dtd" PUBLIC "-//LinuxDoc//DTD LinuxDoc 96//EN" linuxdoc96.dtd -- Linuxdoc97 Strict DTD -- PUBLIC "-//LinuxDoc//DTD LinuxDoc 97//EN" linuxdoc97.dtd -- outdated and shared entities -- ENTITY %common "common" ENTITY %isoent "isoent" ENTITY %deprec96 "deprec96" -- for development and debug, internal use only -- DOCTYPE "QWERTZ" "qwertz.dtd" DOCTYPE "TEST" "test.dtd" -- for SGML validation -- DOCTYPE "HTML" "html32.dtd" PUBLIC "-//W3C//DTD HTML 3.2 Final//EN" html32.dtd -- obsolete -- ENTITY %general "general" -- ================================================= -- -- end of dtd/catalog -- -- Local Variables: mode: sgml End: -- -- ================================================= -- bird-2.0.8/doc/sbase/dtd/birddoc.dtd0000664000175000017500000004226414025744326016114 0ustar feelafeela %isoent; ' >

' > ' -- formula begin -- > '> "> "> ' -- formula end -- > " > " > ' > "> bird-2.0.8/doc/sbase/dist/0000775000175000017500000000000014025744326014171 5ustar feelafeelabird-2.0.8/doc/sbase/dist/fmt_txt.pl0000664000175000017500000002177414025744326016226 0ustar feelafeela# # fmt_txt.pl # # $Id$ # # TXT-specific driver stuff # # © Copyright 1996, Cees de Groot # package LinuxDocTools::fmt_txt; use strict; use File::Copy; use Text::EntityMap; use LinuxDocTools::CharEnts; use LinuxDocTools::Lang; use LinuxDocTools::Vars; use LinuxDocTools::Utils qw(create_temp); my $txt = {}; $txt->{NAME} = "txt"; $txt->{HELP} = ""; $txt->{OPTIONS} = [ { option => "manpage", type => "f", short => "m" }, { option => "filter", type => "f", short => "f" }, { option => "blanks", type => "i", short => "b" } ]; $txt->{manpage} = 0; $txt->{filter} = 0; $txt->{blanks} = 3; $Formats{$txt->{NAME}} = $txt; # # Set correct NsgmlsOpts # $txt->{preNSGMLS} = sub { if ($txt->{manpage}) { $global->{NsgmlsOpts} .= " -iman "; $global->{charset} = "man"; } else { $global->{NsgmlsOpts} .= " -ifmttxt "; $global->{charset} = "latin1" if $global->{charset} eq "latin"; } # # Is there a cleaner solution than this? Can't do it earlier, # would show up in the help messages... # # the language support ja. # the charset support nippon. # $global->{format} = $global->{charset}; $global->{charset} = "nippon" if $global->{language} eq "ja"; $global->{format} = "groff" if $global->{format} eq "ascii"; $global->{format} = "groff" if $global->{format} eq "nippon"; $global->{format} = "groff" if $global->{format} eq "euc-kr"; $ENV{SGML_SEARCH_PATH} =~ s/txt/$global->{format}/; $Formats{"groff"} = $txt; $Formats{"latin1"} = $txt; $Formats{"man"} = $txt; $global->{NsgmlsPrePipe} = "cat $global->{file} " ; }; # Ascii escape sub. this is called-back by `parse_data' below in # `txt_preASP' to properly escape `\' characters coming from the SGML # source. my $txt_escape = sub { my ($data) = @_; $data =~ s|"|\\\&\"|g; # Insert zero-width space in front of " $data =~ s|^\.|\\&.|; # ditto in front of . at start of line $data =~ s|\\|\\\\|g; # Escape backslashes return ($data); }; # # Run the file through the genertoc utility before sgmlsasp. Not necessary # when producing a manpage. A lot of code from FJM, untested by me. # $txt->{preASP} = sub { my ($infile, $outfile) = @_; my (@toc, @lines); my $char_maps = load_char_maps ('.2tr', [ Text::EntityMap::sdata_dirs() ]); if ( $global->{charset} eq "latin1" ) { $char_maps = load_char_maps ('.2l1tr', [ Text::EntityMap::sdata_dirs() ]); } if ($txt->{manpage}) { while (<$infile>) { if (/^-/) { my ($str) = $'; chop ($str); print $outfile "-" . parse_data ($str, $char_maps, $txt_escape) . "\n"; next; } elsif (/^A/) { /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ || die "bad attribute data: $_\n"; my ($name,$type,$value) = ($1,$2,$4); if ($type eq "CDATA") { # CDATA attributes get translated also $value = parse_data ($value, $char_maps, $txt_escape); } print $outfile "A$name $type $value\n"; next; } # # Default action if not skipped over with next: copy in to out. # print $outfile $_; } return; } # note the conversion of `sdata_dirs' list to an anonymous array to # make a single argument # # Build TOC. The file is read into @lines in the meantime, we need to # traverse it twice. # push (@toc, "(HLINE\n"); push (@toc, ")HLINE\n"); push (@toc, "(P\n"); push (@toc, "-" . Xlat ("Table of Contents") . "\n"); push (@toc, ")P\n"); push (@toc, "(VERB\n"); my (@prevheader, @header); my $appendix = 0; my $nonprint = 0; while (<$infile>) { push (@lines, $_); if (/^\(SECT(.*)/) { @prevheader = @header; @header = @header[0..$1]; if ($appendix == 1) { $header[$1] = "A"; $appendix = 0; } else { $header[$1]++; } } if (/^\(APPEND(.*)/) { $appendix = 1; } if (/^\(HEADING/) { $_ = <$infile>; s/\\n/ /g; push (@lines, $_); chop; s/^-//; $_ = join(".",@header) . " " . $_; s/\(\\[0-9][0-9][0-9]\)/\\\1/g; if (!$#header) { # put a newline before top-level sections unless previous was also # a top level section $_ = "\\n" . $_ unless (!$#prevheader); # put a . and a space after top level sections s/ /. /; ##### $_ = "-" . $_ . "\\n"; $_ = "-" . $_; } else { # subsections get indentation matching hierarchy $_ = "-" . " " x $#header . $_; } # remove tags from a toc s/\)TT//g; s/\(TT//g; s/\)IT//g; s/\(IT//g; s/\)EM//g; s/\(EM//g; s/\)BF//g; s/\(BF//g; s/AID * CDATA.*$//g; s/\)LABEL//g; s/\(LABEL//g; push(@toc, parse_data ($_, $char_maps, $txt_escape)); $_ = <$infile>; while (!/^\)HEADING/) { s/\\n/ /g; #### push(@lines, $_); chop; s/^-//; # remove tags from a toc s/\)TT//g; s/\(TT//g; s/\)IT//g; s/\(IT//g; s/\)EM//g; s/\(EM//g; s/\)BF//g; s/\(BF//g; s/AID * CDATA.*$//g; s/\)LABEL//g; s/\(LABEL//g; # remove NIDX, NCDX from a toc entry if (/^\(NIDX$/ || /^\(NCDX$/) { $nonprint = 1; } if (/^\)NIDX$/ || /^\)NCDX$/) { $nonprint = 1; } # $_ = "-" . $_ . "\\n"; push(@toc, parse_data ($_, $char_maps, $txt_escape)) if (! $nonprint); $_ = <$infile>; } s/\\n/ /g; ### push(@lines, $_); push(@toc, "\\n\n"); } } push (@toc, ")VERB\n"); push (@toc, "(HLINE\n"); push (@toc, ")HLINE\n"); my $inheading = 0; my $tipo = ''; for (@lines) { if ($inheading) { next if (/^\)TT/ || /^\(TT/ || /^\)IT/ || /^\(IT/ || /^\)EM/ || /^\(EM/ || /^\)BF/ || /^\(BF/); if (/^-/) { $tipo .= $' ; chop ($tipo); $tipo .= " " unless $tipo =~ / $/; } else { $tipo =~ s/ $//; if ($tipo) { print $outfile "-" . parse_data ($tipo, $char_maps, $txt_escape) . "\n"; } print $outfile $_; $tipo = ''; } if (/^\)HEADING/) { $inheading = 0; } next; } if (/^\(HEADING/) { # # Go into heading processing mode. # $tipo = ''; $inheading = 1; } if (/^\(TOC/) { print $outfile @toc; next; } if (/^-/) { my ($str) = $'; chop ($str); print $outfile "-" . parse_data ($str, $char_maps, $txt_escape) . "\n"; next; } elsif (/^A/) { /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ || die "bad attribute data: $_\n"; my ($name,$type,$value) = ($1,$2,$4); if ($type eq "CDATA") { # CDATA attributes get translated also $value = parse_data ($value, $char_maps, $txt_escape); } print $outfile "A$name $type $value\n"; next; } # # Default action if not skipped over with next: copy in to out. # print $outfile $_; } }; # # Take the sgmlsasp output, and make something # useful from it. # $txt->{postASP} = sub { my $infile = shift; my ($outfile, $groffout); if ($txt->{manpage}) { $outfile = new FileHandle ">$global->{filename}.man"; } else { create_temp("$global->{tmpbase}.txt.1"); $outfile = new FileHandle "|$main::progs->{GROFF} $global->{pass} -T $global->{charset} -t $main::progs->{GROFFMACRO} >\"$global->{tmpbase}.txt.1\""; } # # Feed $outfile with roff input. # while (<$infile>) { unless (/^\.DS/.../^\.DE/) { s/^[ \t]{1,}(.*)/$1/g; } s/^\.[ \t].*/\\\&$&/g; s/\\fC/\\fR/g; s/^.ft C/.ft R/g; print $outfile $_; } $outfile->close; # # If we were making a manpage, we're done. Otherwise, a little bit # of work is left. # if ($txt->{manpage}) { return 0; } else { $outfile->open (">$global->{filename}.txt"); $groffout = new FileHandle "<$global->{tmpbase}.txt.1"; my $count = 0; if ($txt->{filter}) { while (<$groffout>) { s/[^\cH][^\cH]\cH\cH//g; s/.//g; if ($txt->{blanks}) { $count = &{$txt->{cutblank}}($count, $outfile, $_); } else { print $outfile $_; } } } else { if ($txt->{blanks}) { while (<$groffout>) { $count = &{$txt->{cutblank}}($count, $outfile, $_); } } else { copy ($groffout, $outfile); } } } $groffout->close; $outfile->close; return 0; }; $txt->{cutblank} = sub { my ($num, $out, $in) = @_; if ( $in =~ /^$/ ) { $num++; } else { $num = 0; } if ( $num <= $txt->{blanks} ) { print $out $in; } return ($num); }; 1; bird-2.0.8/doc/sbase/dist/fmt_latex2e.pl0000664000175000017500000003617214025744326016751 0ustar feelafeela# # fmt_latex2e.pl # # $Id$ # # LaTeX-specific driver stuff # # © Copyright 1996, Cees de Groot # # Support for PDF files: added by Juan Jose Amor, January 2000 # © Copyright 2000, Juan Jose Amor # package LinuxDocTools::fmt_latex2e; use strict; use LinuxDocTools::CharEnts; use LinuxDocTools::Vars; use LinuxDocTools::Lang; use File::Copy; my $latex2e = {}; $latex2e->{NAME} = "latex2e"; $latex2e->{HELP} = <{OPTIONS} = [ { option => "output", type => "l", 'values' => [ "dvi", "tex", "ps", "pdf" ], short => "o" }, { option => "bibtex", type => "f", short => "b" }, { option => "makeindex", type => "f", short => "m" }, { option => "pagenumber", type => "i", short => "n" }, { option => "quick", type => "f", short => "q" }, { option => "dvips", type => "l", 'values' => [ "dvips", "dvi2ps", "jdvi2kps" ], short => "s" }, { option => "latex", type => "l", 'values' => [ "latex", "hlatexp", "platex", "jlatex" ], short => "x" } ]; $latex2e->{output} = "tex"; $latex2e->{pagenumber} = 1; $latex2e->{quick} = 0; $latex2e->{bibtex} = 0; $latex2e->{makeindex} = 0; $latex2e->{latex} = "unknown"; $latex2e->{dvips} = "unknown"; $Formats{$latex2e->{NAME}} = $latex2e; $latex2e->{preNSGMLS} = sub { $global->{NsgmlsOpts} .= " -ifmttex "; # for Japanese jlatex users if ($global->{language} eq "ja" && $latex2e->{latex} eq "unknown") { $latex2e->{latex} = "jlatex"; $latex2e->{dvips} = "dvi2ps"; # for Japanese platex users # $latex2e->{latex} = "platex"; # $latex2e->{dvips} = "dvips"; } # for Korean users if ($global->{language} eq "ko" && $latex2e->{latex} eq "unknown") { $latex2e->{latex} = "hlatexp"; } # default process command $latex2e->{latex} = "latex" if ($latex2e->{latex} eq "unknown"); $latex2e->{dvips} = "dvips" if ($latex2e->{dvips} eq "unknown"); $global->{NsgmlsPrePipe} = "cat $global->{file} "; }; # extra `\\' here for standard `nsgmls' output my %latex2e_escapes; $latex2e_escapes{'#'} = '\\\\#'; $latex2e_escapes{'$'} = '\\\\$'; $latex2e_escapes{'%'} = '\\\\%'; $latex2e_escapes{'&'} = '\\\\&'; $latex2e_escapes{'~'} = '\\\\~{}'; $latex2e_escapes{'_'} = '\\\\_'; $latex2e_escapes{'^'} = '\\\\^{}'; $latex2e_escapes{'\\'} = '\\verb+\\+'; $latex2e_escapes{'{'} = '\\\\{'; $latex2e_escapes{'}'} = '\\\\}'; $latex2e_escapes{'>'} = '{$>$}'; $latex2e_escapes{'<'} = '{$<$}'; # wouldn't happen, but that's what'd be $latex2e_escapes{'|'} = '{$|$}'; my $in_verb; my $remove_comment; # added 2000 Jan 25 by t.sano # passed to `parse_data' below in latex2e_preASP my $latex2e_escape = sub { my ($data) = @_; if (!$in_verb) { # escape special characters $data =~ s|([#\$%&~_^\\{}<>\|])|$latex2e_escapes{$1}|ge; } return ($data); }; # # Translate character entities and escape LaTeX special chars. # $latex2e->{preASP} = sub { my ($infile, $outfile) = @_; # note the conversion of `sdata_dirs' list to an anonymous array to # make a single argument my $tex_char_maps = load_char_maps ('.2tex', [ Text::EntityMap::sdata_dirs() ]); # ASCII char maps are used in the verbatim environment because TeX # ignores all the escapes my $ascii_char_maps = load_char_maps ('.2ab', [ Text::EntityMap::sdata_dirs() ]); $ascii_char_maps = load_char_maps ('.2l1b', [ Text::EntityMap::sdata_dirs() ]) if $global->{charset} eq "latin"; my $char_maps = $tex_char_maps; # used in `latex2e_escape' anonymous sub to switch between escaping # characters from SGML source or not, depending on whether we're in # a VERB or CODE environment or not $in_verb = 0; # switch to remove empty line from TeX source or not, depending # on whether we're in a HEADING or ABSTRACT environment or not $remove_comment = 0; while (<$infile>) { if (/^-/) { my ($str) = $'; chop ($str); $_ = parse_data ($str, $char_maps, $latex2e_escape); if ($remove_comment) { s/(\s+\\n)+//; } print $outfile "-" . $_ . "\n"; } elsif (/^A/) { /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ || die "bad attribute data: $_\n"; my ($name,$type,$value) = ($1,$2,$4); if ($type eq "CDATA") { # CDATA attributes get translated also if ($name eq "URL" or $name eq "ID" or $name eq "CA") { # URL for url.sty is a kind of verbatim... # CA is used in "tabular" element. # Thanks to Evgeny Stambulchik, he posted this fix # on sgml-tools list. 2000 May 17, t.sano my $old_verb = $in_verb; $in_verb = 1; $value = parse_data ($value, $ascii_char_maps, $latex2e_escape); $in_verb = $old_verb; } else { $value = parse_data ($value, $char_maps, $latex2e_escape); } } print $outfile "A$name $type $value\n"; } elsif (/^\((VERB|CODE)/) { print $outfile $_; # going into VERB/CODE section $in_verb = 1; $char_maps = $ascii_char_maps; } elsif (/^\)(VERB|CODE)/) { print $outfile $_; # leaving VERB/CODE section $in_verb = 0; $char_maps = $tex_char_maps; } elsif (/^\((HEADING|ABSTRACT)/) { print $outfile $_; # empty lines (comment in sgml source) do harm # in HEADING or ABSTRACT $remove_comment = 1; } elsif (/^\)(HEADING|ABSTRACT)/) { print $outfile $_; # leaving HEADING or ABSTRACT section $remove_comment = 0; } else { print $outfile $_; } } }; # return the string of the name of the macro for urldef sub latex2e_defnam($) { my ($num) = @_; if ($num > 26*26*26) { die "Too many URLs!\n"; } my $anum = ord("a"); my $defnam = chr ($anum + ($num / 26 / 26)) . chr ($anum + ($num / 26 % 26)) . chr ($anum + ($num % 26)); return ($defnam); }; # # Take the sgmlsasp output, and make something # useful from it. # $latex2e->{postASP} = sub { my $infile = shift; my $filename = $global->{filename}; my $tmplatexdir = $global->{tmpbase} . "-latex-" . $$ . ".dir"; my $tmplatexnam = $tmplatexdir . "/" . $filename; my @epsfiles = (); my @texlines = (); my @urldefines = (); my @urlnames = (); my $urlnum = 0; my $tmpepsf; my $saved_umask = umask; $ENV{TEXINPUTS} .= ":$main::DataDir"; umask 0077; mkdir ($tmplatexdir, 0700) || return -1; # # check epsfile is specified in source file # check nameurl specified in source file # { my $epsf; open SGMLFILE, "<$filename.sgml"; while () { # for epsfile if ( s/^\s*/$1/ ) { s/\s+angle=.*//; s/\s+height=.*//; s/\"//g; $epsf = $_; chop ( $epsf ); push @epsfiles, $epsf; } if ($latex2e->{output} eq "pdf") { if ( s/^\s*/$1/ ) { s/\"//g; $epsf = $_; chop ( $epsf ); push @epsfiles, $epsf; } } } close SGMLFILE; } { my $urlid; my $urlnam; my $urldef; while (<$infile>) { push @texlines, $_; # for nameurl if ( /\\nameurl/ ) { ($urlid, $urlnam) = ($_ =~ /\\nameurl\{(.*)\}\{(.*)\}/); print $urlnum . ": " . $urlid . "\n" if ( $global->{debug} ); $urldef = latex2e_defnam($urlnum) . "url"; s/\\nameurl\{.*\}\{.*\}/{\\em $urlnam} {\\tt \\$urldef}/; push @urlnames, $_; push @urldefines, "\\urldef{\\$urldef} \\url{$urlid}\n"; $urlnum++; } } close $infile; } open OUTFILE, ">$tmplatexnam.tex"; # # Set the correct \documentclass options. # { my $langlit = ISO2English ($global->{language}); $langlit = ($langlit eq 'english') ? "" : ",$langlit"; my $replace = $global->{papersize} . 'paper' . $langlit; my $hlatexopt = ""; $global->{charset} = "nippon" if ($global->{language} eq "ja"); $global->{charset} = "euc-kr" if ($global->{language} eq "ko"); $replace = $global->{papersize} . 'paper' if ($global->{charset} eq "nippon") || ($global->{charset} eq "euc-kr"); while (defined($texlines[0])) { $_ = shift @texlines; if (/^\\documentclass/) { if ($global->{language} ne "en" || $global->{papersize} ne "a4") { s/\\documentclass\[.*\]/\\documentclass\[$replace\]/; } if ($global->{charset} eq "nippon") { if ($latex2e->{latex} eq "platex") { s/{article}/{jarticle}/; } elsif ($latex2e->{latex} eq "jlatex") { s/{article}/{j-article}/; } } $_ = $_ . "\\makeindex\n" if ($latex2e->{makeindex}); } if (/^\\usepackage.epsfig/ && ($global->{charset} eq "euc-kr")) { $hlatexopt = "[noautojosa]" if ($latex2e->{latex} eq "hlatexp"); $_ = $_ . "\\usepackage" . "$hlatexopt" . "{hangul}\n" } if ((/\\usepackage.t1enc/) && (($global->{charset} eq "nippon") || ($global->{charset} eq "euc-kr"))) { s/^/%%/; } if (/%end-preamble/) { if ($latex2e->{pagenumber}) { $_ = $_ . '\setcounter{page}{'. $latex2e->{pagenumber} . "}\n"; } else { $_ = $_ . "\\pagestyle{empty}\n"; } $_ = $_ . $global->{pass} . "\n" if ($global->{pass}); } if (/\\nameurl/ && $latex2e->{output} ne "pdf") { $_ = shift @urlnames; } print OUTFILE; if (/%end-preamble/) { if ($urlnum && $latex2e->{output} ne "pdf") { while (defined($urldefines[0])) { $_ = shift @urldefines; print OUTFILE; } } } } } close OUTFILE; # # LaTeX, dvips, and assorted cleanups. # if ($latex2e->{output} eq "tex") { # comment out, because this backup action is not documented yet. # # if ( -e "$filename.tex" ) { # rename ("$filename.tex", "$filename.tex.back"); # } umask $saved_umask; copy ("$tmplatexnam.tex", "$filename.tex"); if ( ! $global->{debug} ) { unlink ("$tmplatexnam.tex"); rmdir ($tmplatexdir) || return -1; } return 0; } # # Run LaTeX in nonstop mode so it won't prompt & hang on errors. # Suppress the output of LaTeX on all but the last pass, after # references have been resolved. This avoids large numbers of # spurious warnings. # my $current_dir; chop ($current_dir = `pwd`); print $current_dir . "\n" if ( $global->{debug} ); # # copy epsfiles specified in tex file # for my $epsf ( @epsfiles ) { $tmpepsf = $tmplatexdir . "/" . $epsf; print $epsf . " " . $tmpepsf . "\n" if ( $global->{debug} ); copy ("$epsf", "$tmpepsf") or die "can not copy graphics\n"; } # # go to the temporary directory chdir ($tmplatexdir); my ($latexcommand) = "$latex2e->{latex} '\\nonstopmode\\input{$filename.tex}'"; # # We run pdflatex instead of latex if user selected pdf output # if ($latex2e->{output} eq "pdf") { $latexcommand = "pdflatex '\\nonstopmode\\input{$filename.tex}'"; } # # run hlatex if hlatexp is used # for pdf: how about status?(for hlatex and hlatexp) # if ($latex2e->{latex} eq "hlatexp") { #$latex2e->{output} = "ps" if ($latex2e->{output} eq "pdf"); $latexcommand = "hlatex '\\nonstopmode\\input{$filename.tex}'"; } # # We use jlatex for Japanese encoded (euc-jp) characters. # pdf support for Japanese are not yet. use ps for the time being. # if ($global->{charset} eq "nippon") { $latex2e->{output} = "ps" if ($latex2e->{output} eq "pdf"); $latexcommand = "$latex2e->{latex} '\\nonstopmode\\input{$filename.tex}'" } my ($suppress) = $latex2e->{quick} ? "" : ' >/dev/null'; system $latexcommand . $suppress || die "LaTeX problem\n"; $latex2e->{bibtex} && system "bibtex $filename.tex"; $latex2e->{quick} || system $latexcommand . ' >/dev/null'; $latex2e->{quick} || system $latexcommand; if ( ! $global->{debug} ) { my @suffixes = qw(log blg aux toc lof lot dlog bbl out); for my $suf (@suffixes) { unlink "$tmplatexnam.$suf"; } } # # go back to the working directory chdir ($current_dir); # # output dvi file if ($latex2e->{output} eq "dvi") { # comment out, because this backup action is not documented yet. # # if ( -e "$filename.dvi" ) # { # rename ("$filename.dvi", "$filename.dvi.back"); # } umask $saved_umask; copy ("$tmplatexnam.dvi", "$filename.dvi"); if ( $global->{debug} ) { print "Temporary files are in $tmplatexdir\n"; print "Please check there and remove them manually.\n"; } else { unlink ("$tmplatexnam.tex", "$tmplatexnam.dvi"); for my $epsf ( @epsfiles ) { $tmpepsf = $tmplatexdir . "/" . $epsf; print $tmpepsf . "\n" if ( $global->{debug} ); unlink ("$tmpepsf"); } rmdir ($tmplatexdir) || return -1; } return 0; } # # output pdf file if ($latex2e->{output} eq "pdf") { # comment out, because this backup action is not documented yet. # # if ( -e "$filename.pdf" ) # { # rename ("$filename.pdf", "$filename.pdf.back"); # } umask $saved_umask; copy ("$tmplatexnam.pdf", "$filename.pdf"); if ( $global->{debug} ) { print "Temporary files are in $tmplatexdir\n"; print "Please check there and remove them manually.\n"; } else { unlink ("$tmplatexnam.tex", "$tmplatexnam.pdf"); for my $epsf ( @epsfiles ) { $tmpepsf = $tmplatexdir . "/" . $epsf; print $tmpepsf . "\n" if ( $global->{debug} ); unlink ("$tmpepsf"); } rmdir ($tmplatexdir) || return -1; } return 0; } # # convert dvi into ps using dvips command chdir ($tmplatexdir); if ($latex2e->{dvips} eq "dvi2ps") { `dvi2ps -q -o $global->{papersize} -c $tmplatexnam.ps $filename.dvi`; } elsif ($latex2e->{dvips} eq "jdvi2kps") { `jdvi2kps -q -pa $global->{papersize} -o $tmplatexnam.ps $filename.dvi`; } else { `dvips -R -q -t $global->{papersize} -o $tmplatexnam.ps $filename.dvi`; } chdir ($current_dir); # comment out, because this backup action is not documented yet. # # if ( -e "$filename.ps" ) # { # rename ("$filename.ps", "$filename.ps.back"); # } umask $saved_umask; copy ("$tmplatexnam.ps", "$filename.ps"); unlink ("$tmplatexnam.ps"); if ( $global->{debug} ) { print "Temporary files are in $tmplatexdir\n"; print "Please check there and remove them manually.\n"; } else { unlink ("$tmplatexnam.tex", "$tmplatexnam.dvi", "$tmplatexnam.ps"); for my $epsf ( @epsfiles ) { $tmpepsf = $tmplatexdir . "/" . $epsf; print $tmpepsf . "\n" if ( $global->{debug} ); unlink ("$tmpepsf"); } rmdir ($tmplatexdir) || return -1; } return 0; }; 1; bird-2.0.8/doc/sbase/dist/fmt_html.pl0000664000175000017500000001013614025744326016341 0ustar feelafeela# # fmt_html.pl # # $Id$ # # HTML-specific driver stuff # # © Copyright 1996, Cees de Groot # package LinuxDocTools::fmt_html; use strict; use LinuxDocTools::CharEnts; use LinuxDocTools::Vars; use LinuxDocTools::FixRef; my $fixref = $LinuxDocTools::FixRef::fixref; use LinuxDocTools::Html2Html; my $html2html = $LinuxDocTools::Html2Html::html2html; my $html = {}; $html->{NAME} = "html"; $html->{HELP} = ""; $html->{OPTIONS} = [ { option => "split", type => "l", 'values' => [ "0", "1", "2" ], short => "s" }, { option => "toc", type => "l", 'values' => [ "0", "1", "2" ], short => "T" }, { option => "dosnames", type => "f", short => "h" }, { option => "imagebuttons", type => "f", short => "I"}, { option => "header", type => "s", short => "H"}, { option => "footer", type => "s", short => "F"} ]; $html->{'split'} = 1; $html->{'toc'} = -1; $html->{dosnames} = 0; $html->{imagebuttons} = 0; $html->{header} = ""; $html->{footer} = ""; $html->{preNSGMLS} = sub { $global->{NsgmlsOpts} .= " -ifmthtml "; $global->{NsgmlsPrePipe} = "cat $global->{file}"; }; $Formats{$html->{NAME}} = $html; # HTML escape sub. this is called-back by `parse_data' below in # `html_preASP' to properly escape `<' and `&' characters coming from # the SGML source. my %html_escapes; $html_escapes{'&'} = '&'; $html_escapes{'<'} = '<'; my $html_escape = sub { my ($data) = @_; # replace the char with it's HTML equivalent $data =~ s|([&<])|$html_escapes{$1}|ge; return ($data); }; # # Translate character entities and escape HTML special chars. # $html->{preASP} = sub { my ($infile, $outfile) = @_; # note the conversion of `sdata_dirs' list to an anonymous array to # make a single argument my $char_maps = load_char_maps ('.2html', [ Text::EntityMap::sdata_dirs() ]); while (<$infile>) { if (/^-/) { my ($str) = $'; chop ($str); print $outfile "-" . parse_data ($str, $char_maps, $html_escape) . "\n"; } elsif (/^A/) { /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ || die "bad attribute data: $_\n"; my ($name,$type,$value) = ($1,$2,$4); if ($type eq "CDATA") { # CDATA attributes get translated also $value = parse_data ($value, $char_maps, $html_escape); } print $outfile "A$name $type $value\n"; } else { print $outfile $_; } } return 0; }; # # Take the sgmlsasp output, and make something # useful from it. # $html->{postASP} = sub { my $infile = shift; my $filename = $global->{filename}; # # Set various stuff as a result of option processing. # my $ext = "html"; $ext = "htm" if $html->{dosnames}; my $img = 0; $img = 1 if $html->{imagebuttons}; # # Bring in file # my @file = <$infile>; # # Find references # &{$fixref->{init}}($html->{'split'}); LINE: foreach (@file) { foreach my $pat (keys %{$fixref->{rules}}) { if (/$pat/) { # Call rule function then skip to next line &{$fixref->{rules}->{$pat}}; next LINE; } } &{$fixref->{defaultrule}}; } &{$fixref->{finish}}; # # Run through html2html, preserving stdout # Also, handle prehtml.sed's tasks # my $filter = ""; # $filter = "|$main::progs->{NKF} -e" if ($global->{language} eq "ja"); open SAVEOUT, ">&STDOUT"; open STDOUT, "$filter>$filename.$ext" or die qq(Cannot open "$filename.$ext"); &{$html2html->{init}}($html->{'split'}, $ext, $img, $filename, $fixref->{filenum}, $fixref->{lrec}, $html->{'header'}, $html->{'footer'}, $html->{'toc'}, $global->{tmpbase}, $global->{debug}); LINE: foreach (@file) { s,

,,g; # remove empty

containers foreach my $pat (keys %{$html2html->{rules}}) { if (/$pat/) { # Call rule function then skip to next line &{$html2html->{rules}->{$pat}}; next LINE; } } &{$html2html->{defaultrule}}; } &{$html2html->{finish}}; close STDOUT; open STDOUT, ">&SAVEOUT"; return 0; }; 1; bird-2.0.8/doc/sbase/dist/birddoc/0000775000175000017500000000000014025744326015577 5ustar feelafeelabird-2.0.8/doc/sbase/dist/birddoc/latex2e/0000775000175000017500000000000014025744326017143 5ustar feelafeelabird-2.0.8/doc/sbase/dist/birddoc/latex2e/mapping0000664000175000017500000001477614025744326020540 0ustar feelafeela % birddoc to LaTeX replacement file % The \relax is there to avoid sgml2latex rewriting the class + "\\relax\\documentclass\[a4paper,10pt,openany,oneside\]{book}\n" "\\usepackage\[colorlinks=true,linkcolor=blue,pdftitle={BIRD User's Guide}\]{hyperref}\n" "\\usepackage{enumitem}\n" "\\usepackage{birddoc}\n" "\\usepackage{qwertz}\n" "\\usepackage{url}\n" "\\usepackage\[latin1\]{inputenc}\n" "\\usepackage{epsfig}\n" "\\usepackage{[OPTS]}\n" "\\pagestyle{headings}%end-preamble\n" + + "\\end{document}" + % Manual Pages are expected to be formatted using nroff (or groff), unless % they are included as sections of other qwertz documents. "\\progdoc" + "\n\n\\begin{document}\n" "\\maketitle\n" + + "\\title{" "}" + "\\\\\n" "{\\large " "}" + + "\\author{" "}" + "\\and " + "\\thanks{" "}" " \\\\\n\\\\" + + "\\date{" "}" + "\\\\ "
+ "\\markboth"
"{" "}" "{" "}" + % + "\n\n\\begin{verbatim}" + % + "\\end{verbatim}\n\n" + "{\\tt " "}" % Hacked by mdw to use linuxdoc-sgml \abstract{...} + "\\abstract{" "}" + + "\n \\appendix \n" + + "\\tableofcontents" + + "\\listoffigures" + + "\\listoftables" + + "\n\\chapter" + "\n\\section" + "\n\\subsection" + "\n\\subsubsection" + "\n\\paragraph" + "\n\\subparagraph" "{" "}\n\n"

"\\phantomsection{}"

"\n\n" + "\\begin{itemize}" + + "\\end{itemize}" + + "\\begin{enumerate}" + + "\\end{enumerate}" + + "\\begin{list}{}{}\n" + + "\\end{list}" + + "\\begin{description}\[style=unboxed\]" + + "\\end{description}" + + "\\item " + "\\phantomsection\\item\[{\\ttfamily " "}\] \\hfil\\break\n" + + "\\item\[ " "\] \\hfil\\break\n" + "\\cite{[ID]" "}" "\\cite\[[NOTE]\]{[ID]" "}" "\\idx{" "}" "\\cdx{" "}" "\\nidx{" "}" "\\ncdx{" "}" % The idea here is to automatically insert soft hyphens after every slash in % the filename, so long filenames will break naturally. The url{} macro is % a kluge but it works, "{\\tt " "}" "\\footnote{" "}" "``" "''" + "\\begin{quotation}\n" + + "\n\\end{quotation}\n\n" + "{\\it " "\\/}" "{\\it " "\\/}" "{\\bf " "}" "{\\it " "\\/}" "{\\sf " "}" "{\\sl " "}" "{\\rm " "}" "{\\tt " "}" "{\\tt " "}" "{\\tt " "}" "{\\it " "\\/}" "{\\tt " "}" "{\\it " "\\/}" "{\\rm " "}" "{\\it " "\\/}" "{\\function " "}\n\n" "\n\\funcsect{" "}" "\\hrule" % Added by mdw "\\cparam{" "}" "\\hyperref\[[ID]\]{[NAME]} (p.\\,\\getpagerefnumber{[ID]})" "\\pageref{[ID]}" %url added by HG "\\href{[URL]}{[NAME]}" "\\href{[URL]}{[NAME]}" "\\href{http://www.rfc-editor.org/info/rfc[ID]}{RFC [ID]}" + "\\bibliographystyle{[STYLE]}\n" "\\bibliography{[FILES]}\n" "\\addbibtoc{}" + % + "\\macro{[ID]}{\\qw[ID]}" % %
+ "\\macro{qwmain}{\\qwmain}" %
% + "\\par\n" % "\\medbreak\\hrule\\nopagebreak\n" % "\\begin{verbatim}" + % % + "\\end{verbatim}\n" % "\\nopagebreak\\hrule\\medbreak\n" + + "\\par\n" "\\goodbreak{\\birdnarrow\n" "\\begin{verbatim}" + + "\\end{verbatim}\n" "}\\smallbreak\n" + + "\\begin{verbatim}" + + "\\end{verbatim}" + % tscreen added by mdw + "\\begin{tscreen}" + + "\\end{tscreen}" + + "\\begin{quotation}" + + "\\end{quotation}" + % theorems and such + "\\begin{definition}" + "\\end{definition}\n\n" + + "\\begin{proposition}" + + "\\end{proposition}" + + "\\begin{lemma}" + "\\end{lemma}\n\n" + + "\\begin{corollary}" + "\\end{corollary}\n\n" + + "\n{\\noindent{\\bf Proof.} " + + "}" + "\\begin{theorem}" + "\\end{theorem}\n\n" + "\[" "\]" + % mathematics "$" "$" + "\\\[" "\\\]" + + "\\begin{equation}" + + "\\end{equation}\n" + "\\frac" "{" "}" "{" "}" "_{" "}"
    "^{"
"}" "\\prod" "\\int" "\\sum" "\\sqrt\[[n]\]{" "}" + "\\begin{array}{[ca]}" + + "\\end{array}" + " \\\\ " + " & " "^{" "}" "_{" "}" "\\underline{" "}" "\\overline{" "}" "\\mbox{\\tt " "}" "\\vec{" "}" "{\\cal " "}" "{\\rm " "}" "\\\\ \n" % figures
+ "\\begin{figure}\[[LOC]\]" +
+ "\\end{figure}\n" + + "\\centerline{\\epsfig{file=[FILE],height=[HEIGHT],angle=[ANGLE]}}" + + "\\vspace{[VSPACE]}\n\\par" + + "\\caption{" "}" + % tables + "\\begin{table}\[[LOC]\]" +
+ "\\end{table}" + + "\\begin{center}\n" "\\begin{tabular}{[ca]}" + + "\\end{tabular}\n" "\\end{center}" + "\\\\ " + "& " + "\\hline" + % end of latex replacement file bird-2.0.8/doc/sbase/dist/birddoc/html/0000775000175000017500000000000014025744326016543 5ustar feelafeelabird-2.0.8/doc/sbase/dist/birddoc/html/mapping0000664000175000017500000001377614025744326020137 0ustar feelafeela % Converts qwertz files to html files ready for fixref and html2html. % % This file is R-Rated because of uglyness. % % -Magnus + "<@@enddoc>" +
+ "<@@enddoc>" + + "<@@enddoc>" + + "<@@enddoc>" + + "<@@enddoc>" + % Manual Pages are expected to be formatted using nroff (or groff), unless % they are included as sections of other qwertz documents. + "<@@title>" + "

" "

" + + "

" "

" " and " + "Thanks " + "

" "

" + "
"
+ "" + + "" + + "

Comment

" +
+ "


\n"
"\n
" + + "

Appendix

" +
+ "<@@chapt>" + "<@@endchapt>" + + "<@@sect>" + "<@@endsect>" + + "<@@ssect>" + "<@@endssect>" + + "<@@head>" + "<@@head>" + "<@@head>" + "<@@endhead>" +

"

"

"" + "
" + "
    " + + "
" + + "
    " + + "
" + + "
" + + "
" + + "
  • " "
  • " + "
    " "
    " "
    " "
    " "[[ID]]" "[[NOTE] ([ID])]" "" "" + "
    " "
    " + "\"" "\"" + "" + + "" + "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "

    Function

    \n"
    "\n" "

    " "

    \n" % url support by HG + "<@@url>[URL]\n" "[NAME]\n" "<@@endurl>" + "[NAME]" "RFC [ID]" % ref modified to have an optional name field + "<@@ref>[ID]\n" "[NAME]\n" "<@@endref>" + + "<@@ref>[ID]" + + "<@@ref>[ID]" + + "" + + "" + "" "" + "" + + "
    \n
    "		+
    		+	"
    \n
    " + + "
    "		+
    		+	"
    " + + "
    " + + "
    " + + "
    " + + "
    " + % theorems and such + "" + "" + + "" + "" + + "" + "" + + "" + "" + + "" + "" + + "" + "" + "" "" % mathematics + "" + + "" + + "" + + "" + "" "" "" "" "" "" "" "" "" "" "" ""
      "
        "
      "
    " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" % figures
    + "
    " +
    + "
    " + + "" + + "" + + "" + + "" "" + % tables + "
    \n" +
    + "\n" + + "
    \n" +
    + "\n" + "" + "" + "" + % slides + "" + + "" + + "" + + "" + % letters + "" + + "" + + "" + + "" + + "" "" + + "" + "" + + "" + "" + % first end definition of name
    + "
    " +
    + "
    " + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" "" + + "" + + "" + % end of html replacement file bird-2.0.8/doc/sbase/dist/birddoc/groff/0000775000175000017500000000000014025744326016702 5ustar feelafeelabird-2.0.8/doc/sbase/dist/birddoc/groff/mapping0000664000175000017500000002676414025744326020277 0ustar feelafeela% linuxdoc replacement file % translates into nroff, using ms macros % manpages can be processed using the man macros % does not use neqn for math. % Based on qwertz replacement file by Tom Gordon % linuxdoc mods by mdw % Groff dependencies are few. To port to another roff: % 1. Check and modify, if necessary, font changes. (e.g. In psroff the % same fonts have other names.) % 2. Check the code for including Encapsulated PostScript, generated % for eps elements. % 3. Also make versions of general.grops and math.grops, which are sed % scripts translating character entities into groff character references. + ".nr PS 11\n" % Hacked by mdw ".nr PI 3n\n" ".ds CF \\\\n\%\n" ".ds CH \\&\n" ".ds dR $\n" % dollar, to avoid EQN conflicts % Start with no TOC ".ds printtoc\n" % Footnote style ".nr FF 1\n" % James Clark's trick to prevent unintended paragraph % breaks ".tr \\&\n" % horizontal line ".de hl\n" ".br\n" "\\l'\\\\n(.lu-\\\\n(.iu'\n" "..\n" % paragraph spacing ".if n .nr PD 1v\n" % margins added by mdw ".nr PO 0.25i\n" ".po 0.25i\n" ".nr LL 7.0i\n" ".nr TL 7.0i\n" ".nr HM 0i\n" ".nr FM 0i\n" % Turn off right-margin filling ".na\n" % h is 1 if first paragraph after heading ".nr h 0\n" % initialize heading level ".nr il 1\n" % Number registers for list ".nr bi 0\n" % initialize begin items ".nr ll 0\n" % list level, stores current level ".nr el 0\n" % current enumeration level % Not all list levels are enumerations, as % itemizations can be embedded within enumerations % and vice versa % type of list level is in \n(t\n(ll, where % 0 : itemize, 1 : enumerate, 2: description % enumerator for an enumeration level is in % \n(e\n(el -- i.e. \n(e1=2 means current item of % enumeration level 1 is 2 % context-sensitive paragraph macro % Bug: There's some problem using this to re-start paragraphs after the %
    and
    , so after verb and code I insert .LP. That's fine % except that is loses indentation when using verb or code inside of a list. ".de Pp\n" ".ie \\\\n(ll>0 \\{\\\n" % within list? ".ie \\\\n(bi=1 \\{\\\n" % first par element of item? ".nr bi 0\n" % reset bi flag % if itemization, mark with a bullet ".if \\\\n(t\\\\n(ll=0 \\{.IP \\\\(bu\\}\n" % itemize % if enumeration: increment and print enumerator % for this enumeration level ".if \\\\n(t\\\\n(ll=1 \\{.IP \\\\n+(e\\\\n(el.\\}\n" % if first par element of descrip, do nothing ".\\}\n" ".el .sp \n" % subsequent par element of item ".\\}\n" ".el \\{\\\n" % not within list ".ie \\\\nh=1 \\{\\\n" % first par after heading ".LP\n" ".nr h 0\n" % reset h flag ".\\}\n" ".el .LP \n" % Changed from .PP, mdw ".\\}\n" ".nh\n" "..\n" % for each level, a number register is created % to store its type and current item number, where % -1=bullet of an itemized list. % Format of list level enumerators ".ds f1 1\n" ".ds f2 a\n" ".ds f3 i\n" ".ds f4 A\n" % Number registers for theorems ".nr def 0\n" ".nr prop 0\n" ".nr lemma 0\n" ".nr coroll 0\n" ".nr proof 0\n" ".nr theorem 0\n" % Reference commands % redefine superscript strings so that refer tags look like [this] ".ds \[. \[\n" ".ds .\] \]\n" % set initial level of headings, in register il
    + ".nr il 0" +
    + ".if '\\*[printtoc]'true' .PX\n" + ".nr il 1" + + ".bp\n" ".rm LH\n.rm RH\n" ".TC" + + ".nr il 1" + + ".rm LH\n.rm RH\n" ".bp\n" ".TC" + + ".nr il -1" + % Hacked up titlepag stuff to look more reasonable. Titles and author % names are now stored in strings, printed by the end of . % Wake up! This uses groff-like long string names. You must use groff % to format this. + ".ds mdwtitle\n" ".ds mdwsubtitle\n" ".ds mdwdate\n" ".de printabstract\n" "..\n" + + "\\*[mdwtitle]\n" ".br\n" ".if !'\\*[mdwsubtitle]'' \\*[mdwsubtitle]\n" ".br\n" ".printauthor\n" ".br\n" "\\*[mdwdate]\n" ".br\n" ".printabstract\n" ".br\n" % + ".TL" + % + ".ds mdwtitle " + % + ".br\n" % ".ft R\n" % ".SM" + % + ".LG" + + ".ds mdwsubtitle " + + ".ds mdwdate " + + ".de printabstract\n" ".LP\n" + ".." + % author needs to be set up as its own macro, fired off from .printtitle. + ".de printauthor" + + ".." + % + ".AU" + % + ".br" + "\\**\n" ".FS" + + ".FE" + + ".br" + % + ".br" + + ".br"
    + ".EH '" "'''" + + ".OH '''" "'" + + "(*" + + "*)" + % New abstract given above --mdw % + ".AB" + % + ".AE" + + ".af H1 A" + % limitation: no list of figures or tables. A table of contents % is always generated for books and reports. Thus these next three tags % are no-ops % For now, no table-of-contents in ASCII output. (Uncomment this if % desired). % + ".ds printtoc true" % + ".bp\n" ".NH \\n(il " + + ".NH 1+\\n(il" + + ".NH 2+\\n(il" + + ".NH 3+\\n(il" + + ".NH 4+\\n(il" + + ".NH 5+\\n(il" + ".ds h " + "\\*h\n" ".XS \\n%\n" "\\*(SN \\*h\n" ".XE\n" ".nr h 1\n" % set heading flag to true

    + ".Pp" +

    + ".nr ll +1\n" % increment list level ".nr t\\n(ll 0\n" % set type of level to itemize + ".nr ll -1\n" % decrement list level + ".nr ll +1\n" % increment list level ".nr el +1\n" % increment enumeration level ".nr t\\n(ll 1\n" % set type of level to enum ".nr e\\n(el 0 1\n" % initialize enumerator ".af e\\n(el \\*(f\\n(el\n" % style of enumerator ".if \\n(ll>1 .RS" + + ".if \\n(ll>1 .RE\n" ".br\n" ".nr el -1\n" % decrement enumeration level ".nr ll -1\n" % decrement list level + ".RS\n" ".nr ll +1\n" % increment list level ".nr t\\n(ll 2\n" % set type of level to descrip + ".nr ll -1\n" % decrement list level ".RE" + % number register bi means "begin item". Used in the .P macro to print % bullets or numbers at beginning of first paragraph of an item. % If bi=1 then the paragraph is the first one of the item. + ".nr bi 1\n.Pp" + + ".IP \"\\fB" "\\fR\"\n" ".nr bi 1" + "" "" "" "" + ".\[\n[ID]\n.\]" + + ".\[\n[ID]\n.\]\n([NOTE])" " (-- " "--)" + "\\*Q" "\\*U" + ".RS\n" ".nr LL \\n(LL-\\n(PI" + + ".nr LL \\n(LL+\\n(PI\n" ".RE" + "\\fI" "\\fP" "\\fB" "\\fR" "\\fI" "\\fR" "\\fR" "\\fR" "\\fI" "\\fR" % Changed by mdw "\\fC" "\\fR" % Added by mdw "\\fI<" ">\\fR" "[NAME] <\\fC[URL]\\fR>" "[NAME]" "``[NAME]''" + "\\#" "\\n" + "\\#" "\\n" "??" + ".\[\n" "$LIST$\n" ".\]" + + ".DS L\n" ".hl\n" ".ft R\n" + + ".hl\n" ".DE\n" ".ft P\n" % ".Pp" + % continue previous paragraph (changed mdw) ".LP" + ".DS L\n" ".ft R\n" + + ".DE\n" ".ft P\n" % ".Pp" + % continue previous paragraph (changed mdw) ".LP" % tscreen added by mdw + ".br\n" ".po 0.75i\n" ".ll 6.0i\n" ".ft C\n" ".LP\n" % Used to be Pp + ".br\n" ".po 0.25i\n" ".ll 7.0i\n" ".ft R\n" % This might not be correct ".LP\n" % Used to be Pp + ".br\n" ".po 0.75i\n" ".ll 6.0i\n" ".nr LL 6.0i\n" ".LP\n" % Used to be Pp + ".br\n" ".po 0.25i\n" ".ll 7.0i\n" ".nr LL 7.0i\n" ".LP\n" % Used to be Pp % theorems and such + ".sp\n" ".nr def \\n\[def\]+1\n" ".B \"Definition \\n\[def\] \"" + + ".ft P\n.sp" + + ".sp\n" ".nr prop \\n\[prop\]+1\n" ".B \"Proposition \\n\[prop\] \"" + + ".ft P\n.sp" + + ".sp\n" ".nr lemma \\n\[lemma\]+1\n" ".B \"Lemma \\n\[lemma\] \"" + + ".ft P\n.sp" + + ".sp\n" ".nr coroll \\n\[coroll\]+1\n" ".B \"Corolloary \\n\[coroll\] \"" + + ".ft P\n.sp" + + ".sp\n" ".nr proof \\n\[proof\]+1\n" ".B \"Proof \\n\[proof\] \"" + + ".ft P\n.sp" + + ".sp\n" ".nr theorem \\n\[theorem\]+1\n" ".B \"Theorem \\n\[theorem\] \"" + + ".ft P\n.sp" + + ".B\n(" ")\n.I" + % mathematics -- this nroff version needs work. + ".DS L" + + ".DE" + + ".DS L" + + ".DE" + "{" "} over " "{" "}" " from {" "}"
      " to {"
    "}" " prod " " int " " sum " % limitation: eqn only does square roots! " sqrt {" "}" + ".TS\n" "center, tab(|) ;\n" "[ca]." + + ".TE" + "\n" "|" " sup {" "}" " sub {" "}" "{" "} under " "{" "} bar " " bold{" "}" "{" "} vec " % limitation: no calligraphic characters, using helvetica italics instead. Is there a better font? "\\fI" "\\fP" " roman }" "}" + ".br" + % figures
    % + ".KF" +
    % + ".KE" + + ".if t .PSPIC [file].ps\n" ".if n .sp 4" + % Are TeX units properly handled by this translation of ph? + ".sp [VSPACE]" + + ".sp\n.ce" + % tables + ".KF\n.R" +
    + ".KE" + + ".TS\n" "center, tab(|) ; \n" "[ca]." + + ".TE" + "\n" + "|" % + "_" + % gregh + ".hl\n" + + ".nr PS 18" + + ".bp\n\\&" + % letters -- replacement for email, using mh format. + ".nf" + + + "From: " + "To: "
    + ".de Ad\n"
    + ".." + " <" ">" + "Subject: " + "Sref: " + "In-Reply-To: " + "cc: " + ".fi\n.LP" + + ".LP" + + ".XP\n" "encl: " + ".LP\np.s." % end of roff replacement file bird-2.0.8/doc/sbase/VERSION0000664000175000017500000000000614025744326014272 0ustar feelafeela1.0.9 bird-2.0.8/doc/reply_codes0000664000175000017500000000337414025744326014373 0ustar feelafeelaReply codes of BIRD command-line interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0xxx Action suceessfully completed 1xxx Table entry 2xxx Table heading 8xxx Run-time error 9xxx Parse-time error Continuation + Spontaneous printout 0000 OK 0001 Welcome 0002 Reading configuration 0003 Reconfigured 0004 Reconfiguration in progress 0005 Reconfiguration already in progress, queueing 0006 Reconfiguration ignored, shutting down 0007 Shutdown ordered 0008 Already disabled 0009 Disabled 0010 Already enabled 0011 Enabled 0012 Restarted 0013 Status report 0014 Route count 0015 Reloading 0016 Access restricted 0017 Reconfiguration already in progress, removing queued config 0018 Reconfiguration confirmed 0019 Nothing to do (configure undo/confirm) 0020 Configuration OK 0021 Undo requested 0022 Undo scheduled 0023 Evaluation of expression 0024 Graceful restart status report 0025 Graceful restart ordered 1000 BIRD version 1001 Interface list 1002 Protocol list 1003 Interface address 1004 Interface flags 1005 Interface summary 1006 Protocol details 1007 Route list 1008 Route details 1009 Static route list 1010 Symbol list 1011 Uptime 1012 Route extended attribute list 1013 Show ospf neighbors 1014 Show ospf 1015 Show ospf interface 1016 Show ospf state/topology 1017 Show ospf lsadb 1018 Show memory 1019 Show ROA list 1020 Show BFD sessions 1021 Show RIP interface 1022 Show RIP neighbors 1023 Show Babel interfaces 1024 Show Babel neighbors 1025 Show Babel entries 8000 Reply too long 8001 Route not found 8002 Configuration file error 8003 No protocols match 8004 Stopped due to reconfiguration 8005 Protocol is down => cannot dump 8006 Reload failed 8007 Access denied 8008 Evaluation runtime error 9000 Command too long 9001 Parse error 9002 Invalid symbol type bird-2.0.8/doc/prog-spell.sed0000664000175000017500000000042214025744326014710 0ustar feelafeelas%[^<]*%%g s%[^<]*%%g s%[^<]*%%g s%[^<]*%%g s%/ ]\+/%%g s%/ ]*>%%g s%&[^;]*;%%g bird-2.0.8/doc/prog-root0000664000175000017500000000015614025744326014006 0ustar feelafeelaD doc/prog-head.sgml D doc/prog-intro.sgml C nest C conf C filter C proto C sysdep C lib D doc/prog-foot.sgml bird-2.0.8/doc/prog-intro.sgml0000664000175000017500000001772614025744326015132 0ustar feelafeelaBIRD Design Introduction

    This document describes the internal workings of BIRD, its architecture, design decisions and rationale behind them. It also contains documentation on all the essential components of the system and their interfaces.

    Routing daemons are complicated things which need to act in real time to complex sequences of external events, respond correctly even to the most erroneous behavior of their environment and still handle enormous amount of data with reasonable speed. Due to all of this, their design is very tricky as one needs to carefully balance between efficiency, stability and (last, but not least) simplicity of the program and it would be possible to write literally hundreds of pages about all of these issues. In accordance to the famous quote of Anton Chekhov "Shortness is a sister of talent", we've tried to write a much shorter document highlighting the most important stuff and leaving the boring technical details better explained by the program source itself together with comments contained therein. Design goals

    When planning the architecture of BIRD, we've taken a close look at the other existing routing daemons and also at some of the operating systems used on dedicated routers, gathered all important features and added lots of new ones to overcome their shortcomings and to better match the requirements of routing in today's Internet: IPv6, policy routing, route filtering and so on. From this planning, the following set of design goals has arisen: Support all the standard routing protocols and make it easy to add new ones. This leads to modularity and clean separation between the core and the protocols. Support both IPv4 and IPv6 in the same source tree, re-using most of the code. This leads to abstraction of IP addresses and operations on them. Minimize OS dependent code to make porting as easy as possible. Unfortunately, such code cannot be avoided at all as the details of communication with the IP stack differ from OS to OS and they often vary even between different versions of the same OS. But we can isolate such code in special modules and do the porting by changing or replacing just these modules. Also, don't rely on specific features of various operating systems, but be able to make use of them if they are available. Allow multiple routing tables. Easily solvable by abstracting out routing tables and the corresponding operations. Offer powerful route filtering. There already were several attempts to incorporate route filters to a dynamic router, but most of them have used simple sequences of filtering rules which were very inflexible and hard to use for non-trivial filters. We've decided to employ a simple loop-free programming language having access to all the route attributes and being able to modify the most of them. Support easy configuration and re-configuration. Most routers use a simple configuration language designed ad hoc with no structure at all and allow online changes of configuration by using their command-line interface, thus any complex re-configurations are hard to achieve without replacing the configuration file and restarting the whole router. We've decided to use a more general approach: to have a configuration defined in a context-free language with blocks and nesting, to perform all configuration changes by editing the configuration file, but to be able to read the new configuration and smoothly adapt to it without disturbing parts of the routing process which are not affected by the change. Be able to be controlled online. In addition to the online reconfiguration, a routing daemon should be able to communicate with the user and with many other programs (primarily scripts used for network maintenance) in order to make it possible to inspect contents of routing tables, status of all routing protocols and also to control their behavior (disable, enable or reset a protocol without restarting all the others). To achieve this, we implement a simple command-line protocol based on those used by FTP and SMTP (that is textual commands and textual replies accompanied by a numeric code which makes them both readable to a human and easy to recognize in software). Respond to all events in real time. A typical solution to this problem is to use lots of threads to separate the workings of all the routing protocols and also of the user interface parts and to hope that the scheduler will assign time to them in a fair enough manner. This is surely a good solution, but we have resisted the temptation and preferred to avoid the overhead of threading and the large number of locks involved and preferred a event driven architecture with our own scheduling of events. An unpleasant consequence of such an approach is that long lasting tasks must be split to more parts linked by special events or timers to make the CPU available for other tasks as well. Architecture

    The requirements set above have lead to a simple modular architecture containing the following types of modules: Core modules implement the core functions of BIRD: taking care of routing tables, keeping protocol status, interacting with the user using the Command-Line Interface (to be called CLI in the rest of this document) etc. Library modules form a large set of various library functions implementing several data abstractions, utility functions and also functions which are a part of the standard libraries on some systems, but missing on other ones. Resource management modules take care of resources, their allocation and automatic freeing when the module having requested shuts itself down. Configuration modules are fragments of lexical analyzer, grammar rules and the corresponding snippets of C code. For each group of code modules (core, each protocol, filters) there exist a configuration module taking care of all the related configuration stuff. The filter implements the route filtering language. Protocol modules implement the individual routing protocols. System-dependent modules implement the interface between BIRD and specific operating systems. The client is a simple program providing an easy, though friendly interface to the CLI. Implementation

    BIRD has been written in GNU C. We've considered using C++, but we've preferred the simplicity and straightforward nature of C which gives us fine control over all implementation details and on the other hand enough instruments to build the abstractions we need.

    The modules are statically linked to produce a single executable file (except for the client which stands on its own).

    The building process is controlled by a set of Makefiles for GNU Make, intermixed with several Perl and shell scripts.

    The initial configuration of the daemon, detection of system features and selection of the right modules to include for the particular OS and the set of protocols the user has chosen is performed by a configure script generated by GNU Autoconf.

    The parser of the configuration is generated by the GNU Bison.

    The documentation is generated using The comments from C sources which form a part of the programmer's documentation are extracted using a modified version of the If you want to work on BIRD, it's highly recommended to configure it with a bird-2.0.8/doc/prog-head.sgml0000664000175000017500000000105314025744326014662 0ustar feelafeela BIRD Programmer's Documentation <author> Ondrej Filip <it/<feela@network.cz>/, Pavel Machek <it/<pavel@ucw.cz>/, Martin Mares <it/<mj@ucw.cz>/, Ondrej Zajicek <it/<santiago@crfreenet.org>/ </author> <abstract> This document contains programmer's documentation for the BIRD Internet Routing Daemon project. </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/doc/prog-foot.sgml�����������������������������������������������������������������������0000664�0001750�0001750�00000000011�14025744326�014721� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ </book> �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/doc/kernel-doc���������������������������������������������������������������������������0000775�0001750�0001750�00000062552�14025744326�014114� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/usr/bin/perl ## Copyright (c) 1998 Michael Zucchi, All Rights Reserved ## ## ## ## This software falls under the GNU Public License. Please read ## ## the COPYING file for more information ## # # This will read a 'c' file and scan for embedded comments in the # style of gnome comments (+minor extensions - see below). # # Note: This only supports 'c'. # usage: # kerneldoc [ -docbook | -html | -text | -man | -gnome | -bird ] # [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile # or # [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile # # Set output format using one of -docbook -html -text -man -gnome or -bird. Default is man. # # -function funcname # If set, then only generate documentation for the given function(s). All # other functions are ignored. # # -nofunction funcname # If set, then only generate documentation for the other function(s). All # other functions are ignored. Cannot be used with -function together # (yes thats a bug - perl hackers can fix it 8)) # # c files - list of 'c' files to process # # All output goes to stdout, with errors to stderr. # # format of comments. # In the following table, (...)? signifies optional structure. # (...)* signifies 0 or more structure elements # /** # * function_name(:)? (- short description)? # (* @parameterx: (description of parameter x)?)* # (* a blank line)? # * (Description:)? (Description of function)? # * (section header: (section description)? )* # (*)?*/ # # So .. the trivial example would be: # # /** # * my_function # **/ # # If the Description: header tag is ommitted, then there must be a blank line # after the last parameter specification. # e.g. # /** # * my_function - does my stuff # * @my_arg: its mine damnit # * # * Does my stuff explained. # */ # # or, could also use: # /** # * my_function - does my stuff # * @my_arg: its mine damnit # * Description: Does my stuff explained. # */ # etc. # # All descriptions can be multiline, apart from the short function description. # # All descriptive text is further processed, scanning for the following special # patterns, which are highlighted appropriately. # # 'funcname()' - function # '$ENVVAR' - environmental variable # '&struct_name' - name of a structure or a type # '@parameter' - name of a parameter # '%CONST' - name of a constant. # '|code|' - literal string # match expressions used to find embedded type information $type_constant = "\\\%(\\w+)"; $type_func = "(\\w+\\(\\))"; $type_param = "\\\@(\\w+)"; $type_struct = "\\\&(\\w+)"; $type_env = "(\\\$\\w+)"; $type_code = "\\|([^|]*)\\|"; # Output conversion substitutions. # One for each output format # these work fairly well %highlights_html = ( $type_constant, "<i>\$1</i>", $type_func, "<b>\$1</b>", $type_struct, "<i>\$1</i>", $type_param, "<tt><b>\$1</b></tt>" ); $blankline_html = "<p>"; # sgml, docbook format %highlights_sgml = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>", $type_func, "<function>\$1</function>", $type_struct, "<structname>\$1</structname>", $type_env, "<envar>\$1</envar>", $type_param, "<parameter>\$1</parameter>" ); $blankline_sgml = "</para><para>\n"; # gnome, docbook format %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>", $type_func, "<function>\$1</function>", $type_struct, "<structname>\$1</structname>", $type_env, "<envar>\$1</envar>", $type_param, "<parameter>\$1</parameter>" ); $blankline_gnome = "</para><para>\n"; # bird documentation %highlights_bird = ( $type_constant, "<const/\$1/", $type_func, "<func/\$1/", $type_struct, "<struct/\$1/", $type_param, "<param/\$1/", $type_code, "<tt>\$1</tt>"); $blankline_bird = "<p>"; # these are pretty rough %highlights_man = ( $type_constant, "\\n.I \\\"\$1\\\"\\n", $type_func, "\\n.B \\\"\$1\\\"\\n", $type_struct, "\\n.I \\\"\$1\\\"\\n", $type_param."([\.\, ]*)\n?", "\\n.I \\\"\$1\$2\\\"\\n" ); $blankline_man = ""; # text-mode %highlights_text = ( $type_constant, "\$1", $type_func, "\$1", $type_struct, "\$1", $type_param, "\$1" ); $blankline_text = ""; sub usage { print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n"; print " [ -function funcname [ -function funcname ...] ]\n"; print " [ -nofunction funcname [ -nofunction funcname ...] ]\n"; print " c source file(s) > outputfile\n"; exit 1; } # read arguments if ($#ARGV==-1) { usage(); } $verbose = 0; $output_mode = "man"; %highlights = %highlights_man; $blankline = $blankline_man; $modulename = "API Documentation"; $function_only = 0; while ($ARGV[0] =~ m/^-(.*)/) { $cmd = shift @ARGV; if ($cmd eq "-html") { $output_mode = "html"; %highlights = %highlights_html; $blankline = $blankline_html; } elsif ($cmd eq "-man") { $output_mode = "man"; %highlights = %highlights_man; $blankline = $blankline_man; } elsif ($cmd eq "-text") { $output_mode = "text"; %highlights = %highlights_text; $blankline = $blankline_text; } elsif ($cmd eq "-docbook") { $output_mode = "sgml"; %highlights = %highlights_sgml; $blankline = $blankline_sgml; } elsif ($cmd eq "-gnome") { $output_mode = "gnome"; %highlights = %highlights_gnome; $blankline = $blankline_gnome; } elsif ($cmd eq "-bird") { $output_mode = "bird"; %highlights = %highlights_bird; $blankline = $blankline_bird; } elsif ($cmd eq "-module") { # not needed for sgml, inherits from calling document $modulename = shift @ARGV; } elsif ($cmd eq "-function") { # to only output specific functions $function_only = 1; $function = shift @ARGV; $function_table{$function} = 1; } elsif ($cmd eq "-nofunction") { # to only output specific functions $function_only = 2; $function = shift @ARGV; $function_table{$function} = 1; } elsif ($cmd eq "-v") { $verbose = 1; } elsif (($cmd eq "-h") || ($cmd eq "--help")) { usage(); } } # generate a sequence of code that will splice in highlighting information # using the s// operator. $dohighlight = ""; foreach $pattern (keys %highlights) { # print "scanning pattern $pattern ($highlights{$pattern})\n"; $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; } ## # dumps section contents to arrays/hashes intended for that purpose. # sub dump_section { my $name = shift @_; my $contents = join "\n", @_; if ($name =~ m/$type_constant/) { $name = $1; # print STDERR "constant section '$1' = '$contents'\n"; $constants{$name} = $contents; } elsif ($name =~ m/$type_param/) { # print STDERR "parameter def '$1' = '$contents'\n"; $name = $1; $parameters{$name} = $contents; } else { # print STDERR "other section '$name' = '$contents'\n"; $sections{$name} = $contents; push @sectionlist, $name; } } ## # output function # # parameters, a hash. # function => "function name" # parameterlist => @list of parameters # parameters => %parameter descriptions # sectionlist => @list of sections # sections => %descriont descriptions # sub output_highlight { my $contents = join "\n", @_; my $line; eval $dohighlight; foreach $line (split "\n", $contents) { if ($line eq ""){ print $lineprefix, $blankline; } else { $line =~ s/\\\\\\/\&/g; print $lineprefix, $line; } print "\n"; } } # output in html sub output_html { my %args = %{$_[0]}; my ($parameter, $section); my $count; print "<h2>Function</h2>\n"; print "<i>".$args{'functiontype'}."</i>\n"; print "<b>".$args{'function'}."</b>\n"; print "("; $count = 0; foreach $parameter (@{$args{'parameterlist'}}) { print "<i>".$args{'parametertypes'}{$parameter}."</i> <b>".$parameter."</b>\n"; if ($count != $#{$args{'parameterlist'}}) { $count++; print ", "; } } print ")\n"; print "<h3>Arguments</h3>\n"; print "<dl>\n"; foreach $parameter (@{$args{'parameterlist'}}) { print "<dt><i>".$args{'parametertypes'}{$parameter}."</i> <b>".$parameter."</b>\n"; print "<dd>"; output_highlight($args{'parameters'}{$parameter}); } print "</dl>\n"; foreach $section (@{$args{'sectionlist'}}) { print "<h1>$section</h1>\n"; print "<ul>\n"; output_highlight($args{'sections'}{$section}); print "</ul>\n"; } print "<hr>\n"; } # output in html sub output_intro_html { my %args = %{$_[0]}; my ($parameter, $section); my $count; foreach $section (@{$args{'sectionlist'}}) { print "<h1>$section</h1>\n"; print "<ul>\n"; output_highlight($args{'sections'}{$section}); print "</ul>\n"; } print "<hr>\n"; } # output in sgml DocBook sub output_sgml { my %args = %{$_[0]}; my ($parameter, $section); my $count; my $id; $id = $args{'module'}."-".$args{'function'}; $id =~ s/[^A-Za-z0-9]/-/g; print "<refentry>\n"; print "<refmeta>\n"; print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n"; print "</refmeta>\n"; print "<refnamediv>\n"; print " <refname>".$args{'function'}."</refname>\n"; print " <refpurpose>\n"; print " ".$args{'purpose'}."\n"; print " </refpurpose>\n"; print "</refnamediv>\n"; print "<refsynopsisdiv>\n"; print " <title>Synopsis\n"; print " \n"; print " ".$args{'functiontype'}." "; print "".$args{'function'}." "; print "\n"; # print "\n"; # print " Synopsis\n"; # print " \n"; # print " ".$args{'functiontype'}." "; # print "".$args{'function'}." "; # print "\n"; $count = 0; if ($#{$args{'parameterlist'}} >= 0) { foreach $parameter (@{$args{'parameterlist'}}) { print " ".$args{'parametertypes'}{$parameter}; print " $parameter\n"; } } else { print " \n"; } print " \n"; print "\n"; # print "\n"; # print parameters print "\n Arguments\n"; # print "\nArguments\n"; if ($#{$args{'parameterlist'}} >= 0) { print " \n"; foreach $parameter (@{$args{'parameterlist'}}) { print " \n $parameter\n"; print " \n \n"; $lineprefix=" "; output_highlight($args{'parameters'}{$parameter}); print " \n \n \n"; } print " \n"; } else { print " \n None\n \n"; } print "\n"; # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { print "\n $section\n \n"; # print "\n$section\n"; if ($section =~ m/EXAMPLE/i) { print "\n"; } output_highlight($args{'sections'}{$section}); # print ""; if ($section =~ m/EXAMPLE/i) { print "\n"; } print " \n\n"; } print "\n\n"; } # output in sgml DocBook sub output_intro_sgml { my %args = %{$_[0]}; my ($parameter, $section); my $count; my $id; $id = $args{'module'}; $id =~ s/[^A-Za-z0-9]/-/g; # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { print "\n $section\n \n"; # print "\n$section\n"; if ($section =~ m/EXAMPLE/i) { print "\n"; } output_highlight($args{'sections'}{$section}); # print ""; if ($section =~ m/EXAMPLE/i) { print "\n"; } print " \n\n"; } print "\n\n"; } # output in sgml DocBook sub output_gnome { my %args = %{$_[0]}; my ($parameter, $section); my $count; my $id; $id = $args{'module'}."-".$args{'function'}; $id =~ s/[^A-Za-z0-9]/-/g; print "\n"; print " ".$args{'function'}."\n"; # print "\n"; # print " Synopsis\n"; print " \n"; print " ".$args{'functiontype'}." "; print "".$args{'function'}." "; print "\n"; $count = 0; if ($#{$args{'parameterlist'}} >= 0) { foreach $parameter (@{$args{'parameterlist'}}) { print " ".$args{'parametertypes'}{$parameter}; print " $parameter\n"; } } else { print " \n"; } print " \n"; # print "\n"; # print "\n"; # print parameters # print "\n Arguments\n"; # if ($#{$args{'parameterlist'}} >= 0) { # print " \n"; # foreach $parameter (@{$args{'parameterlist'}}) { # print " \n $parameter\n"; # print " \n \n"; # $lineprefix=" "; # output_highlight($args{'parameters'}{$parameter}); # print " \n \n \n"; # } # print " \n"; # } else { # print " \n None\n \n"; # } # print "\n"; # print "\n Arguments\n"; if ($#{$args{'parameterlist'}} >= 0) { print " \n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach $parameter (@{$args{'parameterlist'}}) { print " $parameter\n"; print " \n"; $lineprefix=" "; output_highlight($args{'parameters'}{$parameter}); print " \n"; } print " \n"; } else { print " \n None\n \n"; } # print "\n"; # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { print "\n $section\n"; # print "\n$section\n"; if ($section =~ m/EXAMPLE/i) { print "\n"; } else { } print "\n"; output_highlight($args{'sections'}{$section}); # print ""; print "\n"; if ($section =~ m/EXAMPLE/i) { print "\n"; } else { } print " \n"; } print "\n\n"; } # output in birddoc sub output_bird { my %args = %{$_[0]}; my ($parameter, $section); my $count; print "

    ".$args{'functiontype'}."\n"; print "".$args{'function'}."\n"; print "("; $count = 0; my $ntyped = 0; foreach $parameter (@{$args{'parameterlist'}}) { if ($args{'parametertypes'}{$parameter} ne "") { print "".$args{'parametertypes'}{$parameter}." "; $ntyped++; } print "".$parameter.""; if ($count != $#{$args{'parameterlist'}}) { $count++; print ", "; } } print ")"; if ($args{'purpose'} ne "") { print " -- "; output_highlight($args{'purpose'}); } print "\n"; if ($ntyped) { print "Arguments\n"; print "

    \n"; foreach $parameter (@{$args{'parameterlist'}}) { print "".$args{'parametertypes'}{$parameter}." ".$parameter."\n"; output_highlight($args{'parameters'}{$parameter}); } print "\n"; } foreach $section (@{$args{'sectionlist'}}) { print "$section\n"; print "

    \n"; output_highlight($args{'sections'}{$section}); } print "\n"; } # output in birddoc sub output_intro_bird { my %args = %{$_[0]}; my ($parameter, $section); my $count; my $id; $id = $args{'module'}; $id =~ s/[^A-Za-z0-9]/-/g; # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { print "$section\n

    \n"; output_highlight($args{'sections'}{$section}); } print "\n\n"; } ## # output in man sub output_man { my %args = %{$_[0]}; my ($parameter, $section); my $count; print ".TH \"$args{'module'}\" \"$args{'function'}\" \"25 May 1998\" \"API Manual\" LINUX\n"; print ".SH Function\n"; print ".I \"".$args{'functiontype'}."\"\n"; print ".B \"".$args{'function'}."\"\n"; print "(\n"; $count = 0; foreach $parameter (@{$args{'parameterlist'}}) { print ".I \"".$args{'parametertypes'}{$parameter}."\"\n.B \"".$parameter."\"\n"; if ($count != $#{$args{'parameterlist'}}) { $count++; print ",\n"; } } print ")\n"; print ".SH Arguments\n"; foreach $parameter (@{$args{'parameterlist'}}) { print ".IP \"".$args{'parametertypes'}{$parameter}." ".$parameter."\" 12\n"; output_highlight($args{'parameters'}{$parameter}); } foreach $section (@{$args{'sectionlist'}}) { print ".SH \"$section\"\n"; output_highlight($args{'sections'}{$section}); } } sub output_intro_man { my %args = %{$_[0]}; my ($parameter, $section); my $count; print ".TH \"$args{'module'}\" \"$args{'module'}\" \"25 May 1998\" \"API Manual\" LINUX\n"; foreach $section (@{$args{'sectionlist'}}) { print ".SH \"$section\"\n"; output_highlight($args{'sections'}{$section}); } } ## # output in text sub output_text { my %args = %{$_[0]}; my ($parameter, $section); print "Function = ".$args{'function'}."\n"; print " return type: ".$args{'functiontype'}."\n\n"; foreach $parameter (@{$args{'parameterlist'}}) { print " ".$args{'parametertypes'}{$parameter}." ".$parameter."\n"; print " -> ".$args{'parameters'}{$parameter}."\n"; } foreach $section (@{$args{'sectionlist'}}) { print " $section:\n"; print " -> "; output_highlight($args{'sections'}{$section}); } } sub output_intro_text { my %args = %{$_[0]}; my ($parameter, $section); foreach $section (@{$args{'sectionlist'}}) { print " $section:\n"; print " -> "; output_highlight($args{'sections'}{$section}); } } ## # generic output function - calls the right one based # on current output mode. sub output_function { # output_html(@_); eval "output_".$output_mode."(\@_);"; } ## # generic output function - calls the right one based # on current output mode. sub output_intro { # output_html(@_); eval "output_intro_".$output_mode."(\@_);"; } ## # takes a function prototype and spits out all the details # stored in the global arrays/hsahes. sub dump_function { my $prototype = shift @_; $prototype =~ s/^static+ //; $prototype =~ s/^extern+ //; $prototype =~ s/^inline+ //; $prototype =~ s/^__inline__+ //; if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ || $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ || $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ || $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ || $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/) { $return_type = $1; $function_name = $2; $args = $3; # print STDERR "ARGS = '$args'\n"; foreach $arg (split ',', $args) { # strip leading/trailing spaces $arg =~ s/^\s*//; $arg =~ s/\s*$//; # print STDERR "SCAN ARG: '$arg'\n"; @args = split('\s', $arg); # print STDERR " -> @args\n"; $param = pop @args; # print STDERR " -> @args\n"; if ($param =~ m/^(\*+)(.*)/) { $param = $2; push @args, $1; } $type = join " ", @args; if ($type eq "" && $param eq "...") { $type="..."; $param="..."; $parameters{"..."} = "variable arguments"; } if ($type eq "") { $type=""; $param="void"; $parameters{void} = "no arguments"; } if ($parameters{$param} eq "") { $parameters{$param} = "-- undescribed --"; print STDERR "Warning($lineno): Function parameter '$param' not described in '$function_name'\n"; } push @parameterlist, $param; $parametertypes{$param} = $type; # print STDERR "param = '$param', type = '$type'\n"; } } else { print STDERR "Error($lineno): cannot understand prototype: '$prototype'\n"; return; } if ($function_only==0 || ( $function_only == 1 && defined($function_table{$function_name})) || ( $function_only == 2 && !defined($function_table{$function_name}))) { output_function({'function' => $function_name, 'module' => $modulename, 'functiontype' => $return_type, 'parameterlist' => \@parameterlist, 'parameters' => \%parameters, 'parametertypes' => \%parametertypes, 'sectionlist' => \@sectionlist, 'sections' => \%sections, 'purpose' => $function_purpose }); } } ###################################################################### # main # states # 0 - normal code # 1 - looking for function name # 2 - scanning field start. # 3 - scanning prototype. $state = 0; $section = ""; $doc_special = "\@\%\$\&"; $doc_start = "^/\\*\\*\$"; $doc_end = "\\*/"; $doc_com = "\\s*\\*\\s*"; $doc_func = $doc_com."(\\w+):?"; $doc_sect = $doc_com."([".$doc_special."]?[\\w ]+):(.*)"; $doc_content = $doc_com."(.*)"; $doc_block = $doc_com."DOC:\\s*(.*)?"; %constants = (); %parameters = (); @parameterlist = (); %sections = (); @sectionlist = (); $contents = ""; $section_default = "Description"; # default section $section_intro = "Introduction"; $section = $section_default; $lineno = 0; foreach $file (@ARGV) { if (!open(IN,"<$file")) { print STDERR "Error: Cannot open file $file\n"; next; } while () { $lineno++; if ($state == 0) { if (/$doc_start/o) { $state = 1; # next line is always the function name } } elsif ($state == 1) { # this line is the function name (always) if (/$doc_block/o) { $state = 4; $contents = ""; if ( $1 eq "" ) { $section = $section_intro; } else { $section = $1; } } elsif (/$doc_func/o) { $function = $1; $state = 2; if (/-(.*)/) { $function_purpose = $1; } else { $function_purpose = ""; } if ($verbose) { print STDERR "Info($lineno): Scanning doc for $function\n"; } } else { print STDERR "WARN($lineno): Cannot understand $_ on line $lineno", " - I thought it was a doc line\n"; $state = 0; } } elsif ($state == 2) { # look for head: lines, and include content if (/$doc_sect/o) { $newsection = $1; $newcontents = $2; if ($contents ne "") { # $contents =~ s/\&/\\\\\\amp;/g; $contents =~ s/\/\\\\\\gt;/g; dump_section($section, $contents); $section = $section_default; } $contents = $newcontents; if ($contents ne "") { $contents .= "\n"; } $section = $newsection; } elsif (/$doc_end/) { if ($contents ne "") { # $contents =~ s/\&/\\\\\\amp;/g; $contents =~ s/\/\\\\\\gt;/g; dump_section($section, $contents); $section = $section_default; $contents = ""; } # print STDERR "end of doc comment, looking for prototype\n"; $prototype = ""; $state = 3; } elsif (/$doc_content/) { # miguel-style comment kludge, look for blank lines after # @parameter line to signify start of description if ($1 eq "" && $section =~ m/^@/) { # $contents =~ s/\&/\\\\\\amp;/g; $contents =~ s/\/\\\\\\gt;/g; dump_section($section, $contents); $section = $section_default; $contents = ""; } else { $contents .= $1."\n"; } } else { # i dont know - bad line? ignore. print STDERR "WARNING($lineno): bad line: $_"; } } elsif ($state == 3) { # scanning for function { (end of prototype) if (m#\s*/\*\s+MACDOC\s*#io) { # do nothing } elsif (/([^\{]*)/) { $prototype .= $1; } if (/\{/) { $prototype =~ s@/\*.*?\*/@@gos; # strip comments. $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. $prototype =~ s@^ +@@gos; # strip leading spaces dump_function($prototype); $function = ""; %constants = (); %parameters = (); %parametertypes = (); @parameterlist = (); %sections = (); @sectionlist = (); $prototype = ""; $state = 0; } } elsif ($state == 4) { # Documentation block if (/$doc_block/) { # $contents =~ s/\&/\\\\\\amp;/g; $contents =~ s/\/\\\\\\gt;/g; dump_section($section, $contents); output_intro({'sectionlist' => \@sectionlist, 'sections' => \%sections }); $contents = ""; $function = ""; %constants = (); %parameters = (); %parametertypes = (); @parameterlist = (); %sections = (); @sectionlist = (); $prototype = ""; if ( $1 eq "" ) { $section = $section_intro; } else { $section = $1; } } elsif (/$doc_end/) { # $contents =~ s/\&/\\\\\\amp;/g; $contents =~ s/\/\\\\\\gt;/g; dump_section($section, $contents); output_intro({'sectionlist' => \@sectionlist, 'sections' => \%sections }); $contents = ""; $function = ""; %constants = (); %parameters = (); %parametertypes = (); @parameterlist = (); %sections = (); @sectionlist = (); $prototype = ""; $state = 0; } elsif (/$doc_content/) { if ( $1 eq "" ) { $contents .= "\n"; } else { $contents .= $1 . "\n"; } } } } } bird-2.0.8/doc/bird.sgml0000664000175000017500000073172114025744326013750 0ustar feelafeela BIRD 2.0 User's Guide <author> Ondrej Filip <it/<feela@network.cz>/, Pavel Machek <it/<pavel@ucw.cz>/, Martin Mares <it/<mj@ucw.cz>/, Maria Matejka <it/<mq@jmq.cz>/, Ondrej Zajicek <it/<santiago@crfreenet.org>/ </author> <abstract> This document contains user documentation for the BIRD Internet Routing Daemon project. </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> <chapt>Introduction <label id="intro"> <sect>What is BIRD <label id="what-is-bird"> <p>The name `BIRD' is actually an acronym standing for `BIRD Internet Routing Daemon'. Let's take a closer look at the meaning of the name: <p><em/BIRD/: Well, we think we have already explained that. It's an acronym standing for `BIRD Internet Routing Daemon', you remember, don't you? :-) <p><em/Internet Routing/: It's a program (well, a daemon, as you are going to discover in a moment) which works as a dynamic router in an Internet type network (that is, in a network running either the IPv4 or the IPv6 protocol). Routers are devices which forward packets between interconnected networks in order to allow hosts not connected directly to the same local area network to communicate with each other. They also communicate with the other routers in the Internet to discover the topology of the network which allows them to find optimal (in terms of some metric) rules for forwarding of packets (which are called routing tables) and to adapt themselves to the changing conditions such as outages of network links, building of new connections and so on. Most of these routers are costly dedicated devices running obscure firmware which is hard to configure and not open to any changes (on the other hand, their special hardware design allows them to keep up with lots of high-speed network interfaces, better than general-purpose computer does). Fortunately, most operating systems of the UNIX family allow an ordinary computer to act as a router and forward packets belonging to the other hosts, but only according to a statically configured table. <p>A <em/Routing Daemon/ is in UNIX terminology a non-interactive program running on background which does the dynamic part of Internet routing, that is it communicates with the other routers, calculates routing tables and sends them to the OS kernel which does the actual packet forwarding. There already exist other such routing daemons: routed (RIP only), GateD (non-free), <HTMLURL URL="http://www.zebra.org" name="Zebra"> and <HTMLURL URL="http://sourceforge.net/projects/mrt" name="MRTD">, but their capabilities are limited and they are relatively hard to configure and maintain. <p>BIRD is an Internet Routing Daemon designed to avoid all of these shortcomings, to support all the routing technology used in the today's Internet or planned to be used in near future and to have a clean extensible architecture allowing new routing protocols to be incorporated easily. Among other features, BIRD supports: <itemize> <item>both IPv4 and IPv6 protocols <item>multiple routing tables <item>the Border Gateway Protocol (BGPv4) <item>the Routing Information Protocol (RIPv2, RIPng) <item>the Open Shortest Path First protocol (OSPFv2, OSPFv3) <item>the Babel Routing Protocol <item>the Router Advertisements for IPv6 hosts <item>a virtual protocol for exchange of routes between different routing tables on a single host <item>a command-line interface allowing on-line control and inspection of status of the daemon <item>soft reconfiguration (no need to use complex online commands to change the configuration, just edit the configuration file and notify BIRD to re-read it and it will smoothly switch itself to the new configuration, not disturbing routing protocols unless they are affected by the configuration changes) <item>a powerful language for route filtering </itemize> <p>BIRD has been developed at the Faculty of Math and Physics, Charles University, Prague, Czech Republic as a student project. It can be freely distributed under the terms of the GNU General Public License. <p>BIRD has been designed to work on all UNIX-like systems. It has been developed and tested under Linux 2.0 to 2.6, and then ported to FreeBSD, NetBSD and OpenBSD, porting to other systems (even non-UNIX ones) should be relatively easy due to its highly modular architecture. <p>BIRD 1.x supported either IPv4 or IPv6 protocol, but had to be compiled separately for each one. BIRD~2 supports both of them with a possibility of further extension. BIRD~2 supports Linux at least 3.16, FreeBSD 10, NetBSD 7.0, and OpenBSD 5.8. Anyway, it will probably work well also on older systems. <sect>Installing BIRD <label id="install"> <p>On a recent UNIX system with GNU development tools (GCC, binutils, m4, make) and Perl, installing BIRD should be as easy as: <code> ./configure make make install vi /usr/local/etc/bird.conf bird </code> <p>You can use <tt>./configure --help</tt> to get a list of configure options. The most important ones are: <tt/--with-protocols=/ to produce a slightly smaller BIRD executable by configuring out routing protocols you don't use, and <tt/--prefix=/ to install BIRD to a place different from <file>/usr/local</file>. <sect>Running BIRD <label id="argv"> <p>You can pass several command-line options to bird: <descrip> <tag><label id="argv-config">-c <m/config name/</tag> use given configuration file instead of <it/prefix/<file>/etc/bird.conf</file>. <tag><label id="argv-debug">-d</tag> enable debug messages to stderr, and run bird in foreground. <tag><label id="argv-debug-file">-D <m/filename of debug log/</tag> enable debug messages to given file. <tag><label id="argv-foreground">-f</tag> run bird in foreground. <tag><label id="argv-group">-g <m/group/</tag> use that group ID, see the next section for details. <tag><label id="argv-help">-h, --help</tag> display command-line options to bird. <tag><label id="argv-local">-l</tag> look for a configuration file and a communication socket in the current working directory instead of in default system locations. However, paths specified by options <cf/-c/, <cf/-s/ have higher priority. <tag><label id="argv-parse">-p</tag> just parse the config file and exit. Return value is zero if the config file is valid, nonzero if there are some errors. <tag><label id="argv-pid">-P <m/name of PID file/</tag> create a PID file with given filename. <tag><label id="argv-recovery">-R</tag> apply graceful restart recovery after start. <tag><label id="argv-socket">-s <m/name of communication socket/</tag> use given filename for a socket for communications with the client, default is <it/prefix/<file>/var/run/bird.ctl</file>. <tag><label id="argv-user">-u <m/user/</tag> drop privileges and use that user ID, see the next section for details. <tag><label id="argv-version">--version</tag> display bird version. </descrip> <p>BIRD writes messages about its work to log files or syslog (according to config). <sect>Privileges <label id="privileges"> <p>BIRD, as a routing daemon, uses several privileged operations (like setting routing table and using raw sockets). Traditionally, BIRD is executed and runs with root privileges, which may be prone to security problems. The recommended way is to use a privilege restriction (options <cf/-u/, <cf/-g/). In that case BIRD is executed with root privileges, but it changes its user and group ID to an unprivileged ones, while using Linux capabilities to retain just required privileges (capabilities CAP_NET_*). Note that the control socket is created before the privileges are dropped, but the config file is read after that. The privilege restriction is not implemented in BSD port of BIRD. <p>An unprivileged user (as an argument to <cf/-u/ options) may be the user <cf/nobody/, but it is suggested to use a new dedicated user account (like <cf/bird/). The similar considerations apply for the group option, but there is one more condition -- the users in the same group can use <file/birdc/ to control BIRD. <p>Finally, there is a possibility to use external tools to run BIRD in an environment with restricted privileges. This may need some configuration, but it is generally easy -- BIRD needs just the standard library, privileges to read the config file and create the control socket and the CAP_NET_* capabilities. <chapt>Architecture <label id="architecture"> <sect>Routing tables <label id="routing-tables"> <p>The heart of BIRD is a routing table. BIRD has several independent routing tables; each of them contains routes of exactly one <m/nettype/ (see below). There are two default tables -- <cf/master4/ for IPv4 routes and <cf/master6/ for IPv6 routes. Other tables must be explicitly configured. <p> These routing tables are not kernel forwarding tables. No forwarding is done by BIRD. If you want to forward packets using the routes in BIRD tables, you may use the Kernel protocol (see below) to synchronize them with kernel FIBs. <p> Every nettype defines a (kind of) primary key on routes. Every route source can supply one route for every possible primary key; new route announcement replaces the old route from the same source, keeping other routes intact. BIRD always chooses the best route for each primary key among the known routes and keeps the others as suboptimal. When the best route is retracted, BIRD re-runs the best route selection algorithm to find the current best route. <p> The global best route selection algorithm is (roughly) as follows: <itemize> <item>Preferences of the routes are compared. <item>Source protocol instance preferences are compared. <item>If source protocols are the same (e.g. BGP vs. BGP), the protocol's route selection algorithm is invoked. <item>If source protocols are different (e.g. BGP vs. OSPF), result of the algorithm is undefined. </itemize> <p><label id="dsc-table-sorted">Usually, a routing table just chooses a selected route from a list of entries for one network. But if the <cf/sorted/ option is activated, these lists of entries are kept completely sorted (according to preference or some protocol-dependent metric). This is needed for some features of some protocols (e.g. <cf/secondary/ option of BGP protocol, which allows to accept not just a selected route, but the first route (in the sorted list) that is accepted by filters), but it is incompatible with some other features (e.g. <cf/deterministic med/ option of BGP protocol, which activates a way of choosing selected route that cannot be described using comparison and ordering). Minor advantage is that routes are shown sorted in <cf/show route/, minor disadvantage is that it is slightly more computationally expensive. <sect>Routes and network types <label id="routes"> <p>BIRD works with several types of routes. Some of them are typical IP routes, others are better described as forwarding rules. We call them all routes, regardless of this difference. <p>Every route consists of several attributes (read more about them in the <ref id="route-attributes" name="Route attributes"> section); the common for all routes are: <itemize> <item>IP address of router which told us about this route <item>Source protocol instance <item>Route preference <item>Optional attributes defined by protocols </itemize> <p>Other attributes depend on nettypes. Some of them are part of the primary key, these are marked (PK). <sect1>IPv4 and IPv6 routes <label id="ip-routes"> <p>The traditional routes. Configuration keywords are <cf/ipv4/ and <cf/ipv6/. <itemize> <item>(PK) Route destination (IP prefix together with its length) <item>Route next hops (see below) </itemize> <sect1>IPv6 source-specific routes <label id="ip-sadr-routes"> <p>The IPv6 routes containing both destination and source prefix. They are used for source-specific routing (SSR), also called source-address dependent routing (SADR), see <rfc id="8043">. Currently limited mostly to the Babel protocol. Configuration keyword is <cf/ipv6 sadr/. <itemize> <item>(PK) Route destination (IP prefix together with its length) <item>(PK) Route source (IP prefix together with its length) <item>Route next hops (see below) </itemize> <sect1>VPN IPv4 and IPv6 routes <label id="vpn-routes"> <p>Routes for IPv4 and IPv6 with VPN Route Distinguisher (<rfc id="4364">). Configuration keywords are <cf/vpn4/ and <cf/vpn6/. <itemize> <item>(PK) Route destination (IP prefix together with its length) <item>(PK) Route distinguisher (according to <rfc id="4364">) <item>Route next hops </itemize> <sect1>Route Origin Authorization for IPv4 and IPv6 <label id="roa-routes"> <p>These entries can be used to validate route origination of BGP routes. A ROA entry specifies prefixes which could be originated by an AS number. Their keywords are <cf/roa4/ and <cf/roa6/. <itemize> <item>(PK) IP prefix together with its length <item>(PK) Matching prefix maximal length <item>(PK) AS number </itemize> <sect1>Flowspec for IPv4 and IPv6 <label id="flow-routes"> <p>Flowspec rules are a form of firewall and traffic flow control rules distributed mostly via BGP. These rules may help the operators stop various network attacks in the beginning before eating up the whole bandwidth. Configuration keywords are <cf/flow4/ and <cf/flow6/. <itemize> <item>(PK) IP prefix together with its length <item>(PK) Flow definition data <item>Flow action (encoded internally as BGP communities according to <rfc id="5575">) </itemize> <sect1>MPLS switching rules <label id="mpls-routes"> <p>This nettype is currently a stub before implementing more support of <rfc id="3031">. BIRD currently does not support any label distribution protocol nor any label assignment method. Only the Kernel, Pipe and Static protocols can use MPLS tables. Configuration keyword is <cf/mpls/. <itemize> <item>(PK) MPLS label <item>Route next hops </itemize> <sect1>Route next hops <label id="route-next-hop"> <p>This is not a nettype. The route next hop is a complex attribute common for many nettypes as you can see before. Every next hop has its assigned device (either assumed from its IP address or set explicitly). It may have also an IP address and an MPLS stack (one or both independently). Maximal MPLS stack depth is set (in compile time) to 8 labels. <p>Every route (when eligible to have a next hop) can have more than one next hop. In that case, every next hop has also its weight. <sect>Protocols and channels <label id="protocols-concept"> <p>BIRD protocol is an abstract class of producers and consumers of the routes. Each protocol may run in multiple instances and bind on one side to route tables via channels, on the other side to specified listen sockets (BGP), interfaces (Babel, OSPF, RIP), APIs (Kernel, Direct), or nothing (Static, Pipe). <p>There are also two protocols that do not have any channels -- BFD and Device. Both of them are kind of service for other protocols. <p>Each protocol is connected to a routing table through a channel. Some protocols support only one channel (OSPF, RIP), some protocols support more channels (BGP, Direct). Each channel has two filters which can accept, reject and modify the routes. An <it/export/ filter is applied to routes passed from the routing table to the protocol, an <it/import/ filter is applied to routes in the opposite direction. <sect>Graceful restart <label id="graceful-restart"> <p>When BIRD is started after restart or crash, it repopulates routing tables in an uncoordinated manner, like after clean start. This may be impractical in some cases, because if the forwarding plane (i.e. kernel routing tables) remains intact, then its synchronization with BIRD would temporarily disrupt packet forwarding until protocols converge. Graceful restart is a mechanism that could help with this issue. Generally, it works by starting protocols and letting them repopulate routing tables while deferring route propagation until protocols acknowledge their convergence. Note that graceful restart behavior have to be configured for all relevant protocols and requires protocol-specific support (currently implemented for Kernel and BGP protocols), it is activated for particular boot by option <cf/-R/. <p>Some protocols (e.g. BGP) could be restarted gracefully after both intentional outage and crash, while others (e.g. OSPF) after intentional outage only. For planned graceful restart, BIRD must be shut down by <ref id="cli-graceful-restart" name="graceful restart"> command instead of regular <ref id="cli-down" name="down"> command. In this way routing neighbors are notified about planned graceful restart and routes are kept in kernel table after shutdown. <chapt>Configuration <label id="config"> <sect>Introduction <label id="config-intro"> <p>BIRD is configured using a text configuration file. Upon startup, BIRD reads <it/prefix/<file>/etc/bird.conf</file> (unless the <tt/-c/ command line option is given). Configuration may be changed at user's request: if you modify the config file and then signal BIRD with <tt/SIGHUP/, it will adjust to the new config. Then there's the client which allows you to talk with BIRD in an extensive way. <p>In the config, everything on a line after <cf/#/ or inside <cf>/* */</cf> is a comment, whitespace characters are treated as a single space. If there's a variable number of options, they are grouped using the <cf/{ }/ brackets. Each option is terminated by a <cf/;/. Configuration is case sensitive. There are two ways how to name symbols (like protocol names, filter names, constants etc.). You can either use a simple string starting with a letter (or underscore) followed by any combination of letters, numbers and underscores (e.g. <cf/R123/, <cf/my_filter/, <cf/bgp5/) or you can enclose the name into apostrophes (<cf/'/) and than you can use any combination of numbers, letters, underscores, hyphens, dots and colons (e.g. <cf/'1:strange-name'/, <cf/'-NAME-'/, <cf/'cool::name'/). <p>Here is an example of a simple config file. It enables synchronization of routing tables with OS kernel, learns network interfaces and runs RIP on all network interfaces found. <code> protocol kernel { ipv4 { export all; # Default is export none }; persist; # Don't remove routes on BIRD shutdown } protocol device { } protocol rip { ipv4 { import all; export all; }; interface "*"; } </code> <sect>Global options <label id="global-opts"> <p><descrip> <tag><label id="opt-include">include "<m/filename/";</tag> This statement causes inclusion of a new file. The <m/filename/ could also be a wildcard, in that case matching files are included in alphabetic order. The maximal depth is 8. Note that this statement can be used anywhere in the config file, even inside other options, but always on the beginning of line. In the following example, the first semicolon belongs to the <cf/include/, the second to <cf/ipv6 table/. If the <file/tablename.conf/ contains exactly one token (the name of the table), this construction is correct: <code> ipv6 table include "tablename.conf";; </code> <tag><label id="opt-log">log "<m/filename/" [<m/limit/ "<m/backup/"] | syslog [name <m/name/] | stderr all|{ <m/list of classes/ }</tag> Set logging of messages having the given class (either <cf/all/ or <cf>{ error|trace [, <m/.../] }</cf> etc.) into selected destination - a file specified as a filename string (with optional log rotation information), syslog (with optional name argument), or the stderr output. Classes are: <cf/info/, <cf/warning/, <cf/error/ and <cf/fatal/ for messages about local problems, <cf/debug/ for debugging messages, <cf/trace/ when you want to know what happens in the network, <cf/remote/ for messages about misbehavior of remote machines, <cf/auth/ about authentication failures, <cf/bug/ for internal BIRD bugs. Logging directly to file supports basic log rotation -- there is an optional log file limit and a backup filename, when log file reaches the limit, the current log file is renamed to the backup filename and a new log file is created. You may specify more than one <cf/log/ line to establish logging to multiple destinations. Default: log everything to the system log, or to the debug output if debugging is enabled by <cf/-d//<cf/-D/ command-line option. <tag><label id="opt-debug-protocols">debug protocols all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag> Set global defaults of protocol debugging options. See <ref id="proto-debug" name="debug"> in the following section. Default: off. <tag><label id="opt-debug-channels">debug channels all|off|{ states|routes|filters|events [, <m/.../] }</tag> Set global defaults of channel debugging options. See <ref id="channel-debug" name="debug"> in the channel section. Default: off. <tag><label id="opt-debug-commands">debug commands <m/number/</tag> Control logging of client connections (0 for no logging, 1 for logging of connects and disconnects, 2 and higher for logging of all client commands). Default: 0. <tag><label id="opt-debug-latency">debug latency <m/switch/</tag> Activate tracking of elapsed time for internal events. Recent events could be examined using <cf/dump events/ command. Default: off. <tag><label id="opt-debug-latency-limit">debug latency limit <m/time/</tag> If <cf/debug latency/ is enabled, this option allows to specify a limit for elapsed time. Events exceeding the limit are logged. Default: 1 s. <tag><label id="opt-watchdog-warn">watchdog warning <m/time/</tag> Set time limit for I/O loop cycle. If one iteration took more time to complete, a warning is logged. Default: 5 s. <tag><label id="opt-watchdog-timeout">watchdog timeout <m/time/</tag> Set time limit for I/O loop cycle. If the limit is breached, BIRD is killed by abort signal. The timeout has effective granularity of seconds, zero means disabled. Default: disabled (0). <tag><label id="opt-mrtdump">mrtdump "<m/filename/"</tag> Set MRTdump file name. This option must be specified to allow MRTdump feature. Default: no dump file. <tag><label id="opt-mrtdump-protocols">mrtdump protocols all|off|{ states|messages [, <m/.../] }</tag> Set global defaults of MRTdump options. See <cf/mrtdump/ in the following section. Default: off. <tag><label id="opt-filter">filter <m/name local variables/{ <m/commands/ }</tag> Define a filter. You can learn more about filters in the following chapter. <tag><label id="opt-function">function <m/name/ (<m/parameters/) <m/local variables/ { <m/commands/ }</tag> Define a function. You can learn more about functions in the following chapter. <tag><label id="opt-protocol">protocol rip|ospf|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag> Define a protocol instance called <cf><m/name/</cf> (or with a name like "rip5" generated automatically if you don't specify any <cf><m/name/</cf>). You can learn more about configuring protocols in their own chapters. When <cf>from <m/name2/</cf> expression is used, initial protocol options are taken from protocol or template <cf><m/name2/</cf> You can run more than one instance of most protocols (like RIP or BGP). By default, no instances are configured. <tag><label id="opt-template">template rip|ospf|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag> Define a protocol template instance called <m/name/ (or with a name like "bgp1" generated automatically if you don't specify any <m/name/). Protocol templates can be used to group common options when many similarly configured protocol instances are to be defined. Protocol instances (and other templates) can use templates by using <cf/from/ expression and the name of the template. At the moment templates (and <cf/from/ expression) are not implemented for OSPF protocol. <tag><label id="opt-define">define <m/constant/ = <m/expression/</tag> Define a constant. You can use it later in every place you could use a value of the same type. Besides, there are some predefined numeric constants based on /etc/iproute2/rt_* files. A list of defined constants can be seen (together with other symbols) using 'show symbols' command. <tag><label id="opt-attribute">attribute <m/type/ <m/name/</tag> Declare a custom route attribute. You can set and get it in filters like any other route attribute. This feature is intended for marking routes in import filters for export filtering purposes instead of locally assigned BGP communities which have to be deleted in export filters. <tag><label id="opt-router-id">router id <m/IPv4 address/</tag> Set BIRD's router ID. It's a world-wide unique identification of your router, usually one of router's IPv4 addresses. Default: the lowest IPv4 address of a non-loopback interface. <tag><label id="opt-router-id-from">router id from [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../]</tag> Set BIRD's router ID based on an IPv4 address of an interface specified by an interface pattern. See <ref id="proto-iface" name="interface"> section for detailed description of interface patterns with extended clauses. <tag><label id="opt-hostname">hostname "<m/name/"</tag> Set hostname. Default: node name as returned by `uname -n'. <tag><label id="opt-graceful-restart">graceful restart wait <m/number/</tag> During graceful restart recovery, BIRD waits for convergence of routing protocols. This option allows to specify a timeout for the recovery to prevent waiting indefinitely if some protocols cannot converge. Default: 240 seconds. <tag><label id="opt-timeformat">timeformat route|protocol|base|log "<m/format1/" [<m/limit/ "<m/format2/"]</tag> This option allows to specify a format of date/time used by BIRD. The first argument specifies for which purpose such format is used. <cf/route/ is a format used in 'show route' command output, <cf/protocol/ is used in 'show protocols' command output, <cf/base/ is used for other commands and <cf/log/ is used in a log file. "<m/format1/" is a format string using <it/strftime(3)/ notation (see <it/man strftime/ for details). It is extended to support sub-second time part with variable precision (up to microseconds) using "%f" conversion code (e.g., "%T.%3f" is hh:mm:ss.sss time). <m/limit/ and "<m/format2/" allow to specify the second format string for times in past deeper than <m/limit/ seconds. There are several shorthands: <cf/iso long/ is a ISO 8601 date/time format (YYYY-MM-DD hh:mm:ss) that can be also specified using <cf/"%F %T"/. Similarly, <cf/iso long ms/ and <cf/iso long us/ are ISO 8601 date/time formats with millisecond or microsecond precision. <cf/iso short/ is a variant of ISO 8601 that uses just the time format (hh:mm:ss) for near times (up to 20 hours in the past) and the date format (YYYY-MM-DD) for far times. This is a shorthand for <cf/"%T" 72000 "%F"/. And there are also <cf/iso short ms/ and <cf/iso short us/ high-precision variants of that. By default, BIRD uses the <cf/iso short ms/ format for <cf/route/ and <cf/protocol/ times, and the <cf/iso long ms/ format for <cf/base/ and <cf/log/ times. <tag><label id="opt-table"><m/nettype/ table <m/name/ [sorted]</tag> Create a new routing table. The default routing tables <cf/master4/ and <cf/master6/ are created implicitly, other routing tables have to be added by this command. Option <cf/sorted/ can be used to enable sorting of routes, see <ref id="dsc-table-sorted" name="sorted table"> description for details. <tag><label id="opt-eval">eval <m/expr/</tag> Evaluates given filter expression. It is used by the developers for testing of filters. </descrip> <sect>Protocol options <label id="protocol-opts"> <p>For each protocol instance, you can configure a bunch of options. Some of them (those described in this section) are generic, some are specific to the protocol (see sections talking about the protocols). <p>Several options use a <m/switch/ argument. It can be either <cf/on/, <cf/yes/ or a numeric expression with a non-zero value for the option to be enabled or <cf/off/, <cf/no/ or a numeric expression evaluating to zero to disable it. An empty <m/switch/ is equivalent to <cf/on/ ("silence means agreement"). <descrip> <tag><label id="proto-disabled">disabled <m/switch/</tag> Disables the protocol. You can change the disable/enable status from the command line interface without needing to touch the configuration. Disabled protocols are not activated. Default: protocol is enabled. <tag><label id="proto-debug">debug all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag> Set protocol debugging options. If asked, each protocol is capable of writing trace messages about its work to the log (with category <cf/trace/). You can either request printing of <cf/all/ trace messages or only of the selected types: <cf/states/ for protocol state changes (protocol going up, down, starting, stopping etc.), <cf/routes/ for routes exchanged with the routing table, <cf/filters/ for details on route filtering, <cf/interfaces/ for interface change events sent to the protocol, <cf/events/ for events internal to the protocol and <cf/packets/ for packets sent and received by the protocol. Classes <cf/routes/ and <cf/filters/ can be also set per-channel using <ref id="channel-debug" name="channel debugging option">) Default: off. <tag><label id="proto-mrtdump">mrtdump all|off|{ states|messages [, <m/.../] }</tag> Set protocol MRTdump flags. MRTdump is a standard binary format for logging information from routing protocols and daemons. These flags control what kind of information is logged from the protocol to the MRTdump file (which must be specified by global <cf/mrtdump/ option, see the previous section). Although these flags are similar to flags of <cf/debug/ option, their meaning is different and protocol-specific. For BGP protocol, <cf/states/ logs BGP state changes and <cf/messages/ logs received BGP messages. Other protocols does not support MRTdump yet. <tag><label id="proto-router-id">router id <m/IPv4 address/</tag> This option can be used to override global router id for a given protocol. Default: uses global router id. <tag><label id="proto-description">description "<m/text/"</tag> This is an optional description of the protocol. It is displayed as a part of the output of 'show protocols all' command. <tag><label id="proto-vrf">vrf "<m/text/"|default</tag> Associate the protocol with specific VRF. The protocol will be restricted to interfaces assigned to the VRF and will use sockets bound to the VRF. A corresponding VRF interface must exist on OS level. For kernel protocol, an appropriate table still must be explicitly selected by <cf/table/ option. By selecting <cf/default/, the protocol is associated with the default VRF; i.e., it will be restricted to interfaces not assigned to any regular VRF. That is different from not specifying <cf/vrf/ at all, in which case the protocol may use any interface regardless of its VRF status. Note that for proper VRF support it is necessary to use Linux kernel version at least 4.14, older versions have limited VRF implementation. Before Linux kernel 5.0, a socket bound to a port in default VRF collide with others in regular VRFs. In BGP, this can be avoided by using <ref id="bgp-strict-bind" name="strict bind"> option. <tag><label id="proto-channel"><m/channel name/ [{<m/channel config/}]</tag> Every channel must be explicitly stated. See the protocol-specific configuration for the list of supported channel names. See the <ref id="channel-opts" name="channel configuration section"> for channel definition. </descrip> <p>There are several options that give sense only with certain protocols: <descrip> <tag><label id="proto-iface">interface [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../] [ { <m/option/; [<m/.../] } ]</tag> Specifies a set of interfaces on which the protocol is activated with given interface-specific options. A set of interfaces specified by one interface option is described using an interface pattern. The interface pattern consists of a sequence of clauses (separated by commas), each clause is a mask specified as a shell-like pattern. Interfaces are matched by their name. An interface matches the pattern if it matches any of its clauses. If the clause begins with <cf/-/, matching interfaces are excluded. Patterns are processed left-to-right, thus <cf/interface "eth0", -"eth*", "*";/ means eth0 and all non-ethernets. Some protocols (namely OSPFv2 and Direct) support extended clauses that may contain a mask, a prefix, or both of them. An interface matches such clause if its name matches the mask (if specified) and its address matches the prefix (if specified). Extended clauses are used when the protocol handles multiple addresses on an interface independently. An interface option can be used more times with different interface-specific options, in that case for given interface the first matching interface option is used. This option is allowed in Babel, BFD, Device, Direct, OSPF, RAdv and RIP protocols. In OSPF protocol it is used in the <cf/area/ subsection. Default: none. Examples: <cf>interface "*" { type broadcast; };</cf> - start the protocol on all interfaces with <cf>type broadcast</cf> option. <cf>interface "eth1", "eth4", "eth5" { type ptp; };</cf> - start the protocol on enumerated interfaces with <cf>type ptp</cf> option. <cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol on all interfaces that have address from 192.168.0.0/16, but not from 192.168.1.0/24. <cf>interface "eth*" 192.168.1.0/24;</cf> - start the protocol on all ethernet interfaces that have address from 192.168.1.0/24. <tag><label id="proto-tx-class">tx class|dscp <m/num/</tag> This option specifies the value of ToS/DS/Class field in IP headers of the outgoing protocol packets. This may affect how the protocol packets are processed by the network relative to the other network traffic. With <cf/class/ keyword, the value (0-255) is used for the whole ToS/Class octet (but two bits reserved for ECN are ignored). With <cf/dscp/ keyword, the value (0-63) is used just for the DS field in the octet. Default value is 0xc0 (DSCP 0x30 - CS6). <tag><label id="proto-tx-priority">tx priority <m/num/</tag> This option specifies the local packet priority. This may affect how the protocol packets are processed in the local TX queues. This option is Linux specific. Default value is 7 (highest priority, privileged traffic). <tag><label id="proto-pass">password "<m/password/" [ { <m>password options</m> } ]</tag> Specifies a password that can be used by the protocol as a shared secret key. Password option can be used more times to specify more passwords. If more passwords are specified, it is a protocol-dependent decision which one is really used. Specifying passwords does not mean that authentication is enabled, authentication can be enabled by separate, protocol-dependent <cf/authentication/ option. This option is allowed in BFD, OSPF and RIP protocols. BGP has also <cf/password/ option, but it is slightly different and described separately. Default: none. </descrip> <p>Password option can contain section with some (not necessary all) password sub-options: <descrip> <tag><label id="proto-pass-id">id <M>num</M></tag> ID of the password, (0-255). If it is not specified, BIRD will choose ID based on an order of the password item in the interface, starting from 1. For example, second password item in one interface will have default ID 2. ID 0 is allowed by BIRD, but some other implementations may not allow it. ID is used by some routing protocols to identify which password was used to authenticate protocol packets. <tag><label id="proto-pass-gen-from">generate from "<m/time/"</tag> The start time of the usage of the password for packet signing. The format of <cf><m/time/</cf> is <tt>dd-mm-yyyy HH:MM:SS</tt>. <tag><label id="proto-pass-gen-to">generate to "<m/time/"</tag> The last time of the usage of the password for packet signing. <tag><label id="proto-pass-accept-from">accept from "<m/time/"</tag> The start time of the usage of the password for packet verification. <tag><label id="proto-pass-accept-to">accept to "<m/time/"</tag> The last time of the usage of the password for packet verification. <tag><label id="proto-pass-from">from "<m/time/"</tag> Shorthand for setting both <cf/generate from/ and <cf/accept from/. <tag><label id="proto-pass-to">to "<m/time/"</tag> Shorthand for setting both <cf/generate to/ and <cf/accept to/. <tag><label id="proto-pass-algorithm">algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 )</tag> The message authentication algorithm for the password when cryptographic authentication is enabled. The default value depends on the protocol. For RIP and OSPFv2 it is Keyed-MD5 (for compatibility), for OSPFv3 protocol it is HMAC-SHA-256. </descrip> <sect>Channel options <label id="channel-opts"> <p>Every channel belongs to a protocol and is configured inside its block. The minimal channel config is empty, then it uses default values. The name of the channel implies its nettype. Channel definitions can be inherited from protocol templates. Multiple definitions of the same channel are forbidden, but channels inherited from templates can be updated by new definitions. <descrip> <tag><label id="channel-debug">debug all|off|{ states|routes|filters [, <m/.../] }</tag> Set channel debugging options. Like in <ref id="proto-debug" name="protocol debugging">, channels are capable of writing trace messages about its work to the log (with category <cf/trace/). You can either request printing of <cf/all/ trace messages or only of the selected types: <cf/states/ for channel state changes (channel going up, down, feeding, reloading etc.), <cf/routes/ for routes propagated through the channel, <cf/filters/ for details on route filtering, remaining debug flags are not used in channel debug. Default: off. <tag><label id="proto-table">table <m/name/</tag> Specify a table to which the channel is connected. Default: the first table of given nettype. <tag><label id="proto-preference">preference <m/expr/</tag> Sets the preference of routes generated by the protocol and imported through this channel. Default: protocol dependent. <tag><label id="proto-import">import all | none | filter <m/name/ | filter { <m/filter commands/ } | where <m/boolean filter expression/</tag> Specify a filter to be used for filtering routes coming from the protocol to the routing table. <cf/all/ is for keeping all routes, <cf/none/ is for dropping all routes. Default: <cf/all/ (except for EBGP). <tag><label id="proto-export">export <m/filter/</tag> This is similar to the <cf>import</cf> keyword, except that it works in the direction from the routing table to the protocol. Default: <cf/none/ (except for EBGP). <tag><label id="proto-import-keep-filtered">import keep filtered <m/switch/</tag> Usually, if an import filter rejects a route, the route is forgotten. When this option is active, these routes are kept in the routing table, but they are hidden and not propagated to other protocols. But it is possible to show them using <cf/show route filtered/. Note that this option does not work for the pipe protocol. Default: off. <tag><label id="proto-rpki-reload">rpki reload <m/switch/</tag> Import or export filters may depend on route RPKI status (using <cf/roa_check()/ operator). In contrast to to other filter operators, this status for the same route may change as the content of ROA tables changes. When this option is active, BIRD activates automatic reload of affected channels whenever ROA tables are updated (after a short settle time). When disabled, route reloads have to be requested manually. The option is ignored if <cf/roa_check()/ is not used in channel filters. Note that for BGP channels, automatic reload requires <ref id="bgp-import-table" name="import table"> or <ref id="bgp-export-table" name="export table"> (for respective direction). Default: on. <tag><label id="proto-import-limit">import limit [<m/number/ | off ] [action warn | block | restart | disable]</tag> Specify an import route limit (a maximum number of routes imported from the protocol) and optionally the action to be taken when the limit is hit. Warn action just prints warning log message. Block action discards new routes coming from the protocol. Restart and disable actions shut the protocol down like appropriate commands. Disable is the default action if an action is not explicitly specified. Note that limits are reset during protocol reconfigure, reload or restart. Default: <cf/off/. <tag><label id="proto-receive-limit">receive limit [<m/number/ | off ] [action warn | block | restart | disable]</tag> Specify an receive route limit (a maximum number of routes received from the protocol and remembered). It works almost identically to <cf>import limit</cf> option, the only difference is that if <cf/import keep filtered/ option is active, filtered routes are counted towards the limit and blocked routes are forgotten, as the main purpose of the receive limit is to protect routing tables from overflow. Import limit, on the contrary, counts accepted routes only and routes blocked by the limit are handled like filtered routes. Default: <cf/off/. <tag><label id="proto-export-limit">export limit [ <m/number/ | off ] [action warn | block | restart | disable]</tag> Specify an export route limit, works similarly to the <cf>import limit</cf> option, but for the routes exported to the protocol. This option is experimental, there are some problems in details of its behavior -- the number of exported routes can temporarily exceed the limit without triggering it during protocol reload, exported routes counter ignores route blocking and block action also blocks route updates of already accepted routes -- and these details will probably change in the future. Default: <cf/off/. </descrip> <p>This is a trivial example of RIP configured for IPv6 on all interfaces: <code> protocol rip ng { ipv6; interface "*"; } </code> <p>This is a non-trivial example. <code> protocol rip ng { ipv6 { table mytable6; import filter { ... }; export filter { ... }; import limit 50; }; interface "*"; } </code> <p>And this is even more complicated example using templates. <code> template bgp { local 198.51.100.14 as 65000; ipv4 { table mytable4; import filter { ... }; export none; }; ipv6 { table mytable6; import filter { ... }; export none; }; } protocol bgp from { neighbor 198.51.100.130 as 64496; # IPv4 channel is inherited as-is, while IPv6 # channel is adjusted by export filter option ipv6 { export filter { ... }; }; } </code> <chapt>Remote control <label id="remote-control"> <p>You can use the command-line client <file>birdc</file> to talk with a running BIRD. Communication is done using a <file/bird.ctl/ UNIX domain socket (unless changed with the <tt/-s/ option given to both the server and the client). The commands can perform simple actions such as enabling/disabling of protocols, telling BIRD to show various information, telling it to show routing table filtered by filter, or asking BIRD to reconfigure. Press <tt/?/ at any time to get online help. Option <tt/-r/ can be used to enable a restricted mode of BIRD client, which allows just read-only commands (<cf/show .../). Option <tt/-v/ can be passed to the client, to make it dump numeric return codes along with the messages. You do not necessarily need to use <file/birdc/ to talk to BIRD, your own applications could do that, too -- the format of communication between BIRD and <file/birdc/ is stable (see the programmer's documentation). <p>There is also lightweight variant of BIRD client called <file/birdcl/, which does not support command line editing and history and has minimal dependencies. This is useful for running BIRD in resource constrained environments, where Readline library (required for regular BIRD client) is not available. <p>Many commands have the <m/name/ of the protocol instance as an argument. This argument can be omitted if there exists only a single instance. <p>Here is a brief list of supported functions: <descrip> <tag><label id="cli-show-status">show status</tag> Show router status, that is BIRD version, uptime and time from last reconfiguration. <tag><label id="cli-show-interfaces">show interfaces [summary]</tag> Show the list of interfaces. For each interface, print its type, state, MTU and addresses assigned. <tag><label id="cli-show-protocols">show protocols [all]</tag> Show list of protocol instances along with tables they are connected to and protocol status, possibly giving verbose information, if <cf/all/ is specified. <!-- TODO: Move these protocol-specific remote control commands to the protocol sections --> <tag><label id="cli-show-ospf-iface">show ospf interface [<m/name/] ["<m/interface/"]</tag> Show detailed information about OSPF interfaces. <tag><label id="cli-show-ospf-neighbors">show ospf neighbors [<m/name/] ["<m/interface/"]</tag> Show a list of OSPF neighbors and a state of adjacency to them. <tag><label id="cli-show-ospf-state">show ospf state [all] [<m/name/]</tag> Show detailed information about OSPF areas based on a content of the link-state database. It shows network topology, stub networks, aggregated networks and routers from other areas and external routes. The command shows information about reachable network nodes, use option <cf/all/ to show information about all network nodes in the link-state database. <tag><label id="cli-show-ospf-topology">show ospf topology [all] [<m/name/]</tag> Show a topology of OSPF areas based on a content of the link-state database. It is just a stripped-down version of 'show ospf state'. <tag><label id="cli-show-ospf-lsadb">show ospf lsadb [global | area <m/id/ | link] [type <m/num/] [lsid <m/id/] [self | router <m/id/] [<m/name/] </tag> Show contents of an OSPF LSA database. Options could be used to filter entries. <tag><label id="cli-show-rip-interfaces">show rip interfaces [<m/name/] ["<m/interface/"]</tag> Show detailed information about RIP interfaces. <tag><label id="cli-show-rip-neighbors">show rip neighbors [<m/name/] ["<m/interface/"]</tag> Show a list of RIP neighbors and associated state. <tag><label id="cli-show-static">show static [<m/name/]</tag> Show detailed information about static routes. <tag><label id="cli-show-bfd-sessions">show bfd sessions [<m/name/]</tag> Show information about BFD sessions. <tag><label id="cli-show-symbols">show symbols [table|filter|function|protocol|template|roa|<m/symbol/]</tag> Show the list of symbols defined in the configuration (names of protocols, routing tables etc.). <tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag> Show contents of specified routing tables, that is routes, their metrics and (in case the <cf/all/ switch is given) all their attributes. <p>You can specify a <m/prefix/ if you want to print routes for a specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get the entry which will be used for forwarding of packets to the given destination. By default, all routes for each network are printed with the selected one at the top, unless <cf/primary/ is given in which case only the selected route is shown. <p>The <cf/show route/ command can process one or multiple routing tables. The set of selected tables is determined on three levels: First, tables can be explicitly selected by <cf/table/ switch, which could be used multiple times, all tables are specified by <cf/table all/. Second, tables can be implicitly selected by channels or protocols that are arguments of several other switches (e.g., <cf/export/, <cf/protocol/). Last, the set of default tables is used: <cf/master4/, <cf/master6/ and each first table of any other network type. <p>You can also ask for printing only routes processed and accepted by a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ } </cf> or matching a given condition (<cf>where <m/condition/</cf>). The <cf/export/, <cf/preexport/ and <cf/noexport/ switches ask for printing of routes that are exported to the specified protocol or channel. With <cf/preexport/, the export filter of the channel is skipped. With <cf/noexport/, routes rejected by the export filter are printed instead. Note that routes not exported for other reasons (e.g. secondary routes or routes imported from that protocol) are not printed even with <cf/noexport/. These switches also imply that associated routing tables are selected instead of default ones. <p>You can also select just routes added by a specific protocol. <cf>protocol <m/p/</cf>. This switch also implies that associated routing tables are selected instead of default ones. <p>If BIRD is configured to keep filtered routes (see <cf/import keep filtered/ option), you can show them instead of routes by using <cf/filtered/ switch. <p>The <cf/stats/ switch requests showing of route statistics (the number of networks, number of routes before and after filtering). If you use <cf/count/ instead, only the statistics will be printed. <tag><label id="cli-mrt-dump">mrt dump table <m/name/|"<m/pattern/" to "<m/filename/" [filter <m/f/|where <m/c/]</tag> Dump content of a routing table to a specified file in MRT table dump format. See <ref id="mrt" name="MRT protocol"> for details. <tag><label id="cli-configure">configure [soft] ["<m/config file/"] [timeout [<m/num/]]</tag> Reload configuration from a given file. BIRD will smoothly switch itself to the new configuration, protocols are reconfigured if possible, restarted otherwise. Changes in filters usually lead to restart of affected protocols. If <cf/soft/ option is used, changes in filters does not cause BIRD to restart affected protocols, therefore already accepted routes (according to old filters) would be still propagated, but new routes would be processed according to the new filters. If <cf/timeout/ option is used, config timer is activated. The new configuration could be either confirmed using <cf/configure confirm/ command, or it will be reverted to the old one when the config timer expires. This is useful for cases when reconfiguration breaks current routing and a router becomes inaccessible for an administrator. The config timeout expiration is equivalent to <cf/configure undo/ command. The timeout duration could be specified, default is 300 s. <tag><label id="cli-configure-confirm">configure confirm</tag> Deactivate the config undo timer and therefore confirm the current configuration. <tag><label id="cli-configure-undo">configure undo</tag> Undo the last configuration change and smoothly switch back to the previous (stored) configuration. If the last configuration change was soft, the undo change is also soft. There is only one level of undo, but in some specific cases when several reconfiguration requests are given immediately in a row and the intermediate ones are skipped then the undo also skips them back. <tag><label id="cli-configure-check">configure check ["<m/config file/"]</tag> Read and parse given config file, but do not use it. useful for checking syntactic and some semantic validity of an config file. <tag><label id="cli-enable-disable-restart">enable|disable|restart <m/name/|"<m/pattern/"|all</tag> Enable, disable or restart a given protocol instance, instances matching the <cf><m/pattern/</cf> or <cf/all/ instances. <tag><label id="cli-reload">reload [in|out] <m/name/|"<m/pattern/"|all</tag> Reload a given protocol instance, that means re-import routes from the protocol instance and re-export preferred routes to the instance. If <cf/in/ or <cf/out/ options are used, the command is restricted to one direction (re-import or re-export). This command is useful if appropriate filters have changed but the protocol instance was not restarted (or reloaded), therefore it still propagates the old set of routes. For example when <cf/configure soft/ command was used to change filters. Re-export always succeeds, but re-import is protocol-dependent and might fail (for example, if BGP neighbor does not support route-refresh extension). In that case, re-export is also skipped. Note that for the pipe protocol, both directions are always reloaded together (<cf/in/ or <cf/out/ options are ignored in that case). <tag><label id="cli-down">down</tag> Shut BIRD down. <tag><label id="cli-graceful-restart">graceful restart</tag> Shut BIRD down for graceful restart. See <ref id="graceful-restart" name="graceful restart"> section for details. <tag><label id="cli-debug">debug <m/protocol/|<m/pattern/|all all|off|{ states|routes|filters|events|packets [, <m/.../] }</tag> Control protocol debugging. <tag><label id="cli-dump">dump resources|sockets|interfaces|neighbors|attributes|routes|protocols</tag> Dump contents of internal data structures to the debugging output. <tag><label id="cli-echo">echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag> Control echoing of log messages to the command-line output. See <ref id="opt-log" name="log option"> for a list of log classes. <tag><label id="cli-eval">eval <m/expr/</tag> Evaluate given expression. </descrip> <chapt>Filters <label id="filters"> <sect>Introduction <label id="filters-intro"> <p>BIRD contains a simple programming language. (No, it can't yet read mail :-). There are two objects in this language: filters and functions. Filters are interpreted by BIRD core when a route is being passed between protocols and routing tables. The filter language contains control structures such as if's and switches, but it allows no loops. An example of a filter using many features can be found in <file>filter/test.conf</file>. <p>Filter gets the route, looks at its attributes and modifies some of them if it wishes. At the end, it decides whether to pass the changed route through (using <cf/accept/) or whether to <cf/reject/ it. A simple filter looks like this: <code> filter not_too_far int var; { if defined( rip_metric ) then var = rip_metric; else { var = 1; rip_metric = 1; } if rip_metric > 10 then reject "RIP metric is too big"; else accept "ok"; } </code> <p>As you can see, a filter has a header, a list of local variables, and a body. The header consists of the <cf/filter/ keyword followed by a (unique) name of filter. The list of local variables consists of <cf><M>type name</M>;</cf> pairs where each pair declares one local variable. The body consists of <cf> { <M>statements</M> }</cf>. Each <m/statement/ is terminated by a <cf/;/. You can group several statements to a single compound statement by using braces (<cf>{ <M>statements</M> }</cf>) which is useful if you want to make a bigger block of code conditional. <p>BIRD supports functions, so that you don't have to repeat the same blocks of code over and over. Functions can have zero or more parameters and they can have local variables. Recursion is not allowed. Function definitions look like this: <code> function name () int local_variable; { local_variable = 5; } function with_parameters (int parameter) { print parameter; } </code> <p>Unlike in C, variables are declared after the <cf/function/ line, but before the first <cf/{/. You can't declare variables in nested blocks. Functions are called like in C: <cf>name(); with_parameters(5);</cf>. Function may return values using the <cf>return <m/[expr]/</cf> command. Returning a value exits from current function (this is similar to C). <p>Filters are defined in a way similar to functions except they can't have explicit parameters. They get a route table entry as an implicit parameter, it is also passed automatically to any functions called. The filter must terminate with either <cf/accept/ or <cf/reject/ statement. If there's a runtime error in filter, the route is rejected. <p>A nice trick to debug filters is to use <cf>show route filter <m/name/</cf> from the command line client. An example session might look like: <code> pavel@bug:~/bird$ ./birdc -s bird.ctl BIRD 0.0.0 ready. bird> show route 10.0.0.0/8 dev eth0 [direct1 23:21] (240) 195.113.30.2/32 dev tunl1 [direct1 23:21] (240) 127.0.0.0/8 dev lo [direct1 23:21] (240) bird> show route ? show route [<prefix>] [table <t>] [filter <f>] [all] [primary]... bird> show route filter { if 127.0.0.5 ˜ net then accept; } 127.0.0.0/8 dev lo [direct1 23:21] (240) bird> </code> <sect>Data types <label id="data-types"> <p>Each variable and each value has certain type. Booleans, integers and enums are incompatible with each other (that is to prevent you from shooting oneself in the foot). <descrip> <tag><label id="type-bool">bool</tag> This is a boolean type, it can have only two values, <cf/true/ and <cf/false/. Boolean is the only type you can use in <cf/if/ statements. <tag><label id="type-int">int</tag> This is a general integer type. It is an unsigned 32bit type; i.e., you can expect it to store values from 0 to 4294967295. Overflows are not checked. You can use <cf/0x1234/ syntax to write hexadecimal values. <tag><label id="type-pair">pair</tag> This is a pair of two short integers. Each component can have values from 0 to 65535. Literals of this type are written as <cf/(1234,5678)/. The same syntax can also be used to construct a pair from two arbitrary integer expressions (for example <cf/(1+2,a)/). <tag><label id="type-quad">quad</tag> This is a dotted quad of numbers used to represent router IDs (and others). Each component can have a value from 0 to 255. Literals of this type are written like IPv4 addresses. <tag><label id="type-string">string</tag> This is a string of characters. There are no ways to modify strings in filters. You can pass them between functions, assign them to variables of type <cf/string/, print such variables, use standard string comparison operations (e.g. <cf/=, !=, <, >, <=, >=/), but you can't concatenate two strings. String literals are written as <cf/"This is a string constant"/. Additionally matching (<cf/˜, !˜/) operators could be used to match a string value against a shell pattern (represented also as a string). <tag><label id="type-ip">ip</tag> This type can hold a single IP address. The IPv4 addresses are stored as IPv4-Mapped IPv6 addresses so one data type for both of them is used. Whether the address is IPv4 or not may be checked by <cf>.is_v4</cf> which returns a <cf/bool/. IP addresses are written in the standard notation (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special operator <cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from the IP address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true. <tag><label id="type-prefix">prefix</tag> This type can hold a network prefix consisting of IP address, prefix length and several other values. This is the key in route tables. Prefixes may be of several types, which can be determined by the special operator <cf/.type/. The type may be: <cf/NET_IP4/ and <cf/NET_IP6/ prefixes hold an IP prefix. The literals are written as <cf><m/ipaddress//<m/pxlen/</cf>. There are two special operators on these: <cf/.ip/ which extracts the IP address from the pair, and <cf/.len/, which separates prefix length from the pair. So <cf>1.2.0.0/16.len = 16</cf> is true. <cf/NET_IP6_SADR/ nettype holds both destination and source IPv6 prefix. The literals are written as <cf><m/ipaddress//<m/pxlen/ from <m/ipaddress//<m/pxlen/</cf>, where the first part is the destination prefix and the second art is the source prefix. They support the same operators as IP prefixes, but just for the destination part. They also support <cf/.src/ and <cf/.dst/ operators to get respective parts of the address as separate <cf/NET_IP6/ values. <cf/NET_VPN4/ and <cf/NET_VPN6/ prefixes hold an IP prefix with VPN Route Distinguisher (<rfc id="4364">). They support the same special operators as IP prefixes, and also <cf/.rd/ which extracts the Route Distinguisher. Their literals are written as <cf><m/vpnrd/ <m/ipprefix/</cf> <cf/NET_ROA4/ and <cf/NET_ROA6/ prefixes hold an IP prefix range together with an ASN. They support the same special operators as IP prefixes, and also <cf/.maxlen/ which extracts maximal prefix length, and <cf/.asn/ which extracts the ASN. <cf/NET_FLOW4/ and <cf/NET_FLOW6/ hold an IP prefix together with a flowspec rule. Filters currently do not support much flowspec parsing, only <cf/.src/ and <cf/.dst/ operators to get source and destination parts of the flowspec as separate <cf/NET_IP4/ / <cf/NET_IP6/ values. <cf/NET_MPLS/ holds a single MPLS label and its handling is currently not implemented. <tag><label id="type-vpnrd">vpnrd</tag> This is a route distinguisher according to <rfc id="4364">. There are three kinds of RD's: <cf><m/asn/:<m/32bit int/</cf>, <cf><m/asn4/:<m/16bit int/</cf> and <cf><m/IPv4 address/:<m/32bit int/</cf> <tag><label id="type-ec">ec</tag> This is a specialized type used to represent BGP extended community values. It is essentially a 64bit value, literals of this type are usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>, where <cf/kind/ is a kind of extended community (e.g. <cf/rt/ / <cf/ro/ for a route target / route origin communities), the format and possible values of <cf/key/ and <cf/value/ are usually integers, but it depends on the used kind. Similarly to pairs, ECs can be constructed using expressions for <cf/key/ and <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where <cf/myas/ is an integer variable). <tag><label id="type-lc">lc</tag> This is a specialized type used to represent BGP large community values. It is essentially a triplet of 32bit values, where the first value is reserved for the AS number of the issuer, while meaning of remaining parts is defined by the issuer. Literals of this type are written as <cf/(123, 456, 789)/, with any integer values. Similarly to pairs, LCs can be constructed using expressions for its parts, (e.g. <cf/(myas, 10+20, 3*10)/, where <cf/myas/ is an integer variable). <tag><label id="type-set">int|pair|quad|ip|prefix|ec|lc|enum set</tag> Filters recognize four types of sets. Sets are similar to strings: you can pass them around but you can't modify them. Literals of type <cf>int set</cf> look like <cf> [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in sets. For pair sets, expressions like <cf/(123,*)/ can be used to denote ranges (in that case <cf/(123,0)..(123,65535)/). You can also use <cf/(123,5..100)/ for range <cf/(123,5)..(123,100)/. You can also use <cf/*/ and <cf/a..b/ expressions in the first part of a pair, note that such expressions are translated to a set of intervals, which may be memory intensive. E.g. <cf/(*,4..20)/ is translated to <cf/(0,4..20), (1,4..20), (2,4..20), ... (65535, 4..20)/. EC sets use similar expressions like pair sets, e.g. <cf/(rt, 123, 10..20)/ or <cf/(ro, 123, *)/. Expressions requiring the translation (like <cf/(rt, *, 3)/) are not allowed (as they usually have 4B range for ASNs). Also LC sets use similar expressions like pair sets. You can use ranges and wildcards, but if one field uses that, more specific (later) fields must be wildcards. E.g., <cf/(10, 20..30, *)/ or <cf/(10, 20, 30..40)/ is valid, while <cf/(10, *, 20..30)/ or <cf/(10, 20..30, 40)/ is not valid. You can also use expressions for int, pair, EC and LC set values. However, it must be possible to evaluate these expressions before daemon boots. So you can use only constants inside them. E.g. <code> define one=1; define myas=64500; int set odds; pair set ps; ec set es; odds = [ one, 2+1, 6-one, 2*2*2-1, 9, 11 ]; ps = [ (1,one+one), (3,4)..(4,8), (5,*), (6,3..6), (7..9,*) ]; es = [ (rt, myas, 3*10), (rt, myas+one, 0..16*16*16-1), (ro, myas+2, *) ]; </code> Sets of prefixes are special: their literals does not allow ranges, but allows prefix patterns that are written as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>. Prefix <cf><m>ip1</m>/<m>len1</m></cf> matches prefix pattern <cf><m>ip2</m>/<m>len2</m>{<m>l</m>,<m>h</m>}</cf> if the first <cf>min(len1, len2)</cf> bits of <cf/ip1/ and <cf/ip2/ are identical and <cf>len1 <= ip1 <= len2</cf>. A valid prefix pattern has to satisfy <cf>low <= high</cf>, but <cf/pxlen/ is not constrained by <cf/low/ or <cf/high/. Obviously, a prefix matches a prefix set literal if it matches any prefix pattern in the prefix set literal. There are also two shorthands for prefix patterns: <cf><m/address//<m/len/+</cf> is a shorthand for <cf><m/address//<m/len/{<m/len/,<m/maxlen/}</cf> (where <cf><m/maxlen/</cf> is 32 for IPv4 and 128 for IPv6), that means network prefix <cf><m/address//<m/len/</cf> and all its subnets. <cf><m/address//<m/len/-</cf> is a shorthand for <cf><m/address//<m/len/{0,<m/len/}</cf>, that means network prefix <cf><m/address//<m/len/</cf> and all its supernets (network prefixes that contain it). For example, <cf>[ 1.0.0.0/8, 2.0.0.0/8+, 3.0.0.0/8-, 4.0.0.0/8{16,24} ]</cf> matches prefix <cf>1.0.0.0/8</cf>, all subprefixes of <cf>2.0.0.0/8</cf>, all superprefixes of <cf>3.0.0.0/8</cf> and prefixes <cf/4.X.X.X/ whose prefix length is 16 to 24. <cf>[ 0.0.0.0/0{20,24} ]</cf> matches all prefixes (regardless of IP address) whose prefix length is 20 to 24, <cf>[ 1.2.3.4/32- ]</cf> matches any prefix that contains IP address <cf>1.2.3.4</cf>. <cf>1.2.0.0/16 ˜ [ 1.0.0.0/8{15,17} ]</cf> is true, but <cf>1.0.0.0/16 ˜ [ 1.0.0.0/8- ]</cf> is false. Cisco-style patterns like <cf>10.0.0.0/8 ge 16 le 24</cf> can be expressed in BIRD as <cf>10.0.0.0/8{16,24}</cf>, <cf>192.168.0.0/16 le 24</cf> as <cf>192.168.0.0/16{16,24}</cf> and <cf>192.168.0.0/16 ge 24</cf> as <cf>192.168.0.0/16{24,32}</cf>. It is not possible to mix IPv4 and IPv6 prefixes in a prefix set. It is currently possible to mix IPv4 and IPv6 addresses in an ip set, but that behavior may change between versions without any warning; don't do it unless you are more than sure what you are doing. (Really, don't do it.) <tag><label id="type-enum">enum</tag> Enumeration types are fixed sets of possibilities. You can't define your own variables of such type, but some route attributes are of enumeration type. Enumeration types are incompatible with each other. <tag><label id="type-bgppath">bgppath</tag> BGP path is a list of autonomous system numbers. You can't write literals of this type. There are several special operators on bgppaths: <cf><m/P/.first</cf> returns the first ASN (the neighbor ASN) in path <m/P/. <cf><m/P/.last</cf> returns the last ASN (the source ASN) in path <m/P/. <cf><m/P/.last_nonaggregated</cf> returns the last ASN in the non-aggregated part of the path <m/P/. Both <cf/first/ and <cf/last/ return zero if there is no appropriate ASN, for example if the path contains an AS set element as the first (or the last) part. If the path ends with an AS set, <cf/last_nonaggregated/ may be used to get last ASN before any AS set. <cf><m/P/.len</cf> returns the length of path <m/P/. <cf><m/P/.empty</cf> makes the path <m/P/ empty. <cf>prepend(<m/P/,<m/A/)</cf> prepends ASN <m/A/ to path <m/P/ and returns the result. <cf>delete(<m/P/,<m/A/)</cf> deletes all instances of ASN <m/A/ from from path <m/P/ and returns the result. <m/A/ may also be an integer set, in that case the operator deletes all ASNs from path <m/P/ that are also members of set <m/A/. <cf>filter(<m/P/,<m/A/)</cf> deletes all ASNs from path <m/P/ that are not members of integer set <m/A/. I.e., <cf/filter/ do the same as <cf/delete/ with inverted set <m/A/. Statement <cf><m/P/ = prepend(<m/P/, <m/A/);</cf> can be shortened to <cf><m/P/.prepend(<m/A/);</cf> if <m/P/ is appropriate route attribute (for example <cf/bgp_path/). Similarly for <cf/delete/ and <cf/filter/. <tag><label id="type-bgpmask">bgpmask</tag> BGP masks are patterns used for BGP path matching (using <cf>path ˜ [= 2 3 5 * =]</cf> syntax). The masks resemble wildcard patterns as used by UNIX shells. Autonomous system numbers match themselves, <cf/*/ matches any (even empty) sequence of arbitrary AS numbers and <cf/?/ matches one arbitrary AS number. For example, if <cf>bgp_path</cf> is 4 3 2 1, then: <tt>bgp_path ˜ [= * 4 3 * =]</tt> is true, but <tt>bgp_path ˜ [= * 4 5 * =]</tt> is false. There is also <cf/+/ operator which matches one or multiple instances of previous expression, e.g. <tt>[= 1 2+ 3 =]</tt> matches both path 1 2 3 and path 1 2 2 2 3, but not 1 3 nor 1 2 4 3. Note that while <cf/*/ and <cf/?/ are wildcard-style operators, <cf/+/ is regex-style operator. BGP mask expressions can also contain integer expressions enclosed in parenthesis and integer variables, for example <tt>[= * 4 (1+2) a =]</tt>. You can also use ranges (e.g. <tt>[= * 3..5 2 100..200 * =]</tt>) and sets (e.g. <tt>[= 1 2 [3, 5, 7] * =]</tt>). <tag><label id="type-clist">clist</tag> Clist is similar to a set, except that unlike other sets, it can be modified. The type is used for community list (a set of pairs) and for cluster list (a set of quads). There exist no literals of this type. There are three special operators on clists: <cf><m/C/.len</cf> returns the length of clist <m/C/. <cf><m/C/.empty</cf> makes the list <m/C/ empty. <cf>add(<m/C/,<m/P/)</cf> adds pair (or quad) <m/P/ to clist <m/C/ and returns the result. If item <m/P/ is already in clist <m/C/, it does nothing. <m/P/ may also be a clist, in that case all its members are added; i.e., it works as clist union. <cf>delete(<m/C/,<m/P/)</cf> deletes pair (or quad) <m/P/ from clist <m/C/ and returns the result. If clist <m/C/ does not contain item <m/P/, it does nothing. <m/P/ may also be a pair (or quad) set, in that case the operator deletes all items from clist <m/C/ that are also members of set <m/P/. Moreover, <m/P/ may also be a clist, which works analogously; i.e., it works as clist difference. <cf>filter(<m/C/,<m/P/)</cf> deletes all items from clist <m/C/ that are not members of pair (or quad) set <m/P/. I.e., <cf/filter/ do the same as <cf/delete/ with inverted set <m/P/. <m/P/ may also be a clist, which works analogously; i.e., it works as clist intersection. Statement <cf><m/C/ = add(<m/C/, <m/P/);</cf> can be shortened to <cf><m/C/.add(<m/P/);</cf> if <m/C/ is appropriate route attribute (for example <cf/bgp_community/). Similarly for <cf/delete/ and <cf/filter/. <tag><label id="type-eclist">eclist</tag> Eclist is a data type used for BGP extended community lists. Eclists are very similar to clists, but they are sets of ECs instead of pairs. The same operations (like <cf/add/, <cf/delete/ or <cf/˜/ and <cf/!˜/ membership operators) can be used to modify or test eclists, with ECs instead of pairs as arguments. <tag><label id="type-lclist">lclist</tag> Lclist is a data type used for BGP large community lists. Like eclists, lclists are very similar to clists, but they are sets of LCs instead of pairs. The same operations (like <cf/add/, <cf/delete/ or <cf/˜/ and <cf/!˜/ membership operators) can be used to modify or test lclists, with LCs instead of pairs as arguments. </descrip> <sect>Operators <label id="operators"> <p>The filter language supports common integer operators <cf>(+,-,*,/)</cf>, parentheses <cf/(a*(b+c))/, comparison <cf/(a=b, a!=b, a<b, a>=b)/. Logical operations include unary not (<cf/!/), and (<cf/&&/), and or (<cf/||/). Special operators include (<cf/˜/, <cf/!˜/) for "is (not) element of a set" operation - it can be used on element and set of elements of the same type (returning true if element is contained in the given set), or on two strings (returning true if first string matches a shell-like pattern stored in second string) or on IP and prefix (returning true if IP is within the range defined by that prefix), or on prefix and prefix (returning true if first prefix is more specific than second one) or on bgppath and bgpmask (returning true if the path matches the mask) or on number and bgppath (returning true if the number is in the path) or on bgppath and int (number) set (returning true if any ASN from the path is in the set) or on pair/quad and clist (returning true if the pair/quad is element of the clist) or on clist and pair/quad set (returning true if there is an element of the clist that is also a member of the pair/quad set). <p>There is one operator related to ROA infrastructure - <cf/roa_check()/. It examines a ROA table and does <rfc id="6483"> route origin validation for a given network prefix. The basic usage is <cf>roa_check(<m/table/)</cf>, which checks the current route (which should be from BGP to have AS_PATH argument) in the specified ROA table and returns ROA_UNKNOWN if there is no relevant ROA, ROA_VALID if there is a matching ROA, or ROA_INVALID if there are some relevant ROAs but none of them match. There is also an extended variant <cf>roa_check(<m/table/, <m/prefix/, <m/asn/)</cf>, which allows to specify a prefix and an ASN as arguments. <sect>Control structures <label id="control-structures"> <p>Filters support two control structures: conditions and case switches. <p>Syntax of a condition is: <cf>if <M>boolean expression</M> then <m/commandT/; else <m/commandF/;</cf> and you can use <cf>{ <m/command1/; <m/command2/; <M>...</M> }</cf> instead of either command. The <cf>else</cf> clause may be omitted. If the <cf><m>boolean expression</m></cf> is true, <m/commandT/ is executed, otherwise <m/commandF/ is executed. <p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case <m/expr/ { else: | <m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [ ... ] }</cf>. The expression after <cf>case</cf> can be of any type which can be on the left side of the ˜ operator and anything that could be a member of a set is allowed before <cf/:/. Multiple commands are allowed without <cf/{}/ grouping. If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements between it and next <cf/:/ statement are executed. If <cf><m/expr/</cf> matches neither of the <cf/:/ clauses, the statements after <cf/else:/ are executed. <p>Here is example that uses <cf/if/ and <cf/case/ structures: <code> case arg1 { 2: print "two"; print "I can do more commands without {}"; 3 .. 5: print "three to five"; else: print "something else"; } if 1234 = i then printn "."; else { print "not 1234"; print "You need {} around multiple commands"; } </code> <sect>Route attributes <label id="route-attributes"> <p>A filter is implicitly passed a route, and it can access its attributes just like it accesses variables. There are common route attributes, protocol-specific route attributes and custom route attributes. Most common attributes are mandatory (always defined), while remaining are optional. Attempts to access undefined attribute result in a runtime error; you can check if an attribute is defined by using the <cf>defined( <m>attribute</m> )</cf> operator. One notable exception to this rule are attributes of bgppath and *clist types, where undefined value is regarded as empty bgppath/*clist for most purposes. Attributes can be defined by just setting them in filters. Custom attributes have to be first declared by <ref id="opt-attribute" name="attribute"> global option. You can also undefine optional attribute back to non-existence by using the <cf>unset( <m/attribute/ )</cf> operator. Common route attributes are: <descrip> <tag><label id="rta-net"><m/prefix/ net</tag> The network prefix or anything else the route is talking about. The primary key of the routing table. Read-only. (See the <ref id="routes" name="chapter about routes">.) <tag><label id="rta-scope"><m/enum/ scope</tag> The scope of the route. Possible values: <cf/SCOPE_HOST/ for routes local to this host, <cf/SCOPE_LINK/ for those specific for a physical link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private routes and <cf/SCOPE_UNIVERSE/ for globally visible routes. This attribute is not interpreted by BIRD and can be used to mark routes in filters. The default value for new routes is <cf/SCOPE_UNIVERSE/. <tag><label id="rta-preference"><m/int/ preference</tag> Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.) <tag><label id="rta-from"><m/ip/ from</tag> The router which the route has originated from. <tag><label id="rta-gw"><m/ip/ gw</tag> Next hop packets routed using this route should be forwarded to. <tag><label id="rta-proto"><m/string/ proto</tag> The name of the protocol which the route has been imported from. Read-only. <tag><label id="rta-source"><m/enum/ source</tag> what protocol has told me about this route. Possible values: <cf/RTS_DUMMY/, <cf/RTS_STATIC/, <cf/RTS_INHERIT/, <cf/RTS_DEVICE/, <cf/RTS_RIP/, <cf/RTS_OSPF/, <cf/RTS_OSPF_IA/, <cf/RTS_OSPF_EXT1/, <cf/RTS_OSPF_EXT2/, <cf/RTS_BGP/, <cf/RTS_PIPE/, <cf/RTS_BABEL/. <tag><label id="rta-dest"><m/enum/ dest</tag> Type of destination the packets should be sent to (<cf/RTD_ROUTER/ for forwarding to a neighboring router, <cf/RTD_DEVICE/ for routing to a directly-connected network, <cf/RTD_MULTIPATH/ for multipath destinations, <cf/RTD_BLACKHOLE/ for packets to be silently discarded, <cf/RTD_UNREACHABLE/, <cf/RTD_PROHIBIT/ for packets that should be returned with ICMP host unreachable / ICMP administratively prohibited messages). Can be changed, but only to <cf/RTD_BLACKHOLE/, <cf/RTD_UNREACHABLE/ or <cf/RTD_PROHIBIT/. <tag><label id="rta-ifname"><m/string/ ifname</tag> Name of the outgoing interface. Sink routes (like blackhole, unreachable or prohibit) and multipath routes have no interface associated with them, so <cf/ifname/ returns an empty string for such routes. Setting it would also change route to a direct one (remove gateway). <tag><label id="rta-ifindex"><m/int/ ifindex</tag> Index of the outgoing interface. System wide index of the interface. May be used for interface matching, however indexes might change on interface creation/removal. Zero is returned for routes with undefined outgoing interfaces. Read-only. <tag><label id="rta-weight"><m/int/ weight</tag> Multipath weight of route next hops. Valid values are 1-256. Reading returns the weight of the first next hop, setting it sets weights of all next hops to the specified value. Therefore, this attribute is not much useful for manipulating individual next hops of an ECMP route, but can be used in BGP multipath setup to set weights of individual routes that are merged to one ECMP route during export to the Kernel protocol (with active <ref id="krt-merge-paths" name="marge paths"> option). <tag><label id="rta-igp-metric"><m/int/ igp_metric</tag> The optional attribute that can be used to specify a distance to the network for routes that do not have a native protocol metric attribute (like <cf/ospf_metric1/ for OSPF routes). It is used mainly by BGP to compare internal distances to boundary routers (see below). </descrip> <p>Protocol-specific route attributes are described in the corresponding protocol sections. <sect>Other statements <label id="other-statements"> <p>The following statements are available: <descrip> <tag><label id="assignment"><m/variable/ = <m/expr/</tag> Set variable (or route attribute) to a given value. <tag><label id="filter-accept-reject">accept|reject [ <m/expr/ ]</tag> Accept or reject the route, possibly printing <cf><m>expr</m></cf>. <tag><label id="return">return <m/expr/</tag> Return <cf><m>expr</m></cf> from the current function, the function ends at this point. <tag><label id="print">print|printn <m/expr/ [<m/, expr.../]</tag> Prints given expressions; useful mainly while debugging filters. The <cf/printn/ variant does not terminate the line. </descrip> <chapt>Protocols <label id="protocols"> <sect>Babel <label id="babel"> <sect1>Introduction <label id="babel-intro"> <p>The Babel protocol (<rfc id="6126">) is a loop-avoiding distance-vector routing protocol that is robust and efficient both in ordinary wired networks and in wireless mesh networks. Babel is conceptually very simple in its operation and "just works" in its default configuration, though some configuration is possible and in some cases desirable. <p>The Babel protocol is dual stack; i.e., it can carry both IPv4 and IPv6 routes over the same IPv6 transport. For sending and receiving Babel packets, only a link-local IPv6 address is needed. <p>BIRD implements an extension for IPv6 source-specific routing (SSR or SADR), but must be configured accordingly to use it. SADR-enabled Babel router can interoperate with non-SADR Babel router, but the later would ignore routes with specific (non-zero) source prefix. <sect1>Configuration <label id="babel-config"> <p>The Babel protocol support both IPv4 and IPv6 channels; both can be configured simultaneously. It can also be configured with <ref id="ip-sadr-routes" name="IPv6 SADR"> channel instead of regular IPv6 channel, in such case SADR support is enabled. Babel supports no global configuration options apart from those common to all other protocols, but supports the following per-interface configuration options: <code> protocol babel [<name>] { ipv4 { <channel config> }; ipv6 [sadr] { <channel config> }; randomize router id <switch>; interface <interface pattern> { type <wired|wireless>; rxcost <number>; limit <number>; hello interval <time>; update interval <time>; port <number>; tx class|dscp <number>; tx priority <number>; rx buffer <number>; tx length <number>; check link <switch>; next hop ipv4 <address>; next hop ipv6 <address>; }; } </code> <descrip> <tag><label id="babel-channel">ipv4 | ipv6 [sadr] <m/channel config/</tag> The supported channels are IPv4, IPv6, and IPv6 SADR. <tag><label id="babel-random-router-id">randomize router id <m/switch/</tag> If enabled, Bird will randomize the top 32 bits of its router ID whenever the protocol instance starts up. If a Babel node restarts, it loses its sequence number, which can cause its routes to be rejected by peers until the state is cleared out by other nodes in the network (which can take on the order of minutes). Enabling this option causes Bird to pick a random router ID every time it starts up, which avoids this problem at the cost of not having stable router IDs in the network. Default: no. <tag><label id="babel-type">type wired|wireless </tag> This option specifies the interface type: Wired or wireless. On wired interfaces a neighbor is considered unreachable after a small number of Hello packets are lost, as described by <cf/limit/ option. On wireless interfaces the ETX link quality estimation technique is used to compute the metrics of routes discovered over this interface. This technique will gradually degrade the metric of routes when packets are lost rather than the more binary up/down mechanism of wired type links. Default: <cf/wired/. <tag><label id="babel-rxcost">rxcost <m/num/</tag> This option specifies the nominal RX cost of the interface. The effective neighbor costs for route metrics will be computed from this value with a mechanism determined by the interface <cf/type/. Note that in contrast to other routing protocols like RIP or OSPF, the <cf/rxcost/ specifies the cost of RX instead of TX, so it affects primarily neighbors' route selection and not local route selection. Default: 96 for wired interfaces, 256 for wireless. <tag><label id="babel-limit">limit <m/num/</tag> BIRD keeps track of received Hello messages from each neighbor to establish neighbor reachability. For wired type interfaces, this option specifies how many of last 16 hellos have to be correctly received in order to neighbor is assumed to be up. The option is ignored on wireless type interfaces, where gradual cost degradation is used instead of sharp limit. Default: 12. <tag><label id="babel-hello">hello interval <m/time/ s|ms</tag> Interval at which periodic Hello messages are sent on this interface, with time units. Default: 4 seconds. <tag><label id="babel-update">update interval <m/time/ s|ms</tag> Interval at which periodic (full) updates are sent, with time units. Default: 4 times the hello interval. <tag><label id="babel-port">port <m/number/</tag> This option selects an UDP port to operate on. The default is to operate on port 6696 as specified in the Babel RFC. <tag><label id="babel-tx-class">tx class|dscp|priority <m/number/</tag> These options specify the ToS/DiffServ/Traffic class/Priority of the outgoing Babel packets. See <ref id="proto-tx-class" name="tx class"> common option for detailed description. <tag><label id="babel-rx-buffer">rx buffer <m/number/</tag> This option specifies the size of buffers used for packet processing. The buffer size should be bigger than maximal size of received packets. The default value is the interface MTU, and the value will be clamped to a minimum of 512 bytes + IP packet overhead. <tag><label id="babel-tx-length">tx length <m/number/</tag> This option specifies the maximum length of generated Babel packets. To avoid IP fragmentation, it should not exceed the interface MTU value. The default value is the interface MTU value, and the value will be clamped to a minimum of 512 bytes + IP packet overhead. <tag><label id="babel-check-link">check link <m/switch/</tag> If set, the hardware link state (as reported by OS) is taken into consideration. When the link disappears (e.g. an ethernet cable is unplugged), neighbors are immediately considered unreachable and all routes received from them are withdrawn. It is possible that some hardware drivers or platforms do not implement this feature. Default: yes. <tag><label id="babel-next-hop-ipv4">next hop ipv4 <m/address/</tag> Set the next hop address advertised for IPv4 routes advertised on this interface. Default: the preferred IPv4 address of the interface. <tag><label id="babel-next-hop-ipv6">next hop ipv6 <m/address/</tag> Set the next hop address advertised for IPv6 routes advertised on this interface. If not set, the same link-local address that is used as the source for Babel packets will be used. In normal operation, it should not be necessary to set this option. </descrip> <sect1>Attributes <label id="babel-attr"> <p>Babel defines just one attribute: the internal babel metric of the route. It is exposed as the <cf/babel_metric/ attribute and has range from 1 to infinity (65535). <sect1>Example <label id="babel-exam"> <p><code> protocol babel { interface "eth*" { type wired; }; interface "wlan0", "wlan1" { type wireless; hello interval 1; rxcost 512; }; interface "tap0"; # This matches the default of babeld: redistribute all addresses # configured on local interfaces, plus re-distribute all routes received # from other babel peers. ipv4 { export where (source = RTS_DEVICE) || (source = RTS_BABEL); }; ipv6 { export where (source = RTS_DEVICE) || (source = RTS_BABEL); }; } </code> <sect1>Known issues <label id="babel-issues"> <p>When retracting a route, Babel generates an unreachable route for a little while (according to RFC). The interaction of this behavior with other protocols is not well tested and strange things may happen. <sect>BFD <label id="bfd"> <sect1>Introduction <label id="bfd-intro"> <p>Bidirectional Forwarding Detection (BFD) is not a routing protocol itself, it is an independent tool providing liveness and failure detection. Routing protocols like OSPF and BGP use integrated periodic "hello" messages to monitor liveness of neighbors, but detection times of these mechanisms are high (e.g. 40 seconds by default in OSPF, could be set down to several seconds). BFD offers universal, fast and low-overhead mechanism for failure detection, which could be attached to any routing protocol in an advisory role. <p>BFD consists of mostly independent BFD sessions. Each session monitors an unicast bidirectional path between two BFD-enabled routers. This is done by periodically sending control packets in both directions. BFD does not handle neighbor discovery, BFD sessions are created on demand by request of other protocols (like OSPF or BGP), which supply appropriate information like IP addresses and associated interfaces. When a session changes its state, these protocols are notified and act accordingly (e.g. break an OSPF adjacency when the BFD session went down). <p>BIRD implements basic BFD behavior as defined in <rfc id="5880"> (some advanced features like the echo mode or authentication are not implemented), IP transport for BFD as defined in <rfc id="5881"> and <rfc id="5883"> and interaction with client protocols as defined in <rfc id="5882">. <p>BFD packets are sent with a dynamic source port number. Linux systems use by default a bit different dynamic port range than the IANA approved one (49152-65535). If you experience problems with compatibility, please adjust <cf>/proc/sys/net/ipv4/ip_local_port_range</cf>. <sect1>Configuration <label id="bfd-config"> <p>BFD configuration consists mainly of multiple definitions of interfaces. Most BFD config options are session specific. When a new session is requested and dynamically created, it is configured from one of these definitions. For sessions to directly connected neighbors, <cf/interface/ definitions are chosen based on the interface associated with the session, while <cf/multihop/ definition is used for multihop sessions. If no definition is relevant, the session is just created with the default configuration. Therefore, an empty BFD configuration is often sufficient. <p>Note that to use BFD for other protocols like OSPF or BGP, these protocols also have to be configured to request BFD sessions, usually by <cf/bfd/ option. In BGP case, it is also possible to specify per-peer BFD session options (e.g. rx/tx intervals) as a part of the <cf/bfd/ option. <p>A BFD instance not associated with any VRF handles session requests from all other protocols, even ones associated with a VRF. Such setup would work for single-hop BFD sessions if <cf/net.ipv4.udp_l3mdev_accept/ sysctl is enabled, but does not currently work for multihop sessions. Another approach is to configure multiple BFD instances, one for each VRF (including the default VRF). Each BFD instance associated with a VRF (regular or default) only handles session requests from protocols in the same VRF. <p>Some of BFD session options require <m/time/ value, which has to be specified with the appropriate unit: <m/num/ <cf/s/|<cf/ms/|<cf/us/. Although microseconds are allowed as units, practical minimum values are usually in order of tens of milliseconds. <code> protocol bfd [<name>] { accept [ipv4|ipv6] [direct|multihop]; interface <interface pattern> { interval <time>; min rx interval <time>; min tx interval <time>; idle tx interval <time>; multiplier <num>; passive <switch>; authentication none; authentication simple; authentication [meticulous] keyed md5|sha1; password "<text>"; password "<text>" { id <num>; generate from "<date>"; generate to "<date>"; accept from "<date>"; accept to "<date>"; from "<date>"; to "<date>"; }; }; multihop { interval <time>; min rx interval <time>; min tx interval <time>; idle tx interval <time>; multiplier <num>; passive <switch>; }; neighbor <ip> [dev "<interface>"] [local <ip>] [multihop <switch>]; } </code> <descrip> <tag><label id="bfd-accept">accept [ipv4|ipv6] [direct|multihop]</tag> A BFD protocol instance accepts (by default) all BFD session requests (with regard to VRF restrictions, see above). This option controls whether IPv4 / IPv6 and direct / multihop session requests are accepted (and which listening sockets are opened). It can be used, for example, to configure separate BFD protocol instances for IPv4 and for IPv6 sessions. <tag><label id="bfd-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag> Interface definitions allow to specify options for sessions associated with such interfaces and also may contain interface specific options. See <ref id="proto-iface" name="interface"> common option for a detailed description of interface patterns. Note that contrary to the behavior of <cf/interface/ definitions of other protocols, BFD protocol would accept sessions (in default configuration) even on interfaces not covered by such definitions. <tag><label id="bfd-multihop">multihop { <m/options/ }</tag> Multihop definitions allow to specify options for multihop BFD sessions, in the same manner as <cf/interface/ definitions are used for directly connected sessions. Currently only one such definition (for all multihop sessions) could be used. <tag><label id="bfd-neighbor">neighbor <m/ip/ [dev "<m/interface/"] [local <m/ip/] [multihop <m/switch/]</tag> BFD sessions are usually created on demand as requested by other protocols (like OSPF or BGP). This option allows to explicitly add a BFD session to the specified neighbor regardless of such requests. The session is identified by the IP address of the neighbor, with optional specification of used interface and local IP. By default the neighbor must be directly connected, unless the session is configured as multihop. Note that local IP must be specified for multihop sessions. </descrip> <p>Session specific options (part of <cf/interface/ and <cf/multihop/ definitions): <descrip> <tag><label id="bfd-interval">interval <m/time/</tag> BFD ensures availability of the forwarding path associated with the session by periodically sending BFD control packets in both directions. The rate of such packets is controlled by two options, <cf/min rx interval/ and <cf/min tx interval/ (see below). This option is just a shorthand to set both of these options together. <tag><label id="bfd-min-rx-interval">min rx interval <m/time/</tag> This option specifies the minimum RX interval, which is announced to the neighbor and used there to limit the neighbor's rate of generated BFD control packets. Default: 10 ms. <tag><label id="bfd-min-tx-interval">min tx interval <m/time/</tag> This option specifies the desired TX interval, which controls the rate of generated BFD control packets (together with <cf/min rx interval/ announced by the neighbor). Note that this value is used only if the BFD session is up, otherwise the value of <cf/idle tx interval/ is used instead. Default: 100 ms. <tag><label id="bfd-idle-tx-interval">idle tx interval <m/time/</tag> In order to limit unnecessary traffic in cases where a neighbor is not available or not running BFD, the rate of generated BFD control packets is lower when the BFD session is not up. This option specifies the desired TX interval in such cases instead of <cf/min tx interval/. Default: 1 s. <tag><label id="bfd-multiplier">multiplier <m/num/</tag> Failure detection time for BFD sessions is based on established rate of BFD control packets (<cf>min rx/tx interval</cf>) multiplied by this multiplier, which is essentially (ignoring jitter) a number of missed packets after which the session is declared down. Note that rates and multipliers could be different in each direction of a BFD session. Default: 5. <tag><label id="bfd-passive">passive <m/switch/</tag> Generally, both BFD session endpoints try to establish the session by sending control packets to the other side. This option allows to enable passive mode, which means that the router does not send BFD packets until it has received one from the other side. Default: disabled. <tag>authentication none</tag> No passwords are sent in BFD packets. This is the default value. <tag>authentication simple</tag> Every packet carries 16 bytes of password. Received packets lacking this password are ignored. This authentication mechanism is very weak. <tag>authentication [meticulous] keyed md5|sha1</tag> An authentication code is appended to each packet. The cryptographic algorithm is keyed MD5 or keyed SHA-1. Note that the algorithm is common for all keys (on one interface), in contrast to OSPF or RIP, where it is a per-key option. Passwords (keys) are not sent open via network. The <cf/meticulous/ variant means that cryptographic sequence numbers are increased for each sent packet, while in the basic variant they are increased about once per second. Generally, the <cf/meticulous/ variant offers better resistance to replay attacks but may require more computation. <tag>password "<M>text</M>"</tag> 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. </descrip> <sect1>Example <label id="bfd-exam"> <p><code> protocol bfd { interface "eth*" { min rx interval 20 ms; min tx interval 50 ms; idle tx interval 300 ms; }; interface "gre*" { interval 200 ms; multiplier 10; passive; }; multihop { interval 200 ms; multiplier 10; }; neighbor 192.168.1.10; neighbor 192.168.2.2 dev "eth2"; neighbor 192.168.10.1 local 192.168.1.1 multihop; } </code> <sect>BGP <label id="bgp"> <p>The Border Gateway Protocol is the routing protocol used for backbone level routing in the today's Internet. Contrary to other protocols, its convergence does not rely on all routers following the same rules for route selection, making it possible to implement any routing policy at any router in the network, the only restriction being that if a router advertises a route, it must accept and forward packets according to it. <p>BGP works in terms of autonomous systems (often abbreviated as AS). Each AS is a part of the network with common management and common routing policy. It is identified by a unique 16-bit number (ASN). Routers within each AS usually exchange AS-internal routing information with each other using an interior gateway protocol (IGP, such as OSPF or RIP). Boundary routers at the border of the AS communicate global (inter-AS) network reachability information with their neighbors in the neighboring AS'es via exterior BGP (eBGP) and redistribute received information to other routers in the AS via interior BGP (iBGP). <p>Each BGP router sends to its neighbors updates of the parts of its routing table it wishes to export along with complete path information (a list of AS'es the packet will travel through if it uses the particular route) in order to avoid routing loops. <sect1>Supported standards <label id="bgp-standards"> <p> <itemize> <item> <rfc id="4271"> - Border Gateway Protocol 4 (BGP) <item> <rfc id="1997"> - BGP Communities Attribute <item> <rfc id="2385"> - Protection of BGP Sessions via TCP MD5 Signature <item> <rfc id="2545"> - Use of BGP Multiprotocol Extensions for IPv6 <item> <rfc id="2918"> - Route Refresh Capability <item> <rfc id="3107"> - Carrying Label Information in BGP <item> <rfc id="4360"> - BGP Extended Communities Attribute <item> <rfc id="4364"> - BGP/MPLS IPv4 Virtual Private Networks <item> <rfc id="4456"> - BGP Route Reflection <item> <rfc id="4486"> - Subcodes for BGP Cease Notification Message <item> <rfc id="4659"> - BGP/MPLS IPv6 Virtual Private Networks <item> <rfc id="4724"> - Graceful Restart Mechanism for BGP <item> <rfc id="4760"> - Multiprotocol extensions for BGP <item> <rfc id="4798"> - Connecting IPv6 Islands over IPv4 MPLS <item> <rfc id="5065"> - AS confederations for BGP <item> <rfc id="5082"> - Generalized TTL Security Mechanism <item> <rfc id="5492"> - Capabilities Advertisement with BGP <item> <rfc id="5549"> - Advertising IPv4 NLRI with an IPv6 Next Hop <item> <rfc id="5575"> - Dissemination of Flow Specification Rules <item> <rfc id="5668"> - 4-Octet AS Specific BGP Extended Community <item> <rfc id="6286"> - AS-Wide Unique BGP Identifier <item> <rfc id="6608"> - Subcodes for BGP Finite State Machine Error <item> <rfc id="6793"> - BGP Support for 4-Octet AS Numbers <item> <rfc id="7311"> - Accumulated IGP Metric Attribute for BGP <item> <rfc id="7313"> - Enhanced Route Refresh Capability for BGP <item> <rfc id="7606"> - Revised Error Handling for BGP UPDATE Messages <item> <rfc id="7911"> - Advertisement of Multiple Paths in BGP <item> <rfc id="7947"> - Internet Exchange BGP Route Server <item> <rfc id="8092"> - BGP Large Communities Attribute <item> <rfc id="8203"> - BGP Administrative Shutdown Communication <item> <rfc id="8212"> - Default EBGP Route Propagation Behavior without Policies </itemize> <sect1>Route selection rules <label id="bgp-route-select-rules"> <p>BGP doesn't have any simple metric, so the rules for selection of an optimal route among multiple BGP routes with the same preference are a bit more complex and they are implemented according to the following algorithm. It starts the first rule, if there are more "best" routes, then it uses the second rule to choose among them and so on. <itemize> <item>Prefer route with the highest Local Preference attribute. <item>Prefer route with the shortest AS path. <item>Prefer IGP origin over EGP and EGP origin over incomplete. <item>Prefer the lowest value of the Multiple Exit Discriminator. <item>Prefer routes received via eBGP over ones received via iBGP. <item>Prefer routes with lower internal distance to a boundary router. <item>Prefer the route with the lowest value of router ID of the advertising router. </itemize> <sect1>IGP routing table <label id="bgp-igp-routing-table"> <p>BGP is mainly concerned with global network reachability and with routes to other autonomous systems. When such routes are redistributed to routers in the AS via BGP, they contain IP addresses of a boundary routers (in route attribute NEXT_HOP). BGP depends on existing IGP routing table with AS-internal routes to determine immediate next hops for routes and to know their internal distances to boundary routers for the purpose of BGP route selection. In BIRD, there is usually one routing table used for both IGP routes and BGP routes. <sect1>Protocol configuration <label id="bgp-proto-config"> <p>Each instance of the BGP corresponds to one neighboring router. This allows to set routing policy and all the other parameters differently for each neighbor using the following configuration parameters: <descrip> <tag><label id="bgp-local">local [<m/ip/] [port <m/number/] [as <m/number/]</tag> Define which AS we are part of. (Note that contrary to other IP routers, BIRD is able to act as a router located in multiple AS'es simultaneously, but in such cases you need to tweak the BGP paths manually in the filters to get consistent behavior.) Optional <cf/ip/ argument specifies a source address, equivalent to the <cf/source address/ option (see below). Optional <cf/port/ argument specifies the local BGP port instead of standard port 179. The parameter may be used multiple times with different sub-options (e.g., both <cf/local 10.0.0.1 as 65000;/ and <cf/local 10.0.0.1; local as 65000;/ are valid). This parameter is mandatory. <tag><label id="bgp-neighbor">neighbor [<m/ip/ | range <m/prefix/] [port <m/number/] [as <m/number/] [internal|external]</tag> Define neighboring router this instance will be talking to and what AS it is located in. In case the neighbor is in the same AS as we are, we automatically switch to IBGP. Alternatively, it is possible to specify just <cf/internal/ or <cf/external/ instead of AS number, in that case either local AS number, or any external AS number is accepted. Optionally, the remote port may also be specified. Like <cf/local/ parameter, this parameter may also be used multiple times with different sub-options. This parameter is mandatory. It is possible to specify network prefix (with <cf/range/ keyword) instead of explicit neighbor IP address. This enables dynamic BGP behavior, where the BGP instance listens on BGP port, but new BGP instances are spawned for incoming BGP connections (if source address matches the network prefix). It is possible to mix regular BGP instances with dynamic BGP instances and have multiple dynamic BGP instances with different ranges. <tag><label id="bgp-iface">interface <m/string/</tag> Define interface we should use for link-local BGP IPv6 sessions. Interface can also be specified as a part of <cf/neighbor address/ (e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). The option may also be used for non link-local sessions when it is necessary to explicitly specify an interface, but only for direct (not multihop) sessions. <tag><label id="bgp-direct">direct</tag> Specify that the neighbor is directly connected. The IP address of the neighbor must be from a directly reachable IP range (i.e. associated with one of your router's interfaces), otherwise the BGP session wouldn't start but it would wait for such interface to appear. The alternative is the <cf/multihop/ option. Default: enabled for eBGP. <tag><label id="bgp-multihop">multihop [<m/number/]</tag> Configure multihop BGP session to a neighbor that isn't directly connected. Accurately, this option should be used if the configured neighbor IP address does not match with any local network subnets. Such IP address have to be reachable through system routing table. The alternative is the <cf/direct/ option. For multihop BGP it is recommended to explicitly configure the source address to have it stable. Optional <cf/number/ argument can be used to specify the number of hops (used for TTL). Note that the number of networks (edges) in a path is counted; i.e., if two BGP speakers are separated by one router, the number of hops is 2. Default: enabled for iBGP. <tag><label id="bgp-source-address">source address <m/ip/</tag> Define local address we should use as a source address for the BGP session. Default: the address of the local end of the interface our neighbor is connected to. <tag><label id="bgp-dynamic-name">dynamic name "<m/text/"</tag> Define common prefix of names used for new BGP instances spawned when dynamic BGP behavior is active. Actual names also contain numeric index to distinguish individual instances. Default: "dynbgp". <tag><label id="bgp-dynamic-name-digits">dynamic name digits <m/number/</tag> Define minimum number of digits for index in names of spawned dynamic BGP instances. E.g., if set to 2, then the first name would be "dynbgp01". Default: 0. <tag><label id="bgp-strict-bind">strict bind <m/switch/</tag> Specify whether BGP listening socket should be bound to a specific local address (the same as the <cf/source address/) and associated interface, or to all addresses. Binding to a specific address could be useful in cases like running multiple BIRD instances on a machine, each using its IP address. Note that listening sockets bound to a specific address and to all addresses collide, therefore either all BGP protocols (of the same address family and using the same local port) should have set <cf/strict bind/, or none of them. Default: disabled. <tag><label id="bgp-check-link">check link <M>switch</M></tag> BGP could use hardware link state into consideration. If enabled, BIRD tracks the link state of the associated interface and when link disappears (e.g. an ethernet cable is unplugged), the BGP session is immediately shut down. Note that this option cannot be used with multihop BGP. Default: enabled for direct BGP, disabled otherwise. <tag><label id="bgp-bfd">bfd <M>switch</M>|graceful| { <m/options/ }</tag> BGP could use BFD protocol as an advisory mechanism for neighbor liveness and failure detection. If enabled, BIRD setups a BFD session for the BGP neighbor and tracks its liveness by it. This has an advantage of an order of magnitude lower detection times in case of failure. When a neighbor failure is detected, the BGP session is restarted. Optionally, it can be configured (by <cf/graceful/ argument) to trigger graceful restart instead of regular restart. It is also possible to specify section with per-peer BFD session options instead of just switch argument. Most BFD session specific options are allowed here with the exception of authentication options. here Note that BFD protocol also has to be configured, see <ref id="bfd" name="BFD"> section for details. Default: disabled. <tag><label id="bgp-ttl-security">ttl security <m/switch/</tag> Use GTSM (<rfc id="5082"> - the generalized TTL security mechanism). GTSM protects against spoofed packets by ignoring received packets with a smaller than expected TTL. To work properly, GTSM have to be enabled on both sides of a BGP session. If both <cf/ttl security/ and <cf/multihop/ options are enabled, <cf/multihop/ option should specify proper hop value to compute expected TTL. Kernel support required: Linux: 2.6.34+ (IPv4), 2.6.35+ (IPv6), BSD: since long ago, IPv4 only. Note that full (ICMP protection, for example) <rfc id="5082"> support is provided by Linux only. Default: disabled. <tag><label id="bgp-password">password <m/string/</tag> Use this password for MD5 authentication of BGP sessions (<rfc id="2385">). When used on BSD systems, see also <cf/setkey/ option below. Default: no authentication. <tag><label id="bgp-setkey">setkey <m/switch/</tag> On BSD systems, keys for TCP MD5 authentication are stored in the global SA/SP database, which can be accessed by external utilities (e.g. setkey(8)). BIRD configures security associations in the SA/SP database automatically based on <cf/password/ options (see above), this option allows to disable automatic updates by BIRD when manual configuration by external utilities is preferred. Note that automatic SA/SP database updates are currently implemented only for FreeBSD. Passwords have to be set manually by an external utility on NetBSD and OpenBSD. Default: enabled (ignored on non-FreeBSD). <tag><label id="bgp-passive">passive <m/switch/</tag> Standard BGP behavior is both initiating outgoing connections and accepting incoming connections. In passive mode, outgoing connections are not initiated. Default: off. <tag><label id="bgp-confederation">confederation <m/number/</tag> BGP confederations (<rfc id="5065">) are collections of autonomous systems that act as one entity to external systems, represented by one confederation identifier (instead of AS numbers). This option allows to enable BGP confederation behavior and to specify the local confederation identifier. When BGP confederations are used, all BGP speakers that are members of the BGP confederation should have the same confederation identifier configured. Default: 0 (no confederation). <tag><label id="bgp-confederation-member">confederation member <m/switch/</tag> When BGP confederations are used, this option allows to specify whether the BGP neighbor is a member of the same confederation as the local BGP speaker. The option is unnecessary (and ignored) for IBGP sessions, as the same AS number implies the same confederation. Default: no. <tag><label id="bgp-rr-client">rr client</tag> Be a route reflector and treat the neighbor as a route reflection client. Default: disabled. <tag><label id="bgp-rr-cluster-id">rr cluster id <m/IPv4 address/</tag> Route reflectors use cluster id to avoid route reflection loops. When there is one route reflector in a cluster it usually uses its router id as a cluster id, but when there are more route reflectors in a cluster, these need to be configured (using this option) to use a common cluster id. Clients in a cluster need not know their cluster id and this option is not allowed for them. Default: the same as router id. <tag><label id="bgp-rs-client">rs client</tag> Be a route server and treat the neighbor as a route server client. A route server is used as a replacement for full mesh EBGP routing in Internet exchange points in a similar way to route reflectors used in IBGP routing. BIRD does not implement obsoleted <rfc id="1863">, but uses ad-hoc implementation, which behaves like plain EBGP but reduces modifications to advertised route attributes to be transparent (for example does not prepend its AS number to AS PATH attribute and keeps MED attribute). Default: disabled. <tag><label id="bgp-allow-local-pref">allow bgp_local_pref <m/switch/</tag> A standard BGP implementation do not send the Local Preference attribute to eBGP neighbors and ignore this attribute if received from eBGP neighbors, as per <rfc id="4271">. When this option is enabled on an eBGP session, this attribute will be sent to and accepted from the peer, which is useful for example if you have a setup like in <rfc id="7938">. The option does not affect iBGP sessions. Default: off. <tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag> BGP prevents routing loops by rejecting received routes with the local AS number in the AS path. This option allows to loose or disable the check. Optional <cf/number/ argument can be used to specify the maximum number of local ASNs in the AS path that is allowed for received routes. When the option is used without the argument, the check is completely disabled and you should ensure loop-free behavior by some other means. Default: 0 (no local AS number allowed). <tag><label id="bgp-allow-as-sets">allow as sets [<m/switch/]</tag> AS path attribute received with BGP routes may contain not only sequences of AS numbers, but also sets of AS numbers. These rarely used artifacts are results of inter-AS route aggregation. AS sets are deprecated (<rfc id="6472">), and likely to be rejected in the future, as they complicate security features like RPKI validation. When this option is disabled, then received AS paths with AS sets are rejected as malformed and corresponding BGP updates are treated as withdraws. Default: on. <tag><label id="bgp-enforce-first-as">enforce first as [<m/switch/]</tag> Routes received from an EBGP neighbor are generally expected to have the first (leftmost) AS number in their AS path equal to the neighbor AS number. This is not enforced by default as there are legitimate cases where it is not true, e.g. connections to route servers. When this option is enabled, routes with non-matching first AS number are rejected and corresponding updates are treated as withdraws. The option is valid on EBGP sessions only. Default: off. <tag><label id="bgp-enable-route-refresh">enable route refresh <m/switch/</tag> After the initial route exchange, BGP protocol uses incremental updates to keep BGP speakers synchronized. Sometimes (e.g., if BGP speaker changes its import filter, or if there is suspicion of inconsistency) it is necessary to do a new complete route exchange. BGP protocol extension Route Refresh (<rfc id="2918">) allows BGP speaker to request re-advertisement of all routes from its neighbor. BGP protocol extension Enhanced Route Refresh (<rfc id="7313">) specifies explicit begin and end for such exchanges, therefore the receiver can remove stale routes that were not advertised during the exchange. This option specifies whether BIRD advertises these capabilities and supports related procedures. Note that even when disabled, BIRD can send route refresh requests. Default: on. <tag><label id="bgp-graceful-restart">graceful restart <m/switch/|aware</tag> When a BGP speaker restarts or crashes, neighbors will discard all received paths from the speaker, which disrupts packet forwarding even when the forwarding plane of the speaker remains intact. <rfc id="4724"> specifies an optional graceful restart mechanism to alleviate this issue. This option controls the mechanism. It has three states: Disabled, when no support is provided. Aware, when the graceful restart support is announced and the support for restarting neighbors is provided, but no local graceful restart is allowed (i.e. receiving-only role). Enabled, when the full graceful restart support is provided (i.e. both restarting and receiving role). Restarting role could be also configured per-channel. Note that proper support for local graceful restart requires also configuration of other protocols. Default: aware. <tag><label id="bgp-graceful-restart-time">graceful restart time <m/number/</tag> The restart time is announced in the BGP graceful restart capability and specifies how long the neighbor would wait for the BGP session to re-establish after a restart before deleting stale routes. Default: 120 seconds. <tag><label id="bgp-long-lived-graceful-restart">long lived graceful restart <m/switch/|aware</tag> The long-lived graceful restart is an extension of the traditional <ref id="bgp-graceful-restart" name="BGP graceful restart">, where stale routes are kept even after the <ref id="bgp-graceful-restart-time" name="restart time"> expires for additional long-lived stale time, but they are marked with the LLGR_STALE community, depreferenced, and withdrawn from routers not supporting LLGR. Like traditional BGP graceful restart, it has three states: disabled, aware (receiving-only), and enabled. Note that long-lived graceful restart requires at least aware level of traditional BGP graceful restart. Default: aware, unless graceful restart is disabled. <tag><label id="bgp-long-lived-stale-time">long lived stale time <m/number/</tag> The long-lived stale time is announced in the BGP long-lived graceful restart capability and specifies how long the neighbor would keep stale routes depreferenced during long-lived graceful restart until either the session is re-stablished and synchronized or the stale time expires and routes are removed. Default: 3600 seconds. <tag><label id="bgp-interpret-communities">interpret communities <m/switch/</tag> <rfc id="1997"> demands that BGP speaker should process well-known communities like no-export (65535, 65281) or no-advertise (65535, 65282). For example, received route carrying a no-adverise community should not be advertised to any of its neighbors. If this option is enabled (which is by default), BIRD has such behavior automatically (it is evaluated when a route is exported to the BGP protocol just before the export filter). Otherwise, this integrated processing of well-known communities is disabled. In that case, similar behavior can be implemented in the export filter. Default: on. <tag><label id="bgp-enable-as4">enable as4 <m/switch/</tag> BGP protocol was designed to use 2B AS numbers and was extended later to allow 4B AS number. BIRD supports 4B AS extension, but by disabling this option it can be persuaded not to advertise it and to maintain old-style sessions with its neighbors. This might be useful for circumventing bugs in neighbor's implementation of 4B AS extension. Even when disabled (off), BIRD behaves internally as AS4-aware BGP router. Default: on. <tag><label id="bgp-enable-extended-messages">enable extended messages <m/switch/</tag> The BGP protocol uses maximum message length of 4096 bytes. This option provides an extension (<rfc id="8654">) to allow extended messages with length up to 65535 bytes. Default: off. <tag><label id="bgp-capabilities">capabilities <m/switch/</tag> Use capability advertisement to advertise optional capabilities. This is standard behavior for newer BGP implementations, but there might be some older BGP implementations that reject such connection attempts. When disabled (off), features that request it (4B AS support) are also disabled. Default: on, with automatic fallback to off when received capability-related error. <tag><label id="bgp-advertise-ipv4">advertise ipv4 <m/switch/</tag> Advertise IPv4 multiprotocol capability. This is not a correct behavior according to the strict interpretation of <rfc id="4760">, but it is widespread and required by some BGP implementations (Cisco and Quagga). This option is relevant to IPv4 mode with enabled capability advertisement only. Default: on. <tag><label id="bgp-advertise-hostname">advertise hostname <m/switch/</tag> Advertise hostname capability along with the hostname. Default: off. <tag><label id="bgp-disable-after-error">disable after error <m/switch/</tag> When an error is encountered (either locally or by the other side), disable the instance automatically and wait for an administrator to fix the problem manually. Default: off. <tag><label id="bgp-disable-after-cease">disable after cease <m/switch/|<m/set-of-flags/</tag> When a Cease notification is received, disable the instance automatically and wait for an administrator to fix the problem manually. When used with <m/switch/ argument, it means handle every Cease subtype with the exception of <cf/connection collision/. Default: off. The <m/set-of-flags/ allows to narrow down relevant Cease subtypes. The syntax is <cf>{<m/flag/ [, <m/.../] }</cf>, where flags are: <cf/cease/, <cf/prefix limit hit/, <cf/administrative shutdown/, <cf/peer deconfigured/, <cf/administrative reset/, <cf/connection rejected/, <cf/configuration change/, <cf/connection collision/, <cf/out of resources/. <tag><label id="bgp-hold-time">hold time <m/number/</tag> Time in seconds to wait for a Keepalive message from the other side before considering the connection stale. Default: depends on agreement with the neighboring router, we prefer 240 seconds if the other side is willing to accept it. <tag><label id="bgp-startup-hold-time">startup hold time <m/number/</tag> Value of the hold timer used before the routers have a chance to exchange open messages and agree on the real value. Default: 240 seconds. <tag><label id="bgp-keepalive-time">keepalive time <m/number/</tag> Delay in seconds between sending of two consecutive Keepalive messages. Default: One third of the hold time. <tag><label id="bgp-connect-delay-time">connect delay time <m/number/</tag> Delay in seconds between protocol startup and the first attempt to connect. Default: 5 seconds. <tag><label id="bgp-connect-retry-time">connect retry time <m/number/</tag> Time in seconds to wait before retrying a failed attempt to connect. Default: 120 seconds. <tag><label id="bgp-error-wait-time">error wait time <m/number/,<m/number/</tag> Minimum and maximum delay in seconds between a protocol failure (either local or reported by the peer) and automatic restart. Doesn't apply when <cf/disable after error/ is configured. If consecutive errors happen, the delay is increased exponentially until it reaches the maximum. Default: 60, 300. <tag><label id="bgp-error-forget-time">error forget time <m/number/</tag> Maximum time in seconds between two protocol failures to treat them as a error sequence which makes <cf/error wait time/ increase exponentially. Default: 300 seconds. <tag><label id="bgp-path-metric">path metric <m/switch/</tag> Enable comparison of path lengths when deciding which BGP route is the best one. Default: on. <tag><label id="bgp-med-metric">med metric <m/switch/</tag> Enable comparison of MED attributes (during best route selection) even between routes received from different ASes. This may be useful if all MED attributes contain some consistent metric, perhaps enforced in import filters of AS boundary routers. If this option is disabled, MED attributes are compared only if routes are received from the same AS (which is the standard behavior). Default: off. <tag><label id="bgp-deterministic-med">deterministic med <m/switch/</tag> BGP route selection algorithm is often viewed as a comparison between individual routes (e.g. if a new route appears and is better than the current best one, it is chosen as the new best one). But the proper route selection, as specified by <rfc id="4271">, cannot be fully implemented in that way. The problem is mainly in handling the MED attribute. BIRD, by default, uses an simplification based on individual route comparison, which in some cases may lead to temporally dependent behavior (i.e. the selection is dependent on the order in which routes appeared). This option enables a different (and slower) algorithm implementing proper <rfc id="4271"> route selection, which is deterministic. Alternative way how to get deterministic behavior is to use <cf/med metric/ option. This option is incompatible with <ref id="dsc-table-sorted" name="sorted tables">. Default: off. <tag><label id="bgp-igp-metric">igp metric <m/switch/</tag> Enable comparison of internal distances to boundary routers during best route selection. Default: on. <tag><label id="bgp-prefer-older">prefer older <m/switch/</tag> Standard route selection algorithm breaks ties by comparing router IDs. This changes the behavior to prefer older routes (when both are external and from different peer). For details, see <rfc id="5004">. Default: off. <tag><label id="bgp-default-med">default bgp_med <m/number/</tag> Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing. Default: 0. <tag><label id="bgp-default-local-pref">default bgp_local_pref <m/number/</tag> A default value for the Local Preference attribute. It is used when a new Local Preference attribute is attached to a route by the BGP protocol itself (for example, if a route is received through eBGP and therefore does not have such attribute). Default: 100 (0 in pre-1.2.0 versions of BIRD). </descrip> <sect1>Channel configuration <label id="bgp-channel-config"> <p>BGP supports several AFIs and SAFIs over one connection. Every AFI/SAFI announced to the peer corresponds to one channel. The table of supported AFI/SAFIs together with their appropriate channels follows. <table loc="h"> <tabular ca="l|l|l|r|r"> <bf/Channel name/ | <bf/Table nettype/ | <bf/IGP table allowed/ | <bf/AFI/ | <bf/SAFI/ @<hline> <cf/ipv4/ | <cf/ipv4/ | <cf/ipv4/ and <cf/ipv6/ | 1 | 1 @ <cf/ipv6/ | <cf/ipv6/ | <cf/ipv4/ and <cf/ipv6/ | 2 | 1 @ <cf/ipv4 multicast/ | <cf/ipv4/ | <cf/ipv4/ and <cf/ipv6/ | 1 | 2 @ <cf/ipv6 multicast/ | <cf/ipv6/ | <cf/ipv4/ and <cf/ipv6/ | 2 | 2 @ <cf/ipv4 mpls/ | <cf/ipv4/ | <cf/ipv4/ and <cf/ipv6/ | 1 | 4 @ <cf/ipv6 mpls/ | <cf/ipv6/ | <cf/ipv4/ and <cf/ipv6/ | 2 | 4 @ <cf/vpn4 mpls/ | <cf/vpn4/ | <cf/ipv4/ and <cf/ipv6/ | 1 | 128 @ <cf/vpn6 mpls/ | <cf/vpn6/ | <cf/ipv4/ and <cf/ipv6/ | 2 | 128 @ <cf/vpn4 multicast/ | <cf/vpn4/ | <cf/ipv4/ and <cf/ipv6/ | 1 | 129 @ <cf/vpn6 multicast/ | <cf/vpn6/ | <cf/ipv4/ and <cf/ipv6/ | 2 | 129 @ <cf/flow4/ | <cf/flow4/ | --- | 1 | 133 @ <cf/flow6/ | <cf/flow6/ | --- | 2 | 133 </tabular> </table> <p>Due to <rfc id="8212">, external BGP protocol requires explicit configuration of import and export policies (in contrast to other protocols, where default policies of <cf/import all/ and <cf/export none/ are used in absence of explicit configuration). Note that blanket policies like <cf/all/ or <cf/none/ can still be used in explicit configuration. <p>BGP channels have additional config options (together with the common ones): <descrip> <tag><label id="bgp-mandatory">mandatory <m/switch/</tag> When local and neighbor sets of configured AFI/SAFI pairs differ, capability negotiation ensures that a common subset is used. For mandatory channels their associated AFI/SAFI must be negotiated (i.e., also announced by the neighbor), otherwise BGP session negotiation fails with <it/'Required capability missing'/ error. Regardless, at least one AFI/SAFI must be negotiated in order to BGP session be successfully established. Default: off. <tag><label id="bgp-next-hop-keep">next hop keep <m/switch/|ibgp|ebgp</tag> Do not modify the Next Hop attribute and advertise the current one unchanged even in cases where our own local address should be used instead. This is necessary when the BGP speaker does not forward network traffic (route servers and some route reflectors) and also can be useful in some other cases (e.g. multihop EBGP sessions). Can be enabled for all routes, or just for routes received from IBGP / EBGP neighbors. Default: disabled for regular BGP, enabled for route servers, <cf/ibgp/ for route reflectors. <tag><label id="bgp-next-hop-self">next hop self <m/switch/|ibgp|ebgp</tag> Always advertise our own local address as a next hop, even in cases where the current Next Hop attribute should be used unchanged. This is sometimes used for routes propagated from EBGP to IBGP when IGP routing does not cover inter-AS links, therefore IP addreses of EBGP neighbors are not resolvable through IGP. Can be enabled for all routes, or just for routes received from IBGP / EBGP neighbors. Default: disabled. <tag><label id="bgp-next-hop-address">next hop address <m/ip/</tag> Specify which address to use when our own local address should be announced in the Next Hop attribute. Default: the source address of the BGP session (if acceptable), or the preferred address of an associated interface. <tag><label id="bgp-gateway">gateway direct|recursive</tag> For received routes, their <cf/gw/ (immediate next hop) attribute is computed from received <cf/bgp_next_hop/ attribute. This option specifies how it is computed. Direct mode means that the IP address from <cf/bgp_next_hop/ is used and must be directly reachable. Recursive mode means that the gateway is computed by an IGP routing table lookup for the IP address from <cf/bgp_next_hop/. Note that there is just one level of indirection in recursive mode - the route obtained by the lookup must not be recursive itself, to prevent mutually recursive routes. Recursive mode is the behavior specified by the BGP standard. Direct mode is simpler, does not require any routes in a routing table, and was used in older versions of BIRD, but does not handle well nontrivial iBGP setups and multihop. Recursive mode is incompatible with <ref id="dsc-table-sorted" name="sorted tables">. Default: <cf/direct/ for direct sessions, <cf/recursive/ for multihop sessions. <tag><label id="bgp-igp-table">igp table <m/name/</tag> Specifies a table that is used as an IGP routing table. The type of this table must be as allowed in the table above. This option is allowed once for every allowed table type. Default: the same as the main table the channel is connected to (if eligible). <tag><label id="bgp-import-table">import table <m/switch/</tag> A BGP import table contains all received routes from given BGP neighbor, before application of import filters. It is also called <em/Adj-RIB-In/ in BGP terminology. BIRD BGP by default operates without import tables, in which case received routes are just processed by import filters, accepted ones are stored in the master table, and the rest is forgotten. Enabling <cf/import table/ allows to store unprocessed routes, which can be examined later by <cf/show route/, and can be used to reconfigure import filters without full route refresh. Default: off. <tag><label id="bgp-export-table">export table <m/switch/</tag> A BGP export table contains all routes sent to given BGP neighbor, after application of export filters. It is also called <em/Adj-RIB-Out/ in BGP terminology. BIRD BGP by default operates without export tables, in which case routes from master table are just processed by export filters and then announced by BGP. Enabling <cf/export table/ allows to store routes after export filter processing, so they can be examined later by <cf/show route/, and can be used to eliminate unnecessary updates or withdraws. Default: off. <tag><label id="bgp-secondary">secondary <m/switch/</tag> Usually, if an export filter rejects a selected route, no other route is propagated for that network. This option allows to try the next route in order until one that is accepted is found or all routes for that network are rejected. This can be used for route servers that need to propagate different tables to each client but do not want to have these tables explicitly (to conserve memory). This option requires that the connected routing table is <ref id="dsc-table-sorted" name="sorted">. Default: off. <tag><label id="bgp-extended-next-hop">extended next hop <m/switch/</tag> BGP expects that announced next hops have the same address family as associated network prefixes. This option provides an extension to use IPv4 next hops with IPv6 prefixes and vice versa. For IPv4 / VPNv4 channels, the behavior is controlled by the Extended Next Hop Encoding capability, as described in <rfc id="5549">. For IPv6 / VPNv6 channels, just IPv4-mapped IPv6 addresses are used, as described in <rfc id="4798"> and <rfc id="4659">. Default: off. <tag><label id="bgp-add-paths">add paths <m/switch/|rx|tx</tag> Standard BGP can propagate only one path (route) per destination network (usually the selected one). This option controls the add-path protocol extension, which allows to advertise any number of paths to a destination. Note that to be active, add-path has to be enabled on both sides of the BGP session, but it could be enabled separately for RX and TX direction. When active, all available routes accepted by the export filter are advertised to the neighbor. Default: off. <tag><label id="bgp-aigp">aigp <m/switch/|originate</tag> The BGP protocol does not use a common metric like other routing protocols, instead it uses a set of criteria for route selection consisting both overall AS path length and a distance to the nearest AS boundary router. Assuming that metrics of different autonomous systems are incomparable, once a route is propagated from an AS to a next one, the distance in the old AS does not matter. The AIGP extension (<rfc id="7311">) allows to propagate accumulated IGP metric (in the AIGP attribute) through both IBGP and EBGP links, computing total distance through multiple autonomous systems (assuming they use comparable IGP metric). The total AIGP metric is compared in the route selection process just after Local Preference comparison (and before AS path length comparison). This option controls whether AIGP attribute propagation is allowed on the session. Optionally, it can be set to <cf/originate/, which not only allows AIGP attribute propagation, but also new AIGP attributes are automatically attached to non-BGP routes with valid IGP metric (e.g. <cf/ospf_metric1/) as they are exported to the BGP session. Default: enabled for IBGP (and intra-confederation EBGP), disabled for regular EBGP. <tag><label id="bgp-cost">cost <m/number/</tag> When BGP <ref id="bgp-gateway" name="gateway mode"> is <cf/recursive/ (mainly multihop IBGP sessions), then the distance to BGP next hop is based on underlying IGP metric. This option specifies the distance to BGP next hop for BGP sessions in direct gateway mode (mainly direct EBGP sessions). <tag><label id="bgp-graceful-restart-c">graceful restart <m/switch/</tag> Although BGP graceful restart is configured mainly by protocol-wide <ref id="bgp-graceful-restart" name="options">, it is possible to configure restarting role per AFI/SAFI pair by this channel option. The option is ignored if graceful restart is disabled by protocol-wide option. Default: off in aware mode, on in full mode. <tag><label id="bgp-long-lived-graceful-restart-c">long lived graceful restart <m/switch/</tag> BGP long-lived graceful restart is configured mainly by protocol-wide <ref id="bgp-long-lived-graceful-restart" name="options">, but the restarting role can be set per AFI/SAFI pair by this channel option. The option is ignored if long-lived graceful restart is disabled by protocol-wide option. Default: off in aware mode, on in full mode. <tag><label id="bgp-long-lived-stale-time-c">long lived stale time <m/number/</tag> Like previous graceful restart channel options, this option allows to set <ref id="bgp-long-lived-stale-time" name="long lived stale time"> per AFI/SAFI pair instead of per protocol. Default: set by protocol-wide option. </descrip> <sect1>Attributes <label id="bgp-attr"> <p>BGP defines several route attributes. Some of them (those marked with `<tt/I/' in the table below) are available on internal BGP connections only, some of them (marked with `<tt/O/') are optional. <descrip> <tag><label id="rta-bgp-path">bgppath bgp_path</tag> Sequence of AS numbers describing the AS path the packet will travel through when forwarded according to the particular route. In case of internal BGP it doesn't contain the number of the local AS. <tag><label id="rta-bgp-local-pref">int bgp_local_pref [I]</tag> Local preference value used for selection among multiple BGP routes (see the selection rules above). It's used as an additional metric which is propagated through the whole local AS. <tag><label id="rta-bgp-med">int bgp_med [O]</tag> The Multiple Exit Discriminator of the route is an optional attribute which is used on external (inter-AS) links to convey to an adjacent AS the optimal entry point into the local AS. The received attribute is also propagated over internal BGP links. The attribute value is zeroed when a route is exported to an external BGP instance to ensure that the attribute received from a neighboring AS is not propagated to other neighboring ASes. A new value might be set in the export filter of an external BGP instance. See <rfc id="4451"> for further discussion of BGP MED attribute. <tag><label id="rta-bgp-origin">enum bgp_origin</tag> Origin of the route: either <cf/ORIGIN_IGP/ if the route has originated in an interior routing protocol or <cf/ORIGIN_EGP/ if it's been imported from the <tt>EGP</tt> protocol (nowadays it seems to be obsolete) or <cf/ORIGIN_INCOMPLETE/ if the origin is unknown. <tag><label id="rta-bgp-next-hop">ip bgp_next_hop</tag> Next hop to be used for forwarding of packets to this destination. On internal BGP connections, it's an address of the originating router if it's inside the local AS or a boundary router the packet will leave the AS through if it's an exterior route, so each BGP speaker within the AS has a chance to use the shortest interior path possible to this point. <tag><label id="rta-bgp-atomic-aggr">void bgp_atomic_aggr [O]</tag> This is an optional attribute which carries no value, but the sole presence of which indicates that the route has been aggregated from multiple routes by some router on the path from the originator. <tag><label id="rta-bgp-aggregator">void bgp_aggregator [O]</tag> This is an optional attribute specifying AS number and IP address of the BGP router that created the route by aggregating multiple BGP routes. Currently, the attribute is not accessible from filters. <tag><label id="rta-bgp-community">clist bgp_community [O]</tag> List of community values associated with the route. Each such value is a pair (represented as a <cf/pair/ data type inside the filters) of 16-bit integers, the first of them containing the number of the AS which defines the community and the second one being a per-AS identifier. There are lots of uses of the community mechanism, but generally they are used to carry policy information like "don't export to USA peers". As each AS can define its own routing policy, it also has a complete freedom about which community attributes it defines and what will their semantics be. <tag><label id="rta-bgp-ext-community">eclist bgp_ext_community [O]</tag> List of extended community values associated with the route. Extended communities have similar usage as plain communities, but they have an extended range (to allow 4B ASNs) and a nontrivial structure with a type field. Individual community values are represented using an <cf/ec/ data type inside the filters. <tag><label id="rta-bgp-large-community">lclist bgp_large_community [O]</tag> List of large community values associated with the route. Large BGP communities is another variant of communities, but contrary to extended communities they behave very much the same way as regular communities, just larger -- they are uniform untyped triplets of 32bit numbers. Individual community values are represented using an <cf/lc/ data type inside the filters. <tag><label id="rta-bgp-originator-id">quad bgp_originator_id [I, O]</tag> This attribute is created by the route reflector when reflecting the route and contains the router ID of the originator of the route in the local AS. <tag><label id="rta-bgp-cluster-list">clist bgp_cluster_list [I, O]</tag> This attribute contains a list of cluster IDs of route reflectors. Each route reflector prepends its cluster ID when reflecting the route. <tag><label id="rta-bgp-aigp">void bgp_aigp [O]</tag> This attribute contains accumulated IGP metric, which is a total distance to the destination through multiple autonomous systems. Currently, the attribute is not accessible from filters. </descrip> <sect1>Example <label id="bgp-exam"> <p><code> protocol bgp { local 198.51.100.14 as 65000; # Use a private AS number neighbor 198.51.100.130 as 64496; # Our neighbor ... multihop; # ... which is connected indirectly ipv4 { export filter { # We use non-trivial export rules if source = RTS_STATIC then { # Export only static routes # Assign our community bgp_community.add((65000,64501)); # Artificially increase path length # by advertising local AS number twice if bgp_path ~ [= 65000 =] then bgp_path.prepend(65000); accept; } reject; }; import all; next hop self; # advertise this router as next hop igp table myigptable4; # IGP table for routes with IPv4 nexthops igp table myigptable6; # IGP table for routes with IPv6 nexthops }; ipv6 { export filter mylargefilter; # We use a named filter import all; missing lladdr self; igp table myigptable4; # IGP table for routes with IPv4 nexthops igp table myigptable6; # IGP table for routes with IPv6 nexthops }; ipv4 multicast { import all; export filter someotherfilter; table mymulticasttable4; # Another IPv4 table, dedicated for multicast igp table myigptable4; }; } </code> <sect>Device <label id="device"> <p>The Device protocol is not a real routing protocol. It doesn't generate any routes and it only serves as a module for getting information about network interfaces from the kernel. This protocol supports no channel. <p>Except for very unusual circumstances, you probably should include this protocol in the configuration since almost all other protocols require network interfaces to be defined for them to work with. <sect1>Configuration <label id="device-config"> <p><descrip> <tag><label id="device-scan-time">scan time <m/number/</tag> Time in seconds between two scans of the network interface list. On systems where we are notified about interface status changes asynchronously (such as newer versions of Linux), we need to scan the list only in order to avoid confusion by lost notification messages, so the default time is set to a large value. <tag><label id="device-iface">interface <m/pattern/ [, <m/.../]</tag> By default, the Device protocol handles all interfaces without any configuration. Interface definitions allow to specify optional parameters for specific interfaces. See <ref id="proto-iface" name="interface"> common option for detailed description. Currently only one interface option is available: <tag><label id="device-preferred">preferred <m/ip/</tag> If a network interface has more than one IP address, BIRD chooses one of them as a preferred one. Preferred IP address is used as source address for packets or announced next hop by routing protocols. Precisely, BIRD chooses one preferred IPv4 address, one preferred IPv6 address and one preferred link-local IPv6 address. By default, BIRD chooses the first found IP address as the preferred one. This option allows to specify which IP address should be preferred. May be used multiple times for different address classes (IPv4, IPv6, IPv6 link-local). In all cases, an address marked by operating system as secondary cannot be chosen as the primary one. </descrip> <p>As the Device protocol doesn't generate any routes, it cannot have any attributes. Example configuration looks like this: <p><code> protocol device { scan time 10; # Scan the interfaces often interface "eth0" { preferred 192.168.1.1; preferred 2001:db8:1:10::1; }; } </code> <sect>Direct <label id="direct"> <p>The Direct protocol is a simple generator of device routes for all the directly connected networks according to the list of interfaces provided by the kernel via the Device protocol. The Direct protocol supports both IPv4 and IPv6 channels; both can be configured simultaneously. It can also be configured with <ref id="ip-sadr-routes" name="IPv6 SADR"> channel instead of regular IPv6 channel in order to be used together with SADR-enabled Babel protocol. <p>The question is whether it is a good idea to have such device routes in BIRD routing table. OS kernel usually handles device routes for directly connected networks by itself so we don't need (and don't want) to export these routes to the kernel protocol. OSPF protocol creates device routes for its interfaces itself and BGP protocol is usually used for exporting aggregate routes. But the Direct protocol is necessary for distance-vector protocols like RIP or Babel to announce local networks. <p>There are just few configuration options for the Direct protocol: <p><descrip> <tag><label id="direct-iface">interface <m/pattern/ [, <m/.../]</tag> By default, the Direct protocol will generate device routes for all the interfaces available. If you want to restrict it to some subset of interfaces or addresses (e.g. if you're using multiple routing tables for policy routing and some of the policy domains don't contain all interfaces), just use this clause. See <ref id="proto-iface" name="interface"> common option for detailed description. The Direct protocol uses extended interface clauses. <tag><label id="direct-check-link">check link <m/switch/</tag> If enabled, a hardware link state (reported by OS) is taken into consideration. Routes for directly connected networks are generated only if link up is reported and they are withdrawn when link disappears (e.g., an ethernet cable is unplugged). Default value is no. </descrip> <p>Direct device routes don't contain any specific attributes. <p>Example config might look like this: <p><code> protocol direct { ipv4; ipv6; interface "-arc*", "*"; # Exclude the ARCnets } </code> <sect>Kernel <label id="krt"> <p>The Kernel protocol is not a real routing protocol. Instead of communicating with other routers in the network, it performs synchronization of BIRD's routing tables with the OS kernel. Basically, it sends all routing table updates to the kernel and from time to time it scans the kernel tables to see whether some routes have disappeared (for example due to unnoticed up/down transition of an interface) or whether an `alien' route has been added by someone else (depending on the <cf/learn/ switch, such routes are either ignored or accepted to our table). <p>Note that routes created by OS kernel itself, namely direct routes representing IP subnets of associated interfaces, are not imported even with <cf/learn/ enabled. You can use <ref id="direct" name="Direct protocol"> to generate these direct routes. <p>If your OS supports only a single routing table, you can configure only one instance of the Kernel protocol. If it supports multiple tables (in order to allow policy routing; such an OS is for example Linux), you can run as many instances as you want, but each of them must be connected to a different BIRD routing table and to a different kernel table. <p>Because the kernel protocol is partially integrated with the connected routing table, there are two limitations - it is not possible to connect more kernel protocols to the same routing table and changing route destination (gateway) in an export filter of a kernel protocol does not work. Both limitations can be overcome using another routing table and the pipe protocol. <p>The Kernel protocol supports both IPv4 and IPv6 channels; only one channel can be configured in each protocol instance. On Linux, it also supports <ref id="ip-sadr-routes" name="IPv6 SADR"> and <ref id="mpls-routes" name="MPLS"> channels. <sect1>Configuration <label id="krt-config"> <p><descrip> <tag><label id="krt-persist">persist <m/switch/</tag> Tell BIRD to leave all its routes in the routing tables when it exits (instead of cleaning them up). <tag><label id="krt-scan-time">scan time <m/number/</tag> Time in seconds between two consecutive scans of the kernel routing table. <tag><label id="krt-learn">learn <m/switch/</tag> Enable learning of routes added to the kernel routing tables by other routing daemons or by the system administrator. This is possible only on systems which support identification of route authorship. <tag><label id="krt-kernel-table">kernel table <m/number/</tag> Select which kernel table should this particular instance of the Kernel protocol work with. Available only on systems supporting multiple routing tables. <tag><label id="krt-metric">metric <m/number/</tag> (Linux) Use specified value as a kernel metric (priority) for all routes sent to the kernel. When multiple routes for the same network are in the kernel routing table, the Linux kernel chooses one with lower metric. Also, routes with different metrics do not clash with each other, therefore using dedicated metric value is a reliable way to avoid overwriting routes from other sources (e.g. kernel device routes). Metric 0 has a special meaning of undefined metric, in which either OS default is used, or per-route metric can be set using <cf/krt_metric/ attribute. Default: 32. <tag><label id="krt-graceful-restart">graceful restart <m/switch/</tag> Participate in graceful restart recovery. If this option is enabled and a graceful restart recovery is active, the Kernel protocol will defer synchronization of routing tables until the end of the recovery. Note that import of kernel routes to BIRD is not affected. <tag><label id="krt-merge-paths">merge paths <M>switch</M> [limit <M>number</M>]</tag> Usually, only best routes are exported to the kernel protocol. With path merging enabled, both best routes and equivalent non-best routes are merged during export to generate one ECMP (equal-cost multipath) route for each network. This is useful e.g. for BGP multipath. Note that best routes are still pivotal for route export (responsible for most properties of resulting ECMP routes), while exported non-best routes are responsible just for additional multipath next hops. This option also allows to specify a limit on maximal number of nexthops in one route. By default, multipath merging is disabled. If enabled, default value of the limit is 16. </descrip> <sect1>Attributes <label id="krt-attr"> <p>The Kernel protocol defines several attributes. These attributes are translated to appropriate system (and OS-specific) route attributes. We support these attributes: <descrip> <tag><label id="rta-krt-source">int krt_source</tag> The original source of the imported kernel route. The value is system-dependent. On Linux, it is a value of the protocol field of the route. See /etc/iproute2/rt_protos for common values. On BSD, it is based on STATIC and PROTOx flags. The attribute is read-only. <tag><label id="rta-krt-metric">int krt_metric</tag> (Linux) The kernel metric of the route. When multiple same routes are in a kernel routing table, the Linux kernel chooses one with lower metric. Note that preferred way to set kernel metric is to use protocol option <cf/metric/, unless per-route metric values are needed. <tag><label id="rta-krt-prefsrc">ip krt_prefsrc</tag> (Linux) The preferred source address. Used in source address selection for outgoing packets. Has to be one of the IP addresses of the router. <tag><label id="rta-krt-realm">int krt_realm</tag> (Linux) The realm of the route. Can be used for traffic classification. <tag><label id="rta-krt-scope">int krt_scope</tag> (Linux IPv4) The scope of the route. Valid values are 0-254, although Linux kernel may reject some values depending on route type and nexthop. It is supposed to represent `indirectness' of the route, where nexthops of routes are resolved through routes with a higher scope, but in current kernels anything below <it/link/ (253) is treated as <it/global/ (0). When not present, global scope is implied for all routes except device routes, where link scope is used by default. </descrip> <p>In Linux, there is also a plenty of obscure route attributes mostly focused on tuning TCP performance of local connections. BIRD supports most of these attributes, see Linux or iproute2 documentation for their meaning. Attributes <cf/krt_lock_*/ and <cf/krt_feature_*/ have type bool, others have type int. Supported attributes are: <cf/krt_mtu/, <cf/krt_lock_mtu/, <cf/krt_window/, <cf/krt_lock_window/, <cf/krt_rtt/, <cf/krt_lock_rtt/, <cf/krt_rttvar/, <cf/krt_lock_rttvar/, <cf/krt_sstresh/, <cf/krt_lock_sstresh/, <cf/krt_cwnd/, <cf/krt_lock_cwnd/, <cf/krt_advmss/, <cf/krt_lock_advmss/, <cf/krt_reordering/, <cf/krt_lock_reordering/, <cf/krt_hoplimit/, <cf/krt_lock_hoplimit/, <cf/krt_rto_min/, <cf/krt_lock_rto_min/, <cf/krt_initcwnd/, <cf/krt_initrwnd/, <cf/krt_quickack/, <cf/krt_feature_ecn/, <cf/krt_feature_allfrag/ <sect1>Example <label id="krt-exam"> <p>A simple configuration can look this way: <p><code> protocol kernel { export all; } </code> <p>Or for a system with two routing tables: <p><code> protocol kernel { # Primary routing table learn; # Learn alien routes from the kernel persist; # Don't remove routes on bird shutdown scan time 10; # Scan kernel routing table every 10 seconds ipv4 { import all; export all; }; } protocol kernel { # Secondary routing table kernel table 100; ipv4 { table auxtable; export all; }; } </code> <sect>MRT <label id="mrt"> <sect1>Introduction <label id="mrt-intro"> <p>The MRT protocol is a component responsible for handling the Multi-Threaded Routing Toolkit (MRT) routing information export format, which is mainly used for collecting and analyzing of routing information from BGP routers. The MRT protocol can be configured to do periodic dumps of routing tables, created MRT files can be analyzed later by other tools. Independent MRT table dumps can also be requested from BIRD client. There is also a feature to save incoming BGP messages in MRT files, but it is controlled by <ref id="proto-mrtdump" name="mrtdump"> options independently of MRT protocol, although that might change in the future. BIRD implements the main MRT format specification as defined in <rfc id="6396"> and the ADD_PATH extension (<rfc id="8050">). <sect1>Configuration <label id="mrt-config"> <p>MRT configuration consists of several statements describing routing table dumps. Multiple independent periodic dumps can be done as multiple MRT protocol instances. The MRT protocol does not use channels. There are two mandatory statements: <cf/filename/ and <cf/period/. The behavior can be modified by following configuration parameters: <descrip> <tag><label id="mrt-table">table <m/name/ | "<m/pattern/"</tag> Specify a routing table (or a set of routing tables described by a wildcard pattern) that are to be dumped by the MRT protocol instance. Default: the master table. <tag><label id="mrt-filter">filter { <m/filter commands/ }</tag> The MRT protocol allows to specify a filter that is applied to routes as they are dumped. Rejected routes are ignored and not saved to the MRT dump file. Default: no filter. <tag><label id="mrt-where">where <m/filter expression/</tag> An alternative way to specify a filter for the MRT protocol. <tag><label id="mrt-filename">filename "<m/filename/"</tag> Specify a filename for MRT dump files. The filename may contain time format sequences with <it/strftime(3)/ notation (see <it/man strftime/ for details), there is also a sequence "%N" that is expanded to the name of dumped table. Therefore, each periodic dump of each table can be saved to a different file. Mandatory, see example below. <tag><label id="mrt-period">period <m/number/</tag> Specify the time interval (in seconds) between periodic dumps. Mandatory. <tag><label id="mrt-always-add-path">always add path <m/switch/</tag> The MRT format uses special records (specified in <rfc id="8050">) for routes received using BGP ADD_PATH extension to keep Path ID, while other routes use regular records. This has advantage of better compatibility with tools that do not know special records, but it loses information about which route is the best route. When this option is enabled, both ADD_PATH and non-ADD_PATH routes are stored in ADD_PATH records and order of routes for network is preserved. Default: disabled. </descrip> <sect1>Example <label id="mrt-exam"> <p><code> protocol mrt { table "tab*"; where source = RTS_BGP; filename "/var/log/bird/%N_%F_%T.mrt"; period 300; } </code> <sect>OSPF <label id="ospf"> <sect1>Introduction <label id="ospf-intro"> <p>Open Shortest Path First (OSPF) is a quite complex interior gateway protocol. The current IPv4 version (OSPFv2) is defined in <rfc id="2328"> and the current IPv6 version (OSPFv3) is defined in <rfc id="5340"> It's a link state (a.k.a. shortest path first) protocol -- each router maintains a database describing the autonomous system's topology. Each participating router has an identical copy of the database and all routers run the same algorithm calculating a shortest path tree with themselves as a root. OSPF chooses the least cost path as the best path. <p>In OSPF, the autonomous system can be split to several areas in order to reduce the amount of resources consumed for exchanging the routing information and to protect the other areas from incorrect routing data. Topology of the area is hidden to the rest of the autonomous system. <p>Another very important feature of OSPF is that it can keep routing information from other protocols (like Static or BGP) in its link state database as external routes. Each external route can be tagged by the advertising router, making it possible to pass additional information between routers on the boundary of the autonomous system. <p>OSPF quickly detects topological changes in the autonomous system (such as router interface failures) and calculates new loop-free routes after a short period of convergence. Only a minimal amount of routing traffic is involved. <p>Each router participating in OSPF routing periodically sends Hello messages to all its interfaces. This allows neighbors to be discovered dynamically. Then the neighbors exchange theirs parts of the link state database and keep it identical by flooding updates. The flooding process is reliable and ensures that each router detects all changes. <sect1>Configuration <label id="ospf-config"> <p>First, the desired OSPF version can be specified by using <cf/ospf v2/ or <cf/ospf v3/ as a protocol type. By default, OSPFv2 is used. In the main part of configuration, there can be multiple definitions of OSPF areas, each with a different id. These definitions includes many other switches and multiple definitions of interfaces. Definition of interface may contain many switches and constant definitions and list of neighbors on nonbroadcast networks. <p>OSPFv2 needs one IPv4 channel. OSPFv3 needs either one IPv6 channel, or one IPv4 channel (<rfc id="5838">). Therefore, it is possible to use OSPFv3 for both IPv4 and Pv6 routing, but it is necessary to have two protocol instances anyway. If no channel is configured, appropriate channel is defined with default parameters. <code> protocol ospf [v2|v3] <name> { rfc1583compat <switch>; rfc5838 <switch>; instance id <num>; stub router <switch>; tick <num>; ecmp <switch> [limit <num>]; merge external <switch>; graceful restart <switch>|aware; graceful restart time <num>; area <id> { stub; nssa; summary <switch>; default nssa <switch>; default cost <num>; default cost2 <num>; translator <switch>; translator stability <num>; networks { <prefix>; <prefix> hidden; }; external { <prefix>; <prefix> hidden; <prefix> tag <num>; }; stubnet <prefix>; stubnet <prefix> { hidden <switch>; summary <switch>; cost <num>; }; interface <interface pattern> [instance <num>] { cost <num>; stub <switch>; hello <num>; poll <num>; retransmit <num>; priority <num>; wait <num>; dead count <num>; dead <num>; secondary <switch>; rx buffer [normal|large|<num>]; tx length <num>; type [broadcast|bcast|pointopoint|ptp| nonbroadcast|nbma|pointomultipoint|ptmp]; link lsa suppression <switch>; strict nonbroadcast <switch>; real broadcast <switch>; ptp netmask <switch>; ptp address <switch>; check link <switch>; bfd <switch>; ecmp weight <num>; ttl security [<switch>; | tx only] tx class|dscp <num>; tx priority <num>; authentication none|simple|cryptographic; password "<text>"; password "<text>" { id <num>; generate from "<date>"; generate to "<date>"; accept from "<date>"; accept to "<date>"; from "<date>"; to "<date>"; algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 ); }; neighbors { <ip>; <ip> eligible; }; }; virtual link <id> [instance <num>] { hello <num>; retransmit <num>; wait <num>; dead count <num>; dead <num>; authentication none|simple|cryptographic; password "<text>"; password "<text>" { id <num>; generate from "<date>"; generate to "<date>"; accept from "<date>"; accept to "<date>"; from "<date>"; to "<date>"; algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 ); }; }; }; } </code> <descrip> <tag><label id="ospf-rfc1583compat">rfc1583compat <M>switch</M></tag> This option controls compatibility of routing table calculation with <rfc id="1583">. Default value is no. <tag><label id="ospf-rfc5838">rfc5838 <m/switch/</tag> Basic OSPFv3 is limited to IPv6 unicast routing. The <rfc id="5838"> extension defines support for more address families (IPv4, IPv6, both unicast and multicast). The extension is enabled by default, but can be disabled if necessary, as it restricts the range of available instance IDs. Default value is yes. <tag><label id="ospf-instance-id">instance id <m/num/</tag> When multiple OSPF protocol instances are active on the same links, they should use different instance IDs to distinguish their packets. Although it could be done on per-interface basis, it is often preferred to set one instance ID to whole OSPF domain/topology (e.g., when multiple instances are used to represent separate logical topologies on the same physical network). This option specifies the instance ID for all interfaces of the OSPF instance, but can be overridden by <cf/interface/ option. Default value is 0 unless OSPFv3-AF extended address families are used, see <rfc id="5838"> for that case. <tag><label id="ospf-stub-router">stub router <M>switch</M></tag> This option configures the router to be a stub router, i.e., a router that participates in the OSPF topology but does not allow transit traffic. In OSPFv2, this is implemented by advertising maximum metric for outgoing links. In OSPFv3, the stub router behavior is announced by clearing the R-bit in the router LSA. See <rfc id="6987"> for details. Default value is no. <tag><label id="ospf-tick">tick <M>num</M></tag> The routing table calculation and clean-up of areas' databases is not performed when a single link state change arrives. To lower the CPU utilization, it's processed later at periodical intervals of <m/num/ seconds. The default value is 1. <tag><label id="ospf-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag> This option specifies whether OSPF is allowed to generate ECMP (equal-cost multipath) routes. Such routes are used when there are several directions to the destination, each with the same (computed) cost. This option also allows to specify a limit on maximum number of nexthops in one route. By default, ECMP is enabled if supported by Kernel. Default value of the limit is 16. <tag><label id="ospf-merge-external">merge external <M>switch</M></tag> This option specifies whether OSPF should merge external routes from different routers/LSAs for the same destination. When enabled together with <cf/ecmp/, equal-cost external routes will be combined to multipath routes in the same way as regular routes. When disabled, external routes from different LSAs are treated as separate even if they represents the same destination. Default value is no. <tag><label id="ospf-graceful-restart">graceful restart <m/switch/|aware</tag> When an OSPF instance is restarted, neighbors break adjacencies and recalculate their routing tables, which disrupts packet forwarding even when the forwarding plane of the restarting router remains intact. <rfc id="3623"> specifies a graceful restart mechanism to alleviate this issue. For OSPF graceful restart, restarting router originates Grace-LSAs, announcing intent to do graceful restart. Neighbors receiving these LSAs enter helper mode, in which they ignore breakdown of adjacencies, behave as if nothing is happening and keep old routes. When adjacencies are reestablished, the restarting router flushes Grace-LSAs and graceful restart is ended. This option controls the graceful restart mechanism. It has three states: Disabled, when no support is provided. Aware, when graceful restart helper mode is supported, but no local graceful restart is allowed (i.e. helper-only role). Enabled, when the full graceful restart support is provided (i.e. both restarting and helper role). Note that proper support for local graceful restart requires also configuration of other protocols. Default: aware. <tag><label id="ospf-graceful-restart-time">graceful restart time <m/num/</tag> The restart time is announced in the Grace-LSA and specifies how long neighbors should wait for proper end of the graceful restart before exiting helper mode prematurely. Default: 120 seconds. <tag><label id="ospf-area">area <M>id</M></tag> This defines an OSPF area with given area ID (an integer or an IPv4 address, similarly to a router ID). The most important area is the backbone (ID 0) to which every other area must be connected. <tag><label id="ospf-stub">stub</tag> This option configures the area to be a stub area. External routes are not flooded into stub areas. Also summary LSAs can be limited in stub areas (see option <cf/summary/). By default, the area is not a stub area. <tag><label id="ospf-nssa">nssa</tag> This option configures the area to be a NSSA (Not-So-Stubby Area). NSSA is a variant of a stub area which allows a limited way of external route propagation. Global external routes are not propagated into a NSSA, but an external route can be imported into NSSA as a (area-wide) NSSA-LSA (and possibly translated and/or aggregated on area boundary). By default, the area is not NSSA. <tag><label id="ospf-summary">summary <M>switch</M></tag> This option controls propagation of summary LSAs into stub or NSSA areas. If enabled, summary LSAs are propagated as usual, otherwise just the default summary route (0.0.0.0/0) is propagated (this is sometimes called totally stubby area). If a stub area has more area boundary routers, propagating summary LSAs could lead to more efficient routing at the cost of larger link state database. Default value is no. <tag><label id="ospf-default-nssa">default nssa <M>switch</M></tag> When <cf/summary/ option is enabled, default summary route is no longer propagated to the NSSA. In that case, this option allows to originate default route as NSSA-LSA to the NSSA. Default value is no. <tag><label id="ospf-default-cost">default cost <M>num</M></tag> This option controls the cost of a default route propagated to stub and NSSA areas. Default value is 1000. <tag><label id="ospf-default-cost2">default cost2 <M>num</M></tag> When a default route is originated as NSSA-LSA, its cost can use either type 1 or type 2 metric. This option allows to specify the cost of a default route in type 2 metric. By default, type 1 metric (option <cf/default cost/) is used. <tag><label id="ospf-translator">translator <M>switch</M></tag> This option controls translation of NSSA-LSAs into external LSAs. By default, one translator per NSSA is automatically elected from area boundary routers. If enabled, this area boundary router would unconditionally translate all NSSA-LSAs regardless of translator election. Default value is no. <tag><label id="ospf-translator-stability">translator stability <M>num</M></tag> This option controls the translator stability interval (in seconds). When the new translator is elected, the old one keeps translating until the interval is over. Default value is 40. <tag><label id="ospf-networks">networks { <m/set/ }</tag> Definition of area IP ranges. This is used in summary LSA origination. Hidden networks are not propagated into other areas. <tag><label id="ospf-external">external { <m/set/ }</tag> Definition of external area IP ranges for NSSAs. This is used for NSSA-LSA translation. Hidden networks are not translated into external LSAs. Networks can have configured route tag. <tag><label id="ospf-stubnet">stubnet <m/prefix/ { <m/options/ }</tag> Stub networks are networks that are not transit networks between OSPF routers. They are also propagated through an OSPF area as a part of a link state database. By default, BIRD generates a stub network record for each primary network address on each OSPF interface that does not have any OSPF neighbors, and also for each non-primary network address on each OSPF interface. This option allows to alter a set of stub networks propagated by this router. Each instance of this option adds a stub network with given network prefix to the set of propagated stub network, unless option <cf/hidden/ is used. It also suppresses default stub networks for given network prefix. When option <cf/summary/ is used, also default stub networks that are subnetworks of given stub network are suppressed. This might be used, for example, to aggregate generated stub networks. <tag><label id="ospf-iface">interface <M>pattern</M> [instance <m/num/]</tag> Defines that the specified interfaces belong to the area being defined. See <ref id="proto-iface" name="interface"> common option for detailed description. In OSPFv2, extended interface clauses are used, because each network prefix is handled as a separate virtual interface. You can specify alternative instance ID for the interface definition, therefore it is possible to have several instances of that interface with different options or even in different areas. For OSPFv2, instance ID support is an extension (<rfc id="6549">) and is supposed to be set per-protocol. For OSPFv3, it is an integral feature. <tag><label id="ospf-virtual-link">virtual link <M>id</M> [instance <m/num/]</tag> Virtual link to router with the router id. Virtual link acts as a point-to-point interface belonging to backbone. The actual area is used as a transport area. This item cannot be in the backbone. Like with <cf/interface/ option, you could also use several virtual links to one destination with different instance IDs. <tag><label id="ospf-cost">cost <M>num</M></tag> Specifies output cost (metric) of an interface. Default value is 10. <tag><label id="ospf-stub-iface">stub <M>switch</M></tag> If set to interface it does not listen to any packet and does not send any hello. Default value is no. <tag><label id="ospf-hello">hello <M>num</M></tag> Specifies interval in seconds between sending of Hello messages. Beware, all routers on the same network need to have the same hello interval. Default value is 10. <tag><label id="ospf-poll">poll <M>num</M></tag> Specifies interval in seconds between sending of Hello messages for some neighbors on NBMA network. Default value is 20. <tag><label id="ospf-retransmit">retransmit <M>num</M></tag> Specifies interval in seconds between retransmissions of unacknowledged updates. Default value is 5. <tag><label id="ospf-transmit-delay">transmit delay <M>num</M></tag> Specifies estimated transmission delay of link state updates send over the interface. The value is added to LSA age of LSAs propagated through it. Default value is 1. <tag><label id="ospf-priority">priority <M>num</M></tag> On every multiple access network (e.g., the Ethernet) Designated Router and Backup Designated router are elected. These routers have some special functions in the flooding process. Higher priority increases preferences in this election. Routers with priority 0 are not eligible. Default value is 1. <tag><label id="ospf-wait">wait <M>num</M></tag> After start, router waits for the specified number of seconds between starting election and building adjacency. Default value is 4*<m/hello/. <tag><label id="ospf-dead-count">dead count <M>num</M></tag> When the router does not receive any messages from a neighbor in <m/dead count/*<m/hello/ seconds, it will consider the neighbor down. <tag><label id="ospf-dead">dead <M>num</M></tag> When the router does not receive any messages from a neighbor in <m/dead/ seconds, it will consider the neighbor down. If both directives <cf/dead count/ and <cf/dead/ are used, <cf/dead/ has precedence. <tag><label id="ospf-rx-buffer">rx buffer <M>num</M></tag> This option allows to specify the size of buffers used for packet processing. The buffer size should be bigger than maximal size of any packets. By default, buffers are dynamically resized as needed, but a fixed value could be specified. Value <cf/large/ means maximal allowed packet size - 65535. <tag><label id="ospf-tx-length">tx length <M>num</M></tag> Transmitted OSPF messages that contain large amount of information are segmented to separate OSPF packets to avoid IP fragmentation. This option specifies the soft ceiling for the length of generated OSPF packets. Default value is the MTU of the network interface. Note that larger OSPF packets may still be generated if underlying OSPF messages cannot be splitted (e.g. when one large LSA is propagated). <tag><label id="ospf-type-bcast">type broadcast|bcast</tag> BIRD detects a type of a connected network automatically, but sometimes it's convenient to force use of a different type manually. On broadcast networks (like ethernet), flooding and Hello messages are sent using multicasts (a single packet for all the neighbors). A designated router is elected and it is responsible for synchronizing the link-state databases and originating network LSAs. This network type cannot be used on physically NBMA networks and on unnumbered networks (networks without proper IP prefix). <tag><label id="ospf-type-ptp">type pointopoint|ptp</tag> Point-to-point networks connect just 2 routers together. No election is performed and no network LSA is originated, which makes it simpler and faster to establish. This network type is useful not only for physically PtP ifaces (like PPP or tunnels), but also for broadcast networks used as PtP links. This network type cannot be used on physically NBMA networks. <tag><label id="ospf-type-nbma">type nonbroadcast|nbma</tag> On NBMA networks, the packets are sent to each neighbor separately because of lack of multicast capabilities. Like on broadcast networks, a designated router is elected, which plays a central role in propagation of LSAs. This network type cannot be used on unnumbered networks. <tag><label id="ospf-type-ptmp">type pointomultipoint|ptmp</tag> This is another network type designed to handle NBMA networks. In this case the NBMA network is treated as a collection of PtP links. This is useful if not every pair of routers on the NBMA network has direct communication, or if the NBMA network is used as an (possibly unnumbered) PtP link. <tag><label id="ospf-link-lsa-suppression">link lsa suppression <m/switch/</tag> In OSPFv3, link LSAs are generated for each link, announcing link-local IPv6 address of the router to its local neighbors. These are useless on PtP or PtMP networks and this option allows to suppress the link LSA origination for such interfaces. The option is ignored on other than PtP or PtMP interfaces. Default value is no. <tag><label id="ospf-strict-nonbroadcast">strict nonbroadcast <m/switch/</tag> If set, don't send hello to any undefined neighbor. This switch is ignored on other than NBMA or PtMP interfaces. Default value is no. <tag><label id="ospf-real-broadcast">real broadcast <m/switch/</tag> In <cf/type broadcast/ or <cf/type ptp/ network configuration, OSPF packets are sent as IP multicast packets. This option changes the behavior to using old-fashioned IP broadcast packets. This may be useful as a workaround if IP multicast for some reason does not work or does not work reliably. This is a non-standard option and probably is not interoperable with other OSPF implementations. Default value is no. <tag><label id="ospf-ptp-netmask">ptp netmask <m/switch/</tag> In <cf/type ptp/ network configurations, OSPFv2 implementations should ignore received netmask field in hello packets and should send hello packets with zero netmask field on unnumbered PtP links. But some OSPFv2 implementations perform netmask checking even for PtP links. This option specifies whether real netmask will be used in hello packets on <cf/type ptp/ interfaces. You should ignore this option unless you meet some compatibility problems related to this issue. Default value is no for unnumbered PtP links, yes otherwise. <tag><label id="ospf-ptp-address">ptp address <m/switch/</tag> In <cf/type ptp/ network configurations, OSPFv2 implementations should use IP address for regular PtP links and interface id for unnumbered PtP links in data field of link description records in router LSA. This data field has only local meaning for PtP links, but some broken OSPFv2 implementations assume there is an IP address and use it as a next hop in SPF calculations. Note that interface id for unnumbered PtP links is necessary when graceful restart is enabled to distinguish PtP links with the same local IP address. This option specifies whether an IP address will be used in data field for <cf/type ptp/ interfaces, it is ignored for other interfaces. You should ignore this option unless you meet some compatibility problems related to this issue. Default value is no for unnumbered PtP links when graceful restart is enabled, yes otherwise. <tag><label id="ospf-check-link">check link <M>switch</M></tag> If set, a hardware link state (reported by OS) is taken into consideration. When a link disappears (e.g. an ethernet cable is unplugged), neighbors are immediately considered unreachable and only the address of the iface (instead of whole network prefix) is propagated. It is possible that some hardware drivers or platforms do not implement this feature. Default value is yes. <tag><label id="ospf-bfd">bfd <M>switch</M></tag> OSPF could use BFD protocol as an advisory mechanism for neighbor liveness and failure detection. If enabled, BIRD setups a BFD session for each OSPF neighbor and tracks its liveness by it. This has an advantage of an order of magnitude lower detection times in case of failure. Note that BFD protocol also has to be configured, see <ref id="bfd" name="BFD"> section for details. Default value is no. <tag><label id="ospf-ttl-security">ttl security [<m/switch/ | tx only]</tag> TTL security is a feature that protects routing protocols from remote spoofed packets by using TTL 255 instead of TTL 1 for protocol packets destined to neighbors. Because TTL is decremented when packets are forwarded, it is non-trivial to spoof packets with TTL 255 from remote locations. Note that this option would interfere with OSPF virtual links. If this option is enabled, the router will send OSPF packets with TTL 255 and drop received packets with TTL less than 255. If this option si set to <cf/tx only/, TTL 255 is used for sent packets, but is not checked for received packets. Default value is no. <tag><label id="ospf-tx-class">tx class|dscp|priority <m/num/</tag> These options specify the ToS/DiffServ/Traffic class/Priority of the outgoing OSPF packets. See <ref id="proto-tx-class" name="tx class"> common option for detailed description. <tag><label id="ospf-ecmp-weight">ecmp weight <M>num</M></tag> When ECMP (multipath) routes are allowed, this value specifies a relative weight used for nexthops going through the iface. Allowed values are 1-256. Default value is 1. <tag><label id="ospf-auth-none">authentication none</tag> No passwords are sent in OSPF packets. This is the default value. <tag><label id="ospf-auth-simple">authentication simple</tag> Every packet carries 8 bytes of password. Received packets lacking this password are ignored. This authentication mechanism is very weak. This option is not available in OSPFv3. <tag><label id="ospf-auth-cryptographic">authentication cryptographic</tag> An authentication code is appended to every packet. The specific cryptographic algorithm is selected by option <cf/algorithm/ for each key. The default cryptographic algorithm for OSPFv2 keys is Keyed-MD5 and for OSPFv3 keys is HMAC-SHA-256. Passwords are not sent open via network, so this mechanism is quite secure. Packets can still be read by an attacker. <tag><label id="ospf-pass">password "<M>text</M>"</tag> Specifies a password used for authentication. See <ref id="proto-pass" name="password"> common option for detailed description. <tag><label id="ospf-neighbors">neighbors { <m/set/ } </tag> A set of neighbors to which Hello messages on NBMA or PtMP networks are to be sent. For NBMA networks, some of them could be marked as eligible. In OSPFv3, link-local addresses should be used, using global ones is possible, but it is nonstandard and might be problematic. And definitely, link-local and global addresses should not be mixed. </descrip> <sect1>Attributes <label id="ospf-attr"> <p>OSPF defines four route attributes. Each internal route has a <cf/metric/. <p>Metric is ranging from 1 to infinity (65535). External routes use <cf/metric type 1/ or <cf/metric type 2/. A <cf/metric of type 1/ is comparable with internal <cf/metric/, a <cf/metric of type 2/ is always longer than any <cf/metric of type 1/ or any <cf/internal metric/. <cf/Internal metric/ or <cf/metric of type 1/ is stored in attribute <cf/ospf_metric1/, <cf/metric type 2/ is stored in attribute <cf/ospf_metric2/. When both metrics are specified then <cf/metric of type 2/ is used. This is relevant e.g. when a type 2 external route is propagated from one OSPF domain to another and <cf/ospf_metric1/ is an internal distance to the original ASBR, while <cf/ospf_metric2/ stores the type 2 metric. Note that in such cases if <cf/ospf_metric1/ is non-zero then <cf/ospf_metric2/ is increased by one to ensure monotonicity of metric, as internal distance is reset to zero when an external route is announced. <p>Each external route can also carry attribute <cf/ospf_tag/ which is a 32-bit integer which is used when exporting routes to other protocols; otherwise, it doesn't affect routing inside the OSPF domain at all. The fourth attribute <cf/ospf_router_id/ is a router ID of the router advertising that route / network. This attribute is read-only. Default is <cf/ospf_metric2 = 10000/ and <cf/ospf_tag = 0/. <sect1>Example <label id="ospf-exam"> <p><code> protocol ospf MyOSPF { ipv4 { export filter { if source = RTS_BGP then { ospf_metric1 = 100; accept; } reject; }; }; area 0.0.0.0 { interface "eth*" { cost 11; hello 15; priority 100; retransmit 7; authentication simple; password "aaa"; }; interface "ppp*" { cost 100; authentication cryptographic; password "abc" { id 1; generate to "22-04-2003 11:00:06"; accept from "17-01-2001 12:01:05"; algorithm hmac sha384; }; password "def" { id 2; generate to "22-07-2005 17:03:21"; accept from "22-02-2001 11:34:06"; algorithm hmac sha512; }; }; interface "arc0" { cost 10; stub yes; }; interface "arc1"; }; area 120 { stub yes; networks { 172.16.1.0/24; 172.16.2.0/24 hidden; }; interface "-arc0" , "arc*" { type nonbroadcast; authentication none; strict nonbroadcast yes; wait 120; poll 40; dead count 8; neighbors { 192.168.120.1 eligible; 192.168.120.2; 192.168.120.10; }; }; }; } </code> <sect>Perf <label id="perf"> <sect1>Introduction <label id="perf-intro"> <p>The Perf protocol is a generator of fake routes together with a time measurement framework. Its purpose is to check BIRD performance and to benchmark filters. <p>Import mode of this protocol runs in several steps. In each step, it generates 2^x routes, imports them into the appropriate table and withdraws them. The exponent x is configurable. It runs the benchmark several times for the same x, then it increases x by one until it gets too high, then it stops. <p>Export mode of this protocol repeats route refresh from table and measures how long it takes. <p>Output data is logged on info level. There is a Perl script <cf>proto/perf/parse.pl</cf> which may be handy to parse the data and draw some plots. <p>Implementation of this protocol is experimental. Use with caution and do not keep any instance of Perf in production configs for long time. The config interface is also unstable and may change in future versions without warning. <sect1>Configuration <label id="perf-config"> <p><descrip> <tag><label id="perf-mode">mode import|export</tag> Set perf mode. Default: import <tag><label id="perf-repeat">repeat <m/number/</tag> Run this amount of iterations of the benchmark for every amount step. Default: 4 <tag><label id="perf-from">exp from <m/number/</tag> Begin benchmarking on this exponent for number of generated routes in one step. Default: 10 <tag><label id="perf-to">exp to <m/number/</tag> Stop benchmarking on this exponent. Default: 20 <tag><label id="perf-threshold-min">threshold min <m/time/</tag> If a run for the given exponent took less than this time for route import, increase the exponent immediately. Default: 1 ms <tag><label id="perf-threshold-max">threshold max <m/time/</tag> If every run for the given exponent took at least this time for route import, stop benchmarking. Default: 500 ms </descrip> <sect>Pipe <label id="pipe"> <sect1>Introduction <label id="pipe-intro"> <p>The Pipe protocol serves as a link between two routing tables, allowing routes to be passed from a table declared as primary (i.e., the one the pipe is connected to using the <cf/table/ configuration keyword) to the secondary one (declared using <cf/peer table/) and vice versa, depending on what's allowed by the filters. Export filters control export of routes from the primary table to the secondary one, import filters control the opposite direction. Both tables must be of the same nettype. <p>The Pipe protocol retransmits all routes from one table to the other table, retaining their original source and attributes. If import and export filters are set to accept, then both tables would have the same content. <p>The primary use of multiple routing tables and the Pipe protocol is for policy routing, where handling of a single packet doesn't depend only on its destination address, but also on its source address, source interface, protocol type and other similar parameters. In many systems (Linux being a good example), the kernel allows to enforce routing policies by defining routing rules which choose one of several routing tables to be used for a packet according to its parameters. Setting of these rules is outside the scope of BIRD's work (on Linux, you can use the <tt/ip/ command), but you can create several routing tables in BIRD, connect them to the kernel ones, use filters to control which routes appear in which tables and also you can employ the Pipe protocol for exporting a selected subset of one table to another one. <sect1>Configuration <label id="pipe-config"> <p>Essentially, the Pipe protocol is just a channel connected to a table on both sides. Therefore, the configuration block for <cf/protocol pipe/ shall directly include standard channel config options; see the example below. <p><descrip> <tag><label id="pipe-peer-table">peer table <m/table/</tag> Defines secondary routing table to connect to. The primary one is selected by the <cf/table/ keyword. </descrip> <sect1>Attributes <label id="pipe-attr"> <p>The Pipe protocol doesn't define any route attributes. <sect1>Example <label id="pipe-exam"> <p>Let's consider a router which serves as a boundary router of two different autonomous systems, each of them connected to a subset of interfaces of the router, having its own exterior connectivity and wishing to use the other AS as a backup connectivity in case of outage of its own exterior line. <p>Probably the simplest solution to this situation is to use two routing tables (we'll call them <cf/as1/ and <cf/as2/) and set up kernel routing rules, so that packets having arrived from interfaces belonging to the first AS will be routed according to <cf/as1/ and similarly for the second AS. Thus we have split our router to two logical routers, each one acting on its own routing table, having its own routing protocols on its own interfaces. In order to use the other AS's routes for backup purposes, we can pass the routes between the tables through a Pipe protocol while decreasing their preferences and correcting their BGP paths to reflect the AS boundary crossing. <code> ipv4 table as1; # Define the tables ipv4 table as2; protocol kernel kern1 { # Synchronize them with the kernel ipv4 { table as1; export all; }; kernel table 1; } protocol kernel kern2 { ipv4 { table as2; export all; }; kernel table 2; } protocol bgp bgp1 { # The outside connections ipv4 { table as1; import all; export all; }; local as 1; neighbor 192.168.0.1 as 1001; } protocol bgp bgp2 { ipv4 { table as2; import all; export all; }; local as 2; neighbor 10.0.0.1 as 1002; } protocol pipe { # The Pipe table as1; peer table as2; export filter { if net ~ [ 1.0.0.0/8+] then { # Only AS1 networks if preference>10 then preference = preference-10; if source=RTS_BGP then bgp_path.prepend(1); accept; } reject; }; import filter { if net ~ [ 2.0.0.0/8+] then { # Only AS2 networks if preference>10 then preference = preference-10; if source=RTS_BGP then bgp_path.prepend(2); accept; } reject; }; } </code> <sect>RAdv <label id="radv"> <sect1>Introduction <label id="radv-intro"> <p>The RAdv protocol is an implementation of Router Advertisements, which are used in the IPv6 stateless autoconfiguration. IPv6 routers send (in irregular 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">, router preferences and specific routes (<rfc id="4191">), and DNS extensions (<rfc id="6106">). <p>The RAdv protocols supports just IPv6 channel. <sect1>Configuration <label id="radv-config"> <p>There are several classes of definitions in RAdv configuration -- interface definitions, prefix definitions and DNS definitions: <descrip> <tag><label id="radv-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag> Interface definitions specify a set of interfaces on which the protocol is activated and contain interface specific options. See <ref id="proto-iface" name="interface"> common options for detailed description. <tag><label id="radv-prefix">prefix <m/prefix/ { <m/options/ }</tag> Prefix definitions allow to modify a list of advertised prefixes. By default, the advertised prefixes are the same as the network prefixes assigned to the interface. For each network prefix, the matching prefix definition is found and its options are used. If no matching prefix definition is found, the prefix is used with default options. Prefix definitions can be either global or interface-specific. The second ones are part of interface options. The prefix definition matching is done in the first-match style, when interface-specific definitions are processed before global definitions. As expected, the prefix definition is matching if the network prefix is a subnet of the prefix in prefix definition. <tag><label id="radv-rdnss">rdnss { <m/options/ }</tag> RDNSS definitions allow to specify a list of advertised recursive DNS servers together with their options. As options are seldom necessary, there is also a short variant <cf>rdnss <m/address/</cf> that just specifies one DNS server. Multiple definitions are cumulative. RDNSS 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. <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 definitions are cumulative, they can be used also as interface-specific options and there is a short variant <cf>dnssl <m/domain/</cf> that just specifies one DNS search domain. <tag><label id="radv-trigger">trigger <m/prefix/</tag> RAdv protocol could be configured to change its behavior based on availability of routes. When this option is used, the protocol waits in suppressed state until a <it/trigger route/ (for the specified network) is exported to the protocol, the protocol also returns to suppressed state if the <it/trigger route/ disappears. Note that route export depends on specified export filter, as usual. This option could be used, e.g., for handling failover in multihoming scenarios. During suppressed state, router advertisements are generated, but with some fields zeroed. Exact behavior depends on which fields are zeroed, this can be configured by <cf/sensitive/ option for appropriate fields. By default, just <cf/default lifetime/ (also called <cf/router lifetime/) is zeroed, which means hosts cannot use the router as a 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: <descrip> <tag><label id="radv-iface-max-ra-interval">max ra interval <m/expr/</tag> Unsolicited router advertisements are sent in irregular time intervals. This option specifies the maximum length of these intervals, in seconds. Valid values are 4-1800. Default: 600 <tag><label id="radv-iface-min-ra-interval">min ra interval <m/expr/</tag> This option specifies the minimum length of that intervals, in seconds. Must be at least 3 and at most 3/4 * <cf/max ra interval/. Default: about 1/3 * <cf/max ra interval/. <tag><label id="radv-iface-min-delay">min delay <m/expr/</tag> The minimum delay between two consecutive router advertisements, in seconds. Default: 3 <tag><label id="radv-solicited-ra-unicast">solicited ra unicast <m/switch/</tag> Solicited router advertisements are usually sent to all-nodes multicast group like unsolicited ones, but the router can be configured to send them as unicast directly to soliciting nodes instead. This is especially useful on wireless networks (see <rfc id="7772">). Default: no <tag><label id="radv-iface-managed">managed <m/switch/</tag> This option specifies whether hosts should use DHCPv6 for IP address configuration. Default: no <tag><label id="radv-iface-other-config">other config <m/switch/</tag> This option specifies whether hosts should use DHCPv6 to receive other configuration information. Default: no <tag><label id="radv-iface-link-mtu">link mtu <m/expr/</tag> This option specifies which value of MTU should be used by hosts. 0 means unspecified. Default: 0 <tag><label id="radv-iface-reachable-time">reachable time <m/expr/</tag> This option specifies the time (in milliseconds) how long hosts should assume a neighbor is reachable (from the last confirmation). Maximum is 3600000, 0 means unspecified. Default 0. <tag><label id="radv-iface-retrans-timer">retrans timer <m/expr/</tag> This option specifies the time (in milliseconds) how long hosts should wait before retransmitting Neighbor Solicitation messages. 0 means unspecified. Default 0. <tag><label id="radv-iface-current-hop-limit">current hop limit <m/expr/</tag> This option specifies which value of Hop Limit should be used by 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 (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-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 also be used to disable RDNSS for given interface if no local definitons are specified. Default: no. <tag><label id="radv-iface-dnssl-local">dnssl local <m/switch/</tag> Use only local DNSSL definitions for this interface. See <cf/rdnss local/ option above. Default: no. </descrip> <p>Prefix specific options <descrip> <tag><label id="radv-prefix-skip">skip <m/switch/</tag> This option allows to specify that given prefix should not be advertised. This is useful for making exceptions from a default policy of advertising all prefixes. Note that for withdrawing an already advertised prefix it is more useful to advertise it with zero valid lifetime. Default: no <tag><label id="radv-prefix-onlink">onlink <m/switch/</tag> This option specifies whether hosts may use the advertised prefix for onlink determination. Default: yes <tag><label id="radv-prefix-autonomous">autonomous <m/switch/</tag> This option specifies whether hosts may use the advertised prefix for stateless autoconfiguration. Default: yes <tag><label id="radv-prefix-valid-lifetime">valid lifetime <m/expr/ [sensitive <m/switch/]</tag> This option specifies the time (in seconds) how long (after the receipt of RA) the prefix information is valid, i.e., autoconfigured IP addresses can be assigned and hosts with that IP addresses are considered directly reachable. 0 means the prefix is no longer valid. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">. Default: 86400 (1 day), <cf/sensitive/ no. <tag><label id="radv-prefix-preferred-lifetime">preferred lifetime <m/expr/ [sensitive <m/switch/]</tag> This option specifies the time (in seconds) how long (after the receipt of RA) IP addresses generated from the prefix using stateless autoconfiguration remain preferred. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">. Default: 14400 (4 hours), <cf/sensitive/ no. </descrip> <p>RDNSS specific options: <descrip> <tag><label id="radv-rdnss-ns">ns <m/address/</tag> This option specifies one recursive DNS server. Can be used multiple times for multiple servers. It is mandatory to have at least one <cf/ns/ option in <cf/rdnss/ definition. <tag><label id="radv-rdnss-lifetime">lifetime [mult] <m/expr/</tag> This option specifies the time how long the RDNSS information may be used by clients after the receipt of RA. It is expressed either in seconds or (when <cf/mult/ is used) in multiples of <cf/max ra interval/. Note that RDNSS information is also invalidated when <cf/default lifetime/ expires. 0 means these addresses are no longer valid DNS servers. Default: 3 * <cf/max ra interval/. </descrip> <p>DNSSL specific options: <descrip> <tag><label id="radv-dnssl-domain">domain <m/address/</tag> This option specifies one DNS search domain. Can be used multiple times for multiple domains. It is mandatory to have at least one <cf/domain/ option in <cf/dnssl/ definition. <tag><label id="radv-dnssl-lifetime">lifetime [mult] <m/expr/</tag> This option specifies the time how long the DNSSL information may be used by clients after the receipt of RA. Details are the same as for 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> ipv6 table radv_routes; # Manually configured routes go here protocol static { ipv6 { 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 ipv6 { table radv_routes; export all; }; interface "eth2" { max ra interval 5; # Fast failover with more routers managed yes; # Using DHCPv6 on eth2 prefix ::/0 { autonomous off; # So do not autoconfigure any IP }; }; interface "eth*"; # No need for any other options prefix 2001:0DB8:1234::/48 { preferred lifetime 0; # Deprecated address range }; prefix 2001:0DB8:2000::/48 { autonomous off; # Do not autoconfigure }; rdnss 2001:0DB8:1234::10; # Short form of RDNSS rdnss { lifetime mult 10; ns 2001:0DB8:1234::11; ns 2001:0DB8:1234::12; }; dnssl { lifetime 3600; domain "abc.com"; domain "xyz.com"; }; } </code> <sect>RIP <label id="rip"> <sect1>Introduction <label id="rip-intro"> <p>The RIP protocol (also sometimes called Rest In Pieces) is a simple protocol, where each router broadcasts (to all its neighbors) distances to all networks it can reach. When a router hears distance to another network, it increments it and broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some network goes unreachable, routers keep telling each other that its distance is the original distance plus 1 (actually, plus interface metric, which is usually one). After some time, the distance reaches infinity (that's 15 in RIP) and all routers know that network is unreachable. RIP tries to minimize situations where counting to infinity is necessary, because it is slow. Due to infinity being 16, you can't use RIP on networks where maximal distance is higher than 15 hosts. <p>BIRD supports RIPv1 (<rfc id="1058">), RIPv2 (<rfc id="2453">), RIPng (<rfc id="2080">), Triggered RIP for demand circuits (<rfc id="2091">), and RIP cryptographic authentication (<rfc id="4822">). <p>RIP is a very simple protocol, and it has a lot of shortcomings. Slow convergence, big network load and inability to handle larger networks makes it pretty much obsolete. It is still usable on very small networks. <sect1>Configuration <label id="rip-config"> <p>RIP configuration consists mainly of common protocol options and interface definitions, most RIP options are interface specific. RIPng (RIP for IPv6) protocol instance can be configured by using <cf/rip ng/ instead of just <cf/rip/ as a protocol type. <p>RIP needs one IPv4 channel. RIPng needs one IPv6 channel. If no channel is configured, appropriate channel is defined with default parameters. <code> protocol rip [ng] [<name>] { infinity <number>; ecmp <switch> [limit <number>]; interface <interface pattern> { metric <number>; mode multicast|broadcast; passive <switch>; address <ip>; port <number>; version 1|2; split horizon <switch>; poison reverse <switch>; demand circuit <switch>; check zero <switch>; update time <number>; timeout time <number>; garbage time <number>; ecmp weight <number>; ttl security <switch>; | tx only; tx class|dscp <number>; tx priority <number>; rx buffer <number>; tx length <number>; check link <switch>; authentication none|plaintext|cryptographic; password "<text>"; password "<text>" { id <num>; generate from "<date>"; generate to "<date>"; accept from "<date>"; accept to "<date>"; from "<date>"; to "<date>"; algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 ); }; }; } </code> <descrip> <tag><label id="rip-infinity">infinity <M>number</M></tag> Selects the distance of infinity. Bigger values will make protocol convergence even slower. The default value is 16. <tag><label id="rip-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag> This option specifies whether RIP is allowed to generate ECMP (equal-cost multipath) routes. Such routes are used when there are several directions to the destination, each with the same (computed) cost. This option also allows to specify a limit on maximum number of nexthops in one route. By default, ECMP is enabled if supported by Kernel. Default value of the limit is 16. <tag><label id="rip-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag> Interface definitions specify a set of interfaces on which the protocol is activated and contain interface specific options. See <ref id="proto-iface" name="interface"> common options for detailed description. </descrip> <p>Interface specific options: <descrip> <tag><label id="rip-iface-metric">metric <m/num/</tag> This option specifies the metric of the interface. When a route is received from the interface, its metric is increased by this value before further processing. Valid values are 1-255, but values higher than infinity has no further meaning. Default: 1. <tag><label id="rip-iface-mode">mode multicast|broadcast</tag> This option selects the mode for RIP to use on the interface. The default is multicast mode for RIPv2 and broadcast mode for RIPv1. RIPng always uses the multicast mode. <tag><label id="rip-iface-passive">passive <m/switch/</tag> Passive interfaces receive routing updates but do not transmit any messages. Default: no. <tag><label id="rip-iface-address">address <m/ip/</tag> This option specifies a destination address used for multicast or broadcast messages, the default is the official RIP (224.0.0.9) or RIPng (ff02::9) multicast address, or an appropriate broadcast address in the broadcast mode. <tag><label id="rip-iface-port">port <m/number/</tag> This option selects an UDP port to operate on, the default is the official RIP (520) or RIPng (521) port. <tag><label id="rip-iface-version">version 1|2</tag> This option selects the version of RIP used on the interface. For RIPv1, automatic subnet aggregation is not implemented, only classful network routes and host routes are propagated. Note that BIRD allows RIPv1 to be configured with features that are defined for RIPv2 only, like authentication or using multicast sockets. The default is RIPv2 for IPv4 RIP, the option is not supported for RIPng, as no further versions are defined. <tag><label id="rip-iface-version-only">version only <m/switch/</tag> Regardless of RIP version configured for the interface, BIRD accepts incoming packets of any RIP version. This option restrict accepted packets to the configured version. Default: no. <tag><label id="rip-iface-split-horizon">split horizon <m/switch/</tag> Split horizon is a scheme for preventing routing loops. When split horizon is active, routes are not regularly propagated back to the interface from which they were received. They are either not propagated back at all (plain split horizon) or propagated back with an infinity metric (split horizon with poisoned reverse). Therefore, other routers on the interface will not consider the router as a part of an independent path to the destination of the route. Default: yes. <tag><label id="rip-iface-poison-reverse">poison reverse <m/switch/</tag> When split horizon is active, this option specifies whether the poisoned reverse variant (propagating routes back with an infinity metric) is used. The poisoned reverse has some advantages in faster convergence, but uses more network traffic. Default: yes. <tag><label id="rip-iface-demand-circuit">demand circuit <m/switch/</tag> Regular RIP sends periodic full updates on an interface. There is the Triggered RIP extension for demand circuits (<rfc id="2091">), which removes periodic updates and introduces update acknowledgments. When enabled, there is no RIP communication in steady-state network. Note that in order to work, it must be enabled on both sides. As there are no hello packets, it depends on hardware link state to detect neighbor failures. Also, it is designed for PtP links and it does not work properly with multiple RIP neighbors on an interface. Default: no. <tag><label id="rip-iface-check-zero">check zero <m/switch/</tag> Received RIPv1 packets with non-zero values in reserved fields should be discarded. This option specifies whether the check is performed or such packets are just processed as usual. Default: yes. <tag><label id="rip-iface-update-time">update time <m/number/</tag> Specifies the number of seconds between periodic updates. A lower number will mean faster convergence but bigger network load. Default: 30. <tag><label id="rip-iface-timeout-time">timeout time <m/number/</tag> Specifies the time interval (in seconds) between the last received route announcement and the route expiration. After that, the network is considered unreachable, but still is propagated with infinity distance. Default: 180. <tag><label id="rip-iface-garbage-time">garbage time <m/number/</tag> Specifies the time interval (in seconds) between the route expiration and the removal of the unreachable network entry. The garbage interval, when a route with infinity metric is propagated, is used for both internal (after expiration) and external (after withdrawal) routes. Default: 120. <tag><label id="rip-iface-ecmp-weight">ecmp weight <m/number/</tag> When ECMP (multipath) routes are allowed, this value specifies a relative weight used for nexthops going through the iface. Valid values are 1-256. Default value is 1. <tag><label id="rip-iface-auth">authentication none|plaintext|cryptographic</tag> Selects authentication method to be used. <cf/none/ means that packets are not authenticated at all, <cf/plaintext/ means that a plaintext password is embedded into each packet, and <cf/cryptographic/ means that packets are authenticated using some cryptographic hash function selected by option <cf/algorithm/ for each key. The default cryptographic algorithm for RIP keys is Keyed-MD5. If you set authentication to not-none, it is a good idea to add <cf>password</cf> section. Default: none. <tag><label id="rip-iface-pass">password "<m/text/"</tag> Specifies a password used for authentication. See <ref id="proto-pass" name="password"> common option for detailed description. <tag><label id="rip-iface-ttl-security">ttl security [<m/switch/ | tx only]</tag> TTL security is a feature that protects routing protocols from remote spoofed packets by using TTL 255 instead of TTL 1 for protocol packets destined to neighbors. Because TTL is decremented when packets are forwarded, it is non-trivial to spoof packets with TTL 255 from remote locations. If this option is enabled, the router will send RIP packets with TTL 255 and drop received packets with TTL less than 255. If this option si set to <cf/tx only/, TTL 255 is used for sent packets, but is not checked for received packets. Such setting does not offer protection, but offers compatibility with neighbors regardless of whether they use ttl security. For RIPng, TTL security is a standard behavior (required by <rfc id="2080">) and therefore default value is yes. For IPv4 RIP, default value is no. <tag><label id="rip-iface-tx-class">tx class|dscp|priority <m/number/</tag> These options specify the ToS/DiffServ/Traffic class/Priority of the outgoing RIP packets. See <ref id="proto-tx-class" name="tx class"> common option for detailed description. <tag><label id="rip-iface-rx-buffer">rx buffer <m/number/</tag> This option specifies the size of buffers used for packet processing. The buffer size should be bigger than maximal size of received packets. The default value is 532 for IPv4 RIP and interface MTU value for RIPng. <tag><label id="rip-iface-tx-length">tx length <m/number/</tag> This option specifies the maximum length of generated RIP packets. To avoid IP fragmentation, it should not exceed the interface MTU value. The default value is 532 for IPv4 RIP and interface MTU value for RIPng. <tag><label id="rip-iface-check-link">check link <m/switch/</tag> If set, the hardware link state (as reported by OS) is taken into consideration. When the link disappears (e.g. an ethernet cable is unplugged), neighbors are immediately considered unreachable and all routes received from them are withdrawn. It is possible that some hardware drivers or platforms do not implement this feature. Default: yes. </descrip> <sect1>Attributes <label id="rip-attr"> <p>RIP defines two route attributes: <descrip> <tag><label id="rta-rip-metric">int rip_metric</tag> RIP metric of the route (ranging from 0 to <cf/infinity/). When routes from different RIP instances are available and all of them have the same preference, BIRD prefers the route with lowest <cf/rip_metric/. When a non-RIP route is exported to RIP, the default metric is 1. <tag><label id="rta-rip-tag">int rip_tag</tag> RIP route tag: a 16-bit number which can be used to carry additional information with the route (for example, an originating AS number in case of external routes). When a non-RIP route is exported to RIP, the default tag is 0. </descrip> <sect1>Example <label id="rip-exam"> <p><code> protocol rip { ipv4 { import all; export all; }; interface "eth*" { metric 2; port 1520; mode multicast; update time 12; timeout time 60; authentication cryptographic; password "secret" { algorithm hmac sha256; }; }; } </code> <sect>RPKI <label id="rpki"> <sect1>Introduction <p>The Resource Public Key Infrastructure (RPKI) is mechanism for origin validation of BGP routes (<rfc id="6480">). BIRD supports only so-called RPKI-based origin validation. There is implemented RPKI to Router (RPKI-RTR) protocol (<rfc id="6810">). It uses some of the RPKI data to allow a router to verify that the autonomous system announcing an IP address prefix is in fact authorized to do so. This is not crypto checked so can be violated. But it should prevent the vast majority of accidental hijackings on the Internet today, e.g. the famous Pakistani accidental announcement of YouTube's address space. <p>The RPKI-RTR protocol receives and maintains a set of ROAs from a cache server (also called validator). You can validate routes (<rfc id="6483">, <rfc id="6811">) using function <cf/roa_check()/ in filter and set it as import filter at the BGP protocol. BIRD offers crude automatic re-validating of affected routes after RPKI update, see option <ref id="proto-rpki-reload" name="rpki reload">. Or you can use a BIRD client command <cf>reload in <m/bgp_protocol_name/</cf> for manual call of revalidation of all routes. <sect1>Supported transports <p> <itemize> <item>Unprotected transport over TCP uses a port 323. The cache server and BIRD router should be on the same trusted and controlled network for security reasons. <item>SSHv2 encrypted transport connection uses the normal SSH port 22. </itemize> <sect1>Configuration <p>We currently support just one cache server per protocol. However you can define more RPKI protocols generally. <code> protocol rpki [<name>] { roa4 { table <tab>; }; roa6 { table <tab>; }; remote <ip> | "<domain>" [port <num>]; port <num>; refresh [keep] <num>; retry [keep] <num>; expire [keep] <num>; transport tcp; transport ssh { bird private key "</path/to/id_rsa>"; remote public key "</path/to/known_host>"; user "<name>"; }; } </code> <p>Alse note that you have to specify the ROA channel. If you want to import only IPv4 prefixes you have to specify only roa4 channel. Similarly with IPv6 prefixes only. If you want to fetch both IPv4 and even IPv6 ROAs you have to specify both channels. <sect2>RPKI protocol options <p> <descrip> <tag>remote <m/ip/ | "<m/hostname/" [port <m/num/]</tag> Specifies a destination address of the cache server. Can be specified by an IP address or by full domain name string. Only one cache can be specified per protocol. This option is required. <tag>port <m/num/</tag> Specifies the port number. The default port number is 323 for transport without any encryption and 22 for transport with SSH encryption. <tag>refresh [keep] <m/num/</tag> Time period in seconds. Tells how long to wait before next attempting to poll the cache using a Serial Query or a Reset Query packet. Must be lower than 86400 seconds (one day). Too low value can caused a false positive detection of network connection problems. A keyword <cf/keep/ suppresses updating this value by a cache server. Default: 3600 seconds <tag>retry [keep] <m/num/</tag> Time period in seconds between a failed Serial/Reset Query and a next attempt. Maximum allowed value is 7200 seconds (two hours). Too low value can caused a false positive detection of network connection problems. A keyword <cf/keep/ suppresses updating this value by a cache server. Default: 600 seconds <tag>expire [keep] <m/num/</tag> Time period in seconds. Received records are deleted if the client was unable to successfully refresh data for this time period. Must be in range from 600 seconds (ten minutes) to 172800 seconds (two days). A keyword <cf/keep/ suppresses updating this value by a cache server. Default: 7200 seconds <tag>ignore max length <m/switch/</tag> Ignore received max length in ROA records and use max value (32 or 128) instead. This may be useful for implementing loose RPKI check for blackholes. Default: disabled. <tag>transport tcp</tag> Unprotected transport over TCP. It's a default transport. Should be used only on secure private networks. Default: tcp <tag>transport ssh { <m/SSH transport options.../ }</tag> It enables a SSHv2 transport encryption. Cannot be combined with a TCP transport. Default: off </descrip> <sect3>SSH transport options <p> <descrip> <tag>bird private key "<m>/path/to/id_rsa</m>"</tag> A path to the BIRD's private SSH key for authentication. It can be a <cf><m>id_rsa</m></cf> file. <tag>remote public key "<m>/path/to/known_host</m>"</tag> A path to the cache's public SSH key for verification identity of the cache server. It could be a path to <cf><m>known_host</m></cf> file. <tag>user "<m/name/"</tag> A SSH user name for authentication. This option is a required. </descrip> <sect1>Examples <sect2>BGP origin validation <p>Policy: Don't import <cf/ROA_INVALID/ routes. <code> roa4 table r4; roa6 table r6; protocol rpki { debug all; roa4 { table r4; }; roa6 { table r6; }; # Please, do not use rpki-validator.realmv6.org in production remote "rpki-validator.realmv6.org" port 8282; retry keep 5; refresh keep 30; expire 600; } filter peer_in_v4 { if (roa_check(r4, net, bgp_path.last) = ROA_INVALID) then { print "Ignore RPKI invalid ", net, " for ASN ", bgp_path.last; reject; } accept; } protocol bgp { debug all; local as 65000; neighbor 192.168.2.1 as 65001; ipv4 { import filter peer_in_v4; export none; }; } </code> <sect2>SSHv2 transport encryption <p> <code> roa4 table r4; roa6 table r6; protocol rpki { debug all; roa4 { table r4; }; roa6 { table r6; }; remote 127.0.0.1 port 2345; transport ssh { bird private key "/home/birdgeek/.ssh/id_rsa"; remote public key "/home/birdgeek/.ssh/known_hosts"; user "birdgeek"; }; # Default interval values } </code> <sect>Static <label id="static"> <p>The Static protocol doesn't communicate with other routers in the network, but instead it allows you to define routes manually. This is often used for specifying how to forward packets to parts of the network which don't use dynamic routing at all and also for defining sink routes (i.e., those telling to return packets as undeliverable if they are in your IP block, you don't have any specific destination for them and you don't want to send them out through the default route to prevent routing loops). <p>There are three classes of definitions in Static protocol configuration -- global options, static route definitions, and per-route options. Usually, the definition of the protocol contains mainly a list of static routes. Static routes have no specific attributes, but <ref id="rta-igp-metric" name="igp_metric"> attribute is used to compare static routes with the same preference. <p>The list of static routes may contain multiple routes for the same network (usually, but not necessary, distinquished by <cf/preference/ or <cf/igp_metric/), but only routes of the same network type are allowed, as the static protocol has just one channel. E.g., to have both IPv4 and IPv6 static routes, define two static protocols, each with appropriate routes and channel. <p>Global options: <descrip> <tag><label id="static-check-link">check link <m/switch/</tag> If set, hardware link states of network interfaces are taken into consideration. When link disappears (e.g. ethernet cable is unplugged), static routes directing to that interface are removed. It is possible that some hardware drivers or platforms do not implement this feature. Default: off. <tag><label id="static-igp-table">igp table <m/name/</tag> Specifies a table that is used for route table lookups of recursive routes. Default: the same table as the protocol is connected to. </descrip> <p>Route definitions (each may also contain a block of per-route options): <sect1>Regular routes; MPLS switching rules <p>There exist several types of routes; keep in mind that <m/prefix/ syntax is <ref id="type-prefix" name="dependent on network type">. <descrip> <tag>route <m/prefix/ via <m/ip/|<m/"interface"/ [<m/per-nexthop options/] [via ...]</tag> Regular routes may bear one or more <ref id="route-next-hop" name="next hops">. Every next hop is preceded by <cf/via/ and configured as shown. <tag>route <m/prefix/ recursive <m/ip/ [mpls <m/num/[/<m/num/[/<m/num/[...]]]]</tag> Recursive nexthop resolves the given IP in the configured IGP table and uses that route's next hop. The MPLS stacks are concatenated; on top is the IGP's nexthop stack and on bottom is this route's stack. <tag>route <m/prefix/ blackhole|unreachable|prohibit</tag> Special routes specifying to silently drop the packet, return it as unreachable or return it as administratively prohibited. First two targets are also known as <cf/drop/ and <cf/reject/. </descrip> <p>When the particular destination is not available (the interface is down or the next hop of the route is not a neighbor at the moment), Static just uninstalls the route from the table it is connected to and adds it again as soon as the destination becomes adjacent again. <sect2>Per-nexthop options <p>There are several options that in a case of multipath route are per-nexthop (i.e., they can be used multiple times for a route, one time for each nexthop). Syntactically, they are not separate options but just parts of <cf/route/ statement after each <cf/via/ statement, not separated by semicolons. E.g., statement <cf/route 10.0.0.0/8 via 192.0.2.1 bfd weight 1 via 192.0.2.2 weight 2;/ describes a route with two nexthops, the first nexthop has two per-nexthop options (<cf/bfd/ and <cf/weight 1/), the second nexthop has just <cf/weight 2/. <descrip> <tag><label id="static-route-bfd">bfd <m/switch/</tag> The Static protocol could use BFD protocol for next hop liveness detection. If enabled, a BFD session to the route next hop is created and the static route is BFD-controlled -- the static route is announced only if the next hop liveness is confirmed by BFD. If the BFD session fails, the static route (or just the affected nexthop from multiple ones) is removed. Note that this is a bit different compared to other protocols, which may use BFD as an advisory mechanism for fast failure detection but ignore it if a BFD session is not even established. Note that BFD protocol also has to be configured, see <ref id="bfd" name="BFD"> section for details. Default value is no. <tag><label id="static-route-mpls">mpls <m/num/[/<m/num/[/<m/num/[...]]]</tag> MPLS labels that should be pushed to packets forwarded by the route. The option could be used for both IP routes (on MPLS ingress routers) and MPLS switching rules (on MPLS transit routers). Default value is no labels. <tag><label id="static-route-onlink">onlink <m/switch/</tag> Onlink flag means that the specified nexthop is accessible on the (specified) interface regardless of IP prefixes of the interface. The interface must be attached to nexthop IP address using link-local-scope format (e.g. <cf/192.0.2.1%eth0/). Default value is no. <tag><label id="static-route-weight">weight <m/switch/</tag> For multipath routes, this value specifies a relative weight of the nexthop. Allowed values are 1-256. Default value is 1. </descrip> <sect1>Route Origin Authorization <p>The ROA config is just <cf>route <m/prefix/ max <m/int/ as <m/int/</cf> with no nexthop. <sect1>Flowspec <label id="flowspec-network-type"> <p>The flow specification are rules for routers and firewalls for filtering purpose. It is described by <rfc id="5575">. There are 3 types of arguments: <m/inet4/ or <m/inet6/ prefixes, bitmasks matching expressions and numbers matching expressions. Bitmasks matching is written using <m/value/<cf>/</cf><m/mask/ or <cf/!/<m/value/<cf>/</cf><m/mask/ pairs. It means that <cf/(/<m/data/ <cf/&/ <m/mask/<cf/)/ is or is not equal to <m/value/. Numbers matching is a matching sequence of numbers and ranges separeted by a commas (<cf/,/) (e.g. <cf/10,20,30/). Ranges can be written using double dots <cf/../ notation (e.g. <cf/80..90,120..124/). An alternative notation are sequence of one or more pairs of relational operators and values separated by logical operators <cf/&&/ or <cf/||/. Allowed relational operators are <cf/=/, <cf/!=/, <cf/</, <cf/<=/, <cf/>/, <cf/>=/, <cf/true/ and <cf/false/. <sect2>IPv4 Flowspec <p><descrip> <tag><label id="flow-dst">dst <m/inet4/</tag> Set a matching destination prefix (e.g. <cf>dst 192.168.0.0/16</cf>). Only this option is mandatory in IPv4 Flowspec. <tag><label id="flow-src">src <m/inet4/</tag> Set a matching source prefix (e.g. <cf>src 10.0.0.0/8</cf>). <tag><label id="flow-proto">proto <m/numbers-match/</tag> Set a matching IP protocol numbers (e.g. <cf/proto 6/). <tag><label id="flow-port">port <m/numbers-match/</tag> Set a matching source or destination TCP/UDP port numbers (e.g. <cf>port 1..1023,1194,3306</cf>). <tag><label id="flow-dport">dport <m/numbers-match/</tag> Set a mating destination port numbers (e.g. <cf>dport 49151</cf>). <tag><label id="flow-sport">sport <m/numbers-match/</tag> Set a matching source port numbers (e.g. <cf>sport = 0</cf>). <tag><label id="flow-icmp-type">icmp type <m/numbers-match/</tag> Set a matching type field number of an ICMP packet (e.g. <cf>icmp type 3</cf>) <tag><label id="flow-icmp-code">icmp code <m/numbers-match/</tag> Set a matching code field number of an ICMP packet (e.g. <cf>icmp code 1</cf>) <tag><label id="flow-tcp-flags">tcp flags <m/bitmask-match/</tag> Set a matching bitmask for TCP header flags (aka control bits) (e.g. <cf>tcp flags 0x03/0x0f;</cf>). The maximum length of mask is 12 bits (0xfff). <tag><label id="flow-length">length <m/numbers-match/</tag> Set a matching packet length (e.g. <cf>length > 1500;</cf>) <tag><label id="flow-dscp">dscp <m/numbers-match/</tag> Set a matching DiffServ Code Point number (e.g. <cf>length > 1500;</cf>). <tag><label id="flow-fragment">fragment <m/fragmentation-type/</tag> Set a matching type of packet fragmentation. Allowed fragmentation types are <cf/dont_fragment/, <cf/is_fragment/, <cf/first_fragment/, <cf/last_fragment/ (e.g. <cf>fragment is_fragment && !dont_fragment</cf>). </descrip> <p><code> protocol static { flow4; route flow4 { dst 10.0.0.0/8; port > 24 && < 30 || 40..50,60..70,80 && >= 90; tcp flags 0x03/0x0f; length > 1024; dscp = 63; fragment dont_fragment, is_fragment || !first_fragment; }; } </code> <sect2>Differences for IPv6 Flowspec <p>Flowspec IPv6 are same as Flowspec IPv4 with a few exceptions. <itemize> <item>Prefixes <m/inet6/ can be specified not only with prefix length, but with prefix <cf/offset/ <m/num/ too (e.g. <cf>::1234:5678:9800:0000/101 offset 64</cf>). Offset means to don't care of <m/num/ first bits. <item>IPv6 Flowspec hasn't mandatory any flowspec component. <item>In IPv6 packets, there is a matching the last next header value for a matching IP protocol number (e.g. <cf>next header 6</cf>). <item>It is not possible to set <cf>dont_fragment</cf> as a type of packet fragmentation. </itemize> <p><descrip> <tag><label id="flow6-dst">dst <m/inet6/ [offset <m/num/]</tag> Set a matching destination IPv6 prefix (e.g. <cf>dst ::1c77:3769:27ad:a11a/128 offset 64</cf>). <tag><label id="flow6-src">src <m/inet6/ [offset <m/num/]</tag> Set a matching source IPv6 prefix (e.g. <cf>src fe80::/64</cf>). <tag><label id="flow6-next-header">next header <m/numbers-match/</tag> Set a matching IP protocol numbers (e.g. <cf>next header != 6</cf>). <tag><label id="flow6-label">label <m/bitmask-match/</tag> Set a 20-bit bitmask for matching Flow Label field in IPv6 packets (e.g. <cf>label 0x8e5/0x8e5</cf>). </descrip> <p><code> protocol static { flow6 { table myflow6; }; route flow6 { dst fec0:1122:3344:5566:7788:99aa:bbcc:ddee/128; src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63; next header = 23; sport > 24 && < 30 || = 40 || 50,60,70..80; dport = 50; tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33; fragment !is_fragment || !first_fragment; label 0xaaaa/0xaaaa && 0x33/0x33; }; } </code> <sect1>Per-route options <p> <descrip> <tag><label id="static-route-filter"><m/filter expression/</tag> This is a special option that allows filter expressions to be configured on per-route basis. Can be used multiple times. These expressions are evaluated when the route is originated, similarly to the import filter of the static protocol. This is especially useful for configuring route attributes, e.g., <cf/ospf_metric1 = 100;/ for a route that will be exported to the OSPF protocol. </descrip> <sect1>Example static configs <label id="static-example"> <p><code> protocol static { ipv4 { table testable; }; # Connect to a non-default routing table check link; # Advertise routes only if link is up route 0.0.0.0/0 via 198.51.100.130; # Default route route 10.0.0.0/8 # Multipath route via 198.51.100.10 weight 2 via 198.51.100.20 bfd # BFD-controlled next hop via 192.0.2.1; route 203.0.113.0/24 blackhole; # Sink route route 10.2.0.0/24 via "arc0"; # Secondary network route 192.168.10.0/24 via 198.51.100.100 { ospf_metric1 = 20; # Set extended attribute }; route 192.168.11.0/24 via 198.51.100.100 { ospf_metric2 = 100; # Set extended attribute ospf_tag = 2; # Set extended attribute }; route 192.168.12.0/24 via 198.51.100.100 { bgp_community.add((65535, 65281)); # Set extended BGP attribute bgp_large_community.add((64512, 1, 1)); # Set extended BGP attribute }; } protocol static { ipv6; # Channel is mandatory route 2001:db8:10::/48 via 2001:db8:1::1; # Route with global nexthop route 2001:db8:20::/48 via fe80::10%eth0; # Route with link-local nexthop route 2001:db8:30::/48 via fe80::20%'eth1.60'; # Iface with non-alphanumeric characters route 2001:db8:40::/48 via "eth2"; # Direct route to eth2 route 2001:db8::/32 unreachable; # Unreachable route route ::/0 via 2001:db8:1::1 bfd; # BFD-controlled default route } </code> <chapt>Conclusions <label id="conclusion"> <sect>Future work <label id="future-work"> <p>Although BIRD supports all the commonly used routing protocols, there are still some features which would surely deserve to be implemented in future versions of BIRD: <itemize> <item>Opaque LSA's <item>Route aggregation and flap dampening <item>Multicast routing protocols <item>Ports to other systems </itemize> <sect>Getting more help <label id="help"> <p>If you use BIRD, you're welcome to join the bird-users mailing list (<HTMLURL URL="mailto:bird-users@network.cz" name="bird-users@network.cz">) where you can share your experiences with the other users and consult your problems with the authors. To subscribe to the list, visit <HTMLURL URL="http://bird.network.cz/?m_list" name="http://bird.network.cz/?m_list">. The home page of BIRD can be found at <HTMLURL URL="http://bird.network.cz/" name="http://bird.network.cz/">. <p>BIRD is a relatively young system and it probably contains some bugs. You can report any problems to the bird-users list and the authors will be glad to solve them, but before you do so, please make sure you have read the available documentation and that you are running the latest version (available at <HTMLURL URL="ftp://bird.network.cz/pub/bird" name="bird.network.cz:/pub/bird">). (Of course, a patch which fixes the bug is always welcome as an attachment.) <p>If you want to understand what is going inside, Internet standards are a good and interesting reading. You can get them from <HTMLURL URL="ftp://ftp.rfc-editor.org/" name="ftp.rfc-editor.org"> (or a nicely sorted version from <HTMLURL URL="ftp://atrey.karlin.mff.cuni.cz/pub/rfc" name="atrey.karlin.mff.cuni.cz:/pub/rfc">). <p><it/Good luck!/ </book> <!-- LocalWords: GPL IPv GateD BGPv RIPv OSPFv Linux sgml html dvi sgmltools Pavel LocalWords: linuxdoc dtd descrip config conf syslog stderr auth ospf bgp Mbps LocalWords: router's eval expr num birdc ctl UNIX if's enums bool int ip GCC LocalWords: len ipaddress pxlen netmask enum bgppath bgpmask clist gw md eth LocalWords: RTS printn quitbird iBGP AS'es eBGP RFC multiprotocol IGP Machek LocalWords: EGP misconfigurations keepalive pref aggr aggregator BIRD's RTC LocalWords: OS'es AS's multicast nolisten misconfigured UID blackhole MRTD MTU LocalWords: uninstalls ethernets IP binutils ANYCAST anycast dest RTD ICMP rfc LocalWords: compat multicasts nonbroadcast pointopoint loopback sym stats LocalWords: Perl SIGHUP dd mm yy HH MM SS EXT IA UNICAST multihop Discriminator txt LocalWords: proto wildcard Ondrej Filip --> �����������������������������������������������bird-2.0.8/doc/bird.conf.example2�������������������������������������������������������������������0000664�0001750�0001750�00000013466�14025744326�015446� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * This is an example configuration file for MP-BGP setting */ log "bird.log" all; # debug protocols all; router id 192.168.1.1; ipv4 table master4; ipv6 table master6; ipv4 table mcast4; ipv6 table mcast6; ipv4 table mtab4; ipv6 table mtab6; vpn4 table vpntab4; vpn6 table vpntab6; vpn4 table vpn4mc; vpn6 table vpn6mc; flow4 table flowtab4; flow6 table flowtab6; protocol device { } protocol kernel kernel4 { ipv4 { export all; }; } protocol kernel kernel6 { ipv6 { export all; }; } protocol static static4 { ipv4; route 10.10.0.0/24 via 192.168.1.2; route 10.10.1.0/24 via 192.168.1.2 { bgp_large_community.add((10,20,30)); bgp_large_community.add((10,(20*3),10)); }; } protocol static static6 { ipv6; route 2001:db8:10:10::/64 via 2001:db8:1:1::10; route 2001:db8:10:11::/64 via 2001:db8:1:1::10; route 2001:db8:1:1::/64 via fe80::ec9b:67ff:fe60:fd5d % ve1; } # VPNv4 routes with MPLS labels protocol static statvpn4 { vpn4; route 10:10 10.20.0.0/24 via 192.168.1.2 mpls 210; route 10:10 10.20.1.0/24 via 192.168.1.2 mpls 210; route 10:20 10.20.0.0/24 via 192.168.1.2 mpls 220; route 10:20 10.20.1.0/24 via 192.168.1.2 mpls 220; } protocol static statvpn6 { vpn6; route 10:10 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/210; route 10:10 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/210; route 10:20 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/220; route 10:20 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/220; } # RFC 5575 flow specification protocol static flowstat4 { flow4; route flow4 { dst 10.0.0.0/8; proto = 23; dport > 24 && < 30 || 40..50,60..70,80; sport > 24 && < 30 || = 40 || 50,60..70,80; icmp type 80; icmp code 90; tcp flags 0x03/0x0f; length 2048..65535; dscp = 63; fragment dont_fragment, is_fragment || !first_fragment; }; route flow4 { dst 11.0.0.0/8; proto = 0x12; sport > 0x5678 && < 0x9abc || 0xdef0 || 0x1234,0x5678,0x9abc..0xdef0; dport = 50; tcp flags 0x000/0xf00; }; route flow4 { dst 12.0.0.0/32; tcp flags ! 0/0x999; }; route flow4 { dst 220.0.254.0/24; tcp flags 0x99/0x999; }; route flow4 { dst 220.0.254.192/28; tcp flags ! 0xfff/0xfff; }; route flow4 { dst 15.0.0.0/8; tcp flags ! 0x999/0x999; }; } protocol static flowstat6 { flow6; route flow6 { dst fec0:1122:3344:5566::1/128; src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63; next header = 23; sport 24..30, 42 || 50,60,70..80; dport = 50; tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33; fragment !is_fragment || !first_fragment; label 0xaaaa/0xaaaa && 0x33/0x33; }; route flow6 { dst fec0:1122:3344:5566::1/128; src ::1:1234:5678:9800:0/101 offset 63; next header = 23; dport = 50; sport > 24 && < 30 || = 40 || = 50 || = 60 || >= 70 && <= 80; tcp flags 0x3/0x3 && 0x0/0xc; }; } protocol pipe { table master4; peer table mcast4; import none; export where source = RTS_OSPF; } protocol pipe { table master6; peer table mcast6; import none; export where source = RTS_OSPF; } protocol ospf v2 ospf4 { ipv4 { import all; # export where source = RTS_STATIC; }; area 0 { interface "ve0" { stub; }; interface "ve1" { hello 5; type ptp; }; interface "ve2" { hello 5; type bcast; ttl security; }; interface "ve3" { hello 5; type bcast; ttl security; }; }; } protocol ospf v3 ospf6 { ipv6 { import all; # export where source = RTS_STATIC; }; area 0 { interface "ve0" { stub; }; interface "ve1" { hello 5; type ptp; }; interface "ve2" { hello 5; type bcast; }; }; } protocol bgp { local 192.168.11.1 as 1000; neighbor 192.168.11.2 as 2000; # local 192.168.1.1 as 1000; # neighbor 192.168.2.1 as 2000; # multihop; # rr client; # strict bind; # debug all; # regular IPv4 unicast (1/1) ipv4 { # connects to master4 table by default import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; }; # regular IPv6 unicast (2/1) ipv6 { # connects to master6 table by default import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; # next hop address 2001:db8:1:1::1; }; # IPv4 multicast topology (1/2) ipv4 multicast { # explicit IPv4 table table mcast4; import all; export all; }; # IPv6 multicast topology (2/2) ipv6 multicast { # explicit IPv6 table table mcast6; import all; export all; # next hop address 2001:db8:1:1::1; }; # IPv4 with MPLS labels (1/4) ipv4 mpls { # explicit IPv4 table table mtab4; import all; export all; }; # IPv6 with MPLS labels (2/4) ipv6 mpls { # explicit IPv6 table table mtab6; import all; export all; # allows IPv4 next hops (6PE) # extended next hop; }; # VPNv4 with MPLS labels (1/128) vpn4 mpls { # connects to vpntab4 table by default import all; export all; }; # VPNv6 with MPLS labels (2/128) vpn6 mpls { # connects to vpntab6 table by default import all; export all; }; # VPNv4 multicast topology (1/129) vpn4 multicast { table vpn4mc; import all; export all; }; # VPNv6 multicast topology (2/129) vpn6 multicast { table vpn6mc; import all; export all; }; # IPv4 Flowspec (1/133) flow4 { # connects to flowtab4 table by default import all; export all; }; # IPv6 Flowspec (2/133) flow6 { # connects to flowtab6 table by default import all; export all; }; } protocol bgp { local 192.168.1.1 as 1000; neighbor 192.168.3.1 as 1000; multihop; rr client; ipv4 { import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; }; ipv6 { import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; next hop address 2001:db8:1:1::1; }; } protocol bgp { local 2001:db8:1:1::1 as 1000; neighbor 2001:db8:4:1::1 as 1000; multihop; rr client; ipv4 { import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; next hop address 192.168.4.1; }; ipv6 { import all; export where source ~ [ RTS_STATIC, RTS_BGP ]; }; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/doc/bird.conf.example��������������������������������������������������������������������0000664�0001750�0001750�00000014021�14025744326�015350� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This is a basic configuration file, which contains boilerplate options and # some basic examples. It allows the BIRD daemon to start but will not cause # anything else to happen. # # Please refer to the BIRD User's Guide documentation, which is also available # online at http://bird.network.cz/ in HTML format, for more information on # configuring BIRD and adding routing protocols. # Configure logging log syslog all; # log "/var/log/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug }; # Set router ID. It is a unique identification of your router, usually one of # IPv4 addresses of the router. It is recommended to configure it explicitly. # router id 198.51.100.1; # Turn on global debugging of all protocols (all messages or just selected classes) # debug protocols all; # debug protocols { events, states }; # Turn on internal watchdog # watchdog warning 5 s; # watchdog timeout 30 s; # You can define your own constants # define my_asn = 65000; # define my_addr = 198.51.100.1; # Tables master4 and master6 are defined by default # ipv4 table master4; # ipv6 table master6; # Define more tables, e.g. for policy routing or as MRIB # ipv4 table mrib4; # ipv6 table mrib6; # The Device protocol is not a real routing protocol. It does not generate any # routes and it only serves as a module for getting information about network # interfaces from the kernel. It is necessary in almost any configuration. protocol device { } # The direct protocol is not a real routing protocol. It automatically generates # direct routes to all network interfaces. Can exist in as many instances as you # wish if you want to populate multiple routing tables with direct routes. protocol direct { disabled; # Disable by default ipv4; # Connect to default IPv4 table ipv6; # ... and to default IPv6 table } # The Kernel protocol is not a real routing protocol. Instead of communicating # with other routers in the network, it performs synchronization of BIRD # routing tables with the OS kernel. One instance per table. protocol kernel { ipv4 { # Connect protocol to IPv4 table by channel # table master4; # Default IPv4 table is master4 # import all; # Import to table, default is import all export all; # Export to protocol. default is export none }; # learn; # Learn alien routes from the kernel # kernel table 10; # Kernel table to synchronize with (default: main) } # Another instance for IPv6, skipping default options protocol kernel { ipv6 { export all; }; } # Static routes (Again, there can be multiple instances, for different address # families and to disable/enable various groups of static routes on the fly). protocol static { ipv4; # Again, IPv4 channel with default options # route 0.0.0.0/0 via 198.51.100.10; # route 192.0.2.0/24 blackhole; # route 10.0.0.0/8 unreachable; # route 10.2.0.0/24 via "eth0"; # # Static routes can be defined with optional attributes # route 10.1.1.0/24 via 198.51.100.3 { rip_metric = 3; }; # route 10.1.2.0/24 via 198.51.100.3 { ospf_metric1 = 100; }; # route 10.1.3.0/24 via 198.51.100.4 { ospf_metric2 = 100; }; } # Pipe protocol connects two routing tables. Beware of loops. # protocol pipe { # table master4; # No ipv4/ipv6 channel definition like in other protocols # peer table mrib4; # import all; # Direction peer table -> table # export all; # Direction table -> peer table # } # RIP example, both RIP and RIPng are supported # protocol rip { # ipv4 { # # Export direct, static routes and ones from RIP itself # import all; # export where source ~ [ RTS_DEVICE, RTS_STATIC, RTS_RIP ]; # }; # interface "eth*" { # update time 10; # Default period is 30 # timeout time 60; # Default timeout is 180 # authentication cryptographic; # No authentication by default # password "hello" { algorithm hmac sha256; }; # Default is MD5 # }; # } # OSPF example, both OSPFv2 and OSPFv3 are supported # protocol ospf v3 { # ipv6 { # import all; # export where source = RTS_STATIC; # }; # area 0 { # interface "eth*" { # type broadcast; # Detected by default # cost 10; # Interface metric # hello 5; # Default hello perid 10 is too long # }; # interface "tun*" { # type ptp; # PtP mode, avoids DR selection # cost 100; # Interface metric # hello 5; # Default hello perid 10 is too long # }; # interface "dummy0" { # stub; # Stub interface, just propagate it # }; # }; #} # Define simple filter as an example for BGP import filter # See https://gitlab.labs.nic.cz/labs/bird/wikis/BGP_filtering for more examples # filter rt_import # { # if bgp_path.first != 64496 then accept; # if bgp_path.len > 64 then accept; # if bgp_next_hop != from then accept; # reject; # } # BGP example, explicit name 'uplink1' is used instead of default 'bgp1' # protocol bgp uplink1 { # description "My BGP uplink"; # local 198.51.100.1 as 65000; # neighbor 198.51.100.10 as 64496; # hold time 90; # Default is 240 # password "secret"; # Password used for MD5 authentication # # ipv4 { # regular IPv4 unicast (1/1) # import filter rt_import; # export where source ~ [ RTS_STATIC, RTS_BGP ]; # }; # # ipv6 { # regular IPv6 unicast (2/1) # import filter rt_import; # export filter { # The same as 'where' expression above # if source ~ [ RTS_STATIC, RTS_BGP ] # then accept; # else reject; # }; # }; # # ipv4 multicast { # IPv4 multicast topology (1/2) # table mrib4; # explicit IPv4 table # import filter rt_import; # export all; # }; # # ipv6 multicast { # IPv6 multicast topology (2/2) # table mrib6; # explicit IPv6 table # import filter rt_import; # export all; # }; #} # Template example. Using templates to define IBGP route reflector clients. # template bgp rr_clients { # local 10.0.0.1 as 65000; # neighbor as 65000; # rr client; # rr cluster id 1.0.0.1; # # ipv4 { # import all; # export where source = RTS_BGP; # }; # # ipv6 { # import all; # export where source = RTS_BGP; # }; # } # # protocol bgp client1 from rr_clients { # neighbor 10.0.1.1; # } # # protocol bgp client2 from rr_clients { # neighbor 10.0.2.1; # } # # protocol bgp client3 from rr_clients { # neighbor 10.0.3.1; # } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/doc/Makefile�����������������������������������������������������������������������������0000664�0001750�0001750�00000002460�14025744326�013573� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Force rebuilds .PHONY: progspell docs progdocs userdocs doc-srcdir := $(shell cd $(s) && pwd) sgml2 := $(doc-srcdir)/sgml2 docs: progdocs userdocs doc-fmt = $(1): $(o)prog.$(1) $(o)bird.$(1) $(call doc-fmt,html) $(call doc-fmt,dvi) $(call doc-fmt,ps) $(call doc-fmt,pdf) progdocs: $(o)prog.html $(o)prog.pdf userdocs: $(o)bird.html $(o)bird.pdf progspell: $(o)prog.spell $(o)prog.sgml: $(srcdir)/tools/progdoc $(objdir)/.dir-stamp $(srcdir)/tools/progdoc $(srcdir) $@ $(o)%.sgml: $(s)%.sgml $(objdir)/.dir-stamp cp $< $@ $(o)%.html: $(o)%.sgml cd $(dir $@) && $(sgml2)html $(notdir $<) $(o)%.tex: $(o)%.sgml cd $(dir $@) && $(sgml2)latex --output=tex $(notdir $<) $(o)%.dvi: $(o)%.tex cd $(dir $@) && TEXINPUTS=$(TEXINPUTS):$(doc-srcdir)/tex latex $(notdir $<) cd $(dir $@) && TEXINPUTS=$(TEXINPUTS):$(doc-srcdir)/tex latex $(notdir $<) $(o)%.ps: $(o)%.dvi dvips -D600 -ta4 -o $@ $< $(o)%.pdf: $(o)%.tex TEXINPUTS=$(TEXINPUTS):$(doc-srcdir)/tex pdflatex -output-directory=$(dir $@) $< TEXINPUTS=$(TEXINPUTS):$(doc-srcdir)/tex pdflatex -output-directory=$(dir $@) $< $(o)%.txt: $(o)%.sgml cd $(dir $@) && $(sgml2)txt $(notdir $<) $(o)prog.spell: $(o)prog.sgml $(s)prog-spell.sed sed -f $(lastword $^) <$< >$@ ispell $@ $(call clean,prog.spell $(addprefix *.,html dvi ps pdf sgml tex txt aux log toc)) ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/doc/LinuxDocTools.pm���������������������������������������������������������������������0000664�0001750�0001750�00000040522�14025744326�015240� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /usr/bin/perl # # LinuxDocTools.pm # # $Id$ # # LinuxDoc-Tools driver core. This contains all the basic functionality # we need to control all other components. # # © Copyright 1996, Cees de Groot. # © Copyright 2000, Taketoshi Sano # # THIS VERSION HAS BEEN HACKED FOR BIRD BY MARTIN MARES # package LinuxDocTools; require 5.004; use strict; =head1 NAME LinuxDocTools - SGML conversion utilities for LinuxDoc DTD. =head1 SYNOPSIS use LinuxDocTools; LinuxDocTools::init; @files = LinuxDocTools::process_options ($0, @ARGV); for $curfile (@files) { LinuxDocTools::process_file ($curfile); } =head1 DESCRIPTION The LinuxDocTools package encapsulates all the functionality offered by LinuxDoc-Tools. It is used, of course, by LinuxDoc-Tools; but the encapsulation should provide for a simple interface for other users as well. =head1 FUNCTIONS =over 4 =cut use DirHandle; use File::Basename; use File::Find; use File::Copy; use FileHandle; use IPC::Open2; use Cwd; use LinuxDocTools::Lang; use LinuxDocTools::Utils qw(process_options usage cleanup trap_signals remove_tmpfiles create_temp); use LinuxDocTools::Vars; sub BEGIN { # # Make sure we're always looking here. Note that "use lib" adds # on the front of the search path, so we first push dist, then # site, so that site is searched first. # use lib "$main::DataDir/dist"; use lib "$main::DataDir/site"; } =item LinuxDocTools::init Takes care of initialization of package-global variables (which are actually defined in L<LinuxDocTools::Vars>). The package-global variables are I<$global>, a reference to a hash containing numerous settings, I<%Formats>, a hash containing all the formats, and I<%FmtList>, a hash containing the currently active formats for help texts. Apart from this, C<LinuxDocTools::init> also finds all distributed and site-local formatting backends and C<require>s them. =cut sub init { trap_signals; # # Register the ``global'' pseudoformat. Apart from the global settings, # we also use $global to keep the global variable name space clean; # everything that we need to provide to other modules is stuffed # into $global. # $global = {}; $global->{NAME} = "global"; $global->{HELP} = ""; $global->{OPTIONS} = [ { option => "backend", type => "l", 'values' => [ "html", "info", "latex", "lyx", "rtf", "txt", "check" ], short => "B" }, { option => "papersize", type => "l", 'values' => [ "a4", "letter" ], short => "p" }, { option => "language", type => "l", 'values' => [ @LinuxDocTools::Lang::Languages ], short => "l" }, { option => "charset", type => "l", 'values' => [ "latin", "ascii", "nippon", "euc-kr" ], short => "c" }, { option => "style", type => "s", short => "S" }, { option => "tabsize", type => "i", short => "t" }, # { option => "verbose", type => "f", short => "v" }, { option => "debug", type => "f", short => "d" }, { option => "define", type => "s", short => "D" }, { option => "include", type => "s", short => "i" }, { option => "pass", type => "s", short => "P" } ]; $global->{backend} = "linuxdoc"; $global->{papersize} = "a4"; $global->{language} = "en"; $global->{charset} = "ascii"; $global->{style} = ""; $global->{tabsize} = 8; $global->{verbose} = 0; $global->{define} = ""; $global->{debug} = 0; $global->{include} = ""; $global->{pass} = ""; $global->{InFiles} = []; $Formats{$global->{NAME}} = $global; # All formats we know. $FmtList{$global->{NAME}} = $global; # List of formats for help msgs. # automatic language detection: disabled by default # { # my $lang; # foreach $lang (@LinuxDocTools::Lang::Languages) # { # if (($ENV{"LC_ALL"} =~ /^$lang/i) || # ($ENV{"LC_CTYPE"} =~ /^$lang/i) || # ($ENV{"LANG"} =~ /^$lang/i)) { # $global->{language} = Any2ISO($lang); # } # } # } # # Used when the format is "global" (from sgmlcheck). # $global->{preNSGMLS} = sub { $global->{NsgmlsOpts} .= " -s "; $global->{NsgmlsPrePipe} = "cat $global->{file}"; }; # # Build up the list of formatters. # my $savdir = cwd; my %Locs; chdir "$main::DataDir/dist"; my $dir = new DirHandle("."); die "Unable to read directory $main::DataDir/dist: $!" unless defined($dir); foreach my $fmt (grep(/^fmt_.*\.pl$/, $dir->read())) { $Locs{$fmt} = "dist"; } $dir->close(); chdir "$main::DataDir/site"; $dir = new DirHandle("."); die "Unable to read directory $main::DataDir/site: $!" unless defined($dir); foreach my $fmt (grep(/^fmt_.*\.pl$/, $dir->read())) { $Locs{$fmt} = "site"; } $dir->close(); foreach my $fmt (keys %Locs) { require $fmt; } chdir $savdir; } =item LinuxDocTools::process_options ($0, @ARGV) This function contains all initialization that is bound to the current invocation of LinuxDocTools. It looks in C<$0> to deduce the backend that should be used (ld2txt activates the I<txt> backend) and parses the options array. It returns an array of filenames it encountered during option processing. As a side effect, the environment variables I<SGMLDECL> and I<SGML_CATALOG_FILES> are modified. =cut sub process_options { my $progname = shift; my @args = @_; # # Deduce the format from the caller's file name # my ($format, $dummy1, $dummy2) = fileparse ($progname, ""); $global->{myname} = $format; $format =~ s/sgml2*(.*)/$1/; # # check the option "--backend / -B" # if ($format eq "linuxdoc") { my @backends = @args; my $arg; while (@backends) { $arg = shift @backends; if ($arg eq "-B") { $arg = shift @backends; $format = $arg; last; } if ( $arg =~ s/--backend=(.*)/$1/ ) { $format = $arg; last; } } } $format = "global" if $format eq "check"; usage ("") if $format eq "linuxdoc"; $format = "latex2e" if $format eq "latex"; $FmtList{$format} = $Formats{$format} or usage ("$global->{myname}: unknown format"); $global->{format} = $format; # # Parse all the options. # my @files = LinuxDocTools::Utils::process_options (@args); $global->{language} = Any2ISO ($global->{language}); # # check the number of given files $#files > -1 || usage ("no filenames given"); # # Setup the SGML environment. # (Note that Debian package rewrite path to catalog of # iso-entities using debian/rules so that it can use # entities from sgml-data pacakge. debian/rules also # removes iso-entites sub directory after doing make install.) # $ENV{SGML_CATALOG_FILES} .= (defined $ENV{SGML_CATALOG_FILES} ? ":" : "") . "$main::prefix/share/sgml/sgml-iso-entities-8879.1986/catalog:" . "$main::prefix/share/sgml/entities/sgml-iso-entities-8879.1986/catalog"; $ENV{SGML_CATALOG_FILES} .= ":$main::DataDir/linuxdoc-tools.catalog"; $ENV{SGML_CATALOG_FILES} .= ":$main::/etc/sgml.catalog"; if (-f "$main::DataDir/dtd/$format.dcl") { $ENV{SGMLDECL} = "$main::DataDir/dtd/$format.dcl"; } elsif (-f "$main::DataDir/dtd/$global->{style}.dcl") { $ENV{SGMLDECL} = "$main::DataDir/dtd/$global->{style}.dcl"; } elsif (-f "$main::DataDir/dtd/sgml.dcl") { $ENV{SGMLDECL} = "$main::DataDir/dtd/sgml.dcl"; } # # OK. Give the list of files we distilled from the options # back to the caller. # return @files; } =item LinuxDocTools::process_file With all the configuration done, this routine will take a single filename and convert it to the currently active backend format. The conversion is done in a number of steps in tight interaction with the currently active backend (see also L<LinuxDocTools::BackEnd>): =over =item 1. Backend: set NSGMLS options and optionally create a pre-NSGMLS pipe. =item 2. Here: Run the preprocessor to handle conditionals. =item 3. Here: Run NSGMLS. =item 4. Backend: run pre-ASP conversion. =item 5. Here: Run SGMLSASP. =item 6. Backend: run post-ASP conversion, generating the output. =back All stages are influenced by command-line settings, currently active format, etcetera. See the code for details. =cut sub process_file { my $file = shift (@_); my $saved_umask = umask; print "Processing file $file\n"; umask 0077; my ($filename, $filepath, $filesuffix) = fileparse ($file, "\.sgml"); my $tmpnam = $filepath . '/' . $filename; $file = $tmpnam . $filesuffix; -f $file || $file =~ /.*.sgml$/ || ($file .= '.sgml'); -f $file || ($file = $tmpnam . '.SGML'); -f $file || die "Cannot find $file\n"; $global->{filename} = $filename; $global->{file} = $file; $global->{filepath} = $filepath; my $tmp = new FileHandle "<$file"; my $dtd; while ( <$tmp> ) { tr/A-Z/a-z/; # check for [<!doctype ... system] type definition if ( /<!doctype\s*(\w*)\s*system/ ) { $dtd = $1; last; } # check for <!doctype ... PUBLIC ... DTD ... if ( /<!doctype\s*\w*\s*public\s*.*\/\/dtd\s*(\w*)/mi ) { $dtd = $1; last; } # check for <!doctype ... # PUBLIC ... DTD ... # (multi-line version) if ( /<!doctype\s*(\w*)/ ) { $dtd = "precheck"; next; } if ( /\s*public\s*.*\/\/dtd\s*(\w*)/ && $dtd eq "precheck" ) { $dtd = $1; last; } } $tmp->close; if ( $global->{debug} ) { print "DTD: " . $dtd . "\n"; } $global->{dtd} = $dtd; # prepare temporary directory my $tmpdir = $ENV{'TMPDIR'} || '/tmp'; $tmpdir = $tmpdir . '/' . 'linuxdoc-dir-' . $$; mkdir ($tmpdir, 0700) || die " - temporary files can not be created, aborted - \n"; my $tmpbase = $global->{tmpbase} = $tmpdir . '/sgmltmp.' . $filename; $ENV{"SGML_SEARCH_PATH"} .= ":$filepath"; # # Set up the preprocessing command. Conditionals have to be # handled here until they can be moved into the DTD, otherwise # a validating SGML parser will choke on them. # # check if output option for latex is pdf or not if ($global->{format} eq "latex2e") { if ($Formats{$global->{format}}{output} eq "pdf") { $global->{define} .= " pdflatex=yes"; } } # local $ENV{PATH} = "$ENV{PATH}:/usr/lib/linuxdoc-tools"; my($precmd) = "|sgmlpre output=$global->{format} $global->{define}"; # # You can hack $NsgmlsOpts here, etcetera. # $global->{NsgmlsOpts} .= "-D $main::prefix/share/sgml -D $main::DataDir"; $global->{NsgmlsOpts} .= "-i$global->{include}" if ($global->{include}); $global->{NsgmlsPrePipe} = "NOTHING"; if ( defined $Formats{$global->{format}}{preNSGMLS} ) { $global->{NsgmlsPrePipe} = &{$Formats{$global->{format}}{preNSGMLS}}; } # # Run the prepocessor and nsgmls. # my ($ifile, $writensgmls); if ($global->{NsgmlsPrePipe} eq "NOTHING") { $ifile = new FileHandle $file; } else { $ifile = new FileHandle "$global->{NsgmlsPrePipe}|"; } create_temp("$tmpbase.1"); $writensgmls = new FileHandle "$precmd|$main::progs->{NSGMLS} $global->{NsgmlsOpts} $ENV{SGMLDECL} >\"$tmpbase.1\""; if ($global->{charset} eq "latin") { while (<$ifile>) { # Outline these commands later on - CdG #change latin1 characters to SGML #by Farzad Farid, adapted by Greg Hankins s/À/\À/g; s/Á/\Á/g; s/Â/\Â/g; s/Ã/\Ã/g; s/Ä/\Ä/g; s/Å/\Å/g; s/Æ/\Æ/g; s/Ç/\Ç/g; s/È/\È/g; s/É/\É/g; s/Ê/\Ê/g; s/Ë/\Ë/g; s/Ì/\Ì/g; s/Í/\Í/g; s/Î/\Î/g; s/Ï/\Ï/g; s/Ñ/\Ñ/g; s/Ò/\Ò/g; s/Ó/\Ó/g; s/Ô/\Ô/g; s/Õ/\Õ/g; s/Ö/\Ö/g; s/Ø/\Ø/g; s/Ù/\Ù/g; s/Ú/\Ú/g; s/Û/\Û/g; s/Ü/\Ü/g; s/Ý/\Ý/g; s/Þ/\Þ/g; s/ß/\ß/g; s/à/\à/g; s/á/\á/g; s/â/\â/g; s/ã/\ã/g; s/ä/\ä/g; s/å/\å/g; s/æ/\æ/g; s/ç/\ç/g; s/è/\è/g; s/é/\é/g; s/ê/\ê/g; s/ë/\ë/g; s/ì/\ì/g; s/í/\í/g; s/î/\î/g; s/ï/\ï/g; s/µ/\μ/g; s/ð/\ð/g; s/ñ/\ñ/g; s/ò/\ò/g; s/ó/\ó/g; s/ô/\ô/g; s/õ/\õ/g; s/ö/\ö/g; s/ø/\ø/g; s/ù/\ù/g; s/ú/\ú/g; s/û/\û/g; s/ü/\ü/g; s/ý/\ý/g; s/þ/\þ/g; s/ÿ/\ÿ/g; print $writensgmls $_; } } else { while (<$ifile>) { print $writensgmls $_; } } $ifile->close; $writensgmls->close; # # Special case: if format is global, we're just checking. # $global->{format} eq "global" && cleanup; # # If the output file is empty, something went wrong. # ! -e "$tmpbase.1" and die "can't create file - exiting"; -z "$tmpbase.1" and die "SGML parsing error - exiting"; if ( $global->{debug} ) { print "Nsgmls stage finished.\n"; } # # If a preASP stage is defined, let the format handle it. # # preASP ($inhandle, $outhandle); # my $inpreasp = new FileHandle "<$tmpbase.1"; my $outpreasp = new FileHandle "$tmpbase.2",O_WRONLY|O_CREAT|O_EXCL,0600; if (defined $Formats{$global->{format}}{preASP}) { &{$Formats{$global->{format}}{preASP}}($inpreasp, $outpreasp) == 0 or die "error pre-processing $global->{format}.\n"; } else { copy ($inpreasp, $outpreasp); } $inpreasp->close; $outpreasp->close; ! -e "$tmpbase.2" and die "can't create file - exiting"; if ( $global->{debug} ) { print "PreASP stage finished.\n"; } # # Run sgmlsasp, with an optional style if specified. # # Search order: # - datadir/site/<dtd>/<format> # - datadir/dist/<dtd>/<format> # So we need to fetch the doctype from the intermediate. # # Note: this is a very simplistic check - but as far as I know, # it is correct. Am I right? # my $tmp = new FileHandle "<$tmpbase.2"; my $dtd; while ( ($dtd = <$tmp>) && ! ( $dtd =~ /^\(/) ) { }; $tmp->close; $dtd =~ s/^\(//; $dtd =~ tr/A-Z/a-z/; chop $dtd; $global->{dtd} = $dtd; my $style = ""; if ($global->{style}) { $style = "$main::DataDir/site/$dtd/$global->{format}/$global->{style}mapping"; -r $style or $style = "$main::DataDir/dist/$dtd/$global->{format}/$global->{style}mapping"; } my $mapping = "$main::DataDir/site/$dtd/$global->{format}/mapping"; -r $mapping or $mapping = "$main::DataDir/dist/$dtd/$global->{format}/mapping"; $global->{charset} = "nippon" if ($global->{language} eq "ja"); # # we don't have Korean groff so charset should be latin1. # if ($global->{language} eq "ko") { if ($global->{format} eq "groff") { $global->{charset} = "latin1"; } else { $global->{charset} = "euc-kr"; } } if ($global->{format} eq "groff" or $global->{format} eq "latex2e") { if ($dtd eq "linuxdoctr") { $mapping = "$main::DataDir/dist/$dtd/$global->{format}/tr-mapping"; } } create_temp("$tmpbase.3"); system ("$main::progs->{SGMLSASP} $style $mapping <\"$tmpbase.2\" | expand -$global->{tabsize} >\"$tmpbase.3\""); ! -e "$tmpbase.3" and die "can't create file - exiting"; if ( $global->{debug} ) { print "ASP stage finished.\n"; } # # If a postASP stage is defined, let the format handle it. # It should leave whatever it thinks is right based on $file. # # postASP ($inhandle) # umask $saved_umask; my $inpostasp = new FileHandle "<$tmpbase.3"; if (defined $Formats{$global->{format}}{postASP}) { &{$Formats{$global->{format}}{postASP}}($inpostasp) == 0 or die "error post-processing $global->{format}.\n"; } $inpostasp->close; if ( $global->{debug} ) { print "postASP stage finished.\n"; } # # All done, remove the temporaries. # if( !$global->{debug} ) { remove_tmpfiles($tmpbase); } } =pod =back =head1 SEE ALSO Documentation for various sub-packages of LinuxDocTools. =head1 AUTHOR SGMLTools are written by Cees de Groot, C<E<lt>cg@cdegroot.comE<gt>>, and various SGML-Tools contributors as listed in C<CONTRIBUTORS>. Taketoshi Sano C<E<lt>sano@debian.org<gt>> rename to LinuxDocTools. =cut 1; ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/configure.ac�����������������������������������������������������������������������������0000664�0001750�0001750�00000032144�14025744326�013656� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������dnl ** This is a configure script template for BIRD dnl ** Process it with autoconf to get ./configure dnl ** (c) 1999--2000 Martin Mares <mj@ucw.cz> AC_INIT AC_CONFIG_SRCDIR([conf/confbase.Y]) AC_CONFIG_AUX_DIR([tools]) AC_ARG_ENABLE([client], [AS_HELP_STRING([--enable-client], [enable building of BIRD client @<:@yes@:>@])], [], [enable_client=yes] ) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], [enable internal debugging routines @<:@no@:>@])], [], [enable_debug=no] ) AC_ARG_ENABLE([debug-generated], [AS_HELP_STRING([--enable-debug-generated], [enable this to abstain from generating #line @<:@no@:>@])], [], [enable_debug_generated=no] ) AC_ARG_ENABLE([debug-expensive], [AS_HELP_STRING([--enable-debug-expensive], [enable expensive consistency checks (implies --enable-debug) @<:@no@:>@])], [], [enable_debug_expensive=no] ) AC_ARG_ENABLE([memcheck], [AS_HELP_STRING([--enable-memcheck], [check memory allocations when debugging @<:@yes@:>@])], [], [enable_memcheck=yes] ) AC_ARG_ENABLE([pthreads], [AS_HELP_STRING([--enable-pthreads], [enable POSIX threads support @<:@try@:>@])], [], [enable_pthreads=try] ) AC_ARG_ENABLE([libssh], [AS_HELP_STRING([--enable-libssh], [enable LibSSH support in RPKI @<:@try@:>@])], [], [enable_libssh=try] ) AC_ARG_ENABLE([mpls-kernel], [AS_HELP_STRING([--enable-mpls-kernel], [enable MPLS support in kernel protocol @<:@try@:>@])], [], [enable_mpls_kernel=try] ) AC_ARG_WITH([protocols], [AS_HELP_STRING([--with-protocols=LIST], [include specified routing protocols @<:@all@:>@])], [], [with_protocols="all"] ) AC_ARG_WITH([sysconfig], [AS_HELP_STRING([--with-sysconfig=FILE], [use specified BIRD system configuration file])] ) AC_ARG_WITH([runtimedir], [AS_HELP_STRING([--with-runtimedir=PATH], [run-state data, obsolete variant of --runstatedir])], [runstatedir="$with_runtimedir"] ) AC_ARG_WITH([iproutedir], [AS_HELP_STRING([--with-iproutedir=PATH], [path to iproute2 config files @<:@/etc/iproute2@:>@])], [given_iproutedir="yes"] ) AC_ARG_VAR([FLEX], [location of the Flex program]) AC_ARG_VAR([BISON], [location of the Bison program]) AC_ARG_VAR([M4], [location of the M4 program]) if test "$enable_debug_expensive" = yes; then enable_debug=yes fi if test "$srcdir" = . ; then # Building in current directory => create obj directory holding all objects objdir=obj else # Building in separate directory objdir=. fi exedir=. AC_SUBST([objdir]) AC_SUBST([exedir]) AC_SUBST([srcdir]) # Workaround for older Autoconfs that do not define runstatedir AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run']) AC_SUBST([runstatedir]) CONFIG_FILE="\$(sysconfdir)/bird.conf" AC_SUBST([CONFIG_FILE]) CONTROL_SOCKET="\$(runstatedir)/bird.ctl" AC_SUBST([CONTROL_SOCKET]) AC_SEARCH_LIBS([clock_gettime], [rt posix4], [], [AC_MSG_ERROR([Function clock_gettime not available.])] ) AC_CANONICAL_HOST # Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC if test "$ac_test_CFLAGS" != set ; then bird_cflags_default=yes fi AC_PROG_CC AC_PROG_CC_C99 if test -z "$GCC" ; then AC_MSG_ERROR([This program requires the GNU C Compiler.]) fi BIRD_CHECK_THREAD_LOCAL if test "$bird_cv_thread_local" = yes ; then AC_DEFINE([HAVE_THREAD_LOCAL], [1], [Define to 1 if _Thread_local is available]) fi if test "$enable_pthreads" != no ; then BIRD_CHECK_PTHREADS if test "$bird_cv_lib_pthreads" = yes ; then AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled]) CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" proto_bfd=bfd elif test "$enable_pthreads" = yes ; then AC_MSG_ERROR([POSIX threads not available.]) fi if test "$enable_pthreads" = try ; then enable_pthreads="$bird_cv_lib_pthreads" fi fi # This is assumed to be necessary for proper BIRD build CFLAGS="$CFLAGS -fno-strict-aliasing -fno-strict-overflow" if test "$bird_cflags_default" = yes ; then BIRD_CHECK_GCC_OPTION([bird_cv_c_option_wno_pointer_sign], [-Wno-pointer-sign], [-Wall]) BIRD_CHECK_GCC_OPTION([bird_cv_c_option_wno_missing_init], [-Wno-missing-field-initializers], [-Wall -Wextra]) if test "$enable_debug" = no; then BIRD_CHECK_LTO fi if test "$bird_cv_c_lto" = yes; then CFLAGS="$CFLAGS -flto" LDFLAGS="$LDFLAGS -flto=4 -g" else LDFLAGS="$LDFLAGS -g" fi CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes -Wno-parentheses" BIRD_ADD_GCC_OPTION([bird_cv_c_option_wno_pointer_sign], [-Wno-pointer-sign]) BIRD_ADD_GCC_OPTION([bird_cv_c_option_wno_missing_init], [-Wno-missing-field-initializers]) fi AC_MSG_CHECKING([CFLAGS]) AC_MSG_RESULT([$CFLAGS]) AC_MSG_CHECKING([LDFLAGS]) AC_MSG_RESULT([$LDFLAGS]) AC_PROG_CPP AC_PROG_INSTALL AC_PROG_RANLIB AC_CHECK_PROG([FLEX], [flex], [flex]) AC_CHECK_PROG([BISON], [bison], [bison]) AC_CHECK_PROGS([M4], [gm4 m4]) test -z "$FLEX" && AC_MSG_ERROR([Flex is missing.]) test -z "$BISON" && AC_MSG_ERROR([Bison is missing.]) test -z "$M4" && AC_MSG_ERROR([M4 is missing.]) AC_MSG_CHECKING([bison version]) BIRD_CHECK_BISON_VERSION(BISON_VERSION) AC_MSG_RESULT([$BISON_VERSION]) if test "$bird_bison_synclines" = yes && test "$enable_debug_generated" = no; then M4FLAGS="$M4FLAGS -s" fi if test "$bird_bison_enhanced_error" = yes; then BISONFLAGS="$BISONFLAGS -Dparse.lac=full -Dparse.error=verbose" fi AC_SUBST([M4FLAGS]) AC_SUBST([BISONFLAGS]) BIRD_CHECK_PROG_FLAVOR_GNU([$M4], [], [AC_MSG_ERROR([Provided M4 is not GNU M4.])] ) if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then if test -f $with_sysconfig ; then sysdesc=$with_sysconfig else sysdesc=$srcdir/sysdep/cf/$with_sysconfig if ! test -f $sysdesc ; then sysdesc=$sysdesc.h fi fi elif test -f sysconfig.h ; then sysdesc=sysconfig else case "$host_os" in linux*) sysdesc=linux default_iproutedir="/etc/iproute2" ;; freebsd*) sysdesc=bsd CPPFLAGS="$CPPFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib" ;; kfreebsd*) sysdesc=bsd ;; netbsd*) sysdesc=bsd CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib" ;; openbsd*) sysdesc=bsd ;; dragonfly*) sysdesc=bsd ;; *) AC_MSG_ERROR([Cannot determine correct system configuration. Please use --with-sysconfig to set it manually.]) ;; esac sysdesc=$srcdir/sysdep/cf/$sysdesc.h fi AC_MSG_CHECKING([which OS configuration should we use]) AC_MSG_RESULT([$sysdesc]) if ! test -f $sysdesc ; then AC_MSG_ERROR([The system configuration file is missing.]) fi sysname=`echo $sysdesc | sed 's/\.h$//'` AC_DEFINE_UNQUOTED([SYSCONF_INCLUDE], ["$sysdesc"], [Which sysdep header to include]) AC_MSG_CHECKING([system-dependent directories]) sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`" AC_MSG_RESULT([$sysdep_dirs]) AC_SUBST([sysdep_dirs]) if test "$with_iproutedir" = no ; then with_iproutedir= ; fi if test -n "$given_iproutedir" then iproutedir=$with_iproutedir else iproutedir=$default_iproutedir fi AC_SUBST([iproutedir]) DAEMON_LIBS= AC_SUBST(DAEMON_LIBS) if test "$enable_libssh" != no ; then AC_CHECK_HEADER([libssh/libssh.h], [true], [fail=yes], [ ]) AC_CHECK_LIB([ssh], [ssh_connect], [true], [fail=yes]) if test "$fail" != yes ; then AC_DEFINE([HAVE_LIBSSH], [1], [Define to 1 if you have the `ssh' library (-lssh).]) DAEMON_LIBS="-lssh $DAEMON_LIBS" enable_libssh=yes else if test "$enable_libssh" = yes ; then AC_MSG_ERROR([LibSSH not available.]) else enable_libssh=no fi fi fi if test "$enable_mpls_kernel" != no ; then BIRD_CHECK_MPLS_KERNEL if test "$bird_cv_mpls_kernel" = yes ; then AC_DEFINE([HAVE_MPLS_KERNEL], [1], [Define to 1 if kernel is MPLS capable]) elif test "$enable_mpls_kernel" = yes ; then AC_MSG_ERROR([Kernel MPLS support not found.]) fi if test "$enable_mpls_kernel" = try ; then enable_mpls_kernel="$bird_cv_mpls_kernel" fi fi all_protocols="$proto_bfd babel bgp mrt ospf perf pipe radv rip rpki static" all_protocols=`echo $all_protocols | sed 's/ /,/g'` if test "$with_protocols" = all ; then with_protocols="$all_protocols" fi AH_TEMPLATE([CONFIG_BABEL], [Babel protocol]) AH_TEMPLATE([CONFIG_BFD], [BFD protocol]) AH_TEMPLATE([CONFIG_BGP], [BGP protocol]) AH_TEMPLATE([CONFIG_MRT], [MRT protocol]) AH_TEMPLATE([CONFIG_OSPF], [OSPF protocol]) AH_TEMPLATE([CONFIG_PIPE], [Pipe protocol]) AH_TEMPLATE([CONFIG_RADV], [RAdv protocol]) AH_TEMPLATE([CONFIG_RIP], [RIP protocol]) AH_TEMPLATE([CONFIG_RPKI], [RPKI protocol]) AH_TEMPLATE([CONFIG_STATIC], [Static protocol]) AC_MSG_CHECKING([protocols]) protocols=`echo "$with_protocols" | sed 's/,/ /g'` if test "$protocols" = no ; then protocols= ; fi for a in $protocols ; do if ! test -f $srcdir/proto/$a/Makefile ; then AC_MSG_RESULT([failed]) AC_MSG_ERROR([Requested protocol $a not found]) fi AC_DEFINE_UNQUOTED([CONFIG_`echo $a | tr 'a-z' 'A-Z'`]) done AC_MSG_RESULT([ok]) AC_SUBST([protocols]) case $sysdesc in */linux*) AC_CHECK_HEADER([linux/rtnetlink.h], [], [AC_MSG_ERROR([Appropriate version of Linux kernel headers not found.])], [ dnl Some older versions of Linux kernel headers require these includes #include <asm/types.h> #include <sys/socket.h> ] ) ;; esac AC_CHECK_HEADERS_ONCE([alloca.h syslog.h]) AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>]) AC_C_BIGENDIAN( [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])], [AC_DEFINE([CPU_LITTLE_ENDIAN], [1], [Define to 1 if cpu is little endian])], [AC_MSG_ERROR([Cannot determine CPU endianity.])] ) BIRD_CHECK_ANDROID_GLOB if test "$bird_cv_lib_glob" = no ; then AC_MSG_ERROR([glob.h not found.]) elif test "$bird_cv_lib_glob" != yes ; then LIBS="$LIBS $bird_cv_lib_glob" fi BIRD_CHECK_ANDROID_LOG if test "$bird_cv_lib_log" = no ; then AC_MSG_ERROR([don't know how to link syslog.]) elif test "$bird_cv_lib_log" != yes ; then LIBS="$LIBS $bird_cv_lib_log" fi if test "$enable_debug" = yes ; then AC_DEFINE([DEBUGGING], [1], [Define to 1 if debugging is enabled]) LDFLAGS="$LDFLAGS -rdynamic" CFLAGS="$CFLAGS -O0 -ggdb -g3" BIRD_CHECK_GCC_OPTION([bird_cv_c_option_dwarf4], [-gdwarf-4], []) BIRD_ADD_GCC_OPTION([bird_cv_c_option_dwarf4], [-gdwarf-4]) AC_CHECK_HEADER([execinfo.h], [ AC_DEFINE([HAVE_EXECINFO_H], [1], [Define to 1 if you have the <execinfo.h> header file.]) AC_SEARCH_LIBS([backtrace], [execinfo], [], [AC_MSG_ERROR([Function backtrace not available.])] ) ] ) if test "$enable_memcheck" = yes ; then AC_CHECK_LIB([dmalloc], [dmalloc_debug]) if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then AC_CHECK_LIB([efence], [malloc]) fi fi if test "enable_debug_expensive" = yes ; then AC_DEFINE([ENABLE_EXPENSIVE_CHECKS], [1], [Define to 1 if you want to run expensive consistency checks.]) fi fi CLIENT=birdcl CLIENT_LIBS= if test "$enable_client" = yes ; then CLIENT="$CLIENT birdc" BASE_LIBS="$LIBS" LIBS="" AC_CHECK_HEADERS([curses.h], [], [AC_MSG_ERROR([The client requires ncurses library. Either install the library or use --disable-client to compile without the client.])], [AC_INCLUDES_DEFAULT] ) AC_SEARCH_LIBS([tgetent], [tinfo tinfow ncurses curses termcap], [TINFO_LIBS="$LIBS"; LIBS=""], [AC_MSG_ERROR([The client requires ncurses library. Either install the library or use --disable-client to compile without the client.])], ) AC_CHECK_HEADERS([readline/readline.h readline/history.h], [], [AC_MSG_ERROR([The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client.])], [AC_INCLUDES_DEFAULT] ) AC_SEARCH_LIBS([rl_callback_read_char], [readline], [READLINE_LIBS="$LIBS"; LIBS=""], [AC_MSG_ERROR([The client requires GNU Readline library. Either install the library or use --disable-client to compile without the client.])], [$TINFO_LIBS] ) AC_CHECK_LIB([readline], [rl_crlf], [AC_DEFINE([HAVE_RL_CRLF], [1], [Define to 1 if you have rl_crlf()])], [], [$TINFO_LIBS] ) AC_CHECK_LIB([readline], [rl_ding], [AC_DEFINE([HAVE_RL_DING], [1], [Define to 1 if you have rl_ding()])], [], [$TINFO_LIBS] ) LIBS="$BASE_LIBS" CLIENT_LIBS="$READLINE_LIBS $TINFO_LIBS" fi AC_SUBST([CLIENT]) AC_SUBST([CLIENT_LIBS]) mkdir -p $objdir/sysdep AC_CONFIG_HEADERS([$objdir/sysdep/autoconf.h:sysdep/autoconf.h.in]) AC_CONFIG_FILES([Makefile:Makefile.in]) AC_OUTPUT AC_MSG_RESULT() AC_MSG_RESULT([BIRD was configured with the following options:]) AC_MSG_RESULT([ Source directory: $srcdir]) AC_MSG_RESULT([ Object directory: $objdir]) AC_MSG_RESULT([ Iproute2 directory: $iproutedir]) AC_MSG_RESULT([ System configuration: $sysdesc]) AC_MSG_RESULT([ Debugging: $enable_debug]) AC_MSG_RESULT([ POSIX threads: $enable_pthreads]) AC_MSG_RESULT([ Routing protocols: $protocols]) AC_MSG_RESULT([ LibSSH support in RPKI: $enable_libssh]) AC_MSG_RESULT([ Kernel MPLS support: $enable_mpls_kernel]) AC_MSG_RESULT([ Client: $enable_client]) rm -f $objdir/.*-stamp ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/������������������������������������������������������������������������������������0000775�0001750�0001750�00000000000�14025744326�012311� 5����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/gen_parser.m4�����������������������������������������������������������������������0000664�0001750�0001750�00000003443�14025744326�014704� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������m4_divert(-1)m4_dnl # # BIRD -- Generator of Configuration Grammar # # (c) 1998--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz> # # Can be freely distributed and used under the terms of the GNU GPL. # # Diversions used: # 1 includes # 2 types etc. # 3 rules # 4 C code # Common aliases m4_define(DNL, `m4_dnl') # Define macros for defining sections m4_define(CF_ZONE, `m4_divert($1)/* $2 from m4___file__ */') m4_define(CF_HDR, `CF_ZONE(1, Headers)') m4_define(CF_DEFINES, `CF_ZONE(1, Defines)') m4_define(CF_DECLS, `CF_ZONE(2, Declarations)') m4_define(CF_GRAMMAR, `CF_ZONE(3, Grammar)') m4_define(CF_CODE, `CF_ZONE(4, C Code)') m4_define(CF_END, `m4_divert(-1)') # Simple iterator m4_define(CF_itera, `m4_ifelse($#, 1, [[CF_iter($1)]], [[CF_iter($1)[[]]CF_itera(m4_shift($@))]])') m4_define(CF_iterate, `m4_define([[CF_iter]], m4_defn([[$1]]))CF_itera($2)') # Keywords act as untyped %token m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)m4_define([[CF_toks]],CF_toks $1)]])') m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@]])m4_ifelse(CF_toks,,,%token[[]]CF_toks )DNL') # CLI commands m4_define(CF_CLI, `m4_define([[CF_cmd]], cmd_[[]]m4_translit($1, [[ ]], _))DNL m4_divert(2)CF_KEYWORDS(m4_translit($1, [[ ]], [[,]])) m4_divert(3)cli_cmd: CF_cmd CF_cmd: $1 $2 END') m4_define(CF_CLI_CMD, `') m4_define(CF_CLI_HELP, `') # ENUM declarations are ignored m4_define(CF_ENUM, `') m4_define(CF_ENUM_PX, `') # After all configuration templates end, we finally generate the grammar file. m4_m4wrap(` m4_divert(0)DNL %{ m4_undivert(1)DNL %} m4_undivert(2)DNL %% m4_undivert(3)DNL %% m4_undivert(4)DNL ') # As we are processing C source, we must access all M4 primitives via # m4_* and also set different quoting convention: `[[' and ']]' m4_changequote([[,]]) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/gen_keywords.m4���������������������������������������������������������������������0000664�0001750�0001750�00000004045�14025744326�015256� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������m4_divert(-1)m4_dnl # # BIRD -- Generator of Configuration Keyword List # # (c) 1998--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz> # # Can be freely distributed and used under the terms of the GNU GPL. # # Common aliases m4_define(DNL, `m4_dnl') # Diversions used: # 1 keywords # Simple iterator m4_define(CF_itera, `m4_ifelse($#, 1, [[CF_iter($1)]], [[CF_iter($1)[[]]CF_itera(m4_shift($@))]])') m4_define(CF_iterate, `m4_define([[CF_iter]], m4_defn([[$1]]))CF_itera($2)') # We include all the headers m4_define(CF_HDR, `m4_divert(0)') m4_define(CF_DECLS, `m4_divert(-1)') m4_define(CF_DEFINES, `m4_divert(-1)') # Keywords are translated to C initializers m4_define(CF_handle_kw, `m4_divert(1){ "m4_translit($1,[[A-Z]],[[a-z]])", $1, NULL }, m4_divert(-1)') m4_define(CF_keywd, `m4_ifdef([[CF_tok_$1]],,[[m4_define([[CF_tok_$1]],1)CF_handle_kw($1)]])') m4_define(CF_KEYWORDS, `m4_define([[CF_toks]],[[]])CF_iterate([[CF_keywd]], [[$@]])m4_ifelse(CF_toks,,,%token[[]]CF_toks )DNL') # CLI commands generate keywords as well m4_define(CF_CLI, `CF_KEYWORDS(m4_translit($1, [[ ]], [[,]])) ') # Enums are translated to C initializers: use CF_ENUM(typename, prefix, values) # For different prefix: CF_ENUM_PX(typename, external prefix, C prefix, values) m4_define(CF_enum, `m4_divert(1){ "CF_enum_prefix_ext[[]]$1", -((CF_enum_type<<16) | CF_enum_prefix_int[[]]$1), NULL }, m4_divert(-1)') m4_define(CF_ENUM, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix_ext]],$2)m4_define([[CF_enum_prefix_int]],$2)CF_iterate([[CF_enum]], [[m4_shift(m4_shift($@))]])DNL') m4_define(CF_ENUM_PX, `m4_define([[CF_enum_type]],$1)m4_define([[CF_enum_prefix_ext]],$2)m4_define([[CF_enum_prefix_int]],$3)CF_iterate([[CF_enum]], [[m4_shift(m4_shift(m4_shift($@)))]])DNL') # After all configuration templates end, we generate the m4_m4wrap(` m4_divert(0) static struct keyword keyword_list[] = { m4_undivert(1){ NULL, -1, NULL } }; ') # As we are processing C source, we must access all M4 primitives via # m4_* and also set different quoting convention: `[[' and ']]' m4_changequote([[,]]) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/gen_commands.m4���������������������������������������������������������������������0000664�0001750�0001750�00000001177�14025744326�015213� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������m4_divert(-1)m4_dnl # # BIRD -- Generator of CLI Command List # # (c) 2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz> # # Can be freely distributed and used under the terms of the GNU GPL. # m4_define(CF_CLI, `m4_divert(0){ "m4_translit($1,A-Z,a-z)", "$3", "$4", 1 }, m4_divert(-1)') m4_define(CF_CLI_CMD, `m4_divert(0){ "m4_translit($1,A-Z,a-z)", "$2", "$3", 1 }, m4_divert(-1)') m4_define(CF_CLI_HELP, `m4_divert(0){ "m4_translit($1,A-Z,a-z)", "$2", "$3", 0 }, m4_divert(-1)') # As we are processing C source, we must access all M4 primitives via # m4_* and also set different quoting convention: `[[' and ']]' m4_changequote([[,]]) �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/flowspec.Y��������������������������������������������������������������������������0000664�0001750�0001750�00000012341�14025744326�014266� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD -- Flow specification (RFC 5575) grammar * * (c) 2016 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #define PARSER 1 #include "nest/bird.h" #include "lib/flowspec.h" CF_DEFINES struct flow_builder *this_flow; CF_DECLS %type <i32> flow_num_op flow_srcdst flow_logic_op flow_num_type_ flow_frag_val flow_neg %type <net_ptr> net_flow4_ net_flow6_ net_flow_ CF_KEYWORDS(FLOW4, FLOW6, DST, SRC, PROTO, NEXT, HEADER, DPORT, SPORT, ICMP, TYPE, CODE, TCP, FLAGS, LENGTH, DSCP, DONT_FRAGMENT, IS_FRAGMENT, FIRST_FRAGMENT, LAST_FRAGMENT, FRAGMENT, LABEL, OFFSET) CF_GRAMMAR /* Network Flow Specification */ flow_num_op: TRUE { $$ = FLOW_OP_TRUE; } | '=' { $$ = FLOW_OP_EQ; } | NEQ { $$ = FLOW_OP_NEQ; } | '<' { $$ = FLOW_OP_LT; } | LEQ { $$ = FLOW_OP_LEQ; } | '>' { $$ = FLOW_OP_GT; } | GEQ { $$ = FLOW_OP_GEQ; } | FALSE { $$ = FLOW_OP_FALSE; } ; flow_logic_op: OR { $$ = FLOW_OP_OR; } | AND { $$ = FLOW_OP_AND; } ; flow_num_type_: PROTO { $$ = FLOW_TYPE_IP_PROTOCOL; } | NEXT HEADER { $$ = FLOW_TYPE_NEXT_HEADER; } | PORT { $$ = FLOW_TYPE_PORT; } | DPORT { $$ = FLOW_TYPE_DST_PORT; } | SPORT { $$ = FLOW_TYPE_SRC_PORT; } | ICMP TYPE { $$ = FLOW_TYPE_ICMP_TYPE; } | ICMP CODE { $$ = FLOW_TYPE_ICMP_CODE; } | LENGTH { $$ = FLOW_TYPE_PACKET_LENGTH; } | DSCP { $$ = FLOW_TYPE_DSCP; } ; flow_num_type: flow_num_type_{ flow_builder_set_type(this_flow, $1); }; flow_flag_type: TCP FLAGS { flow_builder_set_type(this_flow, FLOW_TYPE_TCP_FLAGS); }; flow_frag_type: FRAGMENT { flow_builder_set_type(this_flow, FLOW_TYPE_FRAGMENT); }; flow_label_type: LABEL { flow_builder_set_type(this_flow, FLOW_TYPE_LABEL); }; flow_srcdst: DST { $$ = FLOW_TYPE_DST_PREFIX; } | SRC { $$ = FLOW_TYPE_SRC_PREFIX; } ; flow_num_opts: flow_num_op expr { flow_check_cf_value_length(this_flow, $2); flow_builder_add_op_val(this_flow, $1, $2); } | flow_num_opts flow_logic_op flow_num_op expr { flow_check_cf_value_length(this_flow, $4); flow_builder_add_op_val(this_flow, $2 | $3, $4); } | flow_num_opt_ext | flow_num_opts OR flow_num_opt_ext ; flow_num_opt_ext_expr: expr { flow_check_cf_value_length(this_flow, $1); flow_builder_add_op_val(this_flow, FLOW_OP_EQ, $1); } | expr DDOT expr { flow_check_cf_value_length(this_flow, $1); flow_check_cf_value_length(this_flow, $3); flow_builder_add_op_val(this_flow, FLOW_OP_GEQ, $1); flow_builder_add_op_val(this_flow, FLOW_OP_AND | FLOW_OP_LEQ, $3); } ; flow_num_opt_ext: flow_num_opt_ext_expr | flow_num_opt_ext ',' flow_num_opt_ext_expr ; flow_bmk_opts: flow_neg expr '/' expr { flow_check_cf_bmk_values(this_flow, $1, $2, $4); flow_builder_add_val_mask(this_flow, $1, $2, $4); } | flow_bmk_opts flow_logic_op flow_neg expr '/' expr { flow_check_cf_bmk_values(this_flow, $3, $4, $6); flow_builder_add_val_mask(this_flow, $2 | $3, $4, $6); } | flow_bmk_opts ',' flow_neg expr '/' expr { flow_check_cf_bmk_values(this_flow, $3, $4, $6); flow_builder_add_val_mask(this_flow, 0x40 | $3, $4, $6); /* AND */ } ; flow_neg: /* empty */ { $$ = 0x00; } | '!' { $$ = 0x02; } ; flow_frag_val: DONT_FRAGMENT { $$ = 1; } | IS_FRAGMENT { $$ = 2; } | FIRST_FRAGMENT { $$ = 4; } | LAST_FRAGMENT { $$ = 8; } ; flow_frag_opts: flow_neg flow_frag_val { flow_builder_add_val_mask(this_flow, 0, ($1 ? 0 : $2), $2); } | flow_frag_opts flow_logic_op flow_neg flow_frag_val { flow_builder_add_val_mask(this_flow, $2, ($3 ? 0 : $4), $4); } | flow_frag_opts ',' flow_neg flow_frag_val { flow_builder_add_val_mask(this_flow, 0x40, ($3 ? 0 : $4), $4); /* AND */ } ; flow4_item: flow_srcdst net_ip { flow_builder_set_type(this_flow, $1); flow_builder4_add_pfx(this_flow, (net_addr_ip4 *) &($2)); } | flow_num_type flow_num_opts | flow_flag_type flow_bmk_opts | flow_frag_type flow_frag_opts ; flow6_item: flow_srcdst net_ip6 { flow_builder_set_type(this_flow, $1); flow_builder6_add_pfx(this_flow, (net_addr_ip6 *) &($2), 0); } | flow_srcdst net_ip6 OFFSET NUM { if ($4 > $2.pxlen) cf_error("Prefix offset is higher than prefix length"); flow_builder_set_type(this_flow, $1); flow_builder6_add_pfx(this_flow, (net_addr_ip6 *) &($2), $4); } | flow_num_type flow_num_opts | flow_flag_type flow_bmk_opts | flow_frag_type flow_frag_opts | flow_label_type flow_bmk_opts ; flow4_opts: /* empty */ | flow4_opts flow4_item ';' ; flow6_opts: /* empty */ | flow6_opts flow6_item ';' ; flow_builder_init: { if (this_flow == NULL) this_flow = flow_builder_init(&root_pool); else flow_builder_clear(this_flow); }; flow_builder_set_ipv4: { this_flow->ipv6 = 0; }; flow_builder_set_ipv6: { this_flow->ipv6 = 1; }; net_flow4_: FLOW4 '{' flow_builder_init flow_builder_set_ipv4 flow4_opts '}' { $$ = (net_addr *) flow_builder4_finalize(this_flow, cfg_mem); flow4_validate_cf((net_addr_flow4 *) $$); }; net_flow6_: FLOW6 '{' flow_builder_init flow_builder_set_ipv6 flow6_opts '}' { $$ = (net_addr *) flow_builder6_finalize(this_flow, cfg_mem); flow6_validate_cf((net_addr_flow6 *) $$); }; net_flow_: net_flow4_ | net_flow6_ ; CF_CODE CF_END �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/confbase.Y��������������������������������������������������������������������������0000664�0001750�0001750�00000021416�14025744326�014227� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD -- Configuration Parser Top * * (c) 1998--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ CF_HDR #define PARSER 1 #include "nest/bird.h" #include "conf/conf.h" #include "lib/resource.h" #include "lib/socket.h" #include "lib/timer.h" #include "lib/string.h" #include "nest/protocol.h" #include "nest/iface.h" #include "nest/route.h" #include "nest/bfd.h" #include "nest/cli.h" #include "filter/filter.h" /* FIXME: Turn on YYERROR_VERBOSE and work around lots of bison bugs? */ CF_DEFINES static void check_u16(uint val) { if (val > 0xFFFF) cf_error("Value %u out of range (0-65535)", val); } #define cf_assert(cond, ...) do { if (!(cond)) cf_error(__VA_ARGS__); } while (0) static inline void cf_assert_symbol(const struct symbol *sym, uint class) { switch (class) { case SYM_PROTO: cf_assert(sym->class == SYM_PROTO, "Protocol name required"); break; case SYM_TEMPLATE: cf_assert(sym->class == SYM_TEMPLATE, "Protocol template name required"); break; case SYM_FUNCTION: cf_assert(sym->class == SYM_FUNCTION, "Function name required"); break; case SYM_FILTER: cf_assert(sym->class == SYM_FILTER, "Filter name required"); break; case SYM_TABLE: cf_assert(sym->class == SYM_TABLE, "Table name required"); break; case SYM_ATTRIBUTE: cf_assert(sym->class == SYM_ATTRIBUTE, "Custom attribute name required"); break; case SYM_VARIABLE: cf_assert((sym->class & ~0xff) == SYM_VARIABLE, "Variable name required"); break; case SYM_CONSTANT: cf_assert((sym->class & ~0xff) == SYM_CONSTANT, "Constant name required"); break; default: bug("This shall not happen"); } } CF_DECLS %union { uint i; u32 i32; u64 i64; ip_addr a; ip4_addr ip4; ip6_addr ip6; net_addr net; net_addr *net_ptr; struct symbol *s; const char *t; struct rtable_config *r; struct channel_config *cc; struct channel *c; struct f_inst *x; struct { struct f_inst *begin, *end; } xp; enum filter_return fret; enum ec_subtype ecs; struct f_dynamic_attr fda; struct f_static_attr fsa; struct f_lval flv; struct f_line *fl; const struct filter *f; struct f_tree *e; struct f_trie *trie; struct f_val v; struct password_item *p; struct rt_show_data *ra; struct sym_show_data *sd; struct lsadb_show_data *ld; struct mrt_dump_data *md; struct iface *iface; void *g; btime time; struct f_prefix px; struct proto_spec ps; struct channel_limit cl; struct timeformat *tf; mpls_label_stack *mls; } %token END CLI_MARKER INVALID_TOKEN ELSECOL DDOT %token GEQ LEQ NEQ AND OR %token PO PC %token <i> NUM ENUM %token <ip4> IP4 %token <ip6> IP6 %token <i64> VPN_RD %token <s> CF_SYM_KNOWN CF_SYM_UNDEFINED %token <t> TEXT %type <iface> ipa_scope %type <i> expr bool pxlen4 %type <time> expr_us time %type <a> ipa %type <net> net_ip4_ net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa %type <net_ptr> net_ net_any net_vpn4_ net_vpn6_ net_vpn_ net_roa4_ net_roa6_ net_roa_ net_ip6_sadr_ net_mpls_ %type <mls> label_stack_start label_stack %type <t> text opttext %type <s> symbol %nonassoc PREFIX_DUMMY %left AND OR %nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC %left '+' '-' %left '*' '/' '%' %left '!' %nonassoc '.' %start config CF_KEYWORDS(DEFINE, ON, OFF, YES, NO, S, MS, US, PORT, VPN, MPLS, FROM) CF_GRAMMAR /* Basic config file structure */ config: conf_entries END { return 0; } | CLI_MARKER cli_cmd { return 0; } ; conf_entries: /* EMPTY */ | conf_entries conf ; conf: ';' ; /* Constant expressions */ conf: definition ; definition: DEFINE symbol '=' term ';' { struct f_val *val = cfg_allocz(sizeof(struct f_val)); if (f_eval(f_linearize($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error"); cf_define_symbol($2, SYM_CONSTANT | val->type, val, val); } ; expr: NUM | '(' term ')' { $$ = f_eval_int(f_linearize($2)); } | CF_SYM_KNOWN { if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number constant expected"); $$ = SYM_VAL($1).i; } ; expr_us: expr S { $$ = $1 S_; } | expr MS { $$ = $1 MS_; } | expr US { $$ = $1 US_; } ; symbol: CF_SYM_UNDEFINED | CF_SYM_KNOWN ; /* Switches */ bool: expr { $$ = !!$1; } | ON { $$ = 1; } | YES { $$ = 1; } | OFF { $$ = 0; } | NO { $$ = 0; } | /* Silence means agreement */ { $$ = 1; } ; /* Addresses */ ipa: IP4 { $$ = ipa_from_ip4($1); } | IP6 { $$ = ipa_from_ip6($1); } | CF_SYM_KNOWN { if ($1->class != (SYM_CONSTANT | T_IP)) cf_error("IP address constant expected"); $$ = SYM_VAL($1).ip; } ; ipa_scope: /* empty */ { $$ = NULL; } | '%' symbol { $$ = if_get_by_name($2->name); } ; /* Networks - internal */ pxlen4: '/' NUM { if ($2 > IP4_MAX_PREFIX_LENGTH) cf_error("Invalid prefix length %u", $2); $$ = $2; } ; net_ip4_: IP4 pxlen4 { net_fill_ip4(&($$), $1, $2); net_addr_ip4 *n = (void *) &($$); if (!net_validate_ip4(n)) cf_error("Invalid IPv4 prefix %I4/%d, maybe you wanted %I4/%d", n->prefix, n->pxlen, ip4_and(n->prefix, ip4_mkmask(n->pxlen)), n->pxlen); }; net_ip6_: IP6 '/' NUM { if ($3 > IP6_MAX_PREFIX_LENGTH) cf_error("Invalid prefix length %u", $3); net_fill_ip6(&($$), $1, $3); net_addr_ip6 *n = (void *) &($$); if (!net_validate_ip6(n)) cf_error("Invalid IPv6 prefix %I6/%d, maybe you wanted %I6/%d", n->prefix, n->pxlen, ip6_and(n->prefix, ip6_mkmask(n->pxlen)), n->pxlen); }; net_ip6_sadr_: IP6 '/' NUM FROM IP6 '/' NUM { if ($3 > IP6_MAX_PREFIX_LENGTH) cf_error("Invalid prefix length %u", $3); if ($7 > IP6_MAX_PREFIX_LENGTH) cf_error("Invalid prefix length %u", $7); $$ = cfg_alloc(sizeof(net_addr_ip6_sadr)); net_fill_ip6_sadr($$, $1, $3, $5, $7); net_addr_ip6_sadr *n = (void *) $$; if (!net_validate_ip6_sadr(n)) cf_error("Invalid SADR IPv6 prefix %I6/%d from %I6/%d, maybe you wanted %I6/%d from %I6/%d", n->dst_prefix, n->dst_pxlen, n->src_prefix, n->src_pxlen, ip6_and(n->dst_prefix, ip6_mkmask(n->dst_pxlen)), n->dst_pxlen, ip6_and(n->src_prefix, ip6_mkmask(n->src_pxlen)), n->src_pxlen); }; net_vpn4_: VPN_RD net_ip4_ { $$ = cfg_alloc(sizeof(net_addr_vpn4)); net_fill_vpn4($$, net4_prefix(&$2), net4_pxlen(&$2), $1); } net_vpn6_: VPN_RD net_ip6_ { $$ = cfg_alloc(sizeof(net_addr_vpn6)); net_fill_vpn6($$, net6_prefix(&$2), net6_pxlen(&$2), $1); } net_roa4_: net_ip4_ MAX NUM AS NUM { $$ = cfg_alloc(sizeof(net_addr_roa4)); net_fill_roa4($$, net4_prefix(&$1), net4_pxlen(&$1), $3, $5); if ($3 < net4_pxlen(&$1) || $3 > IP4_MAX_PREFIX_LENGTH) cf_error("Invalid max prefix length %u", $3); }; net_roa6_: net_ip6_ MAX NUM AS NUM { $$ = cfg_alloc(sizeof(net_addr_roa6)); net_fill_roa6($$, net6_prefix(&$1), net6_pxlen(&$1), $3, $5); if ($3 < net6_pxlen(&$1) || $3 > IP6_MAX_PREFIX_LENGTH) cf_error("Invalid max prefix length %u", $3); }; net_mpls_: MPLS NUM { $$ = cfg_alloc(sizeof(net_addr_roa6)); net_fill_mpls($$, $2); } net_ip_: net_ip4_ | net_ip6_ ; net_vpn_: net_vpn4_ | net_vpn6_ ; net_roa_: net_roa4_ | net_roa6_ ; net_: net_ip_ { $$ = cfg_alloc($1.length); net_copy($$, &($1)); } | net_vpn_ | net_roa_ | net_flow_ | net_ip6_sadr_ | net_mpls_ ; /* Networks - regular */ net_ip6: net_ip6_ | CF_SYM_KNOWN { if (($1->class != (SYM_CONSTANT | T_NET)) || (SYM_VAL($1).net->type != NET_IP6)) cf_error("IPv6 network constant expected"); $$ = * SYM_VAL($1).net; } ; net_ip: net_ip_ | CF_SYM_KNOWN { if (($1->class != (SYM_CONSTANT | T_NET)) || !net_is_ip(SYM_VAL($1).net)) cf_error("IP network constant expected"); $$ = * SYM_VAL($1).net; } ; net_any: net_ | CF_SYM_KNOWN { if ($1->class != (SYM_CONSTANT | T_NET)) cf_error("Network constant expected"); $$ = (net_addr *) SYM_VAL($1).net; /* Avoid const warning */ } ; net_or_ipa: net_ip4_ | net_ip6_ | IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); } | IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); } | CF_SYM_KNOWN { if ($1->class == (SYM_CONSTANT | T_IP)) net_fill_ip_host(&($$), SYM_VAL($1).ip); else if (($1->class == (SYM_CONSTANT | T_NET)) && net_is_ip(SYM_VAL($1).net)) $$ = * SYM_VAL($1).net; else cf_error("IP address or network constant expected"); } ; label_stack_start: NUM { $$ = cfg_allocz(sizeof(mpls_label_stack)); $$->len = 1; $$->stack[0] = $1; }; label_stack: label_stack_start | label_stack '/' NUM { if ($1->len >= MPLS_MAX_LABEL_STACK) cf_error("Too many labels in stack"); $1->stack[$1->len++] = $3; $$ = $1; } ; time: TEXT { $$ = tm_parse_time($1); if (!$$) cf_error("Invalid date/time"); } ; text: TEXT | CF_SYM_KNOWN { if ($1->class != (SYM_CONSTANT | T_STRING)) cf_error("String constant expected"); $$ = SYM_VAL($1).s; } ; opttext: TEXT | /* empty */ { $$ = NULL; } ; CF_CODE CF_END ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/conf.h������������������������������������������������������������������������������0000664�0001750�0001750�00000017077�14025744326�013423� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Internet Routing Daemon -- Configuration File Handling * * (c) 1998--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ #ifndef _BIRD_CONF_H_ #define _BIRD_CONF_H_ #include "sysdep/config.h" #include "lib/ip.h" #include "lib/hash.h" #include "lib/resource.h" #include "lib/timer.h" /* Configuration structure */ struct config { pool *pool; /* Pool the configuration is stored in */ linpool *mem; /* Linear pool containing configuration data */ list protos; /* Configured protocol instances (struct proto_config) */ list tables; /* Configured routing tables (struct rtable_config) */ list logfiles; /* Configured log files (sysdep) */ list tests; /* Configured unit tests (f_bt_test_suite) */ list symbols; /* Configured symbols in config order */ int mrtdump_file; /* Configured MRTDump file (sysdep, fd in unix) */ const char *syslog_name; /* Name used for syslog (NULL -> no syslog) */ struct rtable_config *def_tables[NET_MAX]; /* Default routing tables for each network */ struct iface_patt *router_id_from; /* Configured list of router ID iface patterns */ u32 router_id; /* Our Router ID */ u32 proto_default_debug; /* Default protocol debug mask */ u32 proto_default_mrtdump; /* Default protocol mrtdump mask */ u32 channel_default_debug; /* Default channel debug mask */ struct timeformat tf_route; /* Time format for 'show route' */ struct timeformat tf_proto; /* Time format for 'show protocol' */ struct timeformat tf_log; /* Time format for the logfile */ struct timeformat tf_base; /* Time format for other purposes */ u32 gr_wait; /* Graceful restart wait timeout (sec) */ const char *hostname; /* Hostname */ int cli_debug; /* Tracing of CLI connections and commands */ int latency_debug; /* I/O loop tracks duration of each event */ u32 latency_limit; /* Events with longer duration are logged (us) */ u32 watchdog_warning; /* I/O loop watchdog limit for warning (us) */ u32 watchdog_timeout; /* Watchdog timeout (in seconds, 0 = disabled) */ char *err_msg; /* Parser error message */ int err_lino; /* Line containing error */ int err_chno; /* Character where the parser stopped */ char *err_file_name; /* File name containing error */ char *file_name; /* Name of main configuration file */ int file_fd; /* File descriptor of main configuration file */ HASH(struct symbol) sym_hash; /* Lexer: symbol hash table */ struct config *fallback; /* Link to regular config for CLI parsing */ struct sym_scope *root_scope; /* Scope for root symbols */ int obstacle_count; /* Number of items blocking freeing of this config */ int shutdown; /* This is a pseudo-config for daemon shutdown */ int gr_down; /* This is a pseudo-config for graceful restart */ btime load_time; /* When we've got this configuration */ }; /* Please don't use these variables in protocols. Use proto_config->global instead. */ extern struct config *config; /* Currently active configuration */ extern struct config *new_config; /* Configuration being parsed */ struct config *config_alloc(const char *name); int config_parse(struct config *); int cli_parse(struct config *); void config_free(struct config *); int config_commit(struct config *, int type, uint timeout); int config_confirm(void); int config_undo(void); int config_status(void); btime config_timer_status(void); void config_init(void); void cf_error(const char *msg, ...) NORET; void config_add_obstacle(struct config *); void config_del_obstacle(struct config *); void order_shutdown(int gr); #define RECONFIG_NONE 0 #define RECONFIG_HARD 1 #define RECONFIG_SOFT 2 #define RECONFIG_UNDO 3 #define CONF_DONE 0 #define CONF_PROGRESS 1 #define CONF_QUEUED 2 #define CONF_UNQUEUED 3 #define CONF_CONFIRM 4 #define CONF_SHUTDOWN -1 #define CONF_NOTHING -2 /* Pools */ extern linpool *cfg_mem; #define cfg_alloc(size) lp_alloc(cfg_mem, size) #define cfg_allocu(size) lp_allocu(cfg_mem, size) #define cfg_allocz(size) lp_allocz(cfg_mem, size) char *cfg_strdup(const char *c); void cfg_copy_list(list *dest, list *src, unsigned node_size); /* Lexer */ extern int (*cf_read_hook)(byte *buf, uint max, int fd); struct symbol { node n; /* In list of symbols in config */ struct symbol *next; struct sym_scope *scope; int class; /* SYM_* */ uint flags; /* SYM_FLAG_* */ union { struct proto_config *proto; /* For SYM_PROTO and SYM_TEMPLATE */ const struct f_line *function; /* For SYM_FUNCTION */ const struct filter *filter; /* For SYM_FILTER */ struct rtable_config *table; /* For SYM_TABLE */ struct f_dynamic_attr *attribute; /* For SYM_ATTRIBUTE */ struct f_val *val; /* For SYM_CONSTANT */ uint offset; /* For SYM_VARIABLE */ }; char name[0]; }; struct sym_scope { struct sym_scope *next; /* Next on scope stack */ struct symbol *name; /* Name of this scope */ uint slots; /* Variable slots */ int active; /* Currently entered */ }; #define SYM_MAX_LEN 64 /* Remember to update cf_symbol_class_name() */ #define SYM_VOID 0 #define SYM_PROTO 1 #define SYM_TEMPLATE 2 #define SYM_FUNCTION 3 #define SYM_FILTER 4 #define SYM_TABLE 5 #define SYM_ATTRIBUTE 6 #define SYM_VARIABLE 0x100 /* 0x100-0x1ff are variable types */ #define SYM_VARIABLE_RANGE SYM_VARIABLE ... (SYM_VARIABLE | 0xff) #define SYM_CONSTANT 0x200 /* 0x200-0x2ff are variable types */ #define SYM_CONSTANT_RANGE SYM_CONSTANT ... (SYM_CONSTANT | 0xff) #define SYM_TYPE(s) ((s)->val->type) #define SYM_VAL(s) ((s)->val->val) /* Symbol flags */ #define SYM_FLAG_SAME 0x1 /* For SYM_FUNCTION and SYM_FILTER */ struct include_file_stack { void *buffer; /* Internal lexer state */ char *file_name; /* File name */ int fd; /* File descriptor */ int lino; /* Current line num */ int chno; /* Current char num (on current line) */ int toklen; /* Current token length */ int depth; /* Include depth, 0 = cannot include */ struct include_file_stack *prev; /* Previous record in stack */ struct include_file_stack *up; /* Parent (who included this file) */ }; extern struct include_file_stack *ifs; extern struct sym_scope *conf_this_scope; int cf_lex(void); void cf_lex_init(int is_cli, struct config *c); void cf_lex_unwind(void); struct symbol *cf_find_symbol(const struct config *cfg, const byte *c); struct symbol *cf_get_symbol(const byte *c); struct symbol *cf_default_name(char *template, int *counter); struct symbol *cf_localize_symbol(struct symbol *sym); /** * cf_define_symbol - define meaning of a symbol * @sym: symbol to be defined * @type: symbol class to assign * @def: class dependent data * * Defines new meaning of a symbol. If the symbol is an undefined * one (%SYM_VOID), it's just re-defined to the new type. If it's defined * in different scope, a new symbol in current scope is created and the * meaning is assigned to it. If it's already defined in the current scope, * an error is reported via cf_error(). * * Result: Pointer to the newly defined symbol. If we are in the top-level * scope, it's the same @sym as passed to the function. */ #define cf_define_symbol(osym_, type_, var_, def_) ({ \ struct symbol *sym_ = cf_localize_symbol(osym_); \ sym_->class = type_; \ sym_->var_ = def_; \ sym_; }) void cf_push_scope(struct symbol *); void cf_pop_scope(void); char *cf_symbol_class_name(struct symbol *sym); /* Parser */ extern char *cf_text; int cf_parse(void); /* Sysdep hooks */ void sysdep_preconfig(struct config *); int sysdep_commit(struct config *, struct config *); void sysdep_shutdown_done(void); #endif �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/conf.c������������������������������������������������������������������������������0000664�0001750�0001750�00000036367�14025744326�013421� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Internet Routing Daemon -- Configuration File Handling * * (c) 1998--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Configuration manager * * Configuration of BIRD is complex, yet straightforward. There are three * modules taking care of the configuration: config manager (which takes care * of storage of the config information and controls switching between configs), * lexical analyzer and parser. * * The configuration manager stores each config as a &config structure * accompanied by a linear pool from which all information associated * with the config and pointed to by the &config structure is allocated. * * There can exist up to four different configurations at one time: an active * one (pointed to by @config), configuration we are just switching from * (@old_config), one queued for the next reconfiguration (@future_config; if * there is one and the user wants to reconfigure once again, we just free the * previous queued config and replace it with the new one) and finally a config * being parsed (@new_config). The stored @old_config is also used for undo * reconfiguration, which works in a similar way. Reconfiguration could also * have timeout (using @config_timer) and undo is automatically called if the * new configuration is not confirmed later. The new config (@new_config) and * associated linear pool (@cfg_mem) is non-NULL only during parsing. * * Loading of new configuration is very simple: just call config_alloc() to get * a new &config structure, then use config_parse() to parse a configuration * file and fill all fields of the structure and finally ask the config manager * to switch to the new config by calling config_commit(). * * CLI commands are parsed in a very similar way -- there is also a stripped-down * &config structure associated with them and they are lex-ed and parsed by the * same functions, only a special fake token is prepended before the command * text to make the parser recognize only the rules corresponding to CLI commands. */ #include <setjmp.h> #include <stdarg.h> #undef LOCAL_DEBUG #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" #include "nest/iface.h" #include "lib/resource.h" #include "lib/string.h" #include "lib/event.h" #include "lib/timer.h" #include "conf/conf.h" #include "filter/filter.h" #include "sysdep/unix/unix.h" static jmp_buf conf_jmpbuf; struct config *config, *new_config; static struct config *old_config; /* Old configuration */ static struct config *future_config; /* New config held here if recon requested during recon */ static int old_cftype; /* Type of transition old_config -> config (RECONFIG_SOFT/HARD) */ static int future_cftype; /* Type of scheduled transition, may also be RECONFIG_UNDO */ /* Note that when future_cftype is RECONFIG_UNDO, then future_config is NULL, therefore proper check for future scheduled config checks future_cftype */ static event *config_event; /* Event for finalizing reconfiguration */ static timer *config_timer; /* Timer for scheduled configuration rollback */ /* These are public just for cmd_show_status(), should not be accessed elsewhere */ int shutting_down; /* Shutdown requested, do not accept new config changes */ int configuring; /* Reconfiguration is running */ int undo_available; /* Undo was not requested from last reconfiguration */ /* Note that both shutting_down and undo_available are related to requests, not processing */ /** * config_alloc - allocate a new configuration * @name: name of the config * * This function creates new &config structure, attaches a resource * pool and a linear memory pool to it and makes it available for * further use. Returns a pointer to the structure. */ struct config * config_alloc(const char *name) { pool *p = rp_new(&root_pool, "Config"); linpool *l = lp_new_default(p); struct config *c = lp_allocz(l, sizeof(struct config)); /* Duplication of name string in local linear pool */ uint nlen = strlen(name) + 1; char *ndup = lp_allocu(l, nlen); memcpy(ndup, name, nlen); init_list(&c->tests); init_list(&c->symbols); c->mrtdump_file = -1; /* Hack, this should be sysdep-specific */ c->pool = p; c->mem = l; c->file_name = ndup; c->load_time = current_time(); c->tf_route = c->tf_proto = TM_ISO_SHORT_MS; c->tf_base = c->tf_log = TM_ISO_LONG_MS; c->gr_wait = DEFAULT_GR_WAIT; return c; } /** * config_parse - parse a configuration * @c: configuration * * config_parse() reads input by calling a hook function pointed to * by @cf_read_hook and parses it according to the configuration * grammar. It also calls all the preconfig and postconfig hooks * before, resp. after parsing. * * Result: 1 if the config has been parsed successfully, 0 if any * error has occurred (such as anybody calling cf_error()) and * the @err_msg field has been set to the error message. */ int config_parse(struct config *c) { int done = 0; DBG("Parsing configuration file `%s'\n", c->file_name); new_config = c; cfg_mem = c->mem; if (setjmp(conf_jmpbuf)) goto cleanup; cf_lex_init(0, c); sysdep_preconfig(c); protos_preconfig(c); rt_preconfig(c); cf_parse(); if (EMPTY_LIST(c->protos)) cf_error("No protocol is specified in the config file"); /* if (!c->router_id) cf_error("Router ID must be configured manually"); */ done = 1; cleanup: new_config = NULL; cfg_mem = NULL; return done; } /** * cli_parse - parse a CLI command * @c: temporary config structure * * cli_parse() is similar to config_parse(), but instead of a configuration, * it parses a CLI command. See the CLI module for more information. */ int cli_parse(struct config *c) { int done = 0; c->fallback = config; new_config = c; cfg_mem = c->mem; if (setjmp(conf_jmpbuf)) goto cleanup; cf_lex_init(1, c); cf_parse(); done = 1; cleanup: c->fallback = NULL; new_config = NULL; cfg_mem = NULL; return done; } /** * config_free - free a configuration * @c: configuration to be freed * * This function takes a &config structure and frees all resources * associated with it. */ void config_free(struct config *c) { if (c) rfree(c->pool); } void config_add_obstacle(struct config *c) { DBG("+++ adding obstacle %d\n", c->obstacle_count); c->obstacle_count++; } void config_del_obstacle(struct config *c) { DBG("+++ deleting obstacle %d\n", c->obstacle_count); c->obstacle_count--; if (!c->obstacle_count && (c != config)) ev_schedule(config_event); } static int global_commit(struct config *new, struct config *old) { if (!new->hostname) { new->hostname = get_hostname(new->mem); if (!new->hostname) log(L_WARN "Cannot determine hostname"); } if (!old) return 0; if (!new->router_id) { new->router_id = old->router_id; if (new->router_id_from) { u32 id = if_choose_router_id(new->router_id_from, old->router_id); if (!id) log(L_WARN "Cannot determine router ID, using old one"); else new->router_id = id; } } return 0; } static int config_do_commit(struct config *c, int type) { if (type == RECONFIG_UNDO) { c = old_config; type = old_cftype; } else config_free(old_config); old_config = config; old_cftype = type; config = c; configuring = 1; if (old_config && !config->shutdown) log(L_INFO "Reconfiguring"); if (old_config) old_config->obstacle_count++; DBG("filter_commit\n"); filter_commit(c, old_config); DBG("sysdep_commit\n"); int force_restart = sysdep_commit(c, old_config); DBG("global_commit\n"); force_restart |= global_commit(c, old_config); DBG("rt_commit\n"); rt_commit(c, old_config); DBG("protos_commit\n"); protos_commit(c, old_config, force_restart, type); int obs = 0; if (old_config) obs = --old_config->obstacle_count; DBG("do_commit finished with %d obstacles remaining\n", obs); return !obs; } static void config_done(void *unused UNUSED) { if (config->shutdown) sysdep_shutdown_done(); configuring = 0; if (old_config) log(L_INFO "Reconfigured"); if (future_cftype) { int type = future_cftype; struct config *conf = future_config; future_cftype = RECONFIG_NONE; future_config = NULL; log(L_INFO "Reconfiguring to queued configuration"); if (config_do_commit(conf, type)) config_done(NULL); } } /** * config_commit - commit a configuration * @c: new configuration * @type: type of reconfiguration (RECONFIG_SOFT or RECONFIG_HARD) * @timeout: timeout for undo (in seconds; or 0 for no timeout) * * When a configuration is parsed and prepared for use, the * config_commit() function starts the process of reconfiguration. * It checks whether there is already a reconfiguration in progress * in which case it just queues the new config for later processing. * Else it notifies all modules about the new configuration by calling * their commit() functions which can either accept it immediately * or call config_add_obstacle() to report that they need some time * to complete the reconfiguration. After all such obstacles are removed * using config_del_obstacle(), the old configuration is freed and * everything runs according to the new one. * * When @timeout is nonzero, the undo timer is activated with given * timeout. The timer is deactivated when config_commit(), * config_confirm() or config_undo() is called. * * Result: %CONF_DONE if the configuration has been accepted immediately, * %CONF_PROGRESS if it will take some time to switch to it, %CONF_QUEUED * if it's been queued due to another reconfiguration being in progress now * or %CONF_SHUTDOWN if BIRD is in shutdown mode and no new configurations * are accepted. */ int config_commit(struct config *c, int type, uint timeout) { if (shutting_down) { config_free(c); return CONF_SHUTDOWN; } undo_available = 1; if (timeout) tm_start(config_timer, timeout S); else tm_stop(config_timer); if (configuring) { if (future_cftype) { log(L_INFO "Queueing new configuration, ignoring the one already queued"); config_free(future_config); } else log(L_INFO "Queueing new configuration"); future_cftype = type; future_config = c; return CONF_QUEUED; } if (config_do_commit(c, type)) { config_done(NULL); return CONF_DONE; } return CONF_PROGRESS; } /** * config_confirm - confirm a commited configuration * * When the undo timer is activated by config_commit() with nonzero timeout, * this function can be used to deactivate it and therefore confirm * the current configuration. * * Result: %CONF_CONFIRM when the current configuration is confirmed, * %CONF_NONE when there is nothing to confirm (i.e. undo timer is not active). */ int config_confirm(void) { if (config_timer->expires == 0) return CONF_NOTHING; tm_stop(config_timer); return CONF_CONFIRM; } /** * config_undo - undo a configuration * * Function config_undo() can be used to change the current * configuration back to stored %old_config. If no reconfiguration is * running, this stored configuration is commited in the same way as a * new configuration in config_commit(). If there is already a * reconfiguration in progress and no next reconfiguration is * scheduled, then the undo is scheduled for later processing as * usual, but if another reconfiguration is already scheduled, then * such reconfiguration is removed instead (i.e. undo is applied on * the last commit that scheduled it). * * Result: %CONF_DONE if the configuration has been accepted immediately, * %CONF_PROGRESS if it will take some time to switch to it, %CONF_QUEUED * if it's been queued due to another reconfiguration being in progress now, * %CONF_UNQUEUED if a scheduled reconfiguration is removed, %CONF_NOTHING * if there is no relevant configuration to undo (the previous config request * was config_undo() too) or %CONF_SHUTDOWN if BIRD is in shutdown mode and * no new configuration changes are accepted. */ int config_undo(void) { if (shutting_down) return CONF_SHUTDOWN; if (!undo_available || !old_config) return CONF_NOTHING; undo_available = 0; tm_stop(config_timer); if (configuring) { if (future_cftype) { config_free(future_config); future_config = NULL; log(L_INFO "Removing queued configuration"); future_cftype = RECONFIG_NONE; return CONF_UNQUEUED; } else { log(L_INFO "Queueing undo configuration"); future_cftype = RECONFIG_UNDO; return CONF_QUEUED; } } if (config_do_commit(NULL, RECONFIG_UNDO)) { config_done(NULL); return CONF_DONE; } return CONF_PROGRESS; } int config_status(void) { if (shutting_down) return CONF_SHUTDOWN; if (configuring) return future_cftype ? CONF_QUEUED : CONF_PROGRESS; return CONF_DONE; } btime config_timer_status(void) { return tm_active(config_timer) ? tm_remains(config_timer) : -1; } extern void cmd_reconfig_undo_notify(void); static void config_timeout(timer *t UNUSED) { log(L_INFO "Config timeout expired, starting undo"); cmd_reconfig_undo_notify(); int r = config_undo(); if (r < 0) log(L_ERR "Undo request failed"); } void config_init(void) { config_event = ev_new(&root_pool); config_event->hook = config_done; config_timer = tm_new(&root_pool); config_timer->hook = config_timeout; } /** * order_shutdown - order BIRD shutdown * * This function initiates shutdown of BIRD. It's accomplished by asking * for switching to an empty configuration. */ void order_shutdown(int gr) { struct config *c; if (shutting_down) return; if (!gr) log(L_INFO "Shutting down"); else log(L_INFO "Shutting down for graceful restart"); c = lp_alloc(config->mem, sizeof(struct config)); memcpy(c, config, sizeof(struct config)); init_list(&c->protos); init_list(&c->tables); c->shutdown = 1; c->gr_down = gr; config_commit(c, RECONFIG_HARD, 0); shutting_down = 1; } /** * cf_error - report a configuration error * @msg: printf-like format string * * cf_error() can be called during execution of config_parse(), that is * from the parser, a preconfig hook or a postconfig hook, to report an * error in the configuration. */ void cf_error(const char *msg, ...) { char buf[1024]; va_list args; va_start(args, msg); if (bvsnprintf(buf, sizeof(buf), msg, args) < 0) strcpy(buf, "<bug: error message too long>"); va_end(args); new_config->err_msg = cfg_strdup(buf); new_config->err_lino = ifs->lino; new_config->err_chno = ifs->chno - ifs->toklen + 1; new_config->err_file_name = ifs->file_name; cf_lex_unwind(); longjmp(conf_jmpbuf, 1); } /** * cfg_strdup - copy a string to config memory * @c: string to copy * * cfg_strdup() creates a new copy of the string in the memory * pool associated with the configuration being currently parsed. * It's often used when a string literal occurs in the configuration * and we want to preserve it for further use. */ char * cfg_strdup(const char *c) { int l = strlen(c) + 1; char *z = cfg_allocu(l); memcpy(z, c, l); return z; } void cfg_copy_list(list *dest, list *src, unsigned node_size) { node *dn, *sn; init_list(dest); WALK_LIST(sn, *src) { dn = cfg_alloc(node_size); memcpy(dn, sn, node_size); memset(dn, 0, sizeof(node)); add_tail(dest, dn); } } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/cf-lex.l����������������������������������������������������������������������������0000664�0001750�0001750�00000045126�14025744326�013654� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD -- Configuration Lexer * * (c) 1998--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: Lexical analyzer * * The lexical analyzer used for configuration files and CLI commands * is generated using the |flex| tool accompanied by a couple of * functions maintaining the hash tables containing information about * symbols and keywords. * * Each symbol is represented by a &symbol structure containing name * of the symbol, its lexical scope, symbol class (%SYM_PROTO for a * name of a protocol, %SYM_CONSTANT for a constant etc.) and class * dependent data. When an unknown symbol is encountered, it's * automatically added to the symbol table with class %SYM_VOID. * * The keyword tables are generated from the grammar templates * using the |gen_keywords.m4| script. */ %{ #undef REJECT /* Avoid name clashes */ #include <errno.h> #include <stdlib.h> #include <stdarg.h> #include <stdint.h> #include <unistd.h> #include <libgen.h> #include <glob.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/stat.h> #define PARSER 1 #include "nest/bird.h" #include "nest/route.h" #include "nest/protocol.h" #include "filter/filter.h" #include "filter/f-inst.h" #include "conf/conf.h" #include "conf/cf-parse.tab.h" #include "lib/string.h" #include "lib/hash.h" struct keyword { byte *name; int value; struct keyword *next; }; #include "conf/keywords.h" /* Could be defined by Bison in cf-parse.tab.h, inteferes with SYM hash */ #ifdef SYM #undef SYM #endif static uint cf_hash(const byte *c); #define KW_KEY(n) n->name #define KW_NEXT(n) n->next #define KW_EQ(a,b) !strcmp(a,b) #define KW_FN(k) cf_hash(k) #define KW_ORDER 8 /* Fixed */ #define SYM_KEY(n) n->name, n->scope->active #define SYM_NEXT(n) n->next #define SYM_EQ(a,s1,b,s2) !strcmp(a,b) && s1 == s2 #define SYM_FN(k,s) cf_hash(k) #define SYM_ORDER 6 /* Initial */ #define SYM_REHASH sym_rehash #define SYM_PARAMS /8, *1, 2, 2, 6, 20 HASH_DEFINE_REHASH_FN(SYM, struct symbol) HASH(struct keyword) kw_hash; struct sym_scope *conf_this_scope; linpool *cfg_mem; int (*cf_read_hook)(byte *buf, unsigned int max, int fd); struct include_file_stack *ifs; static struct include_file_stack *ifs_head; #define QUOTED_BUFFER_SIZE 4096 static BUFFER_(char) quoted_buffer; static char quoted_buffer_data[QUOTED_BUFFER_SIZE]; static inline void quoted_buffer_init(void) { quoted_buffer.used = 0; quoted_buffer.size = QUOTED_BUFFER_SIZE; quoted_buffer.data = quoted_buffer_data; } #define MAX_INCLUDE_DEPTH 8 #define YY_INPUT(buf,result,max) result = cf_read_hook(buf, max, ifs->fd); #define YY_NO_UNPUT #define YY_FATAL_ERROR(msg) cf_error(msg) #define YY_USER_ACTION ifs->chno += yyleng; ifs->toklen = yyleng; static void cf_include(char *arg, int alen); static int check_eof(void); static enum yytokentype cf_lex_symbol(const char *data); %} %option noyywrap %option noinput %option nounput %option noreject %x COMMENT CCOMM CLI QUOTED APOSTROPHED INCLUDE ALPHA [a-zA-Z_] DIGIT [0-9] XIGIT [0-9a-fA-F] ALNUM [a-zA-Z_0-9] WHITE [ \t] %% ^{WHITE}*include{WHITE}*\" { if (!ifs->depth) cf_error("Include not allowed in CLI"); BEGIN(INCLUDE); } <INCLUDE>[^"\n]+["]{WHITE}*; { char *start, *end; start = yytext; end = strchr(start, '"'); *end = 0; if (start == end) cf_error("Include with empty argument"); cf_include(start, end-start); BEGIN(INITIAL); } <INCLUDE>["] cf_error("Include with empty argument"); <INCLUDE>. cf_error("Unterminated include"); <INCLUDE>\n cf_error("Unterminated include"); <INCLUDE><<EOF>> cf_error("Unterminated include"); {DIGIT}+:{DIGIT}+ { uint len1 UNUSED, len2; u64 l; char *e; errno = 0; l = bstrtoul10(yytext, &e); if (!e || (*e != ':') || (errno == ERANGE) || (l >> 32)) cf_error("ASN out of range"); if (l >> 16) { len1 = 32; len2 = 16; cf_lval.i64 = (2ULL << 48) | (((u64) l) << len2); } else { len1 = 16; len2 = 32; cf_lval.i64 = 0 | (((u64) l) << len2); } errno = 0; l = bstrtoul10(e+1, &e); if (!e || *e || (errno == ERANGE) || (l >> len2)) cf_error("Number out of range"); cf_lval.i64 |= l; return VPN_RD; } [02]:{DIGIT}+:{DIGIT}+ { uint len1, len2; u64 l; char *e; if (yytext[0] == '0') { cf_lval.i64 = 0; len1 = 16; len2 = 32; } else { cf_lval.i64 = 2ULL << 48; len1 = 32; len2 = 16; } errno = 0; l = bstrtoul10(yytext+2, &e); if (!e || (*e != ':') || (errno == ERANGE) || (l >> len1)) cf_error("ASN out of range"); cf_lval.i64 |= ((u64) l) << len2; errno = 0; l = bstrtoul10(e+1, &e); if (!e || *e || (errno == ERANGE) || (l >> len2)) cf_error("Number out of range"); cf_lval.i64 |= l; return VPN_RD; } {DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+:{DIGIT}+ { unsigned long int l; ip4_addr ip4; char *e; cf_lval.i64 = 1ULL << 48; e = strchr(yytext, ':'); *e++ = '\0'; if (!ip4_pton(yytext, &ip4)) cf_error("Invalid IPv4 address %s in Route Distinguisher", yytext); cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16; errno = 0; l = bstrtoul10(e, &e); if (!e || *e || (errno == ERANGE) || (l >> 16)) cf_error("Number out of range"); cf_lval.i64 |= l; return VPN_RD; } {DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+ { if (!ip4_pton(yytext, &cf_lval.ip4)) cf_error("Invalid IPv4 address %s", yytext); return IP4; } ({XIGIT}*::|({XIGIT}*:){3,})({XIGIT}*|{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+) { if (!ip6_pton(yytext, &cf_lval.ip6)) cf_error("Invalid IPv6 address %s", yytext); return IP6; } 0x{XIGIT}+ { char *e; unsigned long int l; errno = 0; l = bstrtoul16(yytext+2, &e); if (!e || *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) cf_error("Number out of range"); cf_lval.i = l; return NUM; } {DIGIT}+ { char *e; unsigned long int l; errno = 0; l = bstrtoul10(yytext, &e); if (!e || *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) cf_error("Number out of range"); cf_lval.i = l; return NUM; } else: { /* Hack to distinguish if..else from else: in case */ return ELSECOL; } ['] { BEGIN(APOSTROPHED); quoted_buffer_init(); } <APOSTROPHED>{ALNUM}|[-]|[.:] BUFFER_PUSH(quoted_buffer) = yytext[0]; <APOSTROPHED>\n cf_error("Unterminated symbol"); <APOSTROPHED><<EOF>> cf_error("Unterminated symbol"); <APOSTROPHED>['] { BEGIN(INITIAL); BUFFER_PUSH(quoted_buffer) = 0; return cf_lex_symbol(quoted_buffer_data); } <APOSTROPHED>. cf_error("Invalid character in apostrophed symbol"); ({ALPHA}{ALNUM}*) { return cf_lex_symbol(yytext); } <CLI>(.|\n) { BEGIN(INITIAL); return CLI_MARKER; } \.\. { return DDOT; } [={}:;,.()+*/%<>~\[\]?!\|-] { return yytext[0]; } ["] { BEGIN(QUOTED); quoted_buffer_init(); } <QUOTED>\n cf_error("Unterminated string"); <QUOTED><<EOF>> cf_error("Unterminated string"); <QUOTED>["] { BEGIN(INITIAL); BUFFER_PUSH(quoted_buffer) = 0; cf_lval.t = cfg_strdup(quoted_buffer_data); return TEXT; } <QUOTED>. BUFFER_PUSH(quoted_buffer) = yytext[0]; <INITIAL,COMMENT><<EOF>> { if (check_eof()) return END; } {WHITE}+ \n ifs->lino++; ifs->chno = 0; # BEGIN(COMMENT); \/\* BEGIN(CCOMM); . cf_error("Unknown character"); <COMMENT>\n { ifs->lino++; ifs->chno = 0; BEGIN(INITIAL); } <COMMENT>. <CCOMM>\*\/ BEGIN(INITIAL); <CCOMM>\n ifs->lino++; ifs->chno = 0; <CCOMM>\/\* cf_error("Comment nesting not supported"); <CCOMM><<EOF>> cf_error("Unterminated comment"); <CCOMM>. \!\= return NEQ; \!\~ return NMA; \<\= return LEQ; \>\= return GEQ; \&\& return AND; \|\| return OR; \[\= return PO; \=\] return PC; %% static uint cf_hash(const byte *c) { uint h = 13 << 24; while (*c) h = h + (h >> 2) + (h >> 5) + ((uint) *c++ << 24); return h; } /* * IFS stack - it contains structures needed for recursive processing * of include in config files. On the top of the stack is a structure * for currently processed file. Other structures are either for * active files interrupted because of include directive (these have * fd and flex buffer) or for inactive files scheduled to be processed * later (when parent requested including of several files by wildcard * match - these do not have fd and flex buffer yet). * * FIXME: Most of these ifs and include functions are really sysdep/unix. */ static struct include_file_stack * push_ifs(struct include_file_stack *old) { struct include_file_stack *ret; ret = cfg_allocz(sizeof(struct include_file_stack)); ret->lino = 1; ret->prev = old; return ret; } static struct include_file_stack * pop_ifs(struct include_file_stack *old) { yy_delete_buffer(old->buffer); close(old->fd); return old->prev; } static void enter_ifs(struct include_file_stack *new) { if (!new->buffer) { new->fd = open(new->file_name, O_RDONLY); if (new->fd < 0) { ifs = ifs->up; cf_error("Unable to open included file %s: %m", new->file_name); } new->buffer = yy_create_buffer(NULL, YY_BUF_SIZE); } yy_switch_to_buffer(new->buffer); } /** * cf_lex_unwind - unwind lexer state during error * * cf_lex_unwind() frees the internal state on IFS stack when the lexical * analyzer is terminated by cf_error(). */ void cf_lex_unwind(void) { struct include_file_stack *n; for (n = ifs; n != ifs_head; n = n->prev) { /* Memory is freed automatically */ if (n->buffer) yy_delete_buffer(n->buffer); if (n->fd) close(n->fd); } ifs = ifs_head; } static void cf_include(char *arg, int alen) { struct include_file_stack *base_ifs = ifs; int new_depth, rv, i; char *patt; glob_t g = {}; new_depth = ifs->depth + 1; if (new_depth > MAX_INCLUDE_DEPTH) cf_error("Max include depth reached"); /* expand arg to properly handle relative filenames */ if (*arg != '/') { int dlen = strlen(ifs->file_name); char *dir = alloca(dlen + 1); patt = alloca(dlen + alen + 2); memcpy(dir, ifs->file_name, dlen + 1); sprintf(patt, "%s/%s", dirname(dir), arg); } else patt = arg; /* Skip globbing if there are no wildcards, mainly to get proper response when the included config file is missing */ if (!strpbrk(arg, "?*[")) { ifs = push_ifs(ifs); ifs->file_name = cfg_strdup(patt); ifs->depth = new_depth; ifs->up = base_ifs; enter_ifs(ifs); return; } /* Expand the pattern */ rv = glob(patt, GLOB_ERR | GLOB_NOESCAPE, NULL, &g); if (rv == GLOB_ABORTED) cf_error("Unable to match pattern %s: %m", patt); if ((rv != 0) || (g.gl_pathc <= 0)) return; /* * Now we put all found files to ifs stack in reverse order, they * will be activated and processed in order as ifs stack is popped * by pop_ifs() and enter_ifs() in check_eof(). */ for(i = g.gl_pathc - 1; i >= 0; i--) { char *fname = g.gl_pathv[i]; struct stat fs; if (stat(fname, &fs) < 0) { globfree(&g); cf_error("Unable to stat included file %s: %m", fname); } if (fs.st_mode & S_IFDIR) continue; /* Prepare new stack item */ ifs = push_ifs(ifs); ifs->file_name = cfg_strdup(fname); ifs->depth = new_depth; ifs->up = base_ifs; } globfree(&g); enter_ifs(ifs); } static int check_eof(void) { if (ifs == ifs_head) { /* EOF in main config file */ ifs->lino = 1; /* Why this? */ return 1; } ifs = pop_ifs(ifs); enter_ifs(ifs); return 0; } static struct symbol * cf_new_symbol(const byte *c) { struct symbol *s; uint l = strlen(c); if (l > SYM_MAX_LEN) cf_error("Symbol too long"); s = cfg_allocz(sizeof(struct symbol) + l + 1); *s = (struct symbol) { .scope = conf_this_scope, .class = SYM_VOID, }; strcpy(s->name, c); if (!new_config->sym_hash.data) HASH_INIT(new_config->sym_hash, new_config->pool, SYM_ORDER); HASH_INSERT2(new_config->sym_hash, SYM, new_config->pool, s); add_tail(&(new_config->symbols), &(s->n)); return s; } /** * cf_find_symbol - find a symbol by name * @cfg: specificed config * @c: symbol name * * This functions searches the symbol table in the config @cfg for a symbol of * given name. First it examines the current scope, then the second recent one * and so on until it either finds the symbol and returns a pointer to its * &symbol structure or reaches the end of the scope chain and returns %NULL to * signify no match. */ struct symbol * cf_find_symbol(const struct config *cfg, const byte *c) { struct symbol *s; if (cfg->sym_hash.data && (s = HASH_FIND(cfg->sym_hash, SYM, c, 1))) return s; /* In CLI command parsing, fallback points to the current config, otherwise it is NULL. */ if (cfg->fallback && cfg->fallback->sym_hash.data && (s = HASH_FIND(cfg->fallback->sym_hash, SYM, c, 1))) return s; return NULL; } /** * cf_get_symbol - get a symbol by name * @c: symbol name * * This functions searches the symbol table of the currently parsed config * (@new_config) for a symbol of given name. It returns either the already * existing symbol or a newly allocated undefined (%SYM_VOID) symbol if no * existing symbol is found. */ struct symbol * cf_get_symbol(const byte *c) { return cf_find_symbol(new_config, c) ?: cf_new_symbol(c); } /** * cf_localize_symbol - get the local instance of given symbol * @sym: the symbol to localize * * This functions finds the symbol that is local to current scope * for purposes of cf_define_symbol(). */ struct symbol * cf_localize_symbol(struct symbol *sym) { /* If the symbol type is void, it has been recently allocated just in this scope. */ if (!sym->class) return sym; /* If the scope is the current, it is already defined in this scope. */ if (sym->scope == conf_this_scope) cf_error("Symbol already defined"); /* Not allocated here yet, doing it now. */ return cf_new_symbol(sym->name); } struct symbol * cf_default_name(char *template, int *counter) { char buf[SYM_MAX_LEN]; struct symbol *s; char *perc = strchr(template, '%'); for(;;) { bsprintf(buf, template, ++(*counter)); s = cf_get_symbol(buf); if (s->class == SYM_VOID) return s; if (!perc) break; } cf_error("Unable to generate default name"); } static enum yytokentype cf_lex_symbol(const char *data) { /* Have we defined such a symbol? */ struct symbol *sym = cf_get_symbol(data); cf_lval.s = sym; if (sym->class != SYM_VOID) return CF_SYM_KNOWN; /* Is it a keyword? */ struct keyword *k = HASH_FIND(kw_hash, KW, data); if (k) { if (k->value > 0) return k->value; else { cf_lval.i = -k->value; return ENUM; } } /* OK, undefined symbol */ cf_lval.s = sym; return CF_SYM_UNDEFINED; } static void cf_lex_init_kh(void) { HASH_INIT(kw_hash, &root_pool, KW_ORDER); struct keyword *k; for (k=keyword_list; k->name; k++) HASH_INSERT(kw_hash, KW, k); } /** * cf_lex_init - initialize the lexer * @is_cli: true if we're going to parse CLI command, false for configuration * @c: configuration structure * * cf_lex_init() initializes the lexical analyzer and prepares it for * parsing of a new input. */ void cf_lex_init(int is_cli, struct config *c) { if (!kw_hash.data) cf_lex_init_kh(); ifs_head = ifs = push_ifs(NULL); if (!is_cli) { ifs->file_name = c->file_name; ifs->fd = c->file_fd; ifs->depth = 1; } yyrestart(NULL); ifs->buffer = YY_CURRENT_BUFFER; if (is_cli) BEGIN(CLI); else BEGIN(INITIAL); c->root_scope = cfg_allocz(sizeof(struct sym_scope)); conf_this_scope = c->root_scope; conf_this_scope->active = 1; } /** * cf_push_scope - enter new scope * @sym: symbol representing scope name * * If we want to enter a new scope to process declarations inside * a nested block, we can just call cf_push_scope() to push a new * scope onto the scope stack which will cause all new symbols to be * defined in this scope and all existing symbols to be sought for * in all scopes stored on the stack. */ void cf_push_scope(struct symbol *sym) { struct sym_scope *s = cfg_allocz(sizeof(struct sym_scope)); s->next = conf_this_scope; conf_this_scope = s; s->active = 1; s->name = sym; s->slots = 0; } /** * cf_pop_scope - leave a scope * * cf_pop_scope() pops the topmost scope from the scope stack, * leaving all its symbols in the symbol table, but making them * invisible to the rest of the config. */ void cf_pop_scope(void) { conf_this_scope->active = 0; conf_this_scope = conf_this_scope->next; ASSERT(conf_this_scope); } /** * cf_symbol_class_name - get name of a symbol class * @sym: symbol * * This function returns a string representing the class * of the given symbol. */ char * cf_symbol_class_name(struct symbol *sym) { switch (sym->class) { case SYM_VOID: return "undefined"; case SYM_PROTO: return "protocol"; case SYM_TEMPLATE: return "protocol template"; case SYM_FUNCTION: return "function"; case SYM_FILTER: return "filter"; case SYM_TABLE: return "routing table"; case SYM_ATTRIBUTE: return "custom attribute"; case SYM_CONSTANT_RANGE: return "constant"; case SYM_VARIABLE_RANGE: return "variable"; default: return "unknown type"; } } /** * DOC: Parser * * Both the configuration and CLI commands are analyzed using a syntax * driven parser generated by the |bison| tool from a grammar which * is constructed from information gathered from grammar snippets by * the |gen_parser.m4| script. * * Grammar snippets are files (usually with extension |.Y|) contributed * by various BIRD modules in order to provide information about syntax of their * configuration and their CLI commands. Each snipped consists of several * sections, each of them starting with a special keyword: |CF_HDR| for * a list of |#include| directives needed by the C code, |CF_DEFINES| * for a list of C declarations, |CF_DECLS| for |bison| declarations * including keyword definitions specified as |CF_KEYWORDS|, |CF_GRAMMAR| * for the grammar rules, |CF_CODE| for auxiliary C code and finally * |CF_END| at the end of the snippet. * * To create references between the snippets, it's possible to define * multi-part rules by utilizing the |CF_ADDTO| macro which adds a new * alternative to a multi-part rule. * * CLI commands are defined using a |CF_CLI| macro. Its parameters are: * the list of keywords determining the command, the list of parameters, * help text for the parameters and help text for the command. * * Values of |enum| filter types can be defined using |CF_ENUM| with * the following parameters: name of filter type, prefix common for all * literals of this type and names of all the possible values. */ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/conf/Makefile����������������������������������������������������������������������������0000664�0001750�0001750�00000002000�14025744326�013741� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������src := cf-parse.tab.c cf-lex.c conf.c obj := $(src-o-files) $(all-daemon) tests_objs := $(tests_objs) $(src-o-files) ifdef DEBUG BISON_DEBUG=-t #FLEX_DEBUG=-d endif $(o)cf-parse.y: $(s)gen_parser.m4 $(o)keywords.h: $(s)gen_keywords.m4 $(o)commands.h: $(s)gen_commands.m4 $(conf-y-targets): $(s)confbase.Y $(s)flowspec.Y $(M4) $(M4FLAGS) -P $(if $(word 2,$(filter %.m4,$^)),$(error "Too many M4 scripts for one target"),$(filter %.m4,$^)) $(filter %.Y,$^) >$@ $(o)cf-parse.tab.h: $(o)cf-parse.tab.c $(o)cf-parse.tab.c: $(o)cf-parse.y $(BISON) $(BISON_DEBUG) $(BISONFLAGS) -dv -pcf_ -b $(@:.tab.c=) $< $(o)cf-lex.c: $(s)cf-lex.l $(FLEX) $(FLEX_DEBUG) -f -s -B -8 -Pcf_ -o$@ $< $(o)cf-lex.o: CFLAGS+=-Wno-sign-compare -Wno-unused-function prepare: $(o)keywords.h $(o)commands.h $(o)cf-parse.tab.h $(addprefix $(o), cf-parse.y keywords.h commands.h cf-parse.tab.h cf-parse.tab.c cf-lex.c): $(objdir)/.dir-stamp $(call clean,cf-parse.tab.h cf-parse.tab.c cf-parse.y keywords.h commands.h cf-lex.c cf-parse.output) bird-2.0.8/conf/Doc���������������������������������������������������������������������������������0000664�0001750�0001750�00000000044�14025744326�012737� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������H Configuration S conf.c S cf-lex.l ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/����������������������������������������������������������������������������������0000775�0001750�0001750�00000000000�14025744326�012642� 5����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/util.c����������������������������������������������������������������������������0000664�0001750�0001750�00000001744�14025744326�013771� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client -- Utility Functions * * (c) 1999--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include "nest/bird.h" #include "lib/string.h" #include "client/client.h" /* Client versions of logging functions */ static void vlog(const char *msg, va_list args) { char buf[1024]; int n = vsnprintf(buf, sizeof(buf), msg, args); if (n < 0) snprintf(buf, sizeof(buf), "???"); else if (n >= (int) sizeof(buf)) snprintf(buf + sizeof(buf) - 100, 100, " ... <too long>"); fputs(buf, stderr); fputc('\n', stderr); } void bug(const char *msg, ...) { va_list args; va_start(args, msg); cleanup(); fputs("Internal error: ", stderr); vlog(msg, args); vfprintf(stderr, msg, args); va_end(args); exit(1); } void die(const char *msg, ...) { va_list args; va_start(args, msg); cleanup(); vlog(msg, args); va_end(args); exit(1); } ����������������������������bird-2.0.8/client/commands.c������������������������������������������������������������������������0000664�0001750�0001750�00000013631�14025744326�014613� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client -- Command Handling * * (c) 1999--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" #include "client/client.h" struct cmd_info { char *command; char *args; char *help; int is_real_cmd; }; static struct cmd_info command_table[] = { #include "conf/commands.h" }; struct cmd_node { struct cmd_node *sibling, *son, **plastson; struct cmd_info *cmd, *help; int len; signed char prio; char token[1]; }; static struct cmd_node cmd_root; #define isspace_(X) isspace((unsigned char) (X)) void cmd_build_tree(void) { uint i; cmd_root.plastson = &cmd_root.son; for(i=0; i<ARRAY_SIZE(command_table); i++) { struct cmd_info *cmd = &command_table[i]; struct cmd_node *old, *new; char *c = cmd->command; old = &cmd_root; while (*c) { char *d = c; while (*c && !isspace_(*c)) c++; for(new=old->son; new; new=new->sibling) if (new->len == c-d && !memcmp(new->token, d, c-d)) break; if (!new) { int size = sizeof(struct cmd_node) + c-d; new = malloc(size); bzero(new, size); *old->plastson = new; old->plastson = &new->sibling; new->plastson = &new->son; new->len = c-d; memcpy(new->token, d, c-d); new->prio = (new->len == 3 && (!memcmp(new->token, "roa", 3) || !memcmp(new->token, "rip", 3))) ? 0 : 1; /* Hack */ } old = new; while (isspace_(*c)) c++; } if (cmd->is_real_cmd) old->cmd = cmd; else old->help = cmd; } } static void cmd_do_display_help(struct cmd_info *c) { char buf[strlen(c->command) + strlen(c->args) + 4]; sprintf(buf, "%s %s", c->command, c->args); printf("%-45s %s\n", buf, c->help); } static void cmd_display_help(struct cmd_info *c1, struct cmd_info *c2) { if (c1) cmd_do_display_help(c1); else if (c2) cmd_do_display_help(c2); } static struct cmd_node * cmd_find_abbrev(struct cmd_node *root, char *cmd, int len, int *pambiguous) { struct cmd_node *m, *best = NULL, *best2 = NULL; *pambiguous = 0; for(m=root->son; m; m=m->sibling) { if (m->len == len && !memcmp(m->token, cmd, len)) return m; if (m->len > len && !memcmp(m->token, cmd, len)) { if (best && best->prio > m->prio) continue; if (best && best->prio == m->prio) best2 = best; best = m; } } if (best2) { *pambiguous = 1; return NULL; } return best; } static void cmd_list_ambiguous(struct cmd_node *root, char *cmd, int len) { struct cmd_node *m; for(m=root->son; m; m=m->sibling) if (m->len > len && !memcmp(m->token, cmd, len)) cmd_display_help(m->help, m->cmd); } void cmd_help(char *cmd, int len) { char *end = cmd + len; struct cmd_node *n, *m; char *z; int ambig; n = &cmd_root; while (cmd < end) { if (isspace_(*cmd)) { cmd++; continue; } z = cmd; while (cmd < end && !isspace_(*cmd)) cmd++; m = cmd_find_abbrev(n, z, cmd-z, &ambig); if (ambig) { cmd_list_ambiguous(n, z, cmd-z); return; } if (!m) break; n = m; } cmd_display_help(n->cmd, NULL); for (m=n->son; m; m=m->sibling) cmd_display_help(m->help, m->cmd); } static int cmd_find_common_match(struct cmd_node *root, char *cmd, int len, int *pcount, char *buf) { struct cmd_node *m; int best, best_prio, i; *pcount = 0; best = -1; best_prio = -1; for(m=root->son; m; m=m->sibling) { if (m->len < len || memcmp(m->token, cmd, len)) continue; if (best_prio > m->prio) continue; if (best_prio < m->prio) { *pcount = 0; best = -1; } (*pcount)++; if (best < 0) { strcpy(buf, m->token + len); best = m->len - len; best_prio = m->prio; } else { i = 0; while (i < best && i < m->len - len && buf[i] == m->token[len+i]) i++; best = i; } } return best; } int cmd_complete(char *cmd, int len, char *buf, int again) { char *start = cmd; char *end = cmd + len; char *fin; struct cmd_node *n, *m; char *z; int ambig, cnt = 0, common; /* Find the last word we want to complete */ for(fin=end; fin > start && !isspace_(fin[-1]); fin--) ; /* Find the context */ n = &cmd_root; while (cmd < fin && n->son) { if (isspace_(*cmd)) { cmd++; continue; } z = cmd; while (cmd < fin && !isspace_(*cmd)) cmd++; m = cmd_find_abbrev(n, z, cmd-z, &ambig); if (ambig) { if (!again) return -1; input_start_list(); cmd_list_ambiguous(n, z, cmd-z); input_stop_list(); return 0; } if (!m) return -1; n = m; } /* Completion of parameters is not yet supported */ if (!n->son) return -1; /* We know the context, let's try to complete */ common = cmd_find_common_match(n, fin, end-fin, &cnt, buf); if (!cnt) return -1; if (cnt == 1) { buf[common++] = ' '; buf[common] = 0; return 1; } if (common > 0) { buf[common] = 0; return 1; } if (!again) return -1; input_start_list(); cmd_list_ambiguous(n, fin, end-fin); input_stop_list(); return 0; } char * cmd_expand(char *cmd) { struct cmd_node *n, *m; char *c, *b, *args; int ambig; args = c = cmd; n = &cmd_root; while (*c) { if (isspace_(*c)) { c++; continue; } b = c; while (*c && !isspace_(*c)) c++; m = cmd_find_abbrev(n, b, c-b, &ambig); if (!m) { if (!ambig) break; puts("Ambiguous command, possible expansions are:"); cmd_list_ambiguous(n, b, c-b); return NULL; } args = c; n = m; } if (!n->cmd) { puts("No such command. Press `?' for help."); return NULL; } b = malloc(strlen(n->cmd->command) + strlen(args) + 1); sprintf(b, "%s%s", n->cmd->command, args); return b; } �������������������������������������������������������������������������������������������������������bird-2.0.8/client/cmds.Y����������������������������������������������������������������������������0000664�0001750�0001750�00000000451�14025744326�013722� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# # BIRD -- Internal Commands Of The Client # # (c) 2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz> # # Can be freely distributed and used under the terms of the GNU GPL. # CF_CLI(QUIT,,, [[Quit the client]]) CF_CLI(EXIT,,, [[Exit the client]]) CF_CLI(HELP,,, [[Description of the help system]]) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/client.h��������������������������������������������������������������������������0000664�0001750�0001750�00000001366�14025744326�014277� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client * * (c) 1999--2000 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ extern int init, busy, interactive; extern int term_lns, term_cls; /* birdc.c / birdcl.c */ void input_start_list(void); void input_stop_list(void); void input_init(void); void input_notify(int prompt); void input_read(void); void more_begin(void); void more_end(void); void cleanup(void); /* commands.c */ void cmd_build_tree(void); void cmd_help(char *cmd, int len); int cmd_complete(char *cmd, int len, char *buf, int again); char *cmd_expand(char *cmd); /* client.c */ void submit_command(char *cmd_raw); /* die() with system error messages */ #define DIE(x, y...) die(x ": %s", ##y, strerror(errno)) ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/client.c��������������������������������������������������������������������������0000664�0001750�0001750�00000020015�14025744326�014262� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client * * (c) 1999--2004 Martin Mares <mj@ucw.cz> * (c) 2013 Tomas Hlavacek <tmshlvck@gmail.com> * * Can be freely distributed and used under the terms of the GNU GPL. */ /** * DOC: BIRD client * * There are two variants of BIRD client: regular and light. regular * variant depends on readline and ncurses libraries, while light * variant uses just libc. Most of the code and the main() is common * for both variants (in client.c file) and just a few functions are * different (in birdc.c for regular and birdcl.c for light). Two * binaries are generated by linking common object files like client.o * (which is compiled from client.c just once) with either birdc.o or * birdcl.o for each variant. */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <sys/select.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" #include "client/client.h" #include "sysdep/unix/unix.h" #define SERVER_READ_BUF_LEN 4096 static char *opt_list = "s:vrl"; static int verbose, restricted, once; static char *init_cmd; static char *server_path = PATH_CONTROL_SOCKET; static int server_fd; static byte server_read_buf[SERVER_READ_BUF_LEN]; static byte *server_read_pos = server_read_buf; int init = 1; /* During intial sequence */ int busy = 1; /* Executing BIRD command */ int interactive; /* Whether stdin is terminal */ static int num_lines, skip_input; int term_lns, term_cls; /*** Parsing of arguments ***/ static void usage(char *name) { fprintf(stderr, "Usage: %s [-s <control-socket>] [-v] [-r] [-l]\n", name); exit(1); } static void parse_args(int argc, char **argv) { int server_changed = 0; int c; while ((c = getopt(argc, argv, opt_list)) >= 0) switch (c) { case 's': server_path = optarg; server_changed = 1; break; case 'v': verbose++; break; case 'r': restricted = 1; break; case 'l': if (!server_changed) server_path = xbasename(server_path); break; default: usage(argv[0]); } /* If some arguments are not options, we take it as commands */ if (optind < argc) { char *tmp; int i; int len = 0; for (i = optind; i < argc; i++) len += strlen(argv[i]) + 1; tmp = init_cmd = malloc(len); for (i = optind; i < argc; i++) { strcpy(tmp, argv[i]); tmp += strlen(tmp); *tmp++ = ' '; } tmp[-1] = 0; once = 1; interactive = 0; } } /*** Input ***/ static void server_send(char *cmd); static int handle_internal_command(char *cmd) { if (!strncmp(cmd, "exit", 4) || !strncmp(cmd, "quit", 4)) { cleanup(); exit(0); } if (!strncmp(cmd, "help", 4)) { puts("Press `?' for context sensitive help."); return 1; } return 0; } static void submit_server_command(char *cmd) { busy = 1; num_lines = 2; server_send(cmd); } static inline void submit_init_command(char *cmd_raw) { char *cmd = cmd_expand(cmd_raw); if (!cmd) { cleanup(); exit(0); } submit_server_command(cmd); free(cmd); } void submit_command(char *cmd_raw) { char *cmd = cmd_expand(cmd_raw); if (!cmd) return; if (!handle_internal_command(cmd)) submit_server_command(cmd); free(cmd); } static void init_commands(void) { if (restricted) { submit_server_command("restrict"); restricted = 0; return; } if (init_cmd) { /* First transition - client received hello from BIRD and there is waiting initial command */ submit_init_command(init_cmd); init_cmd = NULL; return; } if (once) { /* Initial command is finished and we want to exit */ cleanup(); exit(0); } input_init(); term_lns = (term_lns > 0) ? term_lns : 25; term_cls = (term_cls > 0) ? term_cls : 80; init = 0; } /*** Output ***/ void more(void) { more_begin(); printf("--More--\015"); fflush(stdout); redo: switch (getchar()) { case ' ': num_lines = 2; break; case '\n': case '\r': num_lines--; break; case 'q': skip_input = 1; break; default: goto redo; } printf(" \015"); fflush(stdout); more_end(); } /*** Communication with server ***/ static void server_connect(void) { struct sockaddr_un sa; server_fd = socket(AF_UNIX, SOCK_STREAM, 0); if (server_fd < 0) DIE("Cannot create socket"); if (strlen(server_path) >= sizeof(sa.sun_path)) die("server_connect: path too long"); bzero(&sa, sizeof(sa)); sa.sun_family = AF_UNIX; strcpy(sa.sun_path, server_path); if (connect(server_fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) < 0) DIE("Unable to connect to server control socket (%s)", server_path); if (fcntl(server_fd, F_SETFL, O_NONBLOCK) < 0) DIE("fcntl"); } #define PRINTF(LEN, PARGS...) do { if (!skip_input) len = printf(PARGS); } while(0) static void server_got_reply(char *x) { int code; int len = 0; if (*x == '+') /* Async reply */ PRINTF(len, ">>> %s\n", x+1); else if (x[0] == ' ') /* Continuation */ PRINTF(len, "%s%s\n", verbose ? " " : "", x+1); else if (strlen(x) > 4 && sscanf(x, "%d", &code) == 1 && code >= 0 && code < 10000 && (x[4] == ' ' || x[4] == '-')) { if (code) PRINTF(len, "%s\n", verbose ? x : x+5); if (x[4] == ' ') { busy = 0; skip_input = 0; return; } } else PRINTF(len, "??? <%s>\n", x); if (interactive && busy && !skip_input && !init && (len > 0)) { num_lines += (len + term_cls - 1) / term_cls; /* Divide and round up */ if (num_lines >= term_lns) more(); } } static void server_read(void) { int c; byte *start, *p; redo: c = read(server_fd, server_read_pos, server_read_buf + sizeof(server_read_buf) - server_read_pos); if (!c) die("Connection closed by server"); if (c < 0) { if (errno == EINTR) goto redo; else DIE("Server read error"); } start = server_read_buf; p = server_read_pos; server_read_pos += c; while (p < server_read_pos) if (*p++ == '\n') { p[-1] = 0; server_got_reply(start); start = p; } if (start != server_read_buf) { int l = server_read_pos - start; memmove(server_read_buf, start, l); server_read_pos = server_read_buf + l; } else if (server_read_pos == server_read_buf + sizeof(server_read_buf)) { strcpy(server_read_buf, "?<too-long>"); server_read_pos = server_read_buf + 11; } } static void select_loop(void) { int rv; while (1) { if (init && !busy) init_commands(); if (!init) input_notify(!busy); fd_set select_fds; FD_ZERO(&select_fds); FD_SET(server_fd, &select_fds); if (!busy) FD_SET(0, &select_fds); rv = select(server_fd+1, &select_fds, NULL, NULL, NULL); if (rv < 0) { if (errno == EINTR) continue; else DIE("select"); } if (FD_ISSET(0, &select_fds)) { input_read(); continue; } if (FD_ISSET(server_fd, &select_fds)) { server_read(); continue; } } } static void wait_for_write(int fd) { while (1) { int rv; fd_set set; FD_ZERO(&set); FD_SET(fd, &set); rv = select(fd+1, NULL, &set, NULL, NULL); if (rv < 0) { if (errno == EINTR) continue; else DIE("select"); } if (FD_ISSET(server_fd, &set)) return; } } static void server_send(char *cmd) { int l = strlen(cmd); byte *z = alloca(l + 1); memcpy(z, cmd, l); z[l++] = '\n'; while (l) { int cnt = write(server_fd, z, l); if (cnt < 0) { if (errno == EAGAIN) wait_for_write(server_fd); else if (errno == EINTR) continue; else DIE("Server write error"); } else { l -= cnt; z += cnt; } } } int main(int argc, char **argv) { interactive = isatty(0); parse_args(argc, argv); cmd_build_tree(); server_connect(); select_loop(); return 0; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/birdcl.c��������������������������������������������������������������������������0000664�0001750�0001750�00000004615�14025744326�014253� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client - Light variant I/O * * (c) 1999--2004 Martin Mares <mj@ucw.cz> * (c) 2013 Tomas Hlavacek <tomas.hlavacek@nic.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <termios.h> #include <errno.h> #include <sys/ioctl.h> #include <signal.h> #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" #include "client/client.h" #include "sysdep/unix/unix.h" #define INPUT_BUF_LEN 2048 struct termios tty_save; void input_start_list(void) { /* Empty in non-ncurses version. */ } void input_stop_list(void) { /* Empty in non-ncurses version. */ } void input_notify(int prompt) { /* No ncurses -> no status to reveal/hide, print prompt manually. */ if (!prompt) return; printf("bird> "); fflush(stdout); } static int lastnb(char *str, int i) { while (i--) if ((str[i] != ' ') && (str[i] != '\t')) return str[i]; return 0; } void input_read(void) { char buf[INPUT_BUF_LEN]; if ((fgets(buf, INPUT_BUF_LEN, stdin) == NULL) || (buf[0] == 0)) { putchar('\n'); cleanup(); exit(0); } int l = strlen(buf); if ((l+1) == INPUT_BUF_LEN) { printf("Input too long.\n"); return; } if (buf[l-1] == '\n') buf[--l] = '\0'; if (!interactive) printf("%s\n", buf); if (l == 0) return; if (lastnb(buf, l) == '?') { cmd_help(buf, strlen(buf)); return; } submit_command(buf); } static struct termios stored_tty; static int more_active = 0; void more_begin(void) { static struct termios tty; tty = stored_tty; tty.c_lflag &= (~ECHO); tty.c_lflag &= (~ICANON); if (tcsetattr (0, TCSANOW, &tty) < 0) DIE("tcsetattr"); more_active = 1; } void more_end(void) { more_active = 0; if (tcsetattr (0, TCSANOW, &stored_tty) < 0) DIE("tcsetattr"); } static void sig_handler(int signal UNUSED) { cleanup(); exit(0); } void input_init(void) { if (!interactive) return; if (tcgetattr(0, &stored_tty) < 0) DIE("tcgetattr"); if (signal(SIGINT, sig_handler) == SIG_IGN) signal(SIGINT, SIG_IGN); if (signal(SIGTERM, sig_handler) == SIG_IGN) signal(SIGTERM, SIG_IGN); struct winsize tws; if (ioctl(0, TIOCGWINSZ, &tws) == 0) { term_lns = tws.ws_row; term_cls = tws.ws_col; } } void cleanup(void) { if (more_active) more_end(); } �������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/birdc.c���������������������������������������������������������������������������0000664�0001750�0001750�00000010320�14025744326�014065� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * BIRD Client - Readline variant I/O * * (c) 1999--2004 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <termios.h> #include <readline/readline.h> #include <readline/history.h> #include <curses.h> #include "nest/bird.h" #include "lib/resource.h" #include "lib/string.h" #include "client/client.h" static int input_hidden_end; static int prompt_active; /*** Input ***/ /* HACK: libreadline internals we need to access */ extern int _rl_vis_botlin; extern void _rl_move_vert(int); #define HISTORY "/.birdc_history" static char *history_file; static void add_history_dedup(char *cmd) { /* Add history line if it differs from the last one */ HIST_ENTRY *he = history_get(history_length); if (!he || strcmp(he->line, cmd)) add_history(cmd); } static void input_got_line(char *cmd_buffer) { if (!cmd_buffer) { cleanup(); exit(0); } if (cmd_buffer[0]) { add_history_dedup(cmd_buffer); submit_command(cmd_buffer); } free(cmd_buffer); } void input_start_list(void) { /* Leave the currently edited line and make space for listing */ _rl_move_vert(_rl_vis_botlin); #ifdef HAVE_RL_CRLF rl_crlf(); #endif } void input_stop_list(void) { /* Reprint the currently edited line after listing */ rl_on_new_line(); rl_redisplay(); } static int input_complete(int arg UNUSED, int key UNUSED) { static int complete_flag; char buf[256]; if (rl_last_func != input_complete) complete_flag = 0; switch (cmd_complete(rl_line_buffer, rl_point, buf, complete_flag)) { case 0: complete_flag = 1; break; case 1: rl_insert_text(buf); break; default: complete_flag = 1; #ifdef HAVE_RL_DING rl_ding(); #endif } return 0; } static int input_help(int arg, int key UNUSED) { int i, in_string, in_bracket; if (arg != 1) return rl_insert(arg, '?'); in_string = in_bracket = 0; for (i = 0; i < rl_point; i++) { if (rl_line_buffer[i] == '"') in_string = ! in_string; else if (! in_string) { if (rl_line_buffer[i] == '[') in_bracket++; else if (rl_line_buffer[i] == ']') in_bracket--; } } /* `?' inside string or path -> insert */ if (in_string || in_bracket) return rl_insert(1, '?'); rl_begin_undo_group(); /* HACK: We want to display `?' at point position */ rl_insert_text("?"); rl_redisplay(); rl_end_undo_group(); input_start_list(); cmd_help(rl_line_buffer, rl_point); rl_undo_command(1, 0); input_stop_list(); return 0; } void history_init(void) { const char *homedir = getenv("HOME"); if (!homedir) homedir = "."; history_file = malloc(strlen(homedir) + sizeof(HISTORY)); if (!history_file) die("couldn't alloc enough memory for history file name"); sprintf(history_file, "%s%s", homedir, HISTORY); read_history(history_file); } void input_init(void) { if (interactive) history_init(); rl_readline_name = "birdc"; rl_add_defun("bird-complete", input_complete, '\t'); rl_add_defun("bird-help", input_help, '?'); rl_callback_handler_install("bird> ", input_got_line); // rl_get_screen_size(); term_lns = LINES; term_cls = COLS; prompt_active = 1; // readline library does strange things when stdin is nonblocking. // if (fcntl(0, F_SETFL, O_NONBLOCK) < 0) // DIE("fcntl"); } static void input_reveal(void) { /* need this, otherwise some lib seems to eat pending output when the prompt is displayed */ fflush(stdout); tcdrain(STDOUT_FILENO); rl_end = input_hidden_end; rl_expand_prompt("bird> "); rl_forced_update_display(); prompt_active = 1; } static void input_hide(void) { input_hidden_end = rl_end; rl_end = 0; rl_expand_prompt(""); rl_redisplay(); prompt_active = 0; } void input_notify(int prompt) { if (prompt == prompt_active) return; if (prompt) input_reveal(); else input_hide(); } void input_read(void) { rl_callback_read_char(); } void more_begin(void) { } void more_end(void) { } void cleanup(void) { if (init) return; input_hide(); if (interactive) write_history(history_file); rl_callback_handler_remove(); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/Makefile��������������������������������������������������������������������������0000664�0001750�0001750�00000000313�14025744326�014277� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������src := commands.c util.c client.c obj := $(src-o-files) $(all-client) $(conf-y-targets): $(s)cmds.Y $(exedir)/birdc: $(o)birdc.o $(exedir)/birdc: LIBS += $(CLIENT_LIBS) $(exedir)/birdcl: $(o)birdcl.o ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/client/Doc�������������������������������������������������������������������������������0000664�0001750�0001750�00000000037�14025744326�013272� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������H Client S client.c commands.c �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/bird-gdb.py������������������������������������������������������������������������������0000664�0001750�0001750�00000012334�14025744326�013413� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������class BIRDPrinter: def __init__(self, val): self.val = val @classmethod def lookup(cls, val): if val.type.code != cls.typeCode: return None if val.type.tag != cls.typeTag: return None return cls(val) class BIRDFValPrinter(BIRDPrinter): "Print BIRD\s struct f_val" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_val" codemap = { "T_INT": "i", "T_BOOL": "i", "T_PAIR": "i", "T_QUAD": "i", "T_ENUM_RTS": "i", "T_ENUM_BGP_ORIGIN": "i", "T_ENUM_SCOPE": "i", "T_ENUM_RTC": "i", "T_ENUM_RTD": "i", "T_ENUM_ROA": "i", "T_ENUM_NETTYPE": "i", "T_ENUM_RA_PREFERENCE": "i", "T_ENUM_AF": "i", "T_IP": "ip", "T_NET": "net", "T_STRING": "s", "T_PATH_MASK": "path_mask", "T_PATH": "ad", "T_CLIST": "ad", "T_EC": "ec", "T_ECLIST": "ad", "T_LC": "lc", "T_LCLIST": "ad", "T_RD": "ec", "T_PATH_MASK_ITEM": "pmi", "T_SET": "t", "T_PREFIX_SET": "ti", } def to_string(self): code = self.val['type'] if code.type.code != gdb.TYPE_CODE_ENUM or code.type.tag != "f_type": raise Exception("Strange 'type' element in f_val") if str(code) == "T_VOID": return "T_VOID" else: return "(%(c)s) %(v)s" % { "c": code, "v": self.val['val'][self.codemap[str(code)]] } def display_hint(self): return "map" class BIRDFValStackPrinter(BIRDPrinter): "Print BIRD's struct f_val_stack" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_val_stack" def to_string(self): cnt = self.val['cnt'] return ("Value stack (%(cnt)d):\n\t" % { "cnt": cnt }) + \ "\n\t".join([ (".val[%(n) 3d] = " % { "n": n}) + str(self.val['val'][n]) for n in range(cnt-1, -1, -1) ]) def display_hint(self): return "map" class BIRDFInstPrinter(BIRDPrinter): "Print BIRD's struct f_inst" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_inst" def to_string(self): code = self.val['fi_code'] if str(code) == "FI_NOP": return str(code) + ": " + str(self.val.cast(gdb.lookup_type("const char [%(siz)d]" % { "siz": self.val.type.sizeof }))) return "%(code)s:\t%(lineno) 6dL\t%(size)6dS\tnext = %(next)s: .i_%(code)s = %(union)s" % { "code": str(code), "lineno": self.val['lineno'], "size": self.val['size'], "next": str(self.val['next']), "union": str(self.val['i_' + str(code)]) } # def children(self): # children iterator def display_hint(self): return "map" class BIRDFLineItemPrinter(BIRDPrinter): "Print BIRD's struct f_line_item" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_line_item" def to_string(self): code = self.val['fi_code'] if str(code) == "FI_NOP": return str(code) + ": " + str(self.val.cast(gdb.lookup_type("const char [%(siz)d]" % { "siz": self.val.type.sizeof }))) return "%(code)s:\t%(lineno) 6dL\t%(flags)2dF: .i_%(code)s = %(union)s" % { "code": str(code), "lineno": self.val['lineno'], "flags": self.val['flags'], "union": str(self.val['i_' + str(code)]) } class BIRDFLinePrinter(BIRDPrinter): "Print BIRD's struct f_line" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_line" def to_string(self): cnt = self.val['len'] return ("FLine (%(cnt)d, args=%(args)d): " % { "cnt": cnt, "args" : self.val['args'] } + \ ", ".join([ ".items[%(n) 3d] = %(code)s" % { "n": n, "code": str(self.val['items'][n]['fi_code']), } if n % 8 == 0 else str(self.val['items'][n]['fi_code']) for n in range(cnt)])) class BIRDFExecStackPrinter(BIRDPrinter): "Print BIRD's struct f_exec_stack" typeCode = gdb.TYPE_CODE_STRUCT typeTag = "f_exec_stack" def to_string(self): cnt = self.val['cnt'] return ("Exec stack (%(cnt)d):\n\t" % { "cnt": cnt }) + \ "\n\t".join([ ".item[%(n) 3d] = %(retflag)d V%(ventry) 3d P%(pos) 4d %(line)s" % { "retflag": self.val['item'][n]['emask'], "ventry": self.val['item'][n]['ventry'], "pos": self.val['item'][n]['pos'], "line": str(self.val['item'][n]['line'].dereference()), "n": n } for n in range(cnt-1, -1, -1) ]) def register_printers(objfile): objfile.pretty_printers.append(BIRDFInstPrinter.lookup) objfile.pretty_printers.append(BIRDFValPrinter.lookup) objfile.pretty_printers.append(BIRDFValStackPrinter.lookup) objfile.pretty_printers.append(BIRDFLineItemPrinter.lookup) objfile.pretty_printers.append(BIRDFLinePrinter.lookup) objfile.pretty_printers.append(BIRDFExecStackPrinter.lookup) register_printers(gdb.current_objfile()) print("BIRD pretty printers loaded OK.") ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/aclocal.m4�������������������������������������������������������������������������������0000664�0001750�0001750�00000010517�14025744326�013230� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������dnl ** Additional Autoconf tests for BIRD configure script dnl ** (c) 1999 Martin Mares <mj@ucw.cz> AC_DEFUN([BIRD_CHECK_THREAD_LOCAL], [ AC_CACHE_CHECK( [whether _Thread_local is known], [bird_cv_thread_local], AC_COMPILE_IFELSE([ AC_LANG_PROGRAM( [ _Thread_local static int x = 42; ], [] ) ], [bird_cv_thread_local=yes], [bird_cv_thread_local=no] ) ) ]) AC_DEFUN([BIRD_CHECK_PTHREADS], [ bird_tmp_cflags="$CFLAGS" CFLAGS="$CFLAGS -pthread" AC_CACHE_CHECK( [whether POSIX threads are available], [bird_cv_lib_pthreads], [ AC_LINK_IFELSE( [ AC_LANG_PROGRAM( [ #include <pthread.h> ], [ pthread_t pt; pthread_create(&pt, NULL, NULL, NULL); pthread_spinlock_t lock; pthread_spin_lock(&lock); ] ) ], [bird_cv_lib_pthreads=yes], [bird_cv_lib_pthreads=no] ) ] ) CFLAGS="$bird_tmp_cflags" ]) AC_DEFUN([BIRD_CHECK_MPLS_KERNEL], [ AC_CACHE_CHECK( [for Linux MPLS headers], [bird_cv_mpls_kernel], [ AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM( [ #include <linux/lwtunnel.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <sys/socket.h> void t(int arg); ], [ t(AF_MPLS); t(RTA_VIA); t(RTA_NEWDST); t(RTA_ENCAP_TYPE); t(RTA_ENCAP); struct rtvia rtvia; t(LWTUNNEL_ENCAP_MPLS); ] ) ], [bird_cv_mpls_kernel=yes], [bird_cv_mpls_kernel=no] ) ] ) ]) AC_DEFUN([BIRD_CHECK_ANDROID_GLOB], [ AC_CACHE_CHECK( [for glob.h], [bird_cv_lib_glob], AC_LINK_IFELSE([ AC_LANG_PROGRAM( [ #include <glob.h> #include <stdlib.h> ], [ glob(NULL, 0, NULL, NULL); ] ) ], [bird_cv_lib_glob=yes], [ bird_tmp_libs="$LIBS" LIBS="$LIBS -landroid-glob" AC_LINK_IFELSE([ AC_LANG_PROGRAM( [ #include <glob.h> #include <stdlib.h> ], [ glob(NULL, 0, NULL, NULL); ] ) ], [bird_cv_lib_glob=-landroid-glob], [bird_cv_lib_glob=no] ) LIBS="$bird_tmp_libs" ] ) ) ]) AC_DEFUN([BIRD_CHECK_ANDROID_LOG], [ AC_CACHE_CHECK( [for syslog lib flags], [bird_cv_lib_log], AC_LINK_IFELSE([ AC_LANG_PROGRAM( [ #include <sys/syslog.h> ], [ syslog(0, ""); ] ) ], [bird_cv_lib_log=yes], [ bird_tmp_libs="$LIBS" LIBS="$LIBS -llog" AC_LINK_IFELSE([ AC_LANG_PROGRAM( [ #include <sys/syslog.h> ], [ syslog(0, ""); ] ) ], [bird_cv_lib_log=-llog], [bird_cv_lib_log=no] ) LIBS="$bird_tmp_libs" ] ) ) ]) AC_DEFUN([BIRD_CHECK_LTO], [ bird_tmp_cflags="$CFLAGS" bird_tmp_ldflags="$LDFLAGS" CFLAGS="-flto" LDFLAGS="-flto=4" AC_CACHE_CHECK( [whether link time optimizer is available], [bird_cv_c_lto], [ AC_LINK_IFELSE( [AC_LANG_PROGRAM()], [bird_cv_c_lto=yes], [bird_cv_c_lto=no] ) ] ) CFLAGS="$bird_tmp_cflags" LDFLAGS="$bird_tmp_ldflags" ]) AC_DEFUN([BIRD_CHECK_GCC_OPTION], [ bird_tmp_cflags="$CFLAGS" CFLAGS="$3 $2" AC_CACHE_CHECK( [whether CC supports $2], [$1], [ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM()], [$1=yes], [$1=no] ) ] ) CFLAGS="$bird_tmp_cflags" ]) AC_DEFUN([BIRD_ADD_GCC_OPTION], [ if test "$$1" = yes ; then CFLAGS="$CFLAGS $2" fi ]) # BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE]) # copied from autoconf internal _AC_PATH_PROG_FLAVOR_GNU AC_DEFUN([BIRD_CHECK_PROG_FLAVOR_GNU], [ # Check for GNU $1 case `"$1" --version 2>&1` in *GNU*) $2 ;; m4_ifval([$3], [*) $3 ;; ] ) esac ]) AC_DEFUN([BIRD_CHECK_BISON_VERSION], [ $1=`bison --version | ( read line; echo ${line##* } )` case "$$1" in 1.* | 2.0* | 2.1* | 2.2* | 2.3*) AC_MSG_ERROR([Provided Bison version $$1 is too old, need at least 2.4]) ;; 2.*) bird_bison_synclines=no bird_bison_enhanced_error=no ;; 3.* | 4.* | 5.* | 6.* | 7.* | 8.* | 9.*) bird_bison_synclines=yes bird_bison_enhanced_error=yes ;; *) AC_MSG_ERROR([Couldn't parse Bison version $$1. Call the developers for help.]) ;; esac ]) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/README�����������������������������������������������������������������������������������0000664�0001750�0001750�00000010115�14025744326�012242� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ BIRD Internet Routing Daemon Home page http://bird.network.cz/ Mailing list bird-users@network.cz (c) 1998--2008 Martin Mares <mj@ucw.cz> (c) 1998--2000 Pavel Machek <pavel@ucw.cz> (c) 1998--2008 Ondrej Filip <feela@network.cz> (c) 2009--2019 CZ.NIC z.s.p.o. ================================================================================ The BIRD project aims to develop a dynamic IP routing daemon with full support of all modern routing protocols, easy to use configuration interface and powerful route filtering language, primarily targeted on (but not limited to) Linux and other UNIX-like systems and distributed under the GNU General Public License. What do we support ================== o Both IPv4 and IPv6 o Multiple routing tables o Border Gateway Protocol (BGPv4) o Routing Information Protocol (RIPv2, RIPng) o Open Shortest Path First protocol (OSPFv2, OSPFv3) o Babel Routing Protocol (Babel) o Bidirectional Forwarding Detection (BFD) o IPv6 router advertisements o Static routes o Inter-table protocol o Command-line interface allowing on-line control and inspection of status of the daemon o Soft reconfiguration, no need to use complex online commands to change the configuration, just edit the configuration file and notify BIRD to re-read it and it will smoothly switch itself to the new configuration, not disturbing routing protocols unless they are affected by the configuration changes o Powerful language for route filtering, see doc/bird.conf.example o Linux, FreeBSD, NetBSD and OpenBSD ports How to install BIRD =================== o From standard distribution package of your OS (recommended) o From official binary packages for Debian and Red Hat Linux ftp://bird.network.cz/pub/bird/debian/ ftp://bird.network.cz/pub/bird/redhat/ o From source code of the latest stable release version ftp://bird.network.cz/pub/bird/ o From current development code in Git repository https://gitlab.labs.nic.cz/labs/bird/ See the file INSTALL for information about installation from source code. Documentation ============= Online documentation is available at http://bird.network.cz/?get_doc or as HTML files in the doc directory, you can install it by `make install-docs' and rebuild it by `make docs', but you'll need SGMLtools and LaTeX to be installed on your machine. You can also download a neatly formatted PDF version as a separate archive (bird-doc-*.tar.gz) from ftp://bird.network.cz/pub/bird/ User support ============ If you want to help us debugging, enhancing and porting BIRD or just lurk around to see what's going to develop, feel free to subscribe to the BIRD users mailing list bird-users@network.cz, just send `subscribe' to bird-request@network.cz. Bug reports, suggestions, feature requests and code are welcome! We don't use gitlab issues for reporting, sorry. Subscribe: http://bird.network.cz/mailman/listinfo/bird-users/ Archive: http://bird.network.cz/pipermail/bird-users/ Licence ======= This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA History ======= BIRD development started as a student project at the Faculty of Math and Physics, Charles University, Prague, Czech Republic under supervision of RNDr. Libor Forst <forst@cuni.cz>. BIRD has been developed and supported by CZ.NIC z.s.p.o. http://www.nic.cz/ since 2009. Good Luck and enjoy the BIRD :) The BIRD Team ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/NEWS�������������������������������������������������������������������������������������0000664�0001750�0001750�00000052216�14025744326�012071� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Version 2.0.8 (2021-03-18) o Automatic channel reloads based on RPKI changes o Multiple static routes with the same network o Use bitmaps to keep track of exported routes o Per-channel debug flags o CLI commands show info from multiple protocols o Linux: IPv4 routes with IPv6 nexthops o Filter: Optimized redesign of prefix sets o Filter: Improved type checking of user filters o Filter: New src/dst accessors for Flowspec and SADR o Filter: New 'weight' route attribute o Filter: BGP path mask loop operator o Filter: Remove quitbird command o RIP: Demand circuit support (RFC 2091) o BGP: New 'allow as sets' and 'enforce first as' options o BGP: Support for BGP hostname capability o BGP: Support for MD5SIG with dynamic BGP o BFD: Optional separation of IPv4 / IPv6 BFD instances o BFD: Per-peer session options o RPKI: Allow build without libSSH o RPKI: New 'ignore max length' option o OSPF: Redesign of handling of unnumbered PtPs o OSPF: Allow key id 0 in authentication o Babel: Use onlink flag for routes with unreachable next hop o Many bugfixes Notes: Automatic channel reloads based on RPKI changes are enabled by default, but require import table enabled when used in BGP import filter. BIRD now uses bitmaps to keep track of exported routes instead of re-evaluation of export filters. That should improve speed and accuracy in route export handling during reconfiguration, but takes some more memory. Per-channel debug logging and some CLI commands (like 'show ospf neighbors') defaulting to all protocol instances lead to some minor changes in log and CLI output. Caution is recommended when logs or CLI output are monitored by scripts. Version 2.0.7 (2019-10-11) o BGP: Accumulated IGP metric (RFC 7311) o Important filter reconfiguration bugfix o Several other bugfixes Version 2.0.6 (2019-09-10) o RAdv: Solicited unicast RAs o BGP: Optional Adj-RIB-Out o BGP: Extended optional parameters length o Filter: Sets and set expressions in path masks o Several important bugfixes Version 2.0.5 (2019-08-01) o OSPF Graceful restart (RFC 3623, RFC 5187) o BGP: Dynamic BGP o BGP: Promiscuous ASN mode o BGP: Mandatory option for channels o BFD: Support for VRFs o Graceful restart command o Redesigned filtering code o Many bugfixes Notes: Previous version introduced an error in handling of OSPF NSSA-LSA, causing compatibility issues with proper implementations. The error is fixed in this version, therefore there are compatibility issues in OSPF NSSA areas between this and previous version. Version 2.0.4 (2019-02-27) o OSPF: Opaque LSAs (RFC 5250) o OSPF: DN-bit handling (RFC 4576) o Preferred route counters are back o Important BGP bugfix o Several bugfixes related to route propagation o some minor bugfixes Version 2.0.3 (2019-01-05) o MRT table dumps (RFC 6396) o BGP Long-lived graceful restart o BGP: Optional import table (Adj-RIB-In) o BGP: Extend 'next hop keep' and 'next hop self' options o BGP: Improved VRF support o OSPF: Authentication trailer for OSPFv3 (RFC 7166) o Babel: New option to randomize router ID o Filter: Custom route attributes o Filter: Support for src accessor to SADR source prefix o Filter: Support for VPN_RD sets o Filter: Make ifname attribute modifiable o Perf: Protocol to measure BIRD performance internally o More verbose error messages in config processing o Log file size limit / log rotation o Many bugfixes Notes: Export of routes to RS EBGP (route server) sessions from other sources than RS EBGP sessions was changed that ASN is no longer prepended to BGP_PATH in that case. The change does not affect regular BGP configurations or regular route servers that have only RS EBGP peers. For BGP route servers and route reflectors, the default value of option 'next hop keep' was changed to a more appropriate value. Attributes for OSPF and Babel metrics are no longer reset when exported to these protocols and could be set anywhere in BIRD. As a result, OSPF metric is kept when a route is reannounced between OSPF instances. Also, when route is exported to OSPF with both ospf_metric1 and ospf_metric2 attributes it is now propagated as OSPF-E2 route instead of as OSPF-E1 route. Compiling BIRD with --enable-debug no longer automatically activates debug mode (-d option) nor local mode (-l option). Also, debug mode with output to file (-D option) no longer not forces foreground mode (-f option). The configure script now uses standard option --runstatedir, the old option --with-runtimedir is deprecated. Version 2.0.2 (2018-03-22) o Source-specific routing support for Linux kernel and Babel o BGP: New option 'disable after cease' o Filter: Allow silent filter execution o Filter: Fixed stack overflow in BGP mask expressions. o Several bugfixes Notes: Syntax prefix:netmask for IPv4 prefixes was dropped. Just use prefix/pxlen. Version 2.0.1 (2018-01-16) o Linux MPLS kernel support o Better handling of channels inherited from templates o Default EBGP Route Propagation Behavior without Policies (RFC 8212) o Many bugfixes Notes: To satisfy requirements of RFC 8212, external BGP protocols now require explicit configuration of import and export policies. Version 2.0.0 (2017-12-11) o Integrated IPv4 + IPv6 design o Support for MPLS next hops o Support for VPNv4 and VPNv6 networks o Microsecond timers infrastructure o Basic VRF support o Babel: Support for dual-stack IPv4/IPv6 o Babel: Many improvements and bugfixes o Major BGP protocol redesign o Full support for Multiprotocol BGP o BGP multicast support (SAFI 2) o BGP flowspec support (RFC 5575) o BGP with MPLS labels (RFC 3107) o BGP MPLS/VPN support (RFC 4364) o BGP 6PE - IPv6 NLRI over IPv4 MPLS (RFC 4798) o BGP IPv4 NLRI with an IPv6 Next Hop (RFC 5549) o BGP Confederations (RFC 5065) o BGP Shutdown communication (RFC 8203) o BGP: Allow exchanging LOCAL_PREF with eBGP peers o BGP: Allow to specify interface for regular sessions o OSPF: Support of address families in OSPFv3 o OSPF: Enable ECMP and Link detection by default o RAdv: Support for more specific routes (RFC 4191) o RAdv: Proper handling of prefix retraction o RIP: Enable ECMP and Link detection by default o Redesign of RPKI handling o New RPKI-Router protocol o Static: Minor overhaul o Static: Support for all new route types o Kenrel: Default Linux kernel metric changed to 32 o Kernel: Fix IPv6 ECMP handling with Linux 4.11+ o Update of show route command o BIRD client persistent history o New build system o Unit tests o ... Notes: Tables are now defined with appropriate net type keyword. Protocols and tables are now connected by explicit channels, most related protocol options (table, import, export, ...) are now channel options. See doc/bird.conf.example2 for configuration examples. Some options were removed/replaced. Version 1.6.3 (2016-12-21) o Large BGP communities o BFD authentication (MD5, SHA1) o SHA1 and SHA2 authentication for RIP and OSPF o Improved documentation o Several bug fixes Version 1.6.2 (2016-09-29) o Fixes serious bug introduced in the previous version Version 1.6.1 (2016-09-22) o Support for IPv6 ECMP o Better handling of IPv6 tentative addresses o Several updates and fixes in Babel protocol o Filter: New !~ operator o Filter: ASN ranges in bgpmask o KRT: New kernel protocol option 'metric' o KRT: New route attribute 'krt_scope' o Improved BIRD help messages o Fixes memory leak in BGP multipath o Fixes handling of empty path segments in BGP AS_PATH o Several bug fixes Version 1.6.0 (2016-04-29) o Major RIP protocol redesign o New Babel routing protocol o BGP multipath support o KRT: Add support for plenty of kernel route metrics o KRT: Allow more than 256 routing tables o Static: Allow to specify attributes for static routes o Static: Support for BFD controlled static routes o FreeBSD: Setup password for BGP MD5 authentication o IO: Remove socket number limit o Plenty of bug fixes Upgrade notes: For RIP, most protocol options were moved to interface blocks. Version 1.5.0 (2015-04-20) o Major OSPF protocol redesign. o OSPFv2 multi-instance extension (RFC 6549). o BGP AS-wide unique router ID (RFC 6286). o BGP enhanced route refresh (RFC 7313). o Link state support in BGP. o Latency tracking and internal watchdog. o Uses high port range for BFD on BSD. o Increase max symbol length to 64. o Allows to define unnamed protocols from templates. o Fixes two serious bugs in BGP. o Several bugfixes and minor improvements. o Several minor option changes: - OSPF: Protocol-wide 'instance id' option added. - BGP: Parameters to option 'neighbor' extended. - BGP: Separate option 'interface' added. - BGP: Option 'start delay time' renamed to 'connect delay time'. - BGP: Option 'route limit' deprecated. Upgrade notes: For OSPF, there are deep internal changes, but user-visible changes are limited to log messages and minor changes in formatting of command output. For BGP, version 1.5.0 is essentially a minor release. There are two deprecated options ('start delay time' and 'route limit') and some minor formatting changes. Version 1.4.5 (2014-10-06) o New 'show route noexport' command option. o Port option for BGP sessions. o Better constant handling in set literals. o Better rate filtering of log messages. o Several minor bugfixes. Version 1.4.4 (2014-07-09) o Extended OSPF multipath support. o Default router preference for RAdv. o Significant changes in socket layer. o Important bugfix in BGP. o Several minor bugfixes. Version 1.4.3 (2014-04-14) o Important bugfix in IPv6 BGP. Version 1.4.2 (2014-04-02) o Important bugfix in BFD. Version 1.4.1 (2014-03-31) o BGP add-path support (RFC draft). o BGP graceful restart (RFC 4724). o OSPF: many changes in socket layer. o OSPF: support for secondary addresses in BSD. o OSPF: names for vlink pseudointerfaces (vlinkX). o Several bugfixes. Version 1.4.0 (2013-11-25) o BFD protocol (RFC 5880). o BFD support for OSPF and BGP. o New 'allow local as' option for BGP. o Filters allows setting gw, ifname and ifindex. o Filter operator 'delete/filter' extended to bgp_paths. o Filter operator 'len' extended to [e]clists. o BIRD client now allows shorthands for noninteractive commands. o Flag -P for PID file support. o Flag -f added to force BIRD to run in foreground. o Protocol export/import/receive limits are checked during reconfiguration. o Several bugfixes and minor improvements. o Several minor but incompatible changes: - IBGP is multihop by default. - Changes primary address selection on BSD to the first one. - Integers in filters are handled as unsigned. - ISO 8601 time formats used by default. - Import of device routes from kernel protocol allowed. - Last state change now tracks just protocol state change. - Minor changes to default router ID calculation. Version 1.3.11 (2013-07-27) o OSPF stub router option (RFC 3137). o TTL security for OSPF and RIP. o Protocol packet priority and traffic class handling. o Multiple routing tables support for FreeBSD and OpenBSD. o Extends constants to all filter data types. o Implements eval command. o 'bgppath ~ int set' filter operation. o Several bugfixes. Version 1.3.10 (2013-04-30) o Lightweight BIRD client for embedded environments. o Dynamic IPv6 router advertisements. o New 'next hop keep' option for BGP. o Smart default routing table for 'show route export/preexport/protocol'. o Automatic router ID selection could be configured to use address of loopback. o Allows configured global addresses of NBMA neighbors in OSPFv3. o Allows BIRD commands from UNIX shell even in restricted mode. o Route limits inherited from templates can be disabled. o Symbol names enclosed by apostrophes can contain dots. o Several bugfixes. Version 1.3.9 (2013-01-11) o BIRD can be configured to keep and show filtered routes. o Separate receive and import limits. o Several new reconfiguration cmd options (undo, timeout, check). o Configurable automatic router ID selection. o Dragonfly BSD support. o Fixed OSPFv3 vlinks. o Several minor bugfixes. Version 1.3.8 (2012-08-07) o Generalized import and export route limits. o RDNSS and DNSSL support for RAdv. o Include in config file support wildcards. o History deduplication in BIRD client. o New route attributes krt_source, krt_metric. o Different instance ID support for OSPFv3. o Real broadcast mode for OSPFv2. o Several minor bugfixes. Version 1.3.7 (2012-03-22) o Route Origin Authorization basics. o RIPng working again. o Extended clist operations in filters. o Fixes several bugs in BSD iface handling. o Several minor bugfixes and enhancements. Version 1.3.6 (2012-01-20) o Important bugfix in BGP. Version 1.3.5 (2012-01-10) o Protocol templates. o Deterministic MED option for BGP. o Support for link-local addresses in BGP and static protocols. o Several bugfixes. Version 1.3.4 (2011-10-10) o Static recursive routes. o Several bugfixes. Version 1.3.3 (2011-09-11) o OSPF NSSA. o BGP extended communities. o BGP TTL security. o Configuration option "include" added (based on patch from Alexander V. Chernikov). o Some minor bugfixes. Version 1.3.2 (2011-07-08) o Allows run with restricted privileges. o Community list filter operation. o Fixes several problems in filter syntax: - Fixes several conflicts in the grammar. - Fixes a bug in (a..b, c) pair patterns. - Makes pair patterns orthogonal. - Allows term expressions in pair patterns without additional ( ). - Allows several comma separated values in switch cases. o Many bugfixes. Version 1.3.1 (2011-05-02) o Added Linux kernel route attributes krt_prefsrc and krt_realm. o Added BGP option 'med metric' related to MED handling. o Allows to use constants from /etc/iproute2/rt_* files. o Several bugfixes. Version 1.3.0 (2011-03-31) o Proper iBGP (can be used with IGP). o Multipath support (OSPF and static). o L2 link state detection. o IPv6 router advertisements. o Much improved OSPF reconfiguration. o Point-to-MultiPoint interfaces (OSPF). o Minor changes and improvements in config file grammar. o Better community list matching. o Changes default behavior of BGP IPv6 socket to v6only. Use 'listen bgp dual' for the old behavior. o Changes default for handling missing link-local addresses on route servers. Use 'missing lladdr drop' for the old behavior. o Important bugfix for OSPF. o Several minor bugfixes. Version 1.2.5 (2010-10-10) o Several mostly minor bugfixes. Version 1.2.4 (2010-08-03) o Added 'show memory' command. o Important bugfix in IPv6 BGP. o Several minor bugfixes. Version 1.2.3 (2010-06-01) o Pattern matching for community lists. o Many fixes in OSPF protocol (esp. in multi-areas and vlinks). o Several minor bugfixes. Version 1.2.2 (2010-04-10) o Much better BSD kernel support (IPv6, alien routes, ...). o Deep OSPF socket changes, fixes OSPFv2/v3 behavior on BSD. o OSPFv2 in Linux now supports more non-stub IP prefixes on one physical iface. o Export of device routes to the kernel is more restricted. o Routes with strange scope not allowed in BIRD routing tables. o New filterable route attributes bgp_originator_id, bgp_cluster_list and ospf_router_id. o Restricted read-only CLI (option -r). o Pattern matching for 'show protocols' command. o BGP protocol details in 'show protocols all' command. o Configurable syslog name (and default on IPv6 changed). o Statistic counters for pipes were fixed. o Many bugfixes in BGP, OSPF, filters, ... Version 1.2.1 (2010-02-11) o Option 'interpret communities' allows to override implicit handling of well-known communities. o 'configure' command uses route reload when filters change. o Adds router ID of advertising router as OSPF route attribute. o 'show route' command indicates primary route and shows OSPF Router ID. o Configurable date/time formats. o Symbol names can be enclosed by '' and so include hyphen and start with number. o Several minor bugfixes. Version 1.2.0 (2010-01-05) o Implements OSPFv3 (IPv6 support for OSPF). Because the code is shared with OSPFv2 and there were deep changes in it, we suggest caution during upgrade to OSPF users. Some advanced features (like NSSA, vlinks and authentication) are not yet implemented. o Implements MRTdump - binary logging protocol compatible with other routing daemons. Only BGP part of MRTdump is yet implemented. o Changes default value of BGP attribute LOCAL_PREF from 0 to 100. Use 'default bgp_local_pref 0' BGP protocol option for the old behavior. The new value is suggested by RFC 4277. o Changes default mode of pipes from opaque to transparent. Use 'mode opaque' protocol option if the old behavior is needed. Opaque pipe mode is deprecated and might be removed in the future. Version 1.1.7 (2009-12-20) o Implements BGP Route Refresh (RFC 2918). o Implements route reload command. o Deep changes and bugfixes in pipe protocol. o Bugfix in OSPF premature aging of LSA. o Bugfix in OSPF next hop calculation. o Bugfix in core related to route withdraws. o Several minor bugfixes. Version 1.1.6 (2009-11-19) o Implements RFC 5004 - prefer older external routes. o There is a change how route servers handle missing IPv6 link local addresses in next hop atribute - see 'missing lladdr' option. o Several minor features (description field, parse check option). o Several minor bugfixes. Version 1.1.5 (2009-10-29) o Better scalability of BGP. o New accessors for AS path - first and last. o Allows to set protocol-specific router ID. o Allows import kernel 'onlink' routes. o Endianity check in buildsystem changed. Version 1.1.4 (2009-10-02) o BGP passive option. o Several minor bugfixes. Version 1.1.3 (2009-09-11) o Bugfix in core o Bugfix in BGP related to AS2->AS4 conversion. Version 1.1.2 (2009-08-23) o Allow more kernel routing tables in IPv6. o Bugfix in core Version 1.1.1 (2009-08-14) o 'more' style paging in BIRD client. o Important core bug fixed. o Portability to non-x86 related bugfixes. o As usual, miscellaneous bugfixes. Version 1.1.0 (2009-06-28) o Parametrized pair and path mask expressions in the filter language. o Transparent pipe mode allows to implement BGP route server with independent route policy for each peer. o Kernel route table synchronization does not allow overwriting of alien routes. o Configurable BGP import route limits. o During BGP error delay, incoming connections are rejected. o BGP route statistics. o Better support for multiple network addresses on OSPF interfaces. o As usual, miscellaneous bugfixes. Version 1.0.15 (2009-05-25) o FreeBSD and NetBSD port renewed. OpenBSD port introduced. o import/preimport 'show route' modifiers was renamed to export/preexport for consistency with filters. o Minor change in the grammar of 'interface' config option. o Many bugfixes in IPv6 BGP. o As usual, miscellaneous bugfixes. Version 1.0.14 (2009-04-28) o A lot of bugfixes in BGP, OSPF and core. o A bugfix in filters in the pipe protocol. It is recommended to check whether the new behavior of used pipe filters is consistent with expectations. o Reimplementation of prefix sets and a slight change in the meaning of some prefix set patterns. Version 1.0.13 (2009-03-14) o A lot of bugfixes in BGP, OSPF and core o A new syntax for BGP masks Version 1.0.12 (2008-11-12) o new BGP features: BGP MD5, ASN32, BGP route reflector o BGP bugfixes ... Version 1.0.9 (2004-07-15) o Minor bugfix in RIP o A lot of OSPF code rewritten, OSPF supports multiple areas, virtual links, MD5 authentication. It is fully compatible with rfc2329. Version 1.0.8 (2004-06-07) o A lot of bug fixes in RIP, OSPF and BGP (thanx to Andreas Steinmetz) o FreeBSD and NetBSD port introduced o Complete code clean up Version 1.0.7 (2003-08-20) o OSPF bug fixes Version 1.0.6 (2003-04-06) o No more byte order problems in RIP authentication. Thanks to Eric Leblond <eleblond@init-sys.com> for a patch. o Fixed interoperability problems with Cisco and Zebra when talking IPv6 BGP. o Handle more primary addresses with different scopes gracefully. IPv6 needs that. o Comparison of prefixes in filters doesn't ignore their lengts. o As usually, OSPF bug fixes. o Documentation building tools now work with recent linuxdoc-tools. Version 1.0.5 (2001-06-09) o Minor cleanups in the libraries. o Removed a couple of warnings when compiling with newer glibc. o OSPF bug fixes. Version 1.0.4 (2000-09-04) o Fixed a serious bug in 1.0.3. Version 1.0.3 (2000-09-03) o OSPF works better on NBMA networks. Some configuration tags added. Version 1.0.2 (2000-08-24) o Minor bug fixes to OSPF. Version 1.0.1 (2000-06-22) o Updated documentation and fixed a couple of bugs. Version 1.0.0 (2000-06-09) o First stable release. Version 0.0.0 (2000-05-13) o First public development release. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/Makefile.in������������������������������������������������������������������������������0000664�0001750�0001750�00000014244�14025744326�013436� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile for the BIRD Internet Routing Daemon # (c) 1999--2000 Martin Mares <mj@ucw.cz> # (c) 2016 Jan Moskyto Matejka <mq@ucw.cz> # Disable build-in rules MAKEFLAGS += -r # Variable definitions CPPFLAGS=-I$(objdir) -I$(srcdir) @CPPFLAGS@ CFLAGS=$(CPPFLAGS) @CFLAGS@ LDFLAGS=@LDFLAGS@ M4FLAGS=@M4FLAGS@ BISONFLAGS=@BISONFLAGS@ LIBS=@LIBS@ DAEMON_LIBS=@DAEMON_LIBS@ CLIENT_LIBS=@CLIENT_LIBS@ CC=@CC@ M4=@M4@ BISON=@BISON@ FLEX=@FLEX@ RANLIB=@RANLIB@ INSTALL=@INSTALL@ INSTALL_PROGRAM=@INSTALL_PROGRAM@ INSTALL_DATA=@INSTALL_DATA@ client=$(addprefix $(exedir)/,@CLIENT@) daemon=$(exedir)/bird protocols=@protocols@ prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ sbindir=@sbindir@ sysconfdir=@sysconfdir@ localstatedir=@localstatedir@ runstatedir=@runstatedir@ docdir=@prefix@/doc srcdir := @srcdir@ objdir := @objdir@ exedir := @exedir@ git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null)) ifneq ($(git-label),) CFLAGS += -DGIT_LABEL="$(git-label)" endif ifeq ($(objdir),.) objdir := $(realpath .) endif ifeq ($(VERBOSE),) E:=@ Q:=@ else E:=@\# Q:= endif ifneq ($(COLOR),) CFLAGS += -fdiagnostics-color=always endif # Meta rules docgoals := docs userdocs progdocs testgoals := check test tests tests_run cleangoals := clean distclean testsclean .PHONY: all daemon cli $(docgoals) $(testgoals) $(cleangoals) tags cscope prepare all: daemon cli daemon: $(daemon) cli: $(client) $(daemon): LIBS += $(DAEMON_LIBS) # Include directories dirs := client conf doc filter lib nest test $(addprefix proto/,$(protocols)) @sysdep_dirs@ # conf/Makefile declarations needed for all other modules conf-lex-targets := $(addprefix $(objdir)/conf/,cf-lex.o) conf-y-targets := $(addprefix $(objdir)/conf/,cf-parse.y keywords.h commands.h) cf-local = $(conf-y-targets): $(s)config.Y src-o-files = $(patsubst %.c,$(o)%.o,$(src)) tests-target-files = $(patsubst %.c,$(o)%,$(tests_src)) all-daemon = $(daemon): $(obj) all-client = $(client): $(obj) s = $(dir $(lastword $(MAKEFILE_LIST))) ifeq ($(srcdir),.) o = $(objdir)/$(s) else o = $(patsubst $(srcdir)%,$(objdir)%,$(s)) endif define clean_in = clean:: rm -f $(addprefix $(o),$(1)) endef clean = $(eval $(call clean_in,$(1))) # Include main Makefiles of the directories include $(addsuffix /Makefile,$(addprefix $(srcdir)/,$(dirs))) # Generic rules # Object file rules $(objdir)/%.o: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -c $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $< $(objdir)/%.o: $(objdir)/%.c | prepare $(E)echo CC -o $@ -c $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -c $< # Debug: Preprocessed source rules $(objdir)/%.E: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -E $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $< $(objdir)/%.E: $(objdir)/%.c | prepare $(E)echo CC -o $@ -E $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -E $< # Debug: Assembler object rules $(objdir)/%.S: $(srcdir)/%.c | prepare $(E)echo CC -o $@ -S $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $< $(objdir)/%.S: $(objdir)/%.c | prepare $(E)echo CC -o $@ -S $< $(Q)$(CC) $(CFLAGS) -MMD -MP -o $@ -S $< # Finally include the computed dependencies: DEPS = $(shell find $(objdir) -name '*.d') # ## if there is at least one non-clean goal ifneq ($(filter-out $(cleangoals),$(MAKECMDGOALS)),) -include $(DEPS) endif # ## if the implicit goal is called ifeq ($(MAKECMDGOALS),) -include $(DEPS) endif # Rule for pre-generating all generated includables # before compiling any C file prepare: $(objdir)/sysdep/paths.h | $(objdir)/.dir-stamp $(objdir)/.dir-stamp: Makefile $(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc) $(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc) $(Q)touch $@ $(client) $(daemon): $(E)echo LD $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(objdir)/sysdep/paths.h: Makefile echo >$@ "/* Generated by Makefile, don't edit manually! */" echo >>$@ "#define PATH_CONFIG_FILE \"@CONFIG_FILE@\"" echo >>$@ "#define PATH_CONTROL_SOCKET \"@CONTROL_SOCKET@\"" if test -n "@iproutedir@" ; then echo >>$@ "#define PATH_IPROUTE_DIR \"@iproutedir@\"" ; fi # Unit tests rules tests_targets_ok = $(addsuffix .ok,$(tests_targets)) $(tests_targets): %: %.o $(tests_objs) | prepare $(E)echo LD $(LDFLAGS) -o $@ $< "..." $(LIBS) $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) # Hack to avoid problems with tests linking everything $(tests_targets): LIBS += $(DAEMON_LIBS) $(tests_targets_ok): %.ok: % $(Q)$* 2>/dev/null && touch $*.ok test: testsclean check check: tests tests_run tests: $(tests_targets) tests_run: $(tests_targets_ok) STATIC_CHECKERS_ENABLE := nullability.NullableDereferenced nullability.NullablePassedToNonnull nullability.NullableReturnedFromNonnull optin.portability.UnixAPI valist.CopyToSelf valist.Uninitialized valist.Unterminated STATIC_CHECKERS_DISABLE := deadcode.DeadStores STATIC_SCAN_FLAGS := -o $(objdir)/static-scan/ $(addprefix -enable-checker ,$(STATIC_CHECKERS_ENABLE)) $(addprefix -disable-checker ,$(STATIC_CHECKERS_DISABLE)) static-scan: $(E)echo Running static code analysis $(Q)$(MAKE) clean $(Q)scan-build $(STATIC_SCAN_FLAGS) $(MAKE) -$(MAKEFLAGS) tags: cd $(srcdir) ; etags -lc `find $(dirs) -name '*.[chY]'` cscope: cd $(srcdir) ; find $(dirs) -name '*.[chY]' > cscope.files ; cscope -b # Install install: all $(INSTALL) -d $(DESTDIR)/$(sbindir) $(DESTDIR)/$(sysconfdir) $(DESTDIR)/$(runstatedir) for BIN in bird @CLIENT@ ; do \ $(INSTALL_PROGRAM) $(exedir)/$$BIN $(DESTDIR)/$(sbindir)/$$BIN ; \ done if ! test -f $(DESTDIR)/@CONFIG_FILE@ ; then \ $(INSTALL_DATA) $(srcdir)/doc/bird.conf.example $(DESTDIR)/@CONFIG_FILE@ ; \ else \ echo "Not overwriting old bird.conf" ; \ fi install-docs: $(INSTALL) -d $(DESTDIR)/$(docdir) $(INSTALL_DATA) $(objdir)/doc/{bird,prog}{,-*}.html $(DESTDIR)/$(docdir)/ # Cleanup clean:: rm -f $(objdir)/sysdep/paths.h rm -f $(addprefix $(exedir)/,bird birdc birdcl) find $(objdir) -name "*.[od]" -exec rm -f '{}' '+' testsclean: rm -f $(tests_targets_ok) ifeq ($(objdir),obj) distclean: clean rm -rf $(objdir) rm -f config.log config.status configure Makefile else distclean: clean rm -rf * .dir-stamp rm -f config.log config.status configure Makefile endif ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/INSTALL����������������������������������������������������������������������������������0000664�0001750�0001750�00000002007�14025744326�012414� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������How to install BIRD =================== $ ./configure $ make # make install Default location for configuration file is /usr/local/etc/bird.conf and for control socket is /usr/local/var/run/bird.ctl . You can change that by --prefix, --sysconfdir and --runstatedir configure options, e.g.: $ ./configure --prefix=/usr --sysconfdir=/etc --runstatedir=/run To compile current development BIRD source code from Git repository, you also need Git (to download the source code) and Autoconf (to generate the configure script and associated files using 'autoreconf' tool): $ git clone https://gitlab.labs.nic.cz/labs/bird/ $ cd bird $ autoreconf Then continue as in usual installation above. Requirements ============ For compiling BIRD you need these programs and libraries: - GNU C Compiler (or LLVM Clang) - GNU Make - GNU Bison - GNU M4 - Flex - ncurses library - GNU Readline library - libssh library (optional, for RPKI-Router protocol) For compiling BIRD documentation you also need: - Linuxdoc-Tools - LaTeX �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/.gitlab-ci.yml���������������������������������������������������������������������������0000664�0001750�0001750�00000020443�14025744326�014023� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������variables: DEBIAN_FRONTEND: noninteractive LC_ALL: C GIT_STRATEGY: fetch DOCKER_CMD: docker --config="$HOME/.docker/$CI_JOB_ID/" IMG_BASE: registry.labs.nic.cz/labs/bird TOOLS_DIR: /var/lib/gitlab-runner/bird-tools stages: - image - build - test .docker: &docker_build stage: image allow_failure: true script: - $DOCKER_CMD login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.labs.nic.cz # Make sure we refresh the base image if it updates (eg. security updates, etc) # If we do just the build, cache is always reused and the freshness of the # base image is never checked. However, pull always asks and updates the # image only if it changed ‒ therefore, the cache is used unless there's a # change. - $DOCKER_CMD pull `sed -ne 's/^FROM //p' "misc/docker/$IMG_NAME/Dockerfile"` - $DOCKER_CMD build -t "bird:$IMG_NAME" "misc/docker/$IMG_NAME" - $DOCKER_CMD tag "bird:$IMG_NAME" "$IMG_BASE:$IMG_NAME" - $DOCKER_CMD push "$IMG_BASE:$IMG_NAME" after_script: - rm -f "$HOME/.docker/$CI_JOB_ID/" # cleanup the credentials tags: # That's Docker in Docker - dind docker_debian-7-amd64: variables: IMG_NAME: "debian-7-amd64" <<: *docker_build docker_debian-7-i386: variables: IMG_NAME: "debian-7-i386" <<: *docker_build docker_debian-8-amd64: variables: IMG_NAME: "debian-8-amd64" <<: *docker_build docker_debian-8-i386: variables: IMG_NAME: "debian-8-i386" <<: *docker_build docker_debian-9-amd64: variables: IMG_NAME: "debian-9-amd64" <<: *docker_build docker_debian-9-i386: variables: IMG_NAME: "debian-9-i386" <<: *docker_build docker_debian-10-amd64: variables: IMG_NAME: "debian-10-amd64" <<: *docker_build docker_debian-10-i386: variables: IMG_NAME: "debian-10-i386" <<: *docker_build docker_debian-testing-amd64: variables: IMG_NAME: "debian-testing-amd64" <<: *docker_build docker_debian-testing-i386: variables: IMG_NAME: "debian-testing-i386" <<: *docker_build docker_fedora-25-amd64: variables: IMG_NAME: "fedora-25-amd64" <<: *docker_build docker_fedora-26-amd64: variables: IMG_NAME: "fedora-26-amd64" <<: *docker_build docker_fedora-27-amd64: variables: IMG_NAME: "fedora-27-amd64" <<: *docker_build docker_fedora-28-amd64: variables: IMG_NAME: "fedora-28-amd64" <<: *docker_build docker_fedora-29-amd64: variables: IMG_NAME: "fedora-29-amd64" <<: *docker_build docker_fedora-30-amd64: variables: IMG_NAME: "fedora-30-amd64" <<: *docker_build docker_fedora-31-amd64: variables: IMG_NAME: "fedora-31-amd64" <<: *docker_build docker_centos-7-amd64: variables: IMG_NAME: "centos-7-amd64" <<: *docker_build docker_centos-8-amd64: variables: IMG_NAME: "centos-8-amd64" <<: *docker_build docker_ubuntu-14_04-amd64: variables: IMG_NAME: "ubuntu-14.04-amd64" <<: *docker_build docker_ubuntu-16_04-amd64: variables: IMG_NAME: "ubuntu-16.04-amd64" <<: *docker_build docker_ubuntu-18_04-amd64: variables: IMG_NAME: "ubuntu-18.04-amd64" <<: *docker_build docker_ubuntu-19_10-amd64: variables: IMG_NAME: "ubuntu-19.10-amd64" <<: *docker_build docker_opensuse-15.0-amd64: variables: IMG_NAME: "opensuse-15.0-amd64" <<: *docker_build docker_opensuse-15.1-amd64: variables: IMG_NAME: "opensuse-15.1-amd64" <<: *docker_build # TODO We want to copy these BSDs to our own virtual machines, to make sure # someone doesn't update them by accident. .freebsd-11-i386: &freebsd-11-i386_env tags: - freebsd - i386 #only: #- master #- triggers #- tags .freebsd-11-amd64: &freebsd-11-amd64_env tags: - freebsd - amd64 .build: &build-base stage: build script: - autoreconf - ./configure CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS" # Detect which make is available - MAKE=make - which gmake 2>/dev/null >/dev/null && MAKE=gmake - $MAKE # Run tests if they are available - $MAKE check .build-linux: &build-linux <<: *build-base tags: - docker - linux - amd64 build-debian-7-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-7-amd64 build-debian-7-i386: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-7-i386 build-debian-8-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-8-amd64 build-debian-8-i386: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-8-i386 build-debian-9-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-9-amd64 build-debian-9-i386: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-9-i386 build-debian-10-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-10-amd64 build-debian-10-i386: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-10-i386 build-debian-testing-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-testing-amd64 build-debian-testing-i386: <<: *build-linux image: registry.labs.nic.cz/labs/bird:debian-testing-i386 build-fedora-25-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-25-amd64 build-fedora-26-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-26-amd64 build-fedora-27-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-27-amd64 build-fedora-28-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-28-amd64 build-fedora-29-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-29-amd64 build-fedora-30-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-30-amd64 build-fedora-31-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:fedora-31-amd64 build-centos-7-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:centos-7-amd64 build-centos-8-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:centos-8-amd64 build-ubuntu-14_04-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:ubuntu-14.04-amd64 build-ubuntu-16_04-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:ubuntu-16.04-amd64 build-ubuntu-18_04-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:ubuntu-18.04-amd64 build-ubuntu-19_04-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:ubuntu-19.04-amd64 build-opensuse-15.0-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:opensuse-15.0-amd64 build-opensuse-15.1-amd64: <<: *build-linux image: registry.labs.nic.cz/labs/bird:opensuse-15.1-amd64 build-freebsd-11-amd64: <<: *build-base tags: - freebsd - amd64 build-freebsd-11-i386: <<: *build-base tags: - freebsd - i386 build-birdlab: stage: build tags: - birdlab - amd64 script: - DIR=$(pwd) - autoreconf - ./configure - make - cd $TOOLS_DIR - sudo git clean -fx - git pull --ff-only - mv $DIR/bird $DIR/birdc netlab/common .test: &test-base stage: test needs: [build-birdlab] tags: - birdlab - amd64 script: - cd $TOOLS_DIR/netlab - sudo ./stop - sudo ./runtest -m check $TEST_NAME test-ospf-base: <<: *test-base variables: TEST_NAME: cf-ospf-base test-ospf-default: <<: *test-base variables: TEST_NAME: cf-ospf-default test-ospf-priority: <<: *test-base variables: TEST_NAME: cf-ospf-priority test-ospf-nbma: <<: *test-base variables: TEST_NAME: cf-ospf-nbma test-ospf-ptmp: <<: *test-base variables: TEST_NAME: cf-ospf-ptmp test-ospf-authentication: <<: *test-base variables: TEST_NAME: cf-ospf-authentication test-ospf-bfd: <<: *test-base variables: TEST_NAME: cf-ospf-bfd test-ospf-custom: <<: *test-base variables: TEST_NAME: cf-ospf-custom test-ospf-vrf: <<: *test-base variables: TEST_NAME: cf-ospf-vrf test-bgp-base: <<: *test-base variables: TEST_NAME: cf-bgp-base test-bgp-auth: <<: *test-base variables: TEST_NAME: cf-bgp-auth test-bgp-int: <<: *test-base variables: TEST_NAME: cf-bgp-int test-bgp-merged: <<: *test-base variables: TEST_NAME: cf-bgp-merged test-ebgp-loop: <<: *test-base variables: TEST_NAME: cf-ebgp-loop test-ebgp-star: <<: *test-base variables: TEST_NAME: cf-ebgp-star test-ibgp-loop: <<: *test-base variables: TEST_NAME: cf-ibgp-loop test-ibgp-star: <<: *test-base variables: TEST_NAME: cf-ibgp-flat �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/.gitignore�������������������������������������������������������������������������������0000664�0001750�0001750�00000000250�14025744326�013351� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/autom4te.cache/ /obj/ /Makefile /bird /birdc /birdcl /bird.conf /bird.log /config.log /config.status /configure /sysdep/autoconf.h.in /sysdep/autoconf.h.in~ /cscope.* ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bird-2.0.8/.dir-locals.el���������������������������������������������������������������������������0000664�0001750�0001750�00000000224�14025744326�014013� 0����������������������������������������������������������������������������������������������������ustar �feela���������������������������feela������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������; BIRD project coding conventions ((c-mode (c-file-style . "bsd") (c-basic-offset . 2) (fill-column . 80) (show-trailing-whitespace . t))) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������