-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* client side, via intra-cluster client * separately, server (listening) side - except HTTPS * add feature flag: `Do-not-Set-Control-Plane-ToS` * separately: - add feature flag: `Trust-Crypto-Safe-Checksums` Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
c2ca3c9
commit 8185be3
Showing
11 changed files
with
160 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,92 @@ | ||
// Package cmn provides common constants, types, and utilities for AIS clients | ||
// and AIStore. | ||
/* | ||
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved. | ||
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package cmn | ||
|
||
import ( | ||
"syscall" | ||
|
||
"github.com/NVIDIA/aistore/cmn/debug" | ||
"github.com/NVIDIA/aistore/cmn/feat" | ||
"github.com/NVIDIA/aistore/cmn/nlog" | ||
) | ||
|
||
func (args *TransportArgs) setSockOpt(_, _ string, c syscall.RawConn) (err error) { | ||
return c.Control(args.ConnControl(c)) | ||
// ref: https://linuxreviews.org/Type_of_Service_(ToS)_and_DSCP_Values | ||
const ( | ||
lowDelayToS = 0x10 | ||
) | ||
|
||
type ( | ||
cntlFunc func(network, address string, c syscall.RawConn) error | ||
) | ||
|
||
func (args *TransportArgs) ServerControl(c syscall.RawConn) { | ||
switch { | ||
case args.SndRcvBufSize > 0 && args.LowLatencyToS: | ||
c.Control(args._sndrcvtos) | ||
case args.SndRcvBufSize > 0: | ||
c.Control(args._sndrcv) | ||
case args.LowLatencyToS && !Rom.Features().IsSet(feat.DontSetControlPlaneToS): | ||
c.Control(args._tos) | ||
} | ||
} | ||
|
||
func (args *TransportArgs) clientControl() cntlFunc { | ||
switch { | ||
case args.SndRcvBufSize > 0 && args.LowLatencyToS: | ||
return args.setSockSndRcvToS | ||
case args.SndRcvBufSize > 0: | ||
return args.setSockSndRcv | ||
case args.LowLatencyToS && !Rom.Features().IsSet(feat.DontSetControlPlaneToS): | ||
return args.setSockToS | ||
} | ||
return nil | ||
} | ||
|
||
// | ||
//--------------------------- low level internals | ||
// | ||
|
||
func (args *TransportArgs) setSockSndRcv(_, _ string, c syscall.RawConn) (err error) { | ||
return c.Control(args._sndrcv) | ||
} | ||
|
||
// buffering is limited by /proc/sys/net/core/rmem_max and /proc/sys/net/core/wmem_max, respectively | ||
func (args *TransportArgs) _sndrcv(fd uintptr) { | ||
err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, args.SndRcvBufSize) | ||
_croak(err) | ||
|
||
err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, args.SndRcvBufSize) | ||
_croak(err) | ||
} | ||
|
||
func (args *TransportArgs) setSockToS(_, _ string, c syscall.RawConn) (err error) { | ||
return c.Control(args._tos) | ||
} | ||
|
||
func (*TransportArgs) _tos(fd uintptr) { | ||
err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, lowDelayToS) | ||
_croak(err) | ||
} | ||
|
||
func (args *TransportArgs) setSockSndRcvToS(_, _ string, c syscall.RawConn) (err error) { | ||
return c.Control(args._sndrcvtos) | ||
} | ||
|
||
func (args *TransportArgs) _sndrcvtos(fd uintptr) { | ||
err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, args.SndRcvBufSize) | ||
_croak(err) | ||
|
||
err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, args.SndRcvBufSize) | ||
_croak(err) | ||
|
||
err = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TOS, lowDelayToS) | ||
_croak(err) | ||
} | ||
|
||
func (args *TransportArgs) ConnControl(_ syscall.RawConn) (cntl func(fd uintptr)) { | ||
cntl = func(fd uintptr) { | ||
// NOTE: is limited by /proc/sys/net/core/rmem_max | ||
err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_RCVBUF, args.SndRcvBufSize) | ||
debug.AssertNoErr(err) | ||
// NOTE: is limited by /proc/sys/net/core/wmem_max | ||
err = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_SNDBUF, args.SndRcvBufSize) | ||
debug.AssertNoErr(err) | ||
func _croak(err error) { | ||
if err != nil { | ||
nlog.ErrorDepth(1, err) | ||
} | ||
return | ||
} |
Oops, something went wrong.