diff --git a/cmd/internal/switcher/sonic/db/configdb.go b/cmd/internal/switcher/sonic/db/configdb.go index 55b73f5a..d46d008f 100644 --- a/cmd/internal/switcher/sonic/db/configdb.go +++ b/cmd/internal/switcher/sonic/db/configdb.go @@ -14,6 +14,8 @@ const ( untagged = "untagged" vrfName = "vrf_name" portTable = "PORT" + adminStatus = "admin_status" + adminStatusUp = "up" mtu = "mtu" fec = "fec" fecRS = "rs" @@ -25,8 +27,9 @@ type ConfigDB struct { } type Port struct { - Mtu string - FecRs bool + AdminStatus bool + Mtu string + FecRs bool } func newConfigDB(addr string, id int, sep string) *ConfigDB { @@ -176,8 +179,9 @@ func (d *ConfigDB) GetPort(ctx context.Context, interfaceName string) (*Port, er } return &Port{ - Mtu: result[mtu], - FecRs: result[fec] == fecRS, + AdminStatus: result[adminStatus] == adminStatusUp, + Mtu: result[mtu], + FecRs: result[fec] == fecRS, }, nil } @@ -199,3 +203,9 @@ func (d *ConfigDB) SetPortMtu(ctx context.Context, interfaceName string, val str return d.c.HSet(ctx, key, Val{mtu: val}) } + +func (d *ConfigDB) SetAdminStatusUp(ctx context.Context, interfaceName string) error { + key := Key{portTable, interfaceName} + + return d.c.HSet(ctx, key, Val{adminStatus: adminStatusUp}) +} diff --git a/cmd/internal/switcher/sonic/redis/port.go b/cmd/internal/switcher/sonic/redis/port.go index 3d7706bd..03b6b796 100644 --- a/cmd/internal/switcher/sonic/redis/port.go +++ b/cmd/internal/switcher/sonic/redis/port.go @@ -23,7 +23,15 @@ func (a *Applier) ensurePortConfiguration(ctx context.Context, portName, mtu str if p.Mtu != mtu { a.log.Debug("set port mtu to", "port", portName, "mtu", mtu) - return a.db.Config.SetPortMtu(ctx, portName, mtu) + err = a.db.Config.SetPortMtu(ctx, portName, mtu) + if err != nil { + return err + } + } + + if !p.AdminStatus { + a.log.Debug("set admin status to", "port", portName, "admin_status", "up") + return a.db.Config.SetAdminStatusUp(ctx, portName) } return nil