summaryrefslogtreecommitdiff
path: root/lib/ovs-router.c
Commit message (Collapse)AuthorAgeFilesLines
* ovs-router: Fix memory leak at ovs_router_insert__.William Tu2016-03-311-1/+2
| | | | | | | | | | | Reported by Valgrind, testcase: ovn-controller-vtep - test vtep-lswitch. ovs_router_insert__ (ovs-router.c:185) route_table_handle_msg (route-table.c:299) route_table_reset (route-table.c:186) route_table_init (route-table.c:113) Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* sflow: use ovs route API to get source IP address.Pravin B Shelar2016-03-241-14/+19
| | | | | Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* tunneling: Handle multiple ip address for given device.Pravin B Shelar2016-03-241-8/+71
| | | | | | | | | | | | Device can have multiple IP address but netdev_get_in4/6() returns only one configured IPv6 address. Following patch fixes it. OVS router is also updated to return source ip address for given destination, This is required when interface has multiple IP address configured. Signed-off-by: Pravin B Shelar <pshelar@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* Move lib/dynamic-string.h to include/openvswitch directoryBen Warren2016-03-191-1/+1
| | | | | Signed-off-by: Ben Warren <ben@skyportsystems.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* Use ip_parse() and ipv6_parse() and variants in more places.Ben Pfaff2015-12-151-45/+14
| | | | | | | | | | | This saves some code and improves clarity, in my opinion. Some of these changes just change an inet_pton() call into a similar ip_parse() or ipv6_parse() call. In those cases the benefit is better type safety, since inet_pton()'s output parameter is type "void *". Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* packets: Introduce in6_addr_mapped_ipv4() and use where appropriate.Ben Pfaff2015-12-041-2/+1
| | | | | | | This allows code to be written more naturally in some cases. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
* ovs-router: Report ovs/route/add errors as errors.Ben Pfaff2015-11-251-5/+8
| | | | | | | | | The _error version should be used to report errors. Also, add missing return in one error case. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
* ovs-router: Use standard libraries in scan_ipv6_route().Justin Pettit2015-11-241-14/+14
| | | | | Signed-off-by: Justin Pettit <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* packets: Change IPv6 functions to more closely resemble IPv4 ones.Justin Pettit2015-11-241-3/+3
| | | | | Signed-off-by: Justin Petitt <jpettit@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
* route: support IPv6 and use IPv4-mapped addressesThadeu Lima de Souza Cascardo2015-10-131-51/+111
| | | | | | | | This adds support for IPv6 in ovs-router and route-table. IPv4 is stored in ovs-router using IPv4-mapped addresses. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* ovs-router: Include ovs-router.h as first header.Thadeu Lima de Souza Cascardo2015-09-171-1/+3
| | | | | Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovs-router: Add missing ds_destroy after ds was put.Thadeu Lima de Souza Cascardo2015-09-171-0/+1
| | | | | Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* tnl-ports: Add destination IP and MAC address to the match.Pravin B Shelar2015-09-081-11/+22
| | | | | | | | | | | | | Currently tnl-port table wildcard destination ip and mac addresses for given tunnel packet. That could result accepting tunnel packets destined for other hosts. Following patch adds support for matching for ip and mac address. IP address upates to tnl-port table are piggybacked on ovs-router updates. Reported-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* classifier: Make versioning more explicit.Jarno Rajahalme2015-07-061-4/+4
| | | | | | | | | | Now that struct cls_match has 'add_version' the 'version' in cls_match was largely redundant. Remove 'version' from struct cls_rule, and add it to function prototypes that need it. This makes versioning more explicit (or less indirect) in the API. Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* classifier: Support table versioningJarno Rajahalme2015-06-101-3/+4
| | | | | | | | | | | | | | | | | | | This patch allows classifier rules to become visible and invisible in specific versions. A 'version' is defined as a positive monotonically increasing integer, which never wraps around. The new 'visibility' attribute replaces the prior 'to_be_removed' and 'visible' attributes. When versioning is not used, the 'version' parameter should be passed as 'CLS_MIN_VERSION' when creating rules, and 'CLS_MAX_VERSION' when looking up flows. This feature enables the support for atomic OpenFlow bundles without significant performance penalty on 64-bit systems. There is a performance decrease in 32-bit systems due to 64-bit atomics used. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* userspace: Replace all uses of strncpy() by ovs_strlcpy().Ben Pfaff2015-02-201-2/+2
| | | | | | | | | | strncpy() has a lot of pitfalls. A while back we replaced all its uses by calls to ovs_strlcpy() or ovs_strzcpy(), but some more have crept in. This commit fixes them. Reported-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Thomas Graf <tgraf@noironetworks.com>
* classifier: Add support for conjunctive matches.Ben Pfaff2015-01-111-2/+2
| | | | | | | | | | A "conjunctive match" allows higher-level matches in the flow table, such as set membership matches, without causing a cross-product explosion for multidimensional matches. Please refer to the documentation that this commit adds to ovs-ofctl(8) for a better explanation, including an example. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* ovs-router: Add "ovs/route/lookup" commandYAMAMOTO Takashi2014-12-121-0/+27
| | | | | | | | | | | | | This command is useful at least for testing. Example output: % ovs-appctl ovs/route/lookup '10.0.0.1' gateway 172.17.0.254 dev wm0 % Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* ovs-router: non-Linux supportYAMAMOTO Takashi2014-12-101-2/+2
| | | | | | | | | | Refactor ovs-router so that it can work with non-Linux platforms at least in some extent, using the existing route-table code as a fallback. Known restriction: for such platforms, "ovs/router/show" command does not show "Cached" kernel routes. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* dpctl: Fix crash.Pravin B Shelar2014-11-211-1/+1
| | | | | | | | | | ovs-dpctl crashed due to uninitialized router classifier. To fix this issue move ovs router initialization to route table module. Reported-by: Madhu Challa <challa@noironetworks.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* classifier: Defer pvector publication.Jarno Rajahalme2014-11-141-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new functions classifier_defer() and classifier_publish(), which control when the classifier modifications are made available to lookups. By default, all modifications are made available to lookups immediately. Modifications made after a classifier_defer() call MAY be 'deferred' for later 'publication'. A call to classifier_publish() will both publish any deferred modifications, and cause subsequent changes to to be published immediately. Currently any deferring is limited to the visibility of the subtable vector changes. pvector now processes modifications mostly in a working copy, which needs to be explicitly published with pvector_publish(). pvector_publish() sorts the working copy and removes gaps before publishing it. This change helps avoiding O(n**2) memory behavior in corner cases, where large number of rules with different masks are inserted or deleted. VMware-BZ: #1322017 Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* classifier: Remove internal mutex.Jarno Rajahalme2014-11-141-2/+13
| | | | | | | | | | | | | | Almost all classifier users already exclude concurrent modifications, or are single-threaded, hence the classifier internal mutex can be removed. Due to this change, ovs-router.c and tnl-ports.c need new mutexes, which are added. As noted by Ben in review, ovs_router_flush() should also free the entries it removes from the classifier. It now calls ovsrcu_postpone() to that effect. Suggested-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* classifier: Lockless and robust classifier iteration.Jarno Rajahalme2014-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Previously, accurate iteration required writers to be excluded during iteration. This patch adds an rculist to struct cls_subtable, and a corresponding list node to struct cls_rule, which makes iteration more straightforward, and allows the iterators to remain ignorant of the internals of the cls_match. This new list allows iteration of rules in the classifier by traversing the RCU-friendly subtables vector, and the rculist of rules in each subtable. Classifier modifications may be performed concurrently, but whether or not the concurrent iterator sees those changes depends on the timing of change. More specifically, an concurrent iterator: - May or may not see a rule that is being inserted or removed. - Will see either the new or the old version of a rule that is replaced. - Will see all the other rules (that are not being modified). Finally, The subtable's rculist also allows to make classifier_rule_overlaps() lockless, which this patch also does. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* openvswitch: Userspace tunneling.Pravin B Shelar2014-11-121-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Following patch adds support for userspace tunneling. Tunneling needs three more component first is routing table which is configured by caching kernel routes and second is ARP cache which build automatically by snooping arp. And third is tunnel protocol table which list all listening protocols which is populated by vswitchd as tunnel ports are added. GRE and VXLAN protocol support is added in this patch. Tunneling works as follows: On packet receive vswitchd check if this packet is targeted to tunnel port. If it is then vswitchd inserts tunnel pop action which pops header and sends packet to tunnel port. On packet xmit rather than generating Set tunnel action it generate tunnel push action which has tunnel header data. datapath can use tunnel-push action data to generate header for each packet and forward this packet to output port. Since tunnel-push action contains most of packet header vswitchd needs to lookup routing table and arp table to build this action. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* util: Add be32_prefix_mask().Jarno Rajahalme2014-11-111-1/+1
| | | | | | | | | | Shifting a 32-bit entity by 32 bits is undefined behavior. As we have 3 cases where we may hit this, it is a time to introduce a helper for this. VMware-BZ: #1355026 Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
* ovs-router: Fix build on NetBSDYAMAMOTO Takashi2014-11-111-0/+1
| | | | | | | | | | | | Split the linux-specific part of ovs-router.h into ovs-router-linux.h. The breakage was introduced by commit d9b4ebc5d15202bedad06969353435a4c1951c71 ("route-table: Use classifier to store routing table.") Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Acked-by: Ben Pfaff <blp@nicira.com>
* classifier: Constify RCU pointers.Jarno Rajahalme2014-11-061-1/+1
| | | | | | | Returning const struct cls_rule pointers from the classifier API helps callers to remember that they should not modify the rules returned. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovs-router: Fix sparse warningPravin B Shelar2014-11-041-1/+1
| | | | | | | | | | | | | Fixes following warning: ../lib/ovs-router.c:162:11: warning: incorrect type in assignment (different base types) ../lib/ovs-router.c:162:11: expected restricted ovs_be32 [usertype] <noident> ../lib/ovs-router.c:162:11: got restricted ovs_be16 Reported-by: Ben Pfaff <blp@nicira.com> Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
* route-table: Use classifier to store routing table.Pravin B Shelar2014-11-031-0/+275
Rather than using hmap for storing routing entries we can directly use classifier which has support for priority and wildcard entries. This makes route lookup lockless. This help when we use route lookup for native tunneling. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Acked-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>