Functionalization of epoxy resin and the performance of the resultant magnesium-rich primer