brbzull0 commented on code in PR #9905:
URL: https://github.com/apache/trafficserver/pull/9905#discussion_r1247880607
##########
iocore/net/UnixUDPNet.cc:
##########
@@ -326,61 +415,54 @@ UDPNetProcessorInternal::udp_read_from_net(UDPNetHandler
*nh, UDPConnection *xuc
Debug("udp-read", "The UDP packet is truncated");
}
- // fill the IOBufferBlock chain
- int64_t saved = r;
- b = chain.get();
- while (b && saved > 0) {
- if (saved > buffer_size) {
- b->fill(buffer_size);
- saved -= buffer_size;
- b = b->next.get();
- } else {
- b->fill(saved);
- saved = 0;
- next_chain = b->next.get();
- b->next = nullptr;
- }
- }
-
safe_getsockname(xuc->getFd(), reinterpret_cast<struct sockaddr
*>(&toaddr), &toaddr_len);
for (auto cmsg = CMSG_FIRSTHDR(&msg); cmsg != nullptr; cmsg =
CMSG_NXTHDR(&msg, cmsg)) {
- switch (cmsg->cmsg_type) {
-#ifdef IP_PKTINFO
- case IP_PKTINFO:
- if (cmsg->cmsg_level == IPPROTO_IP) {
- struct in_pktinfo *pktinfo =
reinterpret_cast<struct in_pktinfo *>(CMSG_DATA(cmsg));
- reinterpret_cast<sockaddr_in *>(&toaddr)->sin_addr.s_addr =
pktinfo->ipi_addr.s_addr;
- }
+ if (get_ip_address_from_cmsg(cmsg, &toaddr)) {
break;
-#endif
-#ifdef IP_RECVDSTADDR
- case IP_RECVDSTADDR:
- if (cmsg->cmsg_level == IPPROTO_IP) {
- struct in_addr *addr =
reinterpret_cast<struct in_addr *>(CMSG_DATA(cmsg));
- reinterpret_cast<sockaddr_in *>(&toaddr)->sin_addr.s_addr =
addr->s_addr;
+ }
+#ifdef SOL_UDP
+ if (UDP_GRO == cmsg->cmsg_type) {
+ if (nh->is_gro_enabled()) {
+ gso_size = *reinterpret_cast<uint16_t *>(CMSG_DATA(cmsg));
}
break;
+ }
#endif
-#if defined(IPV6_PKTINFO) || defined(IPV6_RECVPKTINFO)
- case IPV6_PKTINFO: // IPV6_RECVPKTINFO uses IPV6_PKTINFO too
- if (cmsg->cmsg_level == IPPROTO_IPV6) {
- struct in6_pktinfo *pktinfo = reinterpret_cast<struct in6_pktinfo
*>(CMSG_DATA(cmsg));
- memcpy(toaddr.sin6_addr.s6_addr, &pktinfo->ipi6_addr, 16);
+ }
+
+ // If we got the gso size, then we need to find out in how many parts this
was spliced.
+ int const parts = gso_size ? static_cast<int>(ceil(static_cast<double>(r)
/ static_cast<double>(gso_size))) : 1;
Review Comment:
> Oh, you mean `r` can be 2500 (1000 + 1000 + 500) where `gso_size` is 1000?
>
Exactly.
> I don't have any better idea to calculate parts faster.
> https://quick-bench.com/q/IC9D3TNEcLCwWgEfoh_Ll3igs2k
does not seems to change much I think.
> Another approach would be get rid of parts. Maybe we can subtract gso_size
from r on every iteration instead (gso_size > would need to be set to r if
gso_size is 0)?
I could probably do that I think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]