mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-23 08:54:25 +01:00
christ
This commit is contained in:
@@ -309,8 +309,16 @@ func (t *tun) Write(b []byte) (int, error) {
|
|||||||
NumBuffers: 0,
|
NumBuffers: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//use just tun
|
||||||
|
//vnethdrBuf := make([]byte, virtio.NetHdrSize+14+len(b)) //todo WHY
|
||||||
|
//if err := hdr.Encode(vnethdrBuf); err != nil {
|
||||||
|
// //return fmt.Errorf("encode vnethdr: %w", err)
|
||||||
|
//}
|
||||||
|
//copy(vnethdrBuf[virtio.NetHdrSize:], b)
|
||||||
|
//return unix.Write(t.fd, vnethdrBuf)
|
||||||
|
//end
|
||||||
|
|
||||||
err := t.vdev.TransmitPacket(hdr, b)
|
err := t.vdev.TransmitPacket(hdr, b)
|
||||||
//err := t.vdev.TransmitPacket2(b)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,13 @@ func NewDevice(options ...Option) (_ *Device, err error) {
|
|||||||
|
|
||||||
// Advertise the supported features. This isn't much for now.
|
// Advertise the supported features. This isn't much for now.
|
||||||
// TODO: Add feature options and implement proper feature negotiation.
|
// TODO: Add feature options and implement proper feature negotiation.
|
||||||
|
getFeatures, err := vhost.GetFeatures(dev.controlFD)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get features: %w", err)
|
||||||
|
}
|
||||||
|
if getFeatures == 0 {
|
||||||
|
|
||||||
|
}
|
||||||
//const funky = virtio.Feature(1 << 27)
|
//const funky = virtio.Feature(1 << 27)
|
||||||
//features := virtio.FeatureVersion1 | funky // | todo virtio.FeatureNetMergeRXBuffers
|
//features := virtio.FeatureVersion1 | funky // | todo virtio.FeatureNetMergeRXBuffers
|
||||||
features := virtio.FeatureVersion1 | virtio.FeatureNetMergeRXBuffers
|
features := virtio.FeatureVersion1 | virtio.FeatureNetMergeRXBuffers
|
||||||
@@ -179,6 +186,8 @@ func (dev *Device) TransmitPacket(vnethdr virtio.NetHdr, packet []byte) error {
|
|||||||
if err := vnethdr.Encode(vnethdrBuf); err != nil {
|
if err := vnethdr.Encode(vnethdrBuf); err != nil {
|
||||||
return fmt.Errorf("encode vnethdr: %w", err)
|
return fmt.Errorf("encode vnethdr: %w", err)
|
||||||
}
|
}
|
||||||
|
vnethdrBuf[virtio.NetHdrSize+14-2] = 0x86
|
||||||
|
vnethdrBuf[virtio.NetHdrSize+14-1] = 0xdd //todo ipv6 ethertype
|
||||||
outBuffers := [][]byte{vnethdrBuf, packet}
|
outBuffers := [][]byte{vnethdrBuf, packet}
|
||||||
//outBuffers := [][]byte{packet}
|
//outBuffers := [][]byte{packet}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user