summaryrefslogtreecommitdiffstats
path: root/lib/prefix.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Zebra: Don't resolve nexthops over default route unless explicitly allowed.Donald Sharp2015-06-111-0/+14
| | | | | | | | | | Ensure that resolution of a nexthop using a default route is not done in the nexthop validation/update code in zebra_rib.c also. This is an addition to the zebra-nht-no-default.patch which made the checks only in the NHT code. In the case of scenarios like interface down, this nexthop update code will kick in first to update the route before the NHT code comes into play; without the additional fix, this code could incorrectly resolve the nexthop over a default route, even when disallowed by the administrator.
* Block martian address configuration on an interface and also block fromDonald Sharp2015-05-201-1/+14
| | | | getting installed into the zebra tables.
* ospfd: For an ABR, ensure the right LSID is MaxAge'dPradosh Mohapatra2014-05-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | PROBLEM: Accurate garbage collection of maxage LSAs. The global OSPF structure has a maxage_lsa tree - the key to the tree is <ls-id, adv-router> tuple. Suppose the ABR has multiple areas and has originated some intra-area LSAs. The key for all those LSAs is the same. The code then ends up in a state where all but the first LSA do not get cleaned up from the areas' LSDB. A subsequent event would readvertise those LSAs. PATCH: Since the LSA is going to stick around till it actually gets cleaned up by the maxage_walker, make the LSA pointer as the key. Each distinct LSA that gets maxage'd then gets added to the tree and will get cleaned up correctly. Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> [CF: Use CHAR_BIT; use uintptr_t; use sizeof(field) instead of sizeof(type)] Signed-off-by: Christian Franke <chris@opensourcerouting.org> [DL: this must remain a temporary fix! needs to be redone after 0.99.23] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* zebra: apply syntactic sugar to rib_dump()David Lamparter2014-04-011-0/+19
| | | | | | | strip the explicit __func__ present on all calls and make the prefix argument a transparent union. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: bgpd-set-v4-nexthop-for-v6-peering.patchPradosh Mohapatra2014-02-101-0/+10
| | | | | | | | | | | | | | | | | | | BGP: While advertising v4 prefixes over a v6 session, set the correct v4 nexthop. ISSUE: For an IPv6 peer, BGPd sets the local router-id as the next-hop's v4 address. This is incorrect as the router-id may not be a valid next-hop to be included in UPDATEs that contain v4 prefixes. PATCH: Set the v4 address in the next-hop field based on the interface that the peering is on (directly connected interface or loopback). Signed-off-by: Pradosh Mohapatra <pmohapat at cumulusnetworks.com> Reviewed-by: Scott Feldman <sfeldma at cumulusnetworks.com> Acked-by: Feng Lu <lu.feng@6wind.com>
* general: remove inline qualifiers and move in-header functions to objectsPaul Jakma2012-01-061-16/+4
| | | | | | * (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.
* 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
* lib: make masklen2ip6() safer and fasterDenis Ovsienko2011-12-131-1/+1
|
* lib: make masklen2ip() safer and fasterDenis Ovsienko2011-12-131-1/+1
|
* lib: prefix2sockunion, prefix_common_bits helper functionsDavid Lamparter2011-11-211-0/+2
| | | | | | prefix2sockunion converts a struct prefix* to a union sockunion *; prefix_common_bits counts the number of common bits in the prefix's address part.
* bgpd: improve NEXT_HOP attribute checks (BZ#680)Denis Ovsienko2011-09-291-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, lib: adopt afi_t and safi_t in several placesMichael Lambert2010-10-061-2/+2
| | | | | | | | | * bgpd/bgp_attr.c, bgpd/bgp_open.h, bgpd/bgp_route.c, lib/prefix.c, lib/prefix.h: Various integer types were being used where, if we had strict type checking, afi_t and safi_t would be required. Signed-off-by: G.Balaji <balajig81@gmail.com> (cherry picked from commit c8af35ffa2dc79ff7d7ff00b1b61f1f50a100ab6)
* ospf6d: fix warnings from recent prefix bit commitStephen Hemminger2009-12-101-0/+6
| | | | | | | | * lib/prefix.h * prefix6_bit(): add IPv6 wrapper for prefix_bit() * ospf6d/ospf6_lsdb.c * ospf6_lsdb_type_router_head(): employ prefix6_bit() * ospf6_lsdb_type_head(): idem
* lib: move check_bit into prefix common codeStephen Hemminger2009-12-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make one version of check prefix bit, and put it inline with proper prototype. This gets rid of some macro's and also some assert() that can never happen on a non-broken compiler. * bgpd/bgp_table.c * CHECK_BIT(): sayonara * check_bit(): sayonara * SET_LINK(): sayonara * set_link(): make use of prefix_bit() instead of check_bit() * bgp_node_match(): idem * bgp_node_lookup(): idem * bgp_node_get(): idem * lib/prefix.h * prefix_bit(): new inline version of check_bit() * lib/table.c * CHECK_BIT(): sayonara * check_bit(): sayonara * SET_LINK(): sayonara * set_link(): make use of prefix_bit() instead of check_bit() * route_node_match(): idem * route_node_lookup(): idem * route_node_get(): idem * ospf6d/ospf6_lsdb.c * CHECK_BIT(): sayonara * ospf6_lsdb_lookup_next(): make use of prefix_bit() instead of CHECK_BIT() * ospf6_lsdb_type_router_head(): idem * ospf6_lsdb_type_head(): idem * ospf6d/ospf6_route.c * CHECK_BIT(): sayonara * ospf6_route_match_head() make use of prefix_bit() instead of * CHECK_BIT()
* [zebra] Bug #351: Don't redistribute routes to ipv4 link-local prefixesPaul Jakma2007-04-101-0/+1
| | | | | | | | | | | 2007-04-07 Paul Jakma <paul.jakma@sun.com> * lib/prefix.h: Add define to match IPv4 Link-Local addresses * zebra/redistribute.c: (zebra_check_addr) Don't redistribute routes to IPv4 link-local prefixes, fixes bug #351. * zebra/redistribute.h: Export zebra_check_addr. * zebra/router-id.c: (router_id_bad_address) re-use zebra_check_addr rather than implementing similar logic.
* [PtP over ethernet] New peer flag allows much more addressing flexibilityAndrew J. Schorr2006-12-121-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating whether a peer address has been configured. Comment now shows the new interpretation of the destination addr: if ZEBRA_IFA_PEER is set, then it must contain the destination address, otherwise it may contain the broadcast address or be NULL. (CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete macros that were specific to IPv4 and not fully general. (CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag. (CONNECTED_PREFIX) New macro giving the prefix to insert into the RIB: if CONNECTED_PEER, then use the destination (peer) address, else use the address field. (CONNECTED_ID) New macro to come up with an identifying address for the struct connected. * if.c: (if_lookup_address, connected_lookup_address) Streamline logic with new CONNECTED_PREFIX macro. * prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros for better performance than the general prefix_copy function. * zclient.c: (zebra_interface_address_read) For non-null destination addresses, set prefixlen to equal the address prefixlen. This is needed to get the new CONNECTED_PREFIX macro to work properly. * connected.c: (connected_up_ipv4, connected_down_ipv4, connected_up_ipv6, connected_down_ipv6) Simplify logic using the new CONNECTED_PREFIX macro. (connected_add_ipv4) Set prefixlen in destination addresses (required by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead of testing for IFF_POINTOPOINT. Delete invalid warning message. Warn about cases where the ZEBRA_IFA_PEER is set but no destination address has been supplied (and turn off the flag). (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning. Set prefixlen in destination address so CONNECTED_PREFIX will work. * connected.h: (connected_add_ipv6) Add new flags argument so callers may set the ZEBRA_IFA_PEER flag. * interface.c: (connected_dump_vty) Use CONNECTED_PEER macro to decide whether the destination address is a peer or broadcast address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT). * if_ioctl.c: (if_getaddrs) Instead of setting a peer address only when the IFF_POINTOPOINT is set, we now accept a peer address whenever it is available and not the same as the local address. Otherwise (no peer address assigned), we check for a broadcast address (regardless of the IFF_BROADCAST flag). And must now pass a flags value of ZEBRA_IFA_PEER to connected_add_ipv4 when a peer address is assigned. The same new logic is used with the IPv6 code as well (and we pass the new flags argument to connected_add_ipv6). (if_get_addr) Do not bother to check IFF_POINTOPOINT: just issue the SIOCGIFDSTADDR ioctl and see if we get back a peer address not matching the local address (and set the ZEBRA_IFA_PEER in that case). If there's no peer address, try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set. * if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl without bothering to check the IFF_POINTOPOINT flag. And if no peer address was found, just try the SIOCGLIFBRDADDR ioctl without checking the IFF_BROADCAST flag. Call connected_add_ipv4 and connected_add_ipv6 with appropriate flags. * if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to connected_add_ipv6. * kernel_socket.c: (ifam_read) Must pass new flags argument to connected_add_ipv6. * rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2 to determine local and possible peer address (so there's no longer a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately. Pass new flags argument to connected_add_ipv6. (netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast to determine whether the connected destination address is a broadcast address. * bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete) Simplify logic by using new CONNECTED_PREFIX macro. * ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix, ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX macro. * ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX macro, both options collapse into the same code. * ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new CONNECTED_ID macro. (ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX macro. * ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro instead of testing the IFF_POINTOPOINT flag. * ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro instead of testing with if_is_pointopoint. And add commented-out code to implement alternative (in my opinion) more elegant behavior that has no special-case treatment for PtP addresses. (ospf_network_run) Use new CONNECTED_ID macro to simplify logic. * rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID macro to simplify logic. (rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does not give a useful result if prefixlen is 32 (we require a peer address in such cases). * ripd.c: (rip_update_interface) Fix same bug as above.
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-40/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | * (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
* * prefix.[hc]: Pass argument to the inet6_ntoa by value making it morehasso2005-04-081-1/+1
| | | | | | inet_ntoa alike. * ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes argument now by value.
* * lib/prefix.[hc]: inet6_ntoa utility function copied fromhasso2005-04-051-0/+2
| | | | | | | | ripngd/ripngd.c (inet6_ntop). * ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa() from lib is used now. * ripng_interface.c: inet6_ntop() -> inet6_ntoa(). * ripng_peer.c: inet6_ntop() -> inet6_ntoa().
* OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd,hasso2004-10-191-0/+8
| | | | ripd might need some more testing though.
* First small part of lib cleanup. Mainly "constification" of arguments andhasso2004-10-041-27/+29
| | | | adding FIXME's.
* Explain the dual use of struct prefix for CIDR prefixes andgdt2004-01-131-0/+9
| | | | address/netmask pairs, and clarify the two comparison functions.
* Initial revisionpaul2002-12-131-0/+161