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

Adding support for loading TC eBPF programs on existing ingress and HTB qdisc #359

Merged
merged 1 commit into from Apr 17, 2024

Conversation

jaysheth2
Copy link
Contributor

@jaysheth2 jaysheth2 commented Mar 27, 2024

This PR is the fix for the issue #362
Specifically, in case of Openstack Hypervisors, whenever rate-limit rules are applied (ref: https://wiki.openstack.org/wiki/InstanceResourceQuota#:~:text=quota%3Acpu_period%3D10240000-,Bandwidth,-limits), openstack install HTB and Ingress qdisc. This PR will add support for deploying TC program on the interface with such HTB and Ingress qdisc as well

@jaysheth2 jaysheth2 marked this pull request as ready for review March 28, 2024 06:09
@sanfern sanfern changed the title Adding support for loading elb-agent on existing ingress and HTB qdisc Adding support for loading TC eBPF programs on existing ingress and HTB qdisc Mar 28, 2024
@jaysheth2 jaysheth2 closed this Apr 2, 2024
@jaysheth2 jaysheth2 reopened this Apr 2, 2024
@jaysheth2 jaysheth2 linked an issue Apr 3, 2024 that may be closed by this pull request
@sanfern sanfern added the feat New Feature label Apr 3, 2024
charleskbliu0
charleskbliu0 previously approved these changes Apr 4, 2024
Copy link

@charleskbliu0 charleskbliu0 left a comment

Choose a reason for hiding this comment

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

Looks good

kf/kf_unix.go Outdated
Comment on lines 235 to 248
if iface.Name == ifaceName && qdisc.Kind == "clsact" {
clsactFound = true
}
if iface.Name == ifaceName && qdisc.Kind == "htb" {
htbFound = true
htbHandle = qdisc.Msg.Handle
}
if iface.Name == ifaceName && qdisc.Kind == "ingress" {
ingressFound = true
ingressHandle = qdisc.Msg.Handle
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we convert this into switch statement

Suggested change
if iface.Name == ifaceName && qdisc.Kind == "clsact" {
clsactFound = true
}
if iface.Name == ifaceName && qdisc.Kind == "htb" {
htbFound = true
htbHandle = qdisc.Msg.Handle
}
if iface.Name == ifaceName && qdisc.Kind == "ingress" {
ingressFound = true
ingressHandle = qdisc.Msg.Handle
}
if iface.Name == ifaceName {
switch qdisc.Kind {
case "clsact":
clsactFound = true
case "htb":
htbFound = true
htbHandle = qdisc.Msg.Handle
case "ingress":
ingressFound = true
ingressHandle = qdisc.Msg.Handle
default:
log.Info("qdisc kind for %s : %v", ifaceName, err)
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the newer commit

kf/kf_unix.go Outdated
Comment on lines 396 to 408
if iface.Name == ifaceName && qdisc.Kind == "clsact" {
clsactFound = true
}
if iface.Name == ifaceName && qdisc.Kind == "htb" {
htbFound = true
htbHandle = qdisc.Msg.Handle
}
if iface.Name == ifaceName && qdisc.Kind == "ingress" {
ingressFound = true
ingressHandle = qdisc.Msg.Handle
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we convert this to switch statement as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the newer commit

kf/kf_unix.go Outdated
}
progFD := uint32(bpfRootProg.FD())
// Netlink attribute used in the Linux kernel
bpfFlag := uint32(tc.BpfActDirect)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to relocate line 301 and 303 outside of the block in order to prevent duplicated code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the newer commit

FD: &progFD,
Flags: &bpfFlag,
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to define tc.Attribute{} outside of the block in order to prevent duplicated code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As tc.Attribute{} is the field of tc.Object.Attribute, I would prefer to keep the declaration in place for context.

},
},
}
} else if !clsactFound && !ingressFound && !htbFound {
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO For clarity, this condition block can be relocated to the end as part of the else statement.

pmoroney
pmoroney previously approved these changes Apr 11, 2024
Copy link

@pmoroney pmoroney left a comment

Choose a reason for hiding this comment

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

LGTM, just one small question

ingressFound = true
ingressHandle = qdisc.Msg.Handle
default:
log.Info().Msgf("Un-supported qdisc kind for interface %s ", ifaceName)

Choose a reason for hiding this comment

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

Is this going to be too verbose? Or is it useful to a user who is inspecting the logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it will be useful for debugging on the hypervisors.

Signed-off-by: Jay Sheth <jaykumar.sheth@walmart.com>
Copy link

@charleskbliu0 charleskbliu0 left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link

@pmoroney pmoroney left a comment

Choose a reason for hiding this comment

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

LGTM Thanks :)

@sanfern sanfern merged commit f061e9f into main Apr 17, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

L3AFD support for loading TC program on HTB and Ingress qdisc
4 participants