Here is a pictorial representation of a proton
This represents the sea of particles that have to be taken into account if one wanted to think in terms of Feynman diagrams.The theory is quantum chromodynamics. QCD leads to:
Confinement, which means that the force between quarks does not diminish as they are separated. Because of this, when you do separate a quark from other quarks, the energy in the gluon field is enough to create another quark pair; they are thus forever bound into hadrons such as the proton and the neutron or the pion and kaon. Although analytically unproven, confinement is widely believed to be true because it explains the consistent failure of free quark searches, and it is easy to demonstrate in lattice QCD.
Thus the three valence quarks are confined within the proton and other hadrons, by numerous exchanges of quark antiquark colored pairs and gluons. These have a mathematical description with four vectors, and it is the invariant mass of the whole conglomerate in the figure that is the mass of the proton, i.e. the instantaneous addition of all four vectors has the four dimensional "length" of the mass of the proton.
Asymptotic freedom, which means that in very high-energy reactions, quarks and gluons interact very weakly creating a quark–gluon plasma.
The existence of jets in e+e- scattering validated the QCD theory for strong interactions, and the quark gluon plasma is part of the studies in experiment in the LHC.
So the mass is from all the four vectors contributing in the bag that is a proton, in the case of the proton mass.
Lattice QCD calculations follow the logic of virtual exchanges , but on the lattice, in order to avoid infinities, and have managed to calculate the mass of the proton:
Lattice QCD has already made successful contact with many experiments. For example, the mass of the proton has been determined theoretically with an error of less than 2 percent.