Open vSwitch
Subsystems (3)
A set of updates for net-next/3.13. Major changes are:
* Restructure flow handling code to be more logically organized and easier to read.
* Rehashing of the flow table is moved from a workqueue to flow installation time. Before, heavy load could block the workqueue for excessive periods of time.
* Additional debugging information is provided to help diagnose megaflows.
* It's now possible to match on TCP flags.
The following changes since commit 272b98c6455f00884f0350f775c5342358ebb73f:
Linux 3.12-rc1 (2013-09-16 16:17:51 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch.git master
for you to fetch changes up to 8ddd094675cfd453fc9838caa46ea108a4107183:
openvswitch: Use flow hash during flow lookup operation. (2013-11-01 18:43:46 -0700)
----------------------------------------------------------------
Andy Zhou (1):
openvswitch: collect mega flow mask stats
Jarno Rajahalme (2):
openvswitch: Widen TCP flags handling.
openvswitch: TCP flags matching support.
Pravin B Shelar (6):
openvswitch: Move flow table rehashing to flow install.
openvswitch: Restructure datapath.c and flow.c
openvswitch: Move mega-flow list out of rehashing struct.
openvswitch: Simplify mega-flow APIs.
openvswitch: Enable all GSO features on internal port.
openvswitch: Use flow hash during flow lookup operation.
Wei Yongjun (2):
openvswitch: remove duplicated include from vport-vxlan.c
openvswitch: remove duplicated include from vport-gre.c
include/uapi/linux/openvswitch.h | 18 +- net/openvswitch/Makefile | 2 + net/openvswitch/datapath.c | 668 ++------------ net/openvswitch/datapath.h | 9 +- net/openvswitch/flow.c | 1605 +-------------------------------- net/openvswitch/flow.h | 132 +-- net/openvswitch/flow_netlink.c | 1630 ++++++++++++++++++++++++++++++++++ net/openvswitch/flow_netlink.h | 60 ++ net/openvswitch/flow_table.c | 592 ++++++++++++ net/openvswitch/flow_table.h | 81 ++ net/openvswitch/vport-gre.c | 2 - net/openvswitch/vport-internal_dev.c | 2 +- net/openvswitch/vport-vxlan.c | 1 - 13 files changed, 2511 insertions(+), 2291 deletions(-) create mode 100644 net/openvswitch/flow_netlink.c create mode 100644 net/openvswitch/flow_netlink.h create mode 100644 net/openvswitch/flow_table.c create mode 100644 net/openvswitch/flow_table.h
A message that is not in the archive (sent off-list or not yet received): 1383378230-59624-1-git-send-email-jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org
PATCH 1/11 openvswitch: Move flow table rehashing to flow install.
From: Pravin B Shelar <[email protected]>
Rehashing in ovs-workqueue can cause ovs-mutex lock contentions in case of heavy flow setups where both needs ovs-mutex. So by moving rehashing to flow-setup we can eliminate contention. This also simplify ovs locking and reduces dependence on workqueue.
--- net/openvswitch/datapath.c | 50 ++++++++++------------------------------------ net/openvswitch/datapath.h | 2 ++ 2 files changed, 13 insertions(+), 39 deletions(-)
net/openvswitch/datapath.c +11 -39
@@ -60,8 +60,6 @@#define REHASH_FLOW_INTERVAL (10 * 60 * HZ) -static void rehash_flow_table (struct work_struct *work); -static DECLARE_DELAYED_WORK(rehash_flow_wq, rehash_flow_table);int ovs_net_id__read_mostly ;
@@ -1289,22 +1287,25 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)/* Check if this is a duplicate flow */ flow =ovs_flow_lookup (table, &key);if (!flow) { +struct flow_table *new_table =NULL ;struct sw_flow_mask *mask_p; +/* Bail out if we're not allowed to create a new flow. */ error = -ENOENT ;if (info->genlhdr->cmd ==OVS_FLOW_CMD_SET ) goto err_unlock_ovs;/* Expand table, if necessary, to make room. */ -if (ovs_flow_tbl_need_to_expand (table)) { -struct flow_table *new_table; - +if (ovs_flow_tbl_need_to_expand (table)) new_table =ovs_flow_tbl_expand (table); -if (!IS_ERR (new_table)) { -rcu_assign_pointer (dp->table, new_table); -ovs_flow_tbl_destroy (table, true); - table =ovsl_dereference (dp->table); - } +else if (time_after (jiffies, dp->last_rehash +REHASH_FLOW_INTERVAL )) + new_table =ovs_flow_tbl_rehash (table); + +if (new_table && !IS_ERR (new_table)) { +rcu_assign_pointer (dp->table, new_table); +ovs_flow_tbl_destroy (table, true); + table =ovsl_dereference (dp->table); + dp->last_rehash = jiffies; }/* Allocate flow. */
@@ -2336,32 +2337,6 @@ error:return err; } -static void rehash_flow_table (struct work_struct *work) -{ -struct datapath *dp; -struct net *net; - -ovs_lock (); -rtnl_lock (); -for_each_net (net) { -struct ovs_net *ovs_net =net_generic (net, ovs_net_id); - -list_for_each_entry (dp, &ovs_net->dps, list_node) { -struct flow_table *old_table =ovsl_dereference (dp->table); -struct flow_table *new_table; - - new_table =ovs_flow_tbl_rehash (old_table); -if (!IS_ERR (new_table)) { -rcu_assign_pointer (dp->table, new_table); -ovs_flow_tbl_destroy (old_table, true); - } - } - } -rtnl_unlock (); -ovs_unlock (); -schedule_delayed_work (&rehash_flow_wq,REHASH_FLOW_INTERVAL ); -} -static int __net_init ovs_init_net (struct net *net) {struct ovs_net *ovs_net =net_generic (net, ovs_net_id);
@@ -2419,8 +2394,6 @@ static int __init dp_init(void)if (err <0 ) goto error_unreg_notifier; -schedule_delayed_work (&rehash_flow_wq,REHASH_FLOW_INTERVAL ); -return 0 ; error_unreg_notifier:
@@ -2437,7 +2410,6 @@ error:static void dp_cleanup (void ) { -cancel_delayed_work_sync (&rehash_flow_wq);dp_unregister_genl (ARRAY_SIZE (dp_genl_families));unregister_netdevice_notifier (&ovs_dp_device_notifier);unregister_pernet_device (&ovs_net_ops);
net/openvswitch/datapath.h +2 -0
@@ -62,6 +62,7 @@ struct dp_stats_percpu {* ovs_mutex and RCU. * @stats_percpu: Per-CPU datapath statistics. * @net: Reference to net namespace. +* @last_rehash: Timestamp of last rehash. * * Context: See the comment on locking at the top of datapath.c for additional * locking information.
@@ -83,6 +84,7 @@ struct datapath {/* Network namespace ref. */ struct net *net;#endif +unsigned long last_rehash; };/**
Signature · 1 line
1.8.3.2
PATCH 2/11 openvswitch: remove duplicated include from vport-vxlan.c
In reply to Jesse GrossFrom: Wei Yongjun <[email protected]>
Remove duplicated include.
--- net/openvswitch/vport-vxlan.c | 1 - 1 file changed, 1 deletion(-)
net/openvswitch/vport-vxlan.c +0 -1
@@ -29,7 +29,6 @@#include <net/ip.h> #include <net/udp.h> #include <net/ip_tunnels.h> -#include <net/udp.h> #include <net/rtnetlink.h> #include <net/route.h> #include <net/dsfield.h>
Signature · 1 line
1.8.3.2
PATCH 3/11 openvswitch: remove duplicated include from vport-gre.c
In reply to Jesse GrossFrom: Wei Yongjun <[email protected]>
Remove duplicated include.
--- net/openvswitch/vport-gre.c | 2 -- 1 file changed, 2 deletions(-)
net/openvswitch/vport-gre.c +0 -2
@@ -24,8 +24,6 @@#include <linux/if_tunnel.h> #include <linux/if_vlan.h> #include <linux/in.h> -#include <linux/if_vlan.h> -#include <linux/in.h> #include <linux/in_route.h> #include <linux/inetdevice.h> #include <linux/jhash.h>
Signature · 1 line
1.8.3.2
PATCH 4/11 openvswitch: Restructure datapath.c and flow.c
In reply to Jesse GrossFrom: Pravin B Shelar <[email protected]>
Over the time datapath.c and flow.c has became pretty large files. Following patch restructures functionality of component into three different components:
flow.c: contains flow extract.flow_netlink.c: netlink flow api.flow_table.c: flow table api.
This patch restructures code without changing logic.
--- net/openvswitch/Makefile | 2 + net/openvswitch/datapath.c | 528 +------------ net/openvswitch/datapath.h | 1 + net/openvswitch/flow.c | 1605 +--------------------------------------- net/openvswitch/flow.h | 128 +--- net/openvswitch/flow_netlink.c | 1603 +++++++++++++++++++++++++++++++++++++++ net/openvswitch/flow_netlink.h | 60 ++ net/openvswitch/flow_table.c | 517 +++++++++++++ net/openvswitch/flow_table.h | 91 +++ 9 files changed, 2354 insertions(+), 2181 deletions(-) create mode 100644 net/openvswitch/flow_netlink.c create mode 100644 net/openvswitch/flow_netlink.h create mode 100644 net/openvswitch/flow_table.c create mode 100644 net/openvswitch/flow_table.h
net/openvswitch/Makefile +2 -0
@@ -9,6 +9,8 @@ openvswitch-y := \ datapath.o \ dp_notify.o \ flow.o \ + flow_netlink.o \ + flow_table.o \ vport.o \ vport-internal_dev.o \ vport-netdev.o
net/openvswitch/datapath.c +30 -498
670 lines not on this page · raw message
net/openvswitch/datapath.h +1 -0
@@ -27,6 +27,7 @@#include <linux/u64_stats_sync.h> #include "flow.h" +#include "flow_table.h" #include "vport.h" #define DP_MAX_PORTS USHRT_MAX
net/openvswitch/flow.c +24 -1581
1,636 lines not on this page · raw message
net/openvswitch/flow.h +26 -102
154 lines not on this page · raw message
net/openvswitch/flow_netlink.c new file +1603 -0
525 lines not on this page · raw message
net/openvswitch/flow_netlink.h new file +60 -0
60 lines not on this page · raw message
net/openvswitch/flow_table.c new file +517 -0
517 lines not on this page · raw message
net/openvswitch/flow_table.h new file +91 -0
91 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.2
Part of the diff is not shown here. View the raw message.
PATCH 5/11 openvswitch: Move mega-flow list out of rehashing struct.
In reply to Jesse GrossFrom: Pravin B Shelar <[email protected]>
ovs-flow rehash does not touch mega flow list. Following patch moves it dp struct datapath. Avoid one extra indirection for accessing mega-flow list head on every packet receive.
--- net/openvswitch/datapath.c | 77 ++++------------ net/openvswitch/datapath.h | 6 +- net/openvswitch/flow_table.c | 205 ++++++++++++++++++++++++++----------------- net/openvswitch/flow_table.h | 32 +++---- 4 files changed, 155 insertions(+), 165 deletions(-)
net/openvswitch/datapath.c +17 -60
@@ -59,8 +59,6 @@#include "vport-internal_dev.h" #include "vport-netdev.h" -#define REHASH_FLOW_INTERVAL (10 * 60 * HZ) -int ovs_net_id__read_mostly ; static void ovs_notify(struct sk_buff *skb, struct genl_info *info,
@@ -163,7 +161,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu) { struct datapath *dp = container_of(rcu, struct datapath, rcu); -ovs_flow_tbl_destroy ((__force struct flow_table *)dp->table, false); +ovs_flow_tbl_destroy (&dp->table, false);free_percpu (dp->stats_percpu);release_net (ovs_dp_get_net (dp));kfree (dp->ports);
@@ -235,7 +233,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb) }/* Look up flow. */ - flow =ovs_flow_tbl_lookup (rcu_dereference (dp->table), &key); + flow =ovs_flow_tbl_lookup (&dp->table, &key);if (unlikely (!flow)) {struct dp_upcall_info upcall;
@@ -453,23 +451,6 @@ out:return err; } -/* Called with ovs_mutex. */ -static int flush_flows (struct datapath *dp) -{ -struct flow_table *old_table; -struct flow_table *new_table; - - old_table =ovsl_dereference (dp->table); - new_table =ovs_flow_tbl_alloc (TBL_MIN_BUCKETS ); -if (!new_table) -return -ENOMEM ; - -rcu_assign_pointer (dp->table, new_table); - -ovs_flow_tbl_destroy (old_table, true); -return 0 ; -} -static void clear_stats (struct sw_flow *flow) { flow->used =0 ;
@@ -584,11 +565,9 @@ static struct genl_ops dp_packet_genl_ops[] = {static void get_dp_stats (struct datapath *dp,struct ovs_dp_stats *stats) { -struct flow_table *table;int i; - table =rcu_dereference_check (dp->table,lockdep_ovsl_is_held ()); - stats->n_flows =ovs_flow_tbl_count (table); + stats->n_flows =ovs_flow_tbl_count (&dp->table); stats->n_hit = stats->n_missed = stats->n_lost =0 ;for_each_possible_cpu (i) {
@@ -773,7 +752,6 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)struct sw_flow_mask mask;struct sk_buff *reply;struct datapath *dp; -struct flow_table *table;struct sw_flow_actions *acts =NULL ;struct sw_flow_match match;int error;
@@ -814,12 +792,9 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)if (!dp) goto err_unlock_ovs; - table =ovsl_dereference (dp->table); -/* Check if this is a duplicate flow */ - flow =ovs_flow_tbl_lookup (table, &key); + flow =ovs_flow_tbl_lookup (&dp->table, &key);if (!flow) { -struct flow_table *new_table =NULL ;struct sw_flow_mask *mask_p;/* Bail out if we're not allowed to create a new flow. */
@@ -827,19 +802,6 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)if (info->genlhdr->cmd ==OVS_FLOW_CMD_SET ) goto err_unlock_ovs; -/* Expand table, if necessary, to make room. */ -if (ovs_flow_tbl_need_to_expand (table)) - new_table =ovs_flow_tbl_expand (table); -else if (time_after (jiffies, dp->last_rehash +REHASH_FLOW_INTERVAL )) - new_table =ovs_flow_tbl_rehash (table); - -if (new_table && !IS_ERR (new_table)) { -rcu_assign_pointer (dp->table, new_table); -ovs_flow_tbl_destroy (table, true); - table =ovsl_dereference (dp->table); - dp->last_rehash = jiffies; - } -/* Allocate flow. */ flow =ovs_flow_alloc ();if (IS_ERR (flow)) {
@@ -852,7 +814,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->unmasked_key = key;/* Make sure mask is unique in the system */ - mask_p =ovs_sw_flow_mask_find (table, &mask); + mask_p =ovs_sw_flow_mask_find (&dp->table, &mask);if (!mask_p) {/* Allocate a new mask if none exsits. */ mask_p =ovs_sw_flow_mask_alloc ();
@@ -860,7 +822,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) goto err_flow_free; mask_p->key = mask.key; mask_p->range = mask.range; -ovs_sw_flow_mask_insert (table, mask_p); +ovs_sw_flow_mask_insert (&dp->table, mask_p); }ovs_sw_flow_mask_add_ref (mask_p);
@@ -868,7 +830,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)rcu_assign_pointer (flow->sf_acts, acts);/* Put flow in bucket. */ -ovs_flow_tbl_insert (table, flow); +ovs_flow_tbl_insert (&dp->table, flow); reply =ovs_flow_cmd_build_info (flow, dp, info->snd_portid, info->snd_seq,OVS_FLOW_CMD_NEW );
@@ -936,7 +898,6 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info)struct sk_buff *reply;struct sw_flow *flow;struct datapath *dp; -struct flow_table *table;struct sw_flow_match match;int err;
@@ -957,8 +918,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) goto unlock; } - table =ovsl_dereference (dp->table); - flow =ovs_flow_tbl_lookup (table, &key); + flow =ovs_flow_tbl_lookup (&dp->table, &key);if (!flow || !ovs_flow_cmp_unmasked_key (flow, &match)) { err = -ENOENT ; goto unlock;
@@ -986,7 +946,6 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)struct sk_buff *reply;struct sw_flow *flow;struct datapath *dp; -struct flow_table *table;struct sw_flow_match match;int err;
@@ -998,7 +957,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) }if (!a[OVS_FLOW_ATTR_KEY ]) { - err =flush_flows (dp); + err =ovs_flow_tbl_flush (&dp->table); goto unlock; }
@@ -1007,8 +966,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)if (err) goto unlock; - table =ovsl_dereference (dp->table); - flow =ovs_flow_tbl_lookup (table, &key); + flow =ovs_flow_tbl_lookup (&dp->table, &key);if (!flow || !ovs_flow_cmp_unmasked_key (flow, &match)) { err = -ENOENT ; goto unlock;
@@ -1020,7 +978,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) goto unlock; } -ovs_flow_tbl_remove (table, flow); +ovs_flow_tbl_remove (&dp->table, flow); err =ovs_flow_cmd_fill_info (flow, dp, reply, info->snd_portid, info->snd_seq,0 ,OVS_FLOW_CMD_DEL );
@@ -1039,8 +997,8 @@ unlock:static int ovs_flow_cmd_dump (struct sk_buff *skb,struct netlink_callback *cb) {struct ovs_header *ovs_header =genlmsg_data (nlmsg_data (cb->nlh)); +struct table_instance *ti;struct datapath *dp; -struct flow_table *table;rcu_read_lock (); dp =get_dp (sock_net (skb->sk), ovs_header->dp_ifindex);
@@ -1049,14 +1007,14 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)return -ENODEV ; } - table =rcu_dereference (dp->table); + ti =rcu_dereference (dp->table.ti);for (;;) {struct sw_flow *flow;u32 bucket, obj; bucket = cb->args[0 ]; obj = cb->args[1 ]; - flow =ovs_flow_tbl_dump_next (table, &bucket, &obj); + flow =ovs_flow_tbl_dump_next (ti, &bucket, &obj);if (!flow)break ;
@@ -1220,9 +1178,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)ovs_dp_set_net (dp,hold_net (sock_net (skb->sk)));/* Allocate table. */ - err = -ENOMEM ; -rcu_assign_pointer (dp->table,ovs_flow_tbl_alloc (TBL_MIN_BUCKETS )); -if (!dp->table) + err =ovs_flow_tbl_init (&dp->table); +if (err) goto err_free_dp; dp->stats_percpu = alloc_percpu(struct dp_stats_percpu);
@@ -1279,7 +1236,7 @@ err_destroy_ports_array: err_destroy_percpu:free_percpu (dp->stats_percpu); err_destroy_table: -ovs_flow_tbl_destroy (ovsl_dereference (dp->table), false); +ovs_flow_tbl_destroy (&dp->table, false); err_free_dp:release_net (ovs_dp_get_net (dp));kfree (dp);
net/openvswitch/datapath.h +2 -4
@@ -58,12 +58,11 @@ struct dp_stats_percpu {* struct datapath - datapath for flow-based packet switching * @rcu: RCU callback head for deferred destruction. * @list_node: Element in global 'dps' list. -* @table: Current flow table. Protected by ovs_mutex and RCU. +* @table: flow table. * @ports: Hash table for ports. %OVSP_LOCAL port always exists. Protected by * ovs_mutex and RCU. * @stats_percpu: Per-CPU datapath statistics. * @net: Reference to net namespace. -* @last_rehash: Timestamp of last rehash. * * Context: See the comment on locking at the top of datapath.c for additional * locking information.
@@ -73,7 +72,7 @@ struct datapath {struct list_head list_node;/* Flow table. */ -struct flow_table __rcu *table; +struct flow_table table;/* Switch ports. */ struct hlist_head *ports;
@@ -85,7 +84,6 @@ struct datapath {/* Network namespace ref. */ struct net *net;#endif -unsigned long last_rehash; };/**
net/openvswitch/flow_table.c +123 -82
355 lines not on this page · raw message
net/openvswitch/flow_table.h +13 -19
@@ -36,42 +36,36 @@#include "flow.h" -#define TBL_MIN_BUCKETS 1024 - -struct flow_table { +struct table_instance {struct flex_array *buckets; -unsigned int count, n_buckets; +unsigned int n_buckets;struct rcu_head rcu; -struct list_head *mask_list;int node_ver;u32 hash_seed;bool keep_flows; }; +struct flow_table { +struct table_instance __rcu *ti; +struct list_head mask_list; +unsigned long last_rehash; +unsigned int count; +}; +int ovs_flow_init (void );void ovs_flow_exit (void );struct sw_flow *ovs_flow_alloc (void );void ovs_flow_free (struct sw_flow *,bool deferred); -static inline int ovs_flow_tbl_count (struct flow_table *table) -{ -return table->count; -} - -static inline int ovs_flow_tbl_need_to_expand (struct flow_table *table) -{ -return (table->count > table->n_buckets); -} - -struct flow_table *ovs_flow_tbl_alloc (int new_size); -struct flow_table *ovs_flow_tbl_expand (struct flow_table *table); -struct flow_table *ovs_flow_tbl_rehash (struct flow_table *table); +int ovs_flow_tbl_init (struct flow_table *); +int ovs_flow_tbl_count (struct flow_table *table);void ovs_flow_tbl_destroy (struct flow_table *table,bool deferred); +int ovs_flow_tbl_flush (struct flow_table *flow_table);void ovs_flow_tbl_insert (struct flow_table *table,struct sw_flow *flow);void ovs_flow_tbl_remove (struct flow_table *table,struct sw_flow *flow); -struct sw_flow *ovs_flow_tbl_dump_next (struct flow_table *table, +struct sw_flow *ovs_flow_tbl_dump_next (struct table_instance *table,u32 *bucket,u32 *idx);struct sw_flow *ovs_flow_tbl_lookup (struct flow_table *,const struct sw_flow_key *);
Signature · 1 line
1.8.3.2
PATCH 6/11 openvswitch: Simplify mega-flow APIs.
In reply to Jesse GrossFrom: Pravin B Shelar <[email protected]>
Hides mega-flow implementation in flow_table.c rather than datapath.c.
--- net/openvswitch/datapath.c | 27 +++------ net/openvswitch/flow_table.c | 138 +++++++++++++++++++++++++------------------ net/openvswitch/flow_table.h | 12 +--- 3 files changed, 89 insertions(+), 88 deletions(-)
net/openvswitch/datapath.c +7 -20
@@ -161,7 +161,7 @@ static void destroy_dp_rcu(struct rcu_head *rcu) { struct datapath *dp = container_of(rcu, struct datapath, rcu); -ovs_flow_tbl_destroy (&dp->table, false); +ovs_flow_tbl_destroy (&dp->table);free_percpu (dp->stats_percpu);release_net (ovs_dp_get_net (dp));kfree (dp->ports);
@@ -795,8 +795,6 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)/* Check if this is a duplicate flow */ flow =ovs_flow_tbl_lookup (&dp->table, &key);if (!flow) { -struct sw_flow_mask *mask_p; -/* Bail out if we're not allowed to create a new flow. */ error = -ENOENT ;if (info->genlhdr->cmd ==OVS_FLOW_CMD_SET )
@@ -812,25 +810,14 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) flow->key = masked_key; flow->unmasked_key = key; - -/* Make sure mask is unique in the system */ - mask_p =ovs_sw_flow_mask_find (&dp->table, &mask); -if (!mask_p) { -/* Allocate a new mask if none exsits. */ - mask_p =ovs_sw_flow_mask_alloc (); -if (!mask_p) - goto err_flow_free; - mask_p->key = mask.key; - mask_p->range = mask.range; -ovs_sw_flow_mask_insert (&dp->table, mask_p); - } - -ovs_sw_flow_mask_add_ref (mask_p); - flow->mask = mask_p;rcu_assign_pointer (flow->sf_acts, acts);/* Put flow in bucket. */ -ovs_flow_tbl_insert (&dp->table, flow); + error =ovs_flow_tbl_insert (&dp->table, flow, &mask); +if (error) { + acts =NULL ; + goto err_flow_free; + } reply =ovs_flow_cmd_build_info (flow, dp, info->snd_portid, info->snd_seq,OVS_FLOW_CMD_NEW );
@@ -1236,7 +1223,7 @@ err_destroy_ports_array: err_destroy_percpu:free_percpu (dp->stats_percpu); err_destroy_table: -ovs_flow_tbl_destroy (&dp->table, false); +ovs_flow_tbl_destroy (&dp->table); err_free_dp:release_net (ovs_dp_get_net (dp));kfree (dp);
net/openvswitch/flow_table.c +79 -59
199 lines not on this page · raw message
net/openvswitch/flow_table.h +3 -9
@@ -60,10 +60,11 @@ void ovs_flow_free(struct sw_flow *, bool deferred);int ovs_flow_tbl_init (struct flow_table *);int ovs_flow_tbl_count (struct flow_table *table); -void ovs_flow_tbl_destroy (struct flow_table *table,bool deferred); +void ovs_flow_tbl_destroy (struct flow_table *table);int ovs_flow_tbl_flush (struct flow_table *flow_table); -void ovs_flow_tbl_insert (struct flow_table *table,struct sw_flow *flow); +int ovs_flow_tbl_insert (struct flow_table *table,struct sw_flow *flow, +struct sw_flow_mask *mask);void ovs_flow_tbl_remove (struct flow_table *table,struct sw_flow *flow);struct sw_flow *ovs_flow_tbl_dump_next (struct table_instance *table,u32 *bucket,u32 *idx);
@@ -73,13 +74,6 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,bool ovs_flow_cmp_unmasked_key (const struct sw_flow *flow,struct sw_flow_match *match); -struct sw_flow_mask *ovs_sw_flow_mask_alloc (void ); -void ovs_sw_flow_mask_add_ref (struct sw_flow_mask *); -void ovs_sw_flow_mask_del_ref (struct sw_flow_mask *,bool deferred); -void ovs_sw_flow_mask_insert (struct flow_table *,struct sw_flow_mask *); -struct sw_flow_mask *ovs_sw_flow_mask_find (const struct flow_table *, -const struct sw_flow_mask *);void ovs_flow_mask_key (struct sw_flow_key *dst,const struct sw_flow_key *src,const struct sw_flow_mask *mask); -#endif /* flow_table.h */
Signature · 1 line
1.8.3.2
PATCH 7/11 openvswitch: collect mega flow mask stats
In reply to Jesse GrossFrom: Andy Zhou <[email protected]>
Collect mega flow mask stats. ovs-dpctl show command can be used to display them for debugging and performance tuning.
--- include/uapi/linux/openvswitch.h | 17 ++++++++++++++--- net/openvswitch/datapath.c | 38 +++++++++++++++++++++++++++++++------- net/openvswitch/datapath.h | 4 ++++ net/openvswitch/flow_table.c | 16 +++++++++++++++- net/openvswitch/flow_table.h | 4 +++- 5 files changed, 67 insertions(+), 12 deletions(-)
include/uapi/linux/openvswitch.h +14 -3
@@ -63,15 +63,18 @@ enum ovs_datapath_cmd {* not be sent. * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the * datapath. Always present in notifications. +* @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the +* datapath. Always present in notifications. * * These attributes follow the &struct ovs_header within the Generic Netlink * payload for %OVS_DP_* commands. */ enum ovs_datapath_attr {OVS_DP_ATTR_UNSPEC , -OVS_DP_ATTR_NAME ,/* name of dp_ifindex netdev */ -OVS_DP_ATTR_UPCALL_PID ,/* Netlink PID to receive upcalls */ -OVS_DP_ATTR_STATS ,/* struct ovs_dp_stats */ +OVS_DP_ATTR_NAME ,/* name of dp_ifindex netdev */ +OVS_DP_ATTR_UPCALL_PID ,/* Netlink PID to receive upcalls */ +OVS_DP_ATTR_STATS ,/* struct ovs_dp_stats */ +OVS_DP_ATTR_MEGAFLOW_STATS ,/* struct ovs_dp_megaflow_stats */ __OVS_DP_ATTR_MAX };
@@ -84,6 +87,14 @@ struct ovs_dp_stats {__u64 n_flows;/* Number of flows present */ }; +struct ovs_dp_megaflow_stats { +__u64 n_mask_hit;/* Number of masks used for flow lookups. */ +__u32 n_masks;/* Number of masks for the datapath. */ +__u32 pad0;/* Pad for future expension. */ +__u64 pad1;/* Pad for future expension. */ +__u64 pad2;/* Pad for future expension. */ +}; +struct ovs_vport_stats {__u64 rx_packets;/* total packets received */ __u64 tx_packets;/* total packets transmitted */
net/openvswitch/datapath.c +31 -7
@@ -221,6 +221,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)struct dp_stats_percpu *stats;struct sw_flow_key key;u64 *stats_counter; +u32 n_mask_hit;int error; stats =this_cpu_ptr (dp->stats_percpu);
@@ -233,7 +234,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb) }/* Look up flow. */ - flow =ovs_flow_tbl_lookup (&dp->table, &key); + flow =ovs_flow_tbl_lookup (&dp->table, &key, &n_mask_hit);if (unlikely (!flow)) {struct dp_upcall_info upcall;
@@ -258,6 +259,7 @@ out:/* Update datapath statistics. */ u64_stats_update_begin (&stats->sync); (*stats_counter)++; + stats->n_mask_hit += n_mask_hit;u64_stats_update_end (&stats->sync); }
@@ -563,13 +565,18 @@ static struct genl_ops dp_packet_genl_ops[] = { } }; -static void get_dp_stats (struct datapath *dp,struct ovs_dp_stats *stats) +static void get_dp_stats (struct datapath *dp,struct ovs_dp_stats *stats, +struct ovs_dp_megaflow_stats *mega_stats) {int i; +memset (mega_stats,0 ,sizeof (*mega_stats)); + stats->n_flows =ovs_flow_tbl_count (&dp->table); + mega_stats->n_masks =ovs_flow_tbl_num_masks (&dp->table); stats->n_hit = stats->n_missed = stats->n_lost =0 ; +for_each_possible_cpu (i) {const struct dp_stats_percpu *percpu_stats;struct dp_stats_percpu local_stats;
@@ -585,6 +592,7 @@ static void get_dp_stats(struct datapath *dp, struct ovs_dp_stats *stats) stats->n_hit += local_stats.n_hit; stats->n_missed += local_stats.n_missed; stats->n_lost += local_stats.n_lost; + mega_stats->n_mask_hit += local_stats.n_mask_hit; } }
@@ -743,6 +751,14 @@ static struct sk_buff *ovs_flow_cmd_build_info(struct sw_flow *flow,return skb; } +static struct sw_flow *__ovs_flow_tbl_lookup (struct flow_table *tbl, +const struct sw_flow_key *key) +{ +u32 __always_unused n_mask_hit; + +return ovs_flow_tbl_lookup (tbl, key, &n_mask_hit); +} +static int ovs_flow_cmd_new_or_set (struct sk_buff *skb,struct genl_info *info) {struct nlattr **a = info->attrs;
@@ -793,7 +809,7 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) goto err_unlock_ovs;/* Check if this is a duplicate flow */ - flow =ovs_flow_tbl_lookup (&dp->table, &key); + flow =__ovs_flow_tbl_lookup (&dp->table, &key);if (!flow) {/* Bail out if we're not allowed to create a new flow. */ error = -ENOENT ;
@@ -905,7 +921,7 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) goto unlock; } - flow =ovs_flow_tbl_lookup (&dp->table, &key); + flow =__ovs_flow_tbl_lookup (&dp->table, &key);if (!flow || !ovs_flow_cmp_unmasked_key (flow, &match)) { err = -ENOENT ; goto unlock;
@@ -953,7 +969,7 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)if (err) goto unlock; - flow =ovs_flow_tbl_lookup (&dp->table, &key); + flow =__ovs_flow_tbl_lookup (&dp->table, &key);if (!flow || !ovs_flow_cmp_unmasked_key (flow, &match)) { err = -ENOENT ; goto unlock;
@@ -1067,6 +1083,7 @@ static size_t ovs_dp_cmd_msg_size(void) msgsize +=nla_total_size (IFNAMSIZ ); msgsize +=nla_total_size (sizeof (struct ovs_dp_stats )); + msgsize +=nla_total_size (sizeof (struct ovs_dp_megaflow_stats ));return msgsize; }
@@ -1076,6 +1093,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, {struct ovs_header *ovs_header;struct ovs_dp_stats dp_stats; +struct ovs_dp_megaflow_stats dp_megaflow_stats;int err; ovs_header = genlmsg_put(skb, portid, seq, &dp_datapath_genl_family,
@@ -1091,8 +1109,14 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,if (err) goto nla_put_failure; -get_dp_stats (dp, &dp_stats); -if (nla_put (skb,OVS_DP_ATTR_STATS ,sizeof (struct ovs_dp_stats ), &dp_stats)) +get_dp_stats (dp, &dp_stats, &dp_megaflow_stats); +if (nla_put (skb,OVS_DP_ATTR_STATS ,sizeof (struct ovs_dp_stats ), + &dp_stats)) + goto nla_put_failure; + +if (nla_put (skb,OVS_DP_ATTR_MEGAFLOW_STATS , +sizeof (struct ovs_dp_megaflow_stats ), + &dp_megaflow_stats)) goto nla_put_failure;return genlmsg_end (skb, ovs_header);
net/openvswitch/datapath.h +4 -0
@@ -46,11 +46,15 @@* @n_lost: Number of received packets that had no matching flow in the flow * table that could not be sent to userspace (normally due to an overflow in * one of the datapath's queues). +* @n_mask_hit: Number of masks looked up for flow match. +* @n_mask_hit / (@n_hit + @n_missed) will be the average masks looked +* up per packet. */ struct dp_stats_percpu {u64 n_hit;u64 n_missed;u64 n_lost; +u64 n_mask_hit;struct u64_stats_sync sync; };
net/openvswitch/flow_table.c +15 -1
@@ -430,13 +430,16 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, }struct sw_flow *ovs_flow_tbl_lookup (struct flow_table *tbl, -const struct sw_flow_key *key) +const struct sw_flow_key *key, +u32 *n_mask_hit) {struct table_instance *ti =rcu_dereference (tbl->ti);struct sw_flow_mask *mask;struct sw_flow *flow; + *n_mask_hit =0 ;list_for_each_entry_rcu (mask, &tbl->mask_list, list) { + (*n_mask_hit)++; flow =masked_flow_lookup (ti, key, mask);if (flow)/* Found */ return flow;
@@ -444,6 +447,17 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl,return NULL ; } +int ovs_flow_tbl_num_masks (const struct flow_table *table) +{ +struct sw_flow_mask *mask; +int num =0 ; + +list_for_each_entry (mask, &table->mask_list, list) + num++; + +return num; +} +static struct table_instance *table_instance_expand (struct table_instance *ti) {return table_instance_rehash (ti, ti->n_buckets *2 );
net/openvswitch/flow_table.h +3 -1
@@ -66,10 +66,12 @@ int ovs_flow_tbl_flush(struct flow_table *flow_table);int ovs_flow_tbl_insert (struct flow_table *table,struct sw_flow *flow,struct sw_flow_mask *mask);void ovs_flow_tbl_remove (struct flow_table *table,struct sw_flow *flow); +int ovs_flow_tbl_num_masks (const struct flow_table *table);struct sw_flow *ovs_flow_tbl_dump_next (struct table_instance *table,u32 *bucket,u32 *idx);struct sw_flow *ovs_flow_tbl_lookup (struct flow_table *, -const struct sw_flow_key *); +const struct sw_flow_key *, +u32 *n_mask_hit);bool ovs_flow_cmp_unmasked_key (const struct sw_flow *flow,struct sw_flow_match *match);
Signature · 1 line
1.8.3.2
PATCH 8/11 openvswitch: Enable all GSO features on internal port.
In reply to Jesse GrossFrom: Pravin B Shelar <[email protected]>
OVS already can handle all types of segmentation offloads that are supported by the kernel.
Following patch specifically enables UDP and IPV6 segmentation offloads.
--- net/openvswitch/vport-internal_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/openvswitch/vport-internal_dev.c +1 -1
@@ -134,7 +134,7 @@ static void do_setup(struct net_device *netdev) netdev->tx_queue_len =0 ; netdev->features =NETIF_F_LLTX |NETIF_F_SG |NETIF_F_FRAGLIST | -NETIF_F_HIGHDMA |NETIF_F_HW_CSUM |NETIF_F_TSO ; +NETIF_F_HIGHDMA |NETIF_F_HW_CSUM |NETIF_F_GSO_SOFTWARE ; netdev->vlan_features = netdev->features; netdev->features |=NETIF_F_HW_VLAN_CTAG_TX ;
Signature · 1 line
1.8.3.2
PATCH 9/11 openvswitch: Widen TCP flags handling.
In reply to Jesse GrossFrom: Jarno Rajahalme <[email protected]>
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.
--- net/openvswitch/datapath.c | 2 +- net/openvswitch/flow.c | 8 +++----- net/openvswitch/flow.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
net/openvswitch/datapath.c +1 -1
@@ -671,7 +671,7 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp, used = flow->used; stats.n_packets = flow->packet_count; stats.n_bytes = flow->byte_count; - tcp_flags = flow->tcp_flags; + tcp_flags = (u8 )ntohs (flow->tcp_flags);spin_unlock_bh (&flow->lock); if (used &&
net/openvswitch/flow.c +3 -5
@@ -58,19 +58,17 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies)return cur_ms - idle_ms; } -#define TCP_FLAGS_OFFSET 13 -#define TCP_FLAG_MASK 0x3f +#define TCP_FLAGS_BE16 (tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF))void ovs_flow_used (struct sw_flow *flow,struct sk_buff *skb) { -u8 tcp_flags =0 ; +__be16 tcp_flags =0 ;if ((flow->key.eth.type ==htons (ETH_P_IP ) || flow->key.eth.type ==htons (ETH_P_IPV6 )) && flow->key.ip.proto ==IPPROTO_TCP &&likely (skb->len >=skb_transport_offset (skb) +sizeof (struct tcphdr ))) { -u8 *tcp = (u8 *)tcp_hdr (skb); - tcp_flags = *(tcp +TCP_FLAGS_OFFSET ) &TCP_FLAG_MASK ; + tcp_flags =TCP_FLAGS_BE16 (tcp_hdr (skb)); }spin_lock (&flow->lock);
net/openvswitch/flow.h +1 -1
@@ -158,7 +158,7 @@ struct sw_flow {unsigned long used;/* Last used time (in jiffies). */ u64 packet_count;/* Number of packets matched. */ u64 byte_count;/* Number of bytes matched. */ -u8 tcp_flags;/* Union of seen TCP flags. */ +__be16 tcp_flags;/* Union of seen TCP flags. */ };struct arp_eth_header {
Signature · 1 line
1.8.3.2
PATCH 10/11 openvswitch: TCP flags matching support.
In reply to Jesse GrossFrom: Jarno Rajahalme <[email protected]>
tcp_flags=flags/mask
Bitwise match on TCP flags. The flags and mask are 16-bit num‐
bers written in decimal or in hexadecimal prefixed by 0x. Each
1-bit in mask requires that the corresponding bit in port must match. Each 0-bit in mask causes the corresponding bit to be ignored.
TCP protocol currently defines 9 flag bits, and additional 3 bits are reserved (must be transmitted as zero), see RFCs 793, 3168, and 3540. The flag bits are, numbering from the least significant bit:
0: FIN No more data from sender.
1: SYN Synchronize sequence numbers.
2: RST Reset the connection.
3: PSH Push function.
4: ACK Acknowledgement field significant.
5: URG Urgent pointer field significant.
6: ECE ECN Echo.
7: CWR Congestion Windows Reduced.
8: NS Nonce Sum.
9-11: Reserved.
12-15: Not matchable, must be zero.
--- include/uapi/linux/openvswitch.h | 1 + net/openvswitch/flow.c | 2 ++ net/openvswitch/flow.h | 2 ++ net/openvswitch/flow_netlink.c | 31 +++++++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-)
include/uapi/linux/openvswitch.h +1 -0
@@ -271,6 +271,7 @@ enum ovs_key_attr {OVS_KEY_ATTR_SKB_MARK ,/* u32 skb mark */ OVS_KEY_ATTR_TUNNEL ,/* Nested set of ovs_tunnel attributes */ OVS_KEY_ATTR_SCTP ,/* struct ovs_key_sctp */ +OVS_KEY_ATTR_TCP_FLAGS ,/* be16 TCP flags. */ #ifdef __KERNEL__ OVS_KEY_ATTR_IPV4_TUNNEL, /* struct ovs_key_ipv4_tunnel */
net/openvswitch/flow.c +2 -0
@@ -428,6 +428,7 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)struct tcphdr *tcp =tcp_hdr (skb); key->ipv4.tp.src = tcp->source; key->ipv4.tp.dst = tcp->dest; + key->ipv4.tp.flags =TCP_FLAGS_BE16 (tcp); } }else if (key->ip.proto ==IPPROTO_UDP ) {if (udphdr_ok (skb)) {
@@ -496,6 +497,7 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key)struct tcphdr *tcp =tcp_hdr (skb); key->ipv6.tp.src = tcp->source; key->ipv6.tp.dst = tcp->dest; + key->ipv6.tp.flags =TCP_FLAGS_BE16 (tcp); } }else if (key->ip.proto ==NEXTHDR_UDP ) {if (udphdr_ok (skb)) {
net/openvswitch/flow.h +2 -0
@@ -93,6 +93,7 @@ struct sw_flow_key {struct {__be16 src;/* TCP/UDP/SCTP source port. */ __be16 dst;/* TCP/UDP/SCTP destination port. */ +__be16 flags;/* TCP flags. */ } tp;struct {u8 sha[ETH_ALEN ];/* ARP source hardware address. */
@@ -109,6 +110,7 @@ struct sw_flow_key {struct {__be16 src;/* TCP/UDP/SCTP source port. */ __be16 dst;/* TCP/UDP/SCTP destination port. */ +__be16 flags;/* TCP flags. */ } tp;struct {struct in6_addr target;/* ND target address. */
net/openvswitch/flow_netlink.c +29 -2
@@ -114,6 +114,7 @@ static bool match_validate(const struct sw_flow_match *match, mask_allowed &= ~((1 <<OVS_KEY_ATTR_IPV4 ) | (1 <<OVS_KEY_ATTR_IPV6 ) | (1 <<OVS_KEY_ATTR_TCP ) + | (1 <<OVS_KEY_ATTR_TCP_FLAGS ) | (1 <<OVS_KEY_ATTR_UDP ) | (1 <<OVS_KEY_ATTR_SCTP ) | (1 << OVS_KEY_ATTR_ICMP)
@@ -154,8 +155,11 @@ static bool match_validate(const struct sw_flow_match *match,if (match->key->ip.proto ==IPPROTO_TCP ) { key_expected |=1 <<OVS_KEY_ATTR_TCP ; -if (match->mask && (match->mask->key.ip.proto ==0xff )) + key_expected |=1 <<OVS_KEY_ATTR_TCP_FLAGS ; +if (match->mask && (match->mask->key.ip.proto ==0xff )) { mask_allowed |=1 <<OVS_KEY_ATTR_TCP ; + mask_allowed |=1 <<OVS_KEY_ATTR_TCP_FLAGS ; + } }if (match->key->ip.proto ==IPPROTO_ICMP ) {
@@ -186,8 +190,11 @@ static bool match_validate(const struct sw_flow_match *match,if (match->key->ip.proto ==IPPROTO_TCP ) { key_expected |=1 <<OVS_KEY_ATTR_TCP ; -if (match->mask && (match->mask->key.ip.proto ==0xff )) + key_expected |=1 <<OVS_KEY_ATTR_TCP_FLAGS ; +if (match->mask && (match->mask->key.ip.proto ==0xff )) { mask_allowed |=1 <<OVS_KEY_ATTR_TCP ; + mask_allowed |=1 <<OVS_KEY_ATTR_TCP_FLAGS ; + } }if (match->key->ip.proto ==IPPROTO_ICMPV6 ) {
@@ -235,6 +242,7 @@ static const int ovs_key_lens[OVS_KEY_ATTR_MAX + 1] = { [OVS_KEY_ATTR_IPV4] = sizeof(struct ovs_key_ipv4), [OVS_KEY_ATTR_IPV6] = sizeof(struct ovs_key_ipv6), [OVS_KEY_ATTR_TCP] = sizeof(struct ovs_key_tcp), + [OVS_KEY_ATTR_TCP_FLAGS] = sizeof(__be16), [OVS_KEY_ATTR_UDP] = sizeof(struct ovs_key_udp), [OVS_KEY_ATTR_SCTP] = sizeof(struct ovs_key_sctp), [OVS_KEY_ATTR_ICMP] = sizeof(struct ovs_key_icmp),
@@ -634,6 +642,19 @@ static int ovs_key_from_nlattrs(struct sw_flow_match *match, u64 attrs, attrs &= ~(1 <<OVS_KEY_ATTR_TCP ); } +if (attrs & (1 <<OVS_KEY_ATTR_TCP_FLAGS )) { +if (orig_attrs & (1 <<OVS_KEY_ATTR_IPV4 )) { +SW_FLOW_KEY_PUT (match, ipv4.tp.flags, +nla_get_be16 (a[OVS_KEY_ATTR_TCP_FLAGS ]), + is_mask); + }else { +SW_FLOW_KEY_PUT (match, ipv6.tp.flags, +nla_get_be16 (a[OVS_KEY_ATTR_TCP_FLAGS ]), + is_mask); + } + attrs &= ~(1 <<OVS_KEY_ATTR_TCP_FLAGS ); + } +if (attrs & (1 <<OVS_KEY_ATTR_UDP )) {const struct ovs_key_udp *udp_key;
@@ -1004,9 +1025,15 @@ int ovs_nla_put_flow(const struct sw_flow_key *swkey,if (swkey->eth.type ==htons (ETH_P_IP )) { tcp_key->tcp_src = output->ipv4.tp.src; tcp_key->tcp_dst = output->ipv4.tp.dst; +if (nla_put_be16 (skb,OVS_KEY_ATTR_TCP_FLAGS , + output->ipv4.tp.flags)) + goto nla_put_failure; }else if (swkey->eth.type ==htons (ETH_P_IPV6 )) { tcp_key->tcp_src = output->ipv6.tp.src; tcp_key->tcp_dst = output->ipv6.tp.dst; +if (nla_put_be16 (skb,OVS_KEY_ATTR_TCP_FLAGS , + output->ipv6.tp.flags)) + goto nla_put_failure; } }else if (swkey->ip.proto ==IPPROTO_UDP ) {struct ovs_key_udp *udp_key;
Signature · 1 line
1.8.3.2
PATCH 11/11 openvswitch: Use flow hash during flow lookup operation.
In reply to Jesse GrossFrom: Pravin B Shelar <[email protected]>
Flow->hash can be used to detect hash collisions and avoid flow key compare in flow lookup.
--- net/openvswitch/flow_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/openvswitch/flow_table.c +1 -1
@@ -421,7 +421,7 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti, hash =flow_hash (&masked_key, key_start, key_end); head =find_bucket (ti, hash);hlist_for_each_entry_rcu (flow, head, hash_node[ti->node_ver]) { -if (flow->mask == mask && +if (flow->mask == mask && flow->hash == hash &&flow_cmp_masked_key (flow, &masked_key, key_start, key_end))return flow;
Signature · 1 line
1.8.3.2
David Miller
maintainerFrom: Jesse Gross <[email protected]>
Date: Sat, 2 Nov 2013 00:43:39 -0700
Quoted 8 lines
A set of updates for net-next/3.13. Major changes are:
* Restructure flow handling code to be more logically organized and easier to read.
* Rehashing of the flow table is moved from a workqueue to flow installation time. Before, heavy load could block the workqueue for excessive periods of time.
* Additional debugging information is provided to help diagnose megaflows.
* It's now possible to match on TCP flags.
Looks good, pulled, thanks Jesse.