mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-22 00:15:37 +01:00
correctly set ethertype, at least for single-IP networks
This commit is contained in:
@@ -43,7 +43,8 @@ type tun struct {
|
||||
useSystemRoutes bool
|
||||
useSystemRoutesBufferSize int
|
||||
|
||||
l *logrus.Logger
|
||||
isV6 bool
|
||||
l *logrus.Logger
|
||||
}
|
||||
|
||||
func (t *tun) Networks() []netip.Prefix {
|
||||
@@ -163,6 +164,9 @@ func newTunGeneric(c *config.C, l *logrus.Logger, file *os.File, vpnNetworks []n
|
||||
useSystemRoutesBufferSize: c.GetInt("tun.use_system_route_table_buffer_size", 0),
|
||||
l: l,
|
||||
}
|
||||
if len(vpnNetworks) != 0 {
|
||||
t.isV6 = vpnNetworks[0].Addr().Is6() //todo what about multi-IP?
|
||||
}
|
||||
|
||||
err := t.reload(c, true)
|
||||
if err != nil {
|
||||
@@ -738,7 +742,7 @@ func (t *tun) AllocSeg(pkt *packet.OutPacket, q int) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
x := pkt.UseSegment(idx, buf)
|
||||
x := pkt.UseSegment(idx, buf, t.isV6)
|
||||
return x, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ func (pkt *OutPacket) Reset() {
|
||||
pkt.wasSegmented = false
|
||||
}
|
||||
|
||||
func (pkt *OutPacket) UseSegment(segID uint16, seg []byte) int {
|
||||
func (pkt *OutPacket) UseSegment(segID uint16, seg []byte, isV6 bool) int {
|
||||
pkt.Valid = true
|
||||
pkt.SegmentIDs = append(pkt.SegmentIDs, segID)
|
||||
pkt.Segments = append(pkt.Segments, seg) //todo do we need this?
|
||||
@@ -56,8 +56,13 @@ func (pkt *OutPacket) UseSegment(segID uint16, seg []byte) int {
|
||||
|
||||
hdr := seg[0 : virtio.NetHdrSize+14]
|
||||
_ = vhdr.Encode(hdr)
|
||||
hdr[virtio.NetHdrSize+14-2] = 0x86
|
||||
hdr[virtio.NetHdrSize+14-1] = 0xdd //todo ipv6 ethertype
|
||||
if isV6 {
|
||||
hdr[virtio.NetHdrSize+14-2] = 0x86
|
||||
hdr[virtio.NetHdrSize+14-1] = 0xdd
|
||||
} else {
|
||||
hdr[virtio.NetHdrSize+14-2] = 0x08
|
||||
hdr[virtio.NetHdrSize+14-1] = 0x00
|
||||
}
|
||||
|
||||
pkt.SegmentHeaders = append(pkt.SegmentHeaders, hdr)
|
||||
pkt.SegmentPayloads = append(pkt.SegmentPayloads, seg[virtio.NetHdrSize+14:])
|
||||
|
||||
Reference in New Issue
Block a user