diff mbox

[ovs-dev,RFC,v2,10/13] Add push_eth/pop_eth flow actions for kernel data path

Message ID 1468344552-11523-1-git-send-email-johnson.li@intel.com
State Changes Requested
Headers show

Commit Message

Johnson.Li July 12, 2016, 5:29 p.m. UTC
Ethernet header could be pushed to/stripped from packets with
flow action push_eth/pop_eth, origin packets will be treated as
payload even the packets are Ethernet packets.

Derived from work by Lorand Jakub and Simon Horman.
Cc: Lorand Jakab <lojakab@cisco.com>
Cc: Simon Horman <simon.horman@netronome.com>
---
This is extracted from l3 flow support paches currently
being targeted at net-next by Simon Horman.

Signed-off-by: Johnson Li <johnson.li@intel.com>
diff mbox

Patch

diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h
index 896fa68..9cf8edd 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -663,6 +663,15 @@  struct ovs_action_push_nsh {
 	uint8_t header[NSH_HEADER_LEN_MAX]; /* NSH header */
 };
 
+/**
+ * struct ovs_action_push_eth - %OVS_ACTION_ATTR_PUSH_ETH action argument.
+ * @addr: Ethernet Addresses(Destination and Source MAC address).
+ * @type: Ethernet Type(IPv4/IPv6, etc.).
+ */
+struct ovs_action_push_eth {
+	struct ovs_key_ethernet addresses;
+};
+
 /* Data path hash algorithm for computing Datapath hash.
  *
  * The algorithm type only specifies the fields in a flow
@@ -843,6 +852,8 @@  enum ovs_action_attr {
 	OVS_ACTION_ATTR_TRUNC,        /* u32 struct ovs_action_trunc. */
 	OVS_ACTION_ATTR_PUSH_NSH,     /* struct ovs_action_push_nsh. */
 	OVS_ACTION_ATTR_POP_NSH,      /* No argument. */
+	OVS_ACTION_ATTR_PUSH_ETH,     /* struct ovs_action_push_eth. */
+	OVS_ACTION_ATTR_POP_ETH,      /* No argument. */
 
 #ifndef __KERNEL__
 	OVS_ACTION_ATTR_TUNNEL_PUSH,   /* struct ovs_action_push_tnl*/
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d2bd64f..ebad3e7 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4199,6 +4199,8 @@  dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
     case OVS_ACTION_ATTR_TRUNC:
     case OVS_ACTION_ATTR_PUSH_NSH:
     case OVS_ACTION_ATTR_POP_NSH:
+    case OVS_ACTION_ATTR_PUSH_ETH:
+    case OVS_ACTION_ATTR_POP_ETH:
     case __OVS_ACTION_ATTR_MAX:
         OVS_NOT_REACHED();
     }
diff --git a/lib/dpif.c b/lib/dpif.c
index cff453e..9132d07 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1171,6 +1171,8 @@  dpif_execute_helper_cb(void *aux_, struct dp_packet_batch *packets_,
     case OVS_ACTION_ATTR_TRUNC:
     case OVS_ACTION_ATTR_PUSH_NSH:
     case OVS_ACTION_ATTR_POP_NSH:
+    case OVS_ACTION_ATTR_PUSH_ETH:
+    case OVS_ACTION_ATTR_POP_ETH:
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
         OVS_NOT_REACHED();
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 8b2d989..375506e 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -508,6 +508,8 @@  requires_datapath_assistance(const struct nlattr *a)
     case OVS_ACTION_ATTR_TRUNC:
     case OVS_ACTION_ATTR_PUSH_NSH:
     case OVS_ACTION_ATTR_POP_NSH:
+    case OVS_ACTION_ATTR_PUSH_ETH:
+    case OVS_ACTION_ATTR_POP_ETH:
         return false;
 
     case OVS_ACTION_ATTR_UNSPEC:
@@ -643,6 +645,8 @@  odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal,
 
         case OVS_ACTION_ATTR_PUSH_NSH:
         case OVS_ACTION_ATTR_POP_NSH:
+        case OVS_ACTION_ATTR_PUSH_ETH:
+        case OVS_ACTION_ATTR_POP_ETH:
             break;
 
         case OVS_ACTION_ATTR_OUTPUT:
diff --git a/lib/odp-util.c b/lib/odp-util.c
index e8213c0..8697e00 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -123,6 +123,8 @@  odp_action_len(uint16_t type)
     case OVS_ACTION_ATTR_CT: return ATTR_LEN_VARIABLE;
     case OVS_ACTION_ATTR_PUSH_NSH: return sizeof(struct ovs_action_push_nsh);
     case OVS_ACTION_ATTR_POP_NSH: return 0;
+    case OVS_ACTION_ATTR_PUSH_ETH: return sizeof(struct ovs_action_push_eth);
+    case OVS_ACTION_ATTR_POP_ETH: return 0;
 
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
@@ -933,6 +935,10 @@  format_odp_action(struct ds *ds, const struct nlattr *a)
         ds_put_cstr(ds, "pop_nsh");
         break;
 
+    case OVS_ACTION_ATTR_PUSH_ETH:
+    case OVS_ACTION_ATTR_POP_ETH:
+        break;
+
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
     default:
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index 86ffdd5..003b2dd 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -1179,6 +1179,8 @@  dpif_sflow_read_actions(const struct flow *flow,
 	case OVS_ACTION_ATTR_UNSPEC:
 	case OVS_ACTION_ATTR_PUSH_NSH:
 	case OVS_ACTION_ATTR_POP_NSH:
+	case OVS_ACTION_ATTR_PUSH_ETH:
+	case OVS_ACTION_ATTR_POP_ETH:
 	case __OVS_ACTION_ATTR_MAX:
 	default:
 	    break;