Adding support for setting IP_TOS/IPV6_TCLASS as a socket option#3300
Adding support for setting IP_TOS/IPV6_TCLASS as a socket option#3300aredmon85 wants to merge 2 commits intoosrg:masterfrom
Conversation
|
You changed gobgp.pb.go and bgp_configs.go by hand? |
Understood, believe this is fixed - regenerated gobgp.pb.go and bgp_configs.go via definition files. |
There was a problem hiding this comment.
Pull request overview
This pull request adds support for configuring the IP_TOS (IPv4 Type of Service) and IPV6_TCLASS (IPv6 Traffic Class) socket options for BGP TCP connections. This feature allows operators to set DSCP values like CS6 (value 192) to ensure BGP control traffic receives proper priority treatment in the network, aligning with RFC 2474 and RFC 4594 standards.
Changes:
- Added
ip-tosconfiguration parameter to transport config supporting both IPv4 and IPv6 - Implemented platform-specific socket option handling across Linux, Darwin, BSD variants, OpenBSD, Windows, and stub platforms
- Updated YANG schema, protobuf definitions, and configuration structures to support the new field
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pyang_plugins/gobgp.yang | Added ip-tos leaf to transport config augmentation |
| proto/api/gobgp.proto | Added ip_tos field to Transport message |
| api/gobgp.pb.go | Generated protobuf code for ip_tos field |
| pkg/config/oc/bgp_configs.go | Added IpTos field to TransportConfig struct with equality check |
| pkg/config/oc/util.go | Added IpTos conversion in peer and peer group API mappings |
| pkg/server/grpc_server.go | Added IpTos conversion from API to config structures |
| pkg/server/fsm.go | Integrated TOS setting in connection initialization and dialer control |
| internal/pkg/netutils/utils.go | Added setSockOptIpTos helper function for IP_TOS/IPV6_TCLASS |
| internal/pkg/netutils/sockopt_linux.go | Implemented SetIPTOSSockopt and added TOS to DialerControl |
| internal/pkg/netutils/sockopt_darwin.go | Implemented SetIpTOSSockopt for macOS |
| internal/pkg/netutils/sockopt_bsd.go | Implemented SetIpTOSSockopt for BSD variants |
| internal/pkg/netutils/sockopt_openbsd.go | Implemented SetIPTOSSockopt and added TOS to DialerControl |
| internal/pkg/netutils/sockopt_windows.go | Added SetIPTOSSockopt returning not-supported error and warning in DialerControl |
| internal/pkg/netutils/sockopt_stub.go | Added SetIpTOSSockopt for unsupported platforms |
| internal/pkg/netutils/sockopt.go | Added SetIPTOSSockopt wrapper but missing TOS handling in DialerControl |
| docs/sources/configuration.md | Added example showing ip-tos configuration usage |
Comments suppressed due to low confidence (1)
internal/pkg/netutils/sockopt.go:76
- Missing TOS handling: The DialerControl function signature now includes a tos parameter, but this implementation doesn't handle it. When tos is non-zero, it should log a warning similar to the other unsupported features, stating that "setting TOS for active connection is not supported".
func DialerControl(logger *slog.Logger, network, address string, c syscall.RawConn, ttl, minTtl uint8, mss uint16, password string, bindInterface string, tos uint8) error {
if password != "" {
logger.Warn("setting md5 for active connection is not supported",
slog.String("Topic", "Peer"),
slog.String("Key", address),
)
}
if ttl != 0 {
logger.Warn("setting ttl for active connection is not supported",
slog.String("Topic", "Peer"),
slog.String("Key", address),
)
}
if minTtl != 0 {
logger.Warn("setting min ttl for active connection is not supported",
slog.String("Topic", "Peer"),
slog.String("Key", address),
)
}
if mss != 0 {
logger.Warn("setting MSS for active connection is not supported",
slog.String("Topic", "Peer"),
slog.String("Key", address),
)
}
return nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Sorry, can you rebase this against the latest master to resolve the conflicts? |
449c264 to
ae2bd0c
Compare
68a9aaa to
553d5c1
Compare
Yes, not a problem - done. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The above members are missing. I fixed and pushed, thanks. |
Thanks for fixing that and merging, much appreciated |
This pull request adds support for configuring IP_TOS/IPV6_TCLASS.
This pull request allows alignment with RFC 2474 and RFC 4594, which both define CS6 as the DiffServ class selector for network control traffic. DSCP class CS6 is widely used to ensure BGP packets are scheduled above most other traffic via high priority TX queues. Using this class with BGP has been widely adopted by several popular closed implementations, including Arista's EOS and Juniper's Junos. (Open source example in FRR).
To support backwards compatibility, the default value used by the operating system is not altered. CS6 (or any other value the operator desires) can be configured optionally under the transport configuration section.
Tested both IPv4 and IPv6 in Ubuntu 24.04 and against Arista EOS:
Example configuration
Packet capture validation
The following
tcpdumpoutput confirms that the configuredip-tos = 192(CS6 / DSCP 48) is applied to both IPv4 and IPv6 BGP TCP sessions.
IPv4 BGP Keepalive exchange
IPv6 BGP Keepalive exchange