-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use livelinesschecker in non-privileged mode #589
Use livelinesschecker in non-privileged mode #589
Conversation
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
} | ||
defer func() { _ = targetNetNS.Close() }() | ||
|
||
pingGroupRangeFilename := "/proc/sys/net/ipv4/ping_group_range" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be constant
// See https://github.com/go-ping/ping#linux | ||
const groupRange = "0 2147483647" | ||
|
||
func set(ctx context.Context, conn *networkservice.Connection) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func set(ctx context.Context, conn *networkservice.Connection) error { | |
func applyPingGroupRange(ctx context, mech *networkservice.Mechanism) error |
const groupRange = "0 2147483647" | ||
|
||
func set(ctx context.Context, conn *networkservice.Connection) error { | ||
if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism != nil && mechanism.GetVLAN() == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if mechanism := kernel.ToMechanism(conn.GetMechanism()); mechanism != nil && mechanism.GetVLAN() == 0 {
Could be used before using applyPingGroupRange(ctx, mech).
This might improve readability because now the function 'set' is doing two things:
- set ping group range
- check mech.
So with applying the suggestion the function will do only:
- set ping group range
Issue: networkservicemesh/deployments-k8s#9218
Description
We use ping to check the liveliness of the connection. In order not to use the root privileges, we need to set the
/proc/sys/net/ipv4/ping_group_range
value. It allows to create theSOCK_DGRAM
socket type (instead ofSOCK_RAW
) for ping and thus use it in non-privileged mode.