Browse Source

Fix SO_MARK setting for UDP outbound connections

SAPikachu 6 years ago
parent
commit
033d2264ff
1 changed files with 5 additions and 0 deletions
  1. 5 0
      transport/internet/sockopt_linux.go

+ 5 - 0
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: