summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* bgpd: Make bgp_info_cmp robust to paths that do not have su_remote infoTimo Teräs2015-09-241-1/+6
| | | | | | | | | My original su_remote == NULL check is not correct. It seems that * bgp_route.c: (bgp_info_cmp) Some bgp_info is compared with su_remote=NULL and it's supposed to be perfectly legal. E.g. configured subnet announces ("network a.b.c.d/n"). Ensure bgp_info_cmp is robust if such a path gets as far as the neighbour address comparison step.
* bgpd: Compile fix for clearing-completion FSM fix, using workqueue helper.Paul Jakma2015-09-241-1/+2
|
* lib/workqueue: Add trivial work_queue_is_scheduled helperPaul Jakma2015-09-242-0/+8
|
* build/lib: Check for and include stdbool.h by defaultPaul Jakma2015-09-242-0/+4
| | | | | * stdbool.h should be widely supported by now, and the 'bool' type makes more semantic sense than an integer type for boolean values.
* bgpd: Fix race in clearing completionDonald Sharp2015-09-242-23/+27
| | | | | | | | | | | | | | | | | | When a peer that is Established goes down, it is moved into the Clearing state to facilitate clearing of the routes received from the peer - remove from the RIB, reselect best path, update/delete from Zebra and to other peers etc. At the end of this, a Clearing_Completed event is generated to the FSM which will allow the peer to move out of Clearing to Idle. The issue in the code is that there is a possibility of multiple Clearing Completed events being generated for a peer, one per AFI/SAFI. Upon the first such event, the peer would move to Idle. If other events happened (e.g., new connection got established) before the last Clearing_Completed event is received, bad things can happen. Fix to ensure only one Clearing_Completed event is generated. Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
* bgpd: Only use routes from Established peers for best path selectionDinesh G Dutt2015-09-241-0/+14
| | | | | | | | | | | | | | Ensure that routes from a peer are not considered for best path comparison if the peer is not in an Established state. There can be a window between a peer being deleted and the background thread that actually clears the routes (marks them as "removed") runs during which best path may run. If this path selection compared two prefixes all the way down to peer IP addresses and one of these two peers had just been deleted, that peer would not have its sockunion structures, especially su_remote, resulting in a BGPD exception. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* bgpd: Ignore stale entry candidates during bestpath selection.vivek2015-09-241-1/+13
| | | | | | | | | | During best path selection, if one of the candidates is a stale entry, do not perform the neighbor address comparison as that information is invalid for the stale entry. Attempting to perform the comparison results in a bgpd exception. Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
* ospfd: trap on state change seems to send incorrect value for ospfNbrStateFernando Soto2015-09-241-17/+27
| | | | | | | | | | | | | | | | The ospfNbrState in the ospf trap sent from ospfd shows an incorrect state. For example, when the connection goes down, the ospfNbrState in the trap is sent as '8' (full). When the connection is reestablished, the state is sent as '7' (loading). The reason seems to be that the trap is sent from nsm_notice_state_change() before the state is actually updated by calling nsm_change_state(). After applying the attached patch, the traps are sent with nbrState '1' when the connection goes down and '8' when it goes back up. Bugzilla #833 https://bugzilla.quagga.net/show_bug.cgi?id=833
* ospfd: Fix for 'no' + 'debug command' does not disable 'debug command'Vystoropskyi, Sergii2015-09-241-1/+1
| | | | | | | | "no debug ospf packet all detail" does not cancel "debug ospf packet all detail" due to the code inconsistency in setting/unsetting debug flags. * ospf_dump.c: added missing flags. Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* ospfd: Fast OSPF convergenceMichael Rossberg2015-09-2410-25/+134
| | | | | | | | | | | | When considering small networks that have extreme requirements on availability and thus convergence delay, the timers given in the OSPF RFC seem a little “conservative”, i.e., the delay between accepted LSAs and the rate at which LSAs are sent. Cisco introduced two commands 'timers throttle lsa all’ and 'timers lsa arrival’, which allow operators to tune these parameters. I have been writing a patch to also support 'timers lsa arrival’ fully and ‘timers throttle lsa all’ (without the throttling part) also in quagga.
* ospfd: Fix bug in 94266fa822ba, nbr_self rebuild didn't add valid nbr_selfPaul Jakma2015-09-244-5/+12
| | | | | | | | | | | | * 94266fa822ba "ospfd: Self nbrs needs to be rebuilt when router ID changes." deleted the nbr_self, and added it back, but ospf_nbr_add_self doesn't actually create the nbr_self - it assumes it's already there. Leading to use after free and crashes after a router-id change. * ospfd/ospf_neighbor.{c,h}: (ospf_nbr_self_reset) Little helper to reset the nbr_self correctly. * ospf_interface.c: (ospf_if_cleanup) moved code to ospf_nbr_self_reset * ospfd.c: (ospf_router_id_update) Use ospf_nbr_self_reset instead of doing the reset badly, fixing 94266fa822ba.
* bgpd/pimd: fix zAPI parsingNicolas Dichtel2015-09-244-68/+73
| | | | | | | | | | | | | Commit c99f3481a598 has changed the API. Now, the vrfid has been added in the header, thus we must read it before parsing the rest of the message. To ease code maintenance, let's add a new function to read a zAPI header. Fixes: c99f3481a598 ("*: add VRF ID in the API message header") Reported-by: Martin Winter <mwinter@opensourcerouting.org> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> Tested-by: Martin Winter <mwinter@opensourcerouting.org>
* Revert "ospfd: Use route_node_lookup() instaed of route_node_get()"Paul Jakma2015-09-242-6/+2
| | | | | | This reverts commit c9b07581e0df8867499e97e08b382b6d3cc9c4c4. See: http://patchwork.quagga.net/patch/410/
* build: Remove the old PIC/PIE patch, let libtool sort it outPaul Jakma2015-09-0312-48/+13
| | | | | | | * Remove the old change from '08 to add in PIE arguments at automake level. Versions of libtool since then know how to deal with -fpie and do the right thing according to whether its building shared or executable objects. So just pass '-fpie' as CFLAG and let libtool do its thing.
* isisd: Attached-bit in LSP headerAmritha Nambiar2015-09-033-11/+60
| | | | | | | | | | | | | | | | | | | | | | | | Set/reset attached-bit in LSP header: This patch provides support for set/reset attached_bit in the LSP header. In IS-IS networks, routing inter-area traffic from L1 areas is accomplished by sending the traffic to the nearest L1/L2 router. A L1/L2 router identifies itself by setting an attach-bit (ATT-bit) in its (LSP). The ATT-bit in LSP can be changed using the set-attached-bit or no-set-attached-bit commands (similar to ‘set-overload-bit’ and 'no set-overload-bit’) using telnet terminal in router configuration mode. Steps: enable configure terminal router isis <Routing area> set-attached-bit V2: Removed looping through area list as this well set the bit for all areas in the list. This implementation now looks exactly like the current overload bit implementation. Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
* isisd: Add new adjacency to LSP neighbor listAmritha Nambiar2015-09-031-1/+7
| | | | | | | | | | | | | | | | | | isis_pdu.c : New adjacency did not always get added to LSP neighbor list. The adjacencies that were created once minimum time allowed before LSP retransmission had surpassed, instantly got their LSP regenerated, but the adjacency circuit type was not set to IIH PDU circuit type before the LSP was regenerated , hence didn't pass the check for adjacency circuit type in lsp_build(), and the adjacency was not added to neighbor list. When a new adjacency is up, to build LSP with neighbor entry corresponding to the adjacency, set adjacency circuit type to circuit type from hello PDU header before new LSP is regenerated/built. This will result in the new adjacency entry getting added to the LSP neighbor list TLV. Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
* pimd: Create ability to modify hell and hold timers per interfaceDonald Sharp2015-09-033-1/+79
| | | | | | | | | | | Create new per interface command: 'ip pim hello <1-180> {<1-180>}' The first number is the Hello Timer for this interface The second number is the Hold Timer to pass to neighbors on this interface. The second number is optional. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: Change ioctl call failure from vty_out to zlog_warnDonald Sharp2015-08-211-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | The command 'show ip multicast' when run, iterates over all interfaces on the router, if you do not have pim configured on that interface it would generate an error message: Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut br1 20.0.15.1 7 7 0 0 0 0 swp1 169.254.0.10 3 3 0 0 0 0 swp2 169.254.0.26 4 4 0 0 0 0 ioctl(SIOCGETVIFCNT=35296) failure for interface swp3 vif_index=-1: errno=22: Invalid argument ioctl(SIOCGETVIFCNT=35296) failure for interface swp4 vif_index=-1: errno=22: Invalid argument This fixes the issue to display this instead: Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut br1 20.0.15.1 7 7 0 0 0 0 swp1 169.254.0.10 3 3 0 0 0 0 swp2 169.254.0.26 4 4 0 0 0 0 swp3 0.0.0.0 5 -1 0 0 0 0 swp4 0.0.0.0 6 -1 0 0 0 0 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: Ensure new generation_id is different from previousDonald Sharp2015-08-211-1/+13
| | | | | | | | | | | | | | | | The RFC states that an interfaces generation_id must be changed if it experiences an if down. From 4.3.1: The GenID option contains a randomly generated 32-bit value that is regenerated each time PIM forwarding is started or restarted on the interface, including when the router itself restarts. Since we are only grabbing a new generation_id without comparing it to the previous generation_id, it is possible that random can generate the exact same number. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: Stop DR election on every helloDonald Sharp2015-08-211-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DR election is occurring on every hello received. This is because the hello receive packet returns a 0 for any successfully received packet. PIMD then looked at the 0 returned and did a DR election. Code was inspected for the cases where DR should happen: (A) Interface ip address change (B) DR priority in hello packet changes (C) Received a new neighbor on an interface (D) Neighbor timer pops. Each of these initiate a DR election in the code currently. Testing was initiated on a pim network: tor-11# show ip pim designated-router NonPri: Number of neighbors missing DR Priority hello option Interface Address DR Uptime Elections Changes NonPri br1 20.0.15.1 20.0.15.1 00:08:16 1 1 0 swp1 169.254.0.10 169.254.0.10 00:08:16 2 1 0 swp2 169.254.0.26 169.254.0.26 00:08:16 2 1 0 tor-11# As you can see Elections == 2. This is because pimd performs an election on (A) and (C) above. I see no need to modify (A) to check if we have any knowledge of the interface before this call. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: Fix first DR ElectionDonald Sharp2015-08-211-20/+20
| | | | | | | | | | | | The function pim_neighbor_new caused the dr election before the addition of the neighbor to the pim_ifp->pim_neighbor_list, in pim_neighbor_add, which is needed to properly elect the correct DR. Move the dr_election and hello trigger till after the addition to the list. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: Add ability to set DR Priority for an interfaceDonald Sharp2015-08-214-7/+82
| | | | | | | | | | | | | | | | | | From RFC 4601, Section 4.3.1: The DR_Priority Option allows a network administrator to give preference to a particular router in the DR election process by giving it a numerically larger DR Priority. The DR_Priority Option SHOULD be included in every Hello message, even if no DR Priority is explicitly configured on that interface. This is necessary because priority-based DR election is only enabled when all neighbors on an interface advertise that they are capable of using the DR_Priority Option. The default priority is 1. This modification allows the setting of the DR Priority on a per interface basis. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pimd: add support for configuring multicast static routesJafar Al-Gharaibeh2015-08-218-7/+731
| | | | | | | | | | | | | | | | | | | | | | Hi, This patch adds the ability to configure multicast static routes directly into pimd. Two source files are introduced to implement the new feature in addition to changes to existing files. Here is how it can be used the CLI: interface <incoming interface> ip mroute <outgoing interface> <group addr> # for asm or ip mroute <outgoing interface> <group addr> <source> # for ssm Please let me know if you have any questions or concerns, Regards, Jafar Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* vtysh: adjust bad_cli_stomps in extract.pl.in to reflect fixes & fix buildPaul Jakma2015-08-041-1/+1
|
* ospfd: Use route_node_lookup() instaed of route_node_get()Joakim Tjernlund2015-08-042-2/+6
| | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
* Removal of 'show ip mroute'Donald Sharp2015-08-041-92/+0
| | | | | | | | | | The 'show ip mroute' in zebra_vty.c collided with the 'show ip mroute' command in pim_cmd.c. The 'show ip rpf' command is functionally equivalent to the zebra_vty.c 'show ip mroute'. Therefore remove the 'show ip mroute' command in zebra_vty.c. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Fix _netlink_route_debug messageKaloyan Kovachev2015-07-291-0/+1
|
* watchquagga.c does not compile without warningsDonald Sharp2015-07-291-3/+5
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* pim: 'show debugging' collisionDonald Sharp2015-07-291-6/+7
| | | | | | | The 'show debugging' cli as setup by pim collided with 'show debugging isis'. Fix that and clean up cli help commands to actually display correctly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Fixup of redhat control files to properly start pimdDonald Sharp2015-07-291-0/+1
|
* ospfd: ospf_nbr_nbma_set()/ospf_snmp_vl_add() add unlockJoakim Tjernlund2015-07-292-0/+5
| | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Feng Lu <lu.feng@6wind.com>
* ospfd: ospf_ls_upd_send() add missing unlock.Joakim Tjernlund2015-07-291-0/+2
| | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Feng Lu <lu.feng@6wind.com>
* ospfd: ospf_ase.c, external_lsa locking fixes.Joakim Tjernlund2015-07-291-4/+6
| | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Feng Lu <lu.feng@6wind.com>
* ospfd: Move route_unlock_node() in ospf_ase_incremental_update()Joakim Tjernlund2015-07-291-1/+1
| | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Feng Lu <lu.feng@6wind.com>
* ospfd: add missing unlock for ospf_interface_address_delete()Joakim Tjernlund2015-07-291-0/+1
| | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Acked-by: Feng Lu <lu.feng@6wind.com>
* ospfd: Self nbrs needs to be rebuilt when router ID changes.Joakim Tjernlund2015-07-291-2/+9
| | | | | | | | | | | Some self nbrs are identified by router_id, these needs to be rebuilt instead of just resetting router ID. Possibly one could optimize for !(virtual | ptop) links by doing oi->nbr_self->router_id = router_id instead. Router ID will change once after startup config has been read and zebra reports router ID, unless router ID has been configured in ospf.
* pimd assert when no route to source from a new igmp joinDonald Sharp2015-06-211-1/+6
| | | | | | | | | When pim_upstream_new is called the code looks up the nexthop. If there is no route to the source, the code silently ignored the error returned. When the nexthop lookup fails don't create the 'struct pim_stream *' to return. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Add code to extract.pl.in to prevent further cli function overwritesDonald Sharp2015-06-211-0/+29
| | | | | | | | | | | | | | | | | Currently extract.pl.in is used to build the vtysh cli. When two different cli's collide with the same command name, the original cli is never called, because it is dropped. This code notes the silent drop and tracks the number of drops. If they change then the code will fail the build. The current number of drops was figured out by running extract.pl and counting up the drops then adding code to compare the numbers returned. If you have added to the problem, the solution is to fix your cli command to not stomp on someone else's command. If you have removed a stomp, safely modify extract.pl.in as part of your commit. Signed-off-by: Donald Sharp <sharpd at cumulusnetworks.com> Acked-by: Vincent Jardin <vincent.jardin@6wind.com>
* pim_mroute.h has a different version of code than linux/mroute.h providesDonald Sharp2015-06-212-0/+9
| | | | | | | | | | | linux/mroutes.h and pim_mroute.h both have copies of the same structures. This is causing failures in setsockopt(..., MRT_ADD_MFC,...) because of data structure incompatibilities between the kernel and what pim_mroute.h was providing. Modify the code to check for mroute.h and include it if necessary. I did not modify the non linux/mroute.h path because I do not have other systems to test on easily. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Quagga: Fix code to use srandom/randomDonald Sharp2015-06-218-21/+10
| | | | | | | | Quagga was using a mix of srand/rand and srandom/random. Consolidate to use srandom/random which are the POSIX versions of random number generators Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* PIMD: Fix code to use srandom/randomDonald Sharp2015-06-216-101/+9
| | | | | | | | pimd rolled it's own solution to random #'s, that was not terribly random. Rely on the underlying system to generate random #'s for us Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib, stream: fix stream sanity checksWenjian Ma2015-06-211-1/+1
| | | | | | Because operator "!" has higher priority than "&&", So we put the "&&" expression in "()" to check both getp and endp. Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: peer_uptime overflows after 1 yearPaul Jakma2015-06-211-3/+8
| | | | | | | | | * bgpd.c: (peer_uptime) Wraps after 1 year, and doesn't indicate years. Fix. Assume a year is 365 days, for an easy life. Fixes: Bug #836 Reported-by: Rolf Hanßen Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib, vtysh: support multiple VRFs by using linux netnsFeng Lu2015-06-035-17/+241
| | | | | | | | | | | | | | | | | | | | | | | | | We realize VRFs with linux netns by default. The main job is to associate a VRF with a netns. Currently this is done by the configuration: [no] vrf N netns <netns-name> This command is also available in vtysh and goes to only zebra, because presently only zebra supports multiple VRF. A file descriptor is added to "struct vrf". This is for the associated netns file. Once the command "vrf N netns NAME" is executed, the specified file is opened and the file descriptor is stored in the VRF N. In this way the association is formed. In vrf_socket(), we first switch to the specified VRF by using the stored file descriptor, and then can allocate a socket which is working in the associated netns. 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>
* *: add VRF ID in the API message headerFeng Lu2015-06-0327-385/+705
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The API messages are used by zebra to exchange the interfaces, addresses, routes and router-id information with its clients. To distinguish which VRF the information belongs to, a new field "VRF ID" is added in the message header. And hence the message version is increased to 3. * The new field "VRF ID" in the message header: Length (2 bytes) Marker (1 byte) Version (1 byte) VRF ID (2 bytes, newly added) Command (2 bytes) - Client side: - zclient_create_header() adds the VRF ID in the message header. - zclient_read() extracts and validates the VRF ID from the header, and passes the VRF ID to the callback functions registered to the API messages. - All relative functions are appended with a new parameter "vrf_id", including all the callback functions. - "vrf_id" is also added to "struct zapi_ipv4" and "struct zapi_ipv6". Clients need to correctly set the VRF ID when using the API functions zapi_ipv4_route() and zapi_ipv6_route(). - Till now all messages sent from a client have the default VRF ID "0" in the header. - The HELLO message is special, which is used as the heart-beat of a client, and has no relation with VRF. The VRF ID in the HELLO message header will always be 0 and ignored by zebra. - Zebra side: - zserv_create_header() adds the VRF ID in the message header. - zebra_client_read() extracts and validates the VRF ID from the header, and passes the VRF ID to the functions which process the received messages. - All relative functions are appended with a new parameter "vrf_id". * Suppress the messages in a VRF which a client does not care: Some clients may not care about the information in the VRF X, and zebra should not send the messages in the VRF X to those clients. Extra flags are used to indicate which VRF is registered by a client, and a new message ZEBRA_VRF_UNREGISTER is introduced to let a client can unregister a VRF when it does not need any information in that VRF. A client sends any message other than ZEBRA_VRF_UNREGISTER in a VRF will automatically register to that VRF. - lib/vrf: A new utility "VRF bit-map" is provided to manage the flags for VRFs, one bit per VRF ID. - Use vrf_bitmap_init()/vrf_bitmap_free() to initialize/free a bit-map; - Use vrf_bitmap_set()/vrf_bitmap_unset() to set/unset a flag in the given bit-map, corresponding to the given VRF ID; - Use vrf_bitmap_check() to test whether the flag, in the given bit-map and for the given VRF ID, is set. - Client side: - In "struct zclient", the following flags are changed from "u_char" to "vrf_bitmap_t": redist[ZEBRA_ROUTE_MAX] default_information These flags are extended for each VRF, and controlled by the clients themselves (or with the help of zclient_redistribute() and zclient_redistribute_default()). - Zebra side: - In "struct zserv", the following flags are changed from "u_char" to "vrf_bitmap_t": redist[ZEBRA_ROUTE_MAX] redist_default ifinfo ridinfo These flags are extended for each VRF, as the VRF registration flags. They are maintained on receiving a ZEBRA_XXX_ADD or ZEBRA_XXX_DELETE message. When sending an interface/address/route/router-id message in a VRF to a client, if the corresponding VRF registration flag is not set, this message will not be dropped by zebra. - A new function zread_vrf_unregister() is introduced to process the new command ZEBRA_VRF_UNREGISTER. All the VRF registration flags are cleared for the requested VRF. Those clients, who support only the default VRF, will never receive a message in a non-default VRF, thanks to the filter in zebra. * New callback for the event of successful connection to zebra: - zclient_start() is splitted, keeping only the code of connecting to zebra. - Now zclient_init()=>zclient_connect()=>zclient_start() operations are purely dealing with the connection to zbera. - Once zebra is successfully connected, at the end of zclient_start(), a new callback is used to inform the client about connection. - Till now, in the callback of connect-to-zebra event, all clients send messages to zebra to request the router-id/interface/routes information in the default VRF. Of corse in future the client can do anything it wants in this callback. For example, it may send requests for both default VRF and some non-default 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: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra, lib/memtypes.c: the netlink sockets work per VRFFeng Lu2015-06-0317-120/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch lets the netlink sockets work per VRF. * The definition of "struct nlsock" is moved into zebra/rib.h. * The previous global variables "netlink" and "netlink_cmd" now become the members of "struct zebra_vrf", and are initialized in zebra_vrf_alloc(). * All relative functions now work for a specific VRF, by adding a new parameter which specifies the working VRF, except those functions in which the VRF ID can be obtained from the interface. * kernel_init(), interface_list() and route_read() are now also working per VRF, and moved from main() to zebra_vrf_enable(). * A new function kernel_terminate() is added to release the netlink sockets. It is called from zebra_vrf_disable(). * Correct VRF ID, instead of the previous VRF_DEFAULT, are now passed to the functions of processing interfaces or route entries. 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: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra: fix VRF code for *BSDDavid Lamparter2015-06-021-1/+1
| | | | | | | There seems to be no rtm_table in struct rt_msghdr, at least on the systems I have access to... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* zebra: maintain RTADV per VRFFeng Lu2015-06-025-68/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This moves the global variable "rtadv" into the "struct zebra_vrf", so that RTADV feature can work per VRF. * rtadv.c/rtadv.h: Add a proper parameter to the functions so that the entity of the "struct zebra_vrf" and interfaces can be obtained from the specified VRF. The old rtadv_init() is splitted into: - rtadv_cmd_init(): it installs the RTADV commands; is called from main(); - new rtadv_init(): it creates the socket; is called from zebra_vrf_enable(). rtadv_terminate() is added to stop the threads, close the socket and clear the counters. It is called from zebra_vrf_disable(). rtadv_make_socket() now calls vrf_socket() to create a socket in the VRF. * interface.h and rib.h: define the macro RTADV. * main.c: according changes, refer to rtadv.c. 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>
* zebra: add hooks upon enabling / disabling a VRFFeng Lu2015-06-024-1/+79
| | | | | | | | | | | | | | | zebra_vrf_enable() is the callback for VRF_ENABLE_HOOK. It presently needs do nothing. zebra_vrf_disable() is the callback for VRF_DISABLE_HOOK. It presently withdraws routes, shuts down interfaces, and clears the router-id candidates in that VRF. 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>
* lib/vrf: enable / disable a VRFFeng Lu2015-06-022-1/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new API vrf_is_enabled() is defined to check whether a VRF is ready to use, that is, to allocate resources in that VRF. Currently there's only one type of resource: socket. Two new hooks VRF_ENABLE_HOOK/VRF_DISABLE_HOOK are introduced to tell the user when a VRF gets ready or to be unavailable. The VRF_ENABLE_HOOK callback is called in the new function vrf_enable(), which is used to let the VRF be ready to use. Till now, only the default VRF can be enabled, and we need do nothing to enable the default, except calling the hook. The VRF_DISABLE_HOOK callback is called in the new function vrf_disable(), which is used to let the VRF be unusable. Till now, it is called only when the VRF is to be deleted. A new utility vrf_socket() is defined to provide a socket in a given VRF to the user. Till now before introducing a way of VRF realization, only the default VRF is enabled since its birth, and vrf_socket() creates socket for only the default VRF. This patch defines the framework of the VRF APIs. The way they serve the users is: - vrf_is_enabled() is used to tell the user whether a VRF is usable; - users are informed by the VRF_ENABLE_HOOK that a VRF gets usable; they can allocate resources after that; - users are informed by the VRF_DISABLE_HOOK that a VRF is to be unavailable, and they must release the resources instantly; - vrf_socket() is used to provide a socket in a given VRF. 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>