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

[11.0 stable] Make table index part of the IP-rule definition. #4156

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions pkg/pillar/dpcreconciler/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ func (r *LinuxDpcReconciler) getIntendedSrcIPRules(dpc types.DevicePortConfig) d
AdapterIfName: port.IfName,
IPAddr: ipAddr.IP,
Priority: devicenetwork.PbrLocalOrigPrio,
Table: devicenetwork.DPCBaseRTIndex + ifIndex,
}, nil)
}
}
Expand Down
23 changes: 5 additions & 18 deletions pkg/pillar/dpcreconciler/linuxitems/srciprule.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/lf-edge/eve-libs/depgraph"
"github.com/lf-edge/eve/pkg/pillar/base"
"github.com/lf-edge/eve/pkg/pillar/devicenetwork"
"github.com/lf-edge/eve/pkg/pillar/dpcreconciler/genericitems"
"github.com/lf-edge/eve/pkg/pillar/netmonitor"
"github.com/lf-edge/eve/pkg/pillar/utils/netutils"
Expand All @@ -25,6 +24,7 @@ type SrcIPRule struct {
AdapterIfName string
IPAddr net.IP
Priority int
Table int
}

// Name combines interface name with the IP address to construct
Expand All @@ -46,7 +46,7 @@ func (r SrcIPRule) Type() string {
// Equal is a comparison method for two equally-named src-IP-rule instances.
func (r SrcIPRule) Equal(other depgraph.Item) bool {
r2 := other.(SrcIPRule)
return r.Priority == r2.Priority
return r.Priority == r2.Priority && r.Table == r2.Table
}

// External returns false.
Expand All @@ -57,8 +57,8 @@ func (r SrcIPRule) External() bool {
// String describes source-based IP rule.
func (r SrcIPRule) String() string {
return fmt.Sprintf("Source-based IP rule: "+
"{adapter: %s, ifName: %s, ip: %s, prio: %d}",
r.AdapterLL, r.AdapterIfName, r.IPAddr, r.Priority)
"{adapter: %s, ifName: %s, ip: %s, prio: %d, table: %d}",
r.AdapterLL, r.AdapterIfName, r.IPAddr, r.Priority, r.Table)
}

// Dependencies lists the referenced adapter as the only dependency.
Expand Down Expand Up @@ -94,20 +94,7 @@ func (c *SrcIPRuleConfigurator) Create(ctx context.Context, item depgraph.Item)

func (c *SrcIPRuleConfigurator) makeNetlinkRule(rule SrcIPRule) (*netlink.Rule, error) {
r := netlink.NewRule()
ifIdx, exists, err := c.NetworkMonitor.GetInterfaceIndex(rule.AdapterIfName)
if !exists {
// Dependencies should prevent this.
err := fmt.Errorf("missing interface %s", rule.AdapterIfName)
c.Log.Error()
return nil, err
}
if err != nil {
err := fmt.Errorf("GetInterfaceIndex(%s) failed: %v",
rule.AdapterIfName, err)
c.Log.Error()
return nil, err
}
r.Table = devicenetwork.DPCBaseRTIndex + ifIdx
r.Table = rule.Table
r.Priority = rule.Priority
r.Family = netutils.HostFamily(rule.IPAddr)
r.Src = netutils.HostSubnet(rule.IPAddr)
Expand Down
Loading