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

Handle set elements that are structured prefixes #8

Conversation

caseydavenport
Copy link
Contributor

For sets that use the "interval" flag, it is possible to include prefixes as elements. In JSON representation, these are returned like so:

{
  "nftables": [
    {
      "metainfo": {
        "version": "1.0.2",
        "release_name": "Lester Gooch",
        "json_schema_version": 1
      }
    },
    {
      "set": {
        "family": "ip",
        "name": "cali40all-ipam-pools",
        "table": "calico",
        "type": "ipv4_addr",
        "handle": 224,
        "flags": [
          "interval"
        ],
        "elem": [
          {
            "prefix": {
              "addr": "192.168.0.0",
              "len": 16
            }
          }
        ]
      }
    }
  ]
}

This change updates ListElements to return these as strings in CIDR notation to match how they are represented when creating the element.

@k8s-ci-robot k8s-ci-robot requested review from aojea and danwinship May 8, 2024 20:59
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 8, 2024
nftables.go Outdated Show resolved Hide resolved
Comment on lines +427 to +434
// - a prefix, expressed as an object:
// {
// "prefix": {
// "addr": "192.168.0.0",
// "len": 16,
// }
// }
//
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is documented https://manpages.debian.org/testing/libnftables1/libnftables-json.5.en.html

PREFIX
{ "prefix": {


        "addr": EXPRESSION,


        "len": NUMBER
}}
Construct an IPv4 or IPv6 prefix consisting of address part in addr and prefix length in len.

@caseydavenport caseydavenport force-pushed the casey-handle-prefix-elements branch from 64b7f64 to ed2cf47 Compare May 9, 2024 17:07
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 9, 2024
@aojea
Copy link
Contributor

aojea commented May 9, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 9, 2024
@danwinship
Copy link
Collaborator

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: caseydavenport, danwinship

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5951417 into kubernetes-sigs:master May 10, 2024
5 checks passed
@caseydavenport caseydavenport deleted the casey-handle-prefix-elements branch May 10, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants