I understand is UDLD is almost BFD for layer2. Meaning in a control plane and forwarding plane separated router architecture BFD if running on the control plane can detect control plane failures but UDLD cannot be used for that purpose. Now when we use BFD in distributed mode, where forwarding plane takes care of bfd packets, would it be in different from UDLD ? Won't having UDLD and BFD configured together be redundant ?
There's actually quite a significant difference between UDLD and BFD.
UDLD was mainly designed to prevent layer 2 bridging loops between directly connected devices, where a switch would put a port into the forwarding state, in the case of STP for example, when it stops receiving BPDUs due to a uni-directional link. To that end, it sends echo PDUs out the port and listens for replies. There may however be other cases where having UDLD is also beneficial.
BFD is to detect a loss of bidirectional communications between routers that are not necessarily directly connected, to facilitate a quicker route reconvergence in case of neighbor failure by triggering a reconvergence regardless of EGP timers. BFD is session based and can for example be used on physical interfaces, tunnels, AToM xconnects and the like.
UDLD will place the interface into err-disabled shutdown where BFD won't. Therefore BFD will not stop STP loops from forming and not replace UDLD as such.
For more information about UDLD: http://www.cisco.com/c/en/us/support/docs/lan-switching/spanning-tree-protocol/10591-77.html
For more information about BFD: http://www.cisco.com/c/en/us/td/docs/ios/12_0s/feature/guide/fs_bfd.html
What is the difference between UDLD and BFD?
While both UDLD and BFD are designed to detect issues between devices, UDLD is a L2 mechanism and BFD is a L3 mechanism.
UDLD is designed to detect failure on a single L2 link.
BFD is designed to detect failures in between two L3 peers. This can span more than a single L2 link.
This leads us to your next question.
Won't having UDLD and BFD configured together be redundant ?
In some cases yes, but in others no. You would have to evaluate your situation to determine this, keeping in mind that one is attempting to detect L2 failures, while the other is trying to detect L3 failures.
Let's look at a concrete example. Consider two routers (R1 & R2) on the same network connected by fiber to a switch utilizing link aggregation on two ports each (R1/P1, etc).
One day a single strand (R1/P1's transmit strand) has failed. R1/P1 is still able to receive from the switch so could believe the link to be up. Because R1 can believe R1/P1 to be up, it will send traffic to the switch on that port, which will be lost as the switch believes it to be down.
If the BFD session traffic is being carried on R1/P2, BFD may not detect the problem while UDLD would detect the L2 failure.