Thread (15 messages) 15 messages, 3 authors, 2015-01-05
STALE4183d

[PATCH/RFC flow-net-next 09/10] net: flow: Add eviction flags to table configuration

From: Simon Horman <hidden>
Date: 2014-12-29 02:16:19
Subsystem: networking drivers, networking [general], the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

The intention is to allow run-time configuration of if and how
a switch or switch-like device may evict flows from tables in
the case of resource contention.

Inspired by a feature of the same name in in OpenFlow.

Signed-off-by: Simon Horman <redacted>
---
 include/uapi/linux/if_flow.h | 16 ++++++++++++++++
 net/core/flow_table.c        | 11 ++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/if_flow.h b/include/uapi/linux/if_flow.h
index bd29145..7264629 100644
--- a/include/uapi/linux/if_flow.h
+++ b/include/uapi/linux/if_flow.h
@@ -186,6 +186,7 @@
  * [NET_FLOW_TABLE_CONFIGS]
  *   [NET_FLOW_TABLE_CONFIG_TABLE]
  *     [NET_FLOW_TABLE_CONFIG_TABLE_ATTR_UID]
+ *     [NET_FLOW_TABLE_CONFIG_TABLE_ATTR_EVICTION]
  *   ...
  *
  * Set Flow Notification <Request>,
@@ -742,9 +743,11 @@ enum {
  * @brief flow table configuration
  *
  * @table unique identifier of table
+ * @eviction flags to control eviction. Bitmask of NET_FLOW_EVICTION_F_*
  */
 struct net_flow_table_config {
 	int table;
+	__u32 eviction;
 };
 
 enum {
@@ -757,10 +760,23 @@ enum {
 enum {
 	NET_FLOW_TABLE_CONFIG_TABLE_ATTR_UNSPEC,
 	NET_FLOW_TABLE_CONFIG_TABLE_ATTR_UID,
+	NET_FLOW_TABLE_CONFIG_TABLE_ATTR_EVICTION,
 	__NET_FLOW_TABLE_CONFIG_TABLE_ATTR_MAX,
 };
 #define NET_FLOW_TABLE_CONFIG_TABLE_ATTR_MAX (__NET_FLOW_TABLE_CONFIG_TABLE_ATTR_MAX - 1)
 
+
+enum {
+	/* Eviction enabled.
+	 * Must be set for any eviction to occur */
+	NET_FLOW_EVICTION_F_ENABLE	= (0 << 1),
+
+	/* Evict entries based on their importance */
+	NET_FLOW_EVICTION_F_IMPORTANCE	= (1 << 1),
+	/* Evict entries based on how close they are to timing out */
+	NET_FLOW_EVICTION_F_TIMEOUT	= (2 << 1),
+};
+
 enum {
 	NET_FLOW_REM_FLOW_UNSPEC,
 	NET_FLOW_REM_FLOW_TABLE,
diff --git a/net/core/flow_table.c b/net/core/flow_table.c
index 6c44311..3030246 100644
--- a/net/core/flow_table.c
+++ b/net/core/flow_table.c
@@ -1595,13 +1595,14 @@ static int net_flow_table_cmd_get_table_config(struct sk_buff *skb,
 		}
 
 		if (nla_put_u32(msg, NET_FLOW_TABLE_CONFIG_TABLE_ATTR_UID,
-				table)) {
+				table) ||
+			nla_put_u32(msg,
+				    NET_FLOW_TABLE_CONFIG_TABLE_ATTR_EVICTION,
+				    tc->eviction)) {
 			err = -ENOBUFS;
 			goto err;
 		}
 
-		/* Write other attributes of tc: Currently none are defined. */
-
 		nla_nest_end(msg, config);
 	}
 
@@ -1669,6 +1670,10 @@ static int net_flow_table_cmd_set_table_config(struct sk_buff *skb,
 
 		new_tc = *tc;
 
+		if (!tb[NET_FLOW_TABLE_CONFIG_TABLE_ATTR_EVICTION]) {
+			new_tc.eviction = nla_get_u32(tb[NET_FLOW_TABLE_CONFIG_TABLE_ATTR_EVICTION]);
+		}
+
 		err = dev->netdev_ops->ndo_flow_table_set_table_config(dev, &new_tc);
 		if (err)
 			goto out;
-- 
2.1.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help