We shall prove that the answer is f:R→R, f(x)=mx+n, with m,n∈R. It is trivial to see that this family of functions satisfy the property.
For the converse, let f with the given property. Consider a,b∈R, a<b, and define
m=b−af(b)−f(a)andn=b−abf(a)−af(b).
We shall show that f(x)=mx+n, for all x∈[a,b]. By way of contradiction, let x0∈[a,b], such that f(x0)=mx0+n. Consider the sets
A={x∈[a,x0]∣f(x)=mx+n}andB={x∈[x0,b]∣f(x)=mx+n}.
A and B are nonempty because a∈A and b∈B. Consider the numbers α=sup(A) and β=inf(B). By the continuity of f we get α∈A, β∈B and α<x0<β. By the hypothesis, there is t∈(0,1) such that
f((1−t)α+tβ)=(1−t)f(α)+tf(β)=m((1−t)α+tβ)+n.
Then γ=(1−t)α+tβ∈(α,β) and f(γ)=mγ+n, in contradiction with the definition of α and β. So, f(x)=mx+n, for all x∈[a,b].
To extend the answer to R, observe that if f:[a,c]→R, c>b is a function obtained from the preceding considerations, say f(x)=m′x+n′, we must have by continuity m=m′, n=n′. The same remark can be made on intervals of the form [c,b] with c<a.