Remove vestigal TCP implementation

Eliot's TCP was never completed. Remove it.

Change-Id: I8456ed02b55f5b3f0b93547533f7467dd2229c07
Signed-off-by: Kevin Paul Herbert <kph@cisco.com>
This commit is contained in:
Kevin Paul Herbert
2016-01-26 18:32:24 -08:00
committed by Damjan Marion
parent dac3fd44ff
commit 8f9e7d43d8
12 changed files with 2 additions and 3437 deletions
-6
View File
@@ -211,12 +211,6 @@ nobase_include_HEADERS += \
# Layer 3 protocols go here
########################################
# vnet/ip/tcp.c \
# vnet/ip/tcp_format.c \
# vnet/ip/tcp_init.c \
# vnet/ip/tcp_pg.c
########################################
# Layer 3 protocol: IP v4/v6
########################################
-1
View File
@@ -2367,7 +2367,6 @@ VLIB_REGISTER_NODE (ip4_local_node,static) = {
.next_nodes = {
[IP_LOCAL_NEXT_DROP] = "error-drop",
[IP_LOCAL_NEXT_PUNT] = "error-punt",
// [IP_LOCAL_NEXT_TCP_LOOKUP] = "ip4-tcp-lookup",
[IP_LOCAL_NEXT_UDP_LOOKUP] = "ip4-udp-lookup",
[IP_LOCAL_NEXT_ICMP] = "ip4-icmp-input",
},
+1 -3
View File
@@ -60,13 +60,11 @@
/* Errors signalled by ip6-local. */ \
_ (UNKNOWN_PROTOCOL, "unknown ip protocol") \
_ (UDP_CHECKSUM, "bad udp checksum") \
_ (TCP_CHECKSUM, "bad tcp checksum") \
_ (ICMP_CHECKSUM, "bad icmp checksum") \
_ (UDP_LENGTH, "inconsistent udp/ip lengths") \
\
/* Errors signalled by {tcp6,udp6}-lookup. */ \
/* Errors signalled by udp6-lookup. */ \
_ (UNKNOWN_UDP_PORT, "no listener for udp port") \
_ (UNKNOWN_TCP_PORT, "no listener for tcp port") \
\
/* Spoofed packets in ip6-rewrite-local */ \
_(SPOOFED_LOCAL_PACKETS, "ip4 spoofed local-address packet drops") \
-3
View File
@@ -1621,7 +1621,6 @@ ip6_local (vlib_main_t * vm,
error1 = len_diff1 < 0 ? IP6_ERROR_UDP_LENGTH : error1;
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_UDP == IP6_ERROR_UDP_CHECKSUM);
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_TCP == IP6_ERROR_TCP_CHECKSUM);
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_ICMP == IP6_ERROR_ICMP_CHECKSUM);
error0 = (! good_l4_checksum0
? IP6_ERROR_UDP_CHECKSUM + type0
@@ -1713,7 +1712,6 @@ ip6_local (vlib_main_t * vm,
error0 = len_diff0 < 0 ? IP6_ERROR_UDP_LENGTH : error0;
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_UDP == IP6_ERROR_UDP_CHECKSUM);
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_TCP == IP6_ERROR_TCP_CHECKSUM);
ASSERT (IP6_ERROR_UDP_CHECKSUM + IP_BUILTIN_PROTOCOL_ICMP == IP6_ERROR_ICMP_CHECKSUM);
error0 = (! good_l4_checksum0
? IP6_ERROR_UDP_CHECKSUM + type0
@@ -1754,7 +1752,6 @@ VLIB_REGISTER_NODE (ip6_local_node,static) = {
.next_nodes = {
[IP_LOCAL_NEXT_DROP] = "error-drop",
[IP_LOCAL_NEXT_PUNT] = "error-punt",
// [IP_LOCAL_NEXT_TCP_LOOKUP] = "ip6-tcp-lookup",
[IP_LOCAL_NEXT_UDP_LOOKUP] = "ip6-udp-lookup",
[IP_LOCAL_NEXT_ICMP] = "ip6-icmp-input",
},
-11
View File
@@ -124,20 +124,9 @@ do { \
if ((error = vlib_call_init_function (vm, ip4_hop_by_hop_init)))
return error;
#if 0
if ((error = vlib_call_init_function (vm, tcp_udp_lookup_init)))
return error;
#endif
if ((error = vlib_call_init_function (vm, udp_local_init)))
return error;
#if 0
if ((error = vlib_call_init_function (vm, tcp_init)))
return error;
#endif
if ((error = vlib_call_init_function (vm, udp_init)))
return error;
+1 -2
View File
@@ -56,10 +56,9 @@ typedef enum {
#undef ip_port
} ip_port_t;
/* Classifies protocols into TCP, UDP, ICMP or other. */
/* Classifies protocols into UDP, ICMP or other. */
typedef enum {
IP_BUILTIN_PROTOCOL_UDP,
IP_BUILTIN_PROTOCOL_TCP,
IP_BUILTIN_PROTOCOL_ICMP,
IP_BUILTIN_PROTOCOL_UNKNOWN,
} ip_builtin_protocol_t;
-6
View File
@@ -881,12 +881,6 @@ void ip_lookup_init (ip_lookup_main_t * lm, u32 is_ip6)
lm->local_next_by_ip_protocol[i] = IP_LOCAL_NEXT_PUNT;
lm->builtin_protocol_by_ip_protocol[i] = IP_BUILTIN_PROTOCOL_UNKNOWN;
}
#if 0
/* Eliot's TCP doesn't actually work */
lm->local_next_by_ip_protocol[IP_PROTOCOL_TCP] = IP_LOCAL_NEXT_TCP_LOOKUP;
lm->builtin_protocol_by_ip_protocol[IP_PROTOCOL_TCP] =
IP_BUILTIN_PROTOCOL_TCP;
#endif
lm->local_next_by_ip_protocol[IP_PROTOCOL_UDP] = IP_LOCAL_NEXT_UDP_LOOKUP;
lm->local_next_by_ip_protocol[is_ip6 ? IP_PROTOCOL_ICMP6 : IP_PROTOCOL_ICMP] = IP_LOCAL_NEXT_ICMP;
-1
View File
@@ -230,7 +230,6 @@ typedef struct {
typedef enum {
IP_LOCAL_NEXT_DROP,
IP_LOCAL_NEXT_PUNT,
// IP_LOCAL_NEXT_TCP_LOOKUP,
IP_LOCAL_NEXT_UDP_LOOKUP,
IP_LOCAL_NEXT_ICMP,
IP_LOCAL_N_NEXT,
-2983
View File
File diff suppressed because it is too large Load Diff
-132
View File
@@ -1,132 +0,0 @@
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* ip/tcp_format.c: tcp formatting
*
* Copyright (c) 2008 Eliot Dresselhaus
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <vnet/ip/ip.h>
static u8 * format_tcp_flags (u8 * s, va_list * args)
{
int flags = va_arg (*args, int);
#define _(f) if (flags & TCP_FLAG_##f) s = format (s, "%s, ", #f);
foreach_tcp_flag
#undef _
return s;
}
/* Format TCP header. */
u8 * format_tcp_header (u8 * s, va_list * args)
{
tcp_header_t * tcp = va_arg (*args, tcp_header_t *);
u32 max_header_bytes = va_arg (*args, u32);
u32 header_bytes;
uword indent;
/* Nothing to do. */
if (max_header_bytes < sizeof (tcp[0]))
return format (s, "TCP header truncated");
indent = format_get_indent (s);
indent += 2;
s = format (s, "TCP: %d -> %d",
clib_net_to_host_u16 (tcp->ports.src),
clib_net_to_host_u16 (tcp->ports.dst));
s = format (s, "\n%Useq. tx 0x%08x rx 0x%08x",
format_white_space, indent,
clib_net_to_host_u32 (tcp->seq_number),
clib_net_to_host_u32 (tcp->ack_number));
s = format (s, "\n%Uflags %U, tcp header: %d bytes",
format_white_space, indent,
format_tcp_flags, tcp->flags,
(tcp->tcp_header_u32s_and_reserved >> 4) * sizeof (u32));
s = format (s, "\n%Uwindow %d, checksum 0x%04x",
format_white_space, indent,
clib_net_to_host_u16 (tcp->window),
clib_net_to_host_u16 (tcp->checksum));
header_bytes = tcp_header_bytes (tcp);
/* Format TCP options. */
#if 0
{
u8 * o;
u8 * option_start = (void *) (tcp + 1);
u8 * option_end = (void *) tcp + header_bytes;
for (o = option_start; o < option_end; )
{
u32 length = o[1];
switch (o[0])
{
case TCP_OPTION_END:
length = 1;
o = option_end;
break;
case TCP_OPTION_NOP:
length = 1;
break;
}
}
}
#endif
/* Recurse into next protocol layer. */
if (max_header_bytes != 0 && header_bytes < max_header_bytes)
{
ip_main_t * im = &ip_main;
tcp_udp_port_info_t * pi;
pi = ip_get_tcp_udp_port_info (im, tcp->ports.dst);
if (pi && pi->format_header)
s = format (s, "\n%U%U",
format_white_space, indent - 2,
pi->format_header,
/* next protocol header */ (void*) tcp + header_bytes,
max_header_bytes - header_bytes);
}
return s;
}
-65
View File
@@ -1,65 +0,0 @@
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* ip/tcp_init.c: tcp initialization
*
* Copyright (c) 2008 Eliot Dresselhaus
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <vlib/vlib.h>
#include <vnet/ip/format.h>
#include <vnet/ip/ip.h>
#include <vnet/ip/tcp_packet.h>
static clib_error_t *
tcp_init (vlib_main_t * vm)
{
ip_main_t * im = &ip_main;
ip_protocol_info_t * pi;
clib_error_t * error;
error = vlib_call_init_function (vm, ip_main_init);
if (! error)
{
pi = ip_get_protocol_info (im, IP_PROTOCOL_TCP);
pi->format_header = format_tcp_header;
pi->unformat_pg_edit = unformat_pg_tcp_header;
}
return 0;
}
VLIB_INIT_FUNCTION (tcp_init);
-224
View File
@@ -1,224 +0,0 @@
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* ip/tcp_pg: TCP packet-generator interface
*
* Copyright (c) 2008 Eliot Dresselhaus
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <vnet/ip/ip.h>
#include <vnet/pg/pg.h>
static void
tcp_pg_edit_function (pg_main_t * pg,
pg_stream_t * s,
pg_edit_group_t * g,
u32 * packets,
u32 n_packets)
{
vlib_main_t * vm = pg->vlib_main;
u32 ip_offset, tcp_offset;
tcp_offset = g->start_byte_offset;
ip_offset = (g-1)->start_byte_offset;
while (n_packets >= 1)
{
vlib_buffer_t * p0;
ip4_header_t * ip0;
tcp_header_t * tcp0;
ip_csum_t sum0;
u32 tcp_len0;
p0 = vlib_get_buffer (vm, packets[0]);
n_packets -= 1;
packets += 1;
ASSERT (p0->current_data == 0);
ip0 = (void *) (p0->data + ip_offset);
tcp0 = (void *) (p0->data + tcp_offset);
tcp_len0 = clib_net_to_host_u16 (ip0->length) - sizeof (ip0[0]);
/* Initialize checksum with header. */
if (BITS (sum0) == 32)
{
sum0 = clib_mem_unaligned (&ip0->src_address, u32);
sum0 = ip_csum_with_carry (sum0, clib_mem_unaligned (&ip0->dst_address, u32));
}
else
sum0 = clib_mem_unaligned (&ip0->src_address, u64);
sum0 = ip_csum_with_carry
(sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
/* Invalidate possibly old checksum. */
tcp0->checksum = 0;
sum0 = ip_incremental_checksum_buffer (vm, p0, tcp_offset, tcp_len0, sum0);
tcp0->checksum = ~ ip_csum_fold (sum0);
}
}
typedef struct {
struct { pg_edit_t src, dst; } ports;
pg_edit_t seq_number, ack_number;
pg_edit_t tcp_header_u32s;
#define _(f) pg_edit_t f##_flag;
foreach_tcp_flag
#undef _
pg_edit_t window;
pg_edit_t checksum;
pg_edit_t urgent_pointer;
} pg_tcp_header_t;
static inline void
pg_tcp_header_init (pg_tcp_header_t * p)
{
/* Initialize fields that are not bit fields in the IP header. */
#define _(f) pg_edit_init (&p->f, tcp_header_t, f);
_ (ports.src);
_ (ports.dst);
_ (seq_number);
_ (ack_number);
_ (window);
_ (checksum);
_ (urgent_pointer);
#undef _
/* Initialize bit fields. */
#define _(f) \
pg_edit_init_bitfield (&p->f##_flag, tcp_header_t, \
flags, \
TCP_FLAG_BIT_##f, 1);
foreach_tcp_flag
#undef _
pg_edit_init_bitfield (&p->tcp_header_u32s, tcp_header_t,
tcp_header_u32s_and_reserved,
4, 4);
}
uword
unformat_pg_tcp_header (unformat_input_t * input, va_list * args)
{
pg_stream_t * s = va_arg (*args, pg_stream_t *);
pg_tcp_header_t * p;
u32 group_index;
p = pg_create_edit_group (s, sizeof (p[0]), sizeof (tcp_header_t),
&group_index);
pg_tcp_header_init (p);
/* Defaults. */
pg_edit_set_fixed (&p->seq_number, 0);
pg_edit_set_fixed (&p->ack_number, 0);
pg_edit_set_fixed (&p->tcp_header_u32s, sizeof (tcp_header_t) / sizeof (u32));
pg_edit_set_fixed (&p->window, 4096);
pg_edit_set_fixed (&p->urgent_pointer, 0);
#define _(f) pg_edit_set_fixed (&p->f##_flag, 0);
foreach_tcp_flag
#undef _
p->checksum.type = PG_EDIT_UNSPECIFIED;
if (! unformat (input, "TCP: %U -> %U",
unformat_pg_edit,
unformat_tcp_udp_port, &p->ports.src,
unformat_pg_edit,
unformat_tcp_udp_port, &p->ports.dst))
goto error;
/* Parse options. */
while (1)
{
if (unformat (input, "window %U",
unformat_pg_edit,
unformat_pg_number, &p->window))
;
else if (unformat (input, "checksum %U",
unformat_pg_edit,
unformat_pg_number, &p->checksum))
;
/* Flags. */
#define _(f) else if (unformat (input, #f)) pg_edit_set_fixed (&p->f##_flag, 1);
foreach_tcp_flag
#undef _
/* Can't parse input: try next protocol level. */
else
break;
}
{
ip_main_t * im = &ip_main;
u16 dst_port;
tcp_udp_port_info_t * pi;
pi = 0;
if (p->ports.dst.type == PG_EDIT_FIXED)
{
dst_port = pg_edit_get_value (&p->ports.dst, PG_EDIT_LO);
pi = ip_get_tcp_udp_port_info (im, dst_port);
}
if (pi && pi->unformat_pg_edit
&& unformat_user (input, pi->unformat_pg_edit, s))
;
else if (! unformat_user (input, unformat_pg_payload, s))
goto error;
if (p->checksum.type == PG_EDIT_UNSPECIFIED)
{
pg_edit_group_t * g = pg_stream_get_group (s, group_index);
g->edit_function = tcp_pg_edit_function;
g->edit_function_opaque = 0;
}
return 1;
}
error:
/* Free up any edits we may have added. */
pg_free_edit_group (s);
return 0;
}