Commit 8ca7ae74 authored by Michael Shao's avatar Michael Shao Committed by Facebook GitHub Bot

Add API to disable UDP6 checksum

Summary: Add APIs to disable rx/tx checksum for UDP over IPV6

Differential Revision: D22487077

fbshipit-source-id: 22af21b108e84782ec0a76ccbc49eaafa73bd266
parent 5d134e78
......@@ -869,6 +869,36 @@ int AsyncUDPSocket::getGRO() {
return gro_.value();
}
bool AsyncUDPSocket::setRxZeroChksum6(FOLLY_MAYBE_UNUSED bool bVal) {
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
if (address().getFamily() != AF_INET6) {
return false;
}
int val = bVal ? 1 : 0;
int ret =
netops::setsockopt(fd_, SOL_UDP, UDP_NO_CHECK6_RX, &val, sizeof(val));
return !ret;
#else
return false;
#endif
}
bool AsyncUDPSocket::setTxZeroChksum6(FOLLY_MAYBE_UNUSED bool bVal) {
#ifdef FOLLY_HAVE_MSG_ERRQUEUE
if (address().getFamily() != AF_INET6) {
return false;
}
int val = bVal ? 1 : 0;
int ret =
netops::setsockopt(fd_, SOL_UDP, UDP_NO_CHECK6_TX, &val, sizeof(val));
return !ret;
#else
return false;
#endif
}
void AsyncUDPSocket::setTrafficClass(int tclass) {
if (netops::setsockopt(
fd_, IPPROTO_IPV6, IPV6_TCLASS, &tclass, sizeof(int)) != 0) {
......
......@@ -383,6 +383,12 @@ class AsyncUDPSocket : public EventHandler {
bool setGRO(bool bVal);
// disable/enable RX zero checksum check for UDP over IPv6
bool setRxZeroChksum6(bool bVal);
// disable/enable TX zero checksum for UDP over IPv6
bool setTxZeroChksum6(bool bVal);
void setTrafficClass(int tclass);
void applyOptions(
......
......@@ -32,6 +32,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/socket.h>
#include <sys/un.h>
......@@ -65,6 +66,14 @@
#define ETH_MAX_MTU 0xFFFFU
#endif
#ifndef UDP_NO_CHECK6_TX
#define UDP_NO_CHECK6_TX 101 /* Disable sending checksum for UDP6X */
#endif
#ifndef UDP_NO_CHECK6_RX
#define UDP_NO_CHECK6_RX 102 /* Disable accpeting checksum for UDP6 */
#endif
#ifndef UDP_SEGMENT
#define UDP_SEGMENT 103
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment