On Dec 11, 2012, at 6:53 , ext Ben Pfaff wrote:
>On Mon, Dec 10, 2012 at 05:16:39PM -0800, Rich Lane wrote:
>>I would have liked to put this in under the BSN vendor ID but there isn't any
>>existing support for actions from other vendors. Let me know if you'd like me
>>to add that.
>
>Jesse made some comments on the rest, here's some on this bit.
>
>I'm open to generalizing the actions code to support other vendor IDs.
>
>It might make sense, though, to instead expose the tunnel destination
>as an NXM/OXM field, and then we could just use NXAST_REG_LOAD or
>OFPAT_SET_FIELD to change it.

Here is an experimental patch I've been using for this.  Can't be applied as
such due to my shortcut of using OXM basic namespace, but this shows that
what Ben proposed above is much simpler than adding more/new actions.

Signed-off-by: Jarno Rajahalme <jarno.rajaha...@nsn.com>
---
 include/openflow/openflow-1.2.h |    7 +++++++
 lib/meta-flow.c                 |   12 ++++++------
 lib/nx-match.c                  |    8 +++++++-
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/openflow/openflow-1.2.h b/include/openflow/openflow-1.2.h
index 5546313..47c575c 100644
--- a/include/openflow/openflow-1.2.h
+++ b/include/openflow/openflow-1.2.h
@@ -112,6 +112,10 @@ enum oxm12_ofb_match_fields {
     OFPXMT12_OFB_TUNNEL_ID,      /* Logical Port Metadata */
     OFPXMT12_OFB_IPV6_EXTHDR,    /* IPv6 Extension Header pseudo-field */
 
+    /* XXX: NSN Experimental */
+    OFPXMT_OFB_TUNNEL_IPV4_SRC = 46,
+    OFPXMT_OFB_TUNNEL_IPV4_DST = 47,
+
     /* End Marker */
     OFPXMT12_OFB_MAX,
 };
@@ -185,6 +189,9 @@ enum oxm12_ofb_match_fields {
 #define OXM_OF_IPV6_EXTHDR    OXM_HEADER   (OFPXMT12_OFB_IPV6_EXTHDR, 2)
 #define OXM_OF_IPV6_EXTHDR_W  OXM_HEADER_W (OFPXMT12_OFB_IPV6_EXTHDR, 2)
 
+#define OXM_OF_TUNNEL_IPV4_SRC       OXM_HEADER   (OFPXMT_OFB_TUNNEL_IPV4_SRC, 
4)
+#define OXM_OF_TUNNEL_IPV4_DST       OXM_HEADER   (OFPXMT_OFB_TUNNEL_IPV4_DST, 
4)
+
 /* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
  * special conditions.
  */
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 749898f..909e434 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -61,18 +61,18 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
         MFM_NONE,
         MFS_IPV4,
         MFP_NONE,
-        false,
-        0, NULL,
-        0, NULL,
+        true,
+        OXM_OF_TUNNEL_IPV4_SRC, "OXM_OF_TUNNEL_IPV4_SRC",
+        OXM_OF_TUNNEL_IPV4_SRC, "OXM_OF_TUNNEL_IPV4_SRC",
     }, {
         MFF_TUN_DST, "tun_dst", NULL,
         MF_FIELD_SIZES(be32),
         MFM_NONE,
         MFS_IPV4,
         MFP_NONE,
-        false,
-        0, NULL,
-        0, NULL,
+        true,
+        OXM_OF_TUNNEL_IPV4_DST, "OXM_OF_TUNNEL_IPV4_DST",
+        OXM_OF_TUNNEL_IPV4_DST, "OXM_OF_TUNNEL_IPV4_DST",
     }, {
         MFF_TUN_FLAGS, "tun_flags", NULL,
         MF_FIELD_SIZES(be16),
diff --git a/lib/nx-match.c b/lib/nx-match.c
index 05f1ce9..8463f60 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -645,7 +645,13 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct match 
*match,
 
     /* Tunnel ID. */
     nxm_put_64m(b, oxm ? OXM_OF_TUNNEL_ID : NXM_NX_TUN_ID,
-               flow->tunnel.tun_id, match->wc.masks.tunnel.tun_id);
+                flow->tunnel.tun_id, match->wc.masks.tunnel.tun_id);
+
+    /* Other tunnel metadata. */
+    nxm_put_32m(b, OXM_OF_TUNNEL_IPV4_SRC,
+                flow->tunnel.ip_src, match->wc.masks.tunnel.ip_src);
+    nxm_put_32m(b, OXM_OF_TUNNEL_IPV4_DST,
+                flow->tunnel.ip_dst, match->wc.masks.tunnel.ip_dst);
 
     /* Registers. */
     for (i = 0; i < FLOW_N_REGS; i++) {
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to