networkservicemesh / networkservicemesh/api
Enable kernel.Mechanism to specify IP Tables ipv4 Nat Chains/Rules
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 18
- Forks
- 22
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
Introduce new constant for parameters for kernel.Mechanism:
IPTABLES4_NAT_TEMPLATE = "iptables__nat_template"
And provide helpers:
# Getters and Setters
func (m *Mechanism) SetIPTables4NatTemplate(tmpl string) *Mechanism {}
func (m *Mechanism) GetIPTables4NatTemplate(tmpl string) string {}
# Helper to evaluate the iptables template using a *networkserviceConnection
func (m *Mechanism) EvaluateIPTables4NatTemplate(conn *networkservice.Connection) {}
The ip tables nat template is expected to be a golang text/template to inject a struct with fields:
- NsmInterfaceName - the name of the interface from conn.GetMechanism().GetInterfaceName()
- NsmSrcIPs - the ipv4 addresses from conn.GetContext().GetIPContext(). GetSrcIpAddrs()
- NsmDstIPs - the ipv4 addresses from conn.GetContext().GetIPContext().GetDstIPAddrs()
Example template:
-N NSM_PREROUTE
-A NSM_PREROUTE -j ISTIO_REDIRECT
-I PREROUTING 1 -p tcp -i {{ .NsmInterfaceName }} -j NSM_PREROUTE
-N NSM_OUTPUT
-A NSM_OUTPUT -j DNAT --to-destination {{ .NsmSrcIps[0] }}
-A OUTPUT -p tcp -s 127.0.0.6 -j NSM_OUTPUT
-N NSM_POSTROUTING
-A NSM_POSTROUTING -j SNAT --to-source ${NsmDstIPs[0]}
-A POSTROUTING -p tcp -o ${NSM_INTERFACE} -j NSM_POSTROUTING
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/api/networkservice/mechanisms/kernel and inspect the kernel.Mechanism API, then trace the networkservice.Connection accessors named in the issue. Define the constant and helpers around the specified NAT template fields, and verify that evaluation produces the requested iptables rules from the connection data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100