correctly set ethertype, at least for single-IP networks

This commit is contained in:
JackDoan
2025-11-14 11:38:34 -06:00
parent a39d3c79b2
commit 3443d3ffd3
2 changed files with 14 additions and 5 deletions

View File

@@ -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
}