Skip to content

Commit

Permalink
MEDIUM: Add new global keywords for HAProxy 3.1
Browse files Browse the repository at this point in the history
expose-deprecated-directives
force-cfg-parser-pause
warn-blocked-traffic-after
tune.bufsize.small
tune.disable-fast-forward
tune.h2.be.rxbuf
tune.h2.fe.rxbuf
tune.renice.runtime
tune.renice.startup
  • Loading branch information
oliwer authored and mjuraga committed Dec 2, 2024
1 parent 7d08503 commit aacf9cf
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 9 deletions.
9 changes: 9 additions & 0 deletions config-parser/section-parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ func (p *configParser) getGlobalParser() *Parsers { //nolint: maintidx
addParser(parser, &sequence, &simple.Number{Name: "tune.buffers.limit"})
addParser(parser, &sequence, &simple.Number{Name: "tune.buffers.reserve"})
addParser(parser, &sequence, &simple.Number{Name: "tune.bufsize"})
addParser(parser, &sequence, &simple.Size{Name: "tune.bufsize.small"})
addParser(parser, &sequence, &simple.Number{Name: "tune.comp.maxlevel"})
addParser(parser, &sequence, &simple.Enabled{Name: "tune.disable-zero-copy-forwarding"})
addParser(parser, &sequence, &simple.Enabled{Name: "tune.disable-fast-forward"})
addParser(parser, &sequence, &simple.Number{Name: "tune.events.max-events-at-once"})
addParser(parser, &sequence, &simple.Enabled{Name: "tune.fail-alloc"})
addParser(parser, &sequence, &simple.OnOff{Name: "tune.fd.edge-triggered"})
Expand All @@ -276,10 +278,12 @@ func (p *configParser) getGlobalParser() *Parsers { //nolint: maintidx
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.be.glitches-threshold"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.be.initial-window-size"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.be.max-concurrent-streams"})
addParser(parser, &sequence, &simple.Size{Name: "tune.h2.be.rxbuf"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.fe.glitches-threshold"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.fe.initial-window-size"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.fe.max-concurrent-streams"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.fe.max-total-streams"})
addParser(parser, &sequence, &simple.Size{Name: "tune.h2.fe.rxbuf"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.header-table-size"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.initial-window-size"})
addParser(parser, &sequence, &simple.Number{Name: "tune.h2.max-concurrent-streams"})
Expand Down Expand Up @@ -316,6 +320,8 @@ func (p *configParser) getGlobalParser() *Parsers { //nolint: maintidx
addParser(parser, &sequence, &simple.Number{Name: "tune.rcvbuf.frontend"})
addParser(parser, &sequence, &simple.Number{Name: "tune.rcvbuf.server"})
addParser(parser, &sequence, &simple.Number{Name: "tune.recv_enough"})
addParser(parser, &sequence, &simple.Number{Name: "tune.renice.runtime"})
addParser(parser, &sequence, &simple.Number{Name: "tune.renice.startup"})
addParser(parser, &sequence, &simple.Number{Name: "tune.ring.queues"})
addParser(parser, &sequence, &simple.Number{Name: "tune.runqueue-depth"})
addParser(parser, &sequence, &simple.OnOff{Name: "tune.sched.low-latency"})
Expand Down Expand Up @@ -444,6 +450,9 @@ func (p *configParser) getGlobalParser() *Parsers { //nolint: maintidx
addParser(parser, &sequence, &simple.OnOff{Name: "ocsp-update.mode"})
addParser(parser, &sequence, &simple.Enabled{Name: "h1-accept-payload-with-any-method"})
addParser(parser, &sequence, &simple.Enabled{Name: "h1-do-not-close-on-insecure-transfer-encoding"})
addParser(parser, &sequence, &simple.Enabled{Name: "expose-deprecated-directives"})
addParser(parser, &sequence, &simple.Time{Name: "force-cfg-parser-pause"})
addParser(parser, &sequence, &simple.Time{Name: "warn-blocked-traffic-after"})
// the ConfigSnippet must be at the end to parsers load order to ensure
// the overloading of any option has been declared previously
addParser(parser, &sequence, &parsers.ConfigSnippet{})
Expand Down
9 changes: 9 additions & 0 deletions config-parser/tests/configs/haproxy.cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,22 @@ global
tune.buffers.limit 30
tune.buffers.reserve 3
tune.bufsize 32768
tune.bufsize.small 16k
tune.disable-zero-copy-forwarding
tune.disable-fast-forward
tune.events.max-events-at-once 150
tune.h1.zero-copy-fwd-recv on
tune.h1.zero-copy-fwd-send on
tune.h2.be.glitches-threshold 16
tune.h2.be.rxbuf 8k
tune.h2.fe.glitches-threshold 24
tune.h2.fe.max-total-streams 1048576
tune.h2.fe.rxbuf 32k
tune.h2.zero-copy-fwd-send on
tune.lua.maxmem 65536
tune.pt.zero-copy-forwarding on
tune.renice.runtime -10
tune.renice.startup 8
tune.ring.queues 8
tune.ssl.default-dh-param 2048
tune.quic.reorder-ratio 75
Expand All @@ -57,6 +63,9 @@ global
ssl-default-bind-ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
ssl-load-extra-del-ext
log 127.0.0.1:514 local0 notice
expose-deprecated-directives
force-cfg-parser-pause 1s
warn-blocked-traffic-after 50ms
# random comment before snippet
###_config-snippet_### BEGIN
tune.ssl.default-dh-param 2048
Expand Down
107 changes: 105 additions & 2 deletions configuration/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,15 @@ func parseTuneOptions(p parser.Parser) (*models.TuneOptions, error) { //nolint:g
options.CompMaxlevel = intOption
}

boolOption, err = parseBoolOption(p, "tune.disable-fast-forward")
if err != nil {
return nil, err
}
if boolOption {
isEmpty = false
options.DisableFastForward = boolOption
}

boolOption, err = parseBoolOption(p, "tune.disable-zero-copy-forwarding")
if err != nil {
return nil, err
Expand Down Expand Up @@ -1494,6 +1503,15 @@ func parseTuneOptions(p parser.Parser) (*models.TuneOptions, error) { //nolint:g
options.H2BeMaxConcurrentStreams = intOption
}

intPOption, err = parseSizeOption(p, "tune.h2.be.rxbuf")
if err != nil {
return nil, err
}
if intPOption != nil {
isEmpty = false
options.H2BeRxbuf = intPOption
}

intPOption, err = parseInt64POption(p, "tune.h2.fe.glitches-threshold")
if err != nil {
return nil, err
Expand Down Expand Up @@ -1530,6 +1548,15 @@ func parseTuneOptions(p parser.Parser) (*models.TuneOptions, error) { //nolint:g
options.H2FeMaxTotalStreams = intPOption
}

intPOption, err = parseSizeOption(p, "tune.h2.fe.rxbuf")
if err != nil {
return nil, err
}
if intPOption != nil {
isEmpty = false
options.H2FeRxbuf = intPOption
}

strOption, err = parseOnOffOption(p, "tune.h2.zero-copy-fwd-send")
if err != nil {
return nil, err
Expand All @@ -1548,6 +1575,24 @@ func parseTuneOptions(p parser.Parser) (*models.TuneOptions, error) { //nolint:g
options.PtZeroCopyForwarding = strOption
}

intPOption, err = parseInt64POption(p, "tune.renice.runtime")
if err != nil {
return nil, err
}
if intPOption != nil {
isEmpty = false
options.ReniceRuntime = intPOption
}

intPOption, err = parseInt64POption(p, "tune.renice.startup")
if err != nil {
return nil, err
}
if intPOption != nil {
isEmpty = false
options.ReniceStartup = intPOption
}

if isEmpty {
return nil, nil //nolint:nilnil
}
Expand Down Expand Up @@ -1585,6 +1630,15 @@ func parseTuneBufferOptions(p parser.Parser) (*models.TuneBufferOptions, error)
options.Bufsize = intOption
}

intPOption, err = parseSizeOption(p, "tune.bufsize.small")
if err != nil {
return nil, err
}
if intPOption != nil {
isEmpty = false
options.BufsizeSmall = intPOption
}

intOption, err = parseInt64Option(p, "tune.pipesize")
if err != nil {
return nil, err
Expand Down Expand Up @@ -2122,6 +2176,12 @@ func ParseGlobalSection(p parser.Parser) (*models.Global, error) { //nolint:goco
}
global.EnvironmentOptions = envOptions

exposeDeprecatedDirectives, err := parseBoolOption(p, "expose-deprecated-directives")
if err != nil {
return nil, err
}
global.ExposeDeprecatedDirectives = exposeDeprecatedDirectives

exposeExperimentalDirectives, err := parseBoolOption(p, "expose-experimental-directives")
if err != nil {
return nil, err
Expand All @@ -2140,6 +2200,11 @@ func ParseGlobalSection(p parser.Parser) (*models.Global, error) { //nolint:goco
}
global.FiftyOneDegreesOptions = fiftyOneDegreesOptions

global.ForceCfgParserPause, err = parseTimeoutOption(p, "force-cfg-parser-pause")
if err != nil {
return nil, err
}

gid, err := parseInt64Option(p, "gid")
if err != nil {
return nil, err
Expand Down Expand Up @@ -2460,6 +2525,11 @@ func ParseGlobalSection(p parser.Parser) (*models.Global, error) { //nolint:goco
}
global.Ulimitn = ulimitn

global.WarnBlockedTrafficAfter, err = parseTimeoutOption(p, "warn-blocked-traffic-after")
if err != nil {
return nil, err
}

wurflOptions, err := parseWurflOptions(p)
if err != nil {
return nil, err
Expand Down Expand Up @@ -2995,6 +3065,10 @@ func SerializeGlobalSection(p parser.Parser, data *models.Global, opt *options.C
return err
}

if err := serializeBoolOption(p, "expose-deprecated-directives", data.ExposeDeprecatedDirectives); err != nil {
return err
}

if err := serializeBoolOption(p, "expose-experimental-directives", data.ExposeExperimentalDirectives); err != nil {
return err
}
Expand All @@ -3007,6 +3081,10 @@ func SerializeGlobalSection(p parser.Parser, data *models.Global, opt *options.C
return err
}

if err := serializeTimeoutOption(p, "force-cfg-parser-pause", data.ForceCfgParserPause, opt); err != nil {
return err
}

if err := serializeInt64Option(p, "gid", data.Gid); err != nil {
return err
}
Expand Down Expand Up @@ -3233,6 +3311,10 @@ func SerializeGlobalSection(p parser.Parser, data *models.Global, opt *options.C
return err
}

if err := serializeTimeoutOption(p, "warn-blocked-traffic-after", data.WarnBlockedTrafficAfter, opt); err != nil {
return err
}

return serializeWurflOptions(p, data.WurflOptions)
}

Expand Down Expand Up @@ -3337,6 +3419,9 @@ func serializeTuneBufferOptions(p parser.Parser, options *models.TuneBufferOptio
if err := serializeInt64Option(p, "tune.bufsize", options.Bufsize); err != nil {
return err
}
if err := serializeSizeOption(p, "tune.bufsize.small", options.BufsizeSmall); err != nil {
return err
}
if err := serializeInt64Option(p, "tune.pipesize", options.Pipesize); err != nil {
return err
}
Expand Down Expand Up @@ -3490,7 +3575,7 @@ func serializeTuneZlibOptions(p parser.Parser, options *models.TuneZlibOptions)
return serializeInt64Option(p, "tune.zlib.windowsize", options.Windowsize)
}

func serializeTuneOptions(p parser.Parser, options *models.TuneOptions, configOptions *options.ConfigurationOptions) error { //nolint:gocognit
func serializeTuneOptions(p parser.Parser, options *models.TuneOptions, configOptions *options.ConfigurationOptions) error { //nolint:gocognit,gocyclo,cyclop
if options == nil {
options = &models.TuneOptions{}
}
Expand All @@ -3500,6 +3585,9 @@ func serializeTuneOptions(p parser.Parser, options *models.TuneOptions, configOp
if err := serializeInt64Option(p, "tune.comp.maxlevel", options.CompMaxlevel); err != nil {
return err
}
if err := serializeBoolOption(p, "tune.disable-fast-forward", options.DisableFastForward); err != nil {
return err
}
if err := serializeBoolOption(p, "tune.disable-zero-copy-forwarding", options.DisableZeroCopyForwarding); err != nil {
return err
}
Expand Down Expand Up @@ -3599,6 +3687,9 @@ func serializeTuneOptions(p parser.Parser, options *models.TuneOptions, configOp
if err := serializeInt64Option(p, "tune.h2.be.max-concurrent-streams", options.H2BeMaxConcurrentStreams); err != nil {
return err
}
if err := serializeSizeOption(p, "tune.h2.be.rxbuf", options.H2BeRxbuf); err != nil {
return err
}
if err := serializeInt64POption(p, "tune.h2.fe.glitches-threshold", options.H2FeGlitchesThreshold); err != nil {
return err
}
Expand All @@ -3611,10 +3702,22 @@ func serializeTuneOptions(p parser.Parser, options *models.TuneOptions, configOp
if err := serializeInt64POption(p, "tune.h2.fe.max-total-streams", options.H2FeMaxTotalStreams); err != nil {
return err
}
if err := serializeSizeOption(p, "tune.h2.fe.rxbuf", options.H2FeRxbuf); err != nil {
return err
}
if err := serializeOnOffOption(p, "tune.h2.zero-copy-fwd-send", options.H2ZeroCopyFwdSend); err != nil {
return err
}
return serializeOnOffOption(p, "tune.pt.zero-copy-forwarding", options.PtZeroCopyForwarding)
if err := serializeOnOffOption(p, "tune.pt.zero-copy-forwarding", options.PtZeroCopyForwarding); err != nil {
return err
}
if err := serializeInt64POption(p, "tune.renice.runtime", options.ReniceRuntime); err != nil {
return err
}
if err := serializeInt64POption(p, "tune.renice.startup", options.ReniceStartup); err != nil {
return err
}
return nil
}

func serializeTimeoutOption(p parser.Parser, option string, data *int64, opt *options.ConfigurationOptions) error {
Expand Down
45 changes: 45 additions & 0 deletions models/global_base.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aacf9cf

Please sign in to comment.