#define GENEVE_DST_PORT 6081
#define VXLAN_DST_PORT 4789
#define LISP_DST_PORT 4341
+#define STT_DST_PORT 7471
#define VXLAN_HLEN (sizeof(struct eth_header) + \
sizeof(struct ip_header) + \
return (class->get_config == get_tunnel_config &&
(!strcmp("geneve", type) || !strcmp("vxlan", type) ||
- !strcmp("lisp", type)));
+ !strcmp("lisp", type) || !strcmp("stt", type)) );
}
const char *
dev->tnl_cfg.dst_port = htons(VXLAN_DST_PORT);
} else if (!strcmp(type, "lisp")) {
dev->tnl_cfg.dst_port = htons(LISP_DST_PORT);
+ } else if (!strcmp(type, "stt")) {
+ dev->tnl_cfg.dst_port = htons(STT_DST_PORT);
}
+ dev->tnl_cfg.dont_fragment = true;
+ dev->tnl_cfg.ttl = DEFAULT_TTL;
return 0;
}
struct smap_node *node;
has_csum = strstr(type, "gre") || strstr(type, "geneve") ||
- strstr(type, "vxlan");
+ strstr(type, "stt") || strstr(type, "vxlan");
ipsec_mech_set = false;
memset(&tnl_cfg, 0, sizeof tnl_cfg);
tnl_cfg.dst_port = htons(LISP_DST_PORT);
}
+ if (!strcmp(type, "stt")) {
+ tnl_cfg.dst_port = htons(STT_DST_PORT);
+ }
+
needs_dst_port = netdev_vport_needs_dst_port(dev_);
tnl_cfg.ipsec = strstr(type, "ipsec");
tnl_cfg.dont_fragment = true;
if ((!strcmp("geneve", type) && dst_port != GENEVE_DST_PORT) ||
(!strcmp("vxlan", type) && dst_port != VXLAN_DST_PORT) ||
- (!strcmp("lisp", type) && dst_port != LISP_DST_PORT)) {
+ (!strcmp("lisp", type) && dst_port != LISP_DST_PORT) ||
+ (!strcmp("stt", type) && dst_port != STT_DST_PORT)) {
smap_add_format(args, "dst_port", "%d", dst_port);
}
}
{
uint32_t hash;
- hash = dp_packet_get_dp_hash(packet);
+ hash = dp_packet_get_rss_hash(packet);
return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
tnl_udp_port_min);
return hlen;
}
+static void
+pkt_metadata_init_tnl(struct pkt_metadata *md)
+{
+ memset(md, 0, offsetof(struct pkt_metadata, tunnel.metadata));
+
+ /* If 'opt_map' is zero then none of the rest of the tunnel metadata
+ * will be read, so we can skip clearing it. */
+ md->tunnel.metadata.opt_map = 0;
+}
+
static int
netdev_gre_pop_header(struct dp_packet *packet)
{
int hlen = sizeof(struct eth_header) +
sizeof(struct ip_header) + 4;
- memset(md, 0, sizeof *md);
+ pkt_metadata_init_tnl(md);
if (hlen > dp_packet_size(packet)) {
return EINVAL;
}
struct flow_tnl *tnl = &md->tunnel;
struct vxlanhdr *vxh;
- memset(md, 0, sizeof *md);
+ pkt_metadata_init_tnl(md);
if (VXLAN_HLEN > dp_packet_size(packet)) {
return EINVAL;
}
struct flow_tnl *tnl = &md->tunnel;
struct genevehdr *gnh;
unsigned int hlen;
+ int err;
- memset(md, 0, sizeof *md);
+ pkt_metadata_init_tnl(md);
if (GENEVE_BASE_HLEN > dp_packet_size(packet)) {
VLOG_WARN_RL(&err_rl, "geneve packet too small: min header=%u packet size=%u\n",
(unsigned int)GENEVE_BASE_HLEN, dp_packet_size(packet));
return EINVAL;
}
- if (gnh->opt_len && gnh->critical) {
- VLOG_WARN_RL(&err_rl, "unknown geneve critical options: %"PRIu8" bytes\n",
- gnh->opt_len * 4);
- return EINVAL;
- }
-
if (gnh->proto_type != htons(ETH_TYPE_TEB)) {
VLOG_WARN_RL(&err_rl, "unknown geneve encapsulated protocol: %#x\n",
ntohs(gnh->proto_type));
tnl->tun_id = htonll(ntohl(get_16aligned_be32(&gnh->vni)) >> 8);
tnl->flags |= FLOW_TNL_F_KEY;
+ err = tun_metadata_from_geneve_header(gnh->options, gnh->opt_len * 4,
+ &tnl->metadata);
+ if (err) {
+ VLOG_WARN_RL(&err_rl, "invalid geneve options");
+ return err;
+ }
+
dp_packet_reset_packet(packet, hlen);
return 0;
struct netdev_vport *dev = netdev_vport_cast(netdev);
struct netdev_tunnel_config *tnl_cfg;
struct genevehdr *gnh;
+ int opt_len;
+ bool crit_opt;
/* XXX: RCUfy tnl_cfg. */
ovs_mutex_lock(&dev->mutex);
gnh = udp_build_header(tnl_cfg, tnl_flow, data);
- gnh->oam = !!(tnl_flow->tunnel.flags & FLOW_TNL_F_OAM);
- gnh->proto_type = htons(ETH_TYPE_TEB);
put_16aligned_be32(&gnh->vni, htonl(ntohll(tnl_flow->tunnel.tun_id) << 8));
ovs_mutex_unlock(&dev->mutex);
- data->header_len = GENEVE_BASE_HLEN;
+
+ opt_len = tun_metadata_to_geneve_header(&tnl_flow->tunnel.metadata,
+ gnh->options, &crit_opt);
+
+ gnh->opt_len = opt_len / 4;
+ gnh->oam = !!(tnl_flow->tunnel.flags & FLOW_TNL_F_OAM);
+ gnh->critical = crit_opt ? 1 : 0;
+ gnh->proto_type = htons(ETH_TYPE_TEB);
+
+ data->header_len = GENEVE_BASE_HLEN + opt_len;
data->tnl_type = OVS_VPORT_TYPE_GENEVE;
return 0;
}
TUNNEL_CLASS("vxlan", "vxlan_sys", netdev_vxlan_build_header,
push_udp_header,
netdev_vxlan_pop_header),
- TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL)
+ TUNNEL_CLASS("lisp", "lisp_sys", NULL, NULL, NULL),
+ TUNNEL_CLASS("stt", "stt_sys", NULL, NULL, NULL),
};
static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;