summaryrefslogtreecommitdiffstats
path: root/lib/if.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: Fix connected lookupDonald Sharp2016-05-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When looking up the connected route, the delete was causing crashes in OSPF due to the oi having copies of the freshly deleted connected interface. Fix code to first lookup the connected route and use that instead of just deleting it. Valgrind Findings: ==24112== Invalid read of size 1 ==24112== at 0x4E8283F: ospf_intra_add_stub (ospf_route.c:614) ==24112== by 0x4E80B15: ospf_spf_process_stubs (ospf_spf.c:1064) ==24112== by 0x4E80F74: ospf_spf_calculate (ospf_spf.c:1269) ==24112== by 0x4E811C9: ospf_spf_calculate_timer (ospf_spf.c:1339) ==24112== by 0x5126230: thread_call (thread.c:1577) ==24112== by 0x401E00: main (ospf_main.c:377) ==24112== Address 0x7f56a09 is 9 bytes inside a block of size 40 free'd ==24112== at 0x4C29E90: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24112== by 0x51290B3: zfree (memory.c:132) ==24112== by 0x51287F0: connected_free (if.c:987) ==24112== by 0x514406A: zebra_interface_address_read (zclient.c:1146) ==24112== by 0x4E5A81C: ospf_interface_address_add (ospf_zebra.c:262) ==24112== by 0x5144838: zclient_read (zclient.c:1397) ==24112== by 0x5126230: thread_call (thread.c:1577) ==24112== by 0x401E00: main (ospf_main.c:377) Ticket: CM-10890 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
* lib: refactor connected_lookup_prefixDonald Sharp2016-05-121-9/+4
| | | | | | | | | | | The connected_lookup_address function should really be a connected_lookup_prefix function. Refactor the code to use it. Ticket: CM-10890 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
* lib, zebra: Refactor vrf creation a bit moreDonald Sharp2016-04-131-1/+1
| | | | | | | | | | | | Create the idea of a VRF_UNKNOWN, this is for a vrf where we don't yet have the vrf_id for it yet. Refactor the vrf_create code out of existence. We had two code paths vrf_create and vrf_get. We should use vrf_get to create the new vrf since XXX_get() creates the data structures now. Signed-off-by: Donald Sharp Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* quagga: Remove iflist global variableDonald Sharp2016-04-081-9/+2
| | | | | | | | | | | | | | | The file if.c has a iflist that had the list of interfaces in the default vrf. Remove this variable and replace with a vrf_iflist lookup on the default vrf where it was used. Additionally, modify ptm code to iterate over all vrf's when enabling ptm. Ticket: CM-10338 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
* lib, zebra: Rename ZEBRA_VRF_ACTIVEDonald Sharp2016-04-081-1/+1
| | | | | | | | | | ZEBRA_VRF_ACTIVE is a poor name for when a vrf is actually active. Rename VRF_ACTIVE. Ticket: CM-10338 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
* lib: Refactor XX_name_len awayDonald Sharp2016-04-081-1/+1
| | | | | | | | | | | We had two functions XXX_name and XXX_name_len that both did the same thing. Remove the XXX_rename_len functions. Ticket: CM-10338 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Radhika Mahankali <radhika@cumulusnetworks.com>
* lib: Combine name comparison functionDonald Sharp2016-03-311-5/+7
| | | | | | | | | | The vrf name comparison function was the same as the interface comparison function. Combine the forces for the goodness of mankind. Ticket: CM-10184 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
* bgpd, lib, zebra: Add ability to retrieve ifp without specifying a vrfDonald Sharp2016-03-231-0/+18
| | | | | | | | | | There are cases where we get an interface name but do not have a corresponding vrf. We care about getting an interface pointer so just provide a function that searches all vrf's for the ifp. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Radhicak Mahankali <radhika@cumulusnetworks.com> Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* Quagga: Fix interface move from VRF to default VRFvivek2016-02-281-4/+6
| | | | | | | | | | | Ensure that during interface lookup (non-vty context), if the interface is found in a different VRF, it is "moved" into the requested VRF. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Ticket: CM-9579 Reviewed By: CCR-4194 Testing Done: Manual
* zebra: fix interface lookup for vrf configurationDon Slice2016-02-101-7/+44
| | | | | | | | | | | | Ticket:CM-9073 Reviewed By: sharpd Testing Done:Manual, see ticket Changed logic when "interface swpxx <vrf foo>" entered so that: 1. it matches when the command is entered without a vrf but the interface already exists in a vrf. 2. If the command is entered with a vrf name that is different than is defined by the kernel, the command is rejected. 3. If the call is made from other than the vty session, believe the new information and update the vrf accordingly.
* lib: Allow vrf under the cliDonald Sharp2016-02-011-3/+85
| | | | | | | Add the infrastructure to allow the vrf keyword. Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Quagga: Fixup decision about what an unnumbered interface isDonald Sharp2015-11-201-30/+0
| | | | | | | | | | | | This Change modifies what zebra thinks is an unnumbered interface. If the interface is not a loopback and the prefixlength for the interface is 32 than consider this an unnumbered interface. Ticket: CM-8016 Reviewed by: CCR-3827 Testing: Full Regression Suites Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib, zebra, vtysh: configure an interface in non-default VRFFeng Lu2015-10-301-0/+21
| | | | | | | | | | | | | | | | | Introduce a new command "interface IFNAME vrf N" to configure an interface in the non-default VRF. Till now, only zebra uses this command. Other daemons will install the command when they support multiple VRFs. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Conflicts: zebra/interface.c
* lib: move the interface list into "struct vrf"Feng Lu2015-10-301-50/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An interface belongs to a specific VRF. So move the interface list into the "struct vrf". * vrf.c/vrf.h: - add a new member "struct list *iflist" to the the "struct vrf"; - call if_init() in vrf_new(); - call if_terminate() in vrf_delete(); - add utilities to access the interface list and VRF ID in the specified VRF. * if.c/if.h: - the global "iflist" now only exists for the default VRF; - the global "if_master" is initialized on the definition; - in if_create(), the interface is added into the list in the specified VRF; if the VRF does not exist, create one; - add parameters to if_init()/if_terminate() so that the interface list in the VRF can be initialized/destroyed; - in if_dump_all() scan the interfaces in all the VRFs; - add a command "show address vrf N" to show addresses in a specified VRF; - add a command "show address vrf all" to show addresses in all VRFs; - new APIs ifxxx_vrf() are added to access an interface in a specified VRF. The old interface APIs (the global variable "iflist" and the API functions) are not changed to keep the backward compatibility. The new APIs are used in the daemons which support multiple VRFs (till now only zebra). Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Conflicts: lib/if.c
* lib, zebra: add "vrf_id" into the "struct interface"Feng Lu2015-10-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | Later, an interface will belong to a specific VRF. Now we add a property "vrf_id" to the "struct interface", and keep it as the default value 0. This property is shown when displaying interfaces information. It is also added in some logs. This is just the preparation to move the interace list into the "struct vrf". The main logic is not changed. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Conflicts: lib/if.c zebra/interface.c
* Zebra: Add IPv6 protocol filtering support & Setting Src of IPv6 routesDinesh G Dutt2015-09-161-9/+26
| | | | | | | | | | | | | | | | | | Ticket: Reviewed By: CCR-3335 Testing Done: bgpsmoke, ENHE tests etc. Add support for filtering routes from upper layer protocols to zebra via route-maps for IPv6. The same functionality already existed for IPv4. In addition, add support for setting source of routes via IPv6 protocol map. Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com> Reviewed-by: Vipin Kumar <vipin@cumulusnetworks.com>
* lib: lib-warnings.patchDonald Sharp2015-05-201-6/+0
| | | | | | Remove compile warnings for the lib directory Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by:
* Unnumbered interface support.Donald Sharp2015-05-201-0/+30
|
* ptm-integration.patchDonald Sharp2015-05-201-2/+16
| | | | | | | | Integrates Prescriptive Topology Module(ptm) into quagga. If this module is enabled, link ups are notified only after the link is verified as being connected to the neighbor specified. The neighbor specification and checking is done by the ptm daemon.
* 'neighbor <if-name> interface' config support in BGP including RA/Zebra changes.Donald Sharp2015-05-201-0/+58
| | | | | | Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com> Reviewed-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Dinesh Dutt <ddutt@cumulusnetworks.com>
* zebra-enable-link-detect-by-default.patchDonald Sharp2015-05-201-0/+3
| | | | | | | | zebra: Set link-detect on by default Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt at cumulusnetworks.com> Reviewed-by: Scott Feldman <sfeldma at cumulusnetworks.com>
* *: nuke ^L (page feed)David Lamparter2014-06-041-5/+5
| | | | | | | | | | | | | | Quagga sources have inherited a slew of Page Feed (^L, \xC) characters from ancient history. Among other things, these break patchwork's XML-RPC API because \xC is not a valid character in XML documents. Nuke them from high orbit. Patches can be adapted simply by: sed -e 's%^L%%' -i filename.patch (you can type page feeds in some environments with Ctrl-V Ctrl-L) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* ospf6d: correct nexthop through directly connected networksDinesh Dutt2013-11-081-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is implementing this part of RFC 2328: This is the "first case", see below, 16.1.1. The next hop calculation ... If there is at least one intervening router in the current shortest path between the destination and the root, the destination simply inherits the set of next hops from the parent. Otherwise, there are two cases. In the first case, the parent vertex is the root (the calculating router itself). This means that the destination is either a directly connected network or directly connected router. The outgoing interface in this case is simply the OSPF interface connecting to the destination network/router. ... The current Quagga code always tries to inherit the nexthop from a parent vertex, but does not cover the case that the destination is directly connected to the root vertex. This patch adds support for that case. Signed-off-by: James Li <jli at cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt at cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge quagga mainline into the google ISIS code.Avneesh Sachdev2012-04-121-9/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The steps were: $ git checkout google-is-is $ git merge quagga $ git checkout google-is-is -- isisd # Resolve conflicts in the following: lib/md5.h zebra/rt_netlink.c zebra/zebra_rib.c zebra/zserv.c Note that the content in the isisd directory is left unchanged in the merge. As a result, changes made to isisd as part of the following commits on the quagga mainline are dropped. # 8ced4e82 is the merge base, e96b3121 is the current quagga master $ git log --oneline --reverse 8ced4e82..e96b3121 -- isisd 5574999 isisd: fix crash on "no router isis" (BZ#536) 8998075 isisd: raise hello rate for DIS (BZ#539) 306ca83 isisd: include hash.h, not hash.c b82cdeb delete CVS keywords 2f65867 isisd: indent longopts array b511468 quagga: option "-z" ("--socket <path>") added 05e54ee build: delete .cvsignore files b4e45f6 fix zebra protocol after MP-BGP changes 7fd6cd8 isisd: fix circuit state machine 907fd95 isisd: send proper LSP after DIS election d034aa0 isisd: fix wrong next-hops from SPF c25eaff isisd: unexpected kernel routing table (BZ#544) e6b03b7 isisd: implement MD5 circuit authentication
| * lib/if: trivial, fix rarely used if debug function to print everythingPaul Jakma2012-01-061-6/+10
| | | | | | | | | | | | * if.c: (if_dump) loop that doesn't do anything, wants to be before the zlog of what it's meant to print out so all the connected addresses get printed out. Trival: just a debug function
| * lib: fix compile warnings from set-never-usedStephen Hemminger2011-12-061-6/+0
| | | | | | | | The if_dump code had empty loop, that caused set-never-used warning.
* | lib: Tweak to if_delete_retain()Josh Bailey2012-04-081-1/+3
|/ | | | | | | * lib/if.c: Change if_delete_retain() to delete all connected addresses, but to not free the list that holds them. Free the list just before the interface structure itself is freed, in if_delete().
* lib: fix more format warnings (#637)Christian Hammers2011-03-231-1/+1
| | | | | | | The following patch was also neccessary to compile. * command.c: (config_logmsg_cmd) use "%s" format spec * if.c: (connected_log) ditto
* lib: Add a function to delete all interfacesTom Goff2011-03-211-0/+18
| | | | | if.c: (if_terminate) This adds a cleanup function that can be called when a daemon exits, similar to vty_terminate().
* lib: if_lookup_by_name should be more robust to null argumentPaul Jakma2009-08-281-7/+9
| | | | * if.c: (if_lookup_by_name) shouldn't crash just cause we got a NULL name
* [cleanup] functions taking no args should be declared with void argsStephen Hemminger2009-06-121-1/+1
| | | | | Use Ansi-C prototypes rather than old K&R method of declaring function without arguments
* [cleanup] add const attribute to lib/if.c::if_dumpStephen Hemminger2009-06-121-1/+1
|
* [cleanup] Convert XMALLOC/memset to XCALLOCStephen Hemminger2009-06-121-3/+1
| | | | Simple conversion of XMALLOC/memset to XCALLOC
* [PtP over ethernet] New peer flag allows much more addressing flexibilityAndrew J. Schorr2006-12-121-38/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [lib] Handle upgrade from SUNWzebra to Quagga for 'interface fooX:Y' commandsPaul Jakma2006-10-161-2/+46
| | | | | | | | | | | | 2006-10-14 Paul Jakma <paul.jakma@sun.com> * if.c: (general) Handle upgrades from SUNWzebra, which tried to track each logical interface as a seperate struct interface, to Quagga, which assigns only one struct interface per ifindex. (if_sunwzebra_get) Try decompose a logical interface name (fooX:Y) to the 'primary' name (fooX), for Solaris. (interface_cmd) Use if_sunwzebra_get on Solaris.
* [zebra] remove internal if_flag_dump, use libzebras version.Paul Jakma2006-06-151-1/+2
| | | | | | | | | 2006-06-15 Paul Jakma <paul.jakma@sun.com> * lib/if.c: (if_flag_dump) remove the whitespace indentation, callers should provide. * zebra/interface.c: (if_flag_dump_vty) redundant code, remove. (if_dump_vty) use libzebra if_flag_dump.
* 2005-11-03 Paul Jakma <paul.jakma@sun.com>paul2005-11-031-1/+1
| | | | | * if.c: (connected_free) use MTYPE for connected label. memtypes.c: Add MTYPE_CONNECTED_LABEL
* 2005-10-26 Paul Jakma <paul.jakma@sun.com>paul2005-10-261-1/+1
| | | | | | | | | | * (general) Cleanup a some calls to XFREE,strdup, etc. to use the memory.h macros. * memtypes.c: Add MTYPE_IF_RMAP_NAME, MTYPE_PQUEUE, MTYPE_PQUEUE_DATA and MTYPE_HOST. * memtypes.h: update auto-built file. * if_rmap.c: Use MTYPE_IF_RMAP_NAME. * pqueue.c: Use the two MTYPE_PQUEUE mtypes for allocations.
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | * (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
* 2005-04-07 Paul Jakma <paul.jakma@sun.com>paul2005-04-071-33/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single scan of the area list, rather than scanning all areas first for INTER_ROUTER and then again for INTER_NETWORK. According to 16.2, the scan should be area specific anyway, and further ospf6d does not seem to implement 16.3 anyway.
* 2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-031-6/+2
| | | | | | | | | | | * 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-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-031-1/+2
| | | | | | * if.c: (if_nametoindex) The man page is rather vague, but it seems like the argument to if_nametoindex has an implicit maximum length of IFNAMSIZ characters.
* 2005-04-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-031-7/+35
| | | | | | | | | | | | | | | * 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-02 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-021-64/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-29 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-01-291-14/+2
| | | | | | | | | | | | | | | | | | | | | * buffer.h: Fix comment on buffer_getstr to reflect that it now uses XMALLOC. * buffer.c: (buffer_getstr) Use XMALLOC(MTYPE_TMP) instead of malloc. * filter.c: (access_list_remark,ipv6_access_list_remark) Use argv_concat instead of buffer_getstr. * if.c: (interface_desc) Use argv_concat instead of buffer_getstr. * plist.c: (ip_prefix_list_description,ipv6_prefix_list_description) Use argv_concat instead of buffer_getstr. * bgp_filter.c: (ip_as_path,no_ip_as_path) Use argv_concat instead of buffer_getstr. * bgp_route.c: (bgp_show_regexp) Fix memory leak: need to free string returned by buffer_getstr. (bgp_show_community) Must use XFREE instead of free on string returned by buffer_getstr. * bgp_routemap.c: (set_community) Must use XFREE instead of free on string returned by buffer_getstr. * bgp_vty.c: (neighbor_description) Use argv_concat instead of buffer_getstr.
* 2004-12-21 Paul Jakma <paul.jakma@sun.com>paul2004-12-211-6/+10
| | | | | * if.h: Add more 'non-generic' IFF_ flags. * if.c: IFF_NOXMIT/IFF_VIRTUAL interfaces are 'loopback like'
* OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd,hasso2004-10-191-55/+29
| | | | ripd might need some more testing though.
* 2004-10-10 Paul Jakma <paul@dishone.st>paul2004-10-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * version.h.in: (pid_output*) add const qualifier. * command.h: Change DEFUN func to take const char *[] rather than char **, to begin process of fixing compile warnings in lib/. Nearly all other changes in this commit follow from this change. * buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take const void * and cast an automatic const char *p to it. (buffer_putstr) add const * command.c: (zencrypt) const qualifier (cmd_execute_command_real) ditto (cmd_execute_command_strict) ditto (config_log_file) ditto. Fix leak of getcwd() returned string. * memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname. * distribute.{c,h}: Update with const qualifier. (distribute_free) use MTYPE_DISTRIBUTE_IFNAME (distribute_lookup) Cast to char *, note that it's ok. (distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME. (distribute_get) Cast to char *, note that it's ok. * filter.c: Update with const qualifier. * if.{c,h}: ditto. * if_rmap.{c,h}: ditto. (if_rmap_lookup) Cast to char *, note that it's ok. (if_rmap_get) ditto. * log.{c,h}: Update with const qualifier. * plist.{c,h}: ditto. * routemap.{c,h}: ditto. * smux.{c,h}: ditto. Fix some signed/unsigned comparisons. * sockopt.c: (getsockopt_cmsg_data) add return for error case. * vty.c: Update with const qualifier.
* Number of warnings is down to 3 again in lib directory. A lot of const'shasso2004-10-051-1/+1
| | | | added to strings and a lot of int -> unsigned int changes.
* Remove usage of evil list and listnode typedefs.hasso2004-09-231-15/+15
|