diff options
author | Neale Ranns <neale@graphiant.com> | 2022-02-15 09:02:27 +0000 |
---|---|---|
committer | Neale Ranns <neale@graphiant.com> | 2022-02-15 09:02:27 +0000 |
commit | f7040f01a57618c899de8d1feb30bcc70b0a45b9 (patch) | |
tree | f23942c61b8a3b8cc496c054d0d2071a85b330c9 /src/vnet | |
parent | cdaf0d8c884ae0f337ef94b0ceb7449c991a3e6c (diff) |
tcp: Do not include the tcp_packet.h file in the ip4_packet.h
Type: refactor
IP4 does not depend on TCP (it's the other way around).
This upside down dependency leads to some nasty circular includes when trying to use ip46_address.h in interface.h
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I4a1bd21543b08b9c1cf1e5563da738414734a878
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/devices/virtio/node.c | 1 | ||||
-rw-r--r-- | src/vnet/devices/virtio/vhost_user_input.c | 1 | ||||
-rw-r--r-- | src/vnet/devices/virtio/virtio.h | 1 | ||||
-rw-r--r-- | src/vnet/flow/flow.h | 1 | ||||
-rw-r--r-- | src/vnet/gso/hdr_offset_parser.h | 1 | ||||
-rw-r--r-- | src/vnet/hash/hash_eth.c | 1 | ||||
-rw-r--r-- | src/vnet/interface_output.h | 1 | ||||
-rw-r--r-- | src/vnet/ip/ip4_inlines.h | 1 | ||||
-rw-r--r-- | src/vnet/ip/ip4_packet.h | 42 | ||||
-rw-r--r-- | src/vnet/ip/ip6_packet.h | 55 | ||||
-rw-r--r-- | src/vnet/ip6-nd/rd_cp_api.c | 1 | ||||
-rw-r--r-- | src/vnet/tcp/tcp_packet.h | 97 |
12 files changed, 106 insertions, 97 deletions
diff --git a/src/vnet/devices/virtio/node.c b/src/vnet/devices/virtio/node.c index bc9afd9cb18..2d2da189d5d 100644 --- a/src/vnet/devices/virtio/node.c +++ b/src/vnet/devices/virtio/node.c @@ -31,6 +31,7 @@ #include <vnet/ip/ip4_packet.h> #include <vnet/ip/ip6_packet.h> #include <vnet/udp/udp_packet.h> +#include <vnet/tcp/tcp_packet.h> #include <vnet/devices/virtio/virtio.h> #include <vnet/devices/virtio/virtio_inline.h> diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c index bdb3d27245b..ffa2d374abf 100644 --- a/src/vnet/devices/virtio/vhost_user_input.c +++ b/src/vnet/devices/virtio/vhost_user_input.c @@ -37,6 +37,7 @@ #include <vnet/devices/devices.h> #include <vnet/feature/feature.h> #include <vnet/udp/udp_packet.h> +#include <vnet/tcp/tcp_packet.h> #include <vnet/interface/rx_queue_funcs.h> #include <vnet/devices/virtio/vhost_user.h> diff --git a/src/vnet/devices/virtio/virtio.h b/src/vnet/devices/virtio/virtio.h index 267d8f94bb1..3784a1bf2e9 100644 --- a/src/vnet/devices/virtio/virtio.h +++ b/src/vnet/devices/virtio/virtio.h @@ -22,6 +22,7 @@ #include <vnet/devices/virtio/vhost_std.h> #include <vnet/devices/virtio/virtio_buffering.h> #include <vnet/gso/gro.h> +#include <vnet/interface.h> #define foreach_virtio_if_flag \ _(0, ADMIN_UP, "admin-up") \ diff --git a/src/vnet/flow/flow.h b/src/vnet/flow/flow.h index 76c1df8a22f..4945f4367c7 100644 --- a/src/vnet/flow/flow.h +++ b/src/vnet/flow/flow.h @@ -18,6 +18,7 @@ #include <vppinfra/clib.h> #include <vppinfra/pcap.h> +#include <vnet/vnet.h> #include <vnet/l3_types.h> #include <vnet/ip/ip4_packet.h> #include <vnet/ip/ip6_packet.h> diff --git a/src/vnet/gso/hdr_offset_parser.h b/src/vnet/gso/hdr_offset_parser.h index b9b885cc58c..999a27880af 100644 --- a/src/vnet/gso/hdr_offset_parser.h +++ b/src/vnet/gso/hdr_offset_parser.h @@ -21,6 +21,7 @@ #include <vnet/ip/ip6_packet.h> #include <vnet/udp/udp_local.h> #include <vnet/udp/udp_packet.h> +#include <vnet/tcp/tcp_packet.h> #include <vnet/vnet.h> #include <vnet/vxlan/vxlan_packet.h> diff --git a/src/vnet/hash/hash_eth.c b/src/vnet/hash/hash_eth.c index 84a21b059be..1ac8b66a1bc 100644 --- a/src/vnet/hash/hash_eth.c +++ b/src/vnet/hash/hash_eth.c @@ -23,6 +23,7 @@ #include <vnet/ip/ip4_packet.h> #include <vnet/ip/ip6_packet.h> #include <vnet/ip/ip6_hop_by_hop_packet.h> +#include <vnet/tcp/tcp_packet.h> #include <vppinfra/lb_hash_hash.h> #include <vnet/hash/hash.h> diff --git a/src/vnet/interface_output.h b/src/vnet/interface_output.h index 786b0ff8e21..b512d9a04a8 100644 --- a/src/vnet/interface_output.h +++ b/src/vnet/interface_output.h @@ -41,6 +41,7 @@ #define __INTERFACE_INLINES_H__ #include <vnet/vnet.h> +#include <vnet/tcp/tcp_packet.h> static_always_inline void vnet_calc_ip4_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ip4, diff --git a/src/vnet/ip/ip4_inlines.h b/src/vnet/ip/ip4_inlines.h index 9a6c8c7f8fb..ca7327fbcdc 100644 --- a/src/vnet/ip/ip4_inlines.h +++ b/src/vnet/ip/ip4_inlines.h @@ -42,6 +42,7 @@ #include <vnet/ip/ip_flow_hash.h> #include <vnet/ip/ip4_packet.h> +#include <vnet/tcp/tcp_packet.h> #define IP_DF 0x4000 /* don't fragment */ diff --git a/src/vnet/ip/ip4_packet.h b/src/vnet/ip/ip4_packet.h index 513a7449b54..2673558e19e 100644 --- a/src/vnet/ip/ip4_packet.h +++ b/src/vnet/ip/ip4_packet.h @@ -41,7 +41,6 @@ #define included_ip4_packet_h #include <vnet/ip/ip_packet.h> /* for ip_csum_t */ -#include <vnet/tcp/tcp_packet.h> /* for tcp_header_t */ #include <vppinfra/byte_order.h> /* for clib_net_to_host_u16 */ #include <vppinfra/warnings.h> /* for WARN_OFF/WARN_ON macro */ @@ -476,47 +475,6 @@ ip4_multicast_ethernet_address (u8 * ethernet_address, ethernet_address[5] = d[3]; } -always_inline void -ip4_tcp_reply_x1 (ip4_header_t * ip0, tcp_header_t * tcp0) -{ - u32 src0, dst0; - - src0 = ip0->src_address.data_u32; - dst0 = ip0->dst_address.data_u32; - ip0->src_address.data_u32 = dst0; - ip0->dst_address.data_u32 = src0; - - src0 = tcp0->src; - dst0 = tcp0->dst; - tcp0->src = dst0; - tcp0->dst = src0; -} - -always_inline void -ip4_tcp_reply_x2 (ip4_header_t * ip0, ip4_header_t * ip1, - tcp_header_t * tcp0, tcp_header_t * tcp1) -{ - u32 src0, dst0, src1, dst1; - - src0 = ip0->src_address.data_u32; - src1 = ip1->src_address.data_u32; - dst0 = ip0->dst_address.data_u32; - dst1 = ip1->dst_address.data_u32; - ip0->src_address.data_u32 = dst0; - ip1->src_address.data_u32 = dst1; - ip0->dst_address.data_u32 = src0; - ip1->dst_address.data_u32 = src1; - - src0 = tcp0->src; - src1 = tcp1->src; - dst0 = tcp0->dst; - dst1 = tcp1->dst; - tcp0->src = dst0; - tcp1->src = dst1; - tcp0->dst = src0; - tcp1->dst = src1; -} - #endif /* included_ip4_packet_h */ /* diff --git a/src/vnet/ip/ip6_packet.h b/src/vnet/ip/ip6_packet.h index fecec7cdf5b..b00eac72c04 100644 --- a/src/vnet/ip/ip6_packet.h +++ b/src/vnet/ip/ip6_packet.h @@ -40,7 +40,7 @@ #ifndef included_ip6_packet_h #define included_ip6_packet_h -#include <vnet/tcp/tcp_packet.h> +#include <vlib/vlib.h> #include <vnet/ip/ip4_packet.h> #include <stdbool.h> @@ -423,59 +423,6 @@ ip6_copy_header (ip6_header_t * dst, const ip6_header_t * src) dst->dst_address.as_uword[1] = src->dst_address.as_uword[1]; } -always_inline void -ip6_tcp_reply_x1 (ip6_header_t * ip0, tcp_header_t * tcp0) -{ - { - ip6_address_t src0, dst0; - - src0 = ip0->src_address; - dst0 = ip0->dst_address; - ip0->src_address = dst0; - ip0->dst_address = src0; - } - - { - u16 src0, dst0; - - src0 = tcp0->src; - dst0 = tcp0->dst; - tcp0->src = dst0; - tcp0->dst = src0; - } -} - -always_inline void -ip6_tcp_reply_x2 (ip6_header_t * ip0, ip6_header_t * ip1, - tcp_header_t * tcp0, tcp_header_t * tcp1) -{ - { - ip6_address_t src0, dst0, src1, dst1; - - src0 = ip0->src_address; - src1 = ip1->src_address; - dst0 = ip0->dst_address; - dst1 = ip1->dst_address; - ip0->src_address = dst0; - ip1->src_address = dst1; - ip0->dst_address = src0; - ip1->dst_address = src1; - } - - { - u16 src0, dst0, src1, dst1; - - src0 = tcp0->src; - src1 = tcp1->src; - dst0 = tcp0->dst; - dst1 = tcp1->dst; - tcp0->src = dst0; - tcp1->src = dst1; - tcp0->dst = src0; - tcp1->dst = src1; - } -} - typedef CLIB_PACKED (struct { u8 data; }) ip6_pad1_option_t; diff --git a/src/vnet/ip6-nd/rd_cp_api.c b/src/vnet/ip6-nd/rd_cp_api.c index 1f0d8587970..3cd55a702e1 100644 --- a/src/vnet/ip6-nd/rd_cp_api.c +++ b/src/vnet/ip6-nd/rd_cp_api.c @@ -13,6 +13,7 @@ * limitations under the License. */ +#include <vnet/vnet.h> #include <vnet/ip6-nd/rd_cp.h> #include <vlibapi/api.h> diff --git a/src/vnet/tcp/tcp_packet.h b/src/vnet/tcp/tcp_packet.h index b0636d871d5..c137ea68108 100644 --- a/src/vnet/tcp/tcp_packet.h +++ b/src/vnet/tcp/tcp_packet.h @@ -16,7 +16,8 @@ #ifndef included_tcp_packet_h #define included_tcp_packet_h -#include <vnet/vnet.h> +#include <vnet/ip/ip4_packet.h> +#include <vnet/ip/ip6_packet.h> /* TCP flags bit 0 first. */ #define foreach_tcp_flag \ @@ -185,6 +186,100 @@ typedef struct #define timestamp_lt(_t1, _t2) ((i32)((_t1)-(_t2)) < 0) #define timestamp_leq(_t1, _t2) ((i32)((_t1)-(_t2)) <= 0) +always_inline void +ip4_tcp_reply_x1 (ip4_header_t *ip0, tcp_header_t *tcp0) +{ + u32 src0, dst0; + + src0 = ip0->src_address.data_u32; + dst0 = ip0->dst_address.data_u32; + ip0->src_address.data_u32 = dst0; + ip0->dst_address.data_u32 = src0; + + src0 = tcp0->src; + dst0 = tcp0->dst; + tcp0->src = dst0; + tcp0->dst = src0; +} + +always_inline void +ip4_tcp_reply_x2 (ip4_header_t *ip0, ip4_header_t *ip1, tcp_header_t *tcp0, + tcp_header_t *tcp1) +{ + u32 src0, dst0, src1, dst1; + + src0 = ip0->src_address.data_u32; + src1 = ip1->src_address.data_u32; + dst0 = ip0->dst_address.data_u32; + dst1 = ip1->dst_address.data_u32; + ip0->src_address.data_u32 = dst0; + ip1->src_address.data_u32 = dst1; + ip0->dst_address.data_u32 = src0; + ip1->dst_address.data_u32 = src1; + + src0 = tcp0->src; + src1 = tcp1->src; + dst0 = tcp0->dst; + dst1 = tcp1->dst; + tcp0->src = dst0; + tcp1->src = dst1; + tcp0->dst = src0; + tcp1->dst = src1; +} + +always_inline void +ip6_tcp_reply_x1 (ip6_header_t *ip0, tcp_header_t *tcp0) +{ + { + ip6_address_t src0, dst0; + + src0 = ip0->src_address; + dst0 = ip0->dst_address; + ip0->src_address = dst0; + ip0->dst_address = src0; + } + + { + u16 src0, dst0; + + src0 = tcp0->src; + dst0 = tcp0->dst; + tcp0->src = dst0; + tcp0->dst = src0; + } +} + +always_inline void +ip6_tcp_reply_x2 (ip6_header_t *ip0, ip6_header_t *ip1, tcp_header_t *tcp0, + tcp_header_t *tcp1) +{ + { + ip6_address_t src0, dst0, src1, dst1; + + src0 = ip0->src_address; + src1 = ip1->src_address; + dst0 = ip0->dst_address; + dst1 = ip1->dst_address; + ip0->src_address = dst0; + ip1->src_address = dst1; + ip0->dst_address = src0; + ip1->dst_address = src1; + } + + { + u16 src0, dst0, src1, dst1; + + src0 = tcp0->src; + src1 = tcp1->src; + dst0 = tcp0->dst; + dst1 = tcp1->dst; + tcp0->src = dst0; + tcp1->src = dst1; + tcp0->dst = src0; + tcp1->dst = src1; + } +} + /** * Parse TCP header options. * |