Skip to content

Commit

Permalink
fix: only set gateway if set in context (opennebula)
Browse files Browse the repository at this point in the history
Fix the network config setup.

Signed-off-by: Christian WALDBILLIG <christian@waldbillig.io>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
chrecht authored and smira committed Feb 23, 2024
1 parent 4575dd8 commit c79d69c
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,26 +127,28 @@ func (o *OpenNebula) ParseMetadata(st state.State, oneContextPlain []byte) (*run
},
)

// Parse gateway address and create RouteSpecSpec entry
gateway, err := netip.ParseAddr(oneContext[ifaceName+"_GATEWAY"])
if err != nil {
return nil, fmt.Errorf("failed to parse gateway ip: %w", err)
}
if oneContext[ifaceName+"_GATEWAY"] != "" {
// Parse gateway address and create RouteSpecSpec entry
gateway, err := netip.ParseAddr(oneContext[ifaceName+"_GATEWAY"])
if err != nil {
return nil, fmt.Errorf("failed to parse gateway ip: %w", err)
}

route := network.RouteSpecSpec{
ConfigLayer: network.ConfigPlatform,
Gateway: gateway,
OutLinkName: ifaceNameLower,
Table: nethelpers.TableMain,
Protocol: nethelpers.ProtocolStatic,
Type: nethelpers.TypeUnicast,
Family: nethelpers.FamilyInet4,
Priority: network.DefaultRouteMetric,
}
route := network.RouteSpecSpec{
ConfigLayer: network.ConfigPlatform,
Gateway: gateway,
OutLinkName: ifaceNameLower,
Table: nethelpers.TableMain,
Protocol: nethelpers.ProtocolStatic,
Type: nethelpers.TypeUnicast,
Family: nethelpers.FamilyInet4,
Priority: network.DefaultRouteMetric,
}

route.Normalize()
route.Normalize()

networkConfig.Routes = append(networkConfig.Routes, route)
networkConfig.Routes = append(networkConfig.Routes, route)
}

// Parse DNS servers
dnsServers := strings.Fields(oneContext[ifaceName+"_DNS"])
Expand Down

0 comments on commit c79d69c

Please sign in to comment.