5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-14 04:30:32 +00:00

Merge pull request #171 from neilalexander/backpressure

Use flow label instead of TCP/UDP/SCTP source/destination
This commit is contained in:
Arceliar 2018-07-22 12:40:31 -05:00 committed by GitHub
commit e00ed4c95d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -429,7 +429,7 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
// Specifically, we append a 0, and then arbitrary data // Specifically, we append a 0, and then arbitrary data
// The 0 ensures that the destination node switch forwards to the self peer (router) // The 0 ensures that the destination node switch forwards to the self peer (router)
// The rest is ignored, but it's still part as the coords, so it affects switch queues // The rest is ignored, but it's still part as the coords, so it affects switch queues
// This helps separate traffic streams (protocol + source + dest port) are queued independently // This helps separate traffic streams (coords, flowlabel) to be queued independently
var coords []byte var coords []byte
addUint64 := func(bs []byte) { addUint64 := func(bs []byte) {
// Converts bytes to a uint64 // Converts bytes to a uint64
@ -443,18 +443,10 @@ func (sinfo *sessionInfo) doSend(bs []byte) {
coords = append(coords, wire_encode_uint64(u)...) coords = append(coords, wire_encode_uint64(u)...)
} }
coords = append(coords, sinfo.coords...) // Start with the real coords coords = append(coords, sinfo.coords...) // Start with the real coords
coords = append(coords, 0) // Add an explicit 0 for the destination's self peer coords = append(coords, 0) // Then target the local switchport
addUint64(bs[6:7]) // Byte 6, next header type (e.g. TCP vs UDP) flowlabel := append([]byte(nil), bs[1:4]...)
// Is the next header TCP, UDP, SCTP for finding source port? flowlabel[0] &= 0x0f
// 0x06 (6) = TCP, 0x11 (17) = UDP, 0x84 (132) = SCTP addUint64(flowlabel)
// TODO: Perhaps improve this for other protocols
// TODO: Consider that the Next Header could be an IPv6 Extension Header instead
if bs[6:7][0] == 0x06 || bs[6:7][0] == 0x11 || bs[6:7][0] == 0x84 {
if len(bs) > 44 {
addUint64(bs[40:42]) // Bytes 40-41, source port for TCP/UDP/SCTP
addUint64(bs[42:44]) // Bytes 42-43, destination port for TCP/UDP/SCTP
}
}
payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce) payload, nonce := boxSeal(&sinfo.sharedSesKey, bs, &sinfo.myNonce)
defer util_putBytes(payload) defer util_putBytes(payload)
p := wire_trafficPacket{ p := wire_trafficPacket{