summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
| * | general: remove inline qualifiers and move in-header functions to objectsPaul Jakma2012-01-064-19/+22
| | | | | | | | | | | | | | | | | | * (general) Move functions in headers into files, to be compiled into shared object files. Remove inline qualifier from functions. Let the compiler do the work.
| * | lib: fix some strtoul() use casesUlrich Weber2012-01-021-1/+2
| | | | | | | | | | | | ...otherwise 4294967295 is not a valid value on 32bit systems
| * | lib: address type-punned pointers in prefix_same()Denis Ovsienko2012-01-021-2/+2
| | | | | | | | | | | | | | | | | | IPV4_ADDR_SAME() wasn't passed the right union member, this could cause a bug due to strict-aliasing. IPV6_ADDR_SAME() case got its fix before the error could be created by macro upgrade.
| * | bgpd: justify checks for IPv4 class D/EDenis Ovsienko2012-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/prefix.h * IPV4_CLASS_DE(): make consistent with counterpart macros * bgp_packet.c * bgp_open_receive(): test using macro instead of ">=" * bgp_route.c * bgp_update_rsclient(): idem * bgp_update_main(): idem
| * | zebra: ZEBRA_HELLO and mopping up routes (BZ#448)Vyacheslav Trushkin2012-01-022-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | ZEBRA_HELLO message is used by routing daemons to inform zebra what type of routes daemon will be announcing to zebra. Also zebra uses route_type_oaths array to track which daemon announces which protocol. Zebra mops up routes if daemon didn't for some reason.
| * | lib: fix type-punning in ip_masklen()Denis Ovsienko2012-01-021-2/+7
| | | | | | | | | | | | | | | ip_masklen() was likely to return incorrect results after being compiled with -fstrict-aliasing (-O2, -O3, -Os)
| * | lib: optimize ip_masklen()Denis Ovsienko2012-01-021-25/+2076
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new implementation makes use of a 64KB mapping table, which makes it possible to compute masklen faster and with constant execution time. The map also allows for additional version of the function, which can detect errors in input argument. The previous implementation had a variable cost of execution, which depended on masklen in a non-linear manner, and at its worst (/31) was 4 times slower, than the new implementation. The only case of old function just slightly outperforming the new one is /0, which is of little practical interest.
| * | Revert "lib: optimize apply_mask_ipv6()"Denis Ovsienko2012-01-011-7/+17
| | | | | | | | | | | | | | | Experience with IPv4 counterpart of this function suggests, that this way of type-punning is likely to cause errors.
| * | fix set never used warningsStephen Hemminger2011-12-184-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (This patch was modified to leave calls to stream_getl() in place, they are necessary for the stream's internal pointer to advance to the correct position. -- Denis) Signed-off-by: Denis Ovsienko <infrastation@yandex.ru> Fix gcc warnings about varables that are set but never used. * bgpd/bgp_attr.c * cluster_unintern(): ret * transit_unintern(): ret * bgp_attr_default_intern(): attre * bgp_mp_reach_parse(): rd_high, rd_low * bgpd/bgp_route.c * bgp_announce_check_rsclient(): bgp * bgpd/bgp_zebra.c * zebra_read_ipv4(): ifindex * zebra_read_ipv6(): ifindex * bgpd/bgpd.c * bgp_config_write_peer(): filter * lib/distribute.c * distribute_list_all(): dist * distribute_list(): dist * distribute_list_prefix_all(): dist * distribute_list_prefix(): dist * lib/if_rmap.c * if_rmap(): if_rmap * lib/vty.c * vty_accept(): vty * lib/zclient.c * zclient_read(): ret * zebra/irdp_interface.c * if_group(): zi * zebra/rt_netlink.c * kernel_read(): ret, sock
| * | lib: optimize apply_mask_ipv6()Denis Ovsienko2011-12-131-17/+7
| | |
| * | lib: optimize apply_mask_ipv4()Denis Ovsienko2011-12-131-18/+3
| | |
| * | lib: make masklen2ip6() safer and fasterDenis Ovsienko2011-12-132-17/+136
| | |
| * | lib: fix endianness of masklen2ip()Denis Ovsienko2011-12-131-3/+39
| | |
| * | lib: make masklen2ip() safer and fasterDenis Ovsienko2011-12-132-17/+40
| | |
| * | lib: spellingDenis Ovsienko2011-12-131-10/+10
| | |
| * | lib: add sockopt helper for setting IPV6_V6ONLY and use itDavid Lamparter2011-12-133-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getaddrinfo returns a list of socket parameters for listening. it will contain both IPv4 and IPv6 listening sockets. unless we use IPV6_V6ONLY on the IPv6 ones, only the socket listed first will work. if the IPv4 one came first, the IPv6 one would get an "Address in use" error. this functionality was already present for bgpd and its listening sockets. as it is needed for vtys as well, make it a common helper. Conflicts: lib/sockunion.c
| * | lib: put route_types.txt to real useDavid Lamparter2011-12-136-229/+259
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this replaces most occurences of routing protocol lists by preprocessor defines from route_types.h. the latter is autogenerated from route_types.txt by a perl script (previously awk). adding a routing protocol now is mostly a matter of changing route_types.txt and log.c. Conflicts: lib/route_types.awk
| * | build: delete .cvsignore filesDenis Ovsienko2011-12-131-14/+0
| | |
| * | lib: clearing zclient.c for some cases of buildingVyacheslav Trushkin2011-12-131-1/+3
| | | | | | | | | | | | | | | lib/zclient.c: using of HAVE_TCP_ZEBRA in zclient_socket_* definitions extended by else clause.
| * | quagga: option "-z" ("--socket <path>") addedVyacheslav Trushkin2011-12-132-14/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All daemons modified to support custom path to zserv socket. lib: generalize a zclient connection zclient_socket_connect added. zclient_socket and zclient_socket_un were hidden under static expression. "zclient_serv_path_set" modified.
| * | lib: fix SMUX compiler warningsStephen Hemminger2011-12-071-4/+3
| | | | | | | | | | | | | | | Make progname a string, and cast when calling asn1. Remove variable set but never used.
| * | lib: fix compile warnings from set-never-usedStephen Hemminger2011-12-071-6/+0
| | | | | | | | | | | | The if_dump code had empty loop, that caused set-never-used warning.
| * | vty_serv_sock_family unusedStephen Hemminger2011-12-071-1/+2
| | | | | | | | | | | | | | | If the vty_serv_sock_addrinfo is being used, then vty_serv_sock_family is unsed. Fix by adjusting ifdef/else/endif
| * | lib: fix memory leak on connect() failureStephen Hemminger2011-12-061-12/+11
| | | | | | | | | | | | | | | Change sockunion_log() to not use strdup(). This fixes a small memory leak that occurs on every failed connect(), and is simpler/cleaner.
| * | lib: call filter delete hook before freeing access listStephen Hemminger2011-12-061-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | The delete_hook was being run after calling access list delete function. This would cause ospf to dereference a NULL, in ospf_filter_update because 'access->name' was already freed. See also: https://bugzilla.vyatta.com/show_bug.cgi?id=7654
| * | lib: prefix2sockunion, prefix_common_bits helper functionsDavid Lamparter2011-11-212-0/+56
| | | | | | | | | | | | | | | | | | prefix2sockunion converts a struct prefix* to a union sockunion *; prefix_common_bits counts the number of common bits in the prefix's address part.
| * | lib: compile even without IPV6_TCLASSDenis Ovsienko2011-10-171-1/+3
| | |
| * | IPv6 transport class suppportStephen Hemminger2011-10-172-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IPv6 supports the same concept of differentiated service for routing protocols as IPv4, but like too many things, the standards committee decided that having two names for the same thing wasn't good enough and introduced a third more generic term transport class. The socket option to set transport class works the same as IPv4, but the arguments are different. * lib/sockopt.[ch] * setsockopt_ipv6_tclass(): new function * bgpd/bgp_network.c * bgp_connect(): set socket option * bgp_listener(): set socket option * ospf6d/ospf6_network.c * ospf6_set_transport_class(): new function * ospf6_serv_sock(): set socket option * ripngd/ripngd.c * ripng_make_socket(): set socket option
| * | bgpd: improve NEXT_HOP attribute checks (BZ#680)Denis Ovsienko2011-09-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/prefix.h * IPV4_CLASS_DE(): new helper macro * bgp_attr.c * bgp_attr_nexthop(): add check for "partial" bit, refresh flag error reporting, explain meaning of RFC4271 section 6.3 and implement it Conflicts: bgpd/bgp_attr.c
| * | bgpd: rename SAFI 3 according to RFC4760Denis Ovsienko2011-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - SAFI value 3 is reserved. It was assigned by RFC 2858 for a use that was never fully implemented, so it is deprecated by this document. * zebra.h: rename macro * bgp_fsm.c: (bgp_graceful_restart_timer_expire, bgp_graceful_stale_timer_expire, bgp_stop, bgp_establish): update * bgpd.c: (peer_nsf_stop): update * bgp_open.c: (bgp_capability_vty_out): SAFI 3 isn't a recognized case any more
| * | lib: provide more information in case of failed LOOKUP.Dmitrij Tejblum2011-09-272-6/+7
| | | | | | | | | | | | | | | | | | | | | * log.[ch] * mes_lookup: add a parameter with the name of the message list, print the name in case of failure. * LOOKUP macro: pass the name of the message list.
| * | lib: use "protocol-independed API" from RFC3678, if that is availableDmitrij Tejblum2011-09-271-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | (This commit is based on the patch from BZ#420, and should fix that bug.) * configure.ac: detect availability of that API * sockopt.c (setsockopt_ipv4_multicast): use it for join/leave IPv4 multicast groups
| * | lib: futher simplification of setsockopt_ipv4_multicast()Dmitrij Tejblum2011-09-271-64/+44
| | | | | | | | | | | | | | | * sockopt.c (setsockopt_ipv4_multicast): check for wrong optname with assert(), rather than return an error.
| * | lib: fix omission in the previous commit to lib/sockopt.cDmitrij Tejblum2011-09-271-0/+1
| | | | | | | | | | | | | | | * sockopt.c (setsockopt_ipv4_multicast_if): fix missed line in the previous commit.
| * | lib: simplify interface of setsockopt_multicast_ipv4().Dmitrij Tejblum2011-09-272-38/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * sockopt.[ch] (setsockopt_ipv4_multicast): ifindex is now mandatory (all non-ancient OSes can use it anyway), and if_addr parameter (the address of the interface) is now gone. (setsockopt_ipv4_multicast_if): IP_MULTICAST_IF processing moved to this new function * ospf_network.c (ospf_if_add_allspfrouters, ospf_if_drop_allspfrouters, ospf_if_add_alldrouters, ospf_if_drop_alldrouters, ospf_if_ipmulticast), rip_interface.c (ipv4_multicast_join, ipv4_multicast_leave, rip_interface_new): adapt to the new interface
| * | lib: remove unused variableDenis Ovsienko2011-09-271-3/+1
| | | | | | | | | | | | * sockopt.c (getsockopt_ifindex): "ifindex" was never used
| * | delete CVS keywordsDenis Ovsienko2011-09-275-10/+0
| | |
| * | configure: dismiss libutil.hStephen Hemminger2011-09-271-4/+0
| |/ | | | | | | | | Recent versions of libc on Linux (Debian Testing) create lots of compile warnings about direct usage of libutil.h
* / bgpd: Adds support to mark up the BGP rib table entry with multipathJosh Bailey2011-07-201-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | information based on the multipath list (mp_list) generated during the best path calculation. Display "multipath" for paths that are multipath and also on bestpath if the route is multipath. Flag a best path with the BGP_INFO_MULTIPATH_CHG if the multipath set has changed since the last update. This can be used to trigger updates to zebra and peers. The multipath markup is a lazily allocated bgp_info_mpath structure that is added to the best path and any multipaths. The mpath structures are linked together with the best path element at the head and the other elements ordered by nexthop and then by peer address. This markup scheme is updated by calling bgp_info_mpath_update() and passing in a new mp_list the the current multipath set. There are additional API's for walking the multipath set, querying the count of multipaths, and for cleaning up the multipath markup information when freeing path information. * bgpd/bgp_mpath.c * bgp_info_mpath_new(): Allocation of new mpath element * bgp_info_mpath_free(): Release memory for mpath element * bgp_info_mpath_get(): Access mpath element of path. Allocate memory on-demand * bgp_info_mpath_enqueue(): Enqueue a path onto the multipath list * bgp_info_mpath_dequeue(): Remove a path from the multipath list * bgp_info_mpath_first(): Return first path on the multipath list * bgp_info_mpath_next(): Return next path on the multipath list * bgp_info_mpath_count(): Return the number of paths on the multipath list * bgp_info_mpath_count_set(): Set the number of paths on the multipath list * bgp_info_mpath_update(): Update multipath markup on bgp route table entry and flag any changes. Emit 'debug bgp event' output on any multipath change. * bgpd/bgp_mpath.h * struct bgp_info_mpath: Information added to a bgp_info path to record multipath information * External declarations for new functions in bgp_mpath.c * bgpd/bgp_route.c * bgp_info_free(): Free mpath memory when freeing path information * bgp_info_reap(): Dequeue path from multipath queue before deleting it * bgp_best_selection(): Calls bgp_info_mpath_update() with latest mp_list to mark-up rib table entry * bgp_vty_out_detail(): Add display of multipath flag for a path. Also display 'multipath' for bestpath if it is a multipath route * bgpd/bgp_route.h * struct bgp_info: Add pointer to bgp_info_mpath information * Add flags to mark a path as multipath (BGP_INFO_MULTIPATH) and to mark bestpath if multipath information has changed (BGP_INFO_MULTIPATH_CHG) * lib/memtypes.c * Add MTYPE_BGP_MPATH_INFO for allocating memory for bgp_info_mpath * tests/bgp_mpath_test.c * Add test case for bgp_info_mpath_update() and supporting functions
* lib: Add support for IPv6 ttl securityStephen Hemminger2011-03-241-11/+19
| | | | | * sockunion.c: (sockopt_minttl) Add IPv6 support for min hop count. The kernel support is Linux kernel 2.6.35 or later.
* bgpd: Cleanups & fixes for minttl / GTSMStephen Hemminger2011-03-241-8/+8
| | | | | | | | * bgp_vty.c: (peer_ebgp_multihop_{un,}set_vty) tail-call cleanup. ({no_,}neighbor_ttl_security) ditto. * bgpd.c: (peer_ttl_security_hops_set) Peer group checks and TTL set only need to be done on transition. * sockunion.c: (sockopt_minttl) remove always-on debug and improve readability.
* bgpd: RFC 5082 Generalized TTL Security Mechanism supportNick Hilliard2011-03-232-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | * bgpd: Add support for RFC 5082 GTSM, which allows the TTL field to be used to verify that incoming packets have been sent from neighbours no more than X IP hops away. In other words, this allows packets that were sent from further away (i.e. not by the neighbour with known distance, and so possibly a miscreant) to be filtered out. * lib/sockunion.{c,h}: (sockopt_minttl) new function, to set a minimum TTL using the IP_MINTTL socket opt. * bgpd.h: (BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK) define for command error for minttl. (struct peer) add a config variable, to store the configured minttl. (peer_ttl_security_hops_{set,unset}) configuration handlers * bgpd.c: (peer_group_get) init gtsm_hops (peer_ebgp_multihop_{un,}set) check for conflicts with GTSM. Multihop and GTSM can't both be active for a peer at the same time. (peer_ttl_security_hops_set) set minttl, taking care to avoid conflicts with ebgp_multihop. (bgp_config_write_peer) write out minttl as "neighbor .. ttl-security hops X". * bgp_vty.c: (bgp_vty_return) message for BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK (peer_ebgp_multihop_{un,}set_vty) * bgp_network.c: (bgp_accept) set minttl on accepted sockets if appropriate. (bgp_connect) ditto for outbound.
* lib: fix more format warnings (#637)Christian Hammers2011-03-232-2/+2
| | | | | | | The following patch was also neccessary to compile. * command.c: (config_logmsg_cmd) use "%s" format spec * if.c: (connected_log) ditto
* lib: add TCP_CORK wrapperStephen Hemminger2011-03-212-0/+11
| | | | | * sockunion.{c,h}: (sockopt_cork) wrapper for TCP_CORK socket option for those platforms that provide it. For other platforms, it is just a nop.
* lib: zlog should clean up its memoryTom Goff2011-03-211-0/+3
| | | | | * log.c: (closezlog) Also free the dynamically allocated filename when a log is closed.
* lib: Add a function to delete all interfacesTom Goff2011-03-212-0/+19
| | | | | if.c: (if_terminate) This adds a cleanup function that can be called when a daemon exits, similar to vty_terminate().
* lib: Better hashing of string values using Bernstein hashStephen Hemminger2011-03-214-16/+19
| | | | | | | | | * hash.{h,c}: (string_hash_make) Hash optimised for strings, current implementation using Bernstein hash, which offers a good compromise between distribution and performance. * distribute.c: (distribute_hash_make) use previous instead of additive string hash. * if_rmap.c: (if_rmap_hash_make) ditto
* bgpd: fix bgp_node locking issuesChris Caputo2011-03-211-0/+1
| | | | | | | | | | | | | | * bgpd: Connected table locks were being locked but not unlocked, such that eventually a lock would exceed 2^31 and become negative, thus triggering an assert later on. * bgp_main.c: (bgp_exit) delete connected elements along with ifp's. * bgp_nexthop.c: (bgp_nexthop_lookup{,_ipv6}) add missing unlocks (bgp_multiaccess_check_v4) ditto (bgp_connected_{add,delete}) Use a distinct memtype for bgp_connected_ref. (bgp_scan_finish) reset the nexthop cache to clean it up when bgpd exits * bgp_route.c: fix missing bgp_node unlocks * lib/memtype.c: (memory_list_bgp) add MTYPE_BGP_CONN * testing: has been tested for almost 2 months now.
* lib: Fix accounting of memoryChris Hall2011-03-211-2/+8
| | | | | | | | * lib/memory.c: (zrealloc) If is called with NULL pointer then it should increment allocations because it behaves the same as zmalloc. (zfree) is called with NULL pointer, it does nothing therefore allocation count should not change.
* lib: Fix bug in prefix trie lookupPaul Jakma2010-12-081-6/+8
| | | | | | | * lib/table.c: (route_node_match) fix overshoot that was causing this function to go 1 bit too far and thus reading past end of prefix. (route_node_lookup) be defensive - don't assume others will clean up leaves when removing info.