From patchwork Tue Apr 25 16:30:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Balogh X-Patchwork-Id: 754918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wC7yq0rZ8z9s8Q for ; Wed, 26 Apr 2017 02:32:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.onmicrosoft.com header.i=@ericsson.onmicrosoft.com header.b="hcZLNPPU"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8AE5FBF0; Tue, 25 Apr 2017 16:30:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5E408BAC for ; Tue, 25 Apr 2017 16:30:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 756AC241 for ; Tue, 25 Apr 2017 16:30:49 +0000 (UTC) X-AuditID: c1b4fb25-ebfff70000004efc-26-58ff79b6c047 Received: from ESESSHC006.ericsson.se (Unknown_Domain [153.88.183.36]) by (Symantec Mail Security) with SMTP id 98.BD.20220.6B97FF85; Tue, 25 Apr 2017 18:30:47 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.36) with Microsoft SMTP Server (TLS) id 14.3.339.0; Tue, 25 Apr 2017 18:30:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.onmicrosoft.com; s=selector1-ericsson-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=H8rrkMn0Wcbl0+VRHH72JVvqAmkCdc/VyfVzqpNTbRg=; b=hcZLNPPUBRf2FM38tFqNSzZLS948yHQf2G6nbDsFbfjbZoF8No5yVLl3WY2ZhqCIvPiERKk7+Bg/oE5k23yhUE7upE6aUAHMqOsFUJwB35jLaFRUZfO7Ho1XJLGmOwARNwmN5Gv8fDH3AGCusAMhn0ZRepDYSVowSqmLmoh4b2o= Received: from AM2PR07MB1042.eurprd07.prod.outlook.com (10.162.37.27) by AM2PR07MB1043.eurprd07.prod.outlook.com (10.162.37.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.6; Tue, 25 Apr 2017 16:30:45 +0000 Received: from AM2PR07MB1042.eurprd07.prod.outlook.com ([fe80::90cd:8ba4:2442:e4d]) by AM2PR07MB1042.eurprd07.prod.outlook.com ([fe80::90cd:8ba4:2442:e4d%15]) with mapi id 15.01.1047.019; Tue, 25 Apr 2017 16:30:45 +0000 From: =?iso-8859-1?Q?Zolt=E1n_Balogh?= To: "'dev@openvswitch.org'" Thread-Topic: [PATCH v4 4/7] userspace: L3 tunnel support for GRE and LISP Thread-Index: AdK935ZGxJM/pII3S220dkNVgdBgkQ== Date: Tue, 25 Apr 2017 16:30:44 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: openvswitch.org; dkim=none (message not signed) header.d=none;openvswitch.org; dmarc=none action=none header.from=ericsson.com; x-originating-ip: [91.82.100.59] x-microsoft-exchange-diagnostics: 1; AM2PR07MB1043; 7:WPIrVXSJ6EY1iQo6pF+Bf/30oMeKI0HD7h4PkeILt/X0sQYzN3n/4pEl9SBUhVWTN3kJPVSSVnAasJwPlQBP8zYgnUC++vV6Sdo0papzHcZiACnq3ydFCsidKRAFf5Wfi0jxUzwm98SldrSaPpflg2uxj3gRSNNaDK5WxKHrfxllvRTNVjHaXqCN06vPGNpDUaNKDXFBJOEqpw5HhpFMlZB5FGLOcrE94IFkt+ph0CqlpTkHA/9U2wk2MFSdPo2DG8go7r9/C+ctUt9MWzvjaPme5u7BmhZGYDtHnliaGcMWQcQHUP2bfiNFlb/FbWP3TNXDe79E8JUncmnKokjuMw== x-ld-processed: 92e84ceb-fbfd-47ab-be52-080c6b87953f,ExtAddr x-ms-office365-filtering-correlation-id: 8402b806-873f-4eec-fa38-08d48bf86c4e x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:AM2PR07MB1043; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(37575265505322)(169324184973407)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148); SRVR:AM2PR07MB1043; BCL:0; PCL:0; RULEID:; SRVR:AM2PR07MB1043; x-forefront-prvs: 0288CD37D9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(39410400002)(39400400002)(39840400002)(39450400003)(39850400002)(33656002)(2906002)(66066001)(3660700001)(3280700002)(5250100002)(54356999)(74316002)(2900100001)(50986999)(7696004)(189998001)(102836003)(3846002)(8936002)(6116002)(81166006)(6916009)(8676002)(5660300001)(38730400002)(107886003)(7736002)(305945005)(86362001)(110136004)(6506006)(6436002)(4326008)(25786009)(55016002)(99286003)(54906002)(9686003)(53946003)(53936002)(579004); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR07MB1043; H:AM2PR07MB1042.eurprd07.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Apr 2017 16:30:44.5208 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR07MB1043 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsUyM2K7iu72yv8RBvtOaVocPb2H2YHR49nN /4wBjFFcNimpOZllqUX6dglcGdf7v7AXdK9irDj2dwpzA+OjbsYuRk4OCQETibVzD7F2MXJx CAmsZ5TYP/0aO4RzglFifftrZhCHRaCXWWLznN1QmSlMEq09F5kgnIeMEgu2TmYHGcYm4Cxx ffdLNhBbRMBQ4tKkk6wgNrNAisS9yXuZQGxhAVeJxmmHWSBqvCT23LgNVa8nsebSH7AaFgFV iX3nlgLN5ODgFYiRaDzhBxJmFBCT+H5qDRPESHGJW0/mM0H8ICCxZM95ZghbVOLl439g/zAK zGaU+LuzBapIQWLTgvdgH0gI9DBLrDh/lw0iYSMxo3s6VLevRN+e3VB2ncT1lWtZIOxsiYOz vrBD2DESEyb+YoEYdJFJYvO1ndCglJG49fERG0TiC4vEgv8tjBAvS0ncvdIJZctIvLizFxos ehI3pk5hm8CoMQvJS7OQpCBsbYllC18zg9i8AoISJ2c+YVnAyLKKUbQ4tTgpN93IWC+1KDO5 uDg/Ty8vtWQTIzBZHNzyW3UH4+U3jocYBTgYlXh4E8L+RwixJpYVV+YeYpTgYFYS4d0qCRTi TUmsrEotyo8vKs1JLT7EKM3BoiTO67jvQoSQQHpiSWp2ampBahFMlomDU6qB0WZhmxGnisnu r7cjWkOVTl+zW7PFaFWQTLW/ax2r1drVV9LfcjRFqhvXaJ/dIfbpy7pZs/Y6iAh2sBsKtSW/ OXP112Zt1s7TAsZTtk0J8dry4t6jgjqOdW9ZTp19KnuC29iSX/XbGmZx23+3eM7K7z7YoRns lnnzlH/sprJaltx79/5+64gTV2Ipzkg01GIuKk4EAKyuE9ASAwAA X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v4 4/7] userspace: L3 tunnel support for GRE and LISP X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Jan Scheurich Add a boolean "layer3" configuration option for tunnel vports. The layer3 option defaults to false for all ports except LISP. GRE ports accept both true and false for "layer3". A tunnel vport configured with layer3=true receives L3 packets. which are then converted to Ethernet packets by pushing a dummy Ethernet heder at the ingress of the OpenFlow pipeline. The Ethernet header of a packet is stripped before sending to a layer3 tunnel vport. Presently a single GRE vport cannot carry both L2 and L3 packets. But it is possible to create two GRE vports representing the same GRE tunel, one with layer3=false, the other with layer3=true. L2 packet from the tunnel are received on the first vport, L3 packets on the second. The controller must send packets to the layer3 GRE vport to tunnel them without their Ethernet header. Units tests have been added to check the L3 tunnel handling. LISP tunnels are not yet supported by the netdev userspace datapath. Signed-off-by: Simon Horman Signed-off-by: Jiri Benc Signed-off-by: Yi Yang Signed-off-by: Jan Scheurich Co-authored-by: Zoltan Balogh --- lib/netdev-native-tnl.c | 26 +++++++++++++++++++++----- lib/netdev-vport.c | 14 ++++++++++++-- ofproto/tunnel.c | 14 +++++++++++--- tests/tunnel-push-pop-ipv6.at | 16 +++++++++++----- tests/tunnel-push-pop.at | 33 ++++++++++++++++++++++++++++----- vswitchd/vswitch.xml | 13 +++++++++++++ 6 files changed, 96 insertions(+), 20 deletions(-) diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index 2798324..4590e25 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -154,6 +154,10 @@ netdev_tnl_push_ip_header(struct dp_packet *packet, *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header); memcpy(eth, header, size); + /* The encapsulated packet has type Ethernet. Adjust dp_packet. */ + packet->packet_type = htonl(PT_ETH); + dp_packet_reset_offsets(packet); + packet->l3_ofs = sizeof (struct eth_header); if (netdev_tnl_is_header_ipv6(header)) { ip6 = netdev_tnl_ipv6_hdr(eth); @@ -345,6 +349,7 @@ parse_gre_header(struct dp_packet *packet, ovs_16aligned_be32 *options; int hlen; unsigned int ulen; + uint16_t greh_protocol; greh = netdev_tnl_ip_extract_tnl_md(packet, tnl, &ulen); if (!greh) { @@ -355,10 +360,6 @@ parse_gre_header(struct dp_packet *packet, return -EINVAL; } - if (greh->protocol != htons(ETH_TYPE_TEB)) { - return -EINVAL; - } - hlen = ulen + gre_header_len(greh->flags); if (hlen > dp_packet_size(packet)) { return -EINVAL; @@ -388,6 +389,15 @@ parse_gre_header(struct dp_packet *packet, options++; } + /* Set the new packet type depending on the GRE protocol field. */ + greh_protocol = ntohs(greh->protocol); + if (greh_protocol == ETH_TYPE_TEB) { + packet->packet_type = htonl(PT_ETH); + } else { + /* Allow all GRE protocol values as Ethertypes */ + packet->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE, greh_protocol); + } + return hlen; } @@ -451,7 +461,11 @@ netdev_gre_build_header(const struct netdev *netdev, greh = netdev_tnl_ip_build_header(data, params, IPPROTO_GRE); - greh->protocol = htons(ETH_TYPE_TEB); + if (tnl_cfg->is_layer3) { + greh->protocol = params->flow->dl_type; + } else { + greh->protocol = htons(ETH_TYPE_TEB); + } greh->flags = 0; options = (ovs_16aligned_be32 *) (greh + 1); @@ -504,6 +518,7 @@ netdev_vxlan_pop_header(struct dp_packet *packet) tnl->tun_id = htonll(ntohl(get_16aligned_be32(&vxh->vx_vni)) >> 8); tnl->flags |= FLOW_TNL_F_KEY; + packet->packet_type = htonl(PT_ETH); dp_packet_reset_packet(packet, hlen + VXLAN_HLEN); return packet; @@ -583,6 +598,7 @@ netdev_geneve_pop_header(struct dp_packet *packet) tnl->metadata.present.len = opts_len; tnl->flags |= FLOW_TNL_F_UDPIF; + packet->packet_type = htonl(PT_ETH); dp_packet_reset_packet(packet, hlen); return packet; diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 84b9be3..ba69461 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -410,7 +410,7 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp) const char *name = netdev_get_name(dev_); const char *type = netdev_get_type(dev_); struct ds errors = DS_EMPTY_INITIALIZER; - bool needs_dst_port, has_csum; + bool needs_dst_port, has_csum, optional_layer3; uint16_t dst_proto = 0, src_proto = 0; struct netdev_tunnel_config tnl_cfg; struct smap_node *node; @@ -418,6 +418,7 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp) has_csum = strstr(type, "gre") || strstr(type, "geneve") || strstr(type, "stt") || strstr(type, "vxlan"); + optional_layer3 = !strcmp(type, "gre"); memset(&tnl_cfg, 0, sizeof tnl_cfg); /* Add a default destination port for tunnel ports if none specified. */ @@ -431,6 +432,7 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp) if (!strcmp(type, "lisp")) { tnl_cfg.dst_port = htons(LISP_DST_PORT); + tnl_cfg.is_layer3 = true; } if (!strcmp(type, "stt")) { @@ -518,6 +520,10 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp) } else if (!strcmp(node->key, "egress_pkt_mark")) { tnl_cfg.egress_pkt_mark = strtoul(node->value, NULL, 10); tnl_cfg.set_egress_pkt_mark = true; + } else if (!strcmp(node->key, "layer3") && optional_layer3) { + if (!strcmp(node->value, "true")) { + tnl_cfg.is_layer3 = true; + } } else { ds_put_format(&errors, "%s: unknown %s argument '%s'\n", name, type, node->key); @@ -587,6 +593,7 @@ static int get_tunnel_config(const struct netdev *dev, struct smap *args) { struct netdev_vport *netdev = netdev_vport_cast(dev); + const char *type = netdev_get_type(dev); struct netdev_tunnel_config tnl_cfg; ovs_mutex_lock(&netdev->mutex); @@ -640,7 +647,6 @@ get_tunnel_config(const struct netdev *dev, struct smap *args) if (tnl_cfg.dst_port) { uint16_t dst_port = ntohs(tnl_cfg.dst_port); - const char *type = netdev_get_type(dev); if ((!strcmp("geneve", type) && dst_port != GENEVE_DST_PORT) || (!strcmp("vxlan", type) && dst_port != VXLAN_DST_PORT) || @@ -654,6 +660,10 @@ get_tunnel_config(const struct netdev *dev, struct smap *args) smap_add(args, "csum", "true"); } + if (tnl_cfg.is_layer3 && !strcmp("gre", type)) { + smap_add(args, "layer3", "true"); + } + if (!tnl_cfg.dont_fragment) { smap_add(args, "df_default", "false"); } diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index 3d02005..0da4f42 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -38,6 +38,7 @@ #include "openvswitch/vlog.h" #include "unaligned.h" #include "ofproto-dpif.h" +#include "netdev-vport.h" VLOG_DEFINE_THIS_MODULE(tunnel); @@ -49,6 +50,7 @@ struct tnl_match { bool in_key_flow; bool ip_src_flow; bool ip_dst_flow; + bool is_layer3; }; struct tnl_port { @@ -162,6 +164,7 @@ tnl_port_add__(const struct ofport_dpif *ofport, const struct netdev *netdev, tnl_port->match.ip_dst_flow = cfg->ip_dst_flow; tnl_port->match.in_key_flow = cfg->in_key_flow; tnl_port->match.odp_port = odp_port; + tnl_port->match.is_layer3 = netdev_vport_is_layer3(netdev); map = tnl_match_map(&tnl_port->match); existing_port = tnl_find_exact(&tnl_port->match, *map); @@ -205,7 +208,8 @@ tnl_port_add__(const struct ofport_dpif *ofport, const struct netdev *netdev, * Returns 0 if successful, otherwise a positive errno value. */ int tnl_port_add(const struct ofport_dpif *ofport, const struct netdev *netdev, - odp_port_t odp_port, bool native_tnl, const char name[]) OVS_EXCLUDED(rwlock) + odp_port_t odp_port, bool native_tnl, const char name[]) + OVS_EXCLUDED(rwlock) { bool ok; @@ -232,7 +236,8 @@ tnl_port_reconfigure(const struct ofport_dpif *ofport, fat_rwlock_wrlock(&rwlock); tnl_port = tnl_find_ofport(ofport); if (!tnl_port) { - changed = tnl_port_add__(ofport, netdev, odp_port, false, native_tnl, name); + changed = tnl_port_add__(ofport, netdev, odp_port, false, native_tnl, + name); } else if (tnl_port->netdev != netdev || tnl_port->match.odp_port != odp_port || tnl_port->change_seq != netdev_get_change_seq(tnl_port->netdev)) { @@ -383,7 +388,6 @@ tnl_wc_init(struct flow *flow, struct flow_wildcards *wc) } /* Match on packet_type for tunneled packets.*/ wc->masks.packet_type = OVS_BE32_MAX; - } } @@ -562,6 +566,7 @@ tnl_find(const struct flow *flow) OVS_REQ_RDLOCK(rwlock) match.in_key_flow = in_key_flow; match.ip_dst_flow = ip_dst_flow; match.ip_src_flow = ip_src == IP_SRC_FLOW; + match.is_layer3 = flow->packet_type != htonl(PT_ETH); tnl_port = tnl_find_exact(&match, map); if (tnl_port) { @@ -611,6 +616,9 @@ tnl_match_fmt(const struct tnl_match *match, struct ds *ds) } else { ds_put_format(ds, ", key=%#"PRIx64, ntohll(match->in_key)); } + if (match->is_layer3) { + ds_put_cstr(ds, ", layer3"); + } ds_put_format(ds, ", dp port=%"PRIu32, match->odp_port); } diff --git a/tests/tunnel-push-pop-ipv6.at b/tests/tunnel-push-pop-ipv6.at index b5e38aa..fc9e32e 100644 --- a/tests/tunnel-push-pop-ipv6.at +++ b/tests/tunnel-push-pop-ipv6.at @@ -12,6 +12,8 @@ AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \ options:remote_ip=2001:cafe::93 options:out_key=flow options:csum=true ofport_request=4\ -- add-port int-br t4 -- set Interface t4 type=geneve \ options:remote_ip=flow options:key=123 ofport_request=5\ + -- add-port int-br t5 -- set Interface t5 type=gre \ + options:remote_ip=2001:cafe::92 options:key=455 options:layer3=true ofport_request=6\ ], [0]) AT_CHECK([ovs-appctl dpif/show], [0], [dnl @@ -25,6 +27,7 @@ dummy@ovs-dummy: hit:0 missed:0 t2 2/4789: (vxlan: key=123, remote_ip=2001:cafe::92) t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=2001:cafe::93) t4 5/6081: (geneve: key=123, remote_ip=flow) + t5 6/3: (gre: key=455, layer3=true, remote_ip=2001:cafe::92) ]) dnl First setup dummy interface IP address, then add the route @@ -124,18 +127,21 @@ AT_CHECK([tail -1 stdout], [0], dnl Check decapsulation of GRE packet AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000006a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000006a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) ovs-appctl time/warp 1000 AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl - port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=? + port 3: rx pkts=2, bytes=196, drop=?, errs=?, frame=?, over=?, crc=? ]) -dnl Check GRE only accepts encapsulated Ethernet frames -AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000006a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +dnl Check decapsulation of L3GRE packet +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000005a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820000800000001c745000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000005a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820000800000001c745000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +ovs-appctl time/warp 1000 ovs-appctl time/warp 1000 -AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl - port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=? +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 6'], [0], [dnl + port 6: rx pkts=2, bytes=168, drop=?, errs=?, frame=?, over=?, crc=? ]) dnl Check decapsulation of Geneve packet with options diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at index 881d05b..b114e26 100644 --- a/tests/tunnel-push-pop.at +++ b/tests/tunnel-push-pop.at @@ -14,6 +14,8 @@ AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \ options:remote_ip=flow options:key=123 ofport_request=5\ -- add-port int-br t5 -- set Interface t5 type=geneve \ options:remote_ip=1.1.2.93 options:out_key=flow options:egress_pkt_mark=1234 ofport_request=6\ + -- add-port int-br t6 -- set Interface t6 type=gre \ + options:remote_ip=1.1.2.92 options:key=456 options:layer3=true ofport_request=7\ ], [0]) AT_CHECK([ovs-appctl dpif/show], [0], [dnl @@ -28,6 +30,7 @@ dummy@ovs-dummy: hit:0 missed:0 t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=1.1.2.93) t4 5/6081: (geneve: key=123, remote_ip=flow) t5 6/6081: (geneve: egress_pkt_mark=1234, out_key=flow, remote_ip=1.1.2.93) + t6 7/3: (gre: key=456, layer3=true, remote_ip=1.1.2.92) ]) dnl First setup dummy interface IP address, then add the route @@ -124,6 +127,13 @@ AT_CHECK([tail -1 stdout], [0], [Datapath actions: clone(tnl_push(tnl_port(3),header(size=42,type=3,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x2000,proto=0x6558),key=0x1c8)),out_port(100)),1) ]) +dnl Check L3GRE tunnel push +AT_CHECK([ovs-ofctl add-flow int-br action=7]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:01),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: pop_eth,clone(tnl_push(tnl_port(3),header(size=42,type=3,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800),ipv4(src=1.1.2.88,dst=1.1.2.92,proto=47,tos=0,ttl=64,frag=0x4000),gre((flags=0x2000,proto=0x800),key=0x1c8)),out_port(100)),1) +]) + dnl Check Geneve tunnel push AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:1.1.2.92->tun_dst,5"]) AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:01),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) @@ -148,18 +158,31 @@ AT_CHECK([tail -1 stdout], [0], dnl Check decapsulation of GRE packet AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) ovs-appctl time/warp 1000 AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl - port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=? + port 3: rx pkts=3, bytes=294, drop=?, errs=?, frame=?, over=?, crc=? ]) -dnl Check GRE only accepts encapsulated Ethernet frames -AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +dnl Check decapsulation of L3GRE packet +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820000800000001c845000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820000800000001c845000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007079464000402fba630101025c0101025820000800000001c845000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +ovs-appctl time/warp 1000 ovs-appctl time/warp 1000 -AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl - port 3: rx pkts=1, bytes=98, drop=?, errs=?, frame=?, over=?, crc=? +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 7'], [0], [dnl + port 7: rx pkts=3, bytes=252, drop=?, errs=?, frame=?, over=?, crc=? +]) + +dnl Check GREL3 only accepts non-fragmented packets? +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6408004500007e79464000402fba550101025c0101025820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) + +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port [[37]]' | sort], [0], [dnl + port 3: rx pkts=3, bytes=294, drop=?, errs=?, frame=?, over=?, crc=? + port 7: rx pkts=3, bytes=252, drop=?, errs=?, frame=?, over=?, crc=? ]) dnl Check decapsulation of Geneve packet with options diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 02980b1..554e4de 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -2385,6 +2385,19 @@ + +

+ gre interfaces support these options. +

+ + +

+ Optional. Packets are sent and received without an Ethernet + header present. +

+
+
+

gre, geneve, and