  SmB6 is a mixed-valence compound with flat f-electron bands that have a
propensity to magnetism. Here, using a realistic Gamma8 quartet model, we
investigate the dynamical spin susceptibility and describe the in-gap
collective mode observed in neutron scattering experiments. We show that as the
Sm valence increases with pressure, the magnetic correlations enhance and SmB6
undergoes a first-order phase transition into a metallic antiferromagnetic
state, whose symmetry depends on the model parameters. The magnetic orderings
give rise to distinct band topologies: while the A-type order leads to an
overlap between valence and conduction bands in the form of Dirac nodal lines,
the G-type order has a negative indirect gap with weak Z2 indices. We also
consider the spin polarized phase under a strong magnetic field, and find that
it exhibits Weyl points as well as nodal lines close to the Fermi level. The
magnetic phases show markedly different surface states and tunable bulk
transport properties, with important implications for experiments. Our theory
predicts that a magnetic order can be stabilized also by lifting the Gamma8
cubic symmetry, thus explaining the surface magnetism reported in SmB6.
