mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Modify ICMPv6 source address for "Packet Too Big" messages to a routable address so that it correctly routes to nodes in an yggdrasil /64 subnet
This commit is contained in:
		
							parent
							
								
									0dc1dd6292
								
							
						
					
					
						commit
						bf0413a0c4
					
				
					 2 changed files with 11 additions and 7 deletions
				
			
		| 
						 | 
					@ -130,7 +130,9 @@ func (i *icmpv6) parse_packet_tun(datain []byte) ([]byte, error) {
 | 
				
			||||||
			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
 | 
				
			||||||
				responsePacket, err := i.create_icmpv6_tun(ipv6Header.Src, ipv6.ICMPTypeNeighborAdvertisement, 0,
 | 
									responsePacket, err := i.create_icmpv6_tun(
 | 
				
			||||||
 | 
										ipv6Header.Src, i.mylladdr,
 | 
				
			||||||
 | 
										ipv6.ICMPTypeNeighborAdvertisement, 0,
 | 
				
			||||||
					&icmp.DefaultMessageBody{Data: response})
 | 
										&icmp.DefaultMessageBody{Data: response})
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
					return nil, err
 | 
										return nil, err
 | 
				
			||||||
| 
						 | 
					@ -147,9 +149,9 @@ func (i *icmpv6) parse_packet_tun(datain []byte) ([]byte, error) {
 | 
				
			||||||
	return nil, errors.New("ICMPv6 type not matched")
 | 
						return nil, errors.New("ICMPv6 type not matched")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (i *icmpv6) create_icmpv6_tap(dstmac macAddress, dst net.IP, mtype ipv6.ICMPType, mcode int, mbody icmp.MessageBody) ([]byte, error) {
 | 
					func (i *icmpv6) create_icmpv6_tap(dstmac macAddress, dst net.IP, src net.IP, mtype ipv6.ICMPType, mcode int, mbody icmp.MessageBody) ([]byte, error) {
 | 
				
			||||||
	// Pass through to create_icmpv6_tun
 | 
						// Pass through to create_icmpv6_tun
 | 
				
			||||||
	ipv6packet, err := i.create_icmpv6_tun(dst, mtype, mcode, mbody)
 | 
						ipv6packet, err := i.create_icmpv6_tun(dst, src, mtype, mcode, mbody)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -167,7 +169,7 @@ func (i *icmpv6) create_icmpv6_tap(dstmac macAddress, dst net.IP, mtype ipv6.ICM
 | 
				
			||||||
	return dataout, nil
 | 
						return dataout, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (i *icmpv6) create_icmpv6_tun(dst net.IP, mtype ipv6.ICMPType, mcode int, mbody icmp.MessageBody) ([]byte, error) {
 | 
					func (i *icmpv6) create_icmpv6_tun(dst net.IP, src net.IP, mtype ipv6.ICMPType, mcode int, mbody icmp.MessageBody) ([]byte, error) {
 | 
				
			||||||
	// Create the ICMPv6 message
 | 
						// Create the ICMPv6 message
 | 
				
			||||||
	icmpMessage := icmp.Message{
 | 
						icmpMessage := icmp.Message{
 | 
				
			||||||
		Type: mtype,
 | 
							Type: mtype,
 | 
				
			||||||
| 
						 | 
					@ -176,7 +178,7 @@ func (i *icmpv6) create_icmpv6_tun(dst net.IP, mtype ipv6.ICMPType, mcode int, m
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Convert the ICMPv6 message into []byte
 | 
						// Convert the ICMPv6 message into []byte
 | 
				
			||||||
	icmpMessageBuf, err := icmpMessage.Marshal(icmp.IPv6PseudoHeader(i.mylladdr, dst))
 | 
						icmpMessageBuf, err := icmpMessage.Marshal(icmp.IPv6PseudoHeader(src, dst))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -187,7 +189,7 @@ func (i *icmpv6) create_icmpv6_tun(dst net.IP, mtype ipv6.ICMPType, mcode int, m
 | 
				
			||||||
		NextHeader: 58,
 | 
							NextHeader: 58,
 | 
				
			||||||
		PayloadLen: len(icmpMessageBuf),
 | 
							PayloadLen: len(icmpMessageBuf),
 | 
				
			||||||
		HopLimit:   255,
 | 
							HopLimit:   255,
 | 
				
			||||||
		Src:        i.mylladdr,
 | 
							Src:        src,
 | 
				
			||||||
		Dst:        dst,
 | 
							Dst:        dst,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -163,7 +163,9 @@ func (r *router) sendPacket(bs []byte) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Create the ICMPv6 response from it
 | 
								// Create the ICMPv6 response from it
 | 
				
			||||||
			icmpv6Buf, err := r.core.tun.icmpv6.create_icmpv6_tun(bs[8:24], ipv6.ICMPTypePacketTooBig, 0, ptb)
 | 
								icmpv6Buf, err := r.core.tun.icmpv6.create_icmpv6_tun(
 | 
				
			||||||
 | 
									bs[8:24], bs[24:40],
 | 
				
			||||||
 | 
									ipv6.ICMPTypePacketTooBig, 0, ptb)
 | 
				
			||||||
			if err == nil {
 | 
								if err == nil {
 | 
				
			||||||
				r.recv <- icmpv6Buf
 | 
									r.recv <- icmpv6Buf
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue