summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
AgeCommit message (Collapse)Author
2006-01-25[zebra/solaris] Interface state fixups for Solaris.paul
2006-01-25 Paul Jakma <paul.jakma@sun.com> * (general) More solaris PF_ROUTE hacks. The IFF_UP mangling for solaris was incomplete on the PF_ROUTE side. fix it. This changeset generally uglifies things. For some future work I'd like to see the state changes seperated out from the details of the code. Differences between systems might then be slightly easier to implement without convoluted hacks. Changes should be specific to Solaris mostly, however also tested on FreeBSD 6. * if_ioctl_solaris.c: (interface_list_ioctl) ignore ~IFF_UP interfaces, we'll hear about them when/if interface goes up through NEWADDR. Update flags explicitely at end of it to kick mangling. * ioctl_solaris.c: (if_mangle_up) removed to interface.c, in kind. (lifreq_set_name) more convenient to take the string, than the ifp. (if_get_flags_direct) new convenience function, returns the actual flags. Used during bootstrap in if_ioctl_solaris.c to peek at flags of logical interfaces to see whether or not to ignore them. (if_get_flags) ENXIO means it's gone, poke out IFF_UP and kick flags update. (if_{un,}set_flags) flags argument should be 64bit. * ioctl.{c,h}: flags argument should be 64bit. * interface.h: Add a 'primary_state' flag to struct zebra_if on SUNOS_5. Export if_flags_update. * interface.c: (if_flags_mangle) moved over in kind from ioctl_solaris.c. Nasty kludge to try get IFF_UP right, as much as is possible. Also keep track of the actual IFF_UP value for the primary interface, so we can know when the ifp must be deleted. (if_flags_update) Take a new interface flags value, apply it to the interface, and take whatever actions are required due to flag transitions. (if_refresh) flag state change logic is moved out to previous. Just call if_get_flags, which will end up using previous to effect the update of flags. (if_flag_dump_vty) IFF_IPV{4,6} aren't interesting, VIRTUAL and NOXMIT are though. * kernel_socket.c: (ifm_read) Down->Down transitions shouldn't create ifp, for non-IFANNOUNCE systems. Use if_flags_update to update flags. flag transition logic is now handled automatically through if_flags_update. (ifam_read) Better to call if_refresh *after* adding connected addresses, as connected count affects IFF_UP on IFF_UP-mangled systems. On Solaris, Up->Down due to DELADDR means we need to delete the ifp - the IFINFO might already have been and gone. * rt.h: include other dependent headers.
2006-01-17[zebra] Record NEWADDR metric on PF_ROUTE, print CACHEINFO debug on netlinkpaul
2006-01-17 Paul Jakma <paul.jakma@sun.com> * kernel_socket.c: (ifam_read) Read metric from RTM_NEWADDR. If interface is an alias, pass the alias as a label for connected_add_ipv{4,6}. * rt_netlink.c: (netlink_interface_addr) print out IFA_CACHEINFO info, if present, when debugging kernel messages.
2005-12-29remove dead code (from David Young)gdt
2005-11-24[zebra] Fix mistake in previous commit and further compile warnings/errors.paul
2005-11-24 Paul Jakma <paul.jakma@sun.com> * kernel_socket.h: New header for functions exported to sysctl methods. * kernel_socket.c: include previous. Remove static qualifier from couple of functions which are used by sysctl methods, incorrectly added in previous commit. Add a workaround for a bogus gcc warning to the RTA_ macros. * Makefile.am: Add kernel_socket.h to noinst_HEADERS * if_sysctl.c: include rt.h and kernel_socket.h and remove redundant prototypes. * rtread_sysctl.c: ditto. (route_read) fix mismatch of return values. * {rt,zserv,rib}.h: Include lib headers depended on.
2005-11-23[zebra] fix some small compile errors, mark several functions staticpaul
2005-11-23 Paul Jakma <paul.jakma@sun.com> * (general) fix some small compile errors, and mark several functions as static. * kernel_socket.c: (ifan_read) should be static. fix missing brackets. (ifm_read,ifam_read,rtm_read_mesg,kernel_read) Make static (ifam_read_mesg) make static. fix incorrect variable name. (rtm_read) make static. Fix call to rib_delete_ipv4 which should be rib_delete_ipv6. (routing_socket,kernel_init) should be static. Void argument should be specified as such, not left incomplete. * rt_netlink.c: rt.h should be included, contains prototypes of exported functions. (kernel_delete_ipv6_old) fix sign of index argument. * rt_socket.c: Exact same as previous. Also, make various functions static. * rtread_getmsg.c: Include zserv.h, which prototypes route_read. Make static. * rtread_sysctl.c: zserv.h and rt.h should be included. fix definition of route_read.
2005-11-12[solaris] Extra debug and cross-checks for kernel_socket, two Sol9 fixes.paul
2005-11-12 Alexander Gall <gall@switch.ch> * See [quagga-dev 1815] * kernel_socket.c: (rtm_write) Use SAROUNDUP when HAVE_SIN_LEN is not available. * rt_socket.c: (kernel_rtm_ipv6(_multipath)) set family to AF_INET6 on ipv6 routes. 2005-11-12 Paul Jakma <paul.jakma@sun.com> * kernel_socket.c: Add RTA_NAME_GET macro to extract name from sockaddr_dl. Add some more RTF_ flags. * (ifan_read) Add some debug messages. * (ifm_read) Add more debug messages. More robust cross-checks of index against name. Fall back to by-name lookup if the index lookup fails, future proofing more than anything else. (ifam_read_mesg) Read RTA_IFP. Add debug messages. (ifam_read) More debug. If there's an RTA_IFP and it isn't the name of the interface, save it as the label. (rtm_read_mesg) Read RTA_IFP. (rtm_read) allow name to be retrieved. (rtmsg_debug) expand on the debug message.
2005-11-11[zebra] Fix warning and small connected-label changes merge error.paul
2005-11-11 Paul Jakma <paul.jakma@sun.com> * kernel_socket.c: (ifm_read) arithmetic on void pointer warning. (ifam_read) Fix error from connected-with-label merge, something crept in from the pending Solaris kernel_socket.c patch which shouldn't have.
2005-11-032005-11-03 Paul Jakma <paul.jakma@sun.com>paul
* 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-09-122005-09-12 Paul Jakma <paul.jakma@sun.com>paul
* (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-08-27 * zebra_rib.c, rib.h: Add distance and metric arguments to thehasso
rib_add_ipv6() function so that IPv6 routes in RIB can have correct metric. No IPv6 routing daemon uses distance yet though. * zserv.c, connected.c, kernel_socket.c, rt_netlink.c, rtread_proc.c,zserv.c: Pass metric and distance info to the rib_add_ipv6(). Forwardport from stable branch.
2005-07-292005-07-29 Paul Jakma <paul.jakma@sun.com>paul
* interface.c: (if_delete_update) should always be available, not just on RTM_IFANNOUNCE/NETLINK systems. * kernel_socket.c: (ifan_read) only call if_delete_update when interface departs, dont if_delete, because we wish to retain interface configuration state even when interfaces are removed. (ifm_read) If we dont have RTM_IFANNOUNCE, then transitioning to down state is only chance we have to clean up interface in case it is deleted (eg Solaris down -> unplumb -> plumb up). * redistribute.c: (zebra_interface_delete_update) should always be available, we /will/ call it now on all systems, via if_delete_update. * zserv.c: (zsend_interface_delete) ditto (zsend_interface_address) Update the call-flow diagramme, to reflect that if_delete_update /is/ now called on all systems, potentially. * zserv.h: (zsend_interface_delete) unconditionally exported, as above.
2005-06-282005-06-28 Paul Jakma <paul.jakma@sun.com>paul
* kernel_socket.c: (RTA_{ADDR,ATTR}_GET) fix mistake, NULL check should be on DEST argument
2005-06-142005-06-14 Paul Jakma <paul.jakma@sun.com>paul
* kernel_socket.c: consolidate the IFAM{ADDR,MASK}GET and RTM{ADDR,MASK}GET macros into generic rta_addrs macros, RTA_{ADDR,ATTR}_GET. (af_check) could use 'inline' attribute (ifam_read_mesg) remove IFAM{ADDR,MASK}GET macro, change to generic macro. (rtm_read_mesg) similar
2005-04-032005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* if_ioctl.c: (interface_list_ioctl) Use if_get_by_name_len. * if_proc.c: (ifaddr_proc_ipv6) Increase size of ifname buffer to avoid overflow. * kernel_socket.c: (ifan_read) Use if_get_by_name_len. * if.h: Fix comments to reflect that if_lookup_by_name and if_get_by_name now require the argument strings to be NUL-terminated. * if.c: (if_lookup_by_name) Compare using strcmp. (if_get_by_name) Pass strlen(ifname) as 2nd arg to if_create.
2005-04-022005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* if.h: (if_lookup_by_name_len, if_get_by_name_len) New functions. * if.c: (if_lookup_by_name_len, if_get_by_name_len) New functions. (if_get_by_name) Tighten up code. (interface) Use new function if_get_by_name_len. * zclient.c: (zebra_interface_add_read) Use new if_get_by_name_len function. (zebra_interface_state_read) Use new if_lookup_by_name_len function. * kernel_socket.c: (ifm_read) Use new if_lookup_by_name_len function to save a memcpy. * if_ioctl_solaris.c: (interface_list_ioctl) Fix subtle bug with new if_get_by_name_len function. * ospf_interface.c: (ospf_vl_new) Use strnlen to fix call to if_create.
2005-04-022005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
Fix problems when netlink interfaces are renamed (same ifindex used for a new interface). Start cleaning up some problems with the way interface names are handled. * interface.c: (if_new_intern_ifindex) Remove obsolete function. (if_delete_update) After distributing the interface deletion message, set ifp->ifindex to IFINDEX_INTERNAL. (if_dump_vty) Detect pseudo interface by checking if ifp->ifindex is IFINDEX_INTERNAL. (zebra_interface) Check return code from interface_cmd.func. Do not set internal ifindex values to if_new_intern_ifindex(), since we now use IFINDEX_INTERNAL for all pseudo interfaces. * kernel_socket.c: (ifm_read) Fix code and comments to reflect that all internal interfaces now have ifp->ifindex set to IFINDEX_INTERNAL. * rt_netlink.c: (set_ifindex) New function used to update ifp->ifindex. Detects interface rename events by checking if that ifindex is already being used. If it is, delete the old interface before assigning the ifindex to the new interface. (netlink_interface, netlink_link_change) Call set_ifindex to update the ifindex. * if.h: Remove define for IFINDEX_INTERNBASE and add define IFINDEX_INTERNAL 0, since all internal (i.e. non-kernel) pseudo- interfaces should have ifindex set to 0. (if_new) Remove function. (if_delete_retain) New function to delete an interface without removing from iflist and freeing the structure. (ifname2ifindex) New function. * if.c: (if_new) Remove function (absorb into if_create). (if_create) Replace function if_new with call to calloc. Set ifp->ifindex to IFINDEX_INTERNAL. Fix off-by-one error in assert to check length of interface name. Add error message if interface with this name already exists. (if_delete_retain) New function to delete an interface without removing from iflist and freeing the structure. (if_delete) Implement with help of if_delete_retain. (ifindex2ifname) Reimplement using if_lookup_by_index. (ifname2ifindex) New function to complement ifindex2ifname. (interface) The interface command should check the name length and fail with a warning message if it is too long. (no_interface) Fix spelling in warning message. (if_nametoindex) Reimplement using if_lookup_by_name. (if_indextoname, ifaddr_ipv4_lookup) Reimplement using if_lookup_by_index. * bgp_zebra.c: (bgp_interface_delete) After deleting, set ifp->ifindex to IFINDEX_INTERNAL. * isis_zebra.c: (isis_zebra_if_del) Call if_delete_retain instead of if_delete, since it is generally not safe to remove interface structures. After deleting, set ifp->ifindex to IFINDEX_INTERNAL. (zebra_interface_if_lookup) Tighten up code. * ospf6_zebra.c: (ospf6_zebra_if_del) Previously, this whole function was commented out. But this is not safe: we should at least update the ifindex when the interface is deleted. So the new version updates the interface status and sets ifp->ifindex to IFINDEX_INTERNAL. (ospf6_zebra_route_update) Use if_indextoname properly. * ospf_vty.c: (show_ip_ospf_interface_sub) Show ifindex and interface flags to help with debugging. * ospf_zebra.c: (ospf_interface_delete) After deleting, set ifp->ifindex to IFINDEX_INTERNAL. (zebra_interface_if_lookup) Make function static. Tighten up code. * rip_interface.c: (rip_interface_delete) After deleting, set ifp->ifindex to IFINDEX_INTERNAL. * ripng_interface.c: (ripng_interface_delete) After deleting, set ifp->ifindex to IFINDEX_INTERNAL.
2005-01-052005-01-05 Paul Jakma <paul@dishone.st>paul
* zserv.c: (zebra_accept) Comment out setting of socket to NONBLOCK for now, as we dont actually deal with with resending.... See bugzilla #122, fix from wawa@yandex-team.ru (Vladimir Ivanov). * kernel_socket.c: (routing_socket) ditto.
2004-12-09Add const to char * to quiet warnings.gdt
Note two warnings in comments. The serious one is that struct interface->ifindex probably needs to be signed, ssince we store and compare to -1.
2004-12-072004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* *.c: Change level of debug messages to LOG_DEBUG.
2004-11-202004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* global: Replace strerror with safe_strerror. And vtysh/vtysh.c needs to include "log.h" to pick up the declaration.
2004-07-13004-07-13 David Wiggins <dwiggins@bbn.comgdt
* kernel_socket.c (rtm_flag_dump): terminate buffer with '\0', not '0'. This is arguably not a security problem, since strlcat is used to copy to the buffer -gdt.
2004-05-112004-05-11 Paul Jakma <paul@dishone.st>paul
* ioctl.h: Add if_ioctl_ipv6 prototype and AF_IOCTL for SOLARIS_IPV6 * kernel_socket.c: Fix SAROUNDUP, compiler doesnt like do..while RHS in assignments :) * redistribute.c: (zebra_interface_delete_update) only used if RTM_IFANNOUNCE and NETLINK is available.
2004-01-082004-01-08 Greg Troxel <gdt@fnord.ir.bbn.com>gdt
* kernel_socket.c (kernel_read): Use sockaddr_storage in buffer for reading kernel messages to ensure enough space (necessary on Solaris due to sockaddr_dl being large). Thanks to Sowmini Varadhan for help with this change.
2004-01-062004-01-05 Greg Troxel <gdt@fnord.ir.bbn.com>gdt
* kernel_socket.c (ifm_read): Major cleanup. Use Sowmini's code to find the sockaddr_dl in all cases, narrowing the Solaris ifdef to just the accomodation of broken kernels. Check sockaddr_dl carefully up front, and later assume any non-NULL sdl pointer is valid. Clean up types and variable declarations, and rename WRAPUP to SAROUNDUP to make the name fit the behavior.
2004-01-06increase buffer size for kernel readsgdt
2004-01-05Fix incorrect test in previous commit; thanks to Sowmini Varadhan forgdt
catching this.
2004-01-052004-01-05 Greg Troxel <gdt@ahi.ir.bbn.com>gdt
* kernel_socket.c (kernel_read): Look up interfaces by index first, so that state changes which do not include a sockaddr_dl now work. Add many sanity checks. In particular, do not assume that a sockaddr_dl follows a message without checking the ifm_addrs flags, and do not trust the length in a sockaddr_dl. Add/clarify many comments.
2003-10-222003-10-22 Paul Jakma <paul@dishone.st>paul
* zebra/kernel_socket.c: HAVE_IPV6 conditional for WRAPUP when HAVE_SA_LEN is not defined. bcopy -> memcpy, bcopy is not portable.
2003-09-242003-09-24 sowmini.varadhan@sun.compaul
* zebra/kernel_socket.c: Fix up WRAPUP macro to deal with multiple address families in the absence of sa_len element in struct sockaddr. (ifm_read): Handle solaris 9 if_msghdr_t. Deal with interfaces which are incomplete, lookup on name rather than the placeholder interface index of -1.
2003-08-012003-08-01 Cougar <cougar@random.ee>paul
* lib/if.c: (if_cmp_func) new function, compare interface names in alphabetical order. (if_create) Take name as argument and add interface in sorted order. (if_get_by_name),(interface_cmd) fixup calls to if_create - see above. (if_init) register list comparison function. * lib/if.h: Add comparison function, modify if_create prototype. * lib/zclient.c: Modify call to if_create. * ospfd/ospf_interface.c: (ospf_vl_new) modify call to if_create. change sprintf to snprintf. * zebra/kernel_socket.c: (ifm_read) modify call to if_create.
2003-07-082003-07-8 Chris Andrews <chris@nodnol.org>paul
* zebra/kernel_socket.c: Update for new zebrad global struct * zebra/ipforward_solaris.c: Add missing privs.h include. Uncomment /dev/ip define. * lib/zebra.h: Add typedefs for SunOS.
2003-06-062003-06-07 Paul Jakma <paul@dishone.st>paul
* Revert Cougar's sort interface names patch, causes problems with enabling of interfaces for OSPF in ospfd.
2003-06-05Patch from Cougar - sort iflist by name.hasso
2003-06-042003-06-04 Paul Jakma <paul@dishone.st>paul
* Merge of zebra privileges
2003-05-25Last fixes from 6Wind patch.hasso
2003-05-25Route (reject|blackhole) support from 6Wind patch.hasso
2002-12-13Initial revisionpaul