-
Notifications
You must be signed in to change notification settings - Fork 835
netem: add Gilbert-Elliot (gemodel) loss support #1210
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
Open
checcoalt
wants to merge
2
commits into
vishvananda:main
Choose a base branch
from
checcoalt:netem-gemodel-loss
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+145
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: vishvananda/netlink
Length of output: 4410
🌐 Web query:
Linux kernel netem NETEM_LOSS_GE nla nested p = 0 accepted💡 Result:
In the Linux kernel's netem (Network Emulator) implementation, NETEM_LOSS_GE refers to the Gilbert-Elliot packet loss model [1]. This model uses a nested Netlink attribute structure to pass parameters between user space (typically the
tctool) and the kernel [2][3]. Thep = 0value in your query refers to the transition probability parameter within the Gilbert-Elliot model configuration [4][3]. When configuringnetem loss gemodelviatc, the parameters correspond to the structurestruct tc_netem_gemodel[3][1]: - p: Probability of transitioning to the bad (lossy) state [4][5]. - r: Probability of exiting the bad state [4][5]. - h: Loss probability in the bad state (often represented as 1-h in documentation) [4][5]. - k1: Loss probability in the good state (often represented as 1-k in documentation) [4][3]. The kernel'sget_loss_clgfunction handles the parsing of these nested attributes [2][3]. It expects the data size to matchsizeof(struct tc_netem_gemodel)[3][6]. If the parameters are provided asp = 0, the kernel accepts this value as a valid probability (specifically, 0% probability of transitioning to the bad state in this context) [4][3]. The input is mapped directly to theclg.a1field in the kernel's internalnetem_sched_datastructure [3][7]. There is no specific mechanism that rejectsp=0as an invalid configuration; rather, it is processed as a standard integer value for the Gilbert-Elliot model [3]. Documentation confirms that the Bernoulli model is a special case of the Gilbert-Elliot model, where setting specific parameters (likep) allows the model to function as a simpler random loss generator [4][8].Citations:
🌐 Web query:
site:codebrowser.dev sch_netem.c get_loss_clg TCA_NETEM_LOSS NLA_F_NESTED NETEM_LOSS_GE💡 Result:
In the Linux kernel, specifically within the network traffic control (tc) subsystem, the terms identified relate to the configuration and handling of netem (Network Emulator) attributes via Netlink messages. 1. TCA_NETEM_LOSS: This is an enumeration value in the Linux kernel (defined in include/uapi/linux/pkt_sched.h) used as a Netlink attribute type to configure packet loss for the netem qdisc [1]. 2. NETEM_LOSS_GE: This represents the "Gilbert-Elliot" packet loss model, also defined in include/uapi/linux/pkt_sched.h within the NETEM_LOSS enumeration [1]. It is used to specify advanced loss patterns beyond simple random loss [1]. 3. NLA_F_NESTED: This is a Netlink flag (defined in include/uapi/linux/netlink.h) used to indicate that an attribute contains a nested list of further attributes [2]. When configuring complex netem attributes (like specific loss models), the kernel often expects them to be nested within a parent Netlink attribute, requiring this flag to be set to ensure proper parsing and validation by the netlink attribute validation logic [3][4]. 4. sch_netem.c and get_loss_clg: While get_loss_clg is not a standard, globally exposed symbol, it refers to the pattern of internal helper functions found in sch_netem.c (and other qdisc implementations) that parse and "get" configuration data—such as loss model parameters (clg likely standing for "Gilbert-Elliot" or a similar configuration model)—from Netlink attributes [1][4][5]. In the context of traffic control, code paths like these utilize the NLA_F_NESTED flag to safely unpack nested structures describing complex loss behaviors, such as the parameters for the NETEM_LOSS_GE model, into the kernel's internal qdisc structures [4][5].
Citations:
🌐 Web query:
sch_netem.c nla_attr_size TCA_NETEM_LOSS NETEM_LOSS_GE nla_f_nested💡 Result:
In the Linux kernel's Network Emulator (netem) implementation (sch_netem.c), these constants and identifiers are used to manage loss models via Netlink attributes [1][2]. TCA_NETEM_LOSS is a Netlink attribute type used to group nested loss model parameters [1][3]. It is defined with the NLA_NESTED policy [3][4], allowing multiple specific loss model parameters to be included within the same nested structure [1][5]. NETEM_LOSS_GE refers to the Gilbert-Elliot loss model, which is one of the supported loss models in netem [1][2]. When userspace configures this model, it passes a struct tc_netem_gemodel containing parameters (p, r, h, k1) [1][3]. NLA_F_NESTED is a flag used by userspace tools (such as iproute2's tc command) when creating nested Netlink attributes [6][7]. When the tc command adds the TCA_NETEM_LOSS attribute, it performs bitwise OR with NLA_F_NESTED (TCA_NETEM_LOSS | NLA_F_NESTED) to indicate to the kernel that the attribute contains further nested attributes [6][8]. The kernel's netem implementation in sch_netem.c includes a get_loss_clg function that uses nla_for_each_nested to iterate through the attributes inside the TCA_NETEM_LOSS nest, identifies them by type (e.g., NETEM_LOSS_GE), and parses the data accordingly [1][5]. The use of nla_attr_size is typically used in the kernel to validate the size of incoming Netlink attributes, including nested ones [3][2].
Citations:
🏁 Script executed:
Repository: vishvananda/netlink
Length of output: 630
Serialize the GE model when any GE parameter is configured.
p = 0is valid for the GE ABI, soGELossP = 0with any nonzero GE parameter still requiresTCA_NETEM_LOSSto select the GE loss model. The currentGELossP > 0check can fall back to the legacy loss model.Proposed fix
🤖 Prompt for AI Agents