Decrypted Traffic Steering 回流回注测试通过

This commit is contained in:
luwenpeng
2022-12-06 15:01:42 +08:00
parent 2ee2307265
commit c1d9a1ab0f
11 changed files with 399 additions and 21 deletions

View File

@@ -5,12 +5,11 @@
#include <assert.h>
#include <arpa/inet.h>
#include <linux/tcp.h>
#include <net/if.h>
#include <tfe_utils.h>
#include <tfe_tcp_restore.h>
static unsigned int fd_so_mask = 0x65;
void tfe_tcp_restore_info_dump(const struct tcp_restore_info *info)
{
char str_client_addr[64] = { 0 };
@@ -57,12 +56,13 @@ void tfe_tcp_restore_info_dump(const struct tcp_restore_info *info)
}
}
int tfe_tcp_restore_fd_create(const struct tcp_restore_endpoint *endpoint, const struct tcp_restore_endpoint *peer)
int tfe_tcp_restore_fd_create(const struct tcp_restore_endpoint *endpoint, const struct tcp_restore_endpoint *peer, const char *devname, unsigned int fd_so_mask)
{
int result = 0;
int sockopt = 0;
int sockfd = 0;
char buffer[IFNAMSIZ] = {0};
socklen_t buffer_len = sizeof(buffer);
unsigned int nr_tcp_repair_opts = 0;
struct tcp_repair_opt tcp_repair_opts[8];
struct tcp_repair_window tcp_repair_window = { 0 };
@@ -88,6 +88,21 @@ int tfe_tcp_restore_fd_create(const struct tcp_restore_endpoint *endpoint, const
goto errout;
}
result = setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, devname, strlen(devname));
if (result < 0)
{
TFE_LOG_ERROR(g_default_logger, "failed at setsockopt(SO_BINDTODEVICE) on %d, %d: %s", devname, errno, strerror(errno));
goto errout;
}
result = getsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, buffer, &buffer_len);
if (result < 0)
{
TFE_LOG_ERROR(g_default_logger, "failed at getsockopt(SO_BINDTODEVICE) on %d, %d: %s", devname, errno, strerror(errno));
goto errout;
}
TFE_LOG_DEBUG(g_default_logger, "sockfd %d successfully bound to %s device, so_mask: %x", sockfd, buffer, fd_so_mask);
// Setup TCP REPAIR Status
sockopt = 1;
result = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&sockopt, sizeof(sockopt));