XTLS/Xray-core · error

LRU size is bigger than subnet size

Error message

LRU size is bigger than subnet size

What it means

writeFull(w, buffer[:chunkLength]) failed while emitting chunk i of a padding turn. This is the pass-through of an underlying transport write error: closed/reset connection, TLS write failure, buffer-overrun timeouts, or a writer whose context was cancelled. The padding layer adds no error of its own here beyond identifying the chunk index.

Source

Thrown at app/dns/fakedns/fake.go:89

	return &Holder{config: conf}, nil
}

func (fkdns *Holder) initializeFromConfig() error {
	return fkdns.initialize(fkdns.config.IpPool, int(fkdns.config.LruSize))
}

func (fkdns *Holder) initialize(ipPoolCidr string, lruSize int) error {
	var ipRange *net.IPNet
	var err error

	if _, ipRange, err = net.ParseCIDR(ipPoolCidr); err != nil {
		return errors.New("Unable to parse CIDR for Fake DNS IP assignment").Base(err).AtError()
	}

	ones, bits := ipRange.Mask.Size()
	rooms := bits - ones
	if math.Log2(float64(lruSize)) >= float64(rooms) {
		return errors.New("LRU size is bigger than subnet size").AtError()
	}
	fkdns.domainToIP = cache.NewLru(lruSize)
	fkdns.ipRange = ipRange
	return nil
}

// GetFakeIPForDomain checks and generates a fake IP for a domain name
func (fkdns *Holder) GetFakeIPForDomain(domain string) []net.Address {
	fkdns.mu.Lock()
	defer fkdns.mu.Unlock()
	if v, ok := fkdns.domainToIP.Get(domain); ok {
		return []net.Address{v.(net.Address)}
	}
	currentTimeMillis := uint64(time.Now().UnixMilli())
	ones, bits := fkdns.ipRange.Mask.Size()
	rooms := bits - ones
	if rooms < 64 {
		currentTimeMillis %= (uint64(1) << rooms)

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Inspect the wrapped error (errors.Unwrap / errors.Is io.ErrClosedPipe, os.ErrDeadlineExceeded) to classify the transport failure
  2. Close and re-establish the connection; padding turns are not resumable
  3. If deadlines hit, align conn write timeouts with the maximum total padding delay the schedule can inject
Defensive patterns

Strategy: try-catch

Try / catch

if err := runPaddingSchedule(reader, writer, isClient, prefix, schedule); err != nil {
    var chunkErr error
    if errors.As(err, &chunkErr) && strings.Contains(err.Error(), "write padding chunk") {
        // transport-level failure: close conn, count the failure, reconnect with backoff
        conn.Close()
        return retryWithBackoff()
    }
    return err
}

Prevention

When it happens

Trigger: Peer disconnects or RSTs mid-handshake while padding turns are being written; write deadline exceeded on the underlying conn; writer wrapped by a component that returns an error (e.g. closed pipe in tests).

Common situations: Client aborts during the padded handshake; proxy/LB idle timeout shorter than the sum of configured padding delays; mobile network切换; test harnesses closing the write side early.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/08da0367e7d39355. Report an issue: GitHub.