Skip to content

Commit

Permalink
Support using TLDK as gVisor plugin stack
Browse files Browse the repository at this point in the history
This commit supports using TLDK-v2 as a third-party plugin network
stack.

- lib/libtle_glue/gvisor_glue.h: includes plugin stack interfaces
defined by gVisor.
- lib/libtle_glue/gvisor_glue_sockops.c: implements socket operations
used by gVisor.
- lib/libtle_glue/gvisor_glue_stackops.c: implements stack operations
used by gVisor, including pre_initstack and initstack.

Co-developed-by: Tianyu Zhou <albert.zty@antgroup.com>
Co-developed-by: Jianfeng Tan <henry.tjf@antgroup.com>
Signed-off-by: Anqi Shen <amy.saq@antgroup.com>
  • Loading branch information
amysaq2023 committed Apr 2, 2024
1 parent 78c896b commit 9efb0da
Show file tree
Hide file tree
Showing 23 changed files with 4,160 additions and 1,416 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc

DIRS-y += dpdk
DIRS-y += lib
DIRS-y += examples
DIRS-y += test

MAKEFLAGS += --no-print-directory
Expand Down Expand Up @@ -56,7 +55,7 @@ $(DIRS-y): $(RTE_SDK)/mk/rte.vars.mk
CUR_SUBDIR=$(CUR_SUBDIR)/$(@) \
S=$(CURDIR)/$(@) \
RTE_TARGET=$(RTE_TARGET) \
EXTRA_CFLAGS="-fPIC" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(filter-out $(DIRS-y),$(MAKECMDGOALS))

test: libtldk.a libtldk.so
Expand All @@ -68,8 +67,8 @@ libtldk.so: lib
-lpthread -ldl -lnuma

define repack
@echo -- repack $1 ---
@rm -rf tmpxyz; rm -f $1; mkdir tmpxyz; cd tmpxyz; \
@echo -- repack $1 in $2 ---
@rm -rf $2; rm -f $1; mkdir $2; cd $2; \
for f in $(LIBS) ; do \
fn=$$(basename $$f) ; \
echo $$fn ; \
Expand All @@ -78,14 +77,19 @@ define repack
ar x $$f ; \
cd .. ; \
done; \
ar cru ../$1 $$(find */*.o | paste -sd " " -); cd ..; rm -rf tmpxyz
ar cru ../$1 $$(find */*.o | paste -sd " " -); cd ..; rm -rf $2
endef

ifeq ($(SHARED_HUGE),y)
override EXTRA_CFLAGS := $(EXTRA_CFLAGS) -DSHARED_HUGE
endif

