mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Clean up / clarify coords sending code.
This commit is contained in:
		
							parent
							
								
									11b0a82c4a
								
							
						
					
					
						commit
						fec7100898
					
				
					 1 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -428,7 +428,7 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
			
		|||
 | 
			
		||||
	var coords []byte
 | 
			
		||||
	// Read IPv6 flowlabel field (20 bits).
 | 
			
		||||
	// XXX(cathugger): is len(bs) validated there?
 | 
			
		||||
	// Assumes packet at least contains IPv6 header.
 | 
			
		||||
	flowlabel := uint(bs[1]&0x0f)<<16 | uint(bs[2])<<8 | uint(bs[3])
 | 
			
		||||
	if flowlabel != 0 {
 | 
			
		||||
		// Now we append something to the coords
 | 
			
		||||
| 
						 | 
				
			
			@ -439,12 +439,13 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
 | 
			
		|||
 | 
			
		||||
		coords = append(coords, sinfo.coords...)            // Start with the real coords
 | 
			
		||||
		coords = append(coords, 0)                          // Then target the local switchport
 | 
			
		||||
		coords = append(coords, wire_encode_uint64(uint64(flowlabel))...) // Then variable-length encoded flowlabel
 | 
			
		||||
		coords = wire_put_uint64(uint64(flowlabel), coords) // Then variable-length encoded flowlabel
 | 
			
		||||
	} else {
 | 
			
		||||
		// 0 value means that flowlabels aren't being generated by OS.
 | 
			
		||||
		// To save bytes, we're not including it, therefore we won't need self-port override either.
 | 
			
		||||
		// So just use sinfo.coords directly to avoid golang GC allocations.
 | 
			
		||||
		// XXX: investigate where flowlabels aren't included, and attempt to look into TCP/UDP/SCTP/DCCP headers' sport/dport fields?
 | 
			
		||||
		// Recent enough Linux kernel supports flowlabels out of the box so this will be rare.
 | 
			
		||||
		// XXX Attempt to look into TCP/UDP/SCTP/DCCP headers' sport/dport fields there?
 | 
			
		||||
		coords = sinfo.coords
 | 
			
		||||
	}
 | 
			
		||||
	payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue