This paper reports on a novel strategy and related algorithm for realizing dynamic routing and grooming into wavelengths of data flows (label switched paths, LSPs) in new generation optical networks based on generalized MPLS (GMPLS). The method allows arbitrary granularities of LSPs. The new generation network is modeled as a multi-layer network consisting of an IP/MPLS layer and an optical layer. In particular, the proposed solution adopts a dynamic routing algorithm based on the Dijkstra algorithm, that makes use of a weight system, integrated with a suitable method for grooming LSPs into wavelengths based on the packing criterion, thus harmonizing the features of MPLS packet flows whose bandwidth vary in a continuous range of values, with the optical world, where the wavelength bandwidth ranges according to discrete values. The weight system is based on the concepts of least resistance routing that allows to evenly distribute the traffic at the MPLS layer, while packing improves the use of optical resources by favoring more filled wavelengths with respect to the emptier ones. To assess the validity of the proposed solution a simulation model has been realized. The results obtained by simulation show that the packing criterion allows reducing the refused bandwidth from two down to about four times, for a network load of 70% and 55%, respectively, when compared with the alternative method named spreading. The dependence of the proposed solution on bandwidth granularity has been also investigated. Moreover, in order to demonstrate the superior performance of the proposed routing solution, a comparison between the proposed strategy with relevant solutions known in the literature, based on either a single or multi-layer approach, is also reported. In order to perform the comparison, all the reference routing solutions that have been considered adopt the packing method for LSP grooming into the lightpaths. The results show that our solution outperforms the others in terms of amount of traffic that can be on-line accommodated. For instance, assuming a blocking probability of 10−3, the proposed solution is able to further reduce the refused bandwidth of the best routing algorithm considered in the analysis by a factor of three times, thanks to the knowledge of optical resource availability.