Skip to content
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

Merged

Conversation

glazychev-art
Copy link
Contributor

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 the SOCK_DGRAM socket type (instead of SOCK_RAW) for ping and thus use it in non-privileged mode.

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
@denis-tingaikin denis-tingaikin merged commit 8f248dc into networkservicemesh:main Jun 19, 2023
}
defer func() { _ = targetNetNS.Close() }()

pingGroupRangeFilename := "/proc/sys/net/ipv4/ping_group_range"
Copy link
Member

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 {
Copy link
Member

@denis-tingaikin denis-tingaikin Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {
Copy link
Member

@denis-tingaikin denis-tingaikin Jun 19, 2023

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:

  1. set ping group range
  2. check mech.

So with applying the suggestion the function will do only:

  1. set ping group range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants