Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions client/firewall/nftables/router_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@
Table: r.workTable,
})

insertReturnTrafficRule(r.conn, r.workTable, r.chains[chainNameRoutingFw])

prio := *nftables.ChainPriorityNATSource - 1
r.chains[chainNameRoutingNat] = r.conn.AddChain(&nftables.Chain{
Name: chainNameRoutingNat,
Expand Down Expand Up @@ -236,9 +234,12 @@
Type: nftables.ChainTypeFilter,
})

// Add the single NAT rule that matches on mark
if err := r.addPostroutingRules(); err != nil {
return fmt.Errorf("add single nat rule: %v", err)
insertReturnTrafficRule(r.conn, r.workTable, r.chains[chainNameRoutingFw])

r.addPostroutingRules()

if err := r.conn.Flush(); err != nil {
return fmt.Errorf("initialize tables: %v", err)
}

if err := r.addMSSClampingRules(); err != nil {
Expand All @@ -250,11 +251,7 @@
}

if err := r.refreshRulesMap(); err != nil {
log.Errorf("failed to clean up rules from FORWARD chain: %s", err)
}

if err := r.conn.Flush(); err != nil {
return fmt.Errorf("initialize tables: %v", err)
log.Errorf("failed to refresh rules: %s", err)
}

return nil
Expand Down Expand Up @@ -695,7 +692,7 @@
}

// addPostroutingRules adds the masquerade rules
func (r *router) addPostroutingRules() error {
func (r *router) addPostroutingRules() {
// First masquerade rule for traffic coming in from WireGuard interface
exprs := []expr.Any{
// Match on the first fwmark
Expand Down Expand Up @@ -762,7 +759,7 @@
Exprs: exprs2,
})

return nil
return

Check failure on line 762 in client/firewall/nftables/router_linux.go

View workflow job for this annotation

GitHub Actions / JS / Lint

S1023: redundant `return` statement (gosimple)

Check failure on line 762 in client/firewall/nftables/router_linux.go

View workflow job for this annotation

GitHub Actions / Linux

S1023: redundant `return` statement (gosimple)
}

// addMSSClampingRules adds MSS clamping rules to prevent fragmentation for forwarded traffic.
Expand Down Expand Up @@ -839,7 +836,7 @@
Exprs: exprsOut,
})

return nil
return r.conn.Flush()
}

// addLegacyRouteRule adds a legacy routing rule for mgmt servers pre route acls
Expand Down Expand Up @@ -1068,7 +1065,7 @@
}
r.conn.InsertRule(inputRule)

return nil
return r.conn.Flush()
}

func (r *router) removeAcceptFilterRules() error {
Expand Down Expand Up @@ -1196,7 +1193,7 @@
for _, chain := range r.chains {
rules, err := r.conn.GetRules(chain.Table, chain)
if err != nil {
return fmt.Errorf(" unable to list rules: %v", err)
return fmt.Errorf("list rules: %w", err)
}
for _, rule := range rules {
if len(rule.UserData) > 0 {
Expand Down
Loading