MPLS L3 VPN Label Selection

Hi:

I just went through the MPLS L3 VPN topic. One thing I did not understand is who and how did the P routers know what labels to swap with ? who and how was this setup ?

Each MPLS router selects a label per prefix, which is then advertised to its neighbors. You can see an example here: