mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	use bbr congestion control on linux, note that we're not doing anything intelligent with the errors right now if setting it fails
This commit is contained in:
		
							parent
							
								
									c600711a8d
								
							
						
					
					
						commit
						8e22d7137a
					
				
					 2 changed files with 29 additions and 1 deletions
				
			
		
							
								
								
									
										28
									
								
								src/yggdrasil/tcp_linux.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/yggdrasil/tcp_linux.go
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					// +build linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package yggdrasil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"syscall"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"golang.org/x/sys/unix"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error {
 | 
				
			||||||
 | 
						var control error
 | 
				
			||||||
 | 
						var bbr error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						control = c.Control(func(fd uintptr) {
 | 
				
			||||||
 | 
							// sys/socket.h: #define	SO_RECV_ANYIF	0x1104
 | 
				
			||||||
 | 
							bbr = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr")
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch {
 | 
				
			||||||
 | 
						case bbr != nil:
 | 
				
			||||||
 | 
							return bbr
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							return control
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
// +build !darwin
 | 
					// +build !darwin,!linux
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package yggdrasil
 | 
					package yggdrasil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue