From 033d2264ffc47ef591746048ba7b3ad54fcb0bd5 Mon Sep 17 00:00:00 2001 From: SAPikachu Date: Fri, 25 Jan 2019 15:53:24 +0800 Subject: [PATCH] Fix SO_MARK setting for UDP outbound connections --- transport/internet/sockopt_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 6c5afddd0..db1cda9c9 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -70,6 +70,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error { + if config.Mark != 0 { + if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, int(config.Mark)); err != nil { + return newError("failed to set SO_MARK").Base(err) + } + } if isTCPSocket(network) { switch config.Tfo { case SocketConfig_Enable: