A method for failure detection, wherein the method is applied to a first service provider edge PE device in an Ethernet virtual private network EVPN, the first PE device is connected to a second PE device through an Internet protocol version 6 segment routing SRv6 pseudo wire PW tunnel, and the method comprises: generating an SRv6 packet; wherein, the SRv6 packet comprises a first indicator, which indicates that an inner packet of the SRv6 packet is a bidirectional forwarding detection BFD packet; sending the SRv6 packet to the second PE device, so that when the second PE device is a tail node, the second PE device establishes a BFD session with a head node based on the BFD packet, and when the head node detects that the PW tunnel between the head node and the tail node fails through the BFD session, the head node switches a service flow to a backup tunnel; or, when the second PE device is a splice device, the second PE device transparently transmits the BFD packet to the tail node, so that the BFD session is established between the head node and the tail node, and when the head node detects that the PW tunnel between the head node and the tail node fails through the BFD session, the head node switches the service flow to the backup tunnel; and wherein, each of the head node and the tail node is a node connected to a custom edge CE device, and wherein, the head node is a first multi-protocol label switching MPLS device, and the first PE device is connected to the first MPLS device through a first MPLS pseudo wire PW tunnel; before generating the SRv6 packet, the method comprises: receiving a first MPLS packet sent by the first MPLS device; decapsulating the first MPLS packet, and reading a PW associated control channel ACH field in the first MPLS packet; if a value of the PW ACH field is a BFD control word, extracting the BFD packet following the PW ACH field; wherein, the BFD control word indicates that an inner packet comprised in the first MPLS packet is the BFD packet; generating the SRv6 packet comprises: encapsulating the BFD packet to obtain the SRv6 packet; wherein, a value of an inner routing header field of the SRv6 packet is the first indicator. generating an SRv6 packet; wherein, the SRv6 packet comprises a first indicator, which indicates that an inner packet of the SRv6 packet is a bidirectional forwarding detection BFD packet; sending the SRv6 packet to the second PE device, so that when the second PE device is a tail node, the second PE device establishes a BFD session with a head node based on the BFD packet, and when the head node detects that the PW tunnel between the head node and the tail node fails through the BFD session, the head node switches a service flow to a backup tunnel; or, when the second PE device is a splice device, the second PE device transparently transmits the BFD packet to the tail node, so that the BFD session is established between the head node and the tail node, and when the head node detects that the PW tunnel between the head node and the tail node fails through the BFD session, the head node switches the service flow to the backup tunnel; and wherein, each of the head node and the tail node is a node connected to a custom edge CE device, and wherein, the head node is a first multi-protocol label switching MPLS device, and the first PE device is connected to the first MPLS device through a first MPLS pseudo wire PW tunnel; before generating the SRv6 packet, the method comprises: receiving a first MPLS packet sent by the first MPLS device; decapsulating the first MPLS packet, and reading a PW associated control channel ACH field in the first MPLS packet; if a value of the PW ACH field is a BFD control word, extracting the BFD packet following the PW ACH field; wherein, the BFD control word indicates that an inner packet comprised in the first MPLS packet is the BFD packet; generating the SRv6 packet comprises: encapsulating the BFD packet to obtain the SRv6 packet; wherein, a value of an inner routing header field of the SRv6 packet is the first indicator. receiving a first MPLS packet sent by the first MPLS device; decapsulating the first MPLS packet, and reading a PW associated control channel ACH field in the first MPLS packet; if a value of the PW ACH field is a BFD control word, extracting the BFD packet following the PW ACH field; wherein, the BFD control word indicates that an inner packet comprised in the first MPLS packet is the BFD packet; generating the SRv6 packet comprises: encapsulating the BFD packet to obtain the SRv6 packet; wherein, a value of an inner routing header field of the SRv6 packet is the first indicator.