Skip to content

Commit

Permalink
datapath: Add Stateless TCP Tunneling protocol.
Browse files Browse the repository at this point in the history
The Stateless TCP Tunnel (STT) protocol encapsulates traffic in
IPv4/TCP packets.
STT uses TCP segmentation offload available in most of NIC. On
packet xmit STT driver appends STT header along with TCP header
to the packet. For GSO packet GSO parameters are set according
to tunnel configuration and packet is handed over to networking
stack. This allows use of segmentation offload available in NICs

The protocol is documented at
http://www.ietf.org/archive/id/draft-davie-stt-06.txt

Signed-off-by: Pravin B Shelar <[email protected]>
Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
Pravin B Shelar committed Apr 29, 2015
1 parent a51a508 commit 4237026
Show file tree
Hide file tree
Showing 14 changed files with 1,920 additions and 12 deletions.
1 change: 1 addition & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ A: Support for tunnels was added to the upstream Linux kernel module
| VXLAN | 3.12
| Geneve | 3.18
| LISP | <not upstream>
| STT | <not upstream>

If you are using a version of the kernel that is older than the one
listed above, it is still possible to use that tunnel protocol. However,
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Post-v2.3.0
- The kernel vports with dependencies are no longer part of the overall
openvswitch.ko but built and loaded automatically as individual kernel
modules (vport-*.ko).
- Support for STT tunneling.


v2.3.0 - 14 Aug 2014
Expand Down
2 changes: 2 additions & 0 deletions datapath/Modules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ both_modules = \
vport_geneve \
vport_gre \
vport_lisp \
vport_stt \
vport_vxlan
# When changing the name of 'build_modules', please also update the
# print-build-modules in Makefile.am.
Expand All @@ -30,6 +31,7 @@ vport_geneve_sources = vport-geneve.c
vport_vxlan_sources = vport-vxlan.c
vport_gre_sources = vport-gre.c
vport_lisp_sources = vport-lisp.c
vport_stt_sources = vport-stt.c

openvswitch_headers = \
compat.h \
Expand Down
2 changes: 2 additions & 0 deletions datapath/linux/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
/random32.c
/reciprocal_div.c
/skbuff-openvswitch.c
/stt.c
/table.c
/time.c
/tmp
Expand All @@ -50,6 +51,7 @@
/vport-lisp.c
/vport-netdev.c
/vport-patch.c
/vport-stt.c
/vport-vxlan.c
/vport.c
/vxlan.c
Expand Down
2 changes: 2 additions & 0 deletions datapath/linux/Modules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ openvswitch_sources += \
linux/compat/net_namespace.c \
linux/compat/reciprocal_div.c \
linux/compat/skbuff-openvswitch.c \
linux/compat/stt.c \
linux/compat/udp.c \
linux/compat/udp_tunnel.c \
linux/compat/vxlan.c \
Expand Down Expand Up @@ -75,6 +76,7 @@ openvswitch_headers += \
linux/compat/include/net/udp.h \
linux/compat/include/net/udp_tunnel.h \
linux/compat/include/net/sock.h \
linux/compat/include/net/stt.h \
linux/compat/include/net/vxlan.h \
linux/compat/include/net/sctp/checksum.h
EXTRA_DIST += linux/compat/build-aux/export-check-whitelist
9 changes: 9 additions & 0 deletions datapath/linux/compat/gso.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ struct ovs_gso_cb {
};
#define OVS_GSO_CB(skb) ((struct ovs_gso_cb *)(skb)->cb)

static inline void skb_clear_ovs_gso_cb(struct sk_buff *skb)
{
OVS_GSO_CB(skb)->fix_segment = NULL;
}
#else
static inline void skb_clear_ovs_gso_cb(struct sk_buff *skb)
{

}
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
Expand Down
1 change: 1 addition & 0 deletions datapath/linux/compat/include/linux/openvswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ enum ovs_vport_type {
OVS_VPORT_TYPE_GENEVE, /* Geneve tunnel. */
OVS_VPORT_TYPE_GRE64 = 104, /* GRE tunnel with 64-bit keys */
OVS_VPORT_TYPE_LISP = 105, /* LISP tunnel */
OVS_VPORT_TYPE_STT = 106, /* STT tunnel */
__OVS_VPORT_TYPE_MAX
};

Expand Down
71 changes: 71 additions & 0 deletions datapath/linux/compat/include/net/stt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef __NET_STT_H
#define __NET_STT_H 1

#include <linux/kconfig.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) && IS_ENABLED(CONFIG_NETFILTER)
#include <net/ip_tunnels.h>
#define OVS_STT

struct stthdr {
__u8 version;
__u8 flags;
__u8 l4_offset;
__u8 reserved;
__be16 mss;
__be16 vlan_tci;
__be64 key;
};

/* Padding after the end of the tunnel headers to provide alignment
* for inner packet IP header after 14 byte Ethernet header.
*/
#define STT_ETH_PAD 2

#define STT_BASE_HLEN (sizeof(struct stthdr) + STT_ETH_PAD)
#define STT_HEADER_LEN (sizeof(struct tcphdr) + STT_BASE_HLEN)

static inline struct stthdr *stt_hdr(const struct sk_buff *skb)
{
return (struct stthdr *)(skb_transport_header(skb) +
sizeof(struct tcphdr));
}

struct stt_sock;
typedef void (stt_rcv_t)(struct stt_sock *stt_sock, struct sk_buff *skb);

/* @list: Per-net list of STT ports.
* @rcv: The callback is called on STT packet recv, STT reassembly can generate
* multiple packets, in this case first packet has tunnel outer header, rest
* of the packets are inner packet segments with no stt header.
* @rcv_data: user data.
* @sock: Fake TCP socket for the STT port.
*/
struct stt_sock {
struct list_head list;
stt_rcv_t *rcv;
void *rcv_data;
struct socket *sock;
struct rcu_head rcu;
};

#define stt_sock_add rpl_stt_sock_add
struct stt_sock *rpl_stt_sock_add(struct net *net, __be16 port,
stt_rcv_t *rcv, void *data);

#define stt_sock_release rpl_stt_sock_release
void rpl_stt_sock_release(struct stt_sock *stt_sock);

#define stt_xmit_skb rpl_stt_xmit_skb
int rpl_stt_xmit_skb(struct sk_buff *skb, struct rtable *rt,
__be32 src, __be32 dst, __u8 tos,
__u8 ttl, __be16 df, __be16 src_port, __be16 dst_port,
__be64 tun_id);

#define stt_init_module ovs_stt_init_module
int ovs_stt_init_module(void);

#define stt_cleanup_module ovs_stt_cleanup_module
void ovs_stt_cleanup_module(void);

#endif
#endif /*ifdef__NET_STT_H */
Loading

0 comments on commit 4237026

Please sign in to comment.