summaryrefslogtreecommitdiffstats
path: root/lib/stream.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: remove VERSION_TYPE_DEV from CONFDATE checksLou Berger2018-07-101-1/+1
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* lib, zebra: Add a bit of code to look at fifoDonald Sharp2018-06-281-0/+3
| | | | | | | When in a dev build add a bit of code to track max depth of a fifo and to allow zebra to report on it. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib: add mt-safe variants for stream_fifo opsQuentin Young2018-05-071-2/+91
| | | | | | | | | | stream_fifo is used as our standard internal message queue. Message queues are useful in multithreaded environments. Up until now I have been doing my own synchronization when using stream_fifo in this way; this patch gets rid of the need for that boilerplate and decreases the risk of locking mistakes when working with this datastructure. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: Only test CONFDATE when VERSION_TYPE_DEV definedLou Berger2018-04-031-1/+1
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-22/+22
| | | | | | | | | | | | | | | | | | | | | | 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>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-22/+22
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* *: don't use deprecated stream.h macrosQuentin Young2017-12-011-1/+6
| | | | | | | Some of the deprecated stream.h macros see such little use that we may as well just remove them and use the non-deprecated macros. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: Add STREAM_GETX functionsDonald Sharp2017-11-131-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when stream reads fail, for any reason, we assert. While a *great* debugging tool, Asserting on production code is not a good thing. So this is the start of a conversion over to a series of STREAM_GETX functions that do not assert and allow the developer a way to program this gracefully and still clean up. Current code is something like this( taken from redistribute.c because this is dead simple ): afi = stream_getc(client->ibuf); type = stream_getc(client->ibuf); instance = stream_getw(client->ibuf); This code has several issues: 1) There is no failure mode for the stream read other than assert. if afi fails to be read the code stops. 2) stream_getX functions cannot be converted to a failure mode because it is impossible to tell a failure from good data with this api. So this new code will convert to this: STREAM_GETC(client->ibuf, afi); STREAM_GETC(client->ibuf, type); STREAM_GETW(client->ibuf, instance); .... stream_failure: return; We've created a stream_getc2( which does not assert ), but we need a way to allow clean failure mode handling. This is done by macro'ing stream_getX2 functions with the equivalent all uppercase STREAM_GETX functions that include a goto. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: fix be32 reading / 24-bit left shiftDavid Lamparter2017-09-091-0/+18
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-92/+88
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: Install SAFI_LABELED_UNICAST routes in SAFI_UNICAST tableDaniel Walton2017-06-161-1/+2
| | | | | | | | | | | | | | | | | | | | | Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> - All ipv4 labeled-unicast routes are now installed in the ipv4 unicast table. This allows us to do things like take routes from an ipv4 unicast peer, allocate a label for them and TX them to a ipv4 labeled-unicast peer. We can do the opposite where we take routes from a labeled-unicast peer, remove the label and advertise them to an ipv4 unicast peer. - Multipath over a labeled route and non-labeled route is not allowed. - You cannot activate a peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast' - The 'tag' variable was overloaded for zebra's route tag feature as well as the mpls label. I added a 'mpls_label_t mpls' variable to avoid this. This is much cleaner but resulted in touching a lot of code.
* *: 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>
* bgpd: labeled unicast processingDon Slice2017-04-061-1/+2
| | | | | | | | | Implement support for negotiating IPv4 or IPv6 labeled-unicast address family, exchanging prefixes and installing them in the routing table, as well as interactions with Zebra for FEC registration. This is the implementation of RFC 3107. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
* Update Traffic Engineering Support for OSPFDOlivier Dugeon2016-09-031-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NOTE: I am squashing several commits together because they do not independently compile and we need this ability to do any type of sane testing on the patches. Since this series builds together I am doing this. -DBS This new structure is the basis to get new link parameters for Traffic Engineering from Zebra/interface layer to OSPFD and ISISD for the support of Traffic Engineering * lib/if.[c,h]: link parameters struture and get/set functions * lib/command.[c,h]: creation of a new link-node * lib/zclient.[c,h]: modification to the ZBUS message to convey the link parameters structure * lib/zebra.h: New ZBUS message Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> Add support for IEEE 754 format * lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to safely convert between big-endian IEEE-754 single and double binary format, as used in IETF RFCs, and C99. Implementation depends on host using __STDC_IEC_559__, which should be everything we care about. Should correctly error out otherwise. * lib/network.[c,h]: Add ntohf and htonf converter * lib/memtypes.c: Add new memeory type for Traffic Engineering support Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> Add link parameters support to Zebra * zebra/interface.c: - Add new link-params CLI commands - Add new functions to set/get link parameters for interface * zebra/redistribute.[c,h]: Add new function to propagate link parameters to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering. * zebra/redistribute_null.c: Add new function zebra_interface_parameters_update() * zebra/zserv.[c,h]: Add new functions to send link parameters Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> Add support of new link-params CLI to vtysh In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue to use the ordered version for adding line i.e. config_add_line_uniq() to print Interface CLI commands as it completely break the new LINK_PARAMS_NODE. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> Update Traffic Engineering support for OSPFD These patches update original code to RFC3630 (OSPF-TE) and add support of RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support of RFC6827 (ASON - GMPLS). * ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering * ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392 * ospfd/ospf_packet.c: Update checking of OSPF_OPTION * ospfd/ospf_vty.[c,h]: Update ospf_str2area_id * ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get Link Parameters information from the interface to populate Traffic Engineering metrics * ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN) * ospfd/ospf_te.[c,h]: Major modifications to update the code to new link parameters structure and new RFCs Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> tmp
* lib: add 3-byte stream functionsDavid Lamparter2016-07-281-0/+4
| | | | | | This will be used for BGP MPLS labels. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* stream: remove unused stream_read_unblockStephen Hemminger2016-05-261-4/+0
| | | | | | | | The one place this was being used in BGP is now gone, can remove deprecated interface. Acked-by: Feng Lu <lu.feng@6wind.com> (cherry picked from commit 3790eb0d3f0bbb24b9c6be97f547cec144ee05d1)
* BGP: support for addpath TXDaniel Walton2015-11-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Vivek Venkataraman <vivek@cumulusnetworks.com Ticket: CM-8014 This implements addpath TX with the first feature to use it being "neighbor x.x.x.x addpath-tx-all-paths". One change to show output is 'show ip bgp x.x.x.x'. If no addpath-tx features are configured for any peers then everything looks the same as it is today in that "Advertised to" is at the top and refers to which peers the bestpath was advertise to. root@superm-redxp-05[quagga-stash5]# vtysh -c 'show ip bgp 1.1.1.1' BGP routing table entry for 1.1.1.1/32 Paths: (6 available, best #6, table Default-IP-Routing-Table) Advertised to non peer-group peers: r1(10.0.0.1) r2(10.0.0.2) r3(10.0.0.3) r4(10.0.0.4) r5(10.0.0.5) r6(10.0.0.6) r8(10.0.0.8) Local, (Received from a RR-client) 12.12.12.12 (metric 20) from r2(10.0.0.2) (10.0.0.2) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 8 Last update: Fri Oct 30 18:26:44 2015 [snip] but once you enable an addpath feature we must display "Advertised to" on a path-by-path basis: superm-redxp-05# show ip bgp 1.1.1.1/32 BGP routing table entry for 1.1.1.1/32 Paths: (6 available, best #6, table Default-IP-Routing-Table) Local, (Received from a RR-client) 12.12.12.12 (metric 20) from r2(10.0.0.2) (10.0.0.2) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 8 Advertised to: r8(10.0.0.8) Last update: Fri Oct 30 18:26:44 2015 Local, (Received from a RR-client) 34.34.34.34 (metric 20) from r3(10.0.0.3) (10.0.0.3) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 7 Advertised to: r8(10.0.0.8) Last update: Fri Oct 30 18:26:39 2015 Local, (Received from a RR-client) 56.56.56.56 (metric 20) from r6(10.0.0.6) (10.0.0.6) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 6 Advertised to: r8(10.0.0.8) Last update: Fri Oct 30 18:26:39 2015 Local, (Received from a RR-client) 56.56.56.56 (metric 20) from r5(10.0.0.5) (10.0.0.5) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 5 Advertised to: r8(10.0.0.8) Last update: Fri Oct 30 18:26:39 2015 Local, (Received from a RR-client) 34.34.34.34 (metric 20) from r4(10.0.0.4) (10.0.0.4) Origin IGP, metric 0, localpref 100, valid, internal AddPath ID: RX 0, TX 4 Advertised to: r8(10.0.0.8) Last update: Fri Oct 30 18:26:39 2015 Local, (Received from a RR-client) 12.12.12.12 (metric 20) from r1(10.0.0.1) (10.0.0.1) Origin IGP, metric 0, localpref 100, valid, internal, best AddPath ID: RX 0, TX 3 Advertised to: r1(10.0.0.1) r2(10.0.0.2) r3(10.0.0.3) r4(10.0.0.4) r5(10.0.0.5) r6(10.0.0.6) r8(10.0.0.8) Last update: Fri Oct 30 18:26:34 2015 superm-redxp-05#
* BGP: Add dynamic update group supportDonald Sharp2015-05-201-0/+3
| | | | | | | | | | | | | | | | | | | | This patch implements the 'update-groups' functionality in BGP. This is a function that can significantly improve BGP performance for Update generation and resultant network convergence. BGP Updates are formed for "groups" of peers and then replicated and sent out to each peer rather than being formed for each peer. Thus major BGP operations related to outbound policy application, adj-out maintenance and actual Update packet formation are optimized. BGP update-groups dynamically groups peers together based on configuration as well as run-time criteria. Thus, it is more flexible than update-formation based on peer-groups, which relies on operator configuration. [Note that peer-group based update formation has been introduced into BGP by Cumulus but is currently intended only for specific releases.] From 11098af65b2b8f9535484703e7f40330a71cbae4 Mon Sep 17 00:00:00 2001 Subject: [PATCH] updgrp commits
* bgpd: efficient NLRI packing for AFs != ipv4-unicastPradosh Mohapatra2014-06-031-0/+11
| | | | | | | | | | | | | | | | | | | | | ISSUE: Currently, for non-ipv4-unicast address families where prefixes are encoded in MP_REACH/MP_UNREACH attributes, BGP ends up sending one prefix per UPDATE message. This is quite inefficient. The patch addresses the issue. PATCH: We introduce a scratch buffer in the peer structure that stores the MP_REACH/MP_UNREACH attributes for non-ipv4-unicast families. This enables us to encode multiple prefixes. In the end, the two buffers are merged to create the UPDATE packet. Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> [DL: removed no longer existing bgp_packet_withdraw prototype] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: add stream_set_endp()Subbaiah Venkata2012-04-071-0/+1
| | | | | | | | | | | | | * lib/stream.[ch]: - Add stream_set_endp(). This can be used to trim data (for example, padding) at the end of a stream. - Fix swapped 'getp' and 'endp' parameters in STREAM_WARN_OFFSETS. From: Subbaiah Venkata <svenkata@google.com> Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@diac24.net>
* [lib] trivial: add const qualifier to stream_put/writePaul Jakma2008-06-071-2/+2
| | | | | | | 2008-06-07 Paul Jakma <paul@jakma.org> * stream.{c,h}: (stream_{put,write}) add const qualifier to source argument. Change u_char to void *.
* [c++] remove/rename some names in headers that clash with C++ reserved wordsPaul Jakma2008-02-261-1/+1
| | | | | | | | | | | 2008-01-30 Peter Szilagyi <sp615@hszk.bme.hu> * lib/stream.h: Remove named 'new' parameter in prototype for c++ header compatibility. * ospfd/ospf_opaque.h: ditto * ospfd/ospfd.h: Renamed struct export to _export for c++ header compatibility. * ospf6d/ospf6_area.h: ditto
* [stream] Add quad-word support and stream_resizepaul2006-01-101-3/+14
| | | | | | | | | | | | 2006-01-10 Paul Jakma <paul.jakma@sun.com> * stream.c: (stream_new) Allocate stream data as seperate object. (stream_free) free the data. (stream_resize) new function, resize stream to new size. (stream_{get,put}q*) new functions to get/put quad word size types. * stream.h: (struct stream) make data seperate from the stream. Export new stream_resize and quad-word get/put functions.
* [c99] change gcc zero-length array to C99 flexible array declarationpaul2005-11-261-1/+1
| | | | | | | | | 2005-11-26 Paul Jakma <paul.jakma@sun.com> * buffer.c: (struct buffer_data) change gcc zero array declaration to C99 incomplete array. * stream.h: (struct stream) same * ospf_api.c: (struct opaque_lsa) same
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-49/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | * (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-05-03 Paul Jakma <paul@dishone.st>paul2005-05-031-7/+8
| | | | | | | | | | | * stream.h: Add comment about the special zero-ing ability of stream_put. (stream_recvmsg, stream_write) should return ssize_t and size_t respectively. Should both be extern linkage. (stream_recvfrom) Stream aware wrapper around recvfrom, in style of stream_read_try. * stream.c: (stream_recvfrom) new function, wrapper around recvfrom. (stream_recvmsg, stream_write) ssize_t and size_t return values
* 2005-02-24 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-02-241-1/+1
| | | | | | | * stream.c: (stream_read_try) Log a warning message if a fatal I/O error occurs. (stream_fifo_new) Fix prototype. * stream.h: Fix prototype for stream_fifo_new (need void arg).
* 2005-02-16 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-02-161-0/+17
| | | | | | | | | | * stream.h: Declare new function stream_read_try suitable for use with non-blocking file descriptors. Indicate that stream_read and stream_read_unblock are deprecated. * stream.c: (stream_read_try) New function for use with non-blocking I/O. (stream_recvmsg) Should return -1 if the stream is too small to contain the data.
* 2005-02-14 Paul Jakma <paul.jakma@sun.com>paul2005-02-151-17/+95
| | | | | | | | | | | | | | | | | | | | * stream.h: Unsigned long updated to size_t * stream.c: ditto * stream.h: Add stream_copy, stream_dup, stream_recvmsg. Add comment describing struct stream abstraction, and various other comments. Deprecate several unsafe/ambigious macros. Add STREAM_WRITEABLE and STREAM_READABLE. Add (stream_getl_from) for symmetry. Update stream_forward_{endp,getp} to use size_t offset. Make stream data a 0 length array, rather than a seperate malloc. * stream.c: Add consistency checks. Update to follow stream.h changes. (stream_new) Alloc stream+data in one go. (stream_copy) new function, copy a stream. (stream_dup) new function, dup a stream. (stream_recvmsg) new function, recvmsg data into a stream. (stream_empty) no need to check getp == 0.
* 2005-02-12 Paul Jakma <paul.jakma@sun.com>paul2005-02-121-13/+13
| | | | | * stream.h: Unsigned long updated to size_t * stream.c: ditto
* 2005-02-09 Paul Jakma <paul.jakma@sun.com>paul2005-02-091-8/+3
| | | | | | | | | | | | | * (global) Update code to match stream.h changes. stream_get_putp effectively replaced with stream_get_endp. stream_forward renamed to stream_forward_getp. stream_forward_endp introduced to replace some previous setting/manual twiddling of putp by daemons. * lib/stream.h: Remove putp. Update reference to putp with endp. Add stream_forward_endp, which daemons were doing manually. Rename stream_forward to stream_forward_getp. lib/stream.c: Remove/update references to putp. introduce stream_forward_endp.
* 2004-06-11 Sowmini Varadhan <sowmini.varadhan@sun.com>paul2004-06-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | * filter.c: (access_list_remark_cmd) buffer_putstr doesnt need cast to u_char. (ipv6_access_list_remark_cmd) ditto. if.c: ditto * network.c: (readn/writen) pointer arg should be type u_char. * plist.c: needs to include stream.h, not declare stream functions internally. (various) Add static qualifier to internal functions. (prefix_list_type_str) extraneous breaks in switch statement. (ip_prefix_list_description_cmd) buffer_putstr doesnt need cast * stream.h: depends on plist.h and export stream_put_prefix * vty.c: (vty_<telnet option build functions>) should use unsigned char, telnet options are 0 -> 255. * zclient.c: various u_char<->char type cleanups. * zebra.h: Having to define CMSG_* can apply to more than just BSDI_NRL. * ripd.c: (rip_distribute_update_all) distribute list hook function pointer prototype requires struct prefix_list * arg. (rip_distribute_update_all_wrapper) update to pass required arg, NULL.
* Initial revisionpaul2002-12-131-0/+113