How to implement PBR for multi wan?

I have am working on an article about MultiWAN with Linux for the Squid-Cache project at:

I want to apply connection mark rules for both outgoing and incoming traffic ie:

  • A connection that was started from WAN connection 1 will be routed back through the connection it was initiated ie WAN1.
  • Force a specific client(by mac or ip address) a mark that will force the a specific routing table.

I do not know where to look for so.. where should I start?