Solution by anakinwang.
We claim the only solution is f(x)≡x.
Proof.
Let P(x,y) denote the problem assertion. It is clear f(x)≡x satisfies P.
To show this is the only solution, observe P(0,0):f(0)=f(0)2, so f(0)∈{0,1}. If f(0)=1, then P(1,0):f(1)=1+f(1), a clear absurdity.
As such, f(0)=0; we have P(x,0):f(x2)=x2 for all x∈R, i.e., f(x)=x for all x≥0. Now, fix some x<0, and pick some y∈(0,−x). Since x2+xy>0, it follows that x2+xy=f(x2+xy)=x2+f(x)y, so f(x)=x for all x∈R, as desired.