summaryrefslogtreecommitdiffstats
path: root/zebra/connected.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib,zebra: use more constMark Stapp2021-09-141-9/+11
| | | | | | Use const in ipX_martian apis, and in some zebra apis. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
* zebra: Do not use connection dest for bcastJuergen Werner2019-08-181-4/+4
| | | | | | | | | The `destination` field of the connection structure was used to store the broadcast address, if the connection was not p2p. This multipurpose is not very evident and the benefits over calculating the bcast address on the fly minimal. Signed-off-by: Juergen Werner <juergen@opensourcerouting.org>
* add cplusplus guards to all zebra headersEmanuele Di Pascale2019-03-251-0/+7
| | | | Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
* zebra: set connected route metric based on the devaddr metricAnuradha Karuppiah2019-01-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MACVLAN devices are typically used for applications such as VRR/VRRP that require a second MAC address (virtual). These devices have a corresponding SVI/VLAN device - root@TORC11:~# ip addr show vlan1002 39: vlan1002@bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9152 qdisc noqueue master vrf1 state UP group default link/ether 00:02:00:00:00:2e brd ff:ff:ff:ff:ff:ff inet6 2001:aa:1::2/64 scope global valid_lft forever preferred_lft forever root@TORC11:~# ip addr show vlan1002-v0 40: vlan1002-v0@vlan1002: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9152 qdisc noqueue master vrf1 state UP group default link/ether 00:00:5e:00:01:01 brd ff:ff:ff:ff:ff:ff inet6 2001:aa:1::a/64 metric 1024 scope global valid_lft forever preferred_lft forever root@TORC11:~# The macvlan device is used primarily for RX (VR-IP/VR-MAC). And TX is via the SVI. To acheive that functionality the macvlan network's metric is set to a higher value. Zebra currently ignores the devaddr metric sent by the kernel and hardcodes it to 0. This commit eliminates that hardcoding. If the devaddr metric is available (METRIC_MAX) it is used for setting up the connected route otherwise we fallback to the dev/interface metric. Setting the macvlan metric to a higher value ensures that zebra will always select the connected route on the SVI (and subsequently use it for next hop resolution etc.) - root@TORC11:~# vtysh -c "show ip route vrf vrf1 2001:aa:1::/64" Routing entry for 2001:aa:1::/64 Known via "connected", distance 0, metric 1024, vrf vrf1 Last update 11:30:56 ago * directly connected, vlan1002-v0 Routing entry for 2001:aa:1::/64 Known via "connected", distance 0, metric 0, vrf vrf1, best Last update 11:30:56 ago * directly connected, vlan1002 root@TORC11:~# Ticket: CM-23511 Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
* lib: convert prefixlen to 16-bit integerQuentin Young2018-10-151-4/+4
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra, lib: error references for zebraQuentin Young2018-08-141-0/+6
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: Fix crash with certain types of tunnelsDonald Sharp2018-04-151-3/+4
| | | | | | | | | | | | | Zebra did not have a handler for tunnels in v6 for some reason. Add code to handle the broadcast address for both addition and deletion. This appears to fix the crash. There might still need to be some work to make the code `work` properly for this type of tunnel. Fixes: #2063 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-4/+4
| | | | | | | | | | | | | | | | | | | | | | The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* zebra: Refactor connected_down_ipv[4|6]Donald Sharp2017-08-311-3/+1
| | | | | | | The connected_down_ipv[4|6] functions are basically identical. Refactor into one common interface. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: Refactor connected_up_ipv[4|6]Donald Sharp2017-08-311-2/+1
| | | | | | | The connected_up_ipv[4|6] functions were almost identical. Combine the forces for the goodness of mankind Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: drop IPv6 "broadcast" and "peer" addr codeDavid Lamparter2017-08-281-3/+2
| | | | | | There is no such thing as an IPv6 "broadcast" or "peer" address. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* zebra: add connected_check_ptp infrastructureDavid Lamparter2017-08-271-1/+4
| | | | | | | | | | add a connected_check_ptp function which does the same as connected_check, but takes an additional peer prefix argument. also fix related prefixlen mixup in PtP addresses (the local part of a PtP address always is /32, but previously the peer mask got copied.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-23/+20
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* frr: Remove HAVE_IPV6 from code baseDonald Sharp2017-01-131-3/+0
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Zebra: Remove reliance on NEXTHOP_TYPE_IPV4_ONLINKDonald Sharp2015-11-161-0/+2
| | | | | | | | | | | | | | | | | Zebra already knows if an interface is unnumbered or not. This is communicated to OSPF. OSPF would only send a NEXTHOP_TYPE_IPV4_ONLINK *if* the path was unnumbered, which it learns from Zebra. As such, Have OSPF use the normal NEXTHOP_TYPE_IPV4_IFINDEX type for unnumbered paths. In Zebra, if the ifindex recieved is unnumbered then assume that the link is NEXTHOP_FLAG_ONLINK. Ticket: CM-8145 Reviewed-by: CCR-3771 Testing: See bug Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Unnumbered interface support.Donald Sharp2015-05-201-0/+3
|
* [PtP over ethernet] New peer flag allows much more addressing flexibilityAndrew J. Schorr2006-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [zebra] fix connected_add_ipv6 declarations, label should be const.paul2005-11-261-1/+2
| | | | | | | 2005-11-26 Paul Jakma <paul.jakma@sun.com> * connected.{c,h}: (connected_add_ipv6) label should have const qualifier, fix declarations.
* 2005-11-03 Paul Jakma <paul.jakma@sun.com>paul2005-11-031-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * connected.{c,h}: Include memory.h (connected_add_ipv4) Use MTYPE for ifc label. (connected_add_ipv6) Also should accept label. Store it in ifp. (connected_del_ipv4) Taking label as argument is pointless. * rt_netlink.c: (netlink_interface_addr) update label usage for connected_{add,delete} functions. * if_ioctl.c: (if_getaddrs) NULL label for connected_add_ipv6. * if_ioctl_solaris.c: (interface_list_ioctl) Pass LIFC_NOXMIT so we also find out about NOXMIT interfaces like VNI. Bit of hackery to turn interface names into the primary interface name, later with routing socket messages we only will about primary interfaces anyway, so we must normalise the name. (if_get_addr) take label as argument, so it can be passed to connected_add. If label is provided, then it is interface name to issue the ioctl for address information on, not the ifp name. (interface_list) List AF_UNSPEC too, just in case. * if_proc.c: (ifaddr_proc_ipv6) label for connected_add_ipv6. * interface.c: (if_addr_wakeup) Some very bogus code - sets IFF_RUNNING - add comment. (if_refresh) (ip_address_install) Use MTYPE for ifc label. * ioctl_solaris.c: (if_mangle_up) New function. Hackery to make IFF_UP reflect whether any addresses are left on the interface, as we get signalled for IFF_UP flags change on the primary interface only. Logical interfaces dont generate IFINFO, but we do get an RTM_DELADDR. (if_get_flags) Call if_mangle_up before return. * kernel_socket.c: (ifam_read) Fixup calls to connected_{add,delete} to match above changes. Rename gate variable to brd, less confusing. Pass the interface name as a label, if it is not same name as ifp->name.
* 2005-10-11 Paul Jakma <paul.jakma@sun.com>paul2005-10-111-2/+4
| | | | | * connected.{c,h}: (connected_{add,delete}_ipv4) label should be const qualified.
* 2005-09-12 Paul Jakma <paul.jakma@sun.com>paul2005-09-121-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * (general) RTM_CHANGE and implicit withdraw on RTM_NEWADDR support. * connected.c: (connected_withdraw) new function. withdraw a connected subnet address set from zebra, and pass information along to clients. (connected_announce) similar, but to announce a new connected subnet address set. (connected_check_ipv4) renamed to connected_check, as its AFI independent. (connected_add_ipv{4,6}) Remove the connected address announce stuff, use connected_announce instead. If connected_check indicates address is already present, treat it as an implicit withdraw of the existing address, ie remove the old address details and replace with the new details. (connected_delete_ipv{4,6}) Use connected_withdraw. (connected_check_ipv6) deleted in favour of connected_check. * connected.h: Rename connected_check_ipv4 to connected_check. delete connected_check_ipv6. * interface.c: Use connected_check rather than the AFI specific symbols. * kernel_socket.c: (rtm_read) RTM_CHANGE support. Create a rib delete event for the existing route, before adding route again. (kernel_read) we can handle RTM_CHANGE now.
* 2005-06-28 Paul Jakma <paul.jakma@sun.com>paul2005-06-281-18/+14
| | | | | | | * (global) Extern and static'ification, with related fixups of declarations, ensuring files include their own headers, etc. if_ioctl.c: (interface_info_ioctl) fix obvious arg mis-order in list loop
* Initial revisionpaul2002-12-131-0/+60