[ovs-dev] [PATCH 1/2] datapath: Add pre_tunnel support
Kyle Mestery
kmestery at cisco.com
Tue Jan 22 18:36:39 UTC 2013
Add support to the tunneling code for a "pre_tunnel"
function. This allows the tunneling code to perform
operations on the packet before the outer IP header is
added.
A tunneling protocol such as LISP may require this, as it needs
to remove the MAC header before applying the LISP header.
Signed-off-by: Kyle Mestery <kmestery at cisco.com>
---
datapath/tunnel.c | 5 +++++
datapath/tunnel.h | 7 +++++++
datapath/vport-capwap.c | 1 +
datapath/vport-gre.c | 2 ++
datapath/vport-vxlan.c | 1 +
5 files changed, 16 insertions(+)
diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index d03b708..f1dd8d3 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -988,6 +988,11 @@ int ovs_tnl_send(struct vport *vport, struct sk_buff *skb)
if (unlikely(vlan_deaccel_tag(skb)))
goto next;
+ /* Pre tunnel header work done by tunneling layer. */
+ if (tnl_vport->tnl_ops->pre_tunnel)
+ skb = tnl_vport->tnl_ops->pre_tunnel(vport, mutable,
+ skb);
+
skb_push(skb, tunnel_hlen);
skb_reset_network_header(skb);
skb_set_transport_header(skb, sizeof(struct iphdr));
diff --git a/datapath/tunnel.h b/datapath/tunnel.h
index b7de7a9..12e7f19 100644
--- a/datapath/tunnel.h
+++ b/datapath/tunnel.h
@@ -135,6 +135,13 @@ struct tnl_ops {
int (*hdr_len)(const struct tnl_mutable_config *,
const struct ovs_key_ipv4_tunnel *);
/*
+ * Some tunnels may need to perform actions on the packet before
+ * appending the outer IP header of the tunneled packet.
+ */
+ struct sk_buff *(*pre_tunnel)(const struct vport *,
+ const struct tnl_mutable_config *,
+ struct sk_buff *);
+ /*
* Returns a linked list of SKBs with tunnel headers (multiple
* packets may be generated in the event of fragmentation). Space
* will have already been allocated at the start of the packet equal
diff --git a/datapath/vport-capwap.c b/datapath/vport-capwap.c
index f45d349..9055b1d 100644
--- a/datapath/vport-capwap.c
+++ b/datapath/vport-capwap.c
@@ -358,6 +358,7 @@ static const struct tnl_ops capwap_tnl_ops = {
.tunnel_type = TNL_T_PROTO_CAPWAP,
.ipproto = IPPROTO_UDP,
.hdr_len = capwap_hdr_len,
+ .pre_tunnel = NULL,
.build_header = capwap_build_header,
};
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index 8ce8a35..80f805a 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -422,6 +422,7 @@ static const struct tnl_ops gre_tnl_ops = {
.tunnel_type = TNL_T_PROTO_GRE,
.ipproto = IPPROTO_GRE,
.hdr_len = gre_hdr_len,
+ .pre_tunnel = NULL,
.build_header = gre_build_header,
};
@@ -439,6 +440,7 @@ static const struct tnl_ops gre64_tnl_ops = {
.tunnel_type = TNL_T_PROTO_GRE64,
.ipproto = IPPROTO_GRE,
.hdr_len = gre_hdr_len,
+ .pre_tunnel = NULL,
.build_header = gre_build_header,
};
diff --git a/datapath/vport-vxlan.c b/datapath/vport-vxlan.c
index f72b95f..4922486 100644
--- a/datapath/vport-vxlan.c
+++ b/datapath/vport-vxlan.c
@@ -329,6 +329,7 @@ static const struct tnl_ops ovs_vxlan_tnl_ops = {
.tunnel_type = TNL_T_PROTO_VXLAN,
.ipproto = IPPROTO_UDP,
.hdr_len = vxlan_hdr_len,
+ .pre_tunnel = NULL,
.build_header = vxlan_build_header,
};
--
1.7.11.7
More information about the dev
mailing list