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 edge-node clustering in mangle table marking with flowlog enabled #4546

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

naiming-zededa
Copy link
Contributor

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 20.90%. Comparing base (42df374) to head (fcdb6a2).
Report is 42 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4546   +/-   ##
=======================================
  Coverage   20.90%   20.90%           
=======================================
  Files          13       13           
  Lines        2894     2894           
=======================================
  Hits          605      605           
  Misses       2163     2163           
  Partials      126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

Run tests

Copy link
Member

@uncleDecart uncleDecart left a comment

Choose a reason for hiding this comment

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

LGTM, from code perspective since we are using new rules only for Kubernetes, I'd do something like this:

func defaultKubernetesIptablesRules() []iptables.Rule {
  // Allow all traffic from Kubernetes pods to Kubernetes services.
  // Note that traffic originating from another node is already D-NATed
  // and will get marked with the kube_pod mark.
  markKubeSvc := iptables.Rule{
    RuleLabel:   "Kubernetes service mark",
    MatchOpts:   []string{"-s", kubePodCIDR.String(), "-d", kubeSvcCIDR.String()},
    Target:      "CONNMARK",
    TargetOpts:  []string{"--set-mark", controlProtoMark("kube_svc")},
    Description: "Mark traffic from Kubernetes pods to Kubernetes services",
  }
  // ...

  return []iptables.Rule{
    markKubeSvc, 
    // ... 
  }
}

func (r *LinuxDpcReconciler) getIntendedMarkingRules(dpc types.DevicePortConfig, intendedIPv4ACLs, intendedIPv6ACLs dg.Graph) {   
  // ...

  if r.HVTypeKube {
    protoMarkV4Rules = append(protoMarkV4Rules, defaultKubernetesIptablesRules()...)
  }
}

And we won't run Kubernetes over ipv6, right?

- similar to the filter table PR lf-edge#4454, this one to allow edge-node
  clustring ip packets to communicate when the device has flowlog
  enabled.

Signed-off-by: Naiming Shen <naiming@zededa.com>
@naiming-zededa
Copy link
Contributor Author

defaultKubernetesIptablesRules()...

Good suggestion, updated. Correct, at the moment of this code, we don't support ipv6 applications for kubernetes.

Copy link
Member

@uncleDecart uncleDecart left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

Re-run tests

@eriknordmark eriknordmark merged commit c1fa6c1 into lf-edge:master Jan 29, 2025
46 of 58 checks passed
@naiming-zededa naiming-zededa deleted the naiming-mangle-cluster branch January 31, 2025 20:08
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.

3 participants