mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 20:00:27 +00:00
Don't process ICMPv6 messages when in TUN mode
This commit is contained in:
parent
cc2b6f093c
commit
4e03bdb054
@ -156,6 +156,9 @@ func (i *icmpv6) parse_packet_tun(datain []byte, datamac *[]byte) ([]byte, error
|
|||||||
// Check for a supported message type
|
// Check for a supported message type
|
||||||
switch icmpv6Header.Type {
|
switch icmpv6Header.Type {
|
||||||
case ipv6.ICMPTypeNeighborSolicitation:
|
case ipv6.ICMPTypeNeighborSolicitation:
|
||||||
|
if !i.tun.iface.IsTAP() {
|
||||||
|
return nil, errors.New("Ignoring Neighbor Solicitation in TUN mode")
|
||||||
|
}
|
||||||
response, err := i.handle_ndp(datain[ipv6.HeaderLen:])
|
response, err := i.handle_ndp(datain[ipv6.HeaderLen:])
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Create our ICMPv6 response
|
// Create our ICMPv6 response
|
||||||
@ -173,6 +176,9 @@ func (i *icmpv6) parse_packet_tun(datain []byte, datamac *[]byte) ([]byte, error
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
case ipv6.ICMPTypeNeighborAdvertisement:
|
case ipv6.ICMPTypeNeighborAdvertisement:
|
||||||
|
if !i.tun.iface.IsTAP() {
|
||||||
|
return nil, errors.New("Ignoring Neighbor Advertisement in TUN mode")
|
||||||
|
}
|
||||||
if datamac != nil {
|
if datamac != nil {
|
||||||
var addr address.Address
|
var addr address.Address
|
||||||
var target address.Address
|
var target address.Address
|
||||||
|
@ -214,11 +214,12 @@ func (tun *tunAdapter) read() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if buf[o+6] == 58 {
|
if buf[o+6] == 58 {
|
||||||
// Found an ICMPv6 packet
|
if tun.iface.IsTAP() {
|
||||||
b := make([]byte, n)
|
// Found an ICMPv6 packet
|
||||||
copy(b, buf)
|
b := make([]byte, n)
|
||||||
// tun.icmpv6.recv <- b
|
copy(b, buf)
|
||||||
go tun.icmpv6.parse_packet(b)
|
go tun.icmpv6.parse_packet(b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
packet := append(util.GetBytes(), buf[o:n]...)
|
packet := append(util.GetBytes(), buf[o:n]...)
|
||||||
tun.send <- packet
|
tun.send <- packet
|
||||||
|
Loading…
Reference in New Issue
Block a user