A forwarding entry generation method, comprising: sending, by a controller, a plurality of resource allocation request messages to a plurality of network devices in a network slice, to trigger each of the plurality of network devices to allocate a resource based on a corresponding resource allocation request message, wherein the plurality of resource allocation request messages are in a one-to-one correspondence with the plurality of network devices, the resource allocation request message comprises an identifier of the network slice and a resource that needs to be allocated by a corresponding network device to the network slice, and the resource comprises a device processing resource and/or a link resource; receiving, by the controller, a plurality of resource allocation response messages sent by the plurality of network devices, wherein the plurality of resource allocation response messages are in a one-to-one correspondence with the plurality of network devices, the resource allocation response message comprises the identifier of the network slice and a segment identifier of a corresponding network device, the segment identifier is used to identify a resource allocated by the corresponding network device to the network slice, the segment identifier comprises a node segment identifier and/or an adjacency segment identifier, and the resource allocated by each of the plurality of network devices belongs to the network slice; and generating, by the controller based on the plurality of resource allocation response messages, a forwarding table corresponding to the network slice, wherein an identifier of the forwarding table is the identifier of the network slice, the forwarding table comprises a forwarding entry for arriving at a network device in the network slice, and the forwarding entry comprises a segment identifier of a network device on a path of arriving at a destination network device in the forwarding entry. sending, by a controller, a plurality of resource allocation request messages to a plurality of network devices in a network slice, to trigger each of the plurality of network devices to allocate a resource based on a corresponding resource allocation request message, wherein the plurality of resource allocation request messages are in a one-to-one correspondence with the plurality of network devices, the resource allocation request message comprises an identifier of the network slice and a resource that needs to be allocated by a corresponding network device to the network slice, and the resource comprises a device processing resource and/or a link resource; receiving, by the controller, a plurality of resource allocation response messages sent by the plurality of network devices, wherein the plurality of resource allocation response messages are in a one-to-one correspondence with the plurality of network devices, the resource allocation response message comprises the identifier of the network slice and a segment identifier of a corresponding network device, the segment identifier is used to identify a resource allocated by the corresponding network device to the network slice, the segment identifier comprises a node segment identifier and/or an adjacency segment identifier, and the resource allocated by each of the plurality of network devices belongs to the network slice; and generating, by the controller based on the plurality of resource allocation response messages, a forwarding table corresponding to the network slice, wherein an identifier of the forwarding table is the identifier of the network slice, the forwarding table comprises a forwarding entry for arriving at a network device in the network slice, and the forwarding entry comprises a segment identifier of a network device on a path of arriving at a destination network device in the forwarding entry.