RANDOM := $(shell bash -c 'echo $$RANDOM')
libtldk.a: lib
$(eval LIBS = $(wildcard $(DPDK_LIBS_PATH)/librte*.a))
$(call repack,libdpdk.a)
$(call repack,libdpdk.a,tmpdir_$(RANDOM))
$(eval LIBS = $(wildcard $(DPDK_LIBS_PATH)/librte*.a $(TLDK_LIBS_PATH)/*.a))
$(call repack,libtldk.a)
$(call repack,libtldk.a,tmpdir_$(RANDOM))

$(RTE_SDK)/mk/rte.vars.mk:
ifeq ($(RTE_SDK),$(LOCAL_RTE_SDK))
Expand Down
12 changes: 8 additions & 4 deletions dpdk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ DPDK_DEBUG ?= n
DPDK_DESTDIR ?= $(CURDIR)/install
PACKETDRILL ?= n


LPM := n
PCAP := n

B := $(DPDK_BUILD_DIR)
I := $(DPDK_INSTALL_DIR)
DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk -b v18.11
DPDK_GIT_REPO ?= http://dpdk.org/git/dpdk
DPDK_SOURCE := $(B)/dpdk

ifneq (,$(findstring clang,$(CC)))
Expand Down Expand Up @@ -108,7 +112,7 @@ $(B)/custom-config: $(B)/.patch.ok Makefile
$(call set,RTE_BUILD_COMBINE_LIBS,n)
$(call set,RTE_LIBRTE_I40E_16BYTE_RX_DESC,y)
$(call set,RTE_LIBRTE_I40E_ITR_INTERVAL,16)
$(call set,RTE_LIBRTE_PMD_PCAP,y)
$(call set,RTE_LIBRTE_PMD_PCAP,n)
@# enable debug init for device drivers
$(call set,RTE_LIBRTE_I40E_DEBUG_INIT,$(DPDK_DEBUG))
$(call set,RTE_LIBRTE_IXGBE_DEBUG_INIT,$(DPDK_DEBUG))
Expand Down Expand Up @@ -220,7 +224,7 @@ $(B)/.download.ok:
@if [ -e $(DPDK_SOURCE) ] ; \
then rm -rf $(DPDK_SOURCE) ; \
fi
@git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) $(DPDK_SOURCE)
@git clone $(DPDK_GIT_REPO) --branch $(DPDK_VERSION) --depth 1 $(DPDK_SOURCE)
@touch $@

.PHONY: download
Expand All @@ -247,7 +251,7 @@ $(B)/.config.ok: $(B)/.patch.ok $(B)/custom-config
config: $(B)/.config.ok

$(B)/.build.ok: $(DPDK_SOURCE_FILES) $(B)/.config.ok
@make $(DPDK_MAKE_ARGS) install
@make $(DPDK_MAKE_ARGS) install -j
@cp $(I)/.config $(B)/.config
@touch $@

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
From b8d96c46dd4ba4c542d2df78db81ee607328c0a7 Mon Sep 17 00:00:00 2001
From: Chas Williams <chas3@att.com>
Date: Sun, 12 Apr 2020 12:07:27 +0800
Subject: [PATCH] ip_frag: fix IPv6 when MTU sizes not aligned to 8

bytes The same issue was fixed on for the ipv4 version of this routine
in commit 8d4d3a4f7337 ("ip_frag: handle MTU sizes not aligned to 8 bytes").
Briefly, the size of an ipv6 header is always 40 bytes. With an MTU of
1500, this will never produce a multiple of 8 bytes for the frag_size
and this routine can never succeed. Since RTE_ASSERTS are disabled by
default, this failure is typically ignored.

To fix this, round down to the nearest 8 bytes and use this when
producing the fragments.

Fixes: 0aa31d7a5929 ("ip_frag: add IPv6 fragmentation support")
Cc: stable@dpdk.org

Signed-off-by: Chas Williams <chas3@att.com>
Acked-by: Luca Boccassi <bluca@debian.org>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
lib/librte_ip_frag/rte_ip_frag.h | 1 +
lib/librte_ip_frag/rte_ipv6_fragmentation.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h
index a4ccaf9d1..04fd9df52 100644
--- a/lib/librte_ip_frag/rte_ip_frag.h
+++ b/lib/librte_ip_frag/rte_ip_frag.h
@@ -115,6 +115,7 @@ struct rte_ip_frag_tbl {
#define RTE_IPV6_EHDR_MF_MASK 1
#define RTE_IPV6_EHDR_FO_SHIFT 3
#define RTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1))
+#define RTE_IPV6_EHDR_FO_ALIGN (1 << RTE_IPV6_EHDR_FO_SHIFT)

#define RTE_IPV6_FRAG_USED_MASK \
(RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK)
diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
index 62a7e4e83..b9437eb11 100644
--- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c
+++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c
@@ -77,11 +77,14 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
uint32_t out_pkt_pos, in_seg_data_pos;
uint32_t more_in_segs;
uint16_t fragment_offset, frag_size;
+ uint64_t frag_bytes_remaining;

- frag_size = (uint16_t)(mtu_size - sizeof(struct ipv6_hdr));
-
- /* Fragment size should be a multiple of 8. */
- RTE_ASSERT((frag_size & ~RTE_IPV6_EHDR_FO_MASK) == 0);
+ /*
+ * Ensure the IP payload length of all fragments (except the
+ * the last fragment) are a multiple of 8 bytes per RFC2460.
+ */
+ frag_size = RTE_ALIGN_FLOOR(mtu_size - sizeof(struct ipv6_hdr),
+ RTE_IPV6_EHDR_FO_ALIGN);

/* Check that pkts_out is big enough to hold all fragments */
if (unlikely (frag_size * nb_pkts_out <
@@ -111,6 +114,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
/* Reserve space for the IP header that will be built later */
out_pkt->data_len = sizeof(struct ipv6_hdr) + sizeof(struct ipv6_extension_fragment);
out_pkt->pkt_len = sizeof(struct ipv6_hdr) + sizeof(struct ipv6_extension_fragment);
+ frag_bytes_remaining = frag_size;

out_seg_prev = out_pkt;
more_out_segs = 1;
@@ -130,7 +134,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,

/* Prepare indirect buffer */
rte_pktmbuf_attach(out_seg, in_seg);
- len = mtu_size - out_pkt->pkt_len;
+ len = frag_bytes_remaining;
if (len > (in_seg->data_len - in_seg_data_pos)) {
len = in_seg->data_len - in_seg_data_pos;
}
@@ -140,11 +144,11 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
out_pkt->pkt_len);
out_pkt->nb_segs += 1;
in_seg_data_pos += len;
+ frag_bytes_remaining -= len;

/* Current output packet (i.e. fragment) done ? */
- if (unlikely(out_pkt->pkt_len >= mtu_size)) {
+ if (unlikely(frag_bytes_remaining == 0))
more_out_segs = 0;
- }

/* Current input segment done ? */
if (unlikely(in_seg_data_pos == in_seg->data_len)) {
--
2.19.1.6.gb485710b

25 changes: 0 additions & 25 deletions dpdk/dpdk-v18.11_patches/0002-eal-prioritize-constructor.patch

This file was deleted.

44 changes: 44 additions & 0 deletions dpdk/dpdk-v18.11_patches/0002-net-virtio-fix-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 8c4cf399015681eb26487021854fd2c3f7da61b7 Mon Sep 17 00:00:00 2001
From: Jerin Jacob <jerinj@marvell.com>
Date: Tue, 30 Jul 2019 16:34:06 +0530
Subject: [PATCH] net/virtio: fix build

Add extern to variable declaration to avoid some compiler treating it
as variable definition.

build error log:

lib/librte_pmd_virtio.a(vhost_kernel.o):(.rodata+0x110):
multiple definition of `vhost_msg_strings'
lib/librte_pmd_virtio.a(vhost_user.o):(.data.rel.ro.local+0x0):
first defined here
lib/librte_pmd_virtio.a(virtio_user_dev.o):(.rodata+0xe8):
multiple definition of `vhost_msg_strings'
lib/librte_pmd_virtio.a(vhost_user.o):(.data.rel.ro.local+0x0):
first defined here

Fixes: 33d24d65fe2b ("net/virtio-user: abstract backend operations")
Cc: stable@dpdk.org

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/virtio/virtio_user/vhost.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_user/vhost.h b/drivers/net/virtio/virtio_user/vhost.h
index 83a85cc6f..fec85e2d6 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -67,7 +67,7 @@ enum vhost_user_request {
VHOST_USER_MAX
};

-const char * const vhost_msg_strings[VHOST_USER_MAX];
+extern const char * const vhost_msg_strings[VHOST_USER_MAX];

struct vhost_memory_region {
uint64_t guest_phys_addr;
--
2.19.1.6.gb485710b

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 1e0bcf34c6d9e3feaebb379caa9bd2c3aa734a46 Mon Sep 17 00:00:00 2001
From: Reshma Pattan <reshma.pattan@intel.com>
Date: Thu, 2 May 2019 10:33:34 +0100
Subject: [PATCH] [PATCH] mk: disable warning for packed member pointer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

gcc 9 on Fedora 30 gives an error
"taking address of packed member may result in an
unaligned pointer value" warnings.

For clang builds this warning is already disabled,
so disable "-Waddress-of-packed-member" for gcc builds
also.

Snippet of build error:
lib/librte_eal/linux/eal/eal_memalloc.c: In function ‘alloc_seg_walk’:
lib/librte_eal/linux/eal/eal_memalloc.c:768:12: error:
taking address of packed member of ‘struct rte_mem_config’ may result
in an unaligned pointer value [-Werror=address-of-packed-member]
768 | cur_msl = &mcfg->memsegs[msl_idx];
| ^~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Tested-by: David Marchand <david.marchand@redhat.com>
---
mk/toolchain/gcc/rte.vars.mk | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mk/toolchain/gcc/rte.vars.mk b/mk/toolchain/gcc/rte.vars.mk
index d8b99faf6..b852fcfd7 100644
--- a/mk/toolchain/gcc/rte.vars.mk
+++ b/mk/toolchain/gcc/rte.vars.mk
@@ -87,5 +87,8 @@ WERROR_FLAGS += -Wimplicit-fallthrough=2
WERROR_FLAGS += -Wno-format-truncation
endif

+# disable packed member unalign warnings
+WERROR_FLAGS += -Wno-address-of-packed-member
+
export CC AS AR LD OBJCOPY OBJDUMP STRIP READELF
export TOOLCHAIN_CFLAGS TOOLCHAIN_LDFLAGS TOOLCHAIN_ASFLAGS
--
2.19.1.6.gb485710b

33 changes: 0 additions & 33 deletions dpdk/dpdk-v18.11_patches/0003-mbuf-add-single-linked-list.patch

This file was deleted.

Loading

0 comments on commit 9efb0da

Please sign in to comment.