Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
U
udpdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ywj
udpdk
Commits
03dc494d
Commit
03dc494d
authored
Nov 03, 2020
by
Leonardo Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: recvfrom returning incorrect value for small packets
parent
841b83bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
apps/pktgen/main.c
apps/pktgen/main.c
+1
-1
udpdk/udpdk_syscall.c
udpdk/udpdk_syscall.c
+6
-0
No files found.
apps/pktgen/main.c
View file @
03dc494d
...
...
@@ -129,7 +129,7 @@ static void usage(void)
printf
(
"%s -c CONFIG -f FUNCTION
\n
"
" -c CONFIG: .ini configuration file"
" -f FUNCTION: 'send' or 'recv'
\n
"
" -l LEN: pa
yload length (not including ETH, IPv4 and UDP headers)
\n
"
" -l LEN: pa
cket length (including 42 bytes for ETH, IPv4 and UDP headers)
\n
"
,
progname
);
}
...
...
udpdk/udpdk_syscall.c
View file @
03dc494d
...
...
@@ -318,6 +318,7 @@ ssize_t udpdk_recvfrom(int sockfd, void *buf, size_t len, int flags,
uint32_t
eff_len
;
// number of bytes to read from this segment
uint32_t
eff_addrlen
;
uint32_t
bytes_left
=
len
;
uint16_t
dgram_payl_len
;
// UDP payload len, inferred from UDP header
unsigned
nb_segs
;
unsigned
offset_payload
;
struct
rte_ether_hdr
*
eth_hdr
;
...
...
@@ -344,6 +345,7 @@ ssize_t udpdk_recvfrom(int sockfd, void *buf, size_t len, int flags,
eth_hdr
=
rte_pktmbuf_mtod
(
pkt
,
struct
rte_ether_hdr
*
);
ip_hdr
=
(
struct
rte_ipv4_hdr
*
)(
eth_hdr
+
1
);
udp_hdr
=
(
struct
rte_udp_hdr
*
)(
ip_hdr
+
1
);
dgram_payl_len
=
rte_be_to_cpu_16
(
udp_hdr
->
dgram_len
)
-
sizeof
(
struct
rte_udp_hdr
);
// Write source address (or part of it if addrlen is too short)
if
(
src_addr
!=
NULL
)
{
...
...
@@ -368,6 +370,10 @@ ssize_t udpdk_recvfrom(int sockfd, void *buf, size_t len, int flags,
sizeof
(
struct
rte_ether_hdr
)
+
sizeof
(
struct
rte_ipv4_hdr
)
+
sizeof
(
struct
rte_udp_hdr
)
:
0
;
// Find how many bytes of data are in this segment
seg_len
=
seg
->
data_len
-
offset_payload
;
if
((
s
==
0
)
&&
(
seg_len
>
dgram_payl_len
))
{
// for very small packets, Ethernet payload is padded to 46 bytes
seg_len
=
dgram_payl_len
;
}
// The amount of data to copy is the minimum between this segment length and the remaining requested bytes
if
(
seg_len
<
bytes_left
)
{
eff_len
=
seg_len
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment