Fix compatibility with MPTCP

This commit is contained in:
世界 2025-10-17 16:26:45 +08:00
parent b42efe2516
commit b49e63f8ef
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 38 additions and 0 deletions

View file

@ -534,6 +534,43 @@ func (r *autoRedirect) nftablesCreateExcludeRules(nft *nftables.Conn, table *nft
nftablesCreateExcludeDestinationIPSet(nft, table, chain, 4, "inet6_route_exclude_address_set", nftables.TableFamilyIPv6, false)
}
mptcpVerdict := expr.VerdictDrop
if r.tunOptions.ExcludeMPTCP {
mptcpVerdict = expr.VerdictReturn
}
nft.AddRule(&nftables.Rule{
Table: table,
Chain: chain,
Exprs: []expr.Any{
&expr.Meta{
Key: expr.MetaKeyL4PROTO,
Register: 1,
},
&expr.Cmp{
Op: expr.CmpOpEq,
Register: 1,
Data: []byte{unix.IPPROTO_TCP},
},
&expr.Exthdr{
DestRegister: 1,
Type: 30,
Offset: 0,
Len: 1,
Flags: unix.NFT_EXTHDR_F_PRESENT,
Op: expr.ExthdrOpTcpopt,
},
&expr.Cmp{
Op: expr.CmpOpEq,
Register: 1,
Data: []byte{1},
},
&expr.Counter{},
&expr.Verdict{
Kind: mptcpVerdict,
},
},
})
return nil
}