summaryrefslogtreecommitdiff
path: root/ofproto/netflow.c
Commit message (Collapse)AuthorAgeFilesLines
* hmap: use short version of safe loops if possible.Adrian Moreno2022-03-301-4/+4
| | | | | | | | | | | | | | | Using SHORT version of the *_SAFE loops makes the code cleaner and less error prone. So, use the SHORT version and remove the extra variable when possible for hmap and all its derived types. In order to be able to use both long and short versions without changing the name of the macro for all the clients, overload the existing name and select the appropriate version depending on the number of arguments. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
* socket-util: Make inet_parse_active() and inet_parse_passive() more alike.Ben Pfaff2018-04-161-1/+1
| | | | | | | | | | | | | | Until now, the default_port parameters to these functions have had different types and different behavior. There is a reason for this, since it makes sense to listen on a kernel-selected port but it does not make sense to connect to a kernel-selected port, but this overlooks the possibility that a caller might want to parse a string in the format understood by inet_parse_active() without actually using it to connect to a remote host. This commit makes the behavior consistent and updates all the callers to work with the new semantics. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mark Michelson <mmichels@redhat.com>
* sparse: Add guards to prevent FreeBSD-incompatible #include order.Ben Pfaff2017-12-221-0/+2
| | | | | | | | | | FreeBSD insists that <sys/types.h> be included before <netinet/in.h> and that <netinet/in.h> be included before <arpa/inet.h>. This adds guards to the "sparse" headers to yield a warning if this order is violated. This commit also adjusts the order of many #includes to suit this requirement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* lib: Move lib/poll-loop.h to include/openvswitchXiao Liang2017-11-031-1/+1
| | | | | | | | Poll-loop is the core to implement main loop. It should be available in libopenvswitch. Signed-off-by: Xiao Liang <shaw.leon@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* netflow: Fix memory leak in netflow_unref.Yunjian Wang2017-05-311-0/+8
| | | | | | | | The memory leak was triggered each time on calling netflow_unref() with containing netflow_flows. And flows need to be removed and destroyed. Signed-off-by: Yunjian Wang <wangyunjian@huawei.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Move lib/ofpbuf.h to include/openvswitch directoryBen Warren2016-03-301-1/+1
| | | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Acked-by: Ryan Moats <rmoats@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* netflow: Mark some function parameters 'const'.Ben Pfaff2015-07-231-3/+4
| | | | | Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ofpbuf: Simplify ofpbuf API.Pravin B Shelar2015-03-031-6/+6
| | | | | | | | | | | | ofpbuf was complicated due to its wide usage across all layers of OVS, Now we have introduced independent dp_packet which can be used for datapath packet, we can simplify ofpbuf. Following patch removes DPDK mbuf and access API of ofpbuf members. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* netflow: Fix interpretation of flow_seq.Motonori Shindo2014-11-041-1/+1
| | | | | | | | | 'flow_seq" field in NetFlow v5 header should represent a number of NetFlow flow records exported while it is representing the number of NetFlow packets exported in the current code. This patch fixes this problem. Signed-off-by: Motonori Shindo <motonori@shin.do> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto/netflow: Use atomic_count for 'netflow_count'.Jarno Rajahalme2014-08-291-11/+8
| | | | | | | | 'netflow_count' and the existence of actual netflow objects is not tightly synchronized, so we can use the relaxed atomic_count for it. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Use ovs_refcount_unref_relaxed.Jarno Rajahalme2014-07-071-1/+1
| | | | | | | | | | After a quick analysis, in most cases the access to refcounted objects is clearly protected either with an explicit lock/mutex, or RCU. there are only a few places where I left a call to ovs_refcount_unref(). Upon closer analysis it may well be that those could also use the relaxed form. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lib/hash: Abstract hash interface.Jarno Rajahalme2014-07-041-9/+9
| | | | | | | | | Use generic names hash_add() and hash_finish() instead of mhash_* equivalents. This makes future changes to hash implentations more localized. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* netflow: Fold netflow_expire() into netflow_flow_clear().Anoob Soman2014-06-091-15/+1
| | | | | | | | | | | | | | | | | | | netflow_flow_clear() asserted that no packets or bytes were included in the statistics for the flow being cleared. Before threading Open vSwitch, this assertion was always true because netflow_expire() was always called before calling netflow_flow_clear(). Since Open vSwitch was threaded, however, it was possible that a packet arrived after netflow_expire() but before netflow_flow_clear(), since each of these function separately took the netflow mutex. This commit fixes the problem by merging netflow_expire() into netflow_flow_clear(), under a single acquisition of the netflow mutex. Signed-off-by: Anoob Soman <anoob.soman@citrix.com> [blp@nicira.com modified the patch to remove netflow_expire() and rewrote the commit message] Signed-off-by: Ben Pfaff <blp@nicira.com>
* netflow: Correctly track flow creation time.Ben Pfaff2014-04-101-1/+0
| | | | | | | | | 'created' is supposed to be the time the flow was created, but it was getting reset to zero on every expiration, causing the flow start time to be wonky after the first active expiration on a flow. Reported-by: Lior Neudorfer <lior@guardicore.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofpbuf: Introduce access api for base, data and size.Pravin Shelar2014-03-301-6/+6
| | | | | | | These functions will be used by later patches. Following patch does not change functionality. Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
* ovs-atomic: Delete atomic, atomic_flag, ovs_refcount destroy functions.Ben Pfaff2014-03-131-2/+1
| | | | | | | | None of the atomic implementations need a destroy function anymore, so it's "more standard" and more convenient for users to get rid of them. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
* netflow: Make netflow_flow_update() parameter const.Joe Stringer2014-03-111-1/+1
| | | | | | | The 'flow' parameter is not modified, so mark it const. Signed-off-by: Joe Stringer <joestringer@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-atomic: Introduce a new 'struct ovs_refcount'.Ben Pfaff2014-01-081-14/+6
| | | | | | | | | | | This is a thin wrapper around an atomic_uint. It is useful anyhow because each ovs_refcount_ref() or ovs_refcount_unref() call saves a few lines of code. This commit also changes all the potential direct users over to use the new data structure. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-atomic: Add atomic_destroy() and use everywhere it is needed.Ben Pfaff2014-01-081-1/+2
| | | | | | | C11 is able to require that atomics don't need to be destroyed, but some of the OVS implementations do. Signed-off-by: Ben Pfaff <blp@nicira.com>
* flow: New function flow_unwildcard_tp_ports().Ethan Jackson2013-12-131-2/+1
| | | | | | | | | | This patch adds a new function flow_unildcard_tp_ports() which doesn't unwildcard the upper half of tp_src and tp_dst with ICMP packets. Unfortunately, this matters in future patches when we compare masks carefully to determine if flows should be evicted from the datapath. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto: New function netflow_exists().Ethan Jackson2013-12-121-1/+16
| | | | | | | Useful in future patches. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* netflow: Make thread safe.Ethan Jackson2013-12-121-12/+66
| | | | | | | In future patches upcall handler threads will need to update netflow. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ofproto: Modularize netflow.Ethan Jackson2013-12-121-78/+185
| | | | | | | | | | The netflow code has its tentacles all over the ofproto-dpif module. This is fine today, but in future facets, which correspond roughly to netflow_flows, will be retired. In preparation, this patch hides as much implementation detail as possible inside the netflow module. Signed-off-by: Ethan Jackson <ethan@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Widen TCP flags handling.Jarno Rajahalme2013-10-291-2/+2
| | | | | | | | | | | Widen TCP flags handling from 7 bits (uint8_t) to 12 bits (uint16_t). The kernel interface remains at 8 bits, which makes no functional difference now, as none of the higher bits is currently of interest to the userspace. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
* netflow: Only un-wildcard IPv4 packets.Justin Pettit2013-06-271-1/+4
| | | | | | | | NetFlow v5 only supports IPv4, so don't bother un-wildcarding non-IPv4 packets. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* ofproto-dpif: Always un-wildcard 'dl_type'.Justin Pettit2013-06-251-1/+0
| | | | | | | | We always look at the fragment status and often look at other L3 headers when processing the packet, so just un-wildcard the Ethertype. Signed-off-by: Justin Pettit <jpettit@nicira.com>
* Create specific types for ofp and odp portAlex Wang2013-06-201-5/+7
| | | | | | | | | | | | Until now, datapath ports and openflow ports were both represented by unsigned integers of various sizes. With implicit conversions, etc., it is easy to mix them up and use one where the other is expected. This commit creates two typedefs, ofp_port_t and odp_port_t. Both of these two types are marked by "__attribute__((bitwise))" so that sparse can be used to detect any misuse. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif: Tighten up megaflow wildcard handling.Justin Pettit2013-06-191-0/+12
| | | | | | | | | | | A number of use-cases weren't handled properly when determining what can be wildcarded for megaflows. This commit both catches additional fields that cannot be wildcarded and loosens a few other cases. Bug #17979 Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Fix misspellings in comments and docs.Andy Hill2013-06-041-2/+2
| | | | | | | | Flagged with: https://github.com/lyda/misspell-check Run with: git ls-files | misspellings -f - Signed-off-by: Andy Hill <hillad@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* netflow: Move packet definitions to header file.Ben Pfaff2011-12-191-55/+2
| | | | | | | | An upcoming commit will introduce code outside of ofproto/netflow.c that works with NetFlow packets, so we need the protocol definitions in a common location. Signed-off-by: Ben Pfaff <blp@nicira.com>
* ofproto-dpif: Factor NetFlow active timeouts out of flow expiration.Ben Pfaff2011-11-231-2/+25
| | | | | | | | | | | | NetFlow active timeouts were only mixed in with flow expiration for convenience: both processes need to iterate all the facets. But an upcoming commit will change flow expiration to work in terms of a new "subfacet" entity, so they will no longer fit together well. This change could be seen as an optimization, since NetFlow active timeouts don't ordinarily have to run as often as flow expiration, especially when the flow expiration rate is stepped up due to a large volume of flows.
* Prepend "nw_" to "frag" and "tos" elements.Justin Pettit2011-11-101-1/+1
| | | | | | Most of the members in structures referring to network elements indicate the layer (e.g., "tl_", "nw_", "tp_"). The "frag" and "tos" members didn't, so this commit add them.
* Don't overload IP TOS with the frag matching bits.Justin Pettit2011-11-091-1/+1
| | | | | | | | This will be useful later when we add support for matching the ECN bits within the TOS field. Signed-off-by: Justin Pettit <jpettit@nicira.com> Acked-by: Jesse Gross <jesse@nicira.com>
* Implement new fragment handling policy.Ben Pfaff2011-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, OVS has handled IP fragments more awkwardly than necessary. It has not been possible to match on L4 headers, even in fragments with offset 0 where they are actually present. This means that there was no way to implement ACLs that treat, say, different TCP ports differently, on fragmented traffic; instead, all decisions for fragment forwarding had to be made on the basis of L2 and L3 headers alone. This commit improves the situation significantly. It is still not possible to match on L4 headers in fragments with nonzero offset, because that information is simply not present in such fragments, but this commit adds the ability to match on L4 headers for fragments with zero offset. This means that it becomes possible to implement ACLs that drop such "first fragments" on the basis of L4 headers. In practice, that effectively blocks even fragmented traffic on an L4 basis, because the receiving IP stack cannot reassemble a full packet when the first fragment is missing. This commit works by adding a new "fragment type" to the kernel flow match and making it available through OpenFlow as a new NXM field named NXM_NX_IP_FRAG. Because OpenFlow 1.0 explicitly says that the L4 fields are always 0 for IP fragments, it adds a new OpenFlow fragment handling mode that fills in the L4 fields for "first fragments". It also enhances ovs-ofctl to allow users to configure this new fragment handling mode and to parse the new field. Signed-off-by: Ben Pfaff <blp@nicira.com> Bug #7557.
* lib: Whitespace cleanup.Ethan Jackson2011-08-121-1/+1
|
* Fix incorrect byte order annotations.Ben Pfaff2011-05-161-1/+1
| | | | | | | These are not actual bugs, just deceptive use of the wrong function or type. Found by sparse.
* Convert remaining network-byte-order "uint<N>_t"s into "ovs_be<N>"s.Ben Pfaff2011-05-161-20/+20
| | | | | | | | | I looked at almost every uint<N>_t in the tree to determine whether it was really in network byte order, and converted the ones that were. The only remaining ones, modulo my mistakes, are in openflow.h. I'm not sure whether we should convert those, because there might be some value in remaining close to upstream for this header.
* ofproto: Change string sets in interface from svec to sset.Ben Pfaff2011-03-311-2/+1
|
* lib: Replace IP_TYPE_ references with IPPROTO_.Justin Pettit2011-02-021-1/+1
| | | | | | A few common IP protocol types were defined in "lib/packets.h". However, we already assume the existence of <netinet/in.h> which contains a more exhaustive list and should be available on POSIX systems.
* ofproto: Avoid clearing NetFlow stats twice upon rule creation.Ben Pfaff2010-11-111-0/+8
| | | | | This seems cleaner to me: it seems risky to "clear" something that has not been initialized yet. It's also a super-minor optimization, I suppose.
* vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.Ben Pfaff2010-10-291-1/+1
| | | | | It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon, so this commit switches to the more common form.
* xtoxll: Rename "byte-order" since it now include more than xtoxll.Ben Pfaff2010-10-291-1/+1
| | | | Suggested-by: Justin Pettit <jpettit@nicira.com>
* netflow: Back-out optimization that could lead to infinite loopJustin Pettit2010-10-121-5/+2
| | | | | | | | | | | | Commit 924282 (netflow: Do 64-bit division less often.) attempted to remove the 64-bit division used to break flow records with large byte counts into multiple NetFlow records. The calculation to determine the number of records was incorrect and should have shifted "byte_delta" by 31 instead of 32. This commit reverts the change (while keeping commit f22a24 (netflow: Avoid (theoretically) looping 2**32 times.) ), since the logic is more straight-forward than the optimized version. Bug #3813
* netflow: Avoid (theoretically) looping 2**32 times.Ben Pfaff2010-10-011-17/+32
| | | | | | | | | If the netflow byte counter is UINT64_MAX, or at any rate much larger than UINT32_MAX, netflow_expire() could loop for a very long time. This commit avoids that case. This is only a theoretical bug fix. I don't know of any actual bug that would cause a counter to be that high.
* netflow: Do 64-bit division less often.Ben Pfaff2010-10-011-8/+11
| | | | | 64-bit division is expensive. Usually we can avoid it entirely, as done by this patch.
* netflow: Send multiple records for byte counts > UINT32_MAXJustin Pettit2010-09-011-23/+46
| | | | | | When a NetFlow record is to be sent for a flow that had more than 2^32 bytes, we used to set the byte count to UINT32_MAX. With this change, we will send out multiple records to account for all the traffic.
* treewide: Remove trailing whitespaceJoe Perches2010-08-301-2/+2
| | | | | | Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Simon Horman <horms@verge.net.au> Signed-off-by: Jesse Gross <jesse@nicira.com>
* datapath: Don't track IP TOS value two different ways.Ben Pfaff2010-08-021-4/+2
| | | | | | | | | | | | | Originally, the datapath didn't care about IP TOS at all. Then, to support NetFlow, we made it keep track of the last-seen IP TOS value on a per-flow basis. Then, to support OpenFlow 1.0, we added a nw_tos field to odp_flow_key. We don't need both methods, so this commit drops the NetFlow-specific tracking. This introduces a small kernel ABI break: upgrading the kernel module without upgrading the OVS userspace will mean that NetFlow records will all show an IP TOS value of 0. I don't consider that to be a serious problem.