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

Small bug fixes related to cellular connectivity #3926

Merged
merged 3 commits into from
May 24, 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/cmd/nim/nim.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ func (n *nim) includeLastResortPort(ifAttrs netmonitor.IfAttrs) bool {
strings.HasPrefix(ifName, "nbu") ||
strings.HasPrefix(ifName, "nbo") ||
strings.HasPrefix(ifName, "wlan") ||
strings.HasPrefix(ifName, "wwan") ||
strings.HasPrefix(ifName, "keth")
if exclude {
return false
Expand Down
27 changes: 25 additions & 2 deletions pkg/wwan/mmagent/mmdbus/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (c *Client) getModemStatus(modemObj dbus.BusObject) (
simCard := types.WwanSimCard{
SlotNumber: slot,
SlotActivated: isPrimary,
Type: types.SimTypePhysical,
Type: types.SimTypeUnspecified,
State: SIMStateAbsent,
}
if simPath.IsValid() && len(simPath) > 1 {
Expand All @@ -558,6 +558,12 @@ func (c *Client) getModemStatus(modemObj dbus.BusObject) (
var simType uint32
_ = getDBusProperty(c, simObj, SIMPropertyType, &simType)
switch simType {
case SIMTypeUnknown:
// If the SIM type is not recognized, consider SIM card as present
// if ICCID is not empty.
if simCard.ICCID != "" {
simCard.State = SIMStatePresent
}
case SIMTypeESIM:
// eSIM is not supported by EVE (or even by ModemManager) for connection
// establishment, but we still want to at least publish correct status
Expand Down Expand Up @@ -599,6 +605,7 @@ func (c *Client) getModemStatus(modemObj dbus.BusObject) (
// Num apps: 0
// Is eUICC: no
// TODO: should we call mbimcli/qmicli ?
simCard.Type = types.SimTypePhysical
rene marked this conversation as resolved.
Show resolved Hide resolved
simCard.State = SIMStatePresent
}
if !simCard.SlotActivated {
Expand Down Expand Up @@ -1350,9 +1357,12 @@ func (c *Client) reconfigureEpsBearerIfNotRegistered(modemObj dbus.BusObject,
}
var currentSettings map[string]dbus.Variant
_ = getDBusProperty(c, modemObj, Modem3GPPPropertyInitialEpsBearer, &currentSettings)
maskedPasswd := interface{}("***")
maskedVariantPasswd := dbus.MakeVariant(maskedPasswd)
c.log.Warnf("Modem %s is failing to register, "+
"trying to apply settings %+v for the initial EPS bearer (previously: %+v)",
modemObj.Path(), newSettings, currentSettings)
modemObj.Path(), maskPassword(newSettings, maskedPasswd),
rene marked this conversation as resolved.
Show resolved Hide resolved
maskPassword(currentSettings, maskedVariantPasswd))
err = c.callDBusMethod(modemObj, Modem3GPPMethodSetInitialEpsBearer, nil, newSettings)
if err != nil {
err = fmt.Errorf(
Expand All @@ -1365,6 +1375,19 @@ func (c *Client) reconfigureEpsBearerIfNotRegistered(modemObj dbus.BusObject,
modemObj, ModemStateRegistered, changeInitEPSBearerTimeout)
}

// maskPassword creates a copy of the original map with the "password" key's value masked
func maskPassword[Type any](data map[string]Type, maskWith Type) map[string]Type {
maskedData := make(map[string]Type)
for key, value := range data {
if key == "password" {
maskedData[key] = maskWith
} else {
maskedData[key] = value
}
}
return maskedData
}

func (c *Client) setPreferredRATs(modemObj dbus.BusObject,
preferredRATs []types.WwanRAT) error {
var prefModes []uint32
Expand Down
1 change: 1 addition & 0 deletions pkg/wwan/mmagent/mmdbus/mmapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const (
// SIM type
// https://www.freedesktop.org/software/ModemManager/doc/latest/ModemManager/ModemManager-Flags-and-Enumerations.html#MMSimType
const (
SIMTypeUnknown = 0
SIMTypePhysical = 1
SIMTypeESIM = 2
)
Expand Down
Loading